javac's hidden options...

Sorry about not writing much these days. Hoping to blog again...

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
When I was reading javac source code, I stumbled upon "-XD" handling code in RecognizedOptions class in com.sun.tools.javac.main package. 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

  javac -XD-printflat Main.java

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!
Comments:

Post a Comment:
Comments are closed for this entry.
About

sundararajan

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks
Links

No bookmarks in folder

Blogroll

No bookmarks in folder

News

No bookmarks in folder