views:

667

answers:

3

In Java, is there any way to use the JDK libraries to discover the private classes implemented within another class? Or do I need so use something like asm?

+3  A: 

Yes: use the Class.getClasses() method. Note that this only returns the public inner classes and interfaces. If you want to get the protected or private classes (I don't why you'd want to do so), you'll have to do something extremely hackish like read in the class file and parse it yourself.

Adam Rosenfield
i meant private classes
Hamlet D'Arcy
A: 

I think this is what you're after: Class.getClasses().

Cogsy
+6  A: 

Class.getDeclaredClasses() is the answer.

Hamlet D'Arcy