use of java.lang.module.ModuleDescriptor in project openj9 by eclipse.
the class MyLoader method dumpModules.
private void dumpModules() {
HashSet<Option> opts = new HashSet<>(Arrays.asList(new Option[] { Option.RETAIN_CLASS_REFERENCE, Option.SHOW_HIDDEN_FRAMES, Option.SHOW_REFLECT_FRAMES }));
List<StackFrame> frameList = (StackWalker.getInstance(opts)).walk(s -> s.collect(Collectors.toList()));
for (StackFrame f : frameList) {
Module frameModule = f.getDeclaringClass().getModule();
if ((null != frameModule)) {
ModuleDescriptor d = frameModule.getDescriptor();
if (null != d) {
StackTraceElement e = f.toStackTraceElement();
String modName = d.name();
String expectedName = e.getModuleName();
if (null != modName) {
assertEquals(modName, expectedName, "Wrong module name");
}
Optional<Version> modVersion = d.version();
if (modVersion.isPresent()) {
String actualVersion = modVersion.get().toString();
String expectedVersion = e.getModuleVersion();
assertEquals(actualVersion, expectedVersion, "Wrong module version");
}
if (f.getDeclaringClass() == Thread.class) {
assertEquals("java.base", expectedName, "Wrong module name");
}
}
}
}
}
Aggregations