-
Notifications
You must be signed in to change notification settings - Fork 629
Closed
Labels
Description
Initially reported here: spotbugs/sonar-findbugs#1036
For Kotlin data classes a zero-arg constructor seems to be generated by the compiler and assigns null values to non-null fields. Considering that this is a generated constructor it is not very relevant to report it to the user.
For instance this Kotlin source:
@Entity
@Table(name = "\"case\"") // 'case' is protected SQL keyword, so we have to put it in quotes here
data class CaseBE(
@Id
override val id: CASE_ID = UUID.randomUUID(),
override var createdAt: OffsetDateTime,
override var updatedAt: OffsetDateTime,
var breakdownFormattedAddress: String, // <--- this is perfectly legal, value has to be specified when calling constructor
) : AbstractAuditedBaseBE(id, createdAt, updatedAt)
Is compiled to a .class containing this constructor:
// Method descriptor #104 ()V
// Stack: 6, Locals: 1
public DummyBE();
0 aload_0 [this]
1 aconst_null
2 aconst_null
3 aconst_null
4 bipush 7
6 aconst_null
7 invokespecial com.bmw.cc.csvbe.persistence.AbstractAuditedBaseBE(java.util.UUID, java.time.OffsetDateTime, java.time.OffsetDateTime, int, kotlin.jvm.internal.DefaultConstructorMarker) [107]
10 return
Local variable table:
[pc: 0, pc: 11] local: this index: 0 type: com.xxx.cases.entity.DummyBE