How to add debug information when compiling with Java's Compiler API
-
27-09-2019 - |
Question
What do I need to do to control whether my classes compiled with a JavaCompiler
will include debug information or not?
I'm thinking it has something to do with the getTask()
-method's options
parameter, but I can't find any references on whether that assumption is correct to start with, and if so, what is the correct way to control that?
Solution
Maybe you could search further in the "options" argument of the getTask() method, which allows to pass options to the compiler; in your case it would be some "-g:none" option as detailed in http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#options
OTHER TIPS
Check out http://www.javabeat.net/articles/73-the-java-60-compiler-api-1.html In JavaCompiler class there is a field to pass in the options -g is the one for debug information.