< prev index next >

test/langtools/tools/javap/8006334/JavapTaskCtorFailWithNPE.java

Print this page

30  */
31 
32 import java.io.File;
33 import java.util.Arrays;
34 import java.io.PrintWriter;
35 import java.io.StringWriter;
36 import java.util.List;
37 import java.util.Locale;
38 import javax.tools.Diagnostic;
39 import javax.tools.DiagnosticCollector;
40 import javax.tools.JavaFileManager;
41 import javax.tools.JavaFileObject;
42 import com.sun.tools.javap.JavapFileManager;
43 import com.sun.tools.javap.JavapTask;
44 
45 public class JavapTaskCtorFailWithNPE {
46 
47     //we will also check the output just to confirm that we get the expected one
48     private static final String expOutput =
49         "Compiled from \"JavapTaskCtorFailWithNPE.java\"\n" +
50         "public class JavapTaskCtorFailWithNPE {\n" +
51         "  public JavapTaskCtorFailWithNPE();\n" +
52         "  public static void main(java.lang.String[]);\n" +
53         "}\n";
54 
55     public static void main(String[] args) {
56         new JavapTaskCtorFailWithNPE().run();
57     }
58 
59     private void run() {
60         File classToCheck = new File(System.getProperty("test.classes"),
61             getClass().getSimpleName() + ".class");
62 
63         DiagnosticCollector<JavaFileObject> dc =
64                 new DiagnosticCollector<JavaFileObject>();
65         StringWriter sw = new StringWriter();
66         PrintWriter pw = new PrintWriter(sw);
67         JavaFileManager fm = JavapFileManager.create(dc, pw);
68         JavapTask t = new JavapTask(pw, fm, dc, null,
69                 Arrays.asList(classToCheck.getPath()));
70         if (t.run() != 0)

30  */
31 
32 import java.io.File;
33 import java.util.Arrays;
34 import java.io.PrintWriter;
35 import java.io.StringWriter;
36 import java.util.List;
37 import java.util.Locale;
38 import javax.tools.Diagnostic;
39 import javax.tools.DiagnosticCollector;
40 import javax.tools.JavaFileManager;
41 import javax.tools.JavaFileObject;
42 import com.sun.tools.javap.JavapFileManager;
43 import com.sun.tools.javap.JavapTask;
44 
45 public class JavapTaskCtorFailWithNPE {
46 
47     //we will also check the output just to confirm that we get the expected one
48     private static final String expOutput =
49         "Compiled from \"JavapTaskCtorFailWithNPE.java\"\n" +
50         "public identity class JavapTaskCtorFailWithNPE {\n" +
51         "  public JavapTaskCtorFailWithNPE();\n" +
52         "  public static void main(java.lang.String[]);\n" +
53         "}\n";
54 
55     public static void main(String[] args) {
56         new JavapTaskCtorFailWithNPE().run();
57     }
58 
59     private void run() {
60         File classToCheck = new File(System.getProperty("test.classes"),
61             getClass().getSimpleName() + ".class");
62 
63         DiagnosticCollector<JavaFileObject> dc =
64                 new DiagnosticCollector<JavaFileObject>();
65         StringWriter sw = new StringWriter();
66         PrintWriter pw = new PrintWriter(sw);
67         JavaFileManager fm = JavapFileManager.create(dc, pw);
68         JavapTask t = new JavapTask(pw, fm, dc, null,
69                 Arrays.asList(classToCheck.getPath()));
70         if (t.run() != 0)
< prev index next >