From a83ba2a0d58325cf3c700538c07a174273140a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sun, 21 Oct 2018 20:02:09 +0800 Subject: [PATCH] =?UTF-8?q?TabooLib=20v4.58=20+=20=E4=BF=AE=E5=A4=8D=20Sim?= =?UTF-8?q?pleVersionControl=20=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../versioncontrol/SimpleClassVisitor.java | 13 +++++++---- .../versioncontrol/SimpleMethodVisitor.java | 22 ++++++++++++++----- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 2a05cb2..bdc462e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.skymc TabooLib - 4.57 + 4.58 UTF-8 diff --git a/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleClassVisitor.java b/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleClassVisitor.java index b58055c..b17c54c 100644 --- a/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleClassVisitor.java +++ b/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleClassVisitor.java @@ -24,22 +24,27 @@ public class SimpleClassVisitor extends ClassVisitor { @Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { - super.visit(version, access, name, translate(signature), translate(superName), translate(interfaces)); + super.visit(version, access, translate(name), translate(signature), translate(superName), translate(interfaces)); } @Override public void visitInnerClass(String name, String outerName, String innerName, int access) { - super.visitInnerClass(name, translate(outerName), translate(innerName), access); + super.visitInnerClass(translate(name), translate(outerName), translate(innerName), access); } @Override public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) { - return super.visitField(access, name, translate(descriptor), translate(signature), value); + return super.visitField(access, translate(name), translate(descriptor), translate(signature), value instanceof String ? translate((String) value) : value); + } + + @Override + public void visitOuterClass(String owner, String name, String descriptor) { + super.visitOuterClass(translate(owner), translate(name), translate(descriptor)); } @Override public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { - return new SimpleMethodVisitor(simpleVersionControl, super.visitMethod(access, name, translate(descriptor), translate(signature), translate(exceptions))); + return new SimpleMethodVisitor(simpleVersionControl, super.visitMethod(access, translate(name), translate(descriptor), translate(signature), translate(exceptions))); } private String translate(String target) { diff --git a/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleMethodVisitor.java b/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleMethodVisitor.java index ab458db..292d81a 100644 --- a/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleMethodVisitor.java +++ b/src/main/java/me/skymc/taboolib/common/versioncontrol/SimpleMethodVisitor.java @@ -1,8 +1,6 @@ package me.skymc.taboolib.common.versioncontrol; -import org.objectweb.asm.Label; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; +import org.objectweb.asm.*; import java.util.stream.IntStream; @@ -21,6 +19,11 @@ public class SimpleMethodVisitor extends MethodVisitor { this.simpleVersionControl = simpleVersionControl; } + @Override + public void visitParameter(String name, int access) { + super.visitParameter(translate(name), access); + } + @Override public void visitMethodInsn(int opcode, String owner, String name, String descriptor) { super.visitMethodInsn(opcode, translate(owner), translate(name), translate(descriptor)); @@ -33,7 +36,11 @@ public class SimpleMethodVisitor extends MethodVisitor { @Override public void visitLdcInsn(Object value) { - super.visitLdcInsn(value instanceof String ? translate((String) value) : value); + if (value instanceof Type) { + super.visitLdcInsn(Type.getType(translate(((Type) value).getDescriptor()))); + } else { + super.visitLdcInsn(value); + } } @Override @@ -43,7 +50,7 @@ public class SimpleMethodVisitor extends MethodVisitor { @Override public void visitFieldInsn(int opcode, String owner, String name, String descriptor) { - super.visitFieldInsn(opcode, translate(owner), name, translate(descriptor)); + super.visitFieldInsn(opcode, translate(owner), translate(name), translate(descriptor)); } @Override @@ -51,6 +58,11 @@ public class SimpleMethodVisitor extends MethodVisitor { super.visitLocalVariable(translate(name), translate(descriptor), translate(signature), start, end, index); } + @Override + public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) { + super.visitInvokeDynamicInsn(translate(name), translate(descriptor), bootstrapMethodHandle, bootstrapMethodArguments); + } + private String translate(String target) { return target == null ? null : simpleVersionControl.replace(target); }