We're updating the issue view to help you get more done. 

Non annotated evolution missed constructors when generics get involved

Description

Adding a non-nullable parameter to a class should work IFF a constructor is provided annotated with the <AT>DeprecatedConstructgorForSerialization annotation. This constructor provides defaults for the properties not present when the class may have been serialized allowing instances of it to be deserialized.

However, something like this was breaking it

1 2 3 4 5 6 7 8 data class NetworkParametersExample( val minimumPlatformVersion: Int, val notaries: List<String>, val maxMessageSize: Int, val maxTransactionSize: Int, val modifiedTime: Instant, val epoch: Int, val whitelistedContractImplementations: Map<String, List<Int>>)

when changed to something like this

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 data class NetworkParametersExample( val minimumPlatformVersion: Int, val notaries: List<String>, val maxMessageSize: Int, val maxTransactionSize: Int, val modifiedTime: Instant, val epoch: Int, val whitelistedContractImplementations: Map<String, List<Int>>, /* to regenerate test class, comment out this element */ val eventHorizon: Int ) { // when regenerating test class this won't be required @DeprecatedConstructorForDeserialization(1) @Suppress("UNUSED") constructor ( minimumPlatformVersion: Int, notaries: List<String>, maxMessageSize: Int, maxTransactionSize: Int, modifiedTime: Instant, epoch: Int, whitelistedContractImplementations: Map<String, List<Int>> ) : this(minimumPlatformVersion, notaries, maxMessageSize, maxTransactionSize, modifiedTime, epoch, whitelistedContractImplementations, Int.MAX_VALUE) }

Because there is the deprecated constructor this should be valid for reading instances of the class serialized as they were in the before time, in the long long ago.

The actual problem is the generics and the way constructors are selected. The types of the serialized args are the generic type because we stripped all type info off of generics a while ago because ti just causes problems. However, the evolver code wasn't and it was seeing List and List<Int> as different

Status

Assignee

Katelyn Baker

Reporter

Katelyn Baker

Affected OS

None

Severity

Medium

Target Version/s

R3 Corda 3.0 GA
Corda 3.2
Corda 3.3

Feature Team

Network Services

Fix versions

Priority

Medium