hi all,
there is something weired going on with applets in different browsers. here is my view of things about this problem.
-insertion of default constructor is a 'runtime' issue dealt by the JVM running the class and creating objects. so, what happens is, there is no code inserted for default constructor in the class file generated by the compiler. i can be sure about this as i tried the following code,
here, AppletTest is assumed to be defined as in the problem statement.
now, when we run this code it gives only one constructor,
public AppletTest(java.lang.String)
this means it doesnt insert the default constructor code into the class file.
that should imply that, JVM does that for us whenever required at runtime.
now, if we come to the main problem then,
as JVM does invoke default const for us (still the class doesn't have default const code), it becomes the responsibility of IE or NN or the appletviewer program. and that is the reason its not working. as IE or NN or appletviewer doesnt do that. why?? i don know.
i observed following things running the following code in IE and NN.
on IE,
init method is called but instance initializer is not being called. that means it didn't invoke public default no-arg constructor. right? and so it didnt initialize display with the
string "Hello world!" as well and i don't get any output on the applet. but still the applet works. it doesnt give me a runtime error. which i found strange thing as it didnt created object for the applet and still it didnt give exception of instantiation of the applet.
on NN,
i am getting runtime exception of instantiation of applet object.
so, i's sure that applet instance is not created in IE or NN. so, i made var display static and had a static initializer block for initialization of that var. it worked on IE. (it didnt work on NN as i's getting exception).
so, i conclude that IE and NN both dont insert that no-arg const to the applets and still IE behaves weiredly.
what i failed to understand is why the hell the code is not working properly for 'appletviewer' which might be using local JVM , which i'm sure support that no-arg const thing.
i made another conclusion. regardless of JVM, in applets it seem not the case that no-arg const is inserted if we dont have one and have a const with some argument.
of course, if we don have any const it works smoothly on IE, NN & appletviewer.
browsers are strange for applets. believe me. i worked for applets for sometime. u 'll go nuts resolving issues regarding applet display and loading in IE and NN browsers to make it work equally on both. i went mad dealing with that coz NN4.77, NN6.1, IE all behaves differently for an applet
so, thats about it. hope it helped little bit. still 'm not sure if any other strong and valid reason is there for this problem.
regards
maulin.