langtools/test/tools/javac/T6405099.java
changeset 2986 5370c4ae4f6f
parent 10 06bc494ca11e
child 5520 86e4b9a9da40
equal deleted inserted replaced
2985:f43e1241e7fb 2986:5370c4ae4f6f
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 6405099
    26  * @bug 6405099
    27  * @summary Compiler crashes when javac encounters /usr/jdk/packges/lib/ext with no 777 permissions
    27  * @summary Compiler crashes when javac encounters /usr/jdk/packges/lib/ext with no 777 permissions
    28  *
       
    29  * @ignore causes NPE in Java Test
       
    30  * @run main T6405099
       
    31  * @compile -extdirs bad T6405099.java
       
    32  */
    28  */
    33 
    29 
    34 import java.io.File;
    30 import java.io.*;
    35 
    31 
    36 public class T6405099
    32 public class T6405099
    37 {
    33 {
    38     public static void main(String[] args) {
    34     public static void main(String[] args) {
    39         File bad = new File("bad");
    35         File bad = new File("bad");
    40         bad.mkdir();
    36         try {
    41         bad.setReadable(false);
    37             bad.mkdir();
    42         bad.setExecutable(false);
    38             bad.setReadable(false);
       
    39             bad.setExecutable(false);
       
    40 
       
    41             test(bad);
       
    42 
       
    43         } finally {
       
    44             bad.setExecutable(true);
       
    45             bad.setReadable(true);
       
    46         }
       
    47     }
       
    48 
       
    49     static void test(File dir) {
       
    50         String[] args = {
       
    51             "-extdirs", dir.getPath(), "-d", ".",
       
    52             new File(System.getProperty("test.src", "."), "T6405099.java").getPath()
       
    53         };
       
    54 
       
    55         StringWriter sw = new StringWriter();
       
    56         PrintWriter pw = new PrintWriter(sw);
       
    57         int rc = com.sun.tools.javac.Main.compile(args, pw);
       
    58         if (rc != 0)
       
    59             throw new Error("compilation failed");
       
    60 
       
    61         System.out.println(sw);
    43     }
    62     }
    44 }
    63 }