I am very confused. I'm trying to override a sprin...
# announcements
g
I am very confused. I'm trying to override a spring batch provided class method, but it is having signature issues. I am not sure, but I'm assuming I'm supposed to return null when null otherwise it's not up to spec(perhaps "" will work, but that's not the cleanest solution). Why won't it let me make it a nullable String, when the method it is overriding is java.lang.String in a java source code? How do I get around this? (parameter being nonnull string is also another signature issue - if I make it a nullable string, it says it has nothing to override because of signature mismatch, yet... source reveals it's a plain java string that isn't annotated otherwise)
As seen here, the method it is overriding is indeed a pure java source code with nullable String(since it's java...)
k
maybe #C0B8ZTWE4 , but should it really be nullable? if so, shouldn't record also be nullable?
g
Yes, the issue is, the class I'm trying to override is a plain java class, not .kt - and the java method has a String parameter and String return type, both nullable since it's not specified otherwise by
@NotNull
. I am trying to figure out exactly why kotlin would complain for making an overridden method over from java into nullable types, which they should be by default.
s
m
Also note that a lot of Spring code uses Package annotations to define things in the package as Not Null by default, so therefore it's more likely that because it doesn't have a Nullable annotation, it is non-null.