Closed jrivard closed 4 years ago
We will probably need to revisit sizeof past Java 9. I think, we relying on reflection, sizeof will need to have JVM arguments. In this case you will need --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
I don't think the sizeof engine would return correct sizes for a new major JDK without modifications. There also is another problem that the reflection-based sizeof engine really should never be picked up as it's much, much slower than the agent and unsafe ones.
Maybe we should have a look at JOL (http://openjdk.java.net/projects/code-tools/jol/) as this does a very similar job, maybe we could join forces?
Yes. It means that the agent has failed (which is expected starting with Java 9 but I think can be fixed) and Unsafe as failed (which I think is the case in Java 10). And yes joining forces with JOL sounds like a good idea.
A few comments:
jdk.attach.allowAttachSelf
. If this is set from the command line, agent sizeof seems to work fine. get(deep)ObjectSize
that doesn't require essentially disabling security. Which would make this library so much smaller :-)The reported issue was fixed in #61. #52 Covers the agent attach issues. Future issues will likely be needed as more issue appear in future JVMs
Executing the basic load of size of in AdopyOpenJDK 10.0.1:
Returns this exception:
InaccessibleObjectException:
java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.Object jdk.internal.loader.AbstractClassLoaderValue$Sub.key accessible: module java.base does not "opens jdk.internal.loader" to unnamed module