访问限制:由于对所需库的限制而无法访问.. \ jre \lib \\\ .jar [英] Access restriction: Is not accessible due to restriction on required library ..\jre\lib\rt.jar

查看:151
本文介绍了访问限制:由于对所需库的限制而无法访问.. \ jre \lib \\\ .jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从后面修改一些遗留代码并获得以下类型的错误:



访问限制:方法create(JAXBRIContext,Object)from由于对所需库的限制,无法访问类型标头.. \ jre \lib \\\ .jar



这些导入语句:

  import com.sun.xml.internal.bind.api.JAXBRIContext; 
import com.sun.xml.internal.ws.api.message.Header;
import com.sun.xml.internal.ws.api.message.Headers;
import com.sun.xml.internal.ws.developer.WSBindingProvider;

一直在寻找这可能意味着什么,以及如何解决它,但无法找到明确的答案。有些帖子似乎暗示我有一些JAR包含了实现类,这些类现在可用作核心java发行版的一部分,但据我所知,我所包含的JAR中没有包含上述类的不同/旧版本。 / p>

任何人都能告诉我这个错误是什么以及我如何解决这个问题?



感谢您提前获得的帮助,



Olli

解决方案

我碰到了类似的东西,我认为警告的原因是Eclipse试图阻止你使用内部 com.sun 作为工作区JRE的一部分安装但不属于公共Java API的软件包。



Justin在他的回答中说,更改编译器设置可以隐藏警告。更细粒度的方法是修改构建路径以明确允许访问相关包:


  1. 打开库选项卡Java Build Path项目属性窗口。

  2. 展开JRE系统库条目。

  3. 选择访问规则并点击编辑按钮。

  4. 单击结果对话框中的添加按钮。

  5. 对于新访问规则,将分辨率设置为可访问,将模式设置为 com / sun / xml / internal / **

添加此访问规则后,您的项目应该在没有这些警告的情况下建立。


I am trying to modify some legacy code from while back and getting the following kind of errors:

Access restriction: The method create(JAXBRIContext, Object) from the type Headers is not accessible due to restriction on required library ..\jre\lib\rt.jar

for these import statements:

import com.sun.xml.internal.bind.api.JAXBRIContext;
import com.sun.xml.internal.ws.api.message.Header;
import com.sun.xml.internal.ws.api.message.Headers;
import com.sun.xml.internal.ws.developer.WSBindingProvider;

Been searching what this might mean and how to fix it, however not been able to find a clear answer. Some posts seem to suggest that I have some JARs included that implement classes that are now available as part of the core java distribution, but as far as I can see none of the JARs I include contain different/older versions of the above classes.

Anyone able to tell me what this error is all about and how I might go about fixing this?

Thanks for your help already in advance,

Olli

解决方案

I ran into something similar, I think that the cause of the warning is Eclipse trying to discourage you from using the internal com.sun packages that are installed as part of your workspace JRE but which are not part of the public Java API.

As Justin says in his answer, changing your compiler settings can hide the warning. A more fine-grained approach is to modify your build path to explicitly allow access to the package in question:

  1. Open the Libraries tab of the Java Build Path project property window.
  2. Expand the JRE System Library entry.
  3. Select "Access rules" and hit the Edit button.
  4. Click the Add button in the resulting dialog.
  5. For the new access rule, set the resolution to Accessible and the pattern to "com/sun/xml/internal/**".

After adding this access rule, your project should build without these warning.

这篇关于访问限制:由于对所需库的限制而无法访问.. \ jre \lib \\\ .jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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