You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/02/08 16:00:00 UTC

[jira] [Commented] (GROOVY-10070) Groovy classes (for Groovy < 4) cannot access protected methods from base classes under Java 16

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

Eric Milles commented on GROOVY-10070:
--------------------------------------

Adding this to your jvm arguments will allow the protected methods from {{AbstractListModel}} to be indexed by {{CachedClass}} / {{MetaClassImpl}}:
{code}
--add-opens java.desktop/javax.swing=ALL-UNNAMED
{code}

With that, the script passes using Groovy 3.0.15

> Groovy classes (for Groovy < 4) cannot access protected methods from base classes under Java 16
> -----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10070
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10070
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.0.8, 3.0.9
>            Reporter: Dimitry Polivaev
>            Priority: Major
>
> Running following script in Groovy Console
> {code:groovy}
> import javax.swing.DefaultListModel
> class MyDefaultListModel extends DefaultListModel<String>{
>     void test(){
>         println(System.getProperty('java.version'))
>         fireIntervalAdded( this, 0, 1 )
>         println "passed"
>     }
> }
> tested = new MyDefaultListModel()
> tested.test()
> {code}
> generates following output:
> {noformat}
> 16.0.1
> Exception thrown
> groovy.lang.MissingMethodException: No signature of method: MyDefaultListModel.fireIntervalAdded() is applicable for argument types: (MyDefaultListModel, Integer, Integer) values: [[], 0, 1]
> 	at MyDefaultListModel.test(ConsoleScript4:5)
> 	at MyDefaultListModel$test.call(Unknown Source)
> 	at ConsoleScript4.run(ConsoleScript4:10)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> {noformat}
> The called method is declared as {{protected void fireIntervalAdded(Object, int, int)}} in javax.swing.AbstractListModel
> Running under Java 15 it generates following output:
> {noformat}
> 15.0.2
> passed
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)