[ https://issues.apache.org/jira/browse/GROOVY-11284?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-11284: --------------------------------- Language: groovy > Generated size() method on records performs unnecessary boxing > -------------------------------------------------------------- > > Key: GROOVY-11284 > URL: https://issues.apache.org/jira/browse/GROOVY-11284 > Project: Groovy > Issue Type: Bug > Affects Versions: 4.0.17 > Reporter: Oscar N > Assignee: Paul King > Priority: Minor > > I have the following code: > {code:groovy} > import groovy.transform.CompileStatic > @CompileStatic > static void main(String[] args) { > println(new Person("John", 42).size()) > } > @CompileStatic > record Person(String name, int age) {} {code} > When checking the compiled output, the size method performs unnecessary > boxing: > {code:java} > @Generated > public final int size() { > return Integer.valueOf(2); > } > {code} > {code:java} > // access flags 0x11 > public final size()I > @Lgroovy/transform/Generated;() > L0 > ICONST_2 > INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer; > INVOKEVIRTUAL java/lang/Integer.intValue ()I > IRETURN > L1 > LOCALVARIABLE this Lorg/example/Person; L0 L1 0 > MAXSTACK = 1 > MAXLOCALS = 1 > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)