我最近升级到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();
有没有可能隐藏这些弃用警告信息?
我尝试过的方法:
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
以及
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
ENGINE = factory.getScriptEngine(new String[] {"--no-java --no-deprecation-warning"}, null, className -> false);
我认为 JDK-8210140 可能涉及一个类似的问题。