Examples of CodeAttribute


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

Examples of com.caucho.bytecode.CodeAttribute

      ExtMethodAnalyzer extMethodAnalyzer
  = new ExtMethodAnalyzer(baseClass, extMethod, offset);
      extEnhancer.analyze(extMethodAnalyzer);
      extEnhancer.update();

      CodeAttribute baseCode = baseMethod.getCode();
      CodeAttribute extCode = extMethod.getCode();

      if (extCode.getMaxStack() < baseCode.getMaxStack())
        extCode.setMaxStack(baseCode.getMaxStack());

      // XXX: needs tests badly
      extCode.removeAttribute("LocalVariableTable");
      extCode.removeAttribute("LineNumberTable");
      baseCode.removeAttribute("LocalVariableTable");
      baseCode.removeAttribute("LineNumberTable");

      /*
        baseMethod.concatenate(extMethod);
View Full Code Here

Examples of com.strobel.assembler.ir.attributes.CodeAttribute

    private boolean tryLoadBody() {
        if (Flags.testAny(_flags, Flags.LOAD_BODY_FAILED)) {
            return false;
        }

        final CodeAttribute codeAttribute = SourceAttribute.find(AttributeNames.Code, _sourceAttributes);

        if (codeAttribute == null) {
            return false;
        }

        Buffer code = codeAttribute.getCode();
        ConstantPool constantPool = _declaringType.getConstantPool();

        if (code == null) {
            final ITypeLoader typeLoader = _declaringType.getTypeLoader();

            if (typeLoader == null) {
                _flags |= Flags.LOAD_BODY_FAILED;
                return true;
            }

            code = new Buffer();

            if (!typeLoader.tryLoadType(_declaringType.getInternalName(), code)) {
                _flags |= Flags.LOAD_BODY_FAILED;
                return true;
            }

            final List<ExceptionTableEntry> exceptionTableEntries = codeAttribute.getExceptionTableEntries();
            final List<SourceAttribute> codeAttributes = codeAttribute.getAttributes();

            final CodeAttribute newCode = new CodeAttribute(
                codeAttribute.getLength(),
                codeAttribute.getMaxStack(),
                codeAttribute.getMaxLocals(),
                codeAttribute.getCodeOffset(),
                codeAttribute.getCodeSize(),
View Full Code Here

Examples of javassist.bytecode.CodeAttribute

  public static String getSignature(CtBehavior method)
      throws NotFoundException {

    CtClass parameterTypes[] = method.getParameterTypes();

    CodeAttribute codeAttribute = method.getMethodInfo().getCodeAttribute();

    LocalVariableAttribute locals = null;

    if (codeAttribute != null) {
      AttributeInfo attribute;
      attribute = codeAttribute.getAttribute("LocalVariableTable");
      locals = (LocalVariableAttribute) attribute;
    }

    String methodName = method.getName();
View Full Code Here

Examples of net.sf.rej.java.attribute.CodeAttribute

  }

  public void execute() {
    if (this.codeAttr == null) {
      int index = this.cp.optionalAddUtf8("Code");
      this.codeAttr = new CodeAttribute(index, this.cp, 0, 0);
    }
   
    this.attrs.addAttribute(this.codeAttr);
  }
View Full Code Here

Examples of org.apache.harmony.pack200.bytecode.CodeAttribute

                   if (!staticModifier.matches(methodFlag))
                       maxLocal++; // one for 'this' parameter
                   maxLocal += SegmentUtils.countArgs(methodDescr[c][m]);
                   // TODO Move creation of code attribute until after constant
                   // pool resolved
                   CodeAttribute attr = new CodeAttribute(maxStack, maxLocal,
                           methodByteCodePacked[c][m]);
                   methodAttributes[c][m].add(attr);
                   i++;
               }
           }
View Full Code Here

Examples of org.apache.harmony.unpack200.bytecode.CodeAttribute

    public void testMixedByteCodes() {
        OperandManager operandManager = new MockOperandManager();
        operandManager.setSegment(segment);
        operandManager.setCurrentClass("java/lang/Foo");

        CodeAttribute attribute = new CodeAttribute(3, // maxStack
                2, // maxLocals
                mixedByteArray, // codePacked
                segment, // segment
                operandManager, // operandManager
                new ArrayList());
View Full Code Here

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

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

        // 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

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

        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
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.