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
This commit is contained in:
Uwe Schindler 2014-08-15 21:16:20 +00:00
parent 0baa187e09
commit 2dd94da6ff
1 changed files with 4 additions and 0 deletions

View File

@ -191,6 +191,10 @@ public final class RamUsageTester {
long shallowInstanceSize = RamUsageEstimator.NUM_BYTES_OBJECT_HEADER;
final ArrayList<Field> 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())) {