|
Authored by: Anonymous on Wednesday, May 09 2012 @ 08:06 AM EDT |
Actually a large proportion of time is spent executing
static initialiser blocks (code that executes when classes
are loaded), probably because they are interpreted (rather
than running them though the JIT). The next version of Java
(8) has a feature (modules, aka project Jigsaw) is
specifically designed to help with this - so you only need
to initialise that code for classes for the modules you
need.
What we need to find out is, what was the benchmark trying
to test?
If it is VM startup times, then actually, running Hello
World is a valid test because it will load the minimum
number of classes required (which in Java, is currently a
huge amount, and far more than strictly necessary). Java has
traditionally been poor in this area rather ironically
(though it is no so bad now).
[ Reply to This | Parent | # ]
|
|
Authored by: Anonymous on Wednesday, May 09 2012 @ 08:24 AM EDT |
I think you misunderstand how class loading works because
uncompressing the classes needed from rt.jar is peanuts
compared to having to execute the "static" code when each
class is loaded. Only those classes that are required are
loaded from rt.jar (or other libraries).
As each class is loaded, every other class that is
referenced from that class also has to be loaded.
Uncompressing each from from rt.jar is trivial, but actually
executing each classes static fields and initialisers can
take quite a bit of time. The original posters point is
quite valid.
Of course, whether you should be able to patent a technique
to make this quicker is simply daft.[ Reply to This | Parent | # ]
|
|
|
|
|