use of org.objectweb.asm.signature.SignatureReader in project bytecode-viewer by Konloch.
the class Textifier method visitField.
@Override
public Textifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
buf.setLength(0);
buf.append('\n');
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
buf.append(tab).append("// DEPRECATED\n");
}
buf.append(tab).append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');
if (signature != null) {
buf.append(tab);
appendDescriptor(FIELD_SIGNATURE, signature);
TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
SignatureReader r = new SignatureReader(signature);
r.acceptType(sv);
buf.append(tab).append("// declaration: ").append(sv.getDeclaration()).append('\n');
}
buf.append(tab);
appendAccess(access);
appendDescriptor(FIELD_DESCRIPTOR, desc);
buf.append(' ').append(name);
if (value != null) {
buf.append(" = ");
if (value instanceof String) {
buf.append('\"').append(value).append('\"');
} else {
buf.append(value);
}
}
buf.append('\n');
text.add(buf.toString());
Textifier t = createTextifier();
text.add(t.getText());
return t;
}
use of org.objectweb.asm.signature.SignatureReader 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;
}
use of org.objectweb.asm.signature.SignatureReader in project platform_frameworks_base by android.
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.SignatureReader in project meghanada-server by mopemope.
the class ClassAnalyzeVisitor method visit.
@Override
public void visit(int api, int access, String name, String signature, String superClass, String[] interfaces) {
// log.debug("Name:{}", name);
// call class
this.access = access;
final boolean isInterface = (Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE;
if (signature != null) {
// generics
// log.debug("name {} sig {}", name, signature);
final SignatureReader signatureReader = new SignatureReader(signature);
ClassSignatureVisitor classSignatureVisitor = new ClassSignatureVisitor(this.className, isInterface);
signatureReader.accept(classSignatureVisitor);
this.classTypeParameters = classSignatureVisitor.getTypeParameters();
this.classIndex = classSignatureVisitor.getClassIndex();
if (!this.classIndex.getSupers().contains(ClassNameUtils.OBJECT_CLASS)) {
this.classIndex.addSuper(ClassNameUtils.OBJECT_CLASS);
}
} else {
this.classTypeParameters = new ArrayList<>(4);
final List<String> supers = new ArrayList<>(4);
if (superClass != null) {
final String superClassFQCN = ClassNameUtils.replaceSlash(superClass);
supers.add(superClassFQCN);
}
Arrays.stream(interfaces).forEach(interfaceName -> supers.add(ClassNameUtils.replaceSlash(interfaceName)));
this.classIndex = new ClassIndex(this.className, new ArrayList<>(4), supers);
this.classIndex.setInterface(isInterface);
}
}
use of org.objectweb.asm.signature.SignatureReader in project sonar-java by SonarSource.
the class BytecodeVisitor method visitField.
@Override
public FieldVisitor visitField(int flags, String name, String desc, @Nullable String signature, @Nullable Object value) {
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(desc);
if (isNotSynthetic(flags)) {
// Flags from asm lib are defined in Opcodes class and map to flags defined in Flags class
final JavaSymbol.VariableJavaSymbol symbol = new JavaSymbol.VariableJavaSymbol(Flags.filterAccessBytecodeFlags(flags), name, convertAsmType(org.objectweb.asm.Type.getType(desc)), classSymbol);
classSymbol.members.enter(symbol);
if (signature != null) {
ReadType typeReader = new ReadType();
new SignatureReader(signature).accept(typeReader);
symbol.type = typeReader.typeRead;
}
// checks for annotations on the field
return new BytecodeFieldVisitor(symbol, this);
}
return null;
}
Aggregations