Skip to content

Apache Lucene open-source search software

LUCENE-7595: Fix bug with RamUsageTester incorrectly handling Iterables outside Java Runtime

Uwe Schindlerdb9190db9372
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 daf81a96b35..6437d8eda12 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
@@ -152,7 +152,7 @@ public final class RamUsageTester {
}
boolean needsReflection = true;
- if (Constants.JRE_IS_MINIMUM_JAVA9) {
+ if (Constants.JRE_IS_MINIMUM_JAVA9 && obClazz.getName().startsWith("java.")) {
// Java 9: Best guess for some known types, as we cannot precisely look into runtime classes:
final ToLongFunction<Object> func = SIMPLE_TYPES.get(obClazz);
if (func != null) { // some simple type like String where the size is easy to get from public properties