Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect remapping of Class#getMethod regarding parameterTypes #11052

Closed
Aurelien30000 opened this issue Jul 10, 2024 · 0 comments
Closed

Incorrect remapping of Class#getMethod regarding parameterTypes #11052

Aurelien30000 opened this issue Jul 10, 2024 · 0 comments
Assignees
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21 Game version 1.21

Comments

@Aurelien30000
Copy link

Aurelien30000 commented Jul 10, 2024

Expected behavior

No error, correct handling of null as described in the javadocs.

Observed/Actual behavior

java.lang.NullPointerException: Cannot read the array length because "<local2>" is null
	at io.papermc.paper.pluginremap.reflect.PaperReflection.parameterDescriptor(PaperReflection.java:147) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at io.papermc.paper.pluginremap.reflect.PaperReflection.strippedMethodKey(PaperReflection.java:141) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at io.papermc.paper.pluginremap.reflect.PaperReflection.findMappedMethodName(PaperReflection.java:94) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at io.papermc.paper.pluginremap.reflect.PaperReflection.mapMethodName(PaperReflection.java:71) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at io.papermc.reflectionrewriter.runtime.AbstractDefaultRulesReflectionProxy.getMethod(AbstractDefaultRulesReflectionProxy.java:100) ~[reflection-rewriter-runtime-0.0.3.jar:?]
	at io.papermc.paper.pluginremap.reflect.PaperReflectionHolder.getMethod(Unknown Source) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at ActionHealth-3.5.9-all.jar/com.zeshanaslam.actionhealth.utils.HealthUtil.getNameReflection(HealthUtil.java:245) ~[ActionHealth-3.5.9-all.jar:?]
	at ActionHealth-3.5.9-all.jar/com.zeshanaslam.actionhealth.utils.HealthUtil.getName(HealthUtil.java:222) ~[ActionHealth-3.5.9-all.jar:?]
	at ActionHealth-3.5.9-all.jar/com.zeshanaslam.actionhealth.LookThread.run(LookThread.java:36) ~[ActionHealth-3.5.9-all.jar:?]
	at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:482) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1717) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:471) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1601) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1308) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[paper-1.21.jar:1.21-49-b0ef3ca]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

You can check out this original issue zeshan321/ActionHealth#67

Steps/models to reproduce

Run remapped Class#getMethod with a null parameterTypes.
You can try with the described problem below: Entity.class.getMethod("getName", (Class<?>[]) null).

Example: https://github.com/zeshan321/ActionHealth/blob/6226feeb3233bd1500f184a87b08480b0e3c028c/src/main/java/com/zeshanaslam/actionhealth/utils/HealthUtil.java#L245C27-L245C85

Plugin and Datapack List

[16:28:51 INFO]: Server Plugins (1):
[16:28:51 INFO]: Bukkit Plugins:
[16:28:51 INFO]:  - ActionHealth
[16:29:46 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[16:29:46 INFO]: There are no more data packs available

Paper version

[16:30:05 INFO]: Checking version, please wait...
[16:30:05 INFO]: This server is running Paper version 1.21-49-master@b0ef3ca (2024-07-09T15:22:17Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21-47-62ed302 (MC: 1.21)

Other

Currently there is no handling of null values, might be nice to support them.
https://github.com/PaperMC/Paper/blob/master/patches/server/0022-Remap-reflection-calls-in-plugins-using-internals.patch#L481

Thanks :D

If you need more details do not hesitate.

@Aurelien30000 Aurelien30000 added status: needs triage type: bug Something doesn't work as it was intended to. labels Jul 10, 2024
@papermc-sniffer papermc-sniffer bot added the version: 1.21 Game version 1.21 label Jul 10, 2024
@papermc-projects papermc-projects bot moved this to 🕑 Needs Triage in Issues: Bugs Jul 10, 2024
@lynxplay lynxplay added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Jul 10, 2024
@papermc-projects papermc-projects bot moved this from 🕑 Needs Triage to ✅ Accepted in Issues: Bugs Jul 10, 2024
@Aurelien30000 Aurelien30000 changed the title Incorrection remapping of Class#getMethod regarding parameterTypes Incorrect remapping of Class#getMethod regarding parameterTypes Jul 10, 2024
@kennytv kennytv self-assigned this Jul 10, 2024
@github-project-automation github-project-automation bot moved this from ✅ Accepted to Done in Issues: Bugs Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21 Game version 1.21
Projects
Status: Done
Development

No branches or pull requests

3 participants