mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Add checkerframework nullness annotations to accepted list for AnnotationTest (#5409)
Also use checkerframework annotations instead of jetbrains ones for Inventory#getContents as jetbrains ones do not allow properly annotating the nullability of an array and it's contents.
This commit is contained in:
parent
4a1f5cb85e
commit
a12e69774f
2 changed files with 36 additions and 1 deletions
|
@ -3597,3 +3597,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
void setColor(@NotNull ChatColor color);
|
||||
|
||||
/**
|
||||
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
||||
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
@@ -0,0 +0,0 @@ import org.objectweb.asm.tree.ParameterNode;
|
||||
public class AnnotationTest {
|
||||
|
||||
private static final String[] ACCEPTED_ANNOTATIONS = {
|
||||
+ // Paper start
|
||||
+ "Lorg/checkerframework/checker/nullness/qual/Nullable;",
|
||||
+ "Lorg/checkerframework/checker/nullness/qual/NonNull;",
|
||||
+ "Lorg/checkerframework/checker/nullness/qual/PolyNull;",
|
||||
+ "Lorg/checkerframework/checker/nullness/qual/MonotonicNonNull;",
|
||||
+ // Paper end
|
||||
"Lorg/jetbrains/annotations/Nullable;",
|
||||
"Lorg/jetbrains/annotations/NotNull;",
|
||||
"Lorg/jetbrains/annotations/Contract;",
|
||||
@@ -0,0 +0,0 @@ public class AnnotationTest {
|
||||
continue;
|
||||
}
|
||||
|
||||
- if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) {
|
||||
+ if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations) && !isWellAnnotated(method.visibleTypeAnnotations)) { // Paper - also check visible type annotations
|
||||
warn(errors, clazz, method, "return value");
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class AnnotationTest {
|
||||
return true;
|
||||
}
|
||||
|
||||
- private static boolean isWellAnnotated(@Nullable List<AnnotationNode> annotations) {
|
||||
+ private static boolean isWellAnnotated(@Nullable List<? extends AnnotationNode> annotations) { // Paper - allow children of AnnotationNode
|
||||
if (annotations == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
- @NotNull
|
||||
- public ItemStack[] getContents();
|
||||
-
|
||||
+ public @Nullable ItemStack @NotNull [] getContents(); // Paper - make array elements nullable instead array
|
||||
+ public @org.checkerframework.checker.nullness.qual.Nullable ItemStack @org.checkerframework.checker.nullness.qual.NonNull [] getContents(); // Paper - make array elements nullable instead array
|
||||
+
|
||||
/**
|
||||
* Completely replaces the inventory's contents. Removes all existing
|
||||
|
|
Loading…
Reference in a new issue