Package org.objectweb.asm

Examples of org.objectweb.asm.ClassWriter


* @author Eric Bruneton
*/
public class AddMethodTransformerTest extends AddMethodAdapterTest {

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


* @author Eric Bruneton
*/
public class RemoveFieldTransformerTest extends RemoveFieldAdapterTest {

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

* @author Eric Bruneton
*/
public class AddFieldTransformerTest extends AddFieldAdapterTest {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    ClassNode cn = generateBasicClass();
    new AddFieldTransformer(null, ACC_PUBLIC, "field", "I")
        .transform(cn);
    cn.accept(ca);
    checkClass(defineClass("C", cw.toByteArray()));
  }
View Full Code Here

*/
public class RemoveMethodTransformerTest extends
    RemoveMethodAdapterTest {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    ClassNode cn = generateBasicClass();
    new RemoveMethodTransformer(null, "m", "()V").transform(cn);
    cn.accept(ca);
    checkClass(defineClass("C", cw.toByteArray()));
  }
View Full Code Here

* @author Eric Bruneton
*/
public class AddFieldAdapterTest extends AbstractTestCase {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    AddFieldAdapter af = new AddFieldAdapter(ca, ACC_PUBLIC, "field",
        "I");
    generateBasicClass(af);
    checkClass(defineClass("C", cw.toByteArray()));
  }
View Full Code Here

* @author Eric Bruneton
*/
public class RemoveFieldAdapterTest extends AbstractTestCase {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    RemoveFieldAdapter af = new RemoveFieldAdapter(ca, "f");
    generateBasicClass(af);
    checkClass(defineClass("C", cw.toByteArray()));
  }
View Full Code Here

* @author Eric Bruneton
*/
public class RemoveDebugAdapterTest extends AbstractTestCase {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    RemoveDebugAdapter rd = new RemoveDebugAdapter(ca);
    generateBasicClass(rd);
    defineClass("C", cw.toByteArray());
  }
View Full Code Here

* @author Eric Bruneton
*/
public class AddMethodAdapterTest extends AbstractTestCase {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    AddMethodAdapter am = new AddMethodAdapter(ca);
    generateBasicClass(am);
    checkClass(defineClass("C", cw.toByteArray()));
  }
View Full Code Here

          n = n.substring(0, n.length() - 6).replace('/', '.');
          InputStream is = zip.getInputStream(e);
          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 (Throwable ignored) {
              continue;
            }
          }
          ClassWriter cw = new ClassWriter(0);
          ClassVisitor cv = getClassAdapter(cw);
          try {
            cr.accept(cv, ClassReader.EXPAND_FRAMES);
          } catch (UnsatisfiedLinkError ignored) {
          } catch (NoClassDefFoundError ignored) {
          }
          byte[] b = cw.toByteArray();
          try {
            new TestClassLoader().defineClass(n, b);
          } catch (ClassFormatError cfe) {
            cfe.printStackTrace();
            fail();
View Full Code Here

* @author Eric Bruneton
*/
public class RemoveMethodAdapterTest extends AbstractTestCase {

  public void test() throws Exception {
    ClassWriter cw = new ClassWriter(0);
    CheckClassAdapter ca = new CheckClassAdapter(cw);
    RemoveMethodAdapter af = new RemoveMethodAdapter(ca, "m", "()V");
    generateBasicClass(af);
    checkClass(defineClass("C", cw.toByteArray()));
  }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.ClassWriter

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.