use of java.lang.module.ModuleDescriptor.Version 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();
if (null != modName) {
assertEquals(modName, e.getModuleName(), "Wrong module name");
}
Optional<Version> modVersion = d.version();
if (modVersion.isPresent()) {
assertEquals(modVersion.get(), e.getModuleVersion(), "Wrong module version");
}
if (f.getDeclaringClass() == Thread.class) {
assertEquals("java.base", e.getModuleName(), "Wrong module name");
}
}
}
}
}
Aggregations