On Jul 28, 12:11 am, zo...@epost.de wrote:
> Hi,
>
> I wonder why..
I've 'stopped' wonderring why any particular
applet caching (or otherwise) happens in any
particular browser/VM combo. It is simply
a) too upredictable.
b) completely out of the immediate control of a
(sandboxed) applet.
> Could anybody give me a hint why TestApplet.class is requested twice
Sh*t happens? What browser (make, version and OS)
runnning what verison of Java (manufacturer, version
and OS) are you speaking of, hear?
Applet 'inconsistencies' between browser versions
and Java versions can pretty much be expected.
> and even TestObject.class is requested although not needed at runtime?
>
> Any help is greatly appreciated.
Have you looked into web start deployment*?
This deployment environment is much more stable
and predictable than your average browser/VM
combo.
* E.G.s <http://www.physci.org/jws/>
zorci@epost.de - 27 Jul 2007 18:42 GMT
Andrew, first thank you for your response.
> Applet 'inconsistencies' between browser versions
> and Java versions can pretty much be expected.
Sure, but please look at this example:
====== JavaApp.java ======
import java.awt.Panel;
public class TestApp {
TestObject o;
void neverCalled() {
Panel p=new Panel();
p.add(o);
}
public static void main(String args[]) {}
}
Compile it, delete TestObject.class, run TestApp and you'll get an
"NoClassDefFoundError: TestObject". As you can see here, at least the
problem of the unneeded class request (TestObject.class) is not applet-
related and occurs also in applications. Of course no one would
recognize a delay since all classes have been preloaded.
> Have you looked into web start deployment*?
Not very deep... I'm still not sure if Java WebStart can be an
alternative to our html/applet-based website due to the following:
1. In contrast to applets, applications cannot play together with the
HTML framework. Much recoding would have to be done to put everything
into an java application.
2. In a HTML framework, Java applets can be substituted by alternative
non-java technologies like javascript or html. Applications cannot.
> b) completely out of the immediate control of a
> (sandboxed) applet.
A JarIndex gives you pretty much control over what code modules are
loaded by an applet at a specific time. Of course one need to be
careful to put the right classes into the right jar's. In WebStart
applications, all the code is loaded at startup by default, even if
unneeded. Applets can of course also be versionized, e.g. by using
different URLs or control the SUN cache state using cache* params.
WebStart is a very good thing when dealing with pure applications, but
in our case it does not seem to be a good alternative right now...
> I wonder why
>
> a) applet classes are (sometimes) requested twice and
I don't know, too.
> b) Component/JComponent classes are requested although never needed at
> runtime.
If you have an applet, Component *is* needed at runtime, because it is
an (indirect) superclass of Applet and JApplet:
Applet extends Panel extends Container extends Component.
JApplet extends Applet extends ... extends Component.

Signature
Thomas
zorci@epost.de - 27 Jul 2007 18:46 GMT
On 27 Jul., 17:42, Thomas Fritsch <i.dont.like.s...@invalid.com>
wrote:
> zo...@epost.de wrote:
> > I wonder why
>
> > a) applet classes are (sometimes) requested twice and
>
> I don't know, too.
mhmm...
> > b) Component/JComponent classes are requested although never needed at
> > runtime.
[quoted text clipped - 3 lines]
> Applet extends Panel extends Container extends Component.
> JApplet extends Applet extends ... extends Component.
Sure, Component.class is ok, but why has my TestObject.class been
requested?
Lew - 27 Jul 2007 20:44 GMT
> On 27 Jul., 17:42, Thomas Fritsch <i.dont.like.s...@invalid.com>
> wrote:
[quoted text clipped - 14 lines]
> Sure, Component.class is ok, but why has my TestObject.class been
> requested?
Because of the member variable
> TestObject o;
in your code. You requested it.

Signature
Lew
zorci@epost.de - 27 Jul 2007 21:50 GMT
> > Sure, Component.class is ok, but why has my TestObject.class been
> > requested?
[quoted text clipped - 3 lines]
>
> in your code. You requested it.
No. As long as I just declare and not instanciate a member variable,
the SUN VM(1.4+) does NOT load the .class file since there is no need.
Try it by removing neverCalled() - no error occurs after deleting
TestObject.class. It has something to do with Component.add()...
Has anybody else an idea?
Tom Hawtin - 02 Aug 2007 17:49 GMT
> No. As long as I just declare and not instanciate a member variable,
> the SUN VM(1.4+) does NOT load the .class file since there is no need.
> Try it by removing neverCalled() - no error occurs after deleting
> TestObject.class. It has something to do with Component.add()...
The original code:
public class TestApplet extends Applet {
TestObject o;
...
add(o);
The TestApplet class needs to be verified before it can be initialised.
As part of the verification it needs to check that the call to
add(Ljava/awt/Component;)Ljava/awt/Component; is valid, i.e. is
TestObject as subtype of Component. In order to determine this, the
verifier is going to need to load TestObject.
Tom Hawtin