mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
37 lines
2.1 KiB
Diff
37 lines
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
|
Subject: [PATCH] Add missing rewrite rules
|
|
|
|
TODO: needs to check and fix it.
|
|
The new added rewriting rules cause incompatible with Nova plugin (The call Registry<*>::freeze in RegistryEventsPatch#transform)
|
|
It breaks kotlin reflection, makes it can't get all members of Registry class and its parent interfaces.
|
|
to validate using Nova plugin:
|
|
```
|
|
println(net.minecraft.core.Registry::class.members.size)
|
|
println(net.minecraft.core.Registry::class.java.methods.size)
|
|
```
|
|
|
|
Tracking PR: https://github.com/PaperMC/asm-utils/pull/48
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/pluginremap/reflect/ReflectionRemapper.java b/src/main/java/io/papermc/paper/pluginremap/reflect/ReflectionRemapper.java
|
|
index a3045afbc0cc057e99189b909367b21cf6a9e03f..2831b8b48a12815f8fb7e82327f654e90d1530a3 100644
|
|
--- a/src/main/java/io/papermc/paper/pluginremap/reflect/ReflectionRemapper.java
|
|
+++ b/src/main/java/io/papermc/paper/pluginremap/reflect/ReflectionRemapper.java
|
|
@@ -22,7 +22,14 @@ public final class ReflectionRemapper {
|
|
private static final RewriteRuleVisitorFactory VISITOR_FACTORY = RewriteRuleVisitorFactory.create(
|
|
Opcodes.ASM9,
|
|
chain -> chain.then(new BaseReflectionRules(PAPER_REFLECTION_HOLDER).rules())
|
|
- .then(DefineClassRule.create(PAPER_REFLECTION_HOLDER_DESC, true)),
|
|
+ // Leaf start - Add missing rewrite rules
|
|
+ .then(
|
|
+ io.papermc.asm.rules.RewriteRule.forOwnerClass(Class.class, rf -> {
|
|
+ rf.plainStaticRewrite(java.lang.constant.ClassDesc.of(PAPER_REFLECTION_HOLDER), b -> b
|
|
+ .match("forName").desc("(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", "(Ljava/lang/Module;Ljava/lang/String;)Ljava/lang/Class;"));
|
|
+ })
|
|
+ ).then(DefineClassRule.create(PAPER_REFLECTION_HOLDER_DESC, true)),
|
|
+ // Leaf end - Add missing rewrite rules
|
|
ClassInfoProvider.basic()
|
|
);
|
|
|