• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

If purpose of Marker interface is to send signal to JVM, What signal or information does it send?

 
Ranch Hand
Posts: 31
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If purpose of Marker interface is to send signal to JVM, What signal or information does it send?
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That depends on the interface in question; is there any particular one you're curious about? It should be noted that marker interfaces can be interpreted by non-JVM code as well -so you can use them in your code-, and that they've been obsolete for a long time, ever since the introduction of annotations (and good riddance, IMO).
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

div tripathi wrote:If purpose of Marker interface is to send signal to JVM...



But is that the purpose of a marker interface? Even if there is a common purpose among all marker interfaces, which I don't think there is, I don't think that "sending a signal to the JVM" is that common purpose.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@OP: What you mean by "sending a signal"? Do you mean that literally, like actively sending the JVM some sort of signal or do you mean like passively in that implementing that marker interface indicates something about the class? For example, it was recently pointed out in another thread that the RandomAccess marker interface actually indicates that a List implementation will typically perform better using a for-loop and List.get(n) versus an Iterator and next()/hasNext(). This would fall under the "passive signal" category.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:For example, it was recently pointed out in another thread that the RandomAccess marker interface actually indicates that a List implementation will typically perform better using a for-loop and List.get(n) versus an Iterator and next()/hasNext(). This would fall under the "passive signal" category.



That's a sort of signal, sure. But to me it's a signal to programmers that using the List.get(n) method would be an O(1) operation rather than an O(N) operation. Now it's true that code in the standard API might well make use of that signal, but the standard API isn't the JVM either.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah I didn't mean to imply that "indicating something about the class" meant "indicating something about the class (to the JVM)" -- all I meant was implementing the marker interface was kind of an announcement to "whoever cared to notice that the class was implementing the marker interface." English is a funny thing but sometimes we can't always predict the many different ways people will interpret what we say.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic