From 2dd94da6ffb51269ea47424a531cb2fae0693dcd Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Fri, 15 Aug 2014 21:16:20 +0000 Subject: [PATCH] SOLR-6382: Add Java9 fix for RAMUsageTester (SecurityException when trying to do reflection on Class class) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1618275 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/lucene/util/RamUsageTester.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/RamUsageTester.java b/lucene/test-framework/src/java/org/apache/lucene/util/RamUsageTester.java index 2d61fa1bf2c..ffd671018d6 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/RamUsageTester.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/RamUsageTester.java @@ -191,6 +191,10 @@ public final class RamUsageTester { long shallowInstanceSize = RamUsageEstimator.NUM_BYTES_OBJECT_HEADER; final ArrayList referenceFields = new ArrayList<>(32); for (Class c = clazz; c != null; c = c.getSuperclass()) { + if (c == Class.class) { + // prevent inspection of Class' fields, throws SecurityException in Java 9! + continue; + } final Field[] fields = c.getDeclaredFields(); for (final Field f : fields) { if (!Modifier.isStatic(f.getModifiers())) {