Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.ClassGen.addMethod()


                org.apache.bcel.generic.Type.VOID,
                new org.apache.bcel.generic.Type[] { org.apache.bcel.generic.Type.STRING },
                Constants.INVOKESPECIAL));

        mg.setMaxStack();
        cg.addMethod(mg.getMethod());

        return cg.getJavaClass().getBytes();
    }

    static org.aspectj.apache.bcel.generic.Type printStreamAT = org.aspectj.apache.bcel.generic.Type.getType("Ljava/io/PrintStream;");
View Full Code Here


           Constants.INVOKEVIRTUAL));

    il.append(InstructionConstants.RETURN);

    mg.setMaxStack(5); // Needed stack size
    cg.addMethod(mg.getMethod());

    il.dispose(); // Reuse instruction handles

    /* Add public <init> method, i.e. empty constructor
     */
 
View Full Code Here

      il.append(InstructionConstants.RETURN);

      mg.stripAttributes(true);
      mg.setMaxStack();
      mg.setMaxLocals();
      cg.addMethod(mg.getMethod());

      byte[] bytes = cg.getJavaClass().getBytes();

      System.out.println("Uncompressed class: " + bytes.length);
View Full Code Here

                                       "<generated-on-the-fly>", // File name
                                       Constants.ACC_PUBLIC | Constants.ACC_FINAL | Constants.ACC_SUPER, // Modifiers
                                       null); // Implemented interfaces

      classGen.addEmptyConstructor(Constants.ACC_PUBLIC);
      classGen.addMethod(createInvokeImpl(metadata, classGen, name));

      // For debug purposes only
//    dump(classGen);

      final byte[] bytes = classGen.getJavaClass().getBytes();
View Full Code Here

                                                                       constantPoolGen);

        org.apache.bcel.classfile.Method getterMethod =
            constructGetterMethod(newClassName, constantPoolGen,
                                  instructionFactory, field);
        classGen.addMethod(getterMethod);

        org.apache.bcel.classfile.Method setterMethod =
            constructSetterMethod(newClassName, constantPoolGen,
                                  instructionFactory, field);
        classGen.addMethod(setterMethod);
View Full Code Here

        classGen.addMethod(getterMethod);

        org.apache.bcel.classfile.Method setterMethod =
            constructSetterMethod(newClassName, constantPoolGen,
                                  instructionFactory, field);
        classGen.addMethod(setterMethod);

        return generateClassAndGetInstance(classGen, newClassName,
                                           field.getDeclaringClass().getProtectionDomain());
    }
View Full Code Here

        else {
            accessorMethod =
                constructGetterMethod(newClassName, constantPoolGen,
                                      instructionFactory, method);
        }
        classGen.addMethod(accessorMethod);

        return generateClassAndGetInstance(classGen, newClassName,
                                           method.getDeclaringClass().getProtectionDomain());
    }
View Full Code Here

        cg.setMethods(methods);

        // add the new methods
        for (Iterator it = newMethods.iterator(); it.hasNext();) {
            Method method = (Method)it.next();
            cg.addMethod(method);
        }
    }

    /**
     * Creates a static class field.
View Full Code Here

        cg.setMethods(methods);

        // add the new methods
        for (Iterator it = newMethods.iterator(); it.hasNext();) {
            Method method = (Method)it.next();
            cg.addMethod(method);
        }
    }

    /**
     * Creates a static class field.
View Full Code Here

        cg.setMethods(methods);

        // add the proxy methods
        for (Iterator it = proxyMethods.iterator(); it.hasNext();) {
            Method method = (Method)it.next();
            cg.addMethod(method);
        }
    }

    /**
     * Searches for a invocation to the super class' method that the current
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.