By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

custom class loader question

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.