import java.io.File; import javax.tools.JavaCompiler; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider;; // NOTE: extra semicolon for test
import com.sun.source.tree.CompilationUnitTree; import com.sun.source.tree.ImportTree; import com.sun.source.util.JavacTask;
; // NOTE: extra semicolon for test
publicclass T6963934 { publicstaticvoid main(String[] args) throws Exception {
File testSrc = new File(System.getProperty("test.src"));
File thisSrc = new File(testSrc, T6963934.class.getSimpleName() + ".java");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
JavacTask task = (JavacTask) compiler.getTask(null, fileManager, null, null, null,
fileManager.getJavaFileObjects(thisSrc));
CompilationUnitTree tree = task.parse().iterator().next(); int count = 0; for (ImportTree importTree : tree.getImports()) {
System.out.println(importTree);
count++;
} int expected = 7; if (count != expected) thrownew Exception("unexpected number of imports found: " + count + ", expected: " + expected);
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-10)
¤
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.