Java class data sharing

Java 1.5 introduces class data sharing:

This looks a lot like .Net's ngen concept, except it only works on core classes(for .net's equivalence, mscorlib.dll).

Maybe their next step is introducing ngen?



Comments (5)

  1. Nicholas Allen says:

    This sounds more like the emacs fast loading trick than ngen. Basically, I think they’re starting the vm until just before it jumps to main. Then they dump core and write out the vm data structures to a file. On future loads, they read the core file and start execution where they left off. So that’s why it only works with core classes since user classes wouldn’t have been loaded yet. The only new trick (and I’m not sure if this is new) is to organize the core dump so that a big portion of it can be marked read-only and shared between processes.

    It would be nice if they had in addition to this something like ngen (or at least a static optimizing compiler).

  2. M.J. says:

    Good grief–are Sun and Microsoft going to get into a mud wrestling match about who "innovated" with the most obvious technology?

    Sharing of data between instances of the JVM has been on Sun’s TODO list since almost as soon as Java came out. It’s not Sun engineers that came up with that "brilliant" idea (nor Microsoft engineers, for that matter), it’s the users.

    The real question is why it takes something as cumbersome as "ngen" to do it or why Sun doesn’t do sharing for everything. Code, JIT output, and data should be shared automatically and for everything whenever it is possible, rather than involving a step like "ngen". "Ngen" is already an inconvenient and substandard shortcut for the implementors because apparently they couldn’t figure out how to do things right.

  3. Nicholas, from what you described, yes, it is more like Emacs fast loading trick. I said it is like ngen, because ngen pretty much does the same thing, burn some runtime data structure into the native image, as well as compile the IL code into machine code.

    M.J., JITTER will compile the IL code in the process’s private address space. Those can’t be seen by other processes(Well, maybe you can use shared memory, but there are a lot of complications there). The working way is to pre-compile the IL code into a native dll, and every processes uses that native dll, a.k.a ngen.

Skip to main content