Example usage for org.objectweb.asm TypeReference EXCEPTION_PARAMETER

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

Introduction

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

Prototype

int EXCEPTION_PARAMETER

To view the source code for org.objectweb.asm TypeReference EXCEPTION_PARAMETER.

Click Source Link

Document

The sort of type references that target the type of the exception of a 'catch' clause in a method.

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  a 2  s .co  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;
}