Package alt.jiapi.file

Examples of alt.jiapi.file.CodeAttribute


     * Get an InstructionList, that represents a byte-code of this method.
     *
     * @return InstructionList
     */
    public InstructionList getInstructionList() {
        CodeAttribute ca = null;
        if (instructions == null) {
            ca = (CodeAttribute)getAttribute("Code");

            if (ca == null) {
                return null;
            }

            byte[] byteCode = ca.getByteCode();
           
            instructions = new InstructionList(byteCode,
                                               method.getConstantPool());
            instructions.setDeclaringMethod(this);

            if (true/* configurable by jiapi.properties */) {
                // create private representation of
                // line number table, so that we can update
                // its offsets, when class is instrumented
                lineNumberTable = new LinkedList();
               
                LineNumberTableAttribute lnta = (LineNumberTableAttribute)ca.getAttribute(LineNumberTableAttribute.ATTRIBUTE_NAME);
               
                if (lnta != null) {
                    List entries = lnta.getEntries();
                    Iterator i = entries.iterator();
                    while(i.hasNext()) {
                        LineNumberTableAttribute.Entry entry =
                            (LineNumberTableAttribute.Entry)i.next();
                       
                        Instruction ins =
                            instructions.instructionAtOffset(entry.getStartPc());
                       
                        lineNumberTable.add(new LNTableEntry(entry, ins));
                    }
                }
                else {
                    //System.out.println("ERROR: could not get line number table");
                }
            }


            this.exceptionTable = new LinkedList();
            List eTable = ca.getExceptionTable();
           
            if (eTable != null) {
                Iterator i = eTable.iterator();
                while(i.hasNext()) {
                    CodeAttribute.ExceptionTableEntry entry =
View Full Code Here


        if (instructions != null) {
            instructions.updateOffsets();
            // Update branch offsets
            updateBranchOffsets();
           
            CodeAttribute ca = (CodeAttribute)getAttribute("Code");
            ca.setByteCode(instructions.getBytes());
           
            // Update max locals & max stack
            updateMaxLocals(ca, instructions);
            updateMaxStack(ca, instructions);
        }
View Full Code Here

            }
        }
    }

    public /*private*/ int getMaxLocals() {
        CodeAttribute ca = (CodeAttribute)getAttribute("Code");
        if (ca == null) {
            throw new NullPointerException("No Code attribute found");
        }
        ca.setByteCode(getInstructionList().getBytes());

        return updateMaxLocals(ca, getInstructionList());
    }
View Full Code Here

        return updateMaxLocals(ca, getInstructionList());
    }

    public /*private*/ int getMaxStack() {
        CodeAttribute ca = (CodeAttribute)getAttribute("Code");
        //ca.setByteCode(instructions.getBytes());

        return updateMaxStack(ca, getInstructionList());
    }
View Full Code Here

        attrs.add(new SyntheticAttribute(cp));

        short maxStack = 0;
        int maxLocals = signature.getParameters().length + 1;

        attrs.add(new CodeAttribute(cp, maxStack, (short)maxLocals));

        // Create field, and add it to ClassFile
        Method m = new Method(cp, modifiers, name, signature.getDescriptor(),
                              attrs);
View Full Code Here

TOP

Related Classes of alt.jiapi.file.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.