Skip to content

Commit

Permalink
fix: annotation testing could be interrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonCaramel committed Oct 1, 2024
1 parent e7e1ab5 commit da67c57
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions patches/api/0003-Test-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..77154095cfb8b259bdb318e8ff40cb6f
+ }
+}
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
index 64e7aef6220097edefdff3b98a771b988365930d..7ff939ea41417bad3a436a87c89d5efa7ecefe86 100644
index 64e7aef6220097edefdff3b98a771b988365930d..f8b8969ee7a0b6f7b3224ff081e35c14a398c9d0 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java
+++ b/src/test/java/org/bukkit/AnnotationTest.java
@@ -29,7 +29,13 @@ public class AnnotationTest {
Expand Down Expand Up @@ -108,8 +108,8 @@ index 64e7aef6220097edefdff3b98a771b988365930d..7ff939ea41417bad3a436a87c89d5efa
}

+ // Paper start - skip class if it's @NullMarked
+ if (isClassNullMarked(clazz)) {
+ return;
+ if (isClassNullMarked(clazz, foundClasses)) {
+ continue;
+ }
+ // Paper end - skip class if it's @NullMarked
+
Expand Down Expand Up @@ -187,20 +187,31 @@ index 64e7aef6220097edefdff3b98a771b988365930d..7ff939ea41417bad3a436a87c89d5efa
}

private static void collectClasses(@NotNull File from, @NotNull Map<String, ClassNode> to) throws IOException {
@@ -125,6 +186,12 @@ public class AnnotationTest {
@@ -125,6 +186,23 @@ public class AnnotationTest {
}
}

+ // Paper start - skip class if it's @NullMarked
+ private static boolean isClassNullMarked(@NotNull ClassNode clazz) {
+ private static boolean isClassNullMarked(@NotNull ClassNode clazz, @NotNull Map<String, ClassNode> allClasses) {
+ if (clazz.nestHostClass != null) {
+ final ClassNode nestHostNode = allClasses.get(clazz.nestHostClass);
+ if (nestHostNode != null) {
+ return isClassNullMarked0(nestHostNode);
+ }
+ }
+
+ return isClassNullMarked0(clazz);
+ }
+
+ private static boolean isClassNullMarked0(@NotNull ClassNode clazz) {
+ return clazz.visibleAnnotations != null && clazz.visibleAnnotations.stream().anyMatch(node -> "Lorg/jspecify/annotations/NullMarked;".equals(node.desc));
+ }
+ // Paper end - skip class if it's @NullMarked
+
private static boolean isClassIncluded(@NotNull ClassNode clazz, @NotNull Map<String, ClassNode> allClasses) {
// Exclude private, synthetic or deprecated classes and annotations, since their members can't be null
if ((clazz.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_DEPRECATED | Opcodes.ACC_ANNOTATION)) != 0) {
@@ -140,6 +207,11 @@ public class AnnotationTest {
@@ -140,6 +218,11 @@ public class AnnotationTest {
// Exceptions are excluded
return false;
}
Expand All @@ -212,7 +223,7 @@ index 64e7aef6220097edefdff3b98a771b988365930d..7ff939ea41417bad3a436a87c89d5efa

for (String excludedClass : EXCLUDED_CLASSES) {
if (excludedClass.equals(clazz.name)) {
@@ -152,7 +224,7 @@ public class AnnotationTest {
@@ -152,7 +235,7 @@ public class AnnotationTest {

private static boolean isMethodIncluded(@NotNull ClassNode clazz, @NotNull MethodNode method, @NotNull Map<String, ClassNode> allClasses) {
// Exclude private, synthetic and deprecated methods
Expand All @@ -221,7 +232,7 @@ index 64e7aef6220097edefdff3b98a771b988365930d..7ff939ea41417bad3a436a87c89d5efa
return false;
}

@@ -170,11 +242,30 @@ public class AnnotationTest {
@@ -170,11 +253,30 @@ public class AnnotationTest {
if ("<init>".equals(method.name) && isAnonymous(clazz)) {
return false;
}
Expand Down

0 comments on commit da67c57

Please sign in to comment.