jbellis / jamm

Java Agent for Memory Measurements
Apache License 2.0
684 stars 125 forks source link

java.lang.reflect.InaccessibleObjectException: Unable to make field jdk.inte rnal.ref.PhantomCleanable #45

Closed stephankoelle closed 1 year ago

stephankoelle commented 3 years ago

The JVM (openjdk 15) sometimes has internal PhantomCleanable those throw an exception

Jamm must be set as -javaagent: java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make field jdk.inte
rnal.ref.PhantomCleanable jdk.internal.ref.PhantomCleanable.prev accessible: module java.base does not "opens jdk.internal.ref" to unnamed module @1ce92674: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.In
accessibleObjectException: Unable to make field jdk.internal.ref.PhantomCleanable jdk.internal.ref.PhantomCleanable.prev accessible: module java.base does not "opens jdk.internal.ref" to unnamed module @1ce92674
        at org.github.jamm.MemoryMeterBase.measureDeep(MemoryMeterBase.java:129) [jamm-0.4.0.jar:0.4.0-SNAPSHOT]
stephankoelle commented 3 years ago
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field jdk.internal.ref.PhantomCleanable jdk.internal.ref.PhantomCleanable.prev accessible: module java.base does not "opens jdk.internal.ref" to unnamed module @1ce92674
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:361) [java.base:]
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:301) [java.base:]
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177) [java.base:]
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:171) [java.base:]
        at org.github.jamm.MemoryMeterBase.declaredClassFields0(MemoryMeterBase.java:241) [jamm-0.4.0.jar:0.4.0-SNAPSHOT]
        ... 83 more
stephankoelle commented 3 years ago

46

horschi commented 3 years ago
Caused by: java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make field final jdk.internal.loader.URLClassPath jdk.internal.loader.ClassLoaders$AppClassLoader.ucp accessible: module java.base does not "opens jdk.internal.loader" to unnamed module @164642a4
    at org.github.jamm.MemoryMeterBase.declaredClassFields0(MemoryMeterBase.java:246)
    at org.github.jamm.MemoryMeterBase.access$0(MemoryMeterBase.java:223)
    at org.github.jamm.MemoryMeterBase$1.computeValue(MemoryMeterBase.java:24)
    at org.github.jamm.MemoryMeterBase$1.computeValue(MemoryMeterBase.java:1)
    at org.github.jamm.MemoryMeterBase.declaredClassFields(MemoryMeterBase.java:219)
    at org.github.jamm.MemoryMeterBase.measureDeep(MemoryMeterBase.java:119)
    ... ? more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field final jdk.internal.loader.URLClassPath jdk.internal.loader.ClassLoaders$AppClassLoader.ucp accessible: module java.base does not "opens jdk.internal.loader" to unnamed module @164642a4
    at org.github.jamm.MemoryMeterBase.declaredClassFields0(MemoryMeterBase.java:241)
blerer commented 1 year ago

Thanks for reporting this problem. This problem is now fixed.