• 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

How to determine all classes in current class loader

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic