• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to determine class type in static initialization block  RSS feed

 
Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to determine the class type, i.e. retrieve a Class object for the class being loade, in static initialization block? I want to use reflection to determine if my subclasses have certain capabilities. I know the proper way to do this would be to use interfaces but, for backwards compatibility, that is not possible at this time.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
During static initialization, the subclasses of your class can't be loaded yet; a class can't be loaded until its parent is.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact, a class doesn't know anything about its subclasses, and gets loaded once, not matter how many subclasses exist.

Can you tell us more about what you are trying to achieve?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!