Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7926

Method that returns void in a Trait with generics produces questionable byte code

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.7
    • Fix Version/s: 2.4.8
    • Component/s: None
    • Labels:
      None

      Description

      Given the following trait:

      trait MyTrait<D> {
          void delete() {
              // no-op
          }
      }
      class MyImpl implements MyTrait<MyImpl> {
      }
      

      The delete method produces byte code that when decompiled looks like:

          public void delete() {
              CallSite[] var1 = $getCallSiteArray();
              void var10000 = (void)var1[1].call(Helper.class, this);
          }
      

      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):

      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)
      

      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?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                graemerocher1 Graeme Rocher
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: