Example usage for org.objectweb.asm TypeReference getTryCatchBlockIndex

List of usage examples for org.objectweb.asm TypeReference getTryCatchBlockIndex

Introduction

In this page you can find the example usage for org.objectweb.asm TypeReference getTryCatchBlockIndex.

Prototype

public int getTryCatchBlockIndex() 

Source Link

Document

Returns the index of the try catch block (using the order in which they are visited with visitTryCatchBlock), whose 'catch' type is referenced by this type reference.

Usage

From source file:org.decojer.cavaj.readers.asm.ReadMethodVisitor.java

License:Open Source License

@Override
public AnnotationVisitor visitTryCatchAnnotation(final int typeRef, final TypePath typePath, final String desc,
        final boolean visible) {
    final A a = this.annotationVisitor.init(desc, visible ? RetentionPolicy.RUNTIME : RetentionPolicy.CLASS);
    if (a == null) {
        log.warn(getM() + ": Cannot read annotation for descriptor '" + desc + "'!");
        return null;
    }//from   ww  w.j av a2 s.c o m
    final TypeReference typeReference = new TypeReference(typeRef);
    switch (typeReference.getSort()) {
    case TypeReference.EXCEPTION_PARAMETER: {
        final int tryCatchBlockIndex = typeReference.getTryCatchBlockIndex();
        final Exc exc = this.excs.get(tryCatchBlockIndex);
        if (exc == null) {
            log.warn(getM() + ": Cannot apply type annotation '" + a + "' to missing exception!");
            break;
        }
        final T excT = exc.getT();
        if (excT == null) {
            log.warn(getM() + ": Cannot apply type annotation '" + a + "' to catch all exception!");
            break;
        }
        exc.setT(annotateT(excT, a, typePath));
        break;
    }
    default:
        log.warn(
                getM() + ": Unknown type annotation ref sort '0x" + Integer.toHexString(typeReference.getSort())
                        + "' : " + typeRef + " : " + typePath + " : " + desc + " : " + visible);
    }
    return this.annotationVisitor;
}