Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marker interface related question

 
pink yadav
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
1) Can we create our marker interface in java without extends Serializable Interface
2) Otherwise how can we instruct to jvm this is my marker interface if we create.
3) How JVM will know the default marker interface or is there any specification java using to indicate to jvm



 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to get the wrong idea about marker interface. java.io.Serializable is an example of a marker interface in the sense that its purpose is only to tell that the class is serializable. It has no method at all.

A better way to achieve the same thing is to use annotation.

Hope it helps.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM doesn't need to know about any marker interface you create (and it won't). And there is no "default" marker interface - all of them are created equal.
 
pink yadav
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks to reply, but
I mean to say that can we create our own marker interface like Serializable?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We also have a FAQ about marker interfaces. And yes, you can make a marker interface. The way you want it to be interpreted is up to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic