[ 
https://issues.apache.org/jira/browse/GROOVY-10391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17460037#comment-17460037
 ] 

Łukasz Pieróg commented on GROOVY-10391:
----------------------------------------

[~emilles] any suggestion on how can I achieve that? afaik dynamically 
generated module that the generated proxies belong to i.e., `jdk.proxy1`, 
cannot be open to all-unnamed-modules like other modules

> Default interface methods causing problems with java 17 and groovy 3.0.9
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-10391
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10391
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.0.9
>         Environment: jdk 17.0.1 corretto
> gradle 7.3
> groovy 3.0.9
>            Reporter: Łukasz Pieróg
>            Priority: Major
>             Fix For: 4.0.0-beta-2
>
>
> I'm trying to migrate a project to build on JDK17 and in that project we use 
> groovy and spock for testing. It seems that groovy 3.* has a problem with 
> reflection access to JDK especially visible when using closures
> A simple test class:
> {code:java}
> static void main(String[] args) {
>     def predicate = {true} as java.util.function.Predicate
>     predicate.negate()
>     println "i don't work!! :("
> } {code}
> Produces
> {noformat}
> java.lang.IllegalAccessException: module jdk.proxy1 does not open jdk.proxy1 
> to unnamed module @43517800{noformat}
> In line
> {code:java}
> predicate.negate() {code}
> .negate() being a default method in a Predicate interface which a part of the 
> jdk
> The following however works:
> {code:java}
> static void main(String[] args) {
>     def predicate = new Predicate() {
>         @Override
>         boolean test(Object o) {
>             true
>         }
>     }
>     predicate.negate()
>     println "i work!! :)"
> } {code}
> I'm using JDK 17.0.1 Corretto for my tests and the example minimal project 
> can be found here:
> [https://github.com/lukaszpierog/jdk17-groovy3]
> The above code works with groovy 4.0.0-beta-2. Spock does not support groovy 
> 4 at this moment, so upgrading groovy to 4 isn't an option for me and it 
> seems to only be a beta release at the moment.
> I've tried adding jvm args 
> --add-opens=java.base/java.lang.invoke=ALL-UNNAMED
> however that does not seem to affect the output
> Please advise



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to