On Saturday, 7 December 2013 at 08:31:08 UTC, Marco Leise wrote:
How is that easier in Java? When whole-program analysis finds
that there is no class extending C, it could devirtualize all
methods of C, but(!) you can load and unload new derived
classes at runtime, too.
Also the JVM doesn't load all classes at program startup,
because it would create too much of a delay. This goes so
far that there is even a special class for splash screens with
minimal dependencies, to avoid loading most of the runtime and
GUI library first.
I think whole-program analysis in such an environment is
outright impossible.
You forgot that this is JITTed. The JVM can reemit the code for a
function when assumption on its optimization do not hold.
When the JVM load new classes, it invalidate a bunch of code.
That mean that a function can be final, then virtual, then back
to final, etc ..., during the program execution.