Package javassist.bytecode

Examples of javassist.bytecode.ParameterAnnotationsAttribute


      }
   }
  
   private void copyParameterAnnotations(int numParams, javassist.bytecode.MethodInfo src, javassist.bytecode.MethodInfo dest, String paramsTag)
   {
      ParameterAnnotationsAttribute params = (ParameterAnnotationsAttribute)src.getAttribute(paramsTag);
      if (params != null)
      {
         dest.addAttribute(params.copy(dest.getConstPool(), EMPTY_HASHMAP));
         ParameterAnnotationsAttribute srcParams = new ParameterAnnotationsAttribute(src.getConstPool(), paramsTag);
         Annotation[][] emptyParamAnnotations = new Annotation[numParams][];
         for (int i = 0 ; i < numParams ; i++)
         {
            emptyParamAnnotations[i] = new Annotation[0];
         }
         srcParams.setAnnotations(emptyParamAnnotations);
         src.addAttribute(srcParams);
      }
   }
View Full Code Here


      }
   }
  
   private void moveParameterAnnotations(int numParams, MethodInfo src, MethodInfo dest, String paramsTag)
   {
      ParameterAnnotationsAttribute params = (ParameterAnnotationsAttribute)src.getAttribute(paramsTag);
      if (params != null)
      {
         @SuppressWarnings("unchecked")
         HashMap map = new HashMap();
         dest.addAttribute(params.copy(dest.getConstPool(), map));
         ParameterAnnotationsAttribute srcParams = new ParameterAnnotationsAttribute(src.getConstPool(), paramsTag);
         Annotation[][] emptyParamAnnotations = new Annotation[numParams][];
         for (int i = 0 ; i < numParams ; i++)
         {
            emptyParamAnnotations[i] = new Annotation[0];
         }
         srcParams.setAnnotations(emptyParamAnnotations);
         src.addAttribute(srcParams);
      }
   }
View Full Code Here

      }
   }
  
   private void copyParameterAnnotations(int numParams, javassist.bytecode.MethodInfo src, javassist.bytecode.MethodInfo dest, String paramsTag)
   {
      ParameterAnnotationsAttribute params = (ParameterAnnotationsAttribute)src.getAttribute(paramsTag);
      if (params != null)
      {
         dest.addAttribute(params.copy(dest.getConstPool(), EMPTY_HASHMAP));
         ParameterAnnotationsAttribute srcParams = new ParameterAnnotationsAttribute(src.getConstPool(), paramsTag);
         Annotation[][] emptyParamAnnotations = new Annotation[numParams][];
         for (int i = 0 ; i < numParams ; i++)
         {
            emptyParamAnnotations[i] = new Annotation[0];
         }
         srcParams.setAnnotations(emptyParamAnnotations);
         src.addAttribute(srcParams);
      }
   }
View Full Code Here

                    populate(invisible.getAnnotations(), cf.getName());
                }
            }
            if (scanParameterAnnotations)
            {
                ParameterAnnotationsAttribute paramsVisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.visibleTag);
                ParameterAnnotationsAttribute paramsInvisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.invisibleTag);

                if (paramsVisible != null && paramsVisible.getAnnotations() != null)
                {
                    for (Annotation[] anns : paramsVisible.getAnnotations())
                    {
                        populate(anns, cf.getName());
                    }
                }
                if (paramsInvisible != null && paramsInvisible.getAnnotations() != null)
                {
                    for (Annotation[] anns : paramsInvisible.getAnnotations())
                    {
                        populate(anns, cf.getName());
                    }
                }
            }
View Full Code Here

          populate(invisible.getAnnotations(), cf.getName());
        }
      }
      if (scanParameterAnnotations)
      {
        ParameterAnnotationsAttribute paramsVisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.visibleTag);
        ParameterAnnotationsAttribute paramsInvisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.invisibleTag);

        if (paramsVisible != null && paramsVisible.getAnnotations() != null)
        {
          for (Annotation[] anns : paramsVisible.getAnnotations())
          {
            populate(anns, cf.getName());
          }
        }
        if (paramsInvisible != null && paramsInvisible.getAnnotations() != null)
        {
          for (Annotation[] anns : paramsInvisible.getAnnotations())
          {
            populate(anns, cf.getName());
          }
        }
      }
View Full Code Here

                //capture all the runtime visible method annotations on the original method
                annotations = (AnnotationsAttribute) originalMethod.getMethodInfo().getAttribute(
                    AnnotationsAttribute.visibleTag);

                //capture all the runtime visible parameter annotations on the original method
                ParameterAnnotationsAttribute parameterAnnotations = (ParameterAnnotationsAttribute) originalMethod
                    .getMethodInfo().getAttribute(ParameterAnnotationsAttribute.visibleTag);

                //capture the generic signature of the original method.
                signature = (SignatureAttribute) originalMethod.getMethodInfo().getAttribute(
                    SignatureAttribute.tag);
View Full Code Here

                    newParameterAnnotations[i - fromIndex][j] = cloneAnnotation(origAnnotation, constPool);
                }
            }

            ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(constPool,
                ParameterAnnotationsAttribute.visibleTag);

            newAnnotationsAttribute.setAnnotations(newParameterAnnotations);

            return newAnnotationsAttribute;
        }

        return null;
View Full Code Here

                        newAnnotations[i][0].addMemberValue("name", new StringMemberValue(paramName, method
                                .getMethodInfo().getConstPool()));
                        i++;
                    }

                    ParameterAnnotationsAttribute newAnnotationsAttribute = new ParameterAnnotationsAttribute(
                            method.getMethodInfo().getConstPool(), ParameterAnnotationsAttribute.visibleTag);
                    newAnnotationsAttribute.setAnnotations(newAnnotations);
                    method.getMethodInfo().addAttribute(newAnnotationsAttribute);

                    customClass.addMethod(method);
                }
            }
View Full Code Here

    private void addMethodParameterAnnotation(final CtMethod ctMethod, final Annotation[][] parameterAnnotations) {

        MethodInfo methodInfo = ctMethod.getMethodInfo();

        ParameterAnnotationsAttribute attribute = (ParameterAnnotationsAttribute) methodInfo
            .getAttribute(ParameterAnnotationsAttribute.visibleTag);

        if (attribute == null) {
            attribute = new ParameterAnnotationsAttribute(getConstPool(), ParameterAnnotationsAttribute.visibleTag);
        }
       
        List<javassist.bytecode.annotation.Annotation[]> result = CollectionFactory.newList();
       
        for (Annotation[] next : parameterAnnotations)
        {
          List<javassist.bytecode.annotation.Annotation> list = CollectionFactory.newList();
         
      for (Annotation annotation : next)
      {
            final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);
           
            list.add(copy);
      }
     
      result.add(list.toArray(new javassist.bytecode.annotation.Annotation[]{}));
    }
       
        javassist.bytecode.annotation.Annotation[][] annotations = result.toArray(new javassist.bytecode.annotation.Annotation[][]{});
       
        attribute.setAnnotations(annotations);
       
        methodInfo.addAttribute(attribute);
    }
View Full Code Here

                    populate(invisible.getAnnotations(), cf.getName());
                }
            }
            if (scanParameterAnnotations)
            {
                ParameterAnnotationsAttribute paramsVisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.visibleTag);
                ParameterAnnotationsAttribute paramsInvisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.invisibleTag);

                if (paramsVisible != null && paramsVisible.getAnnotations() != null)
                {
                    for (Annotation[] anns : paramsVisible.getAnnotations())
                    {
                        populate(anns, cf.getName());
                    }
                }
                if (paramsInvisible != null && paramsInvisible.getAnnotations() != null)
                {
                    for (Annotation[] anns : paramsInvisible.getAnnotations())
                    {
                        populate(anns, cf.getName());
                    }
                }
            }
View Full Code Here

TOP

Related Classes of javassist.bytecode.ParameterAnnotationsAttribute

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.