Allow use of TYPE_USE annotations

This commit is contained in:
Riley Park 2021-06-21 09:55:17 -07:00
parent 33a04d97ab
commit 15e4b30e9e
No known key found for this signature in database
GPG Key ID: D831AF236C834E45
317 changed files with 56 additions and 27 deletions

View File

@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Riley Park <riley.park@meino.net>
Date: Mon, 21 Jun 2021 09:51:29 -0700
Subject: [PATCH] Allow use of TYPE_USE annotations
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
index 0c7377247ad9251c9e498039511e7220370aba2d..2ef6b56642f792d1a648e76e904e61bf7a662f8c 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java
+++ b/src/test/java/org/bukkit/AnnotationTest.java
@@ -66,15 +66,26 @@ 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) && !isWellAnnotated(method.invisibleTypeAnnotations)) { // Paper - also check (in)visible type annotations
warn(errors, clazz, method, "return value");
}
Type[] paramTypes = Type.getArgumentTypes(method.desc);
List<ParameterNode> parameters = method.parameters;
+ dancing: // Paper
for (int i = 0; i < paramTypes.length; i++) {
if (mustBeAnnotated(paramTypes[i]) && !isWellAnnotated(method.invisibleParameterAnnotations == null ? null : method.invisibleParameterAnnotations[i])) {
+ // Paper start - wheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+ if (method.invisibleTypeAnnotations != null) {
+ for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) {
+ continue dancing;
+ }
+ }
+ }
+ // Paper end
ParameterNode paramNode = parameters == null ? null : parameters.get(i);
String paramName = paramNode == null ? null : paramNode.name;

View File

@ -3706,7 +3706,7 @@ index da01d2926cc8a2485a3349ac1ebb32cad20e287c..f0af10a5b9ad048be197ed5ec6c8ed26
/** /**
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
index 0c7377247ad9251c9e498039511e7220370aba2d..c62919f18f318fec15a6c364d8b6d562c2b04762 100644 index 4aee3dd321453009fda10db9c4fbea0ffed6ed69..002677ac589aa88b643c52a883a72a2bdc3696dd 100644
--- a/src/test/java/org/bukkit/AnnotationTest.java --- a/src/test/java/org/bukkit/AnnotationTest.java
+++ b/src/test/java/org/bukkit/AnnotationTest.java +++ b/src/test/java/org/bukkit/AnnotationTest.java
@@ -26,6 +26,12 @@ import org.objectweb.asm.tree.ParameterNode; @@ -26,6 +26,12 @@ import org.objectweb.asm.tree.ParameterNode;
@ -3722,16 +3722,7 @@ index 0c7377247ad9251c9e498039511e7220370aba2d..c62919f18f318fec15a6c364d8b6d562
"Lorg/jetbrains/annotations/Nullable;", "Lorg/jetbrains/annotations/Nullable;",
"Lorg/jetbrains/annotations/NotNull;", "Lorg/jetbrains/annotations/NotNull;",
"Lorg/jetbrains/annotations/Contract;", "Lorg/jetbrains/annotations/Contract;",
@@ -66,7 +72,7 @@ public class AnnotationTest { @@ -185,7 +191,7 @@ 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");
}
@@ -174,7 +180,7 @@ public class AnnotationTest {
return true; return true;
} }

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Entity Origin API
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 03e12de470f983e89a473c4e42c21941085b1d37..fdce246aecac775c3ff4a028c307b09762505258 100644 index d7a4cfed4f46b34f83fb2c07bdab5a71215d26bb..8c93c640dd163ca99df81706715117094fea5738 100644
--- a/src/main/java/org/bukkit/entity/Entity.java --- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -655,5 +655,15 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent @@ -655,5 +655,15 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Use ASM for event executors.
Uses method handles for private or static methods. Uses method handles for private or static methods.
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index 3a36b2b7f38e3446177f0883083d30c739f6c9b1..9d0675e2afcd9c0f82b6e993b1185d507b32ed0f 100644 index 19b55f2c25db81fc352a7ab973b2ca7fefbcb432..d1a3e38012873109709cc6fffdce9d9c5614ec73 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -24,6 +24,8 @@ dependencies { @@ -24,6 +24,8 @@ dependencies {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Entity#fromMobSpawner()
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index fdce246aecac775c3ff4a028c307b09762505258..fdc95c87a6020bdcaee5b0b8ab5a996c0e241b33 100644 index 8c93c640dd163ca99df81706715117094fea5738..85478ed185a938aa8e95d450da8197c76f13106b 100644
--- a/src/main/java/org/bukkit/entity/Entity.java --- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -665,5 +665,12 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent @@ -665,5 +665,12 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent

View File

@ -5,7 +5,7 @@ Subject: [PATCH] LivingEntity#setKiller
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 45e9f585c3e522ecf94a6bc42cdc190e1a191a5c..33fffda7c8b05cde3c95623937e7eb6c8b628ec6 100644 index b41133f23d25f90fc0993499056c4eeaf003a701..bfc90a3569abc717f37c064e3068c55ef323edab 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java --- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -279,6 +279,15 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @@ -279,6 +279,15 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource

View File

@ -14,7 +14,7 @@ it without having to shade it in the plugin and going through
several layers of logging abstraction. several layers of logging abstraction.
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index c10c9f86db276b42d8b7c21c353970691990f125..6d04816e22f44a33c001d2b7e080402fba6af86c 100644 index d1a3e38012873109709cc6fffdce9d9c5614ec73..e142072f31a41b25ac637970f79e71ab70c2f28c 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -26,6 +26,7 @@ dependencies { @@ -26,6 +26,7 @@ dependencies {

Some files were not shown because too many files have changed in this diff Show More