• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Serialisation as Marker

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
As we know Serialisable is a marker interface and doesn't have any enforced implementation.
Then how does the whole serialization mechanism work. How does JVM knows internally this.

Is there any inbuilt mechanism underlying this.

Also how is marker interface different in terms of annotations. Are they also same or different.

Thanks in advance
Avinash
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How the marker interface works has been asked and answered many times. Also how/why annotations instead of a marker interface has also been answered multiple times. Fortunately the forums have a search feature. You may like to try it. Also I strongly recommend that you go through some beginner's text on the subject.

Question - Have you read on the subject from any Core Java Fundamental's reference book? Like from 'Head First Java' or from 'Thinking in Java'?
I'd say it will be a good idea to read about Serialization first and then post specific questions if you do not understand a specific thing.

Chan.
 
author
Posts: 23926
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, let's move this topic to Java in General, as Serialization is not really related to forum of "Threads and synchronization".

Avinash Tiwari wrote:
As we know Serialisable is a marker interface and doesn't have any enforced implementation.
Then how does the whole serialization mechanism work. How does JVM knows internally this.

Is there any inbuilt mechanism underlying this.



Serialization is a mechanism of the JVM -- and as such, it seems to allow stuff that violate specification. As for the Serializable interface, the mechanism simply checks it. If the class is Serializable, it can be serialized. Not sure what you mean by "doesn't have any enforced implementation".

Henry
 
Avinash Tiwari
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Thanks for the reply.
As for basic principles of marker interface , yes I do understand they are kind of metadata to a class which JVM might be using.
However the question I have is , does implementing this interface provides kind of type checking only or do they serve other purpose too.

Like the implementer of the logic checks the type for object and determines whether it is of marker and then proceeds with respective business logic.
Is this the case which drove their existence.

However being at class level , the property was enforced on whole class and subclasses and to provide the marker capability to specific granular elements or methods , annotations were brought in.

Thanks
Avinash
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic