Package javassist.bytecode

Examples of javassist.bytecode.AttributeInfo


        Bytecode b = new Bytecode(proxy.getConstPool());
        b.add(Opcode.RETURN);
        method.setAccessFlags(AccessFlag.PUBLIC);
        method.setCodeAttribute(b.toCodeAttribute());
        method.getCodeAttribute().setMaxLocals(paramCount + 1);
        AttributeInfo an = annotations.copy(proxy.getConstPool(), Collections.EMPTY_MAP);
        method.addAttribute(an);

        try {
            proxy.addMethod(method);
            method.getCodeAttribute().computeMaxStack();
View Full Code Here


                if (at == null) {
                    at = new AnnotationsAttribute(file.getConstPool(), AnnotationsAttribute.visibleTag);
                    m.addAttribute(at);
                }
                at.addAnnotation(new Annotation(ModifiedMethod.class.getName(), file.getConstPool()));
                m.addAttribute(new AttributeInfo(file.getConstPool(), Constants.FINAL_METHOD_ATTRIBUTE, new byte[0]));
                modified = true;
            }
        }
        return modified;
    }
View Full Code Here

     * @param copyFrom
     */
    public static void copyCustomAttributes(final CtMethod copyTo, final CtMethod copyFrom) {
        List attributes = copyFrom.getMethodInfo().getAttributes();
        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
            AttributeInfo attributeInfo = (AttributeInfo) iterator.next();
            if (attributeInfo.getName().startsWith(AttributeEnhancer.CUSTOM_ATTRIBUTE)) {
                copyTo.setAttribute(attributeInfo.getName(), attributeInfo.get());
               
                //FIXME bug here = ALEX WHAT DO YOU MEAN????
               
                //System.out.println("JavassistHelper.copyCustomAttributes " + copyFrom.getName() + " to " +
                // copyTo.getName() + " " + attributeInfo.getName());
View Full Code Here

        else
            throw new NotFoundException(m.toString());
    }

    public byte[] getAttribute(String name) {
        AttributeInfo ai = getClassFile2().getAttribute(name);
        if (ai == null)
            return null;
        else
            return ai.get();
    }
View Full Code Here

    }

    public void setAttribute(String name, byte[] data) {
        checkModify();
        ClassFile cf = getClassFile2();
        cf.addAttribute(new AttributeInfo(cf.getConstPool(), name, data));
    }
View Full Code Here

        else
            throw new NotFoundException(m.toString());
    }

    public byte[] getAttribute(String name) {
        AttributeInfo ai = getClassFile2().getAttribute(name);
        if (ai == null)
            return null;
        else
            return ai.get();
    }
View Full Code Here

    }

    public void setAttribute(String name, byte[] data) {
        checkModify();
        ClassFile cf = getClassFile2();
        cf.addAttribute(new AttributeInfo(cf.getConstPool(), name, data));
    }
View Full Code Here

            if (Modifier.isFinal(clazz.getModifiers())) {
                clazz.setModifiers(clazz.getModifiers() ^ Modifier.FINAL);
            }

            ClassFile classFile = clazz.getClassFile2();
            AttributeInfo attribute = classFile.getAttribute(InnerClassesAttribute.tag);
            if (attribute != null && attribute instanceof InnerClassesAttribute) {
                InnerClassesAttribute ica = (InnerClassesAttribute) attribute;
                String name = classFile.getName();
                int n = ica.tableLength();
                for (int i = 0; i < n; ++i) {
View Full Code Here

    protected static void addAnnotation(CtClass clazz, CtMethod method, String annotationClassName) throws Exception {
        ClassFile ccFile = clazz.getClassFile();
        ConstPool constPool = ccFile.getConstPool();

        AttributeInfo info = method.getMethodInfo().getAttribute(AnnotationsAttribute.visibleTag);
        AnnotationsAttribute attr;
        if (info == null) {
            attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
        } else {
            attr = AnnotationsAttribute.class.cast(info);
View Full Code Here

    }

    protected void addRunWithArquillian(CtClass clazz) throws Exception {
        ClassFile ccFile = clazz.getClassFile();
        ConstPool constPool = ccFile.getConstPool();
        AttributeInfo info = ccFile.getAttribute(AnnotationsAttribute.visibleTag);
        AnnotationsAttribute attr;
        if (info == null) {
            attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
        } else {
            attr = AnnotationsAttribute.class.cast(info);
View Full Code Here

TOP

Related Classes of javassist.bytecode.AttributeInfo

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.