use of org.objectweb.asm.signature.SignatureWriter in project android_frameworks_base by DirtyUnicorns.
the class AbstractClassAdapter method renameTypeSignature.
/**
* Renames the ClassSignature handled by ClassVisitor.visit
* or the MethodTypeSignature handled by ClassVisitor.visitMethod.
*/
String renameTypeSignature(String sig) {
if (sig == null) {
return null;
}
SignatureReader reader = new SignatureReader(sig);
SignatureWriter writer = new SignatureWriter();
reader.accept(new RenameSignatureAdapter(writer));
sig = writer.toString();
return sig;
}
use of org.objectweb.asm.signature.SignatureWriter in project cdap by caskdata.
the class Signatures method getMethodSignature.
/**
* Generates signature for the given method.
*
* @param method Method that needs signature to be generated
* @param returnType the {@link TypeToken} of the return type
* @param argTypes List of {@link TypeToken} that matches with the number of arguments in the given method.
* For a given method argument, if the corresponding {@link TypeToken} is non-null, it will be
* used to generate the type parameter in the signature, otherwise, the one in the method will be used.
* It's useful if the method is parameterized so that parameterize type information can be passed
* through the type tokens.
* @return A method signature string
*/
public static String getMethodSignature(Method method, TypeToken<?> returnType, TypeToken<?>... argTypes) {
SignatureWriter signWriter = new SignatureWriter();
Type[] argumentTypes = method.getArgumentTypes();
for (int i = 0; i < argumentTypes.length; i++) {
SignatureVisitor sv = signWriter.visitParameterType();
if (argTypes[i] != null) {
visitTypeSignature(argTypes[i], sv);
} else {
sv.visitClassType(argumentTypes[i].getInternalName());
sv.visitEnd();
}
}
visitTypeSignature(returnType, signWriter.visitReturnType());
return signWriter.toString();
}
use of org.objectweb.asm.signature.SignatureWriter in project cdap by caskdata.
the class FieldAccessorGenerator method setterSignature.
/**
* @return the setter signature {@code <T> void set(Object object, T value)}
*/
private String setterSignature() {
SignatureWriter writer = new SignatureWriter();
writer.visitFormalTypeParameter("T");
SignatureVisitor sv = writer.visitClassBound();
sv.visitClassType(Type.getInternalName(Object.class));
sv.visitEnd();
sv = writer.visitParameterType();
sv.visitClassType(Type.getInternalName(Object.class));
sv.visitEnd();
sv = writer.visitParameterType();
sv.visitTypeVariable("T");
sv.visitReturnType().visitBaseType('V');
return writer.toString();
}
use of org.objectweb.asm.signature.SignatureWriter in project cdap by caskdata.
the class Signatures method getClassSignature.
public static String getClassSignature(TypeToken<?> interfaceType) {
SignatureWriter signWriter = new SignatureWriter();
SignatureVisitor sv = signWriter.visitSuperclass();
sv.visitClassType(Type.getInternalName(Object.class));
sv.visitEnd();
SignatureVisitor interfaceVisitor = sv.visitInterface();
interfaceVisitor.visitClassType(Type.getInternalName(interfaceType.getRawType()));
if (interfaceType.getType() instanceof ParameterizedType) {
for (java.lang.reflect.Type paramType : ((ParameterizedType) interfaceType.getType()).getActualTypeArguments()) {
interfaceVisitor.visitTypeArgument(SignatureVisitor.INSTANCEOF);
visitTypeSignature(interfaceType.resolveType(paramType), interfaceVisitor);
}
}
sv.visitEnd();
return signWriter.toString();
}
use of org.objectweb.asm.signature.SignatureWriter in project android_frameworks_base by crdroidandroid.
the class AbstractClassAdapter method renameTypeSignature.
/**
* Renames the ClassSignature handled by ClassVisitor.visit
* or the MethodTypeSignature handled by ClassVisitor.visitMethod.
*/
String renameTypeSignature(String sig) {
if (sig == null) {
return null;
}
SignatureReader reader = new SignatureReader(sig);
SignatureWriter writer = new SignatureWriter();
reader.accept(new RenameSignatureAdapter(writer));
sig = writer.toString();
return sig;
}
Aggregations