use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.
the class T6358168 method testAnnotationProcessing.
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);
}
}
use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.
the class T6358168 method testNoAnnotationProcessing.
static void testNoAnnotationProcessing(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[] { "-d", "." });
JavaCompiler compiler = JavaCompiler.instance(context);
compiler.compile(List.of(f));
try {
compiler.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);
}
}
use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.
the class T6435291 method main.
public static void main(String... args) {
javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, null, null, null, null, null);
JavaCompiler compiler = JavaCompiler.instance(task.getContext());
try {
compiler.resolveIdent("T").complete();
} catch (BadClassFile e) {
System.err.println("Passed: expected completion failure " + e.getClass().getName());
return;
} catch (Exception e) {
throw new RuntimeException("Failed: unexpected exception");
}
throw new RuntimeException("Failed: no error reported");
}
use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.
the class T6330997 method main.
public static void main(String... args) {
increaseMajor("T1.class", 1);
increaseMajor("T2.class", 2);
javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, null, null, null, null, null);
JavaCompiler compiler = JavaCompiler.instance(task.getContext());
try {
compiler.resolveIdent("T1").complete();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed: unexpected exception while reading class T1");
}
try {
compiler.resolveIdent("T2").complete();
} catch (BadClassFile e) {
System.err.println("Passed: expected completion failure " + e.getClass().getName());
return;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed: unexpected exception while reading class T2");
}
throw new RuntimeException("Failed: no error reported");
}
use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.
the class TestResolveIdent method main.
public static void main(String[] args) throws IOException {
javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, null, null, null, null, null);
JavaCompiler compiler = JavaCompiler.instance(task.getContext());
System.out.println(compiler.resolveIdent(getDeprecatedClass().getCanonicalName()));
}
Aggregations