Original code:
public class Issue160 {
public static void t1() {
String s = null;
if (s != null) {
s = "abc";
} else {
s = "123";
// return;
}
System.out.println(s.toString());
}
}
Code with default annotation from getDefaultAnnotation():
@NonNull
public class Issue160 {
public static void t1() {
@NonNull String s = null;
if (s != null) {
s = "abc";
} else {
s = "123";
// return;
}
System.out.println(s.toString());
}
}
Both the @NonNull annotations are incorrect. Based on the discussion with @zcai1, the method to fetch the default annotation doesn't understand that String s is a local variable.
Original code:
Code with default annotation from
getDefaultAnnotation():Both the
@NonNullannotations are incorrect. Based on the discussion with @zcai1, the method to fetch the default annotation doesn't understand thatString sis a local variable.