CORDA-539 - Fix for attempting to create a primitive nullable field

Refactoring meant that the secondary constructor wasn't being called any
more and thus the check wasn't being made. Originally, we always
created copies of fields when constructing a schema which meant we always
called the secondary constructor, now we don't
This commit is contained in:
Katelyn Baker
2017-09-13 10:35:59 +01:00
parent 063771fac4
commit ef409c4d65

View File

@ -4,8 +4,6 @@ import jdk.internal.org.objectweb.asm.Opcodes.*
import org.objectweb.asm.ClassWriter import org.objectweb.asm.ClassWriter
import org.objectweb.asm.MethodVisitor import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Type import org.objectweb.asm.Type
import java.beans.BeanDescriptor
import java.util.*
abstract class Field(val field: Class<out Any?>) { abstract class Field(val field: Class<out Any?>) {
abstract var descriptor: String? abstract var descriptor: String?
@ -95,12 +93,14 @@ class NullableField(field: Class<out Any?>) : ClassField(field) {
override val nullabilityAnnotation = "Ljavax/annotation/Nullable;" override val nullabilityAnnotation = "Ljavax/annotation/Nullable;"
constructor(name: String, field: Class<out Any?>) : this(field) { constructor(name: String, field: Class<out Any?>) : this(field) {
this.name = name
}
init {
if (field.isPrimitive) { if (field.isPrimitive) {
throw NullablePrimitiveException( throw NullablePrimitiveException(
"Field $name is primitive type ${Type.getDescriptor(field)} and thus cannot be nullable") "Field $name is primitive type ${Type.getDescriptor(field)} and thus cannot be nullable")
} }
this.name = name
} }
override fun nullTest(mv: MethodVisitor, slot: Int) { override fun nullTest(mv: MethodVisitor, slot: Int) {