2

After compiling my program groovy, I got this error before the expected result. Please, how can I fix this?

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/Users/xxxx/.sdkman/candidates/groovy/current/lib/groovy-2.5.8.jar) to construc
tor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
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

Here is my code

public class Todo {
    String name
    String note

    public static void main(String[] args) {

        def todos = [
            new Todo(name:"1", note:"one"),
            new Todo(name:"1", note:"one"),
            new Todo(name:"1", note:"one")
        ]

        todos.each {
            println "${it.name} ${it.note}"
        }

    }
}

I was expecting this result without the error message

1 one
1 one
1 one
PILA
  • 625
  • 1
  • 5
  • 18
  • 1
    *"how can I fix this?"* Run on Java 8. It is an ongoing issue that hasn't been fixed yet ([GROOVY-8339](https://issues.apache.org/jira/browse/GROOVY-8339)). See also: [How to hide warning “Illegal reflective access” in java 9 without JVM argument?](https://stackoverflow.com/q/46454995/5221149) *(not recommended)* – Andreas Oct 24 '19 at 05:25
  • Duplicate of https://stackoverflow.com/questions/52930532/groovy-jdk-11-disable-the-warning-message - You may use a env var defined in that answer to hide them. They are warnings, not errors. – erichelgeson Oct 24 '19 at 16:04

0 Answers0