pixelbumper
01/22/2018, 6:08 PMvoid addItem(@NonNull String item){
if (item != null) {
/*additem */
} else {
/* do some error logging */
}
}
Now i wanted to test this method for safe null handling using kotlin and had to find out that kotlin is also evaluating @NonNull
annotations, which does not allow me to pass null values to the method anymore.
I also tried to fool the compiler by casting to a nullable type, but it seems that methods containing @NonNull
annotations get bytecode enhanced so that they throw IllegalStateExceptions on null values. My question now is: is there a compiler option to turn off the evaluation of jsr305 annotations?