jdk.internal.org.objectweb.asm.util.TraceSignatureVisitor Java Examples

The following examples show how to use jdk.internal.org.objectweb.asm.util.TraceSignatureVisitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NashornTextifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #2
Source File: NashornTextifier.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #3
Source File: NashornTextifier.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #4
Source File: NashornTextifier.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }
 
Example #5
Source File: NashornTextifier.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #6
Source File: NashornTextifier.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #7
Source File: NashornTextifier.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #8
Source File: NashornTextifier.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }
 
Example #9
Source File: NashornTextifier.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #10
Source File: NashornTextifier.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #11
Source File: NashornTextifier.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #12
Source File: NashornTextifier.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }
 
Example #13
Source File: NashornTextifier.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #14
Source File: NashornTextifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #15
Source File: NashornTextifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #16
Source File: NashornTextifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }
 
Example #17
Source File: NashornTextifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #18
Source File: NashornTextifier.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #19
Source File: NashornTextifier.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #20
Source File: NashornTextifier.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }
 
Example #21
Source File: NashornTextifier.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #22
Source File: NashornTextifier.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #23
Source File: NashornTextifier.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #24
Source File: NashornTextifier.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }
 
Example #25
Source File: NashornTextifier.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    final int major = version & 0xFFFF;
    final int minor = version >>> 16;

    currentClassName = name;

    final StringBuilder sb = new StringBuilder();
    sb.append("// class version ").
        append(major).
        append('.').
        append(minor).append(" (").
        append(version).
        append(")\n");

    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        sb.append("// DEPRECATED\n");
    }

    sb.append("// access flags 0x"). //TODO TRANSLATE TO WHAT THEY MEAN
        append(Integer.toHexString(access).toUpperCase()).
        append('\n');

    appendDescriptor(sb, CLASS_SIGNATURE, signature);
    if (signature != null) {
        final TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
        final SignatureReader r = new SignatureReader(signature);
        r.accept(sv);
        sb.append("// declaration: ").
            append(name).
            append(sv.getDeclaration()).
            append('\n');
    }

    appendAccess(sb, access & ~Opcodes.ACC_SUPER);
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
        sb.append("@interface ");
    } else if ((access & Opcodes.ACC_INTERFACE) != 0) {
        sb.append("interface ");
    } else if ((access & Opcodes.ACC_ENUM) == 0) {
        sb.append("class ");
    }
    appendDescriptor(sb, INTERNAL_NAME, name);

    if (superName != null && !"java/lang/Object".equals(superName)) {
        sb.append(" extends ");
        appendDescriptor(sb, INTERNAL_NAME, superName);
        sb.append(' ');
    }
    if (interfaces != null && interfaces.length > 0) {
        sb.append(" implements ");
        for (final String interface1 : interfaces) {
            appendDescriptor(sb, INTERNAL_NAME, interface1);
            sb.append(' ');
        }
    }
    sb.append(" {\n");

    addText(sb);
}
 
Example #26
Source File: NashornTextifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,final String signature, final Label start, final Label end, final int index) {

    final StringBuilder sb = new StringBuilder();
    if (!localVarsStarted) {
        text.add("\n");
        localVarsStarted = true;
        graph.addNode("vars");
        currentBlock = "vars";
    }

    sb.append(tab2).append("local ").append(name).append(' ');
    final int len = sb.length();
    for (int i = 0; i < 25 - len; i++) {
        sb.append(' ');
    }
    String label;

    label = appendLabel(sb, start);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }
    label = appendLabel(sb, end);
    for (int i = 0; i < 5 - label.length(); i++) {
        sb.append(' ');
    }

    sb.append(index).append(tab2);

    appendDescriptor(sb, FIELD_DESCRIPTOR, desc);
    sb.append('\n');

    if (signature != null) {
        sb.append(tab2);
        appendDescriptor(sb, FIELD_SIGNATURE, signature);

        final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        final SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        sb.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    addText(sb.toString());
}
 
Example #27
Source File: NashornTextifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@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");
    }

    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;
}
 
Example #28
Source File: NashornTextifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public NashornTextifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
        final StringBuilder sb = new StringBuilder();
//        sb.append('\n');
        if ((access & Opcodes.ACC_DEPRECATED) != 0) {
            sb.append(tab).append("// DEPRECATED\n");
        }

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

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

            final TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
            final SignatureReader r = new SignatureReader(signature);
            r.acceptType(sv);
            sb.append(tab).
                append("// declaration: ").
                append(sv.getDeclaration()).
                append('\n');
        }

        sb.append(tab);
        appendAccess(sb, access);

        final String prunedDesc = desc.endsWith(";") ? desc.substring(0, desc.length() - 1) : desc;
        appendDescriptor(sb, FIELD_DESCRIPTOR, prunedDesc);
        sb.append(' ').append(name);
        if (value != null) {
            sb.append(" = ");
            if (value instanceof String) {
                sb.append('\"').append(value).append('\"');
            } else {
                sb.append(value);
            }
        }

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

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

        return t;
    }