src/share/classes/sun/reflect/annotation/AnnotationSupport.java
Print this page
@@ -84,15 +84,15 @@
// and invoke it to get the contents.
Class<? extends Annotation> containerClass = containerInstance.annotationType();
AnnotationType annoType = AnnotationType.getInstance(containerClass);
if (annoType == null)
- throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations");
+ throw new AnnotationFormatError(containerInstance + " is an invalid container for repeating annotations");
Method m = annoType.members().get("value");
if (m == null)
- throw new InvalidContainerAnnotationError(containerInstance +
+ throw new AnnotationFormatError(containerInstance +
" is an invalid container for repeating annotations");
m.setAccessible(true);
@SuppressWarnings("unchecked") // not provably safe, but we catch the ClassCastException
A[] a = (A[])m.invoke(containerInstance); // this will erase to (Annotation[]) but we
@@ -101,15 +101,13 @@
return a;
} catch (IllegalAccessException | // couldnt loosen security
IllegalArgumentException | // parameters doesn't match
InvocationTargetException | // the value method threw an exception
ClassCastException e) { // well, a cast failed ...
- throw new InvalidContainerAnnotationError(
+ throw new AnnotationFormatError(
containerInstance + " is an invalid container for repeating annotations",
- e,
- containerInstance,
- null);
+ e);
}
}
/* Sanity check type of and return a list of all the annotation
* instances of type {@code annotationClass} from {@code
@@ -127,14 +125,12 @@
for (int i = 0; i < a.length; i++)
l.add(annotationClass.cast(a[i]));
return l;
} catch (ClassCastException |
NullPointerException e) {
- throw new InvalidContainerAnnotationError(
+ throw new AnnotationFormatError(
String.format("%s is an invalid container for repeating annotations of type: %s",
containerInstance, annotationClass),
- e,
- containerInstance,
- annotationClass);
+ e);
}
}
}