Dav*_*her 69 java compiler-errors unchecked
我在编译代码时收到一条消息:
Note: H:\Project2\MyGui2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
我该如何重新编译-Xlint:unchecked?
sud*_*ode 47
在javac的命令行中指定它:
javac -Xlint:未选中
或者,如果您使用Ant修改您的javac目标
<javac ...>
<compilerarg value="-Xlint"/>
</javac>
Run Code Online (Sandbox Code Playgroud)
如果您使用的是Maven,请在中进行配置 maven-compiler-plugin
<compilerArgument>-Xlint:unchecked</compilerArgument>
Run Code Online (Sandbox Code Playgroud)
Bri*_*rns 43
对于IntelliJ 13.1,请转到File- > Settings- > Project Settings- > Compiler- > Java Compiler,然后在右侧Additional command line parameters输入"-Xlint:unchecked".
小智 21
在gradle项目中,您可以通过以下方式添加此编译参数:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked"
}
}
Run Code Online (Sandbox Code Playgroud)
And*_*sen 18
我知道这听起来很奇怪,但我很确定这是你的问题:
在MyGui.java中的某个地方,您使用的是通用集合而未指定类型.例如,如果你在某处使用ArrayList,那么你这样做:
List list = new ArrayList();
Run Code Online (Sandbox Code Playgroud)
当你应该这样做:
List<String> list = new ArrayList<String>();
Run Code Online (Sandbox Code Playgroud)
tar*_*arn 13
gradle有另一种方法:
compileJava {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
Run Code Online (Sandbox Code Playgroud)
对于 Android Studio,将以下内容添加到块中的顶级build.gradle文件中allprojects
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
119108 次 |
| 最近记录: |