41
41
*
42
42
* <p>The nullness applies to a type usage, a field, a method return type or a parameter.
43
43
* <a href="https://jspecify.dev/docs/user-guide/">JSpecify annotations</a> are fully supported, as well as
44
- * <a href="https://kotlinlang.org/docs/null-safety.html">Kotlin null safety</a> and {@code @Nullable} annotations
45
- * regardless of their package (from Spring, JSR-305 or Jakarta set of annotations for example).
44
+ * <a href="https://kotlinlang.org/docs/null-safety.html">Kotlin null safety</a>, {@code @Nullable} annotations
45
+ * regardless of their package (from Spring, JSR-305 or Jakarta set of annotations for example) and Java primitive
46
+ * types.
46
47
*
47
48
* @author Sebastien Deleuze
48
49
* @since 7.0
49
50
*/
50
51
public enum Nullness {
51
52
52
53
/**
53
- * Unspecified nullness (Java and JSpecify {@code @NullUnmarked} defaults ).
54
+ * Unspecified nullness (Java default for non-primitive types and JSpecify {@code @NullUnmarked} code ).
54
55
*/
55
56
UNSPECIFIED ,
56
57
@@ -60,7 +61,7 @@ public enum Nullness {
60
61
NULLABLE ,
61
62
62
63
/**
63
- * Will not include null (Kotlin and JSpecify {@code @NullMarked} defaults ).
64
+ * Will not include null (Kotlin default and JSpecify {@code @NullMarked} code ).
64
65
*/
65
66
NON_NULL ;
66
67
@@ -130,6 +131,9 @@ private static boolean hasNullableAnnotation(AnnotatedElement element) {
130
131
}
131
132
132
133
private static Nullness jSpecifyNullness (AnnotatedElement annotatedElement , Class <?> declaringClass , AnnotatedType annotatedType ) {
134
+ if (annotatedType .getType () instanceof Class <?> clazz && clazz .isPrimitive ()) {
135
+ return (clazz != void .class ? Nullness .NON_NULL : Nullness .UNSPECIFIED );
136
+ }
133
137
if (annotatedType .isAnnotationPresent (Nullable .class )) {
134
138
return Nullness .NULLABLE ;
135
139
}
0 commit comments