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

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


    private int hasAnnotation(PrintWriter out,
                              ClassMethod method,
                              String methodName)
        throws EnhancerMetaDataUserException, EnhancerMetaDataFatalError
    {
        final CodeAttribute codeAttr = method.codeAttribute();

        // return if method is abstract or native
        if (codeAttr == null)
            return NEGATIVE;

        int res = NEGATIVE;
        // don't annotate readObject(ObjectInputStream) or any jdo* methods
        // except for jdoPreStore() and jdoPreDelete().
        final boolean jdoMethod
            = ((methodName.startsWith("jdo")
                && !(methodName.equals("jdoPreStore()")
                     || methodName.equals("jdoPreDelete()")))
               || methodName.equals("readObject(java.io.ObjectInputStream)"));

        // first instruction is a target
        final Insn firstInsn = codeAttr.theCode();
        Insn insn = firstInsn.next();
        while (insn != null) {
            switch(insn.opcode()) {
            case VMConstants.opc_getfield:
            case VMConstants.opc_putfield: {
View Full Code Here


        // check the found method
        affirm(!method.isAbstract(),
               "Attempt to add code to an abstract method.");
        affirm(!method.isNative(),
               "Attempt to add code to a native method.");
        final CodeAttribute foundCodeAttr = method.codeAttribute();
        affirm(foundCodeAttr != null)// by JVM spec

        // prepend the new code to the current one
        final Insn firstInsn = codeAttr.theCode();
        affirm(firstInsn != null);
        final Insn foundFirstInsn = foundCodeAttr.theCode();
        affirm(foundFirstInsn != null);
        final Insn lastInsn = firstInsn.append(foundFirstInsn);
        affirm(lastInsn != null);
        foundCodeAttr.setTheCode(firstInsn);

        // ajust the method's stack and locals demand
        foundCodeAttr.setStackUsed(max(foundCodeAttr.stackUsed(),
                                       codeAttr.stackUsed()));
        foundCodeAttr.setLocalsUsed(max(foundCodeAttr.localsUsed(),
                                        codeAttr.localsUsed()));

        // add the exception attribute or its exceptions
        if (exceptAttr != null) {
            affirm((exceptAttr.getExceptions().size()
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

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

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

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

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

                            className,
                            JDO_PC_jdoPreSerialize_Name,
                            JDO_PC_jdoPreSerialize_Sig)));

        // create code block to be added
        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                1, // maxStack
                                0, // maxLocals
                                begin,
                                new ExceptionTable(),
                                new AttributeVector());
View Full Code Here

        insn = insn.append(Insn.create(opc_iconst_0));

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

        final CodeAttribute codeAttr
            = new CodeAttribute(getCodeAttributeUtf8(),
                                2, // maxStack
                                2, // 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.