jamm
jamm copied to clipboard
CannotAccessFieldException reading hidden class
Using jamm 0.4.0, Apache Impala is running into
java.util.regex.Pattern$CharPredicate$$Lambda$23/0x80000002d cannot be retrieved
at org.github.jamm.accessors.JpmsAccessor.getFieldValue(JpmsAccessor.java:54)
at org.github.jamm.MemoryMeter.getFieldValue(MemoryMeter.java:568)
at org.github.jamm.MemoryMeter.addField(MemoryMeter.java:550)
at org.github.jamm.MemoryMeter.addDeclaredFields(MemoryMeter.java:537)
at org.github.jamm.MemoryMeter.addFields(MemoryMeter.java:529)
at org.github.jamm.MemoryMeter.measureDeep(MemoryMeter.java:507)
at org.github.jamm.MemoryMeter.measureDeep(MemoryMeter.java:441)
at org.apache.impala.catalog.local.CatalogdMetaProvider$SizeOfWeigher.weigh(CatalogdMetaProvider.java:2056)
at com.google.common.cache.LocalCache$Segment.setValue(LocalCache.java:2014)
at com.google.common.cache.LocalCache$Segment.storeLoadedValue(LocalCache.java:3162)
at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2322)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2283)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2159)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
at com.google.common.cache.LocalCache.get(LocalCache.java:3966)
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4863)
at org.apache.impala.catalog.local.CatalogdMetaProvider.loadWithCaching(CatalogdMetaProvider.java:534)
at org.apache.impala.catalog.local.CatalogdMetaProvider.loadTableList(CatalogdMetaProvider.java:683)
at org.apache.impala.catalog.local.LocalDb.loadTableNames(LocalDb.java:173)
at org.apache.impala.catalog.local.LocalDb.getAllTableNames(LocalDb.java:158)
at org.apache.impala.service.Frontend.getCatalogMetrics(Frontend.java:1058)
at org.apache.impala.service.JniFrontend.getCatalogMetrics(JniFrontend.java:244)
Caused by: java.lang.UnsupportedOperationException: can't get field offset on a hidden class: private final java.util.regex.Pattern$CharPredicate java.util.regex.Pattern$CharPredicate$$Lambda$23/0x80000002d.arg$1
at jdk.unsupported/sun.misc.Unsafe.objectFieldOffset(Unsafe.java:645)
at org.github.jamm.accessors.JpmsAccessor.getFieldValue(JpmsAccessor.java:46)
... 21 more
That's not the outcome I expected from reading https://github.com/jbellis/jamm#unsafe. I thought it would try to guess the object's size.
It is because the problem is not with the Unsafe strategy but with the crawling. Jamm is using reflection to visit the object tree but if some objects are not accessible due to the module system it will try to use Unsafe to by pass the module system. Unfortunately, if the class is a hidden one it will not be able to access the field.
There is a way to do it but it is quite hacky so we avoided it until now.
One option is to add an add-open for java.util.regex
. I do not know if it is an option for you.
That option works for me. It wasn't immediately clear to me that was how to fix it. Thanks!
Cool. Can I close this ticket?
It still seems a little odd that it doesn't attempt to estimate, similar to how the README describes it. There's no other real option except to add-open for various any class that keeps a reference to a lambda. But I've accepted that workaround for now.
I can let it open for now and see if I can find a solution.
I can let it open for now and see if I can find a solution.
Until then, I agree we can add a note in the README to prevent further confusion and let people know about the workaround with add-opens, as explained in this thread. I can add the update next week.