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

Daniel Sun resolved GROOVY-12569.
---------------------------------
    Fix Version/s: 7.0.0-alpha-1
                   6.0.1
         Assignee: Daniel Sun
       Resolution: Fixed

Fixed on master in 82a6436cfb1ac8085f3f33520df7e534045d86bf 
(https://github.com/apache/groovy/commit/82a6436cfb1ac8085f3f33520df7e534045d86bf,
 #3098) and on the GROOVY_6_0_X branch in 
ef0f9b5f8fdf05879b4ba62ca5f0bd0e599eb781 
(https://github.com/apache/groovy/commit/ef0f9b5f8fdf05879b4ba62ca5f0bd0e599eb781).

> SC: a package-private class of another GroovyClassLoader compilation fails 
> with IllegalAccessError where dynamic code works
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12569
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12569
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 7.0.0-alpha-1, 6.0.1
>
>
> A class that is not public is accessible only within its run-time package 
> (JVMS 5.4.4), and the JVM checks that wherever an instruction names the 
> class. Dynamic code uses a package-private class of an earlier 
> {{GroovyShell}} parse, or of a library used by a script, without naming it. 
> Statically compiled code names it and fails:
> {code:groovy}
> def shell = new GroovyShell()
> shell.evaluate '''package p
>     @groovy.transform.PackageScope class Hidden implements Runnable {
>         static String sm() { 'sm' }
>         String name
>         String own() { 'own' }
>         void run() { }
>     }
>     true
> '''
> shell.evaluate '''package p
>     @groovy.transform.CompileStatic
>     def test() {
>         def h = new Hidden(name: 'x')
>         h.run()
>         Runnable r = h
>         [Hidden.sm(), h.own(), h.name]
>     }
>     test()
> ''' // each line fails with IllegalAccessError; without @CompileStatic it 
> works
> {code}
> Expected: with the option {{CompilerConfiguration.RUNTIME_PACKAGE_CHECK}} 
> (GROOVY-12568), an instruction that names such a class is reported when the 
> class is generated. A value of the class that no instruction names keeps 
> working. Classes compiled to class files are used directly.
> PR: https://github.com/apache/groovy/pull/3098



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to