Package org.ow2.asm

Examples of org.ow2.asm.ClassWriter.toByteArray()


        deadCode(cw);

        cw.visitEnd();

        return cw.toByteArray();
    }

    private void uninitializedThisType(final ClassWriter cw) {
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC,
                "<init>",
View Full Code Here


                                signature,
                                exceptions));
            }

        }, ClassReader.EXPAND_FRAMES);
        return cw.toByteArray();
    }

    public static TestSuite suite() throws Exception {
        return new LocalVariablesSorterTest2().getSuite();
    }
View Full Code Here

        mv.visitMaxs(0, 0);
        mv.visitAttribute(new CodeComment());
        mv.visitEnd();

        cw.visitEnd();
        return cw.toByteArray();
    }
}
View Full Code Here

        mv.visitMaxs(0, 0);
        mv.visitEnd();

        cw.visitEnd();

        return cw.toByteArray();
    }
}
View Full Code Here

        ClassReader cr = new ClassReader(is);
        if (cr.readInt(4) != Opcodes.V1_6) {
            try {
                ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
                cr.accept(cw, 0);
                cr = new ClassReader(cw.toByteArray());
            } catch (Exception e) {
                skipTest();
                return;
            }
        }
View Full Code Here

                        desc,
                        signature,
                        exceptions);
            }
        }, 0);
        byte[] b = cw.toByteArray();
        try {
            LOADER.defineClass(n, b);
        } catch (ClassFormatError cfe) {
            fail(cfe.getMessage());
        } catch (Throwable ignored) {
View Full Code Here

        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        cv.visitEnd();

        Class<?> c = LOADER.defineClass("A", cw.toByteArray());
        assertEquals(c.getField("counter").getInt(c.newInstance()), 5);
    }

    // ------------------------------------------------------------------------
View Full Code Here

                    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
                    ClassReader cr = new ClassReader(getClass().getResourceAsStream("/"
                            + name.replace('.', '/') + ".class"));
                    cr.accept(new AdviceClassAdapter(cw),
                            ClassReader.EXPAND_FRAMES);
                    byte[] bytecode = cw.toByteArray();
                    return super.defineClass(name, bytecode, 0, bytecode.length);
                } catch (IOException ex) {
                    throw new ClassNotFoundException("Load error: "
                            + ex.toString(), ex);
                }
View Full Code Here

        ClassReader cr = new ClassReader(is);
        ClassWriter cw = new ClassWriter(0);
        ClassVisitor cv = new TraceClassVisitor(cw,
                new PrintWriter(new CharArrayWriter()));
        cr.accept(cv, new Attribute[] { new Comment(), new CodeComment() }, 0);
        assertEquals(cr, new ClassReader(cw.toByteArray()));
    }
}
View Full Code Here

        nativeMethod(cw);
        clinitMethod(cw);

        cw.visitEnd();

        return cw.toByteArray();
    }

    private void constInsns(final ClassWriter cw) {
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC,
                "constInsns",
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.