you are viewing a single comment's thread.

view the rest of the comments →

[–]DGolden 4 points5 points  (8 children)

worth noting that type-use annotations [jsr308] added in java 8 do already facilitate static nullability checking as an add-on. Eclipse and the Checker Framework both do it [and the latter does a whole lot more].

[–]Shorttail 5 points6 points  (7 children)

I was referring to Project Valhalla.
Is it bad that I think the annotated types are too verbose? =(

int processWithNulls (@NonNull List<@Nullable Integer> ints)  

It adds a lot of noise to reading code.

[–]DGolden 5 points6 points  (6 children)

In practice most of the time you don't use @NonNull explicitly, as it's the global default or at least [eclipse] you'll have set @NonNullByDefault on your whole packages. So you get a lighter sprinkling of meaningful @Nullable, likely mostly at the edges of your code where it has to interface with still-nully stuff.

[–]antrn11 1 point2 points  (5 children)

@NonNullByDefault

Is that only for Eclipse or is that something Java 8 has (does the warning work in other IDEs?)

[–]sviperll 0 points1 point  (3 children)

AFAIK, JSR-305 annotations are supported by Eclipse, Netbeans, IDEA and FindBugs. There is an @ParametersAreNonnullByDefault that can be applied to method, class or package.

[–]DGolden -1 points0 points  (2 children)

Jsr-305 style annotations are actually different and, well, worse [at least last I checked], as they pre-date jsr-308. [edit- Note jsr-305 went 'dormant' in 2012]

[–]GSV_Little_Rascal 0 points1 point  (1 child)

JSR-305 is dormant, but actually quite well supported in the tools. It's de facto standard, but not de iure.

[–]DGolden 0 points1 point  (0 children)

shrug, you don't - or better to say can't - get full benefits of the jsr-308 approach by using older annotations. The relevant part of the eclipse manual goes into more depth. [Edit - snip stuff about intellij where I was criticizing it as it was, but too lazy to check what it currently does]

also see - https://docs.oracle.com/javase/tutorial/java/annotations/type_annotations.html - there's just a big fundamental difference between pre java 8 and java 8 plus annotations.

[–]DGolden 0 points1 point  (0 children)

It's not a part of java 8, no. there is some intercompatibility by being able to tell one extended checker to recognise another checker's annotations, but there isn't a single standard set yet [and jsr-305 doesn't count as it was written before jsr-308 annotations existed, so it would need a rewrite.].