< prev index next >

test/tools/javap/T6868539.java

Print this page
rev 3478 : Other minor touchups


  41 
  42     void run() {
  43         String output = javap("T6868539");
  44         verify(output, "Utf8 +java/lang/String");                                   // 1: Utf8
  45                                                                                     // 2: currently unused
  46         verify(output, "Integer +123456");                                          // 3: Integer
  47         verify(output, "Float +123456.0f");                                         // 4: Float
  48         verify(output, "Long +123456l");                                            // 5: Long
  49         verify(output, "Double +123456.0d");                                        // 6: Double
  50         verify(output, "Class +#[0-9]+ +// +T6868539");                             // 7: Class
  51         verify(output, "String +#[0-9]+ +// +not found");                           // 8: String
  52         verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I");       // 9: Fieldref
  53         verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V");   // 10: Methodref
  54         verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
  55                                                                                     // 11: InterfaceMethodref
  56         verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V");            // 12: NameAndType
  57         if (errors > 0)
  58             throw new Error(errors + " found.");
  59     }
  60 


  61     void verify(String output, String... expects) {
  62         for (String expect: expects) {
  63             if (!output.matches("(?s).*" + expect + ".*"))
  64                 error(expect + " not found");
  65         }
  66     }
  67 
  68     void error(String msg) {
  69         System.err.println(msg);
  70         errors++;
  71     }
  72 
  73     int errors;
  74 
  75     String javap(String className) {
  76         String testClasses = System.getProperty("test.classes", ".");
  77         StringWriter sw = new StringWriter();
  78         PrintWriter out = new PrintWriter(sw);
  79         String[] args = { "-v", "-classpath", testClasses, className };
  80         int rc = com.sun.tools.javap.Main.run(args, out);
  81         if (rc != 0)
  82             throw new Error("javap failed. rc=" + rc);
  83         out.close();
  84         String output = sw.toString();


  41 
  42     void run() {
  43         String output = javap("T6868539");
  44         verify(output, "Utf8 +java/lang/String");                                   // 1: Utf8
  45                                                                                     // 2: currently unused
  46         verify(output, "Integer +123456");                                          // 3: Integer
  47         verify(output, "Float +123456.0f");                                         // 4: Float
  48         verify(output, "Long +123456l");                                            // 5: Long
  49         verify(output, "Double +123456.0d");                                        // 6: Double
  50         verify(output, "Class +#[0-9]+ +// +T6868539");                             // 7: Class
  51         verify(output, "String +#[0-9]+ +// +not found");                           // 8: String
  52         verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I");       // 9: Fieldref
  53         verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V");   // 10: Methodref
  54         verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
  55                                                                                     // 11: InterfaceMethodref
  56         verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V");            // 12: NameAndType
  57         if (errors > 0)
  58             throw new Error(errors + " found.");
  59     }
  60 
  61     String notFound = " not found";
  62 
  63     void verify(String output, String... expects) {
  64         for (String expect: expects) {
  65             if (!output.matches("(?s).*" + expect + ".*"))
  66                 error(expect + notFound);
  67         }
  68     }
  69 
  70     void error(String msg) {
  71         System.err.println(msg);
  72         errors++;
  73     }
  74 
  75     int errors;
  76 
  77     String javap(String className) {
  78         String testClasses = System.getProperty("test.classes", ".");
  79         StringWriter sw = new StringWriter();
  80         PrintWriter out = new PrintWriter(sw);
  81         String[] args = { "-v", "-classpath", testClasses, className };
  82         int rc = com.sun.tools.javap.Main.run(args, out);
  83         if (rc != 0)
  84             throw new Error("javap failed. rc=" + rc);
  85         out.close();
  86         String output = sw.toString();
< prev index next >