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-7926) Method that returns void in a Trait with generics produces questionable byte code
Date Thu, 08 Sep 2016 10:04:21 GMT

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

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

GitHub user graemerocher opened a pull request:

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

    GROOVY-7926 - Don't use a CastExpression if the return type is void.

    As per https://issues.apache.org/jira/browse/GROOVY-7926 traits currently try to cast
the void type which leads to mysterious exceptions on some JVMs (notably JRocket and the IBM
JVM)

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

    $ git pull https://github.com/graemerocher/incubator-groovy GROOVY-7926

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

    https://github.com/apache/groovy/pull/416.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 #416
    
----
commit 42f014e4ffadf3aea39e07031f7cf8a7f9babe73
Author: Graeme Rocher <graeme.rocher@gmail.com>
Date:   2016-09-08T10:00:08Z

    GROOVY-7926 - Don't use a CastExpression if the return type is void.

----


> Method that returns void in a Trait with generics produces questionable byte code
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-7926
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7926
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>            Reporter: Graeme Rocher
>
> Given the following trait:
> {code}
> trait MyTrait<D> {
>     void delete() {
>         // no-op
>     }
> }
> class MyImpl implements MyTrait<MyImpl> {
> }
> {code}
> The delete method produces byte code that when decompiled looks like:
> {code}
>     public void delete() {
>         CallSite[] var1 = $getCallSiteArray();
>         void var10000 = (void)var1[1].call(Helper.class, this);
>     }
> {code}
> As you can see "void" is used as a type of a variable. This results in the following
exception on the IBM JVM (it works fine in Oracle and OpenJDK):
> {code}
> Caused by: java.lang.NoClassDefFoundError: void
> 	at it.dedagroup.Test.delete(Test.groovy)
> 	at org.grails.datastore.gorm.GormEntity$delete$0.call(Unknown Source)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
> {code}
> Since the issue occurs only in IBM JVM it could be argued that this is a problem with
that JVM, however the byte code produced does seem suspicious to me as "void" cannot be used
as a type of a local variable. Thoughts?



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

Mime
View raw message