我对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
Run Code Online (Sandbox Code Playgroud)
而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)
Run Code Online (Sandbox Code Playgroud)
任何帮助来解决这个问题.
小智 7
这对我来说不仅仅是一个"警告":我无法使用当前的JVM 9运行Groovy脚本(在macOS上),更不用说10.解决方法(直到Groovy的兼容版本可用)是安装jenv和早期版本的Java,因此您可以在需要时进行切换.
设置JAVA_HOME为版本 8 JRE 为我解决了这个问题:
#! /usr/bin/env -S JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre groovy
println "hello world"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9691 次 |
| 最近记录: |