From d32c59819a56873f41bd60d1ca2654398f59e398 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:31:14 -0700 Subject: [PATCH] Move everything from rewriter except for reflection rules to asm-utils --- .../{DefaultRules.java => BuiltInReflectionRules.java} | 7 +++++-- .../io/papermc/reflectionrewriter/DefineClassRule.java | 5 +++++ .../main/java/io/papermc/reflectionrewriter/EnumRule.java | 4 ++++ .../main/java/io/papermc/asmutils}/BasicRewriteRule.java | 2 +- .../main/java/io/papermc/asmutils}/ClassInfo.java | 2 +- .../main/java/io/papermc/asmutils}/ClassInfoImpl.java | 2 +- .../main/java/io/papermc/asmutils}/ClassInfoProvider.java | 2 +- .../java/io/papermc/asmutils}/ClassProcessingContext.java | 2 +- .../java/io/papermc/asmutils}/InvokeStaticRewrite.java | 4 ++-- .../main/java/io/papermc/asmutils}/MethodMatcher.java | 2 +- .../java/io/papermc/asmutils}/MethodVisitorFactory.java | 2 +- .../main/java/io/papermc/asmutils}/RewriteRule.java | 2 +- .../main/java/io/papermc/asmutils}/RewriteRules.java | 6 +----- .../java/io/papermc/asmutils/RewriteRulesClassVisitor.java | 6 +++--- .../main/java/io/papermc/asmutils}/ShouldProcess.java | 2 +- 15 files changed, 29 insertions(+), 21 deletions(-) rename reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/{DefaultRules.java => BuiltInReflectionRules.java} (96%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/BasicRewriteRule.java (94%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/ClassInfo.java (93%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/ClassInfoImpl.java (89%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/ClassInfoProvider.java (98%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/ClassProcessingContext.java (96%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/InvokeStaticRewrite.java (97%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/MethodMatcher.java (98%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/MethodVisitorFactory.java (90%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/RewriteRule.java (98%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/RewriteRules.java (88%) rename reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ReflectionRewriter.java => src/main/java/io/papermc/asmutils/RewriteRulesClassVisitor.java (91%) rename {reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter => src/main/java/io/papermc/asmutils}/ShouldProcess.java (87%) diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefaultRules.java b/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/BuiltInReflectionRules.java similarity index 96% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefaultRules.java rename to reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/BuiltInReflectionRules.java index 876bbd0..4074972 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefaultRules.java +++ b/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/BuiltInReflectionRules.java @@ -1,9 +1,12 @@ package io.papermc.reflectionrewriter; +import io.papermc.asmutils.InvokeStaticRewrite; +import io.papermc.asmutils.MethodMatcher; +import io.papermc.asmutils.RewriteRule; import java.util.List; import java.util.Set; -public final class DefaultRules { +public final class BuiltInReflectionRules { private final String proxy; private final RewriteRule classRule; private final RewriteRule methodHandlesLookupRule; @@ -11,7 +14,7 @@ public final class DefaultRules { private final RewriteRule constantBootstrapsRule; private final RewriteRule methodTypeRule; - public DefaultRules(final String proxyClassName) { + public BuiltInReflectionRules(final String proxyClassName) { this.proxy = proxyClassName; this.classRule = this.createClassRule(); this.methodHandlesLookupRule = this.createMethodHandlesLookupRule(); diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefineClassRule.java b/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefineClassRule.java index 5122703..17cf966 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefineClassRule.java +++ b/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/DefineClassRule.java @@ -1,5 +1,10 @@ package io.papermc.reflectionrewriter; +import io.papermc.asmutils.ClassInfo; +import io.papermc.asmutils.ClassInfoProvider; +import io.papermc.asmutils.ClassProcessingContext; +import io.papermc.asmutils.InvokeStaticRewrite; +import io.papermc.asmutils.RewriteRule; import java.util.Set; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/EnumRule.java b/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/EnumRule.java index 29f7f31..af65384 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/EnumRule.java +++ b/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/EnumRule.java @@ -1,5 +1,9 @@ package io.papermc.reflectionrewriter; +import io.papermc.asmutils.ClassInfo; +import io.papermc.asmutils.ClassInfoProvider; +import io.papermc.asmutils.InvokeStaticRewrite; +import io.papermc.asmutils.RewriteRule; import java.util.function.Predicate; import org.checkerframework.checker.nullness.qual.Nullable; import org.objectweb.asm.MethodVisitor; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/BasicRewriteRule.java b/src/main/java/io/papermc/asmutils/BasicRewriteRule.java similarity index 94% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/BasicRewriteRule.java rename to src/main/java/io/papermc/asmutils/BasicRewriteRule.java index b295aa6..24b28db 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/BasicRewriteRule.java +++ b/src/main/java/io/papermc/asmutils/BasicRewriteRule.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfo.java b/src/main/java/io/papermc/asmutils/ClassInfo.java similarity index 93% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfo.java rename to src/main/java/io/papermc/asmutils/ClassInfo.java index cd79495..d9f24c8 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfo.java +++ b/src/main/java/io/papermc/asmutils/ClassInfo.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfoImpl.java b/src/main/java/io/papermc/asmutils/ClassInfoImpl.java similarity index 89% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfoImpl.java rename to src/main/java/io/papermc/asmutils/ClassInfoImpl.java index 9f6d049..4468325 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfoImpl.java +++ b/src/main/java/io/papermc/asmutils/ClassInfoImpl.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfoProvider.java b/src/main/java/io/papermc/asmutils/ClassInfoProvider.java similarity index 98% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfoProvider.java rename to src/main/java/io/papermc/asmutils/ClassInfoProvider.java index c120700..8b361e9 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassInfoProvider.java +++ b/src/main/java/io/papermc/asmutils/ClassInfoProvider.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import java.util.Collections; import java.util.LinkedHashMap; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassProcessingContext.java b/src/main/java/io/papermc/asmutils/ClassProcessingContext.java similarity index 96% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassProcessingContext.java rename to src/main/java/io/papermc/asmutils/ClassProcessingContext.java index 90cf2c7..fb293b0 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ClassProcessingContext.java +++ b/src/main/java/io/papermc/asmutils/ClassProcessingContext.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/InvokeStaticRewrite.java b/src/main/java/io/papermc/asmutils/InvokeStaticRewrite.java similarity index 97% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/InvokeStaticRewrite.java rename to src/main/java/io/papermc/asmutils/InvokeStaticRewrite.java index c8f30ab..281026d 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/InvokeStaticRewrite.java +++ b/src/main/java/io/papermc/asmutils/InvokeStaticRewrite.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -9,7 +9,7 @@ @DefaultQualifier(NonNull.class) @FunctionalInterface -interface InvokeStaticRewrite extends MethodVisitorFactory { +public interface InvokeStaticRewrite extends MethodVisitorFactory { @Nullable Rewrite rewrite(ClassProcessingContext context, int opcode, String owner, String name, String descriptor, boolean isInterface); @Override diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/MethodMatcher.java b/src/main/java/io/papermc/asmutils/MethodMatcher.java similarity index 98% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/MethodMatcher.java rename to src/main/java/io/papermc/asmutils/MethodMatcher.java index efe9331..ffe45ad 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/MethodMatcher.java +++ b/src/main/java/io/papermc/asmutils/MethodMatcher.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import java.util.HashSet; import java.util.Set; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/MethodVisitorFactory.java b/src/main/java/io/papermc/asmutils/MethodVisitorFactory.java similarity index 90% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/MethodVisitorFactory.java rename to src/main/java/io/papermc/asmutils/MethodVisitorFactory.java index 7a05ed5..d7492ba 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/MethodVisitorFactory.java +++ b/src/main/java/io/papermc/asmutils/MethodVisitorFactory.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/RewriteRule.java b/src/main/java/io/papermc/asmutils/RewriteRule.java similarity index 98% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/RewriteRule.java rename to src/main/java/io/papermc/asmutils/RewriteRule.java index f1b5cde..3aa54fa 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/RewriteRule.java +++ b/src/main/java/io/papermc/asmutils/RewriteRule.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import java.util.Arrays; import java.util.List; diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/RewriteRules.java b/src/main/java/io/papermc/asmutils/RewriteRules.java similarity index 88% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/RewriteRules.java rename to src/main/java/io/papermc/asmutils/RewriteRules.java index c321a54..21d652f 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/RewriteRules.java +++ b/src/main/java/io/papermc/asmutils/RewriteRules.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import java.util.ArrayList; import java.util.Arrays; @@ -50,10 +50,6 @@ public Builder rules(final List rules) { return this; } - public Builder defaultRules(final String proxyClassName) { - return this.rules(new DefaultRules(proxyClassName).rules()); - } - public RewriteRules build() { return new RewriteRules(this.rules); } diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ReflectionRewriter.java b/src/main/java/io/papermc/asmutils/RewriteRulesClassVisitor.java similarity index 91% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ReflectionRewriter.java rename to src/main/java/io/papermc/asmutils/RewriteRulesClassVisitor.java index 29b8bfc..424ae74 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ReflectionRewriter.java +++ b/src/main/java/io/papermc/asmutils/RewriteRulesClassVisitor.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.NonNull; @@ -8,13 +8,13 @@ import org.objectweb.asm.MethodVisitor; @DefaultQualifier(NonNull.class) -public final class ReflectionRewriter extends ClassVisitor implements ClassProcessingContext { +public final class RewriteRulesClassVisitor extends ClassVisitor implements ClassProcessingContext { private final RewriteRules rules; private final ClassInfoProvider classInfoProvider; private @MonotonicNonNull String name; private @Nullable String superName; - public ReflectionRewriter( + public RewriteRulesClassVisitor( final int api, final ClassVisitor parent, final RewriteRules rules, diff --git a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ShouldProcess.java b/src/main/java/io/papermc/asmutils/ShouldProcess.java similarity index 87% rename from reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ShouldProcess.java rename to src/main/java/io/papermc/asmutils/ShouldProcess.java index bb21afc..31ada7b 100644 --- a/reflection-rewriter/rewriter/src/main/java/io/papermc/reflectionrewriter/ShouldProcess.java +++ b/src/main/java/io/papermc/asmutils/ShouldProcess.java @@ -1,4 +1,4 @@ -package io.papermc.reflectionrewriter; +package io.papermc.asmutils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier;