在 javac 中使用内部 sun 类 [英] Using internal sun classes with javac

查看:49
本文介绍了在 javac 中使用内部 sun 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法禁用 javac 1.6.0_22 的限制,阻止我使用像 sun.awt.event.* 这样的 JRE 内部类?

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.* ?

不想寻找:

  1. 解释为什么被禁止.
  2. 建议使用不同的类
  3. 建议使用反射
  4. 建议使用 ecj/eclipse

我只是想知道这是否可能,如果可能,那么如何.

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

推荐答案

我自己找到了答案.

当 javac 编译代码时,它默认不链接 rt.jar.相反,它使用带有类存根的特殊符号文件 lib/ct.sym.

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.

令人惊讶的是,这个文件包含许多但不是全部的内部 sun 类.在我的例子中,其中一个比平常更内部的类是 sun.awt.event.IgnorePaintEvent.

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.

我的问题的答案是:javac -XDignore.symbol.file

这就是 javac 用于编译 rt.jar 的内容.

That's what javac uses for compiling rt.jar.

这篇关于在 javac 中使用内部 sun 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆