[ 
https://issues.apache.org/jira/browse/GROOVY-12570?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Scott Murphy Heiberg updated GROOVY-12570:
------------------------------------------
    Description: 
{code:groovy}
def shell = new GroovyShell()
shell.evaluate '''package p
    class M { @groovy.transform.PackageScope String pm() { 'M' } }
    true
'''
shell.evaluate '''package p
    class B extends M { // same package name as M, but another class loader
        String pm() { 'B>' + super.pm() }
    }
    new B().pm()
''' // MissingMethodException; expected 'B>M'
{code}

The JVM does not let {{B.pm()}} override a package-private method of another 
run-time package, so no {{super$}} method can call it, and the meta-class drops 
the method from the methods for super calls without keeping the superclass 
method. The same holds under {{@CompileStatic}}. Expected: {{super.pm()}} calls 
{{M.pm()}}.

PR: https://github.com/apache/groovy/pull/3099

  was:
{code:groovy}
def shell = new GroovyShell()
shell.evaluate '''package p
    class M { @groovy.transform.PackageScope String pm() { 'M' } }
    true
'''
shell.evaluate '''package p
    class B extends M { // same package name as M, but another class loader
        String pm() { 'B>' + super.pm() }
    }
    new B().pm()
''' // MissingMethodException; expected 'B>M'
{code}

The JVM does not let {{B.pm()}} override a package-private method of another 
run-time package, so no {{super$}} method can call it, and the meta-class drops 
the method from the methods for super calls without keeping the superclass 
method. The same holds under {{@CompileStatic}}. Expected: {{super.pm()}} calls 
{{M.pm()}}.


> super.m() cannot reach a package-private method of a superclass defined by 
> another class loader
> -----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12570
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12570
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> def shell = new GroovyShell()
> shell.evaluate '''package p
>     class M { @groovy.transform.PackageScope String pm() { 'M' } }
>     true
> '''
> shell.evaluate '''package p
>     class B extends M { // same package name as M, but another class loader
>         String pm() { 'B>' + super.pm() }
>     }
>     new B().pm()
> ''' // MissingMethodException; expected 'B>M'
> {code}
> The JVM does not let {{B.pm()}} override a package-private method of another 
> run-time package, so no {{super$}} method can call it, and the meta-class 
> drops the method from the methods for super calls without keeping the 
> superclass method. The same holds under {{@CompileStatic}}. Expected: 
> {{super.pm()}} calls {{M.pm()}}.
> PR: https://github.com/apache/groovy/pull/3099



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
  • [jira] [Updated] (GROOVY-125... Scott Murphy Heiberg (Jira)

Reply via email to