1. package java.lang.annotation;
  2. /**
  3. * Thrown to indicate that a program has attempted to access an element of
  4. * an annotation type that was added to the annotation type definition after
  5. * the annotation was compiled (or serialized). This exception will not be
  6. * thrown if the new element has a default value.
  7. *
  8. * @author Josh Bloch
  9. * @since 1.5
  10. */
  11. public class IncompleteAnnotationException extends RuntimeException {
  12. private Class annotationType;
  13. private String elementName;
  14. /**
  15. * Constructs an IncompleteAnnotationException to indicate that
  16. * the named element was missing from the specified annotation type.
  17. *
  18. * @param annotationType the Class object for the annotation type
  19. * @param elementName the name of the missing element
  20. */
  21. public IncompleteAnnotationException(
  22. Class<? extends Annotation> annotationType,
  23. String elementName) {
  24. super(annotationType.getName() + " missing element " + elementName);
  25. this.annotationType = annotationType;
  26. this.elementName = elementName;
  27. }
  28. /**
  29. * Returns the Class object for the annotation type with the
  30. * missing element.
  31. *
  32. * @return the Class object for the annotation type with the
  33. * missing element
  34. */
  35. public Class<? extends Annotation> annotationType() {
  36. return annotationType;
  37. }
  38. /**
  39. * Returns the name of the missing element.
  40. *
  41. * @return the name of the missing element
  42. */
  43. public String elementName() {
  44. return elementName;
  45. }
  46. }