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 2017/05/02 02:04:14 UTC
[jira] [Closed] (GROOVY-7828) Created a class loader that override
loadClass can calls protected methods results in VerifyError
[ https://issues.apache.org/jira/browse/GROOVY-7828?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-7828.
-----------------------------
> 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
> Assignee: John Wagenleitner
> Fix For: 2.5.0-alpha-1
>
>
> 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.15#6346)