[
https://issues.apache.org/jira/browse/LUCENE-10339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17465979#comment-17465979
]
Tomoko Uchida commented on LUCENE-10339:
----------------------------------------
It seems "requires [static] jdk.management" indeed affects the return value of
Module.canRead().
{code}
Class<?> beanClazz =
Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
final Method getVMOptionMethod = beanClazz.getMethod("getVMOption",
String.class);
final Object hotSpotBean =
Class.forName("java.lang.management.ManagementFactory")
.getMethod("getPlatformMXBean", Class.class)
.invoke(null, beanClazz);
final Object vmOption = getVMOptionMethod.invoke(hotSpotBean,
"UseCompressedOops");
boolean compressedOops =
Boolean.parseBoolean(
vmOption.getClass().getMethod("getValue").invoke(vmOption).toString());
System.out.println("Compressed OOPs enabled: " + compressedOops);
final Module module = Main.class.getModule();
final ModuleLayer layer = module.getLayer();
boolean readable =
layer.findModule("jdk.management").map(module::canRead).get();
System.out.println("jdk.management is readable: " + readable);
} catch (Exception e) {
e.printStackTrace();
}
{code}
{code}
// without "requires static jdk.management"
modtest $ java --module-path build/libs -m modtest/modtest.Main
Compressed OOPs enabled: true
jdk.management is readable: false // ...?
modtest $ java --module-path build/libs --add-modules jdk.management -m
modtest/modtest.Main
Picked up _JAVA_OPTIONS: -Duser.language=en
Compressed OOPs enabled: true
jdk.management is readable: false // ...?
{code}
{code}
// with "requires static jdk.management"
modtest $ java --module-path build/libs -m modtest/modtest.Main
Compressed OOPs enabled: true
jdk.management is readable: true
modtest $ java --module-path build/libs --add-modules jdk.management -m
modtest/modtest.Main
Compressed OOPs enabled: true
jdk.management is readable: true
{code}
> Add require derective for jdk.management to core's module descriptor.
> ---------------------------------------------------------------------
>
> Key: LUCENE-10339
> URL: https://issues.apache.org/jira/browse/LUCENE-10339
> Project: Lucene - Core
> Issue Type: Sub-task
> Reporter: Tomoko Uchida
> Priority: Major
> Attachments: Screenshot from 2021-12-25 18-04-55.png, Screenshot from
> 2021-12-25 20-11-38.png
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> IntelliJ IDEA warns as follows in o.a.l.u.RamUsageEstimator.
> !Screenshot from 2021-12-25 18-04-55.png!
> !Screenshot from 2021-12-25 20-11-38.png!
> This means we would need "require" or "require static" directive(s) in core's
> module descriptor to make RamUsageEstimator correctly work.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]