MethodHandle initialization process - problem with JVM TI early VM start event
Alan Bateman
Alan.Bateman at oracle.com
Wed Jan 4 12:15:30 UTC 2017
On 04/01/2017 10:39, David Holmes wrote:
>
> That is my thought too, that the spec needs to give less of the
> impression that it's okay to access java.base classes at this early VM
> start event, and basically say that any form of class-loading is not
> guaranteed to succeed and will quite likely crash the JVM.
The JVM TI spec has always allowed agents to call any JNI function in
the start phase. I don't think there was any intention to have agents
load and execute arbitrary java code but this wasn't fully spelled out.
For JDK 9 then we attempt to preserve this compatibility for existing
agents by deferring the start phase until after the module system is
initialized (initPhase2). This has the side effect that they miss out on
some interesting events during startup. They can of course replay at
least some of them with GenerateEvents but it's not enough for some
agents. So this is the reason for the can_generate_early_vmstart
capability and it's intended for agents that take an oath of carefulness.
So for the spec update then I think the restrictions can be mostly
limited to when the can_generate_early_vmstart capability is enabled.
Ideally we should avoid introducing yet another event that signals the
point in the start phase when it's safe to do things, agents can use the
VMInit for that.
-Alan
More information about the core-libs-dev
mailing list