Package org.apache.jdo.impl.enhancer.classfile

Examples of org.apache.jdo.impl.enhancer.classfile.CodeAttribute


        insn = insn.append(mediate);
        insn = appendMediatedWriteAccess(insn, fieldIndex, fieldRef, varStart);

        // end of method body

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                (2 * fieldSize) + 3, // maxStack
                                fieldSize + 2, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here


        }

        // end of method body
        insn = insn.append(Insn.create(opc_return));

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                3, // maxStack
                                1, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

        // return newObject;

        // end of method body
        insn = insn.append(Insn.create(opc_areturn));

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                1, //3, //3, // maxStack
                                1, //2, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

        insn = appendThrowJavaException(
            insn, JAVA_UnsupportedOperationException_Path,
            "Method " + methodName + " not yet implemented");

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                3, // maxStack
                                countMethodArgWords(methodSig), // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

     * Annotate the class method.  For now, brute force rules.
     */
    private boolean annotated(ClassMethod method)
    {
        boolean annotated = false;
        final CodeAttribute codeAttr = method.codeAttribute();
        if (codeAttr == null) {
            return annotated;
        }

        env.message(
            "annotating: " + userClassName
            + "." + method.name().asString()
            + Descriptor.userMethodArgs(method.signature().asString()));
       
        // first instruction is a target
        final Insn firstInsn = codeAttr.theCode();
        affirm(firstInsn.opcode() == Insn.opc_target);
        Insn insn = firstInsn.next();
        while (insn != null) {
            switch(insn.opcode()) {
            case opc_getfield:
View Full Code Here

            System.out.println("    methodName = " + methodName);
            System.out.println("    methodSig = " + methodSig);
            System.out.println("    superName = " + superName);
        }

        final CodeAttribute codeAttr = method.codeAttribute();
        for (Insn insn = codeAttr.theCode();
             insn != null;
             insn = insn.next()) {

            // Found the clone method.  See if it is the flavor of clone()
            // which does a super.clone() call, and if it is, add
            // field initializations for the jdoStateManager and jdoFlags
            // fields.
            if (insn.opcode() != opc_invokespecial)
                continue;

            final InsnConstOp invoke = (InsnConstOp)insn;
            final ConstMethodRef methodRef = (ConstMethodRef)invoke.value();
            final ConstNameAndType methodNT = methodRef.nameAndType();
            final String methodName = methodNT.name().asString();
            final String methodSig = methodNT.signature().asString();

            if (!(methodName.equals("clone")
                  && methodSig.equals("()Ljava/lang/Object;")))
                continue;

            if (false) {
                final ConstClass methodClass = methodRef.className();
                final String methodClassName = methodClass.asString();
                System.out.println("        found invocation of: "
                                   + methodClassName
                                   + "." + methodName + methodSig);
            }

            // check whether next instruction already is a downcast to a
            // class implementing PersistenceCapable
            final String thisClass = classFile.classNameString();
            final Insn checkCastInsn = insn.next();
            final boolean needCheckcast;
            if (checkCastInsn.opcode() != opc_checkcast) {
                needCheckcast = true;
            } else {
                ConstClass target =
                    (ConstClass) ((InsnConstOp)checkCastInsn).value();
                if (target.asString().equals(thisClass)) {
                    insn = checkCastInsn;
                    needCheckcast = false;
                } else {
                    needCheckcast = true;
                }
            }

            // clear jdo fields of clone
            {
                // duplicate downcasted reference
                final Insn newInsn = Insn.create(opc_dup);
                if (needCheckcast) {
                    newInsn.append(Insn.create(opc_checkcast,
                                               pool.addClass(thisClass)));
                }
                newInsn.append(Insn.create(opc_dup));

                // clear jdo fields
                newInsn.append(Insn.create(opc_aconst_null));
                newInsn.append(Insn.create(
                    opc_putfield,
                    pool.addFieldRef(
                        thisClass,
                        JDOConstants.JDO_PC_jdoStateManager_Name,
                        JDOConstants.JDO_PC_jdoStateManager_Sig)));
                newInsn.append(Insn.create(opc_iconst_0));
                newInsn.append(Insn.create(
                    opc_putfield,
                    pool.addFieldRef(
                        thisClass,
                        JDOConstants.JDO_PC_jdoFlags_Name,
                        JDOConstants.JDO_PC_jdoFlags_Sig)));

                // insert code
                insn.insert(newInsn);

                // increase stack
                final int annotationStack = 3;
                codeAttr.setStackUsed(codeAttr.stackUsed() + annotationStack);
            }
        }
    }
View Full Code Here

        Insn insn = begin;

        // end of method body
        insn = insn.append(Insn.create(opc_return));

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                0, // maxStack
                                countMethodArgWords(methodSig), // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

                        getjdoFlagsFieldRef()));

        // end of method body
        insn = insn.append(Insn.create(opc_return));

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                4, // maxStack
                                3, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

        // end of method body
        insn = insn.append(end);
        insn = insn.append(Insn.create(opc_return));

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                3, // maxStack
                                2, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

        // end of method body
        insn = insn.append(end);
        insn = insn.append(Insn.create(opc_return));

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                3, // maxStack
                                3, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

TOP

Related Classes of org.apache.jdo.impl.enhancer.classfile.CodeAttribute

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.