Hi
You should be able to create new instances of classes with default constructor with .newInstance(); At leas I am:
Class clazz = Class.forName("my.new.dumped.Clazz");
Object o = clazz.newInstance();
(you have to catch some exceptions here);


Do not forget that you class must have no-arg constructor:
package my.new.dumped;
calss Clazz {
Clazz() {//it is enough;}
//something else
}

Two pieces of advise from me:
1. When generating classes, make them implementing some interfaces, or extending appropriate class. Thus you may:
SomeInterface si = (SomeInterface)clazz.newInstance();
and invoke methods without reflection;
2. While in development, run the verifier on your dumped classes. Most probably your JVM verifier has much less comprehensive output than JustICE: the bcel's verifier. An easy way to run it is:
org.apache.bcel.Verifier.main(new String[]{"my.new.dumped.Clazz"));


Hope this Helps
Cheffo

Sapan Shah wrote:

Hi,
I m stuck up in creating the new instance of classes. Using BCEL i created a
class and have written the same onto the file system.
I am able to execute the Class.forName for the file but not able to create a
new instance using class.newInstance().
I checked the mailing list for creating the instance, but still not able to
figure it out exactly.

IF you could please guide me for the same.

Thanks and Regards,
------------------------------------
Sapan Shah
Software Engineer
Patni Computer Systems Limited
A 78/9 GIDC  Electronics Estate,
Sector 25,
Gandhinagar
mob: (+91)98240 59280
http://www.patni.com
World-Wide Partnerships. World-Class Solutions

This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to whom this
message was originally addressed. Any review, e-transmission dissemination
or other use of or taking of any action in reliance upon this information by
persons or entities other than the intended recipient is prohibited. If you
have received this e-mail in error kindly delete this e-mail from your
records. If it appears that this mail has been forwarded to you without
proper authority, please notify us immediately at [EMAIL PROTECTED] and
delete this mail.







--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to