Dynamic class loading questions
Chuck Wright <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I posted this question in January, and haven't seen a
response, and none in the archive, so here's another
try...This is definitely a question for the dalsemi
guys.
Thanks,
- C
-------------------------------------------------------
Hello all,
Apologies if this is old ground, but I do not find an
answer in the archives or the distribution.
Based on a small experiment, it appears to me that
a static initializer in a dynamically loaded class does
not get executed. (I am using 1.12, on a 400)
In Limitations.txt I see a discussion of static initializers
being handled slightly differently, but no mention of
them with regard to dynamic class loading.
Is this the expected behavior?
Thanks!
- C
public class dyn{
public static void main(String args[])
throws ClassNotFoundException{
System.out.println("Loading dynoaded");
Class c = Class.forName("dynloaded");
System.out.println("Loaded dynloaded, creating instance");
try{
c.newInstance();
System.out.println("done");
}catch(Exception e){
System.out.println("error instantiating" + e);
}
}
static{
System.out.println("Hello from static initializer for dyn");
}
}
public class dynloaded{
public int instancevar = 0;
public dynloaded(){
System.out.println("Default constructor for class dynloaded");
}
static{
System.out.println("hello from static initializer inside dynloaded");
}
}
Output running dyn on PC:
Hello from static initializer for dyn
Loading dynoaded
hello from static initializer inside dynloaded
Loaded dynloaded, creating instance
Default constructor for class dynloaded
done
On TINI:
Hello from static initializer for dyn
Loading dynoaded
Loaded dynloaded, creating instance
Default constructor for class dynloaded
done
--
Chuck Wright
http://chuck-wright.com
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini