469,602 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

custom class loader question

Hi

I've written a Custom class loader, which reads the bytecode from a
database and returns the Class object.

For example, bytecode of a class "Test" is stored in the database.
Through custom class loader, I get the Class object for this class
"Test" as follows:

Class c = cl.loadClass("Test",true)) // cl is instance of my custom
class loader

Now I want to call the methods of "Test" class.
Is it possible to get an instance of the Test class?

One way to access the methods of the Test object is using reflection
APIs, but is there a way I can directly get the instance of Test
class, which I can use to call its methods.

thanks,
Naresh
Jul 17 '05 #1
1 4101
Naresh Agarwal wrote:
Hi

I've written a Custom class loader, which reads the bytecode from a
database and returns the Class object.

For example, bytecode of a class "Test" is stored in the database.
Through custom class loader, I get the Class object for this class
"Test" as follows:

Class c = cl.loadClass("Test",true)) // cl is instance of my custom
class loader

Now I want to call the methods of "Test" class.
Is it possible to get an instance of the Test class?
Use Class.newInstance().

One way to access the methods of the Test object is using reflection
APIs, but is there a way I can directly get the instance of Test
class, which I can use to call its methods.


Yes, this should be possible, but will require some configuration and/or
special code. I believe there is a way to tell the JVM which class
should be the system class loader. I would start there.

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Murat Tasan | last post: by
1 post views Thread by Tony Burrows | last post: by
2 posts views Thread by BentleyInc | last post: by
6 posts views Thread by Mark Wilden | last post: by
9 posts views Thread by Greger | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.