| import org.eclipse.jdt.annotation.NonNull; | |
| import org.eclipse.jdt.annotation.Nullable; | |
| public class NullAnnotatedFields { | |
| @NonNull Letter nonNull; | |
| @Nullable Letter nullable; | |
| String test() { | |
| nonNull.print(); | |
| nullable.print(); | |
| nonNull = null; | |
| if (nullable != null) | |
| nullable.print(); // protected | |
| nullable = new Letter(); | |
| bar(); // spoils protection | |
| return nullable.toString(); | |
| } | |
| void bar() { | |
| } | |
| } | |
| // --- not shown in the screenshot: --- | |
| class Letter { | |
| void print() {} | |
| } |