Package javassist.bytecode

Examples of javassist.bytecode.ClassFile.addMethod()


                    newMethod.getMethodInfo().addAttribute(annotations);
                }

                //it is important to add the method directly to the classfile, not the class
                //because otherwise the generics info wouldn't survive
                newClassFile.addMethod(newMethod.getMethodInfo());
            }

            return newClass.toClass();

        } catch (Exception e) {
View Full Code Here


        method.getCodeAttribute().setMaxLocals(paramCount + 1);
        AttributeInfo an = annotations.copy(proxy.getConstPool(), Collections.EMPTY_MAP);
        method.addAttribute(an);

        try {
            proxy.addMethod(method);
            method.getCodeAttribute().computeMaxStack();
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            DataOutputStream dos = new DataOutputStream(bytes);
            try {
                proxy.write(dos);
View Full Code Here

                method.getCodeAttribute().setMaxLocals(locals);
            }

            copyMethodAttributes(mInfo, method);
            try {
                proxy.addMethod(method);
            } catch (DuplicateMemberException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
View Full Code Here

                e.printStackTrace();
            }
        }

        try {
            proxy.addMethod(nInfo);
        } catch (DuplicateMemberException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
View Full Code Here

        method.getCodeAttribute().setMaxLocals(types.length + 1);

        copyMethodAttributes(mInfo, method);

        try {
            proxy.addMethod(method);
        } catch (DuplicateMemberException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
View Full Code Here

/*  716 */     addSetter(this.classname, cf, pool);
/*  717 */     addGetter(this.classname, cf, pool);
/*      */
/*  719 */     if (this.factoryWriteReplace) {
/*      */       try {
/*  721 */         cf.addMethod(makeWriteReplace(pool));
/*      */       }
/*      */       catch (DuplicateMemberException e)
/*      */       {
/*      */       }
/*      */     }
View Full Code Here

/*  66 */       code.setMaxLocals(regno + 1);
/*  67 */       code.addInvokespecial(this.clazz, "<init>", desc);
/*     */
/*  69 */       code.addReturn(null);
/*  70 */       minfo.setCodeAttribute(code.toCodeAttribute());
/*  71 */       cf.addMethod(minfo);
/*     */     }
/*     */     catch (CannotCompileException e) {
/*  74 */       throw new CompileError(e);
/*     */     }
/*     */     catch (NotFoundException e) {
View Full Code Here

/*     */       else {
/* 129 */         code.addInvokevirtual(this.clazz, name, desc);
/*     */       }
/* 131 */       code.addReturn(Descriptor.getReturnType(desc, pool));
/* 132 */       minfo.setCodeAttribute(code.toCodeAttribute());
/* 133 */       cf.addMethod(minfo);
/*     */     }
/*     */     catch (CannotCompileException e) {
/* 136 */       throw new CompileError(e);
/*     */     }
/*     */     catch (NotFoundException e) {
View Full Code Here

/* 180 */         code.setMaxLocals(1);
/*     */       }
/*     */
/* 183 */       code.addReturn(Descriptor.toCtClass(fieldType, pool));
/* 184 */       minfo.setCodeAttribute(code.toCodeAttribute());
/* 185 */       cf.addMethod(minfo);
/* 186 */       this.accessors.put(key, minfo);
/* 187 */       return minfo;
/*     */     }
/*     */     catch (CannotCompileException e) {
/* 190 */       throw new CompileError(e);
View Full Code Here

/*     */       }
/*     */
/* 237 */       code.addReturn(null);
/* 238 */       code.setMaxLocals(reg);
/* 239 */       minfo.setCodeAttribute(code.toCodeAttribute());
/* 240 */       cf.addMethod(minfo);
/* 241 */       this.accessors.put(key, minfo);
/* 242 */       return minfo;
/*     */     }
/*     */     catch (CannotCompileException e) {
/* 245 */       throw new CompileError(e);
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.