java Groovy - 警告:发生了非法的反射访问操作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47935772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Groovy - WARNING: An illegal reflective access operation has occurred
提问by Here_2_learn
I am pretty much new to java and groovy. I have installed groovy 3.0 on my windows 10 laptop (64 bit) and when tried to run groovy getting following warning:
我对 java 和 groovy 非常陌生。我已经在我的 Windows 10 笔记本电脑(64 位)上安装了 groovy 3.0,当尝试运行 groovy 时收到以下警告:
>groovy -v
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/groovy-3.0.0-alpha-1/lib/groovy-3.0.0-alpha-1.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Groovy Version: 3.0.0-alpha-1 JVM: 9.0.1 Vendor: Oracle Corporation OS: Windows 10
And the java version is:
而java版本是:
java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Any help to resolve this.
任何帮助解决这个问题。
回答by T Semple
It is more than a 'warning' for me: I cannot get Groovy scripts to run (on macOS) with the current JVM 9, much less 10. The workaround (until a compatible version of Groovy is available) is to install jenv and an earlier version of Java, so you can switch when needed.
对我来说,这不仅仅是一个“警告”:我无法使用当前的 JVM 9 运行(在 macOS 上)Groovy 脚本,更不用说 10。解决方法(直到 Groovy 的兼容版本可用)是安装 jenv 和较早版本的 Java,因此您可以在需要时进行切换。
回答by crusy
To disable the warnings you can pass --add-opens
to the JVM, see details here. Unfortunately Groovy requires a lotof modules/packages to be opened, see this (currently reverted) commit(source). Just tested these with AdoptOpenJDK 11.
要禁用可以传递--add-opens
给 JVM的警告,请参阅此处的详细信息。不幸的是,Groovy 需要打开大量模块/包,请参阅此(当前已恢复)提交(源)。刚刚使用 AdoptOpenJDK 11 测试了这些。
回答by Csaba Toth
Although my environment is Linux, after struggling some days to setup Groovy on Grails environment I feel like I know the answer: use JDK 8 for now. I was fiddling with JDK 9, and I thought it was too far behind so I tried JDK 11, which made things even worse, I got actual crashes. It seems like that Groovy / Grails is heavily lagging behind in terms of Java version compatibility.
尽管我的环境是 Linux,但在为在 Grails 环境中设置 Groovy 苦苦挣扎了几天之后,我觉得我知道答案:现在使用 JDK 8。我在摆弄 JDK 9,我认为它太落后了,所以我尝试了 JDK 11,这让事情变得更糟,我真的崩溃了。似乎 Groovy / Grails 在 Java 版本兼容性方面严重滞后。
Once the new Groovy will be released (said to be end of this year) then newer JDK can be used as well.
一旦新的 Groovy 发布(据说是今年年底),那么新的 JDK 也可以使用。
回答by user152476
Use the Java 8, however, if the java version must be 9 or >, you need to update the groovy version too.
使用Java 8,但是,如果Java版本必须是9或>,则还需要更新groovy版本。
I was running groovy 2.2.1 and it only works until java version 8
我正在运行 groovy 2.2.1,它只在 java 版本 8 之前有效
回答by softwarevamp
add groovy-version to your pom:
将 groovy-version 添加到您的 pom 中:
<groovy.version>3.0.4</groovy.version>