Package javassist.bytecode

Examples of javassist.bytecode.MethodInfo


        ConstPool cp = cf.getConstPool();
        List list = cf.getMethods();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            MethodInfo minfo = (MethodInfo)list.get(i);
            if (minfo.isConstructor()) {
                CodeAttribute codeAttr = minfo.getCodeAttribute();
                if (codeAttr != null)
                    try {
                        Bytecode init = new Bytecode(cp, 0,
                                                codeAttr.getMaxLocals());
                        CtClass[] params
                            = Descriptor.getParameterTypes(
                                                minfo.getDescriptor(),
                                                classPool);
                        int stacksize = makeFieldInitializer(init, params);
                        insertAuxInitializer(codeAttr, init, stacksize);
                        minfo.rebuildStackMapIf6(classPool, cf);
                    }
                    catch (BadBytecode e) {
                        throw new CannotCompileException(e);
                    }
            }
View Full Code Here


        catch (NotFoundException e) {}

        List list = getClassFile2().getMethods();
        int n = list.size();
        for (int i = 0; i < n; i++) {
            MethodInfo minfo = (MethodInfo)list.get(i);
            table.put(minfo.getName(), this);
        }

        list = getClassFile2().getFields();
        n = list.size();
        for (int i = 0; i < n; i++) {
View Full Code Here

    /**
     * Prints the instructions and the frame states of the given method.
     */
    public void print(CtMethod method) {
        stream.println("\n" + getMethodString(method));
        MethodInfo info = method.getMethodInfo2();
        ConstPool pool = info.getConstPool();
        CodeAttribute code = info.getCodeAttribute();
        if (code == null)
            return;

        Frame[] frames;
        try {
View Full Code Here

       
    }
   
    private void addMethodAnnotation(final CtMethod ctMethod, final Annotation annotation) {

        MethodInfo methodInfo = ctMethod.getMethodInfo();

        AnnotationsAttribute attribute = (AnnotationsAttribute) methodInfo
            .getAttribute(AnnotationsAttribute.visibleTag);

        if (attribute == null) {
            attribute = new AnnotationsAttribute(getConstPool(), AnnotationsAttribute.visibleTag);
        }

        final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);

        attribute.addAnnotation(copy);

        methodInfo.addAttribute(attribute);

    }
View Full Code Here

    }

    private void addMethodParameterAnnotation(final CtMethod ctMethod, final Annotation[][] parameterAnnotations) {

        MethodInfo methodInfo = ctMethod.getMethodInfo();

        ParameterAnnotationsAttribute attribute = (ParameterAnnotationsAttribute) methodInfo
            .getAttribute(ParameterAnnotationsAttribute.visibleTag);

        if (attribute == null) {
            attribute = new ParameterAnnotationsAttribute(getConstPool(), ParameterAnnotationsAttribute.visibleTag);
        }
       
        List<javassist.bytecode.annotation.Annotation[]> result = CollectionFactory.newList();
       
        for (Annotation[] next : parameterAnnotations)
        {
          List<javassist.bytecode.annotation.Annotation> list = CollectionFactory.newList();
         
      for (Annotation annotation : next)
      {
            final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);
           
            list.add(copy);
      }
     
      result.add(list.toArray(new javassist.bytecode.annotation.Annotation[]{}));
    }
       
        javassist.bytecode.annotation.Annotation[][] annotations = result.toArray(new javassist.bytecode.annotation.Annotation[][]{});
       
        attribute.setAnnotations(annotations);
       
        methodInfo.addAttribute(attribute);
    }
View Full Code Here

    /**
     * Returns the constructor or method containing the expression.
     */
    public CtBehavior where() {
        MethodInfo mi = thisMethod;
        CtBehavior[] cb = thisClass.getDeclaredBehaviors();
        for (int i = cb.length - 1; i >= 0; --i)
            if (cb[i].getMethodInfo2() == mi)
                return cb[i];

View Full Code Here

    private void makeBehaviorCache(CtMember.Cache cache) {
        List list = getClassFile2().getMethods();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            MethodInfo minfo = (MethodInfo)list.get(i);
            if (minfo.isMethod()) {
                CtMethod newMethod = new CtMethod(minfo, this);
                cache.addMethod(newMethod);
            }
            else {
                CtConstructor newCons = new CtConstructor(minfo, this);
View Full Code Here

        getClassFile2().addMethod(c.getMethodInfo2());
    }

    public void removeConstructor(CtConstructor m) throws NotFoundException {
        checkModify();
        MethodInfo mi = m.getMethodInfo2();
        ClassFile cf = getClassFile2();
        if (cf.getMethods().remove(mi)) {
            getMembers().remove(m);
            memberRemoved = true;
        }
View Full Code Here

            setModifiers(getModifiers() | Modifier.ABSTRACT);
    }

    public void removeMethod(CtMethod m) throws NotFoundException {
        checkModify();
        MethodInfo mi = m.getMethodInfo2();
        ClassFile cf = getClassFile2();
        if (cf.getMethods().remove(mi)) {
            getMembers().remove(m);
            memberRemoved = true;
        }
View Full Code Here

        ClassFile cf = getClassFile2();
        ConstPool cp = cf.getConstPool();
        List list = cf.getMethods();
        int n = list.size();
        for (int i = 0; i < n; ++i) {
            MethodInfo minfo = (MethodInfo)list.get(i);
            converter.doit(this, minfo, cp);
        }
    }
View Full Code Here

TOP

Related Classes of javassist.bytecode.MethodInfo

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.