Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.ParameterAnnotations


  {
    if (haveUnpackedParameterAnnotations)
      return;
    // Find attributes that contain parameter annotation data
    Attribute[] attrs = getAttributes();
    ParameterAnnotations paramAnnVisAttr = null;
    ParameterAnnotations paramAnnInvisAttr = null;
    for (int i = 0; i < attrs.length; i++)
    {
      Attribute attribute = attrs[i];
      if (attribute instanceof ParameterAnnotations)
      {
        // Initialize param_annotations
        if (!hasParameterAnnotations)
        {
          param_annotations = new List[arg_types.length];
          for (int j = 0; j < arg_types.length; j++)
            param_annotations[j] = new ArrayList<AnnotationEntryGen>();
        }
        hasParameterAnnotations = true;
        ParameterAnnotations rpa = (ParameterAnnotations) attribute;
        if (rpa instanceof RuntimeVisibleParameterAnnotations)
          paramAnnVisAttr = rpa;
        else
          paramAnnInvisAttr = rpa;
        for (int j = 0; j < arg_types.length; j++)
        {
          // This returns Annotation[] ...
          ParameterAnnotationEntry immutableArray = rpa
              .getParameterAnnotationEntries()[j];
          // ... which needs transforming into an AnnotationGen[] ...
          List<AnnotationEntryGen> mutable = makeMutableVersion(immutableArray.getAnnotationEntries());
          // ... then add these to any we already know about
          param_annotations[j].addAll(mutable);
View Full Code Here


     */
    public static void generate(Attribute[] old, Attribute[] new_,
            List<AttributePatch> patches){
        for(boolean isRuntime : new boolean[]{true, false}){
            // Find old Annotations
            ParameterAnnotations oldAnnots = null;
            for(int i = 0; i < old.length; i++){
                boolean correct = false;
                correct |= isRuntime &&
                        old[i] instanceof RuntimeVisibleParameterAnnotations;
                correct |= !isRuntime &&
                        old[i] instanceof RuntimeInvisibleParameterAnnotations;
                if(correct){
                    oldAnnots = (ParameterAnnotations)old[i];
                    break;
                }
            }
           
            //Find new Annotations
            ParameterAnnotations newAnnots = null;
            for(int i = 0; i < new_.length; i++){
                boolean correct = false;
                correct |= isRuntime &&
                        new_[i] instanceof RuntimeVisibleParameterAnnotations;
                correct |= !isRuntime &&
                        new_[i] instanceof
                                RuntimeInvisibleParameterAnnotations;
                if(correct){
                    newAnnots = (ParameterAnnotations)new_[i];
                    break;
                }
            }
           
            ParameterAnnotationEntry[] oldEntries = oldAnnots == null ?
                    new ParameterAnnotationEntry[0] :
                    oldAnnots.getParameterAnnotationEntries();
            ParameterAnnotationEntry[] newEntries = newAnnots == null ?
                    new ParameterAnnotationEntry[0] :
                    newAnnots.getParameterAnnotationEntries();
           
            int paes = oldEntries.length;
            if(newEntries.length > paes)
                paes = newEntries.length;
           
View Full Code Here

                        "RuntimeInvisibleParameterAnnotations");
        AnnotationEntry[][] oldAnnots;
        if(index == -1)
            oldAnnots = new AnnotationEntry[0][0];
        else{
            ParameterAnnotations pa = (ParameterAnnotations)attribs.get(index);
            ParameterAnnotationEntry[] paes =
                    pa.getParameterAnnotationEntries();
            oldAnnots = new AnnotationEntry[pa.getNumParameterAnnotation()][];
            for(int i = 0; i < oldAnnots.length; i++)
                oldAnnots[i] = paes[i].getAnnotationEntries();
        }
       
        int num_paes = newAnnots.length;
        if(oldAnnots.length > num_paes)
            num_paes = oldAnnots.length;
       
        // Unify...
       
        List<ParameterAnnotationEntry> paes =
                new ArrayList<ParameterAnnotationEntry>();
        for(int i = 0; i < num_paes; i++){
            List<AnnotationEntry> aes = new ArrayList<AnnotationEntry>();
            // Add old annotations.
            if(oldAnnots.length > i){
                entries: for(AnnotationEntry oldAe : oldAnnots[i]){
                    if(remAnnots.length > i){
                        for(AnnotationEntry remAe : remAnnots[i]){
                            if(Util.equals(oldAe, remAe))
                                continue entries;
                        }
                    }
                    aes.add(oldAe);
                }
            }
            // Add new annotations
            if(newAnnots.length > i){
                for(AnnotationEntry newAe : newAnnots[i])
                    aes.add(newAe);
            }
           
            // Pack into ParameterAnnotationEntry
            ParameterAnnotationEntry pae = new ParameterAnnotationEntry(
                    aes.toArray(new AnnotationEntry[aes.size()]));
            paes.add(pae);
        }
       
        // Get length
        boolean nonEmptyFound = false;
        int length = 1; // num_parameters
        for(int i = 0; i < paes.size(); i++){
            length += 2; // num_annotations
            for(AnnotationEntry e : paes.get(i).getAnnotationEntries()){
                length += Util.getLength(e);
                nonEmptyFound = true;
            }
        }
        if(!nonEmptyFound)
            return attribs;
       
        // Pack into ParamterAnnotations
        ParameterAnnotations pa;
        if(isRuntime)
            pa = new RuntimeVisibleParameterAnnotations(
                    Util.findConstantStringIn(map,
                            "RuntimeVisibleParameterAnnotations"),
                    length,
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.ParameterAnnotations

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.