TabooLib v4.58

+ 修复 SimpleVersionControl 的一些问题
This commit is contained in:
坏黑 2018-10-21 20:02:09 +08:00
parent 2bcc82aa15
commit a83ba2a0d5
3 changed files with 27 additions and 10 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.skymc</groupId> <groupId>me.skymc</groupId>
<artifactId>TabooLib</artifactId> <artifactId>TabooLib</artifactId>
<version>4.57</version> <version>4.58</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -24,22 +24,27 @@ public class SimpleClassVisitor extends ClassVisitor {
@Override @Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { 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 @Override
public void visitInnerClass(String name, String outerName, String innerName, int access) { 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 @Override
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) { 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 @Override
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { 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) { private String translate(String target) {

View File

@ -1,8 +1,6 @@
package me.skymc.taboolib.common.versioncontrol; package me.skymc.taboolib.common.versioncontrol;
import org.objectweb.asm.Label; import org.objectweb.asm.*;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@ -21,6 +19,11 @@ public class SimpleMethodVisitor extends MethodVisitor {
this.simpleVersionControl = simpleVersionControl; this.simpleVersionControl = simpleVersionControl;
} }
@Override
public void visitParameter(String name, int access) {
super.visitParameter(translate(name), access);
}
@Override @Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor) { public void visitMethodInsn(int opcode, String owner, String name, String descriptor) {
super.visitMethodInsn(opcode, translate(owner), translate(name), translate(descriptor)); super.visitMethodInsn(opcode, translate(owner), translate(name), translate(descriptor));
@ -33,7 +36,11 @@ public class SimpleMethodVisitor extends MethodVisitor {
@Override @Override
public void visitLdcInsn(Object value) { 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 @Override
@ -43,7 +50,7 @@ public class SimpleMethodVisitor extends MethodVisitor {
@Override @Override
public void visitFieldInsn(int opcode, String owner, String name, String descriptor) { 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 @Override
@ -51,6 +58,11 @@ public class SimpleMethodVisitor extends MethodVisitor {
super.visitLocalVariable(translate(name), translate(descriptor), translate(signature), start, end, index); 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) { private String translate(String target) {
return target == null ? null : simpleVersionControl.replace(target); return target == null ? null : simpleVersionControl.replace(target);
} }