< prev index next >
test/hotspot/jtreg/runtime/appcds/cacheObject/CheckArchivedModuleApp.java
Print this page
*** 21,30 ****
--- 21,31 ----
* questions.
*
*/
import java.io.File;
+ import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor;
import java.util.Set;
import sun.hotspot.WhiteBox;
//
*** 39,58 ****
System.out.println("Archived open_archive_heap objects are not mapped.");
System.out.println("This may happen during normal operation. Test Skipped.");
return;
}
! boolean expectArchived = "yes".equals(args[0]);
! checkModuleDescriptors(expectArchived);
}
! private static void checkModuleDescriptors(boolean expectArchived) {
Set<Module> modules = ModuleLayer.boot().modules();
for (Module m : modules) {
ModuleDescriptor md = m.getDescriptor();
String name = md.name();
! if (expectArchived) {
if (wb.isShared(md)) {
System.out.println(name + " is archived. Expected.");
} else {
throw new RuntimeException(
"FAILED. " + name + " is not archived. Expect archived.");
--- 40,61 ----
System.out.println("Archived open_archive_heap objects are not mapped.");
System.out.println("This may happen during normal operation. Test Skipped.");
return;
}
! boolean expectArchivedDescriptors = "yes".equals(args[0]);
! boolean expectArchivedConfiguration = "yes".equals(args[1]);
! checkModuleDescriptors(expectArchivedDescriptors);
! checkConfiguration(expectArchivedConfiguration);
}
! private static void checkModuleDescriptors(boolean expectArchivedDescriptors) {
Set<Module> modules = ModuleLayer.boot().modules();
for (Module m : modules) {
ModuleDescriptor md = m.getDescriptor();
String name = md.name();
! if (expectArchivedDescriptors) {
if (wb.isShared(md)) {
System.out.println(name + " is archived. Expected.");
} else {
throw new RuntimeException(
"FAILED. " + name + " is not archived. Expect archived.");
*** 65,70 ****
--- 68,92 ----
"FAILED. " + name + " is archived. Expect not archived.");
}
}
}
}
+
+ private static void checkConfiguration(boolean expectArchivedConfiguration) {
+ Configuration cf = ModuleLayer.boot().configuration();
+ if (expectArchivedConfiguration) {
+ if (wb.isShared(cf)) {
+ System.out.println("Boot layer configuration is archived. Expected.");
+ } else {
+ throw new RuntimeException(
+ "FAILED. Boot layer configuration is not archived.");
+ }
+ } else {
+ if (!wb.isShared(cf)) {
+ System.out.println("Boot layer configuration is not archived. Expected.");
+ } else {
+ throw new RuntimeException(
+ "FAILED. Boot layer configuration is archived.");
+ }
+ }
+ }
}
< prev index next >