* Returns the annotations associated with this method or constructor.
*
* @return an array of annotation-type objects.
- * @see CtMember#getAnnotations()
+ * @see #getAvailableAnnotations()
* @since 3.1
*/
public Object[] getAnnotations() throws ClassNotFoundException {
/**
* Returns the annotations associated with this method or constructor.
- * If any annotations are not on the classpath, they are not returned
+ * If any annotations are not on the classpath, they are not included
+ * in the returned array.
*
* @return an array of annotation-type objects.
- * @see CtMember#getAnnotations()
+ * @see #getAnnotations()
* @since 3.3
*/
public Object[] getAvailableAnnotations(){
try{
return getAnnotations(true);
- }catch (ClassNotFoundException e){
+ }
+ catch (ClassNotFoundException e){
throw new RuntimeException("Unexpected exception", e);
}
}
- private Object[] getAnnotations(boolean ignoreNotFound) throws ClassNotFoundException {
+ private Object[] getAnnotations(boolean ignoreNotFound)
+ throws ClassNotFoundException
+ {
MethodInfo mi = getMethodInfo2();
AnnotationsAttribute ainfo = (AnnotationsAttribute)
mi.getAttribute(AnnotationsAttribute.invisibleTag);
AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
mi.getAttribute(AnnotationsAttribute.visibleTag);
- return CtClassType.toAnnotationType(ignoreNotFound, getDeclaringClass().getClassPool(),
+ return CtClassType.toAnnotationType(ignoreNotFound,
+ getDeclaringClass().getClassPool(),
ainfo, ainfo2);
}
* equal to the number of the formal parameters. If each parameter has no
* annotation, the elements of the returned array are empty arrays.
*
- * @see CtMember#getAnnotations()
+ * @see #getAvailableParameterAnnotations()
+ * @see #getAnnotations()
* @since 3.1
*/
public Object[][] getParameterAnnotations() throws ClassNotFoundException {
/**
* Returns the parameter annotations associated with this method or constructor.
- * If any annotations are not on the classpath, they are not returned
+ * If any annotations are not on the classpath, they are not included in the
+ * returned array.
*
* @return an array of annotation-type objects. The length of the returned array is
* equal to the number of the formal parameters. If each parameter has no
* annotation, the elements of the returned array are empty arrays.
*
- * @see CtMember#getAnnotations()
+ * @see #getParameterAnnotations()
+ * @see #getAvailableAnnotations()
* @since 3.3
*/
public Object[][] getAvailableParameterAnnotations(){
try {
return getParameterAnnotations(true);
- }catch(ClassNotFoundException e) {
+ }
+ catch(ClassNotFoundException e) {
throw new RuntimeException("Unexpected exception", e);
}
}
- Object[][] getParameterAnnotations(boolean ignoreNotFound) throws ClassNotFoundException {
+ Object[][] getParameterAnnotations(boolean ignoreNotFound)
+ throws ClassNotFoundException
+ {
MethodInfo mi = getMethodInfo2();
ParameterAnnotationsAttribute ainfo = (ParameterAnnotationsAttribute)
mi.getAttribute(ParameterAnnotationsAttribute.invisibleTag);
ParameterAnnotationsAttribute ainfo2 = (ParameterAnnotationsAttribute)
mi.getAttribute(ParameterAnnotationsAttribute.visibleTag);
- return CtClassType.toAnnotationType(ignoreNotFound, getDeclaringClass().getClassPool(),
+ return CtClassType.toAnnotationType(ignoreNotFound,
+ getDeclaringClass().getClassPool(),
ainfo, ainfo2, mi);
}
-
+
/**
* Obtains parameter types of this method/constructor.
*/
* the <code>Author</code> object.
*
* @return an array of annotation-type objects.
+ * @see CtMember#getAnnotations()
* @since 3.1
*/
public Object[] getAnnotations() throws ClassNotFoundException {
/**
* Returns the annotations associated with this class.
- * For example, if an annotation <code>@Author</code> is associated
- * with this class, the returned array contains an <code>Author</code>
- * object. The member values can be obtained by calling methods on
- * the <code>Author</code> object. If any annotations are not on the
- * classpath, they are not returned
+ * This method is equivalent to <code>getAnnotations()</code>
+ * except that, if any annotations are not on the classpath,
+ * they are not included in the returned array.
*
* @return an array of annotation-type objects.
+ * @see #getAnnotations()
+ * @see CtMember#getAvailableAnnotations()
* @since 3.3
*/
public Object[] getAvailableAnnotations(){
}
public Object[] getAvailableAnnotations(){
- try
- {
+ try {
return getAnnotations(true);
}
- catch (ClassNotFoundException e)
- {
+ catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected exception ", e);
}
}
- 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);
+ 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);
}
- static Object[] toAnnotationType(boolean ignoreNotFound, ClassPool cp, AnnotationsAttribute a1,
- AnnotationsAttribute a2) throws ClassNotFoundException {
+ static Object[] toAnnotationType(boolean ignoreNotFound, ClassPool cp,
+ AnnotationsAttribute a1, AnnotationsAttribute a2)
+ throws ClassNotFoundException
+ {
Annotation[] anno1, anno2;
int size1, size2;
for (int i = 0 ; i < size1 ; i++){
try{
annotations.add(toAnnoType(anno1[i], cp));
- }catch(ClassNotFoundException e){
}
+ catch(ClassNotFoundException e){}
}
- for (int j = 0; j < size2; j++)
- {
+ for (int j = 0; j < size2; j++) {
try{
annotations.add(toAnnoType(anno2[j], cp));
- }catch(ClassNotFoundException e){
}
+ catch(ClassNotFoundException e){}
}
-
+
return annotations.toArray();
}
}
- static Object[][] toAnnotationType(boolean ignoreNotFound, ClassPool cp, ParameterAnnotationsAttribute a1,
- ParameterAnnotationsAttribute a2, MethodInfo minfo)
+ static Object[][] toAnnotationType(boolean ignoreNotFound, ClassPool cp,
+ ParameterAnnotationsAttribute a1,
+ ParameterAnnotationsAttribute a2,
+ MethodInfo minfo)
throws ClassNotFoundException
{
int numParameters = 0;
for (int j = 0 ; j < size1 ; j++){
try{
annotations.add(toAnnoType(anno1[j], cp));
- }catch(ClassNotFoundException e){
}
+ catch(ClassNotFoundException e){}
}
for (int j = 0; j < size2; j++){
try{
annotations.add(toAnnoType(anno2[j], cp));
- }catch(ClassNotFoundException e){
}
+ catch(ClassNotFoundException e){}
}
-
+
result[i] = annotations.toArray();
}
}
* Returns the annotations associated with this field.
*
* @return an array of annotation-type objects.
- * @see CtMember#getAnnotations()
+ * @see #getAvailableAnnotations()
* @since 3.1
*/
public Object[] getAnnotations() throws ClassNotFoundException {
/**
* Returns the annotations associated with this field.
- * If any annotations are not on the classpath, they are not returned
+ * If any annotations are not on the classpath, they are not included
+ * in the returned array.
*
* @return an array of annotation-type objects.
- * @see CtMember#getAnnotations()
+ * @see #getAnnotations()
* @since 3.3
*/
public Object[] getAvailableAnnotations(){
- try
- {
- return getAnnotations(true);
- }
- catch (ClassNotFoundException e)
- {
+ try {
+ return getAnnotations(true);
+ }
+ catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected exception", e);
- }
+ }
}
-
+
private Object[] getAnnotations(boolean ignoreNotFound) throws ClassNotFoundException {
FieldInfo fi = getFieldInfo2();
AnnotationsAttribute ainfo = (AnnotationsAttribute)
/**
* Returns the annotations associated with this member.
- * For example, if an annotation <code>@Author</code> is associated
- * with this member, the returned array contains an <code>Author</code>
- * object. The member values can be obtained by calling methods on
- * the <code>Author</code> object.
- * If any annotations are not on the classpath, they are not returned
+ * This method is equivalent to <code>getAnnotations()</code>
+ * except that, if any annotations are not on the classpath,
+ * they are not included in the returned array.
*
* @return an array of annotation-type objects.
- * @see CtClass#getAnnotations()
+ * @see #getAnnotations()
+ * @see CtClass#getAvailableAnnotations()
+ * @since 3.3
*/
- public abstract Object[] getAvailableAnnotations() throws ClassNotFoundException;
+ public abstract Object[] getAvailableAnnotations()
+ throws ClassNotFoundException;
/**
/**
* Executes a method invocation on a proxy instance.
- * The implementations of <code>toString</code>, <code>equals</code>,
- * and <code>hashCode</code> are directly supplied by the
- * <code>AnnotationImpl</code>. The <code>annotationType</code> method
+ * The implementations of <code>toString()</code>, <code>equals()</code>,
+ * and <code>hashCode()</code> are directly supplied by the
+ * <code>AnnotationImpl</code>. The <code>annotationType()</code> method
* is also available on the proxy instance.
*/
public Object invoke(Object proxy, Method method, Object[] args)