https://kotlinlang.org logo
#jackson-kotlin
Title
# jackson-kotlin
d

diesieben07

11/22/2018, 11:08 AM
What you want is not possible. Even if Kotlin does not emit runtime type assertions, as far as Kotlin reflection is concerned, the type is still e.g.
String
, which cannot be null.
If you want
null
to end up in a property at all, the property must have a nullable type. Hacking around with disabling the assertions is a terrible idea. You will receive random
NullPointerExceptions
in places. The assertions have a reason...
r

rrader

11/22/2018, 11:20 AM
no, the validation will be done by other tool, like
@NotNull
annotation
why is it not possible? the library just should check if kotlin throw any exceptions
d

diesieben07

11/22/2018, 11:30 AM
The library checks the types reported by Kotlin reflection.
Those are still not-null.
Validation and type-system are different things. Just because the values are validated, they still can be null as far as the compiler is concerned.
r

rrader

11/22/2018, 11:54 AM
The library checks the types reported by Kotlin reflection.
Why? Why just not to pass them to constructor and check the exception?
Validation and type-system are different things
in this case they are the same, both do validation
but kotlin intrisics fail on first argument,
@NotNull
can return all arguments that violate contract
7 Views