Search in sources :

Example 26 with SignatureReader

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;
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader)

Example 27 with SignatureReader

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;
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader) SignatureWriter(org.objectweb.asm.signature.SignatureWriter)

Example 28 with SignatureReader

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;
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader) SignatureWriter(org.objectweb.asm.signature.SignatureWriter)

Example 29 with SignatureReader

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);
    }
}
Also used : ClassIndex(meghanada.reflect.ClassIndex) SignatureReader(org.objectweb.asm.signature.SignatureReader) ArrayList(java.util.ArrayList)

Example 30 with SignatureReader

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;
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader)

Aggregations

SignatureReader (org.objectweb.asm.signature.SignatureReader)41 SignatureWriter (org.objectweb.asm.signature.SignatureWriter)12 ArrayList (java.util.ArrayList)5 ClassNode (org.codehaus.groovy.ast.ClassNode)4 GenericsType (org.codehaus.groovy.ast.GenericsType)3 Type (org.objectweb.asm.Type)3 SignatureVisitor (org.objectweb.asm.signature.SignatureVisitor)3 BoundDescriptor (com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor)2 AbstractBoundVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor)2 List (java.util.List)2 Map (java.util.Map)2 TypeSignatureVisitor (net.sourceforge.pmd.dcd.asm.TypeSignatureVisitor)2 EntryMessage (org.apache.logging.log4j.message.EntryMessage)2 ConstantExpression (org.codehaus.groovy.ast.expr.ConstantExpression)2 ReturnStatement (org.codehaus.groovy.ast.stmt.ReturnStatement)2 DelegatingMethodVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.delegate.DelegatingMethodVisitor)1 ClassSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.ClassSignatureVisitor)1 MethodSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.MethodSignatureVisitor)1 IOException (java.io.IOException)1 Constructor (java.lang.reflect.Constructor)1