jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java
changeset 40124 01f8745abd3c
parent 39834 53a6fb443c20
child 43185 d75d9ff8d4e7
--- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java	Thu Aug 04 14:29:27 2016 -0700
+++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java	Fri Aug 05 09:42:05 2016 +0530
@@ -30,6 +30,9 @@
  * @run main ExcludeVMPluginTest
  */
 import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.Map;
 import jdk.tools.jlink.internal.ResourcePoolManager;
@@ -167,6 +170,13 @@
         poolMgr.add(
             ResourcePoolEntry.create("/java.base/native/jvm.cfg",
                 ResourcePoolEntry.Type.NATIVE_LIB, jvmcfgContent));
+
+        // java.base/module-info.class is used by exclude vm plugin
+        // to get current osName(). We read it from jrt-fs and add a
+        // ResourcePoolEntry
+        poolMgr.add(
+            ResourcePoolEntry.create("/java.base/module-info.class",
+                ResourcePoolEntry.Type.CLASS_OR_RESOURCE, getJavaBaseModuleInfo()));
         for (String in : input) {
             poolMgr.add(ResourcePoolEntry.create(in,
                     ResourcePoolEntry.Type.NATIVE_LIB, new byte[0]));
@@ -187,15 +197,19 @@
             throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg);
         }
 
-        if (out.entryCount() != (expectedOutput.length + 1)) {
+        // Apart from native resources, we should find jvm.cfg and
+        // java.base/module-info.class. So, we add 2 here to the
+        // expected count!
+        if (out.entryCount() != (expectedOutput.length + 2)) {
             out.entries().forEach(m -> {
                 System.err.println(m.path());
             });
-            throw new Exception("Invalid output size " + out.entryCount() + " expected " + (expectedOutput.length + 1));
+            throw new Exception("Invalid output size " + out.entryCount() + " expected " + (expectedOutput.length + 2));
         }
 
         out.entries().forEach(md -> {
-            if (md.path().equals("/java.base/native/jvm.cfg")) {
+            if (md.path().equals("/java.base/native/jvm.cfg") ||
+                md.path().equals("/java.base/module-info.class")) {
                 return;
             }
             boolean contained = false;
@@ -209,7 +223,11 @@
                 throw new RuntimeException(md.path() + " not expected");
             }
         });
+    }
 
+    // read java.base/module-info.class from jrt-fs
+    private static Path getJavaBaseModuleInfo() {
+        return Paths.get(URI.create("jrt:/modules/java.base/module-info.class"));
     }
 
     private static boolean isWindows() {