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
.