8065765: Missing space in output message from -XX:+CheckEndorsedAndExtDirs

Tue, 02 Dec 2014 08:42:50 -0800

author
mchung
date
Tue, 02 Dec 2014 08:42:50 -0800
changeset 7398
c03d85ef5e6a
parent 7396
b12418b0d05c
child 7399
0b86bdf28e07

8065765: Missing space in output message from -XX:+CheckEndorsedAndExtDirs
Reviewed-by: hseigel, ccheung

src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/runtime/arguments.cpp	Tue Dec 02 10:43:43 2014 +0000
     1.2 +++ b/src/share/vm/runtime/arguments.cpp	Tue Dec 02 08:42:50 2014 -0800
     1.3 @@ -3543,7 +3543,7 @@
     1.4  
     1.5    if (nonEmptyDirs > 0) {
     1.6      jio_fprintf(defaultStream::output_stream(),
     1.7 -      "Endorsed standards override mechanism and extension mechanism"
     1.8 +      "Endorsed standards override mechanism and extension mechanism "
     1.9        "will not be supported in a future release.\n"
    1.10        "Refer to JEP 220 for details (http://openjdk.java.net/jeps/220).\n");
    1.11      return false;
     2.1 --- a/test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java	Tue Dec 02 10:43:43 2014 +0000
     2.2 +++ b/test/runtime/CheckEndorsedAndExtDirs/EndorsedExtDirs.java	Tue Dec 02 08:42:50 2014 -0800
     2.3 @@ -26,10 +26,16 @@
     2.4   * @bug 8064667
     2.5   * @summary Sanity test for -XX:+CheckEndorsedAndExtDirs
     2.6   * @library /testlibrary
     2.7 - * @run main/othervm -XX:+CheckEndorsedAndExtDirs EndorsedExtDirs
     2.8 + * @run main/othervm EndorsedExtDirs
     2.9   */
    2.10  
    2.11  import com.oracle.java.testlibrary.*;
    2.12 +import java.io.File;
    2.13 +import java.io.IOException;
    2.14 +import java.nio.file.attribute.BasicFileAttributes;
    2.15 +import java.nio.file.Files;
    2.16 +import java.nio.file.Path;
    2.17 +import java.nio.file.Paths;
    2.18  import java.util.ArrayList;
    2.19  import java.util.List;
    2.20  
    2.21 @@ -38,9 +44,28 @@
    2.22      public static void main(String arg[]) throws Exception {
    2.23          fatalError("-XX:+CheckEndorsedAndExtDirs", "-Djava.endorsed.dirs=foo");
    2.24          fatalError("-XX:+CheckEndorsedAndExtDirs", "-Djava.ext.dirs=bar");
    2.25 +        testNonEmptySystemExtDirs();
    2.26      }
    2.27  
    2.28 -    static void fatalError(String... args) throws Exception {
    2.29 +    static void testNonEmptySystemExtDirs() throws Exception {
    2.30 +        String home = System.getProperty("java.home");
    2.31 +        Path ext = Paths.get(home, "lib", "ext");
    2.32 +        String extDirs = System.getProperty("java.ext.dirs");
    2.33 +        String[] dirs = extDirs.split(File.pathSeparator);
    2.34 +        long count = 0;
    2.35 +        for (String d : dirs) {
    2.36 +            Path path = Paths.get(d);
    2.37 +            if (Files.notExists(path) || path.equals(ext)) continue;
    2.38 +            count += Files.find(path, 1, (Path p, BasicFileAttributes attr)
    2.39 +                                       -> p.getFileName().toString().endsWith(".jar"))
    2.40 +                          .count();
    2.41 +        }
    2.42 +        if (count > 0) {
    2.43 +            fatalError("-XX:+CheckEndorsedAndExtDirs");
    2.44 +        }
    2.45 +    }
    2.46 +
    2.47 +    static ProcessBuilder newProcessBuilder(String... args) {
    2.48          List<String> commands = new ArrayList<>();
    2.49          String java = System.getProperty("java.home") + "/bin/java";
    2.50          commands.add(java);
    2.51 @@ -51,8 +76,15 @@
    2.52          commands.add(cpath);
    2.53          commands.add("EndorsedExtDirs");
    2.54  
    2.55 -        System.out.println("Launching " + commands);
    2.56 -        ProcessBuilder pb = new ProcessBuilder(commands);
    2.57 +        System.out.println("Process " + commands);
    2.58 +        return new ProcessBuilder(commands);
    2.59 +    }
    2.60 +
    2.61 +    static void fatalError(String... args) throws Exception {
    2.62 +        fatalError(newProcessBuilder(args));
    2.63 +    }
    2.64 +
    2.65 +    static void fatalError(ProcessBuilder pb) throws Exception {
    2.66          OutputAnalyzer output = new OutputAnalyzer(pb.start());
    2.67          output.shouldContain("Could not create the Java Virtual Machine");
    2.68          output.shouldHaveExitValue(1);

mercurial