groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8757) Incorrect bytecode produced after compiling class implementing trait with generic method
Date Sun, 26 Aug 2018 01:19:00 GMT

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

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

Github user asfgit closed the pull request at:

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


> Incorrect bytecode produced after compiling class implementing trait with generic method
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8757
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8757
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.15, 3.0.0-alpha-3, 2.5.2
>            Reporter: Daniil Ovchinnikov
>            Assignee: Paul King
>            Priority: Critical
>
> {code:java|title=T.groovy}
> trait T {
>     def <T extends Number> T foo(Class<T> c) {
>         println c
>         return null 
>     }
> }
> {code}
> {code:java|title=C.groovy}
> class C implements T {}
> {code}
> {code:java|title=usage.groovy}
> new C().foo(Integer)
> {code}
> {noformat}
> $ groovyc C.groovy T.groovy
> $ groovy usage.groovy
> class java.lang.Integer
> $ groovyc C.groovy # recompile C using already compiled T
> $ groovy usage.groovy
> Caught: java.lang.VerifyError: Bad return type
> Exception Details:
>   Location:
>     C.foo(Ljava/lang/Class;)Ljava/lang/Number; @5: areturn
>   Reason:
>     Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/lang/Number'
(from method signature)
>   Current Frame:
>     bci: @5
>     flags: { }
>     locals: { 'C', 'java/lang/Class' }
>     stack: { 'java/lang/Object' }
>   Bytecode:
>     0x0000000: 2a2b b600 88b0
> java.lang.VerifyError: Bad return type
> Exception Details:
>   Location:
>     C.foo(Ljava/lang/Class;)Ljava/lang/Number; @5: areturn
>   Reason:
>     Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/lang/Number'
(from method signature)
>   Current Frame:
>     bci: @5
>     flags: { }
>     locals: { 'C', 'java/lang/Class' }
>     stack: { 'java/lang/Object' }
>   Bytecode:
>     0x0000000: 2a2b b600 88b0
> 	at usage.run(usage.groovy:1)
> {noformat}
> {noformat:title=original javap output}
> public class C implements T,groovy.lang.GroovyObject {
>   public static transient boolean __$stMC;
>   public C();
>   public <T extends java.lang.Number> T foo(java.lang.Class<T>);
>   public <T extends java.lang.Number> T Ttrait$super$foo(java.lang.Class<T>);
>   static {};
>   protected groovy.lang.MetaClass $getStaticMetaClass();
>   public groovy.lang.MetaClass getMetaClass();
>   public void setMetaClass(groovy.lang.MetaClass);
>   public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
>   public java.lang.Object getProperty(java.lang.String);
>   public void setProperty(java.lang.String, java.lang.Object);
> }
> {noformat}
> {noformat:title=recompiled javap output}
> public class C implements T,groovy.lang.GroovyObject {
>   public static transient boolean __$stMC;
>   public C();
>   public <T> T foo(java.lang.Class<T>);
>   public <T extends java.lang.Number> T Ttrait$super$foo(java.lang.Class<T>);
>   static {};
>   protected groovy.lang.MetaClass $getStaticMetaClass();
>   public groovy.lang.MetaClass getMetaClass();
>   public void setMetaClass(groovy.lang.MetaClass);
>   public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
>   public java.lang.Object getProperty(java.lang.String);
>   public void setProperty(java.lang.String, java.lang.Object);
>   public java.lang.Number foo(java.lang.Class);
> }
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message