Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10413

IllegalAccessException when using closures for functional interfaces with default methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.9
    • 4.0.0-beta-1
    • None
    • None
    • Groovy 3.0.9, Amazon Corretto 17.0, Windows 10 Enterprise, German, x64

    Description

       

      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`.

      Stacktrace:

       

      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 

      I attached a minimal project with this issue to the ticket.

       

      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

      Attachments

        1. groovy-bug-j17.zip
          72 kB
          Christoph Loy

        Activity

          People

            Unassigned Unassigned
            cloy_vector Christoph Loy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: