Help with class loader and reflection APIs in Java

hercules

Disciple
Hello,
My requirement is to create some java classes at runtime. For which I have a class loader which loads them. My next requirement was to call the methods from the newly loaded classes using reflection. In my class loader I have implemented loadClass() function.
I call my functions this way:
Class clas = ccl.loadClass("testParser.file");
Method method1 = clas.getMethod("print");
method1.invoke(new file());

But problem is here the class file()(which contains function print), is loaded by the class loader so its not known to the compiler. And i can't declare my function print() as static, so I have to pass the object of the declaring class.... I am in a fix..Any gr8 mind can provide some help please ?
 
Back
Top