• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to determine all classes in current class loader

 
Chris Nappin
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to be able to get a list of all classes that can be loaded by the current class loader, so that I can then inspect them looking for specific annotations - like a Java EE 5 container does, but all the code would be sitting inside an application, not in the container. Is this possible in a reliable, portable manner in a J2EE container environment? I imagine hacks to locate physical .jar/.ear/.war files won't work accross containers, when some expand them and others don't?

Does anyone know if any of the AOP or byte-code manipulation libraries (cglib, BCEL, ASM etc) have APIs that might help here?
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I don't think there's any nice generic way to do this. You have to do something specific to the type of ClassLoader you're using.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic