Skip to content

Commit

Permalink
Move everything from rewriter except for reflection rules to asm-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Feb 12, 2024
1 parent eca8506 commit d32c598
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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;
private final RewriteRule lambdaMetafactoryRule;
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.papermc.reflectionrewriter;
package io.papermc.asmutils;

import java.util.Collections;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.papermc.reflectionrewriter;
package io.papermc.asmutils;

import java.util.HashSet;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.papermc.reflectionrewriter;
package io.papermc.asmutils;

import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.papermc.reflectionrewriter;
package io.papermc.asmutils;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -50,10 +50,6 @@ public Builder rules(final List<RewriteRule> rules) {
return this;
}

public Builder defaultRules(final String proxyClassName) {
return this.rules(new DefaultRules(proxyClassName).rules());
}

public RewriteRules build() {
return new RewriteRules(this.rules);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit d32c598

Please sign in to comment.