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

The following examples show how to use jdk.internal.org.objectweb.asm.util.TraceClassVisitor. 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;
}
 
Example #8
Source File: ASMToolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void logASM(String className, byte[] bytes) {
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Generated bytecode for class " + className);
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.TRACE, () -> {
        ClassReader cr = new ClassReader(bytes);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintWriter w = new PrintWriter(baos);
        w.println("Bytecode:");
        cr.accept(new TraceClassVisitor(w), 0);
        return baos.toString();
    });
}
 
Example #9
Source File: ASMToolkit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void logASM(String className, byte[] bytes) {
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Generated bytecode for class " + className);
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.TRACE, () -> {
        ClassReader cr = new ClassReader(bytes);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintWriter w = new PrintWriter(baos);
        w.println("Bytecode:");
        cr.accept(new TraceClassVisitor(w), 0);
        return baos.toString();
    });
}
 
Example #10
Source File: ASMToolkit.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void logASM(String className, byte[] bytes) {
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Generated bytecode for class " + className);
    Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.TRACE, () -> {
        ClassReader cr = new ClassReader(bytes);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintWriter w = new PrintWriter(baos);
        w.println("Bytecode:");
        cr.accept(new TraceClassVisitor(w), 0);
        return baos.toString();
    });
}
 
Example #11
Source File: ClassEmitter.java    From openjdk-8-source with GNU General Public License v2.0 5 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)) {
        new ClassReader(bytecode).accept(new TraceClassVisitor(pw), 0);
    }
    return new String(baos.toByteArray());
}
 
Example #12
Source File: ClassEmitter.java    From openjdk-8 with GNU General Public License v2.0 5 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)) {
        new ClassReader(bytecode).accept(new TraceClassVisitor(pw), 0);
    }
    return new String(baos.toByteArray());
}
 
Example #13
Source File: ClassEmitter.java    From nashorn with GNU General Public License v2.0 5 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)) {
        new ClassReader(bytecode).accept(new TraceClassVisitor(pw), 0);
    }
    return new String(baos.toByteArray());
}
 
Example #14
Source File: AddressVarHandleGenerator.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static String debugPrintClass(byte[] classFile) {
    ClassReader cr = new ClassReader(classFile);
    StringWriter sw = new StringWriter();
    cr.accept(new TraceClassVisitor(new PrintWriter(sw)), 0);
    return sw.toString();
}