javajavacinternal

Using internal sun classes with javac


Is there a way to disable restrictions of javac 1.6.0_22 that prevent me from using JRE internal classes like sun.awt.event.* ?

I'm not looking for:

  1. an explanation why it is forbidden.
  2. suggestion to use different classes
  3. suggestion to use reflection
  4. suggestion to use ecj/eclipse

I just want to know if it is possible or not, and if it is then how.


Solution

  • 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.