33 public class CheckArchivedModuleApp { 34 static WhiteBox wb; 35 public static void main(String args[]) throws Exception { 36 wb = WhiteBox.getWhiteBox(); 37 38 if (!wb.areOpenArchiveHeapObjectsMapped()) { 39 System.out.println("Archived open_archive_heap objects are not mapped."); 40 System.out.println("This may happen during normal operation. Test Skipped."); 41 return; 42 } 43 44 boolean expectArchived = "yes".equals(args[0]); 45 checkModuleDescriptors(expectArchived); 46 } 47 48 private static void checkModuleDescriptors(boolean expectArchived) { 49 Set<Module> modules = ModuleLayer.boot().modules(); 50 for (Module m : modules) { 51 ModuleDescriptor md = m.getDescriptor(); 52 String name = md.name(); 53 if (expectArchived && wb.isShared(md)) { 54 System.out.println(name + " is archived. Expected."); 55 } else if (!expectArchived && !wb.isShared(md)) { 56 System.out.println(name + " is not archived. Expected."); 57 } else if (expectArchived) { 58 throw new RuntimeException( 59 "FAILED. " + name + " is not archived. Expect archived."); 60 } else { 61 throw new RuntimeException( 62 "FAILED. " + name + " is archived. Expect not archived."); 63 } 64 } 65 } 66 } | 33 public class CheckArchivedModuleApp { 34 static WhiteBox wb; 35 public static void main(String args[]) throws Exception { 36 wb = WhiteBox.getWhiteBox(); 37 38 if (!wb.areOpenArchiveHeapObjectsMapped()) { 39 System.out.println("Archived open_archive_heap objects are not mapped."); 40 System.out.println("This may happen during normal operation. Test Skipped."); 41 return; 42 } 43 44 boolean expectArchived = "yes".equals(args[0]); 45 checkModuleDescriptors(expectArchived); 46 } 47 48 private static void checkModuleDescriptors(boolean expectArchived) { 49 Set<Module> modules = ModuleLayer.boot().modules(); 50 for (Module m : modules) { 51 ModuleDescriptor md = m.getDescriptor(); 52 String name = md.name(); 53 if (expectArchived) { 54 if (wb.isShared(md)) { 55 System.out.println(name + " is archived. Expected."); 56 } else { 57 throw new RuntimeException( 58 "FAILED. " + name + " is not archived. Expect archived."); 59 } 60 } else { 61 if (!wb.isShared(md)) { 62 System.out.println(name + " is not archived. Expected."); 63 } else { 64 throw new RuntimeException( 65 "FAILED. " + name + " is archived. Expect not archived."); 66 } 67 } 68 } 69 } 70 } |