Java 无法解析 jdk.internal 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24720665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't resolve jdk.internal package
提问by Teletha
NetBeans seems to be not able to resolve jdk.internal.* classes, but other internal API (i.e. com.sun.*) has no problem resolving.
NetBeans 似乎无法解析 jdk.internal.* 类,但其他内部 API(即 com.sun.*)解析没有问题。
Compile error: "jdk.internal.org.objectweb.asm.ClassReader does not exist"
(This package exists in rt.jar)
编译错误:“jdk.internal.org.objectweb.asm.ClassReader 不存在”
(这个包在rt.jar中存在)
Is this NetBeans bug?
这是 NetBeans 错误吗?
NetBeans: 8.0 (Build 201403101706)
Java: 1.8.0_20-ea; Java HotSpot(TM) 64-Bit Server VM 25.20-b20
System: Windows 7 version 6.1 running on amd64
NetBeans:8.0(内部版本 201403101706)
Java:1.8.0_20-ea;Java HotSpot(TM) 64 位服务器 VM 25.20-b20
系统:在 amd64 上运行的 Windows 7 版本 6.1
采纳答案by Teletha
This is javac's restriction. By default, javac does not read classes from rt.jar. It reads from a symbol file, which only contains standard API and some internal API (e.g. com.sun., com.oracle.and sun.*).
这是 javac 的限制。默认情况下,javac 不从 rt.jar 读取类。它从一个符号文件中读取,该文件只包含标准 API 和一些内部 API(例如 com.sun. 、 com.oracle.和 sun.*)。
To disable this mechanism, I can use javac -XDignore.symbol.file=true
option.
要禁用此机制,我可以使用 javac-XDignore.symbol.file=true
选项。
For Maven, edit POM file like the following.
对于 Maven,编辑 POM 文件如下。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
Now, I can build project without error, but Error notification remains on NetBeans editor UI. To remove these error, I append -J-DCachingArchiveProvider.disableCtSym
option in NETBEANS_HOME/etc/netbeans.conf file.
现在,我可以无错误地构建项目,但错误通知仍保留在 NetBeans 编辑器 UI 上。为了消除这些错误,我-J-DCachingArchiveProvider.disableCtSym
在 NETBEANS_HOME/etc/netbeans.conf 文件中附加了选项。
netbeans_default_options="... -J-DCachingArchiveProvider.disableCtSym=true"
Finally, I removed all error from NetBeans environment.
最后,我从 NetBeans 环境中删除了所有错误。