mirror of https://github.com/apache/lucene.git
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:
parent
0baa187e09
commit
2dd94da6ff
|
@ -191,6 +191,10 @@ public final class RamUsageTester {
|
||||||
long shallowInstanceSize = RamUsageEstimator.NUM_BYTES_OBJECT_HEADER;
|
long shallowInstanceSize = RamUsageEstimator.NUM_BYTES_OBJECT_HEADER;
|
||||||
final ArrayList<Field> referenceFields = new ArrayList<>(32);
|
final ArrayList<Field> referenceFields = new ArrayList<>(32);
|
||||||
for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
|
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();
|
final Field[] fields = c.getDeclaredFields();
|
||||||
for (final Field f : fields) {
|
for (final Field f : fields) {
|
||||||
if (!Modifier.isStatic(f.getModifiers())) {
|
if (!Modifier.isStatic(f.getModifiers())) {
|
||||||
|
|
Loading…
Reference in New Issue