Question

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

Était-ce utile?

La solution

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top