我正在使用Eclipse.我有以下代码行:
wr.write(new sun.misc.BASE64Encoder().encode(buf));
Run Code Online (Sandbox Code Playgroud)
Eclipse将此行标记为错误.我导入了所需的库:
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
Run Code Online (Sandbox Code Playgroud)
我使用Apache Commons作为建议的解决方案,包括:
import org.apache.commons.*;
Run Code Online (Sandbox Code Playgroud)
并导入从以下网址下载的JAR文件:http://commons.apache.org/codec/
但问题仍然存在.Eclipse仍然显示前面提到的错误; 请指教.
有没有办法禁用javac 1.6.0_22的限制,阻止我使用JRE内部类sun.awt.event.*?
我不是在寻找:
我只想知道它是否可能,如果是,那么如何.
我正在使用sun.misc.BASE64Encoder包中的encode()方法.如何抑制它生成的编译器警告?
sun.misc.BASE64Encoder是Sun专有的API,可能会被删除
作为后续,我为什么不在Eclipse中看到这个警告?
当泛型添加到1.5时,java.lang.reflect添加了一个Type具有各种子类型的接口来表示类型.Class改装为Type1.5前类型的实施.Type子类型可用于1.5的新类型泛型类型.
这一切都很好.有点尴尬,Type不得不做一些有用的事情,但可以尝试试用,错误,摆弄和(自动)测试.除了涉及实施......
应该怎样equals和hashCode实施.ParameterizedType子类型的API描述Type说:
实现此接口的类的实例必须实现equals()方法,该方法等同于共享相同泛型类型声明且具有相同类型参数的任何两个实例.
(我想这意味着getActualTypeArguments和getRawType,但不getOwnerType?)
我们从一般合同中知道,java.lang.Object这hashCode也必须实施,但似乎没有规定这种方法应该产生什么价值.
Type似乎没有提到其他子类型,equals或者hashCode除了Class每个值具有不同的实例之外.
所以,我该怎么把我equals和hashCode?
(如果你想知道,我试图替代类型参数的实际类型.所以,如果我知道在运行时 TypeVariable<?> T的Class<?> String话,我想替换TypeS,所以List<T>成为List<String>,T[]成为String[],List<T>[](可能发生!)变List<String>[]等)
或者我是否必须创建自己的并行类型层次结构(Type由于法律原因而没有重复)?(有图书馆吗?)
编辑:关于我为什么需要这个问题,有几个问题.实际上,为什么要查看泛型类型信息呢?
我开始使用非泛型类/接口类型.(如果你想要一个参数化类型,比如List<String>那时你总是可以用一个新类添加一个间接层.)然后我就按照字段或方法.那些可以参考参数化类型.只要他们不使用通配符,我仍然可以在面对类似的时候找出实际的静态类型T …
我从我的蚂蚁脚本中调用javac,如下所示:
<javac srcdir="src"
destdir="build/classes" source="1.6"
target="1.6" debug="true" encoding="Cp1252"
nowarn="true">
Run Code Online (Sandbox Code Playgroud)
但它仍然会在输出中抛出编译器警告:
[javac] Compiling 73 source files to C:\IKOfficeRoot\Java\ERP\Framework\build\classes
[javac] C:\IKOfficeRoot\Java\ERP\Framework\src\de\ikoffice\util\LoggerFactory.java:49: warning: sun.reflect.Reflection is Sun proprietary API and may be removed in a future release
[javac] return Logger.getLogger(Reflection.getCallerClass(2));
[javac] ^
[javac] Note: C:\IKOfficeRoot\Java\ERP\Framework\src\de\ikoffice\db\SingleShotResultSet.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 warning
Run Code Online (Sandbox Code Playgroud)
我也试过了
<compilerarg line="-Xlint:-unchecked -Xlint:-deprecation"/>
Run Code Online (Sandbox Code Playgroud)
和
<compilerarg …Run Code Online (Sandbox Code Playgroud) 在我们的项目构建期间,我们得到一个相当无法解释的警告:
[javac] (...)\SessionKeeper.java:39: warning: NEW is internal proprietary API and may be removed in a future release
[javac] private static final int timeOfInactivity = 1000 * 60 * 9; // allowed time of inactivity
[javac] ^
附加信息:
任何人都可以解释为什么编译器发出此警告,以及我应该改变什么以避免它?
[编辑]添加了附近的代码
private static final String CLASS_NAME = SessionKeeper.class.getName();
private static final int logoutDelaySeconds = 1000 * 60; // logout after 1 min. from the point when dialog was shown to the user
private static final int timeOfInactivity = 1000 … 我有一个使用Gradle(1.8)构建的Groovy项目,其中一些Java类报告以下编译器警告消息:
warning: Unsafe is internal proprietary API and may be removed in a future release
import sun.misc.Unsafe;
Run Code Online (Sandbox Code Playgroud)
有没有办法抑制该错误消息?我发现了一些建议使用javac编译器选项的答案,-XDignore.symbol.file但是在使用Groovy插件时我无法在Gradle构建中应用它.
有解决方案吗
谢谢