Package javassist.bytecode

Examples of javassist.bytecode.AnnotationsAttribute$Parser


    /**
     * Retrieve all method annotations.
     */   
    protected static AnnotationsAttribute getAnnotations(CtMethod ctMethod) {
        AnnotationsAttribute annotationsAttribute = (AnnotationsAttribute) ctMethod.getMethodInfo().getAttribute(AnnotationsAttribute.visibleTag);
        if (annotationsAttribute == null) {
            annotationsAttribute = new AnnotationsAttribute(ctMethod.getMethodInfo().getConstPool(), AnnotationsAttribute.visibleTag);
            ctMethod.getMethodInfo().addAttribute(annotationsAttribute);
        }
        return annotationsAttribute;
    }
View Full Code Here


public class JavassistUtils
{
   public static void addFieldAnnotation(CtField field, javassist.bytecode.annotation.Annotation annotation)
   {
      FieldInfo fieldInfo = field.getFieldInfo();
      AnnotationsAttribute attribute = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      fieldInfo.addAttribute(attribute);
   }
View Full Code Here

   }

   public static void addClassAnnotation(CtClass clazz, javassist.bytecode.annotation.Annotation annotation)
   {
      ClassFile classFile = clazz.getClassFile();
      AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      classFile.addAttribute(attribute);
   }
View Full Code Here

public class JavassistUtils
{
   public static void addFieldAnnotation(CtField field, javassist.bytecode.annotation.Annotation annotation)
   {
      FieldInfo fieldInfo = field.getFieldInfo();
      AnnotationsAttribute attribute = (AnnotationsAttribute) fieldInfo.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      fieldInfo.addAttribute(attribute);
   }
View Full Code Here

   }

   public static void addClassAnnotation(CtClass clazz, javassist.bytecode.annotation.Annotation annotation)
   {
      ClassFile classFile = clazz.getClassFile();
      AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
      if (attribute == null)
         attribute = new AnnotationsAttribute(classFile.getConstPool(), AnnotationsAttribute.visibleTag);
      attribute.addAnnotation(annotation);
      classFile.addAttribute(attribute);
   }
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.get(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]);
                                    MemberValue memberValue = createMemberValue(
                                            classFile.getConstPool(), pool.getCtClass(member.getReturnType().getCanonicalName()), 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

    protected void setUp() throws Exception {
        super.setUp();
        NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
        QueryObjectModelFactoryImpl factory = new QOMF(resolver);
        ValueFactory vf = new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), resolver);
        parser = new Parser(factory, vf);
    }
View Full Code Here

        super.setUp();
        WorkspaceImpl wsp = (WorkspaceImpl) superuser.getWorkspace();
        QueryManagerImpl qm = (QueryManagerImpl) wsp.getQueryManager();
        QueryObjectModelFactoryImpl factory = (QueryObjectModelFactoryImpl) qm
                .getQOMFactory();
        parser = new Parser(factory, superuser.getValueFactory());
    }
View Full Code Here

  private ManifestParseTree parse(InputStream inputStream) throws IOException, TokenizerException, ParserException {
    Preprocessor preprocessor = new ManifestPreprocessor();
    List<InputLine> contents = preprocessor.process(inputStream);
    Tokenizer tokenizer = new ManifestTokenizer(contents);

    Parser parser = new ManifestParser();
    return parser.parse(tokenizer);
  }
View Full Code Here

  private ManifestParseTree parse(InputStream inputStream) throws IOException, TokenizerException, ParserException {
    Preprocessor preprocessor = new ManifestPreprocessor();
    List<InputLine> contents = preprocessor.process(inputStream);
    Tokenizer tokenizer = new ManifestTokenizer(contents);

    Parser parser = new ManifestParser();
    return parser.parse(tokenizer);
  }
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.