Agent and sizing

Henri Tremblay henri.tremblay at
Fri Oct 13 14:18:30 UTC 2017

Thanks for your answers.

The way it goes is:

>From the application (not the agent):
1- Walk through all the fields
2- If it's a primitive, size it, using the Instrumentation (that indeed was
leaked to the application) with getObjectSize
3- If not, get the value (WARNING) and go introspect this new object

Works perfectly.

On 13 October 2017 at 02:42, Alan Bateman <Alan.Bateman at> wrote:

> On 13/10/2017 07:11, Remi Forax wrote:
>> Hi Henry,
>> technically, scanning all the fields of a class is warning free,
>> but to compute the size, you need the actual value of the fields, so you
>> need to extract the value of a field, even if it's a private field, and
>> this get you a lot of warning (or error).
> If there are warnings then he must be using the reflection API to access
> fields in the JDK classes that should not be accessible. This should not be
> an issue for java agents as the Instrumentation API has support for
> redefining modules and opening specific packages to the agent module. There
> are lengthy threads on jigsaw-dev going back to 2015 on this topic. As
> always, the integrity busting power of the Instrumentation API is something
> that agent developers need to guard, the Instrumentation object should not
> be leaked to libraries or applications.
> -Alan

More information about the jdk9-dev mailing list