Proposal to introduce method "Instrumentation.getInstance()" to instrument the current VM

Aleksey Shipilev shade at
Thu Sep 29 18:43:03 UTC 2016

On 09/29/2016 07:50 PM, Rafael Winterhalter wrote:
> I want to propose adding a method to the instrumentation API to receive an
> instance of the current VM's instrumentation API. Currently, many
> applications "self-attach" to gain such access. Unfortunately, this only
> works on JDK-VMs but I believe that this approach will grow in popularity
> with Java 9 where the Attach API is also part of any regular VM.

> interface Instrumentation {
>   static Instrumentation getInstance(boolean redefine, boolean retransform,
> boolean nativePrefix) {
>     // security manager check
>     return getInstance0(redefine, retransform, nativePrefix);
>   }
> }

I would like to second this proposal.

Our very own JOL [1] uses self-attach [2] to get Instrumentation
instance for carefully polling Object instance sizes. Self-attach
enables JOL usage as the library dependency without requiring command
line tweaks.



More information about the core-libs-dev mailing list