Package javassist.bytecode

Examples of javassist.bytecode.CodeAttribute


                CtMethod.ConstParameter.string(constructor.getSignature()),
                ctClass
        );
        newConstructor.setBody(constructor, null);
        newConstructor.setModifiers(accessFlags);
        CodeAttribute codeAttribute = newConstructor.getMethodInfo().getCodeAttribute();
        codeAttribute.setMaxLocals(codeAttribute.getMaxLocals() + 1);

        ctClass.addConstructor(newConstructor);
    }
View Full Code Here


/*  37 */   Map subTable = new HashMap();
/*  38 */   Set done = new HashSet();
/*     */
/*     */   public Subroutine[] scan(MethodInfo method) throws BadBytecode
/*     */   {
/*  42 */     CodeAttribute code = method.getCodeAttribute();
/*  43 */     CodeIterator iter = code.iterator();
/*     */
/*  45 */     this.subroutines = new Subroutine[code.getCodeLength()];
/*  46 */     this.subTable.clear();
/*  47 */     this.done.clear();
/*     */
/*  49 */     scan(0, iter, null);
/*     */
/*  51 */     ExceptionTable exceptions = code.getExceptionTable();
/*  52 */     for (int i = 0; i < exceptions.size(); i++) {
/*  53 */       int handler = exceptions.handlerPc(i);
/*     */
/*  56 */       scan(handler, iter, this.subroutines[exceptions.startPc(i)]);
/*     */     }
View Full Code Here

/*     */   public void print(CtMethod method)
/*     */   {
/*  78 */     this.stream.println("\n" + getMethodString(method));
/*  79 */     MethodInfo info = method.getMethodInfo2();
/*  80 */     ConstPool pool = info.getConstPool();
/*  81 */     CodeAttribute code = info.getCodeAttribute();
/*  82 */     if (code == null)
/*  83 */       return;
/*     */     Frame[] frames;
/*     */     try {
/*  87 */       frames = new Analyzer().analyze(method.getDeclaringClass(), info);
/*     */     } catch (BadBytecode e) {
/*  89 */       throw new RuntimeException(e);
/*     */     }
/*     */
/*  92 */     int spacing = String.valueOf(code.getCodeLength()).length();
/*     */
/*  94 */     CodeIterator iterator = code.iterator();
/*  95 */     while (iterator.hasNext()) {
/*     */       int pos;
/*     */       try { pos = iterator.next();
/*     */       } catch (BadBytecode e) {
/* 100 */         throw new RuntimeException(e);
View Full Code Here

/*     */
/*     */   public Frame[] analyze(CtClass clazz, MethodInfo method)
/*     */     throws BadBytecode
/*     */   {
/* 122 */     this.clazz = clazz;
/* 123 */     CodeAttribute codeAttribute = method.getCodeAttribute();
/*     */
/* 125 */     if (codeAttribute == null) {
/* 126 */       return null;
/*     */     }
/* 128 */     int maxLocals = codeAttribute.getMaxLocals();
/* 129 */     int maxStack = codeAttribute.getMaxStack();
/* 130 */     int codeLength = codeAttribute.getCodeLength();
/*     */
/* 132 */     CodeIterator iter = codeAttribute.iterator();
/* 133 */     IntQueue queue = new IntQueue();
/*     */
/* 135 */     this.exceptions = buildExceptionInfo(method);
/* 136 */     this.subroutines = this.scanner.scan(method);
/*     */
View Full Code Here

/* 1081 */     code.addAload(0);
/* 1082 */     int s = addLoadParameters(code, cons.getParameterTypes(), 1);
/* 1083 */     code.addInvokespecial(superClass.getName(), "<init>", desc);
/* 1084 */     code.addOpcode(177);
/* 1085 */     code.setMaxLocals(s + 1);
/* 1086 */     CodeAttribute ca = code.toCodeAttribute();
/* 1087 */     minfo.setCodeAttribute(ca);
/*      */
/* 1089 */     StackMapTable.Writer writer = new StackMapTable.Writer(32);
/* 1090 */     writer.sameFrame(pc);
/* 1091 */     ca.setAttribute(writer.toStackMapTable(cp));
/* 1092 */     return minfo;
/*      */   }
View Full Code Here

/*      */
/* 1164 */     Class retType = meth.getReturnType();
/* 1165 */     addUnwrapper(code, retType);
/* 1166 */     addReturn(code, retType);
/*      */
/* 1168 */     CodeAttribute ca = code.toCodeAttribute();
/* 1169 */     forwarder.setCodeAttribute(ca);
/* 1170 */     return forwarder;
/*      */   }
View Full Code Here

/*     */ public class MapMaker extends Tracer
/*     */ {
/*     */   public static StackMapTable make(ClassPool classes, MethodInfo minfo)
/*     */     throws BadBytecode
/*     */   {
/*  87 */     CodeAttribute ca = minfo.getCodeAttribute();
/*  88 */     if (ca == null) {
/*  89 */       return null;
/*     */     }
/*  91 */     TypedBlock[] blocks = TypedBlock.makeBlocks(minfo, ca, true);
/*  92 */     if (blocks == null) {
/*  93 */       return null;
/*     */     }
/*  95 */     MapMaker mm = new MapMaker(classes, minfo, ca);
/*  96 */     mm.make(blocks, ca.getCode());
/*  97 */     return mm.toStackMap(blocks);
/*     */   }
View Full Code Here

/*     */   }
/*     */
/*     */   public static StackMap make2(ClassPool classes, MethodInfo minfo)
/*     */     throws BadBytecode
/*     */   {
/* 108 */     CodeAttribute ca = minfo.getCodeAttribute();
/* 109 */     if (ca == null) {
/* 110 */       return null;
/*     */     }
/* 112 */     TypedBlock[] blocks = TypedBlock.makeBlocks(minfo, ca, true);
/* 113 */     if (blocks == null) {
/* 114 */       return null;
/*     */     }
/* 116 */     MapMaker mm = new MapMaker(classes, minfo, ca);
/* 117 */     mm.make(blocks, ca.getCode());
/* 118 */     return mm.toStackMap2(minfo.getConstPool(), blocks);
/*     */   }
View Full Code Here

/*     */   }
/*     */
/*     */   protected void doit(CtClass clazz, MethodInfo minfo, ConstPool cp)
/*     */     throws CannotCompileException
/*     */   {
/* 496 */     CodeAttribute codeAttr = minfo.getCodeAttribute();
/* 497 */     if ((codeAttr == null) || (this.transformers == null))
/* 498 */       return;
/* 499 */     for (Transformer t = this.transformers; t != null; t = t.getNext()) {
/* 500 */       t.initialize(cp, clazz, minfo);
/*     */     }
/* 502 */     CodeIterator iterator = codeAttr.iterator();
/* 503 */     while (iterator.hasNext()) {
/*     */       try {
/* 505 */         int pos = iterator.next();
/* 506 */         for (t = this.transformers; t != null; t = t.getNext())
/* 507 */           pos = t.transform(clazz, pos, iterator, cp);
/*     */       }
/*     */       catch (BadBytecode e) {
/* 510 */         throw new CannotCompileException(e);
/*     */       }
/*     */     }
/*     */
/* 514 */     int locals = 0;
/* 515 */     int stack = 0;
/* 516 */     for (t = this.transformers; t != null; t = t.getNext()) {
/* 517 */       int s = t.extraLocals();
/* 518 */       if (s > locals) {
/* 519 */         locals = s;
/*     */       }
/* 521 */       s = t.extraStack();
/* 522 */       if (s > stack) {
/* 523 */         stack = s;
/*     */       }
/*     */     }
/* 526 */     for (t = this.transformers; t != null; t = t.getNext()) {
/* 527 */       t.clean();
/*     */     }
/* 529 */     if (locals > 0) {
/* 530 */       codeAttr.setMaxLocals(codeAttr.getMaxLocals() + locals);
/*     */     }
/* 532 */     if (stack > 0)
/* 533 */       codeAttr.setMaxStack(codeAttr.getMaxStack() + stack);
/*     */   }
View Full Code Here

/*     */     String signature;
/*     */     String methodname;
/*     */     String classname;
/* 203 */     Javac jc = new Javac(this.thisClass);
/* 204 */     ClassPool cp = this.thisClass.getClassPool();
/* 205 */     CodeAttribute ca = this.iterator.get();
/*     */     try {
/* 207 */       CtClass[] params = Descriptor.getParameterTypes(signature, cp);
/* 208 */       CtClass retType = Descriptor.getReturnType(signature, cp);
/* 209 */       int paramVar = ca.getMaxLocals();
/* 210 */       jc.recordParams(classname, params, true, paramVar, withinStatic());
/*     */
/* 212 */       int retVar = jc.recordReturnType(retType, true);
/* 213 */       if (c == 184)
/* 214 */         jc.recordStaticProceed(classname, methodname);
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.