src/jdk.internal.vm.compiler/share/classes/org.graalvm.util/src/org/graalvm/util/ObjectSizeEstimate.java
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.util/src/org/graalvm/util/ObjectSizeEstimate.java Fri Feb 02 10:37:48 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.util/src/org/graalvm/util/ObjectSizeEstimate.java Fri Feb 02 17:28:17 2018 -0800
@@ -26,6 +26,9 @@
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import org.graalvm.collections.EconomicMap;
+import org.graalvm.collections.Equivalence;
+
/**
* Calculates approximate estimates of the size of an object graph.
*
@@ -193,8 +196,8 @@
} else {
size.recordPointer();
if (maxDepth > 1) {
- f.setAccessible(true);
try {
+ f.setAccessible(true);
Object inner = f.get(o);
if (inner != null) {
if (depth < maxDepth && !identityHashMap.containsKey(inner)) {
@@ -205,6 +208,14 @@
}
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new UnsupportedOperationException("Must have access privileges to traverse object graph");
+ } catch (RuntimeException e) {
+ if ("java.lang.reflect.InaccessibleObjectException".equals(e.getClass().getName())) {
+ // This is a newly introduced exception in JDK9 and thus
+ // cannot be declared in the catch clause.
+ throw new UnsupportedOperationException("Target class is not exported to the current module.", e);
+ } else {
+ throw e;
+ }
}
}
}