< prev index next >

test/hotspot/jtreg/runtime/appcds/cacheObject/CheckArchivedModuleApp.java

Print this page

        

@@ -21,10 +21,11 @@
  * questions.
  *
  */
 
 import java.io.File;
+import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.util.Set;
 import sun.hotspot.WhiteBox;
 
 //

@@ -39,20 +40,22 @@
             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);
+        boolean expectArchivedDescriptors = "yes".equals(args[0]);
+        boolean expectArchivedConfiguration = "yes".equals(args[1]);
+        checkModuleDescriptors(expectArchivedDescriptors);
+        checkConfiguration(expectArchivedConfiguration);
     }
 
-    private static void checkModuleDescriptors(boolean expectArchived) {
+    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 (expectArchived) {
+            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,6 +68,25 @@
                         "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 >