8191533: jar --describe-module prints service provider class names in lower case
authorsherman
Wed, 16 May 2018 10:12:10 -0700
changeset 50130 aefd3c7f5373
parent 50129 7db531b83661
child 50151 e2eff4dcebbd
8191533: jar --describe-module prints service provider class names in lower case Reviewed-by: alanb
src/jdk.jartool/share/classes/sun/tools/jar/Main.java
src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java
test/jdk/tools/jar/modularJar/Basic.java
--- a/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Wed May 16 09:40:57 2018 -0700
+++ b/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Wed May 16 10:12:10 2018 -0700
@@ -1911,12 +1911,16 @@
         return true;
     }
 
-    static <T> String toString(Collection<T> set) {
+    static <T> String toLowerCaseString(Collection<T> set) {
         if (set.isEmpty()) { return ""; }
         return " " + set.stream().map(e -> e.toString().toLowerCase(Locale.ROOT))
                   .sorted().collect(joining(" "));
     }
 
+    static <T> String toString(Collection<T> set) {
+        if (set.isEmpty()) { return ""; }
+        return " " + set.stream().map(e -> e.toString()).sorted().collect(joining(" "));
+    }
 
     private void describeModule(InputStream entryInputStream, String uriString)
         throws IOException
@@ -1952,12 +1956,14 @@
                 .sorted(Comparator.comparing(Exports::source))
                 .filter(e -> !e.isQualified())
                 .forEach(e -> sb.append("exports ").append(e.source())
-                                .append(toString(e.modifiers())).append("\n"));
+                                .append(toLowerCaseString(e.modifiers()))
+                                .append("\n"));
 
         // dependences
         md.requires().stream().sorted()
                 .forEach(r -> sb.append("requires ").append(r.name())
-                                .append(toString(r.modifiers())).append("\n"));
+                                .append(toLowerCaseString(r.modifiers()))
+                                .append("\n"));
 
         // service use and provides
         md.uses().stream().sorted()
@@ -1975,7 +1981,7 @@
                 .sorted(Comparator.comparing(Exports::source))
                 .filter(Exports::isQualified)
                 .forEach(e -> sb.append("qualified exports ").append(e.source())
-                                .append(" to").append(toString(e.targets()))
+                                .append(" to").append(toLowerCaseString(e.targets()))
                                 .append("\n"));
 
         // open packages
@@ -1983,15 +1989,15 @@
                 .sorted(Comparator.comparing(Opens::source))
                 .filter(o -> !o.isQualified())
                 .forEach(o -> sb.append("opens ").append(o.source())
-                                 .append(toString(o.modifiers()))
+                                 .append(toLowerCaseString(o.modifiers()))
                                  .append("\n"));
 
         md.opens().stream()
                 .sorted(Comparator.comparing(Opens::source))
                 .filter(Opens::isQualified)
                 .forEach(o -> sb.append("qualified opens ").append(o.source())
-                                 .append(toString(o.modifiers()))
-                                 .append(" to").append(toString(o.targets()))
+                                 .append(toLowerCaseString(o.modifiers()))
+                                 .append(" to").append(toLowerCaseString(o.targets()))
                                  .append("\n"));
 
         // non-exported/non-open packages
--- a/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Wed May 16 09:40:57 2018 -0700
+++ b/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Wed May 16 10:12:10 2018 -0700
@@ -320,12 +320,17 @@
         }
     }
 
-    static <T> String toString(Collection<T> c) {
+    static <T> String toLowerCaseString(Collection<T> c) {
         if (c.isEmpty()) { return ""; }
         return " " + c.stream().map(e -> e.toString().toLowerCase(Locale.ROOT))
                 .sorted().collect(joining(" "));
     }
 
+    static <T> String toString(Collection<T> c) {
+        if (c.isEmpty()) { return ""; }
+        return " " + c.stream().map(e -> e.toString()).sorted().collect(joining(" "));
+    }
+
     private void describeModule(ModuleDescriptor md,
                                 ModuleTarget target,
                                 ModuleHashes hashes)
@@ -346,12 +351,12 @@
                 .sorted(Comparator.comparing(Exports::source))
                 .filter(e -> !e.isQualified())
                 .forEach(e -> sb.append("exports ").append(e.source())
-                                .append(toString(e.modifiers())).append("\n"));
+                                .append(toLowerCaseString(e.modifiers())).append("\n"));
 
         // dependences
         md.requires().stream().sorted()
                 .forEach(r -> sb.append("requires ").append(r.name())
-                                .append(toString(r.modifiers())).append("\n"));
+                                .append(toLowerCaseString(r.modifiers())).append("\n"));
 
         // service use and provides
         md.uses().stream().sorted()
@@ -369,7 +374,7 @@
                 .sorted(Comparator.comparing(Exports::source))
                 .filter(Exports::isQualified)
                 .forEach(e -> sb.append("qualified exports ").append(e.source())
-                                .append(" to").append(toString(e.targets()))
+                                .append(" to").append(toLowerCaseString(e.targets()))
                                 .append("\n"));
 
         // open packages
@@ -377,15 +382,15 @@
                 .sorted(Comparator.comparing(Opens::source))
                 .filter(o -> !o.isQualified())
                 .forEach(o -> sb.append("opens ").append(o.source())
-                                 .append(toString(o.modifiers()))
+                                 .append(toLowerCaseString(o.modifiers()))
                                  .append("\n"));
 
         md.opens().stream()
                 .sorted(Comparator.comparing(Opens::source))
                 .filter(Opens::isQualified)
                 .forEach(o -> sb.append("qualified opens ").append(o.source())
-                                 .append(toString(o.modifiers()))
-                                 .append(" to").append(toString(o.targets()))
+                                 .append(toLowerCaseString(o.modifiers()))
+                                 .append(" to").append(toLowerCaseString(o.targets()))
                                  .append("\n"));
 
         // non-exported/non-open packages
--- a/test/jdk/tools/jar/modularJar/Basic.java	Wed May 16 09:40:57 2018 -0700
+++ b/test/jdk/tools/jar/modularJar/Basic.java	Wed May 16 10:12:10 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 
 /*
  * @test
- * @bug 8167328 8171830 8165640 8174248 8176772 8196748
+ * @bug 8167328 8171830 8165640 8174248 8176772 8196748 8191533
  * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
@@ -666,6 +666,17 @@
             "-C", modClasses.toString(), "jdk/test/baz/BazService.class",
             "-C", modClasses.toString(), "jdk/test/baz/internal/BazServiceImpl.class")
             .assertSuccess();
+
+        for (String option : new String[]  {"--describe-module", "-d" }) {
+            jar(option,
+                "--file=" + modularJar.toString())
+                .assertSuccess()
+                .resultChecker(r ->
+                    assertTrue(r.output.contains("provides jdk.test.baz.BazService with jdk.test.baz.internal.BazServiceImpl"),
+                               "Expected to find ", "provides jdk.test.baz.BazService with jdk.test.baz.internal.BazServiceImpl",
+                               " in [", r.output, "]")
+                );
+        }
     }
 
     @Test