Using internal sun classes with javac
I have found the answer myself.
When javac is compiling code it doesn't link against rt.jar
by default.
Instead it uses special symbol file lib/ct.sym
with class stubs.
Surprisingly this file contains many but not all of internal sun classes.
In my case one of those more-internal-than-usual classes was sun.awt.event.IgnorePaintEvent
.
And the answer to my question is: javac -XDignore.symbol.file
That's what javac uses for compiling rt.jar
.
In addition to the answer by @marcin-wisnicki if you're using Maven, note that the compiler plugin will silently drop any -XD flags, unless you also specify
<fork>true</fork>
: e.g.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
...
There's a better solution. First add the option to javac -XDenableSunApiLintControl
and then use @SupressWarnings("sunapi")
in your code.