jdk.nashorn.internal.ir.debug.NashornClassReader Java Examples

The following examples show how to use jdk.nashorn.internal.ir.debug.NashornClassReader. 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: ClassEmitter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}
 
Example #2
Source File: ClassEmitter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}
 
Example #3
Source File: ClassEmitter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}
 
Example #4
Source File: ClassEmitter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}
 
Example #5
Source File: ClassEmitter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}
 
Example #6
Source File: ClassEmitter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}
 
Example #7
Source File: ClassEmitter.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Disassemble an array of byte code.
 *
 * @param bytecode  byte array representing bytecode
 *
 * @return disassembly as human readable string
 */
static String disassemble(final byte[] bytecode) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (final PrintWriter pw = new PrintWriter(baos)) {
        final NashornClassReader cr = new NashornClassReader(bytecode);
        final Context ctx = AccessController.doPrivileged(new PrivilegedAction<Context>() {
            @Override
            public Context run() {
                return Context.getContext();
            }
        });
        final TraceClassVisitor tcv = new TraceClassVisitor(null, new NashornTextifier(ctx.getEnv(), cr), pw);
        cr.accept(tcv, 0);
    }

    final String str = new String(baos.toByteArray());
    return str;
}