Why does serializable interface has no methods inside it

Aloha
Can anyone please help me with this....Serializable interface has no methods inside it.So how is it useful to the user.Also if I am writing a class which implements Serializable how does JVM know what to do.?

JoachimSauer wrote:
dannyyates wrote:
[The JVM] doesn't know about serialisation [...]Sorry for the nitpick, but that's not completely true. The JVM needs to know about serialisation at least at little bitNo.
since Serialization creates new objects without the code from the constructrs ever being run. ObjectInputStream loads the classes just like any other code would, although it's obviously reading the serialized stream to get that information... and then calls newInstance() on ObjectStreamClass.
And ObjectStreamClass uses reflection to get a constructor (via java.lang.Class getDeclaredConstructor ) and then uses said java.lang.reflect.Constructor to create a new instance via newInstance()
There is no JVM magic. It is all Java code. (With the exception of what java.lang.reflect.Constructor does because at the point it dives into sun packages but you could do the same by calling java.lang.reflect.Constructor)

Similar Messages

  • Why does auto brightness has a bug in iOS 7.1.1 . The brightness switches automatically to higher in bright places but not returns to lower brightness in dark places but when you lock and unlock it becomes normal

    Why does auto brightness has a bug in iOS 7.1.1 . The brightness switches automatically to higher in bright places but not returns to lower brightness in dark places but when you lock and unlock it becomes normal

    Hello,
    Same problem for me. Really a pain in the *** this bug ! Does Apple fixed it. I'm really suprised noone reports this problem  and apple does not adress this.
    Because of that, I cannot give it anymore to children because it hurts the view. Really a shame on the part of apple !
    Regards

  • I m coming from linux platform ... now need my g   to work with vim ... how to install g   which supports C  0x ... why does  not it has repository with apple ... its so easy rather than going to UI ...

    i m coming from linux platform ... now need my g   to work with vim ... how to install g   which supports C  0x ... why does  not it has repository with apple ... its so easy rather than going to UI ...

    tom i have been using ubuntu for c++ project
    i use lambda and atomic (c++0x) but now as I am working on MAC not able to use them
    installed xcode(4.3) and changed compiler settings to LLVM3.1 but still both features are not available
    to compile wanted to have g++ which supports c++0x features ...
    new to MAC (2-3 days) so was in rush to solution
    let me know if you have some suggestion ...
    else will try with eclipse cdt .... 

  • When i try to purchase a song, why does apple id has been disabled comes up

    when i try to purchase a song, why does apple id has been disabled come up?

    We are fellow users on here so we won't know that actual reason, but you might be able to re-enable it via this page : http://iforgot.apple.com
    Or you might need to contact Apple : http://www.apple.com/support/itunes/contact/

  • Why does not JButton have processActionEvent method, unlike Button ?

    java.awt.Button has processActionEvent( ActionEvent e) method which ( as i think ) calls actionPerformed(e) of the registered listeners.
    Why does not javax.swing.JButton have this method ? from where and how is actionPerformed() of JButton called ?
    I want to know how exactly this event is handled ?
    Thanks in advance.

    eng.robo wrote:
    java.awt.Button has processActionEvent( ActionEvent e) method which ( as i think ) calls actionPerformed(e) of the registered listeners.
    Why does not javax.swing.JButton have this method ? from where and how is actionPerformed() of JButton called ?Swing and AWT are very different and you should not expect one to have the methods of the other.
    I want to know how exactly this event is handled ?Have you read the JButton section in the Sun Swing tutorial? This will tell you much. To see exactly how actions are handled in JButtons, I suggest that you open and look through the source code for the AbstractButton and DefaultButtonModel classes.

  • Why does a find and replace method remove whitespace?

    I have method that searches for a string in a FM document and replaces it with a variable. If for example, there was a string foobar that I wanted to replace with the variable barfoo. Then, I expect this text:
    Lorem ipsum dolor sit amet, foobar consectetur adipiscing elit. Vivamus sed purus urna, ac tristique tortor. Nam auctor tellus non enim pulvinar a vestibulum neque tincidunt.
    To be changed to this text:
    Lorem ipsum dolor sit amet, barfoo consectetur adipiscing elit. Vivamus sed purus urna, ac tristique tortor. Nam auctor tellus non enim pulvinar a vestibulum neque tincidunt.
    However, while the text does do the replace it also removes the whitespace between the variable and the text that appears right after the variable so it actually looks looks like this:
    Lorem ipsum dolor sit amet, barfooconsectetur adipiscing elit. Vivamus sed purus urna, ac tristique tortor. Nam auctor tellus non enim pulvinar a vestibulum neque tincidunt.
    Why is the find and replace method removing the whitespace and how do I prevent that from happening? The method is provided below.
    function FindAndReplaceString(pDoc, findString, replaceVariable)
        if (typeof pDoc != 'undefined'&&typeof findString != 'undefined'&&typeof replaceVariable != 'undefined'&&pDoc.ObjectValid()&&findString.length>0&&replaceVariable.length>0)
            var vVarFmtStatus=checkVarFmStatus (pDoc, replaceVariable);
            if (vVarFmtStatus=='In Doc')
                var tr = new TextRange();
                var findParams = new PropVals();
                var frame = pDoc.MainFlowInDoc.FirstTextFrameInFlow;
                var restoreTR = pDoc.TextSelection;
                tr.beg.obj = tr.end.obj = frame.FirstPgf;
                tr.beg.offset = tr.end.offset = 0;
                findParams = AllocatePropVals(1);
                findParams[0].propIdent.num = Constants.FS_FindText;
                findParams[0].propVal.valType = Constants.FT_String;
                findParams[0].propVal.sval = findString;
                tr = pDoc.Find(tr.beg, findParams);
                var vLoopCounter=0;
                while(FA_errno === Constants.FE_Success&&vLoopCounter++< 1000)
                    pDoc.TextSelection = tr;
                    pDoc.Clear(0);
                    var newVar = pDoc.NewAnchoredFormattedVar(replaceVariable, tr.beg);
                    var varLength = newVar.TextRange.end.offset - newVar.TextRange.beg.offset;
                    tr.beg.offset += varLength;
                    tr = pDoc.Find(tr.beg, findParams);
                if (vLoopCounter>0)
                    Log (vLogFileName, 'In the document \''+pDoc.Name+'\', the string \''+findString+'\' was replaced with the variable \''+replaceVariable+'\' '+vLoopCounter+' times.\n')
                if (vLoopCounter>1000)
                    recordErrors (vErrorLog, 'ERROR: In the document "'+pDoc.Name+'", the find and replace operation was stopped after executing '+vLoopCounter+' times. The term being searched for is "'+findString+'" the replacement variable is "'+ replaceVariable+'".')
                pDoc.TextSelection = restoreTR;
                pDoc.ScrollToText(restoreTR);
                } else {
                    recordErrors (vErrorLog, 'ERROR: The find and replace operation failed because the variable '+replaceVariable+' does not exist in the following doc: '+pDoc.Name)
            } else {
                recordErrors (vErrorLog,'Invalid or unitialized parameter passed to function FindAndReplaceString')

    Hi,
    Not at the moment. Please post in http://forums.adobe.com/community/muse/ideas so other users can vote on the feature request.
    Thanks,
    Abhishek

  • Why does this abstract class and method work without implement it?

    hi,
    I have seen many times that in some examples that there are objects made from abstract classes directly. However, in all books, manual and tutorials that I've read explain that we MUST implement those methods in a subclass.
    An example of what I'm saying is the example code here . In a few words that example makes Channels (java.nio.channel) and does operations with them. My problem is in the class to make this channels, because they used the ServerSockeChannel class and socket() method directly despite they are abstracts.
       // Create a new channel: if port == 0, FileChannel on /dev/tty, else
       // a SocketChannel from the first accept on the given port number
    private static ByteChannel newChannel (int netPort)
          throws Exception
          if (netPort == 0) {
             FileInputStream fis = new FileInputStream ("/dev/tty");
             return (fis.getChannel());
          } else {
    //CONFLICT LINES
             ServerSocketChannel ssc = ServerSocketChannel.open(); //<--I have never thought do that!! Anyway, how it is static method may work.
             ssc.socket().bind (new InetSocketAddress (netPort)); //<--but here, this method (socket) is abstract. WHY RETURN A SOCKET????????  this mehod should be empty by default.
             System.out.print ("Waiting for connection on port "
                + netPort + "...");
             System.out.flush();
             ByteChannel channel = ssc.accept();
             ssc.close();
             System.out.println ("Got it");
             return (channel);
       } I test this code and works fine. So why can it be??
    Also, I read that the abstract classes can't have static methods. Is it true???
    Please Help!!
    PS: i have seen this kind of code many times. So i feel that I don't understand how its really the abstract methods are made.
    PS2: I understand that obviously you don't do something like this: *"obj = new AbstractClass(); "*. I dont understand how it could be: ServerSocketChannel ssc = ServerSocketChannel.open(); and the compiler didn't warn.

    molavec wrote:
    ServerSocketChannel ssc = ServerSocketChannel.open(); //<--I have never thought do that!! Anyway, how it is static method may work.
    The static method creates an instance of a class which extends ServerSocketChannel, but is actually another non-abstract class.I thought that, but reading the documentation I saw that about open() method:
    Opens a server-socket channel.
    The new channel is created by invoking the openServerSocketChannel method of the system-wide default SelectorProvider object.
    The new channel's socket is initially unbound; it must be bound to a specific address via one of its socket's bind methods before connections can be accepted.
    ...and the problem is the same openServerSocketChannel is abstract, so i don't understand how it could return a ServerSocketChannel.There is a concrete implementation class that has implemented that method.
    I guess that really the open() method use a SelectorProvider's subclase but it doesn't appear in the doc.It doesn't need to. First, you don't care about those implementation details, and second, you know that if the class is abstract, it must use some concrete subclass.
    Ok, I speak Spanish by default (<-- this sounds like "I am a machine", ^_^' ). So, I didn't know how to say that the method would be {}. Is there a way to say that?? I recommendable for me to know, for the future questions o answers.Not sure what you're saying here. But the other respondent was trying to explain to you the difference between an abstract method and an empty method.
    // abstract method
    public abstract void foo();
    // empty method
    public void bar() {
    Which class does extend ServerSocketChannel? I can not see it.It may be a package-private class or a private nested class. There's no need to document that specific implementation, since you never need to use it directly.

  • Why does Context.INITIAL_CONTEXT_FACTORY has to be vendor specific?

    I have a standalone Java app that reads messages from a JMS queue, and when I create a InitialContext, I give it the property Context.INITIAL_CONTEXT_FACTORY = weblogic.jndi.WLInitialContextFactory.
    Why? I mean, should I as a client not be able to connect to any JMS queue without any knowledge about what vendor this JMS server runs on? Can I give it some Sun standard factory instead that will work?
    Thank you
    Søren

    The problem here is JMS is not a protocol specification like say SOAP, in which the size and format of every message is well defined, written in stone. Neither is JDBC nor JPA, they are just API specifications. We are given a library of interfaces to which we program, and every vendor will give us a concealed form of their implementation. Because of that, there is some point in every one of those APIs where we must specify the implementing clasess, which are free to define their own implementation.
    Does this answer your question? Hope it has been useful.
    Regards
    Jorge

  • Why does "a photo has been found in the iPhoto library that was not imported" message appear every time I open i photo?

    It happens on my iMac, and now that I have transferred some photos from that computer to my MacBook it is happening there, too.  If I say that I don't want to import it, it "saves" it automatically to a file somewhere on the hard drive.  That folder appears empty when opened, so I'm not sure what it's saving.  Every time I open iPhoto it asks me twice before I can proceed, and creates two neat little folders with nothing in them.  If I say that I do want to import the mystery photo, it plunks the nothing that has not been imported in to a Recovered Photos album.  Once again, nothing there.  Any ideas as to how to fix this problem?

    Go to your Pictures Folder and find the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.
    Look there for a Folder called 'Import' or 'Importing'.
    Drag it to the Desktop. *Make no other changes*.
    Start iPhoto. Does that help?
    If it does then look inside that folder on your desktop. Does it contain anything you want? If not you can trash the folder.

  • Why does my iPhone has two names?

    My iPhone 4 has two different names .
    One in My Computer where I enter to copy my photos from it to the my computer, and one in iTunes . Why is that?
    I have attached a photo : http://s8.postimage.org/hjp36vb85/why.png

    You don't understand. Look at the PHOTO . If I change it in iTunes, it only changes ther. In My Computer, where the photos are, it still says "ank"

  • Verizon for one you have very bad customer service, for two why does someone who has a one year warranty have to go into the store to replace my samsung galaxy s4 phone, when all it has done for months is over heat?

    I dont understand why i would need to go into the store for a replacement phone when i have had my phone under one year just because i have had it under one year. My phone has been over heating and i been trying to get a replacement phone, but i dont really have time to go in the store and i really dont see why i can replace my phone over the phone after one year.
    oh and your customer service sucks.
    Thank you

    Broke new phone Verizon couldn't help even give me form for insurance I pay for in their stores.Seperate corp.Had no Internet waited 2 weeks mail me form.They suck.Did run across 1 dude finially knew his stuff and personally handeled many problems.It was after most working there didn't took me month replacement phone mailed.If customers service person seems new ask for someone can fix problems asap.
    >> Edited to comply with the Verizon Wireless Terms of Service <<
    Edited by:  Verizon Moderator

  • Why does Illustrator CC has a B5 preset page setup of 182 x 257 and not 176 x 250 like the EU DIN-standard?

    I just started a document for a series of illustrations for a client; The booklet had to be B5. So i just opened the presets in Illustrator for B5.
    Now that I am starting the final designs, I was going through the specs off the printer and I found out that my document was 182 x 257 mm. This is a Japanese B5 standard. not the EU B5 standard !!!!!
    I happy i found out now!
    Adobe Illustrator developers: go hangout more with your Ps and Id- colleagues, they got it right....
    Paper size - Wikipedia, the free encyclopedia

    It's not a matter of 'correct'. It's a matter of consistence. Why in Id and Ps the ISO-standard and in Ai the JIS-standard?
    btw I mentioned the EU DIN- standard and that is even the  ISO so that is quit international.
    one world!

  • Why does my itunes has an error reported everytime when i get ready to sync my stuff?

    everytime i plug my phone up to itunes, and get ready to sync stuff to my phone...my computer finds an error in itunes .. what do i do ?

    No one even has an idea? I'm lost.

  • Why does InDesign interface keep reverting to dark?

    I keep having to go into preferences and reset the interface to the Light theme, because whenever I open a new InDesign session after switching the computer on it reverts to the Dark UI. I have saved my Workspace and Synced with CC and it still keeps going back to dark. And if I try to Sync rather than reset prefs, I would have expected a conflict with the cloud pref settings, but there is nothing - it just stays dark! Also when this happens I notice that the "Recent" documents list is gone from the file menu.

    I hate the dark interface. I've written long explanations of how I think the dark interface infiltrated the graphics applications.
    However, Adobe put a lot of effort into the dark interface, and many photographers wanted it for Photoshop and then Illustrator and InDesign. And given all that work, I don't think they will change the default.
    Just like they're not going to change the default unit of measurement from picas to inches. And believe me, most people I see have no idea what a pica is, much less how to use it.

  • In iTunes, why does music which has been ripped from a best-of CD continue to show the year of the CD release even after I change the year to the year of the song release in playlists?

    I often rip music from CDs of artists that released songs in the '60s and '70s. When I rip the music, in iTunes it shows the year of the CD release, usually something in the '90s or 2000s. I change the year in 'Get Info' to the correct year, and it changes it fine. However, after a while, it will show the old year again, the year of the CD. This is a problem because I like to arrange playlists based on song years, and this messes with that.
    Tell me: is there a way to permanently fix the reverting year problem? Also, when I spot a song that this has happened to, when I click on 'Get Info', the correct ear is still in there, and when I hit 'OK' it changes back. This is really frustrating...

    In some cases the original iTunes Store metadata seems to be given preference over personal changes. If you are seeing this then
    Go to Edit > Preferences > Store and turn off
    Show iTunes in the Cloud purchases
    Share details about your library with Apple
    On any iOS device go to Settings > Music and turn off
    Show All Music
    Close and reopen iTunes and/or reset the device and you should see your version of the metadata for each track rather than the original store data. If not it should reset as you play through content, or you can use my script UpdateTagInfo to force iTunes to read the current data from the tags.
    tt2

Maybe you are looking for