Jas*_*own 4 java javac gradle nashorn java-11
我最近升级到 Java11。有 150 个新的 Nashorn 弃用警告:
Utils.java:31: warning: [removal] NashornScriptEngineFactory in jdk.nashorn.api.scripting has been deprecated and marked for removal
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
Run Code Online (Sandbox Code Playgroud)
是否可以隐藏这些弃用警告?
我试过的:
tasks.withType(JavaCompile) {
options.compilerArgs += '-Xlint:-deprecation'
}
./gradlew build -Dnashorn.option.no.deprecation.warning=true
gradle-wrapper.properties: org.gradle.jvmargs= -Dnashorn.args=--no-deprecation-warning
Run Code Online (Sandbox Code Playgroud)
也
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
ENGINE = factory.getScriptEngine(new String[] {"--no-java --no-deprecation-warning"}, null, className -> false);
Run Code Online (Sandbox Code Playgroud)
我相信JDK-8210140可能引用了类似的问题。
您看到的警告是由编译器发出的,--no-deprecation-warning唯一会抑制"Warning: Nashorn engine is planned to be removed from a future JDK release"在创建脚本引擎实例时发出的运行时警告。
您应该能够使用:
@SuppressWarnings("removal")
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
Run Code Online (Sandbox Code Playgroud)
在源代码中完全抑制警告。
或以其他方式使用:
-Xlint:-removal
Run Code Online (Sandbox Code Playgroud)
作为编译器参数。这将抑制警告,但您仍会收到每个文件的注释。
| 归档时间: |
|
| 查看次数: |
6068 次 |
| 最近记录: |