Java Applets and Class Loaders

What’s New in Java Plug-in 1.3.1_01a

Prior to version 1.3.1_01a, Java Plug-in would use a single class loader to load multiple applets during a browser session. This practice allowed the multiple applets to share information with each other through static variables.

In order to maximize compatibility with the Java virtual machines embedded in Microsoft Internet Explorer browsers, beginning with version 1.3.1_01a Java Plug-in uses separate class loaders for applets that differ in their codebase and/or the value of the ARCHIVE parameter in the APPLET tags that invoke the applets. Only if two or more applets share the same codebase and have the same value for their ARCHIVE parameter will the same class loader be used.

I naturally assumed that it worked the way it works now but without a way to control the version of the Java Plug-in used by the browser it might not be safe to assume that kind of behaviour. One way around this is to hash on e.g. the Applet ID when referencing statics, which seems to be what Sun do in Swing.