[ https://issues.apache.org/jira/browse/GROOVY-11630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17946163#comment-17946163 ]
ASF GitHub Bot commented on GROOVY-11630: ----------------------------------------- eric-milles opened a new pull request, #2203: URL: https://github.com/apache/groovy/pull/2203 consolidate metadata keys to shared value > Extraneous bytecode generated after calls to void DGM methods > ------------------------------------------------------------- > > Key: GROOVY-11630 > URL: https://issues.apache.org/jira/browse/GROOVY-11630 > Project: Groovy > Issue Type: Bug > Components: class generator, Compiler, Static compilation > Affects Versions: 5.0.0-alpha-12 > Reporter: Oscar N > Assignee: Eric Milles > Priority: Minor > > I have the following code: > {code:groovy} > import groovy.transform.CompileStatic > @CompileStatic > final class DGMUsage { > static void main(String[] args) { > println "Groovy version: ${GroovySystem.version}" > var list = (1..100).toList() > list.shuffle() > } > } > {code} > When looking at the compiled output, null is pushed to the stack then > immediately popped for DGMs that have a void return type: > {code:java} > // access flags 0x89 > public static varargs main([Ljava/lang/String;)V > L0 > LINENUMBER 6 L0 > LDC LDGMUsage;.class > NEW org/codehaus/groovy/runtime/GStringImpl > DUP > ICONST_1 > ANEWARRAY java/lang/Object > DUP > ICONST_0 > INVOKESTATIC groovy/lang/GroovySystem.getVersion ()Ljava/lang/String; > AASTORE > ICONST_2 > ANEWARRAY java/lang/String > DUP > ICONST_0 > LDC "Groovy version: " > AASTORE > DUP > ICONST_1 > LDC "" > AASTORE > INVOKESPECIAL org/codehaus/groovy/runtime/GStringImpl.<init> > ([Ljava/lang/Object;[Ljava/lang/String;)V > INVOKESTATIC org/codehaus/groovy/runtime/DefaultGroovyMethods.println > (Ljava/lang/Object;Ljava/lang/Object;)V > ACONST_NULL > POP > L1 > LINENUMBER 8 L1 > NEW groovy/lang/IntRange > DUP > ICONST_1 > ICONST_1 > ICONST_1 > BIPUSH 100 > INVOKESPECIAL groovy/lang/IntRange.<init> (ZZII)V > INVOKESTATIC org/codehaus/groovy/runtime/DefaultGroovyMethods.toList > (Ljava/lang/Iterable;)Ljava/util/List; > ASTORE 1 > L2 > LINENUMBER 9 L2 > ALOAD 1 > INVOKESTATIC org/codehaus/groovy/runtime/DefaultGroovyMethods.shuffle > (Ljava/util/List;)V > ACONST_NULL > POP > L3 > LINENUMBER 10 L3 > RETURN > LOCALVARIABLE args [Ljava/lang/String; L0 L3 0 > LOCALVARIABLE list Ljava/util/List; L2 L3 1 > MAXSTACK = 8 > MAXLOCALS = 2 > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)