javac's hidden options...
By sundararajan on Sep 10, 2007
Earlier, I blogged about javac's hidden option "-printflat". I modified javac source to "open up" the hidden "-printflat" flag. Well, it turns out that you don't need to do that!! As per javac source docs, there are 4 kinds of options:
- standard public options, e.g. -classpath
- extended public options, beginning -X, e.g. -Xlint
- hidden options -- not public or documented, e.g. -fullversion
- even more hidden options -- typically for debugging the compiler, beginning -XD, e.g. -XDrawDiagnostics
com.sun.tools.javac.mainpackage. It appears that not much check is done by -XD handling code. With -XDxyz, the code puts "xyz", "xyz" as key-value pairs in compiler's options table. And with "-XDxyz=abc" the -XD handling code puts "xyz", "abc" as key-value pairs in options table. So, we can use
to achieve what was done my previous blog entry. -XD-printflat would put "-printflat" in compiler's internal options table. No need to modify javac sources at all!
javac -XD-printflat Main.java