Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when size of using with Java 10 #54

Closed
jrivard opened this issue Jul 12, 2018 · 5 comments
Closed

Exception when size of using with Java 10 #54

jrivard opened this issue Jul 12, 2018 · 5 comments
Milestone

Comments

@jrivard
Copy link

jrivard commented Jul 12, 2018

Executing the basic load of size of in AdopyOpenJDK 10.0.1:

    final SizeOf sizeof = SizeOf.newInstance();
    return sizeof.deepSizeOf( object );

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

@henri-tremblay
Copy link
Contributor

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

@lorban
Copy link

lorban commented Jul 13, 2018

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?

@henri-tremblay
Copy link
Contributor

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.

@sesuncedu
Copy link

A few comments:

  1. UnsafeSizeOf seems to be ok at runtime in the recent-ish build of openjdk 11 I have installed (linux , amd64). Compiling is broken, due to the jdk.internal module not being in the build path.
  2. Layouts haven't really changed much (for hotspot) since compressed-oops ; I expect that value types will break all the things.
  3. Attaching to self requires setting the system property - jdk.attach.allowAttachSelf . If this is set from the command line, agent sizeof seems to work fine.
  4. It ought to be possible to perform the attach by spawning another jvm, passing the id of the current process, and having it do the attach.
  5. I have no idea why the JDK doesn't provide a get(deep)ObjectSize that doesn't require essentially disabling security. Which would make this library so much smaller :-)

@chrisdennis
Copy link
Member

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

@chrisdennis chrisdennis added this to the v0.4.0 milestone Sep 18, 2020
mszygenda pushed a commit to SentiOne/ehcache2 that referenced this issue Feb 1, 2023
This is a backport of a fix developed in:

Original Author: @mprusakov
ehcache/sizeof#61
ehcache/sizeof#54

Also adds unit test for that issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants