Package org.objectweb.asm.util

Examples of org.objectweb.asm.util.CheckClassAdapter


public class AddAnnotationTransformerTest extends
    AddAnnotationAdapterTest {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    ClassNode cn = generateBasicClass();
    new AddAnnotationTransformer(null, "Ljava/lang/Deprecated;")
        .transform(cn);
    cn.accept(ca);
    checkClass(defineClass("C", cw.toByteArray()));
View Full Code Here


  }

  static byte[] make_tuple_class_data(int num_cells) {
    ClassWriter cww = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);

    CheckClassAdapter cw = new CheckClassAdapter(cww);

    String this_class_name = ETUPLE_NAME + num_cells;
    String super_class_name = ETUPLE_NAME;
    cw.visit(Opcodes.V1_4, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER,
        this_class_name, null, super_class_name, null);

    // create fields

    for (int i = 1; i <= num_cells; i++) {
      cw.visitField(Opcodes.ACC_PUBLIC, "elem" + i, ETERM_TYPE
          .getDescriptor(), null, null);
    }

    // create count method
    create_count(cw, num_cells);

    // create cast method
    create_cast(cw, num_cells);
    create_cast2(cw, num_cells);

    // create constructor
    create_constructor(cw, super_class_name);

    // create copy
    create_tuple_copy(num_cells, cw, this_class_name, super_class_name);

    create_tuple_make(num_cells, cw, this_class_name, super_class_name);
    create_tuple_make2(num_cells, cw, this_class_name, super_class_name);
    // create nth
    create_tuple_nth(num_cells, cw, this_class_name);

    // create set
    create_tuple_set(num_cells, cw, this_class_name);

    cw.visitEnd();
    byte[] data = cww.toByteArray();

    // dump(this_class_name, data);

    return data;
View Full Code Here

        if (!m_alreadyManipulated) {
            InputStream is2 = new ByteArrayInputStream(origin);
            ClassReader reader = new ClassReader(is2);
            ClassWriter writer = new ClassLoaderAwareClassWriter(ClassWriter.COMPUTE_FRAMES, m_className, m_superClass,
                    m_classLoader);
            ClassManipulator process = new ClassManipulator(new CheckClassAdapter(writer, false), this);
            if (m_version >= Opcodes.V1_6) {
                reader.accept(process, ClassReader.EXPAND_FRAMES);
            } else {
                reader.accept(process, 0);
            }
View Full Code Here

        ClassNode ca = new ClassNode() {
            public void visitEnd() {
                //accept(cv);
            }
        };
        cr.accept(new CheckClassAdapter(ca), ClassWriter.COMPUTE_MAXS);
        boolean failed = false;

        List methods = ca.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = (MethodNode) methods.get(i);
View Full Code Here

*/
public final class Debugs {

  public static void debugByteCode(ClassDefinition classDefinition, PrintWriter writer) {
    ClassReader reader = new ClassReader(classDefinition.getBytecode());
    reader.accept(new CheckClassAdapter(new TraceClassVisitor(writer)), 0);

    File file = new File("/tmp/" + classDefinition.getInternalName() + ".class");
    file.getParentFile().mkdirs();
    writer.println(file);
    writer.flush();
View Full Code Here

        ClassNode ca = new ClassNode() {
            public void visitEnd() {
                //accept(cv);
            }
        };
        cr.accept(new CheckClassAdapter(ca), true);
        boolean failed = false;

        List methods = ca.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = (MethodNode) methods.get(i);
View Full Code Here

    }

    @SuppressWarnings("unchecked")
  public Class<T> generate() {
      ClassWriter out = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      CheckClassAdapter writer = new CheckClassAdapter(out);
     
    int offset = 0;
      declareClass(writer);
      declareConstructor(writer);
      for (Method getter : inspector.getters) {
        offset = declareField(getter, writer, offset);
      }
     
      writer.visitEnd();
     
        return (Class<T>) new GeneratedClassLoader(options).defineClass(implementationName, out);
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
  public Class<I> generate() {
      ClassWriter out = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      CheckClassAdapter writer = new CheckClassAdapter(out);
    declareClass(writer);
      declareConstructor(writer);
        declareAccessors(writer);
        customisation.customise(writer);
        return finish(out);
View Full Code Here

*/
public final class Debugs {

  public static void debugByteCode(ClassDefinition classDefinition, PrintWriter writer) {
    ClassReader reader = new ClassReader(classDefinition.getBytecode());
    reader.accept(new CheckClassAdapter(new TraceClassVisitor(writer)), 0);

    File file = new File("/tmp/" + classDefinition.getInternalName() + ".class");
    file.getParentFile().mkdirs();
    writer.println(file);
    writer.flush();
View Full Code Here

       
        ClassReader cr = new ClassReader(bytecode);
               
        ClassNode classNode = new ClassNode();
        final int flags = 0// Don't skip anything.
        cr.accept(new CheckClassAdapter(classNode), flags);
       
        List<?> methods = classNode.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = (MethodNode)methods.get(i);
            if (method.instructions.size() > 0) {
View Full Code Here

TOP

Related Classes of org.objectweb.asm.util.CheckClassAdapter

Copyright © 2018 www.massapicom. 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.