And once the class is loaded into the VM, you can try something
like this:
private Object instantiate(Class aClass, IForm arg) {
// Whoever said that writing tests is fun, was wrong.
Constructor cstr = null;
Class par1 = null;
try {
par1 = Class.forName("ch.unibe.piccola.IForm");
} catch (ClassNotFoundException cnfe) {cnfe.printStackTrace();}
Class[] parameterTypes = {par1};
try {
cstr= aClass.getConstructor(parameterTypes);
} catch (NoSuchMethodException nsme) {nsme.printStackTrace();}
Object[] initArgs = {arg};
Object obj = null;
try {
obj = cstr.newInstance(initArgs);
} catch (Exception e) {e.printStackTrace();}
return obj;
}
Juozas Baliuka wrote:
use ClassLoader.defineClass( byte[], int, int)
----- Original Message -----
From: "Mark R. Diggory" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 17, 2003 8:17 PM
Subject: How to get instance of my new Class.
I've written code using the BCEL packages that produces a new Class.
I can see how to get the byte code or source of the be class and save it
a file from the examples provided, however, I don't really want to do
this yet. I'd like to jusat create a new instance of my class I've
created in the current process in which I generatede it. Does anyone
have suggestions on how I can do this?
thanks,
Mark
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
Andreas Schlapbach [EMAIL PROTECTED]
http://www.iam.unibe.ch/~schlpbch
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>