You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Christoph Loy (Jira)" <ji...@apache.org> on 2021/12/14 12:48:00 UTC
[jira] [Created] (GROOVY-10413) IllegalAccessException when using closures for functional interfaces with default methods
Christoph Loy created GROOVY-10413:
--------------------------------------
Summary: IllegalAccessException when using closures for functional interfaces with default methods
Key: GROOVY-10413
URL: https://issues.apache.org/jira/browse/GROOVY-10413
Project: Groovy
Issue Type: Bug
Affects Versions: 3.0.9
Environment: Groovy 3.0.9, Amazon Corretto 17.0, Windows 10 Enterprise, German, x64
Reporter: Christoph Loy
Attachments: groovy-bug-j17.zip
h3.
h3. Given:
* A functional interface `IStillFunctional` with a method `foo` and a default-method `bar`.
* A java method `doConsume(IStillFunctional)` (defined in a Java-Class)
I get an `IllegalAccessException` when I pass a Closure to the `doConsume` method and then call the default-method `bar`.
h3. Stacktrace:
{code:java}
Caught: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at jdk.proxy2/jdk.proxy2.$Proxy18.bar(Unknown Source)
at com.Consumer2.doConsume(Consumer2.java:6)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.GroovyMain.run(GroovyMain.groovy:3)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.GroovyMain.main(GroovyMain.groovy)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Caused by: java.lang.IllegalAccessException: module jdk.proxy2 does not open jdk.proxy2 to unnamed module @51565ec2
... 19 more {code}
I attached a minimal project with this issue to the ticket.
h3. Observations:
* The issue seems to happen in org.codehaus.groovy.runtime.ConversionHandler#invoke.
* The issue does not happen when the Consumer-Class is defined in a Groovy file.
* The issue did not occur under JDK 11
--
This message was sent by Atlassian Jira
(v8.20.1#820001)