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

Extraneous bytecode generated after calls to void methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.5.23, 3.0.20, 5.0.0-alpha-4, 4.0.17
    • None
    • Compiler
    • None

    Description

      I have the following code:

      package org.example
      
      import groovy.transform.CompileStatic
      
      @CompileStatic
      final class Main {
          static void main(String[] args) {
              exampleMethod()
          }
      
          static void exampleMethod() {}
      }
      
      

      When looking at the compiled output, null is pushed to the stack then immediately popped:

      // access flags 0x89
      public static varargs main([Ljava/lang/String;)V
       L0
        LINENUMBER 8 L0
        INVOKESTATIC org/example/Main.exampleMethod ()V
        ACONST_NULL
        POP
       L1
        LINENUMBER 9 L1
        RETURN
        LOCALVARIABLE args [Ljava/lang/String; L0 L1 0
        MAXSTACK = 1
        MAXLOCALS = 1
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            paint_ninja Oscar N
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: