[
https://issues.apache.org/jira/browse/GROOVY-12718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148981#comment-18148981
]
ASF GitHub Bot commented on GROOVY-12718:
-----------------------------------------
codeconsole commented on PR #3252:
URL: https://github.com/apache/groovy/pull/3252#issuecomment-7073786427
Thanks. The two `UnnecessaryFullyQualifiedName` hits are in `Groovy12720`
(`java.beans.Transient` at lines 91-92) and came in with the earlier master
merge. Master fixed them in 687ae270adf. I merged current master in 18f487335c
rather than rebasing, so the reviewed commits stay as they are without a
force-push. The merge was clean, and both the #3097 import and this PR's import
are kept in `AsmClassGenerator`. On the merged tree `lintGate` passes,
`bugs.Groovy12718` and `bugs.Groovy12720` pass, and the
`org.codehaus.groovy.classgen.asm`, `groovy.transform.stc` and `gls` tests
pass. A correction to my earlier comment: the test class is `bugs.Groovy12718`,
not `DynamicFieldOfAnotherRuntimePackageTest`.
> super.f, super.@f and this.@f of a package-private field of a superclass of
> another class loader fail with IllegalAccessError in dynamic code
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12718
> URL: https://issues.apache.org/jira/browse/GROOVY-12718
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.32, 5.0.8, 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> def shell = new GroovyShell()
> shell.evaluate '''package p
> class F { @groovy.transform.PackageScope String pf = 'pf' }
> true'''
> shell.evaluate '''package p
> class C extends F {
> def test() {
> assert pf == 'pf' // works
> assert this.pf == 'pf' // works
> super.pf // IllegalAccessError, as are super.@pf,
> this.@pf and writes through them
> }
> }
> new C().test()'''
> {code}
> *Actual:* {{IllegalAccessError: class p.C tried to access field p.F.pf}}.
> *Expected:* the value of the field, through the meta-class, as for {{pf}} and
> {{this.pf}}.
> Cause: {{F}} comes from an earlier parse, so it has the same package name as
> {{C}} but another class loader, which makes it another run-time package.
> {{AsmClassGenerator.visitPropertyExpression}} and
> {{visitAttributeExpression}} decide by the package name and write
> {{GETFIELD}} or {{PUTFIELD}}, in dynamic and {{@TypeChecked}} code too.
> Verified on 4.0.32, 5.0.8, 6.0.0 and master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)