You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2019/12/09 21:36:01 UTC
[jira] [Closed] (GROOVY-9293) Compilation error when accessing
package-private super class field using `this` from inside a closure
[ https://issues.apache.org/jira/browse/GROOVY-9293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-9293.
-----------------------------
> Compilation error when accessing package-private super class field using `this` from inside a closure
> -----------------------------------------------------------------------------------------------------
>
> Key: GROOVY-9293
> URL: https://issues.apache.org/jira/browse/GROOVY-9293
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.5.8, 3.0.0-rc-1
> Reporter: Daniel Sun
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.0-rc-2
>
>
> Compilation fails when accessing a package-private super class field from inside a closure:
> {code:java}
> // error message: java.lang.IllegalAccessError: class a.ConcreteClass$_doThing_closure1 tried to access field a.Abstract_Class.superField (a.ConcreteClass$_doThing_closure1 is in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @5fa47fea; a.Abstract_Class is in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @28cda624)
> GroovyShell shell = new GroovyShell()
> shell.evaluate('''
> package a
>
> import groovy.transform.CompileStatic
>
> @CompileStatic
> abstract class Abstract_Class {
> @groovy.transform.PackageScope String superField = 'field'
>
> abstract String doThing()
> }
> assert true
> ''')
> shell.evaluate('''
> package a
>
> import a.Abstract_Class
> import groovy.transform.CompileStatic
>
> @CompileStatic
> class ConcreteClass extends Abstract_Class {
>
> @Override
> String doThing() {
> this.with {
> return this.superField
> }
> }
> }
> assert true
> ''')
> shell.evaluate("assert new a.ConcreteClass().doThing() == 'field'")
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)