Methods Summary |
---|
java.lang.String | renameFieldSignature(java.lang.String sig)Renames the FieldTypeSignature handled by ClassVisitor.visitField
or MethodVisitor.visitLocalVariable.
return renameTypeSignature(sig);
|
abstract java.lang.String | renameInternalType(java.lang.String name)Returns the new FQCN for the class, if the reference to this class needs
to be updated. Else, it returns the same string.
|
java.lang.String | renameMethodDesc(java.lang.String desc)Renames a method descriptor, i.e. applies renameType to all arguments and to the
return value.
if (desc == null) {
return null;
}
Type[] args = Type.getArgumentTypes(desc);
StringBuilder sb = new StringBuilder("(");
for (Type arg : args) {
String name = renameType(arg);
sb.append(name);
}
sb.append(')");
Type ret = Type.getReturnType(desc);
String name = renameType(ret);
sb.append(name);
return sb.toString();
|
java.lang.String | renameType(org.objectweb.asm.Type type)Renames an object type, e.g. "Lcom.package.MyClass;" or an array type that has an
object element, e.g. "[Lcom.package.MyClass;"
If the type doesn't need to be renamed, returns the internal name of the input type.
if (type == null) {
return null;
}
if (type.getSort() == Type.OBJECT) {
String in = type.getInternalName();
return "L" + renameInternalType(in) + ";";
} else if (type.getSort() == Type.ARRAY) {
StringBuilder sb = new StringBuilder();
for (int n = type.getDimensions(); n > 0; n--) {
sb.append('[");
}
sb.append(renameType(type.getElementType()));
return sb.toString();
}
return type.getDescriptor();
|
org.objectweb.asm.Type | renameTypeAsType(org.objectweb.asm.Type type)Renames an object type, e.g. "Lcom.package.MyClass;" or an array type that has an
object element, e.g. "[Lcom.package.MyClass;".
This is like renameType() except that it returns a Type object.
If the type doesn't need to be renamed, returns the input type object.
if (type == null) {
return null;
}
if (type.getSort() == Type.OBJECT) {
String in = type.getInternalName();
String newIn = renameInternalType(in);
if (!newIn.equals(in)) {
return Type.getType("L" + newIn + ";");
}
} else if (type.getSort() == Type.ARRAY) {
StringBuilder sb = new StringBuilder();
for (int n = type.getDimensions(); n > 0; n--) {
sb.append('[");
}
sb.append(renameType(type.getElementType()));
return Type.getType(sb.toString());
}
return type;
|
java.lang.String | renameTypeDesc(java.lang.String desc)Renames a type descriptor, e.g. "Lcom.package.MyClass;"
If the type doesn't need to be renamed, returns the input string as-is.
if (desc == null) {
return null;
}
return renameType(Type.getType(desc));
|
java.lang.String | renameTypeSignature(java.lang.String sig)Renames the ClassSignature handled by ClassVisitor.visit
or the MethodTypeSignature handled by ClassVisitor.visitMethod.
if (sig == null) {
return null;
}
SignatureReader reader = new SignatureReader(sig);
SignatureWriter writer = new SignatureWriter();
reader.accept(new RenameSignatureAdapter(writer));
sig = writer.toString();
return sig;
|
public void | visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
name = renameInternalType(name);
superName = renameInternalType(superName);
signature = renameTypeSignature(signature);
if (interfaces != null) {
for (int i = 0; i < interfaces.length; ++i) {
interfaces[i] = renameInternalType(interfaces[i]);
}
}
/* Java 7 verifies the StackMapTable of a class if its version number is greater than 50.0.
* However, the check is disabled if the class version number is 50.0 or less. Generation
* of the StackMapTable requires a rewrite using the tree API of ASM. As a workaround,
* we rewrite the version number of the class to be 50.0
*
* http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6693236
*/
if (version > 50) {
version = 50;
}
super.visit(version, access, name, signature, superName, interfaces);
|
public org.objectweb.asm.AnnotationVisitor | visitAnnotation(java.lang.String desc, boolean visible)
desc = renameTypeDesc(desc);
return super.visitAnnotation(desc, visible);
|
public org.objectweb.asm.FieldVisitor | visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
desc = renameTypeDesc(desc);
return super.visitField(access, name, desc, signature, value);
|
public void | visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
name = renameInternalType(name);
outerName = renameInternalType(outerName);
super.visitInnerClass(name, outerName, innerName, access);
|
public org.objectweb.asm.MethodVisitor | visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
desc = renameMethodDesc(desc);
signature = renameTypeSignature(signature);
MethodVisitor mw = super.visitMethod(access, name, desc, signature, exceptions);
return new RenameMethodAdapter(mw);
|
public void | visitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)
super.visitOuterClass(renameInternalType(owner), name, renameTypeDesc(desc));
|