changeset 39304:8d9ceb81a46e

8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module Reviewed-by: jlaskey, mchung
author sundar
date Tue, 28 Jun 2016 09:57:09 +0530
parents 5aefc354587e
children b10720494ec4
files jdk/test/tools/jlink/JLinkTest.java
diffstat 1 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/tools/jlink/JLinkTest.java	Mon Jun 27 20:22:04 2016 -0700
+++ b/jdk/test/tools/jlink/JLinkTest.java	Tue Jun 28 09:57:09 2016 +0530
@@ -53,7 +53,7 @@
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
  * @build tests.*
- * @run main/othervm -verbose:gc -Xmx1g JLinkTest
+ * @run main/othervm -Xmx1g JLinkTest
  */
 public class JLinkTest {
     // number of built-in plugins from jdk.jlink module
@@ -64,6 +64,10 @@
                     providers().size();
     }
 
+    private static boolean isOfJLinkModule(Plugin p) {
+        return p.getClass().getModule() == Plugin.class.getModule();
+    }
+
     public static void main(String[] args) throws Exception {
 
         Helper helper = Helper.newHelper();
@@ -72,20 +76,27 @@
             return;
         }
         helper.generateDefaultModules();
-        int numPlugins = getNumJlinkPlugins();
+        // expected num. of plugins from jdk.jlink module
+        int expectedJLinkPlugins = getNumJlinkPlugins();
+        int totalPlugins = 0;
         {
             // number of built-in plugins
             List<Plugin> builtInPlugins = new ArrayList<>();
             builtInPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
+            totalPlugins = builtInPlugins.size();
+            // actual num. of plugins loaded from jdk.jlink module
+            int actualJLinkPlugins = 0;
             for (Plugin p : builtInPlugins) {
                 p.getState();
                 p.getType();
+                if (isOfJLinkModule(p)) {
+                    actualJLinkPlugins++;
+                }
             }
-            // Note: other boot layer modules may provide jlink plugins.
-            // We should at least see the builtin plugins from jdk.jlink.
-            if (builtInPlugins.size() < numPlugins) {
-                throw new AssertionError("Found plugins doesn't match expected number : " +
-                        numPlugins + "\n" + builtInPlugins);
+            if (expectedJLinkPlugins != actualJLinkPlugins) {
+                throw new AssertionError("Actual plugins loaded from jdk.jlink: " +
+                        actualJLinkPlugins + " which doesn't match expected number : " +
+                        expectedJLinkPlugins);
             }
         }
 
@@ -150,9 +161,9 @@
             long number = Stream.of(output.split("\\R"))
                     .filter((s) -> s.matches("Plugin Name:.*"))
                     .count();
-            if (number != numPlugins) {
+            if (number != totalPlugins) {
                 System.err.println(output);
-                throw new AssertionError("Found: " + number + " expected " + numPlugins);
+                throw new AssertionError("Found: " + number + " expected " + totalPlugins);
             }
         }