The Object Sharing Scheme (and how it has broken)

  1. The Netscape Java runtime environment runs all applets inside of a common runtime environment. This means that all static data is shared (including classes themselves).

  2. An object cache can be implemented as static Hashtable member of a class. Access is through a synchronized static method, which creates the Hashtable if it has not yet been created, and creates requested objects if they are not already in the Hashtable.

    The Hashtable should not be initialized where it is defined, since the static initialization method is apparently not synchronized by default, and this can cause trouble.

  3. IDVI uses this scheme to cache decoded pk font files (in the class idvi.font.DVIFont), parsed dvi files (in the class idvi.dvi.DVIDocument), and color schemes (in the class idvi.display.ColorScheme).

  4. The basic assumption that static data is shared breaks under Microsoft Internet Explorer, and may break under the Netscape 3.0 for Windows JIT Java runtime environment. Either we have to give up on caching things this way (which will be a speed hit) or we need to find a new safer way of sharing data.