mocobeta commented on a change in pull request #572:
URL: https://github.com/apache/lucene/pull/572#discussion_r776136859
##########
File path: lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java
##########
@@ -153,6 +154,19 @@ private RamUsageEstimator() {}
}
} catch (@SuppressWarnings("unused") ReflectiveOperationException |
RuntimeException e) {
isHotspot = false;
+ final Logger log = Logger.getLogger(RamUsageEstimator.class.getName());
+ final Module module = RamUsageEstimator.class.getModule();
+ final ModuleLayer layer = module.getLayer();
+ // classpath / unnamed module has no layer, so we need to check:
+ if (layer != null
+ &&
layer.findModule("jdk.management").map(module::canRead).orElse(false) == false)
{
+ log.warning(
+ "Lucene cannot correctly calculate object sizes on 64bit JVMs,
unless the 'jdk.management' Java module "
+ + "is readable [please add 'jdk.management' to modular
application either by command line or its module descriptor]");
+ } else {
+ log.warning(
+ "Lucene cannot correctly calculate object sizes on 64bit JVMs
that are not based on Hotspot.");
Review comment:
What I see here is, OpenJ9 VM AdoptOpenJDK-11.0.11+9 (with off-the-shelf
setup) throws NoSuchMethodException at this line:
https://github.com/apache/lucene/blob/e89c9fcca87b8febdecc581a1cd77ba479339176/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java#L136
Then the logger correctly outputs the warning message with this PR.
```
$ java --module-path build/libs -m modtest/modtest.Main
12月 29, 2021 11:57:30 午前 modtest.Main main
警告: Lucene cannot correctly calculate object sizes on 64bit JVMs that are
not based on Hotspot.
// stactrace for debug
java.lang.NoSuchMethodException:
com.sun.management.HotSpotDiagnosticMXBean.getVMOption(java.lang.String)
at java.base/java.lang.Class.newNoSuchMethodException(Class.java:635)
$ java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
Eclipse OpenJ9 VM AdoptOpenJDK-11.0.11+9 (build openj9-0.26.0, JRE 11 Linux
amd64-64-Bit Compressed References 20210421_975 (JIT enabled, AOT enabled)
OpenJ9 - b4cc246d9
OMR - 162e6f729
JCL - 7796c80419 based on jdk-11.0.11+9)
```
I don't have much information about J9. I have run applications on it once
or twice for testing or making compatibility matrices.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]