Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API

怎么解决BASE64找不到JAR包问题,之前写过一篇,但是只记录了一种方法,本文列举三种解决方法:

最近维护以前的一个项目,发现用到BASE64编码解码的地方出现了错误提示,如下图所示:

这是eclipse设置问题,eclipse默认把这些受访问限制的API设成了ERROR,下面列出几种解决方案:

方案一:
右键项目-->Build Path-->Configure  Build  Path-->JRE System Library-->Access rules-->Add,关键步骤截图如下:

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API

 

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API

提示错误信息消失,错误解决:

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API

方案二:
Windows -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and trstricted API -> Forbidden reference (access rules): -> change to warning

Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API

方案三:
在build path中先移除JRE System Library,再添加JRE System Library,重新编译后就可以了

 Access restriction: The method 'CharacterDecoder.decodeBuffer(String)' is not API
————————————————
版权声明:本文为****博主「pcwl1206」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.****.net/pcwl1206/article/details/83316884