Example usage for org.objectweb.asm.util TraceSignatureVisitor getExceptions

List of usage examples for org.objectweb.asm.util TraceSignatureVisitor getExceptions

Introduction

In this page you can find the example usage for org.objectweb.asm.util TraceSignatureVisitor getExceptions.

Prototype

public String getExceptions() 

Source Link

Document

Returns the Java generic exception types declaration corresponding to the visited signature.

Usage

From source file:com.gargoylesoftware.js.nashorn.internal.ir.debug.NashornTextifier.java

License:Open Source License

@Override
public NashornTextifier visitMethod(final int access, final String name, final String desc,
        final String signature, final String[] exceptions) {

    graph = new Graph(name);

    final List<Label> extraLabels = cr.getExtraLabels(currentClassName, name, desc);
    this.labelIter = extraLabels == null ? null : extraLabels.iterator();

    final StringBuilder sb = new StringBuilder();

    sb.append('\n');
    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append(tab).append("// DEPRECATED\n");
    }/*w w w .  j a  v a  2  s . c  o m*/

    sb.append(tab).append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');

    if (signature != null) {
        sb.append(tab);
        appendDescriptor(sb, METHOD_SIGNATURE, signature);

        final TraceSignatureVisitor v = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(v);
        final String genericDecl = v.getDeclaration();
        final String genericReturn = v.getReturnType();
        final String genericExceptions = v.getExceptions();

        sb.append(tab).append("// declaration: ").append(genericReturn).append(' ').append(name)
                .append(genericDecl);

        if (genericExceptions != null) {
            sb.append(" throws ").append(genericExceptions);
        }
        sb.append('\n');
    }

    sb.append(tab);
    appendAccess(sb, access);
    if ((access & Opcodes.ACC_NATIVE) != 0) {
        sb.append("native ");
    }
    if ((access & Opcodes.ACC_VARARGS) != 0) {
        sb.append("varargs ");
    }
    if ((access & Opcodes.ACC_BRIDGE) != 0) {
        sb.append("bridge ");
    }

    sb.append(name);
    appendDescriptor(sb, METHOD_DESCRIPTOR, desc);
    if (exceptions != null && exceptions.length > 0) {
        sb.append(" throws ");
        for (final String exception : exceptions) {
            appendDescriptor(sb, INTERNAL_NAME, exception);
            sb.append(' ');
        }
    }

    sb.append('\n');
    addText(sb);

    final NashornTextifier t = createNashornTextifier();
    addText(t.getText());
    return t;
}