changeset 5452:d386e11a4db3

8065765: Missing space in output message from -XX:+CheckEndorsedAndExtDirs Reviewed-by: mchung
author igerasim
date Thu, 04 Dec 2014 22:12:36 +0300
parents 81e87cbbbf43
children 5fe5dd92998b
files src/share/vm/runtime/arguments.cpp test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java
diffstat 2 files changed, 41 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/arguments.cpp	Fri Feb 28 16:00:40 2014 +0400
+++ b/src/share/vm/runtime/arguments.cpp	Thu Dec 04 22:12:36 2014 +0300
@@ -3023,7 +3023,7 @@
 
   if (nonEmptyDirs > 0) {
     jio_fprintf(defaultStream::output_stream(),
-      "Endorsed standards override mechanism and extension mechanism"
+      "Endorsed standards override mechanism and extension mechanism "
       "will not be supported in a future release.\n"
       "Refer to JEP 220 for details (http://openjdk.java.net/jeps/220).\n");
     return false;
--- a/test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java	Fri Feb 28 16:00:40 2014 +0400
+++ b/test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java	Thu Dec 04 22:12:36 2014 +0300
@@ -26,10 +26,16 @@
  * @bug 8064667
  * @summary Sanity test for -XX:+CheckEndorsedAndExtDirs
  * @library /testlibrary
- * @run main/othervm -XX:+CheckEndorsedAndExtDirs EndorsedExtDirs
+ * @run main/othervm EndorsedExtDirs
  */
 
 import com.oracle.java.testlibrary.*;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -38,9 +44,32 @@
     public static void main(String arg[]) throws Exception {
         fatalError("-XX:+CheckEndorsedAndExtDirs", "-Djava.endorsed.dirs=foo");
         fatalError("-XX:+CheckEndorsedAndExtDirs", "-Djava.ext.dirs=bar");
+        testNonEmptySystemExtDirs();
     }
 
-    static void fatalError(String... args) throws Exception {
+    static void testNonEmptySystemExtDirs() throws Exception {
+        String home = System.getProperty("java.home");
+        Path ext = Paths.get(home, "lib", "ext");
+        String extDirs = System.getProperty("java.ext.dirs");
+        String[] dirs = extDirs.split(File.pathSeparator);
+        long count = 0;
+        for (String d : dirs) {
+            Path path = Paths.get(d);
+            if (Files.notExists(path) || path.equals(ext)) continue;
+            try (DirectoryStream<Path> jars =
+                    Files.newDirectoryStream(path, "*.jar"))
+            {
+                for (Path j : jars) {
+                    count++;
+                }
+            }
+        }
+        if (count > 0) {
+            fatalError("-XX:+CheckEndorsedAndExtDirs");
+        }
+    }
+
+    static ProcessBuilder newProcessBuilder(String... args) {
         List<String> commands = new ArrayList<>();
         String java = System.getProperty("java.home") + "/bin/java";
         commands.add(java);
@@ -51,8 +80,15 @@
         commands.add(cpath);
         commands.add("EndorsedExtDirs");
 
-        System.out.println("Launching " + commands);
-        ProcessBuilder pb = new ProcessBuilder(commands);
+        System.out.println("Process " + commands);
+        return new ProcessBuilder(commands);
+    }
+
+    static void fatalError(String... args) throws Exception {
+        fatalError(newProcessBuilder(args));
+    }
+
+    static void fatalError(ProcessBuilder pb) throws Exception {
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldContain("Could not create the Java Virtual Machine");
         output.shouldHaveExitValue(1);