Package javassist.bytecode

Examples of javassist.bytecode.AnnotationsAttribute$Parser


        return false;
    }

    public Object getAnnotation(Class clz) throws ClassNotFoundException {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return getAnnotationType(clz, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here


    private Object[] getAnnotations(boolean ignoreNotFound)
        throws ClassNotFoundException
    {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

        cf.setAccessFlags(AccessFlag.of(mod));
    }

    public boolean hasAnnotation(Class clz) {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return hasAnnotationType(clz, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

        return false;
    }

    public Object getAnnotation(Class clz) throws ClassNotFoundException {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return getAnnotationType(clz, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

    private Object[] getAnnotations(boolean ignoreNotFound)
        throws ClassNotFoundException
    {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

    private void addAnnotation(Annotation annotation)
    {
       
        final ClassFile classFile = getClassFile();
       
        AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
       
        if (attribute == null)
        {
            attribute = new AnnotationsAttribute(getConstPool(), AnnotationsAttribute.visibleTag);
        }
       
        final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);
       
       
        attribute.addAnnotation(copy);
       
        classFile.addAttribute(attribute);
       
    }
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 Object[] getAnnotations(boolean ignoreNotFound)
        throws ClassNotFoundException
    {
        ClassFile cf = getClassFile2();
        AnnotationsAttribute ainfo = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.invisibleTag)
        AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
                cf.getAttribute(AnnotationsAttribute.visibleTag)
        return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2);
    }
View Full Code Here

            DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
            ClassFile cf = null;
            try
            {
               cf = new ClassFile(dstream);
               AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
               if (visible != null)
               {
                  if (EJB3Util.isStateless(visible)) return true;
                  if (EJB3Util.isStatefulSession(visible)) return true;
                  if (EJB3Util.isMessageDriven(visible)) return true;
View Full Code Here

                Class<?>[] parameterTypes = method.getParameterTypes();
                Annotation[][] parameterAnnotations = method.getParameterAnnotations();
                for (int i = 0; i < parameterTypes.length; i ++) {
                    Class<?> type = parameterTypes[i];
                    Annotation[] annotations = parameterAnnotations[i];
                    AnnotationsAttribute attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
                    for (Annotation annotation : annotations) {
                        if (annotation.annotationType().isAnnotationPresent(Constraint.class)) {
                            javassist.bytecode.annotation.Annotation ja = new javassist.bytecode.annotation.Annotation(
                                    classFile.getConstPool(), pool.getCtClass(annotation.annotationType().getName()));
                            Method[] members = annotation.annotationType().getMethods();
                            for (Method member : members) {
                                if (Modifier.isPublic(member.getModifiers())
                                        && member.getParameterTypes().length == 0
                                        && member.getDeclaringClass() == annotation.annotationType()) {
                                    Object value = member.invoke(annotation, new Object[0]);
                                    if (value != null && ! value.equals(member.getDefaultValue())) {
                                        MemberValue memberValue = createMemberValue(
                                                classFile.getConstPool(), pool.get(member.getReturnType().getName()), value);
                                        ja.addMemberValue(member.getName(), memberValue);
                                    }
                                }
                            }
                            attribute.addAnnotation(ja);
                        }
                    }
                    String fieldName = method.getName() + "Argument" + i;
                    CtField ctField = CtField.make("public " + type.getCanonicalName() + " " + fieldName + ";", pool.getCtClass(parameterClassName));
                    ctField.getFieldInfo().addAttribute(attribute);
View Full Code Here

TOP

Related Classes of javassist.bytecode.AnnotationsAttribute$Parser

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.