public String getClassName() { return remapper.mapType(className); }
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { AnnotationVisitor av = super.visitAnnotation(remapper.mapDesc(desc), visible); return av == null ? null : new RemappingAnnotationAdapter(av, remapper) { @Override public void visitEnum(String name, String enumDesc, String value) { if (Type.getType(enumDesc).getClassName().equals(RedefinitionPolicy.class.getName())) { RedefinitionPolicy valueAsEnum = RedefinitionPolicy.valueOf(value); if (Type.getType(desc).getClassName().equals(FieldRedefinitionPolicy.class.getName())) { cv.visitAttribute(new SingleByteAttribute(FieldRedefinitionPolicy.class.getSimpleName(), (byte) valueAsEnum.ordinal())); } if (Type.getType(desc).getClassName().equals(MethodRedefinitionPolicy.class.getName())) { cv.visitAttribute(new SingleByteAttribute(MethodRedefinitionPolicy.class.getSimpleName(), (byte) valueAsEnum.ordinal())); } } super.visitEnum(name, desc, value); } }; }
return mapType((Type) value); return new Handle( handle.getTag(), mapType(handle.getOwner()), mapMethodName(handle.getOwner(), handle.getName(), handle.getDesc()), handle.getTag() <= Opcodes.H_PUTSTATIC ? mapDesc(handle.getDesc()) : mapMethodDesc(handle.getDesc()), handle.isInterface()); for (int i = 0; i < bootstrapMethodArgumentCount; ++i) { remappedBootstrapMethodArguments[i] = mapValue(constantDynamic.getBootstrapMethodArgument(i)); mapInvokeDynamicMethodName(constantDynamic.getName(), descriptor), mapDesc(descriptor), (Handle) mapValue(constantDynamic.getBootstrapMethod()), remappedBootstrapMethodArguments);
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { FieldVisitor fv = super.visitField(access, remapper.mapFieldName(className, name, desc), remapper.mapDesc(desc), remapper.mapSignature(signature, true), remapper.mapValue(value)); return fv == null ? null : createFieldRemapper(fv); }
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { for (int i = 0; i < bsmArgs.length; i++) { bsmArgs[i] = remapper.mapValue(bsmArgs[i]); } super.visitInvokeDynamicInsn( remapper.mapInvokeDynamicMethodName(name, desc), remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm), bsmArgs); }
@Override public void visitOuterClass(final String owner, final String name, final String descriptor) { super.visitOuterClass( remapper.mapType(owner), name == null ? null : remapper.mapMethodName(owner, name, descriptor), descriptor == null ? null : remapper.mapMethodDesc(descriptor)); }
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { this.className = name; super.visit(version, access, remapper.mapType(name), remapper .mapSignature(signature, false), remapper.mapType(superName), interfaces == null ? null : remapper.mapTypes(interfaces)); }
@Override public void visitFieldInsn( final int opcode, final String owner, final String name, final String descriptor) { super.visitFieldInsn( opcode, remapper.mapType(owner), remapper.mapFieldName(owner, name, descriptor), remapper.mapDesc(descriptor)); }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { String newDesc = remapper.mapMethodDesc(desc); MethodVisitor mv = super.visitMethod(access, remapper.mapMethodName( className, name, desc), newDesc, remapper.mapSignature( signature, false), exceptions == null ? null : remapper.mapTypes(exceptions)); return mv == null ? null : createRemappingMethodAdapter(access, newDesc, mv); }
public String map(String name) { return super.map(name); } }
private Type mapType(Type t) { switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return Type.getType(s); case Type.OBJECT: s = map(t.getInternalName()); return s != null ? Type.getObjectType(s) : t; case Type.METHOD: return Type.getMethodType(mapMethodDesc(t.getDescriptor())); } return t; }
@Override public void visitLdcInsn(Object cst) { cst = remapper.mapValue(cst); super.visitLdcInsn(cst); }
public static MethodNode remap(MethodNode originalMethod, Remapper remapper) { String[] exceptions = getExceptions(originalMethod); MethodNode mappedMethod = new MethodNode( originalMethod.access, originalMethod.name, remapper.mapMethodDesc(originalMethod.desc), remapper.mapSignature(originalMethod.signature, false), remapper.mapTypes(exceptions)); RemappingMethodAdapter remapVisitor = new RemappingMethodAdapter( mappedMethod.access, mappedMethod.desc, mappedMethod, remapper); originalMethod.accept(remapVisitor); return mappedMethod; }
public String mapDesc(String desc) { Type t = Type.getType(desc); switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return s; case Type.OBJECT: String newType = map(t.getInternalName()); if (newType != null) { return 'L' + newType + ';'; } } return desc; }
@Override public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) { super.visitLocalVariable(name, remapper.mapDesc(desc), remapper.mapSignature(signature, true), start, end, index); }
@Override public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { super.visitInnerClass( remapper.mapType(name), outerName == null ? null : remapper.mapType(outerName), innerName == null ? null : remapper.mapInnerClassName(name, outerName, innerName), access); }
/** * Constructs a new remapper for signatures. The default implementation of this method returns a * new {@link SignatureRemapper}. * * @param signatureVisitor the SignatureVisitor the remapper must delegate to. * @return the newly created remapper. * @deprecated use {@link #createSignatureRemapper} instead. */ @Deprecated protected SignatureVisitor createRemappingSignatureAdapter( final SignatureVisitor signatureVisitor) { return createSignatureRemapper(signatureVisitor); }
@Override public String mapSignature(String signature, boolean typeSignature) { // JDT decorates some lambdas with this and SignatureReader chokes on it if (signature != null && signature.contains("!*")) { return null; } return super.mapSignature(signature, typeSignature); }
return mapType((Type) value); return new Handle( handle.getTag(), mapType(handle.getOwner()), mapMethodName(handle.getOwner(), handle.getName(), handle.getDesc()), handle.getTag() <= Opcodes.H_PUTSTATIC ? mapDesc(handle.getDesc()) : mapMethodDesc(handle.getDesc()), handle.isInterface()); for (int i = 0; i < bootstrapMethodArgumentCount; ++i) { remappedBootstrapMethodArguments[i] = mapValue(constantDynamic.getBootstrapMethodArgument(i)); mapInvokeDynamicMethodName(constantDynamic.getName(), descriptor), mapDesc(descriptor), (Handle) mapValue(constantDynamic.getBootstrapMethod()), remappedBootstrapMethodArguments);
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { FieldVisitor fv = super.visitField(access, remapper.mapFieldName(className, name, desc), remapper.mapDesc(desc), remapper.mapSignature(signature, true), remapper.mapValue(value)); return fv == null ? null : createRemappingFieldAdapter(fv); }