Package javassist.bytecode

Examples of javassist.bytecode.CodeAttribute


          || methodName.equals( EnhancerConstants.NEXT_GETTER_NAME )
          || methodName.equals( EnhancerConstants.NEXT_SETTER_NAME ) ) {
        continue;
      }

      final CodeAttribute codeAttr = methodInfo.getCodeAttribute();
      if ( codeAttr == null ) {
        // would indicate an abstract method, continue to next method
        continue;
      }

      try {
        final CodeIterator itr = codeAttr.iterator();
        while ( itr.hasNext() ) {
          final int index = itr.next();
          final int op = itr.byteAt( index );
          if ( op != Opcode.PUTFIELD && op != Opcode.GETFIELD ) {
            continue;
View Full Code Here


    * @param method the method
    * @throws Exception for any error
    */
   public static void rewriteLDC(ConstPool constPool, MethodInfo method) throws BadBytecode
   {
      CodeAttribute code = method.getCodeAttribute();
      if (code == null)
         return;
      CodeIterator iterator = code.iterator();
      while (iterator.hasNext())
      {
         int index = iterator.next();
         int op = iterator.byteAt(index);

View Full Code Here

    }
    else {
      // return
      code.addOpcode( Opcode.RETURN );
    }
    CodeAttribute ca = code.toCodeAttribute();
    if (stackmap != null) {
      ca.setAttribute(stackmap);
    }
    mi.setCodeAttribute( ca );
    mi.setAccessFlags( AccessFlag.PUBLIC );
    classfile.addMethod( mi );
  }
View Full Code Here

    code.addIndex(field_index);
    // areturn // return the value of the field
    code.addOpcode(Opcode.ARETURN);
    minfo.setCodeAttribute(code.toCodeAttribute());
    minfo.setAccessFlags(AccessFlag.PUBLIC);
    CodeAttribute codeAttribute = minfo.getCodeAttribute();
    if (codeAttribute != null) {
      StackMapTable smt = MapMaker.make(classPool, minfo);
      codeAttribute.setAttribute(smt);
    }
    classfile.addMethod(minfo);
  }
View Full Code Here

    code.addIndex(field_index);
    // return
    code.addOpcode(Opcode.RETURN);
    minfo.setCodeAttribute(code.toCodeAttribute());
    minfo.setAccessFlags(AccessFlag.PUBLIC);
    CodeAttribute codeAttribute = minfo.getCodeAttribute();
    if (codeAttribute != null) {
      StackMapTable smt = MapMaker.make(classPool, minfo);
      codeAttribute.setAttribute(smt);
    }
    classfile.addMethod(minfo);
  }
View Full Code Here

    // *return // each type
    addTypeDependDataReturn(code, finfo.getDescriptor());

    minfo.setCodeAttribute(code.toCodeAttribute());
    minfo.setAccessFlags(AccessFlag.PUBLIC);
    CodeAttribute codeAttribute = minfo.getCodeAttribute();
    if (codeAttribute != null) {
      StackMapTable smt = MapMaker.make(classPool, minfo);
      codeAttribute.setAttribute(smt);
    }
    classfile.addMethod(minfo);
  }
View Full Code Here

    // return
    code.addOpcode(Opcode.RETURN);

    minfo.setCodeAttribute(code.toCodeAttribute());
    minfo.setAccessFlags(AccessFlag.PUBLIC);
    CodeAttribute codeAttribute = minfo.getCodeAttribute();
    if (codeAttribute != null) {
      StackMapTable smt = MapMaker.make(classPool, minfo);
      codeAttribute.setAttribute(smt);
    }
    classfile.addMethod(minfo);
  }
View Full Code Here

          || methodName.startsWith(EACH_WRITE_METHOD_PREFIX)
          || methodName.equals(GETFIELDHANDLER_METHOD_NAME)
          || methodName.equals(SETFIELDHANDLER_METHOD_NAME)) {
        continue;
      }
      CodeAttribute codeAttr = minfo.getCodeAttribute();
      if (codeAttr == null) {
        continue;
      }
      CodeIterator iter = codeAttr.iterator();
      while (iter.hasNext()) {
        int pos = iter.next();
        pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
        pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
      }
      StackMapTable smt = MapMaker.make(classPool, minfo);
      codeAttr.setAttribute(smt);
    }
  }
View Full Code Here

    public CtClass[] mayThrow() {
        ClassPool pool = thisClass.getClassPool();
        ConstPool cp = thisMethod.getConstPool();
        LinkedList list = new LinkedList();
        try {
            CodeAttribute ca = thisMethod.getCodeAttribute();
            ExceptionTable et = ca.getExceptionTable();
            int pos = currentPos;
            int n = et.size();
            for (int i = 0; i < n; ++i)
                if (et.startPc(i) <= pos && pos < et.endPc(i)) {
                    int t = et.catchType(i);
View Full Code Here

    }

    protected void runEditor(ExprEditor ed, CodeIterator oldIterator)
        throws CannotCompileException
    {
        CodeAttribute codeAttr = oldIterator.get();
        int orgLocals = codeAttr.getMaxLocals();
        int orgStack = codeAttr.getMaxStack();
        int newLocals = locals();
        codeAttr.setMaxStack(stack());
        codeAttr.setMaxLocals(newLocals);
        ExprEditor.LoopContext context
            = new ExprEditor.LoopContext(newLocals);
        int size = oldIterator.getCodeLength();
        int endPos = oldIterator.lookAhead();
        oldIterator.move(currentPos);
        if (ed.doit(thisClass, thisMethod, context, oldIterator, endPos))
            edited = true;

        oldIterator.move(endPos + oldIterator.getCodeLength() - size);
        codeAttr.setMaxLocals(orgLocals);
        codeAttr.setMaxStack(orgStack);
        maxLocals = context.maxLocals;
        maxStack += context.maxStack;
    }
View Full Code Here

TOP

Related Classes of javassist.bytecode.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.