Details
-
Type:
Bug
-
Status: Done (View workflow)
-
Priority:
Medium
-
Resolution: Done
-
Affects Version/s: Corda 3.2
-
Fix Version/s: Corda 3.3
-
Component/s: None
-
Labels:None
-
Severity:Medium
-
Target Version/s:
-
Feature Team:Corda Core
-
Sprint:
Description
The following test fails, because the `ClassCarpenter` incorrectly calculates the stack size of fields if there are double-size primitive fields (e.g. long or double) in a superclass constructor:
@Test fun `superclasses with double size constructor parameters`() { val schema1 = ClassSchema( "gen.A", mapOf("a" to NonNullableField(Long::class.javaPrimitiveType!!))) val schema2 = ClassSchema( "gen.B", mapOf("b" to NonNullableField(String::class.java)), schema1) val clazz = cc.build(schema2) val i = clazz.constructors[0].newInstance(1L, "xb") as SimpleFieldAccess assertEquals(1L, i["a"]) assertEquals("xb", i["b"]) assertEquals("B{a=1, b=xb}", i.toString()) }
The fault is in ClassWriter.generateClassConstructor, and the solution is to sum the sizes of the fields in the superclass constructor and make sure this value is used to set the initial stack slot correctly for the parameters.