Examples of ClassGen


Examples of org.apache.bcel.generic.ClassGen

        String strippedClassName = strippedClassName(method);
        String newClassName =
            StringUtil.strcat(newClassNamePrefix(strippedClassName), "_",
                              methodType(isSetter), "Method_", method.getName());
        String javaFileName = StringUtil.strcat(strippedClassName, ".java");
        ClassGen classGen = new ClassGen(newClassName,
            CompiledAccessor.class.getName(),
            javaFileName,
            Constants.ACC_PUBLIC | Constants.ACC_FINAL | Constants.ACC_SUPER,
            EmptyStringArray);
        classGen.addEmptyConstructor(Constants.ACC_PUBLIC);

        ConstantPoolGen constantPoolGen = classGen.getConstantPool();
        InstructionFactory instructionFactory = new InstructionFactory(classGen,
                                                                       constantPoolGen);

        org.apache.bcel.classfile.Method accessorMethod = null;
        if (isSetter) {
            accessorMethod =
                constructSetterMethod(newClassName, constantPoolGen,
                                      instructionFactory, method);
        }
        else {
            accessorMethod =
                constructGetterMethod(newClassName, constantPoolGen,
                                      instructionFactory, method);
        }
        classGen.addMethod(accessorMethod);

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

Examples of org.apache.bcel.generic.ClassGen

        createClasses();
    }

    private void createClasses ()
    {
        _baseClassGen = new ClassGen(_javaClass.copy());
        _derivedClassGen = new ClassGen(_javaClass.copy());

        if (_baseClassGen.isFinal()) {
            _baseClassGen.isFinal(false);
            _derivedClassGen.isFinal(false);
            try {
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

     **/

    public ClassFabricator(String className, String parentClassName, int accessFlags)
    {
        _classGen =
            new ClassGen(
                className,
                parentClassName,
                "<synthetic>",
                accessFlags | Constants.ACC_SUPER,
                null);
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

     *
     * @return byte code
     */
    private static byte[] createSubClassByteCode(final String className)
    {
        ClassGen classGen = new ClassGen(className,
                AbstractLDAPSSLSocketFactory.class.getName(),
                "<generated>",
                ACC_PUBLIC | ACC_SUPER,
                null);
        ConstantPoolGen constantPoolGen = classGen.getConstantPool();
        InstructionFactory factory = new InstructionFactory(classGen);

        createSslContextStaticField(classGen, constantPoolGen);
        createGetDefaultStaticMethod(classGen, constantPoolGen, factory);

        classGen.addEmptyConstructor(Constants.ACC_PROTECTED);

        JavaClass javaClass = classGen.getJavaClass();
        ByteArrayOutputStream out = null;
        try
        {
            out = new ByteArrayOutputStream();
            javaClass.dump(out);
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

private InstructionFactory _factory;
  private ConstantPoolGen    _cp;
  private ClassGen           _cg;

  public ComplexObjectCreator(String objectType) {
    _cg = new ClassGen(objectType, "java.lang.Object", "ComplexObject.java", ACC_PUBLIC | ACC_SUPER, new String[] { "com.betfair.cougar.api.Result" });

    _cp = _cg.getConstantPool();
    _factory = new InstructionFactory(_cg, _cp);
    this.objectType = objectType;
  }
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

    }

    private static void nullBCELAdapt(final byte[] b) throws IOException {
        JavaClass jc = new ClassParser(new ByteArrayInputStream(b),
                "class-name").parse();
        ClassGen cg = new ClassGen(jc);
        ConstantPoolGen cp = cg.getConstantPool();
        Method[] ms = cg.getMethods();
        for (int k = 0; k < ms.length; ++k) {
            MethodGen mg = new MethodGen(ms[k], cg.getClassName(), cp);
            boolean lv = ms[k].getLocalVariableTable() == null;
            boolean ln = ms[k].getLineNumberTable() == null;
            if (lv) {
                mg.removeLocalVariables();
            }
            if (ln) {
                mg.removeLineNumbers();
            }
            mg.stripAttributes(skipDebug);
            InstructionList il = mg.getInstructionList();
            if (il != null) {
                InstructionHandle ih = il.getStart();
                while (ih != null) {
                    ih = ih.getNext();
                }
                if (compute) {
                    mg.setMaxStack();
                    mg.setMaxLocals();
                }
                if (computeFrames) {
                    ModifiedPass3bVerifier verif;
                    verif = new ModifiedPass3bVerifier(jc, k);
                    verif.do_verify();
                }
            }
            cg.replaceMethod(ms[k], mg.getMethod());
        }
        cg.getJavaClass().getBytes();
    }
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

        Class generatedClass;
        synchronized ( Type.class )
        {
            // Create BCEL class generator
            m_classGenerator =
                new ClassGen(
                    wrapperClassName,
                    WRAPPER_SUPERCLASS_NAME,
                    null,
                    Constants.ACC_FINAL
                |Constants.ACC_PUBLIC
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.ClassGen

  // ----

  public LazyClassGen(String class_name, String super_class_name, String file_name, int access_flags, String[] interfaces,
      World world) {
    myGen = new ClassGen(class_name, super_class_name, file_name, access_flags, interfaces);
    cp = myGen.getConstantPool();
    fact = new InstructionFactory(myGen, cp);
    regenerateGenericSignatureAttribute = true;
    this.world = world;
  }
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.ClassGen

    this.world = world;
  }

  // Non child type, so it comes from a real type in the world.
  public LazyClassGen(BcelObjectType myType) {
    myGen = new ClassGen(myType.getJavaClass());
    cp = myGen.getConstantPool();
    fact = new InstructionFactory(myGen, cp);
    this.myType = myType;
    world = myType.getResolvedTypeX().getWorld();
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.ClassGen

    // again haven't you? come on, admit it, no-one writes classes this big
    // by hand).
    // create an empty myGen so that we can give back a return value that
    // doesn't upset the
    // rest of the process.
    myGen = new ClassGen(myGen.getClassName(), myGen.getSuperclassName(), myGen.getFileName(), myGen.getModifiers(),
        myGen.getInterfaceNames());
    // raise an error against this compilation unit.
    getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CLASS_TOO_BIG, this.getClassName()),
        new SourceLocation(new File(myGen.getFileName()), 0), null);
  }
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.