Examples of AnnotationsAttribute


Examples of javassist.bytecode.AnnotationsAttribute

    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
    }
    return match;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
    }
    return match;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
    }
    return match;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

        EnhancerConstants.NEXT_SETTER_NAME
    );
  }

  private AnnotationsAttribute getVisibleAnnotations(FieldInfo fieldInfo) {
    AnnotationsAttribute annotationsAttribute = (AnnotationsAttribute) fieldInfo.getAttribute( AnnotationsAttribute.visibleTag );
    if ( annotationsAttribute == null ) {
      annotationsAttribute = new AnnotationsAttribute(
          fieldInfo.getConstPool(),
          AnnotationsAttribute.visibleTag
      );
      fieldInfo.addAttribute( annotationsAttribute );
    }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    if ( makeTransient ) {
      theField.setModifiers( theField.getModifiers() | Modifier.TRANSIENT );
    }
    theField.setModifiers( Modifier.setPrivate( theField.getModifiers() ) );

    final AnnotationsAttribute annotationsAttribute = getVisibleAnnotations( theField.getFieldInfo() );
    annotationsAttribute.addAnnotation( new Annotation( Transient.class.getName(), constPool ) );
    return theField;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
    }
    return match;
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

   }
  
   private void copyAnnotations(javassist.bytecode.MethodInfo src, javassist.bytecode.MethodInfo dest, String annotationTag)
   {
      AnnotationsAttribute attribute = (AnnotationsAttribute) src.getAttribute(annotationTag);
      if (attribute != null)
      {
         dest.addAttribute(attribute.copy(dest.getConstPool(), EMPTY_HASHMAP));
      }
   }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

      copyAnnotations(srcFile, destFile, AnnotationsAttribute.visibleTag);
   }
  
   private void copyAnnotations(ClassFile src, ClassFile dest, String annotationTag)
   {
      AnnotationsAttribute attribute = (AnnotationsAttribute) src.getAttribute(annotationTag);
      if (attribute != null)
      {
         dest.addAttribute(attribute.copy(dest.getConstPool(), EMPTY_HASHMAP));
      }
   }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    }

    public static void createAnnotation(CtField ctField, Class<? extends Annotation> annotationType, Map<String, MemberValue> members) {
        if (ctField.hasAnnotation(annotationType)) return;

        AnnotationsAttribute attr = new AnnotationsAttribute(ctField.getFieldInfo().getConstPool(), AnnotationsAttribute.visibleTag);
        boolean isNewAttr = true;
        List<AttributeInfo> attributeInfos = ctField.getFieldInfo().getAttributes();
        for (AttributeInfo attributeInfo : attributeInfos) {
            if (attributeInfo instanceof AnnotationsAttribute) {
                attr = (AnnotationsAttribute) attributeInfo;
                isNewAttr = false;
            }
        }

        javassist.bytecode.annotation.Annotation[] annotations = attr.getAnnotations();
        javassist.bytecode.annotation.Annotation annotation = new javassist.bytecode.annotation.Annotation(annotationType.getName(), attr.getConstPool());

        for (javassist.bytecode.annotation.Annotation annotation1 : annotations) {
            if (annotation1.getTypeName().equals(annotationType.getName())) {
                annotation = annotation1;
                break;
            }
        }

        for (Map.Entry<String, MemberValue> member : members.entrySet()) {
            try {
                if (annotation.getMemberValue(member.getKey()) == null) {
                    annotation.addMemberValue(member.getKey(), member.getValue());
                }
            } catch (Exception e) {
                e.printStackTrace();
                annotation.addMemberValue(member.getKey(), member.getValue());
            }

        }

        attr.addAnnotation(annotation);
        if (isNewAttr) {
            ctField.getFieldInfo().addAttribute(attr);
        }

    }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    public static void createAnnotation(CtClass ctClass, Class<? extends Annotation> annotationType, Map<String, MemberValue> members) {


        if (ctClass.hasAnnotation(annotationType)) return;

        AnnotationsAttribute attr = new AnnotationsAttribute(ctClass.getClassFile().getConstPool(), AnnotationsAttribute.visibleTag);
        boolean isNewAttr = true;
        List<AttributeInfo> attributeInfos = ctClass.getClassFile2().getAttributes();
        for (AttributeInfo attributeInfo : attributeInfos) {
            if (attributeInfo instanceof AnnotationsAttribute) {
                attr = (AnnotationsAttribute) attributeInfo;
                isNewAttr = false;
            }
        }

        javassist.bytecode.annotation.Annotation[] annotations = attr.getAnnotations();
        javassist.bytecode.annotation.Annotation annotation = new javassist.bytecode.annotation.Annotation(annotationType.getName(), attr.getConstPool());

        for (javassist.bytecode.annotation.Annotation annotation1 : annotations) {
            if (annotation1.getTypeName().equals(annotationType.getName())) {
                annotation = annotation1;
                break;
            }
        }

        for (Map.Entry<String, MemberValue> member : members.entrySet()) {
            try {
                if (annotation.getMemberValue(member.getKey()) == null) {
                    annotation.addMemberValue(member.getKey(), member.getValue());
                }
            } catch (Exception e) {
                e.printStackTrace();
                annotation.addMemberValue(member.getKey(), member.getValue());
            }

        }

        attr.addAnnotation(annotation);

        if (isNewAttr) {
            ctClass.getClassFile().addAttribute(attr);
        }
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.