Examples of ClassWriter


Examples of com.ponysdk.generator.ClassWriter

    public ProxyBuilderGenerator(final List<Root> domains) {
        this.domains = domains;
    }

    public void generate() throws Exception {
        final ClassWriter classWriter = new ClassWriter(this, getSrcGeneratedDirectory(), getPackageName(), "ProxyBuilder");
        classWriter.addImplements(ApplicationContextAware.class);
        classWriter.addNewLine();
        classWriter.addLine("private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ProxyBuilder.class);");

        classWriter.addLine("@Override");
        classWriter.addLine("public void setApplicationContext(" + ApplicationContext.class.getCanonicalName() + " context) throws " + BeansException.class.getCanonicalName() + " {");
        classWriter.addNewLine();

        for (final Root root : domains) {
            this.domain = root.getDomain();
            classWriter.addLine("try{");
            classWriter.indentBlock();
            classWriter.addLine("com.ponysdk.core.service.PonyServiceRegistry.registerPonyService(context.getBean(" + GeneratorHelper.getServiceFullClassName(domain) + ".class));");
            classWriter.unindentBlock();
            classWriter.addLine("}catch(org.springframework.beans.factory.NoSuchBeanDefinitionException e){");
            classWriter.indentBlock();
            classWriter.addLine("log.warn(\"No service defined for " + domain.getName() + "\");");
            classWriter.unindentBlock();
            classWriter.addLine("}");
            classWriter.addLine("catch(Exception e){");
            classWriter.indentBlock();
            classWriter.addLine("String errorMessage = \"Error when starting service " + domain.getName() + "\";");
            classWriter.addLine("log.error(errorMessage, e);");
            classWriter.addLine("throw new " + RuntimeException.class.getCanonicalName() + "(errorMessage, e);");

            classWriter.unindentBlock();
            classWriter.addLine("}");
        }
        classWriter.addLine("}");

        classWriter.generateContentAndStore();
    }
View Full Code Here

Examples of com.sleepycat.asm.ClassWriter

        /*
         * The writer is at the end of the visitor chain.  Pass true to
         * calculate stack size, for safety.
         */
        ClassWriter writer = new ClassWriter(true);
        ClassVisitor visitor = writer;

        /* The enhancer is at the beginning of the visitor chain. */
        visitor = new BytecodeEnhancer(visitor);

        /* The reader processes the class and invokes the visitors. */
        ClassReader reader = new ClassReader(bytes);
        try {

            /*
             * Pass false for skipDebug since we are rewriting the class and
             * should include all information.
             */
            reader.accept(visitor, false);
            return writer.toByteArray();
        } catch (BytecodeEnhancer.NotPersistentException e) {
            /* The class is not persistent and should not be enhanced. */
            return null;
        }
    }
View Full Code Here

Examples of com.sun.tools.javac.jvm.ClassWriter

        // options = options.prepend("-verbose");
        JavacTaskImpl task = (JavacTaskImpl)
            tool.getTask(null, fm, null, options, null, null);
        com.sun.tools.javac.main.JavaCompiler compiler =
            com.sun.tools.javac.main.JavaCompiler.instance(task.getContext());
        ClassWriter writer = ClassWriter.instance(task.getContext());
        Symtab syms = Symtab.instance(task.getContext());
        Names names = Names.instance(task.getContext());
        Attribute.Compound proprietaryAnno =
            new Attribute.Compound(syms.proprietaryType,
                                   List.<Pair<Symbol.MethodSymbol,Attribute>>nil());
View Full Code Here

Examples of groovyjarjarasm.asm.ClassWriter

                    // the class.  This makes it possible for a debugger to find the source file for the class.  By default
                    // Groovy will only put the filename into the class, but that does not help a debugger for Gradle
                    // because it does not know where Gradle scripts might live.
                    @Override
                    protected groovyjarjarasm.asm.ClassVisitor createClassVisitor() {
                        return new ClassWriter(ClassWriter.COMPUTE_MAXS) {
                            // ignore the sourcePath that is given by Groovy (this is only the filename) and instead
                            // insert the full path if our script source has a source file
                            @Override
                            public void visitSource(String sourcePath, String debugInfo) {
                                super.visitSource(source.getFileName(), debugInfo);
View Full Code Here

Examples of jdk.internal.org.objectweb.asm.ClassWriter

         *
         * @param types the type signature, wherein reference types are erased to 'L'
         * @return the generated concrete BMH class
         */
        static Class<? extends BoundMethodHandle> generateConcreteBMHClass(String types) {
            final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);

            final String className  = SPECIES_PREFIX_PATH + types;
            final String sourceFile = SPECIES_PREFIX_NAME + types;
            final int NOT_ACC_PUBLIC = 0// not ACC_PUBLIC
            cw.visit(V1_6, NOT_ACC_PUBLIC + ACC_FINAL + ACC_SUPER, className, null, BMH, null);
            cw.visitSource(sourceFile, null);

            // emit static types and SPECIES_DATA fields
            cw.visitField(NOT_ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null).visitEnd();

            // emit bound argument fields
            for (int i = 0; i < types.length(); ++i) {
                final char t = types.charAt(i);
                final String fieldName = makeFieldName(types, i);
                final String fieldDesc = t == 'L' ? JLO_SIG : String.valueOf(t);
                cw.visitField(ACC_FINAL, fieldName, fieldDesc, null, null).visitEnd();
            }

            MethodVisitor mv;

            // emit constructor
            mv = cw.visitMethod(NOT_ACC_PUBLIC, "<init>", makeSignature(types, true), null, null);
            mv.visitCode();
            mv.visitVarInsn(ALOAD, 0);
            mv.visitVarInsn(ALOAD, 1);
            mv.visitVarInsn(ALOAD, 2);

            mv.visitMethodInsn(INVOKESPECIAL, BMH, "<init>", makeSignature("", true));

            for (int i = 0, j = 0; i < types.length(); ++i, ++j) {
                // i counts the arguments, j counts corresponding argument slots
                char t = types.charAt(i);
                mv.visitVarInsn(ALOAD, 0);
                mv.visitVarInsn(typeLoadOp(t), j + 3); // parameters start at 3
                mv.visitFieldInsn(PUTFIELD, className, makeFieldName(types, i), typeSig(t));
                if (t == 'J' || t == 'D') {
                    ++j; // adjust argument register access
                }
            }

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

            // emit implementation of reinvokerTarget()
            mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "reinvokerTarget", "()" + MH_SIG, null, null);
            mv.visitCode();
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, className, "argL0", JLO_SIG);
            mv.visitTypeInsn(CHECKCAST, MH);
            mv.visitInsn(ARETURN);
            mv.visitMaxs(0, 0);
            mv.visitEnd();

            // emit implementation of speciesData()
            mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "speciesData", MYSPECIES_DATA_SIG, null, null);
            mv.visitCode();
            mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
            mv.visitInsn(ARETURN);
            mv.visitMaxs(0, 0);
            mv.visitEnd();

            // emit clone()
            mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "clone", makeSignature("", false), null, E_THROWABLE);
            mv.visitCode();
            // return speciesData().constructor[0].invokeBasic(mt, lf, argL0, ...)
            // obtain constructor
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
            mv.visitFieldInsn(GETFIELD, SPECIES_DATA, "constructor", "[" + MH_SIG);
            mv.visitInsn(ICONST_0);
            mv.visitInsn(AALOAD);
            // load mt, lf
            mv.visitVarInsn(ALOAD, 1);
            mv.visitVarInsn(ALOAD, 2);
            // put fields on the stack
            emitPushFields(types, className, mv);
            // finally, invoke the constructor and return
            mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types, false));
            mv.visitInsn(ARETURN);
            mv.visitMaxs(0, 0);
            mv.visitEnd();

            // for each type, emit cloneExtendT()
            for (Class<?> c : TYPES) {
                char t = Wrapper.basicTypeChar(c);
                mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "cloneExtend" + t, makeSignature(String.valueOf(t), false), null, E_THROWABLE);
                mv.visitCode();
                // return SPECIES_DATA.extendWithIndex(extensionIndex(t)).constructor[0].invokeBasic(mt, lf, argL0, ..., narg)
                // obtain constructor
                mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
                int iconstInsn = ICONST_0 + extensionIndex(t);
                assert(iconstInsn <= ICONST_5);
                mv.visitInsn(iconstInsn);
                mv.visitMethodInsn(INVOKEVIRTUAL, SPECIES_DATA, "extendWithIndex", BMHSPECIES_DATA_EWI_SIG);
                mv.visitFieldInsn(GETFIELD, SPECIES_DATA, "constructor", "[" + MH_SIG);
                mv.visitInsn(ICONST_0);
                mv.visitInsn(AALOAD);
                // load mt, lf
                mv.visitVarInsn(ALOAD, 1);
                mv.visitVarInsn(ALOAD, 2);
                // put fields on the stack
                emitPushFields(types, className, mv);
                // put narg on stack
                mv.visitVarInsn(typeLoadOp(t), 3);
                // finally, invoke the constructor and return
                mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types + t, false));
                mv.visitInsn(ARETURN);
                mv.visitMaxs(0, 0);
                mv.visitEnd();
            }

            // emit class initializer
            mv = cw.visitMethod(NOT_ACC_PUBLIC | ACC_STATIC, "<clinit>", VOID_SIG, null, null);
            mv.visitCode();
            mv.visitLdcInsn(types);
            mv.visitLdcInsn(Type.getObjectType(className));
            mv.visitMethodInsn(INVOKESTATIC, SPECIES_DATA, "getForClass", BMHSPECIES_DATA_GFC_SIG);
            mv.visitFieldInsn(PUTSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
            mv.visitInsn(RETURN);
            mv.visitMaxs(0, 0);
            mv.visitEnd();

            cw.visitEnd();

            // load class
            final byte[] classFile = cw.toByteArray();
            InvokerBytecodeGenerator.maybeDump(className, classFile);
            Class<? extends BoundMethodHandle> bmhClass =
                //UNSAFE.defineAnonymousClass(BoundMethodHandle.class, classFile, null).asSubclass(BoundMethodHandle.class);
                UNSAFE.defineClass(className, classFile, 0, classFile.length,
                                   BoundMethodHandle.class.getClassLoader(), null)
View Full Code Here

Examples of jodd.asm5.ClassWriter

    // reads information
    TargetClassInfoReader targetClassInfoReader = new TargetClassInfoReader();
    classReader.accept(targetClassInfoReader, 0);

    this.destClassWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);

    // create proxy
    if (log.isDebugEnabled()) {
      log.debug("processing: " + classReader.getClassName());
    }
View Full Code Here

Examples of net.sf.cglib.asm.ClassWriter

     * generating the bytecode. Defining the class from the byte code must be the responsibility of the
     * caller of this method, since it requires a ClassLoader to be created to define and load this interface.
     */
    protected byte[] generateRemoteInterface(Class serviceInterface) {
        String interfazeName = serviceInterface.getName();
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);

        String simpleName = serviceInterface.getSimpleName();
        cw.visit(Constants.V1_5, Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE, interfazeName
            .replace('.', '/'), null, "java/lang/Object", new String[] {"java/rmi/Remote"});

        StringBuffer argsAndReturn = null;
        Method[] methods = serviceInterface.getMethods();
        for (Method method : methods) {
            argsAndReturn = new StringBuffer("(");
            Class[] paramTypes = method.getParameterTypes();
            Class returnType = method.getReturnType();

            for (Class paramType : paramTypes) {
                argsAndReturn.append(Type.getType(paramType));
            }
            argsAndReturn.append(")");
            argsAndReturn.append(Type.getType(returnType));

            cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT,
                           method.getName(),
                           argsAndReturn.toString(),
                           null,
                           new String[] {"java/rmi/RemoteException"});
        }
        cw.visitEnd();
        return cw.toByteArray();
    }
View Full Code Here

Examples of net.sf.joafip.asm.ClassWriter

@SuppressWarnings("PMD")
public class ObjectDump implements Opcodes {

  public static byte[] dump() throws Exception {

    ClassWriter cw = new ClassWriter(0);
    FieldVisitor fv;
    MethodVisitor mv;
    @SuppressWarnings("unused")
    AnnotationVisitor av0;

    cw.visit(
        V1_5,
        ACC_PUBLIC + ACC_SUPER,
        "java/lang/Object",
        null,
        null,
        new String[] { "net/sf/joafip/store/service/proxy/IProxyCallBack" });

    {
      fv = cw.visitField(
          ACC_PRIVATE + ACC_TRANSIENT,
          "proxyCallBack",
          "Lnet/sf/joafip/store/service/proxy/IProxyCallBackToImplement;",
          null, null);
      fv.visitEnd();
    }
    {
      fv = cw.visitField(ACC_PRIVATE + ACC_TRANSIENT,
          "setProxyCallBackTrace", "Ljava/lang/Exception;", null,
          null);
      fv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
      mv.visitCode();
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 1);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC + ACC_NATIVE,
          "registerNatives", "()V", null, null);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_NATIVE,
          "getClass", "()Ljava/lang/Class;",
          "()Ljava/lang/Class<*>;", null);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_NATIVE, "hashCode", "()I",
          null, null);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z",
          null, null);
      mv.visitCode();
      mv.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 0, new Object[] {});
      mv.visitVarInsn(ALOAD, 0);
      mv.visitVarInsn(ALOAD, 1);
      Label l0 = new Label();
      mv.visitJumpInsn(IF_ACMPNE, l0);
      mv.visitInsn(ICONST_1);
      Label l1 = new Label();
      mv.visitJumpInsn(GOTO, l1);
      mv.visitLabel(l0);
      mv.visitFrame(Opcodes.F_NEW, 2, new Object[] { "java/lang/Object",
          "java/lang/Object" }, 0, new Object[] {});
      mv.visitInsn(ICONST_0);
      mv.visitLabel(l1);
      mv.visitFrame(Opcodes.F_NEW, 2, new Object[] { "java/lang/Object",
          "java/lang/Object" }, 1, new Object[] { Opcodes.INTEGER });
      mv.visitInsn(IRETURN);
      mv.visitMaxs(2, 2);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PROTECTED + ACC_NATIVE, "clone",
          "()Ljava/lang/Object;", null,
          new String[] { "java/lang/CloneNotSupportedException" });
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;",
          null, null);
      mv.visitCode();
      mv.visitTypeInsn(NEW, "java/lang/StringBuilder");
      mv.visitInsn(DUP);
      mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder",
          "<init>", "()V");
      mv.visitVarInsn(ALOAD, 0);
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass",
          "()Ljava/lang/Class;");
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getName",
          "()Ljava/lang/String;");
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder",
          "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;");
      mv.visitLdcInsn("@");
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder",
          "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;");
      mv.visitVarInsn(ALOAD, 0);
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "hashCode",
          "()I");
      mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer",
          "toHexString", "(I)Ljava/lang/String;");
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder",
          "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;");
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder",
          "toString", "()Ljava/lang/String;");
      mv.visitInsn(ARETURN);
      mv.visitMaxs(2, 1);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_NATIVE, "notify",
          "()V", null, null);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_NATIVE,
          "notifyAll", "()V", null, null);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_NATIVE, "wait",
          "(J)V", null,
          new String[] { "java/lang/InterruptedException" });
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "wait", "(JI)V", null,
          new String[] { "java/lang/InterruptedException" });
      mv.visitCode();
      mv.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 0, new Object[] {});
      mv.visitVarInsn(LLOAD, 1);
      mv.visitInsn(LCONST_0);
      mv.visitInsn(LCMP);
      Label l0 = new Label();
      mv.visitJumpInsn(IFGE, l0);
      mv.visitTypeInsn(NEW, "java/lang/IllegalArgumentException");
      mv.visitInsn(DUP);
      mv.visitLdcInsn("timeout value is negative");
      mv.visitMethodInsn(INVOKESPECIAL,
          "java/lang/IllegalArgumentException", "<init>",
          "(Ljava/lang/String;)V");
      mv.visitInsn(ATHROW);
      mv.visitLabel(l0);
      mv.visitFrame(Opcodes.F_NEW, 3, new Object[] { "java/lang/Object",
          Opcodes.LONG, Opcodes.INTEGER }, 0, new Object[] {});
      mv.visitVarInsn(ILOAD, 3);
      Label l1 = new Label();
      mv.visitJumpInsn(IFLT, l1);
      mv.visitVarInsn(ILOAD, 3);
      mv.visitLdcInsn(new Integer(999999));
      Label l2 = new Label();
      mv.visitJumpInsn(IF_ICMPLE, l2);
      mv.visitLabel(l1);
      mv.visitFrame(Opcodes.F_NEW, 3, new Object[] { "java/lang/Object",
          Opcodes.LONG, Opcodes.INTEGER }, 0, new Object[] {});
      mv.visitTypeInsn(NEW, "java/lang/IllegalArgumentException");
      mv.visitInsn(DUP);
      mv.visitLdcInsn("nanosecond timeout value out of range");
      mv.visitMethodInsn(INVOKESPECIAL,
          "java/lang/IllegalArgumentException", "<init>",
          "(Ljava/lang/String;)V");
      mv.visitInsn(ATHROW);
      mv.visitLabel(l2);
      mv.visitFrame(Opcodes.F_NEW, 3, new Object[] { "java/lang/Object",
          Opcodes.LONG, Opcodes.INTEGER }, 0, new Object[] {});
      mv.visitVarInsn(ILOAD, 3);
      mv.visitLdcInsn(new Integer(500000));
      Label l3 = new Label();
      mv.visitJumpInsn(IF_ICMPGE, l3);
      mv.visitVarInsn(ILOAD, 3);
      Label l4 = new Label();
      mv.visitJumpInsn(IFEQ, l4);
      mv.visitVarInsn(LLOAD, 1);
      mv.visitInsn(LCONST_0);
      mv.visitInsn(LCMP);
      mv.visitJumpInsn(IFNE, l4);
      mv.visitLabel(l3);
      mv.visitFrame(Opcodes.F_NEW, 3, new Object[] { "java/lang/Object",
          Opcodes.LONG, Opcodes.INTEGER }, 0, new Object[] {});
      mv.visitVarInsn(LLOAD, 1);
      mv.visitInsn(LCONST_1);
      mv.visitInsn(LADD);
      mv.visitVarInsn(LSTORE, 1);
      mv.visitLabel(l4);
      mv.visitFrame(Opcodes.F_NEW, 3, new Object[] { "java/lang/Object",
          Opcodes.LONG, Opcodes.INTEGER }, 0, new Object[] {});
      mv.visitVarInsn(ALOAD, 0);
      mv.visitVarInsn(LLOAD, 1);
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "wait",
          "(J)V");
      mv.visitInsn(RETURN);
      mv.visitMaxs(4, 4);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "wait", "()V", null,
          new String[] { "java/lang/InterruptedException" });
      mv.visitCode();
      mv.visitVarInsn(ALOAD, 0);
      mv.visitInsn(LCONST_0);
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "wait",
          "(J)V");
      mv.visitInsn(RETURN);
      mv.visitMaxs(3, 1);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PROTECTED, "finalize", "()V", null,
          new String[] { "java/lang/Throwable" });
      mv.visitCode();
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 1);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
      mv.visitCode();
      mv.visitMethodInsn(INVOKESTATIC, "java/lang/Object",
          "registerNatives", "()V");
      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 0);
      mv.visitEnd();
    }
    {
      mv = cw.visitMethod(ACC_PRIVATE, "forceLoad$JOAFIP$",
          "(Ljava/lang/Object;)V", null, null);
      mv.visitCode();
      Label l0 = new Label();
      Label l1 = new Label();
      Label l2 = new Label();
      mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception");
      mv.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 0, new Object[] {});
      mv.visitVarInsn(ALOAD, 1);
      mv.visitVarInsn(ALOAD, 0);
      Label l3 = new Label();
      mv.visitJumpInsn(IF_ACMPEQ, l3);
      mv.visitLabel(l0);
      mv.visitVarInsn(ALOAD, 1);
      mv.visitMethodInsn(INVOKESTATIC,
          "net/sf/joafip/store/service/proxy/ProxyManager2",
          "forceLoad", "(Ljava/lang/Object;)V");
      mv.visitLabel(l1);
      mv.visitJumpInsn(GOTO, l3);
      mv.visitLabel(l2);
      mv.visitFrame(Opcodes.F_NEW, 2, new Object[] { "java/lang/Object",
          "java/lang/Object" }, 1,
          new Object[] { "java/lang/Exception" });
      mv.visitVarInsn(ASTORE, 2);
      mv.visitTypeInsn(NEW,
          "net/sf/joafip/store/service/proxy/JoafipObjectException");
      mv.visitInsn(DUP);
      mv.visitVarInsn(ALOAD, 2);
      mv.visitMethodInsn(INVOKESPECIAL,
          "net/sf/joafip/store/service/proxy/JoafipObjectException",
          "<init>", "(Ljava/lang/Throwable;)V");
      mv.visitInsn(ATHROW);
      mv.visitLabel(l3);
      mv.visitFrame(Opcodes.F_NEW, 2, new Object[] { "java/lang/Object",
          "java/lang/Object" }, 0, new Object[] {});
      mv.visitInsn(RETURN);
      mv.visitMaxs(3, 3);
      mv.visitEnd();
    }
    cw.visitEnd();

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

Examples of nginx.clojure.asm.ClassWriter

   
    }

    static byte[] instrumentClass(MethodDatabase db, byte[] data, boolean check) {
        ClassReader r = new ClassReader(data);
        ClassWriter cw = new DBClassWriter(db, r);
        ClassVisitor cv = check ? new CheckClassAdapter(cw) : cw;
        ClassEntry ce = MethodDatabaseUtil.buildClassEntryFamily(db, r);
        if(db.shouldIgnore(r.getClassName())) {
            return null;
        }
        db.trace("TRANSFORM: %s", r.getClassName());
        InstrumentClass ic = new InstrumentClass(r.getClassName(), ce, cv, db, false);
        r.accept(ic, ClassReader.SKIP_FRAMES);
        return cw.toByteArray();
    }
View Full Code Here

Examples of oracle.toplink.libraries.asm.ClassWriter

    }
   
    public final void begin( String name, Attributes attrs) {
      int major = Integer.parseInt( attrs.getValue( "major"));
      int minor = Integer.parseInt( attrs.getValue( "minor"));
      cw = new ClassWriter( computeMax);
      Map vals = new HashMap();
      vals.put( "version", new Integer(minor << 16 | major));
      vals.put( "access", attrs.getValue( "access"));
      vals.put( "name", attrs.getValue( "name"));
      vals.put( "parent", attrs.getValue( "parent"));
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.