You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/05/05 09:36:12 UTC

[jira] [Commented] (GROOVY-7793) Compiler compiles class with private abstract method

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

ASF GitHub Bot commented on GROOVY-7793:
----------------------------------------

GitHub user andresteingress opened a pull request:

    https://github.com/apache/groovy/pull/328

    GROOVY-7793: Compiler compiles class with private abstract method

    This PR adds some logic to the class completion verifier that adds an error to the error collector when private abstract methods are detected in abstract classes or enums (for interfaces such a check is already available).

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/andresteingress/groovy GROOVY-7793

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/328.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #328
    
----
commit 81945cb177a588bb6d7ff0a5868691ed92d89260
Author: Andre Steingress <me...@andresteingress.com>
Date:   2016-05-04T21:17:03Z

    GROOVY-7793: Compiler compiles class with private abstract method

----


> Compiler compiles class with private abstract method
> ----------------------------------------------------
>
>                 Key: GROOVY-7793
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7793
>             Project: Groovy
>          Issue Type: Bug
>          Components: bytecode, Compiler
>    Affects Versions: 2.3.11
>         Environment: - OS X
> - Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
> - IntelliJ Idea 14 CE \w Groovy plugin
> - Gradle 2.2
>            Reporter: Simo Tuokko
>
> Using Groovy and JDBI in following class:
> {code:title=ItemDAO.groovy|borderStyle=solid}
> abstract class ItemDAO {
>     @SqlUpdate("...")
>     @GetGeneratedKeys
>     private abstract long insertItem(@BindBean Item item)
> }
> {code}
> When class is used JDBI will create proxy-implementation based on the the abstract class (or interface).
> It will compile without any issues, but running it causes (shown below) class-loading/verify error. This is programmers fault to have "private abstract" methods, but I guess Groovy-compiler should not let this thru? Maybe IntelliJ Idea groovy-plugin should say it's illegal as well?
> I haven't tried this with the latest Groovy-version but unless it has been specifically fixed it might still occur?
> ---
> Exception in thread "main" java.lang.ClassFormatError: Method insertDish in class com/company/ItemDAO has illegal modifiers: 0x402
> 	at java.lang.ClassLoader.defineClass1(Native Method)
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
> 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
> 	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> 	at java.lang.Class.getDeclaredMethods0(Native Method)
> 	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
> 	at java.lang.Class.getDeclaredMethods(Class.java:1975)
> 	at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:85)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:82)
> 	at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:80)
> 	at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
> 	at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
> 	at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:251)
> 	at groovy.lang.MetaClassImpl.populateMethods(MetaClassImpl.java:390)
> 	at groovy.lang.MetaClassImpl.fillMethodIndex(MetaClassImpl.java:340)
> 	at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3224)
> 	at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:222)
> 	at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:253)
> 	at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255)
> 	at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:859)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:194)



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