本文整理汇总了Java中com.sun.tools.javac.main.JavaCompiler.initProcessAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java JavaCompiler.initProcessAnnotations方法的具体用法?Java JavaCompiler.initProcessAnnotations怎么用?Java JavaCompiler.initProcessAnnotations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.main.JavaCompiler
的用法示例。
在下文中一共展示了JavaCompiler.initProcessAnnotations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAnnotationProcessing
import com.sun.tools.javac.main.JavaCompiler; //导入方法依赖的package包/类
static void testAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable {
Context context = new Context();
fm.setContext(context);
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
compilerMain.setOptions(Options.instance(context));
compilerMain.filenames = new LinkedHashSet<File>();
compilerMain.processArgs(new String[] {
"-XprintRounds",
"-processorpath", testClasses,
"-processor", self,
"-d", "."});
JavaCompiler compiler = JavaCompiler.instance(context);
compiler.initProcessAnnotations(null);
JavaCompiler compiler2 = compiler.processAnnotations(compiler.enterTrees(compiler.parseFiles(List.of(f))));
try {
compiler2.compile(List.of(f));
throw new Error("Error: AssertionError not thrown after second call of compile");
} catch (AssertionError e) {
System.err.println("Exception from compiler (expected): " + e);
}
}
示例2: testAnnotationProcessing
import com.sun.tools.javac.main.JavaCompiler; //导入方法依赖的package包/类
static void testAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable {
Context context = new Context();
fm.setContext(context);
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
compilerMain.setOptions(Options.instance(context));
compilerMain.filenames = new ListBuffer<File>();
compilerMain.processArgs(new String[] {
"-XprintRounds",
"-processorpath", testClasses,
"-processor", self,
"-d", "."});
JavaCompiler compiler = JavaCompiler.instance(context);
compiler.initProcessAnnotations(null);
JavaCompiler compiler2 = compiler.processAnnotations(compiler.enterTrees(compiler.parseFiles(List.of(f))));
try {
compiler2.compile(List.of(f));
throw new Error("Error: AssertionError not thrown after second call of compile");
} catch (AssertionError e) {
System.err.println("Exception from compiler (expected): " + e);
}
}