Review Request JDK-8200559: Java agents doing instrumentation need a means to define auxiliary classes
Alan Bateman
Alan.Bateman at oracle.com
Mon Jul 2 09:55:45 UTC 2018
On 02/07/2018 09:41, Rafael Winterhalter wrote:
> Hi,
>
> I was wondering if a solution for this problem is still planned for
> JDK 11 giving the beginning ramp down.
>
> With removing sun.misc.Unsafe::defineClass, Java agents only have an
> option to use jdk.internal.misc.Unsafe::defineClass for the use-cases
> that I described.
>
> I think it would be a missed opportunity not to offer an alternative
> as of JDK 11 as a second migration would make it even less likely that
> agents would avoid unsafe API.
>
Mandy's propoal to allow agents doing instrumentation to define
auxiliary classes in the same runtime package as the class being loaded
or redefine is a good proposal make complete sense and that fits with
the intended use of this API. Unfortunately it didn't make JDK 11.
I read the mails and arguments for an Instrumentation.defineClass but I
don't think it's the right API to add. The Instrumentation API was
designed for tool agents, not libraries, and a lot of discussion seems
to be trying to use the API for cases that it was never intended. Also
an unrestricted defineClass creates an attractive nuisance that would
likely create a lot of problems further down the road. I think it would
be better to focus on some of the use-cases to see if we can identify
cases where a standard API make sense.
-Alan
More information about the serviceability-dev
mailing list