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

John Wagenleitner edited comment on GROOVY-7828 at 8/26/16 3:09 AM:
--------------------------------------------------------------------

This is fixed in master.  I confirmed that commit 
https://github.com/apache/groovy/commit/415b95545a9e2ca3a22e2d29fad4a3b65278fb84
 for GROOVY-7325 now causes a compile time error as expected.  The commit 
applies cleanly to GROOVY_2_4_X, so maybe worth applying to get it into 2.4.8?


was (Author: jwagenleitner):
This is fixed in master.  I confirmed that commit 
https://github.com/apache/groovy/commit/415b95545a9e2ca3a22e2d29fad4a3b65278fb84
 for GROOVY-7325 now causes a compile time error as expected.  It commit 
applies cleanly to GROOVY_2_4_X, so maybe worth getting into 2.4.8?

> Created a class loader that override loadClass can calls protected methods 
> results in VerifyError
> -------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7828
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7828
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.6
>            Reporter: Graeme Rocher
>
> The following script results in a VerifyError:
> {code}
> java.lang.VerifyError: (class: FooClassLoader, method: loadClass signature: 
> (Ljava/lang/String;Z)Ljava/lang/Class;) Bad access to protected data
>       at java.lang.Class.getDeclaredConstructors0(Native Method)
>       at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
>       at java.lang.Class.getDeclaredConstructors(Class.java:2020)
>       at 
> org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:77)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at 
> org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:74)
>       at 
> org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:72)
>       at 
> org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:49)
>       at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:36)
>       at 
> org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:271)
>       at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:220)
> {code}
> It should fail with a compilation error since the `loadClass` method is 
> protected.
> {code}
> import groovy.transform.*
> @CompileStatic
> class FooClassLoader extends URLClassLoader {
>         protected Class<?> loadClass(String name, boolean resolve) throws 
> ClassNotFoundException {
>             try {
>                 return super.loadClass(name, resolve)
>             } catch (ClassNotFoundException cnfe) {
>                 return ClassLoader.systemClassLoader.loadClass(name, resolve)
>             }
>         }
> }
> def cl = new FooClassLoader()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to