mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 09:17:36 +01:00
Fix method reflection remapping with null parameter types passed
Fixes #11052
This commit is contained in:
parent
360b879fa0
commit
76d8369ad4
@ -395,7 +395,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ protected String mapDeclaredMethodName(final Class<?> clazz, final String name, final Class<?>... parameterTypes) {
|
+ protected String mapDeclaredMethodName(final Class<?> clazz, final String name, final Class<?> @Nullable ... parameterTypes) {
|
||||||
+ final @Nullable Map<String, String> mapping = this.strippedMethodMappings.get(clazz.getName());
|
+ final @Nullable Map<String, String> mapping = this.strippedMethodMappings.get(clazz.getName());
|
||||||
+ if (mapping == null) {
|
+ if (mapping == null) {
|
||||||
+ return name;
|
+ return name;
|
||||||
@ -404,7 +404,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ protected String mapMethodName(final Class<?> clazz, final String name, final Class<?>... parameterTypes) {
|
+ protected String mapMethodName(final Class<?> clazz, final String name, final Class<?> @Nullable ... parameterTypes) {
|
||||||
+ final @Nullable String mapped = this.findMappedMethodName(clazz, name, parameterTypes);
|
+ final @Nullable String mapped = this.findMappedMethodName(clazz, name, parameterTypes);
|
||||||
+ return mapped != null ? mapped : name;
|
+ return mapped != null ? mapped : name;
|
||||||
+ }
|
+ }
|
||||||
@ -424,7 +424,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return mapped != null ? mapped : name;
|
+ return mapped != null ? mapped : name;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private @Nullable String findMappedMethodName(final Class<?> clazz, final String name, final Class<?>... parameterTypes) {
|
+ private @Nullable String findMappedMethodName(final Class<?> clazz, final String name, final Class<?> @Nullable ... parameterTypes) {
|
||||||
+ final Map<String, String> map = this.strippedMethodMappings.get(clazz.getName());
|
+ final Map<String, String> map = this.strippedMethodMappings.get(clazz.getName());
|
||||||
+ @Nullable String mapped = null;
|
+ @Nullable String mapped = null;
|
||||||
+ if (map != null) {
|
+ if (map != null) {
|
||||||
@ -474,11 +474,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return mapped;
|
+ return mapped;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static String strippedMethodKey(final String methodName, final Class<?>... parameterTypes) {
|
+ private static String strippedMethodKey(final String methodName, final Class<?> @Nullable ... parameterTypes) {
|
||||||
+ return methodName + parameterDescriptor(parameterTypes);
|
+ return methodName + parameterDescriptor(parameterTypes);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static String parameterDescriptor(final Class<?>... parameterTypes) {
|
+ private static String parameterDescriptor(final Class<?> @Nullable ... parameterTypes) {
|
||||||
|
+ if (parameterTypes == null) {
|
||||||
|
+ // Null parameterTypes is treated as an empty array
|
||||||
|
+ return "()";
|
||||||
|
+ }
|
||||||
+ final StringBuilder builder = new StringBuilder();
|
+ final StringBuilder builder = new StringBuilder();
|
||||||
+ builder.append('(');
|
+ builder.append('(');
|
||||||
+ for (final Class<?> parameterType : parameterTypes) {
|
+ for (final Class<?> parameterType : parameterTypes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user