aspose file tools
The moose likes Beginning Java and the fly likes Marker Interface methods ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Marker Interface methods ?" Watch "Marker Interface methods ?" New topic
Author

Marker Interface methods ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1300
Marker Interface means they do not have any methods. But Clonable interface has clone() method, Serializable Interface has readObject() and witeObject() methods. How ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
Neither Serializable nor Cloneable has any methods (check their javadocs). That there are methods related to their function that are not part of the actual interfaces indicates a screwed-up design.


Android appsImageJ pluginsJava web charts
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3050
    
    1

Ulf Dittmer wrote:That there are methods related to their function that are not part of the actual interfaces indicates a screwed-up design.


Quoted for truth.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Well, I can see one reason why the methods are not in the interface - that requires them to be public. For Cloneable / clone() I still don't see any problems with that. readObject / writeObject however are intended solely for the serialization mechanism. That's why they're private. If they are part of the interface then they must become public, and any code can call them. For writeObject that probably isn't a real problem, but readObject may leave the object in an inconsistent state, especially if the passed ObjectInputStream's current data does not represent the object.

On a related note: why doesn't ObjectOutputStream.writeObject take Serializable as its parameter instead of Object? Any non-serializable object will lead to an exception, so why not limit it through the compiler?


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marker Interface methods ?
 
Similar Threads
What is advantage of marker interface?
serializable interface
Use of marker interface
Is Runnable a marker interface ?
How does a class gets that functionality from marker interface?