1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with this 4 * work for additional information regarding copyright ownership. The ASF 5 * licenses this file to you under the Apache License, Version 2.0 (the 6 * "License"); you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18package java.lang.annotation; 19 20/** 21 * Indicates that an element of an annotation type was accessed that was added 22 * after the type was compiled or serialized. This does not apply to new 23 * elements that have default values. 24 * 25 * @since 1.5 26 */ 27public class IncompleteAnnotationException extends RuntimeException { 28 29 private static final long serialVersionUID = 8445097402741811912L; 30 31 private Class<? extends Annotation> annotationType; 32 33 private String elementName; 34 35 /** 36 * Constructs an instance with the incomplete annotation type and the name 37 * of the element that's missing. 38 * 39 * @param annotationType 40 * the annotation type. 41 * @param elementName 42 * the name of the incomplete element. 43 */ 44 public IncompleteAnnotationException(Class<? extends Annotation> annotationType, 45 String elementName) { 46 super("The element " + elementName + " is not complete for the annotation " + 47 annotationType.getName()); 48 this.annotationType = annotationType; 49 this.elementName = elementName; 50 } 51 52 /** 53 * Returns the annotation type. 54 * 55 * @return a Class instance. 56 */ 57 public Class<? extends Annotation> annotationType() { 58 return annotationType; 59 } 60 61 /** 62 * Returns the incomplete element's name. 63 * 64 * @return the name of the element. 65 */ 66 public String elementName() { 67 return elementName; 68 } 69} 70