Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with Reflections and recursive type search

Marek Lapin
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i tried to make a program that will be given a java class file (.class) as parameter and it will use java reflection to introspect the class, find out method, fields etc and create an XML file with the class description.

the problem is when i e.g. ask for the superclass of the class that i am inspecting and i get a Class object. now i want to get the name of that object ..but for that the class needs to be inspected too and so on and so on.

the problem is that my class loader cant find these aditional classes


public MyClass extends SomeOtherClass

if i try to introspect the class file from MyClass i need to add to classpath SomeOtherClass and use the super.findSystemClass() in my ClassLoader to find it.

my classloader looks like this

when i use JBuilder to open a java class file it makes all the introspection and displays the class structure, the types that he cann not find he simply omits (in my case it would display public class MyClass{ ...} )

i cant get pass the exeption when i dont find the class...

another issue - i need to give to have the full binary name... eg i need to call Class.forName("net.something.mine.MyClass"), if i dont supply this full binary name then the classloader says it cant find that class...

i dont think JBuilder cares for simply gets the absolute files path and it is enough for it to make the introspection

so resume of what i would like to know

1. how to bypass the recursive class introspection or ho to ignore the exeption "class not found" then introspecting innes classes

2. some workaroud the full qualified binary name (or how to get it from the class file?)

thanks for advice

best regards
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic