質問

I'd be interested to know whether it's possible to run javac or an equivalent tool to just analyze the given Java source code without actually generating any code.

The usefulness would lie in being able to verify whether my Java code is correct without having to generate any .class output files.

Thanks

役に立ちましたか?

解決

Yes, there is. I have never tried it, so I can not verify that this actually works, but ...

javac -proc:only

means that only annotation processing is done, without any subsequent compilation.

If that did not work, what is wrong with just using

javac -d /dev/null

他のヒント

You may be interested in the Java Tools API. This API gives you programmatic control over the Java compiler and you can pretty much write a program to read and analyze a Java program. The API docs give an example of compiling a list of compiler error messages.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top