void run() throws Exception {
File srcDir = new File("src");
srcDir.mkdirs();
File classesDir = new File("classes");
classesDir.mkdirs();
File f = writeFile(new File(srcDir, "E.java"), "enum E { A, B }");
javac("-d", classesDir.getPath(), f.getPath());
String out = javap("-p", "-v", new File(classesDir, "E.class").getPath());
Pattern expect = Pattern.compile("\\Qprivate E();\\E\\s+\\Qdescriptor: (Ljava/lang/String;I)V\\E");
checkContains(out, expect);
}
File writeFile(File f, String body) throws IOException { try (FileWriter out = new FileWriter(f)) {
out.write(body);
} return f;
}
void javac(String... args) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw); int rc = com.sun.tools.javac.Main.compile(args, pw);
pw.flush();
String out = sw.toString(); if (!out.isEmpty())
System.err.println(out); if (rc != 0) thrownew Exception("compilation failed");
}
String javap(String... args) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw); int rc = com.sun.tools.javap.Main.run(args, pw);
pw.flush();
String out = sw.toString(); if (!out.isEmpty())
System.err.println(out); if (rc != 0) thrownew Exception("javap failed"); return out;
}
void checkContains(String s, Pattern p) throws Exception { if (!p.matcher(s).find()) thrownew Exception("expected pattern not found: " + p);
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.3Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.