Accessing module internals from bytecode rewriting agent
Alan.Bateman at oracle.com
Fri Jun 16 12:41:43 UTC 2017
On 16/06/2017 10:26, Michael Rasmussen wrote:
> If going that route, then there are 3 capabilities added with JVMTI 9
> that you should look into, in order to be able to intercept the
> loading of the very early classes as well (Object, String, Class etc):
The two can_generate_early_XXXX capabilities are new.
can_generate_all_class_hook_events has been there since JVM TI 1.0.
> Also note, that if your modified classes cause other classes to be
> loaded during loading/verification, then you might get into trouble.
> For instance if they don't exist in java.base, they won't be found.
I assume you mean calling JNI FindClass in the start phase. A long
standing bug in the JVM TI spec is that it set expectations that any JNI
function could be used in the start phase even though the VM is not
fully initialized. That spec issue was corrected and expectations dialed
down with the spec changes in 9. Another point is that the start phase
defaults to being deferred until VM initialization is at the point that
it can classes in modules other than java.base. That keeps existing JVM
TI agents working as the cost of them missing out on events from early
startup (long before main is executed).
More information about the core-libs-dev