Access restriction: The type 'BASE64Decoder' is not API

I'm trying to convert old project into maven project. But when project is maven then it shows warnings on class with import:

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

Access restriction: The type 'BASE64Decoder' is not API (restriction on required library 'C:Program FilesJavajre7librt.jar')

So what is the problem with it?


All sun.* and com.sun.* packages are private to a Java implementation. Any future release of Java may alter them, possibly in ways which may break application code that relies on them.

In contrast, all classes in java.*, javax.* and javafx.* packages are set in stone. Their names and their public members will not change and will not be removed (except, in theory, the deprecated ones).

That is why you're getting a message that those classes are not part of the public API. They are not meant for public consumption.

As of Java 8, you should be using java.util.Base64 instead. However, it looks like you're using Java 7, so you'll want to use DatatypeConverter.parseBase64Binary and DatatypeConverter.printBase64Binary instead.

It should also be mentioned that Java 9, which is expected to be released in July 2017, will not allow programs to access sun.* classes. See https://mreinhold.org/blog/jigsaw-module-system .

链接地址: http://www.djcxy.com/p/73810.html

上一篇: 如何在Linux上访问Java中的智能卡?

下一篇: 访问限制:“BASE64Decoder”类型不是API