[quote]I haven’t investigated it yet, but hopefully its not too hard to use.
[/quote]
See and judge for yourself.
Test code:
public class Test {
private int hidden = 99;
public getHiddenVariable() {
return hidden;
}
public static void main(String argv[]) {
System.out.println("Hidden variable:" + new Test().getHiddenVariable());
}
}
Compiler code:
public class CompileTest {
public static void main(String[] args) {
File[] files = { new File("C:/java/Test.java") };
JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool();
StandardJavaFileManager fileManager = compiler
.getStandardFileManager(null);
Iterable<? extends JavaFileObject> compilationUnits = fileManager
.getJavaFileObjectsFromFiles(Arrays.asList(files));
compiler.getTask(null, fileManager, null, null, null, compilationUnits)
.run();
try {
fileManager.close();
} catch (IOException e) {
e.printStackTrace();
}
}
And standard output:
C:\java\Test.java:5: invalid method declaration; return type required
public getHiddenVariable() {
^
1 error
Nice error messages as well!
