jtulach@1379
|
1 |
/*
|
jtulach@1379
|
2 |
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
jtulach@1379
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
jtulach@1379
|
4 |
*
|
jtulach@1379
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
jtulach@1379
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
jtulach@1379
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
jtulach@1379
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
jtulach@1379
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
jtulach@1379
|
10 |
*
|
jtulach@1379
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
jtulach@1379
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
jtulach@1379
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
jtulach@1379
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
jtulach@1379
|
15 |
* accompanied this code).
|
jtulach@1379
|
16 |
*
|
jtulach@1379
|
17 |
* You should have received a copy of the GNU General Public License version
|
jtulach@1379
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
jtulach@1379
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
jtulach@1379
|
20 |
*
|
jtulach@1379
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
jtulach@1379
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
jtulach@1379
|
23 |
* questions.
|
jtulach@1379
|
24 |
*/
|
jtulach@1379
|
25 |
|
jtulach@1379
|
26 |
package java.lang.annotation;
|
jtulach@1379
|
27 |
import java.lang.reflect.Method;
|
jtulach@1379
|
28 |
|
jtulach@1379
|
29 |
/**
|
jtulach@1379
|
30 |
* Thrown to indicate that a program has attempted to access an element of
|
jtulach@1379
|
31 |
* an annotation whose type has changed after the annotation was compiled
|
jtulach@1379
|
32 |
* (or serialized).
|
jtulach@1379
|
33 |
* This exception can be thrown by the {@linkplain
|
jtulach@1379
|
34 |
* java.lang.reflect.AnnotatedElement API used to read annotations
|
jtulach@1379
|
35 |
* reflectively}.
|
jtulach@1379
|
36 |
*
|
jtulach@1379
|
37 |
* @author Josh Bloch
|
jtulach@1379
|
38 |
* @see java.lang.reflect.AnnotatedElement
|
jtulach@1379
|
39 |
* @since 1.5
|
jtulach@1379
|
40 |
*/
|
jtulach@1379
|
41 |
public class AnnotationTypeMismatchException extends RuntimeException {
|
jtulach@1379
|
42 |
private static final long serialVersionUID = 8125925355765570191L;
|
jtulach@1379
|
43 |
|
jtulach@1379
|
44 |
/**
|
jtulach@1379
|
45 |
* The <tt>Method</tt> object for the annotation element.
|
jtulach@1379
|
46 |
*/
|
jtulach@1379
|
47 |
private final Method element;
|
jtulach@1379
|
48 |
|
jtulach@1379
|
49 |
/**
|
jtulach@1379
|
50 |
* The (erroneous) type of data found in the annotation. This string
|
jtulach@1379
|
51 |
* may, but is not required to, contain the value as well. The exact
|
jtulach@1379
|
52 |
* format of the string is unspecified.
|
jtulach@1379
|
53 |
*/
|
jtulach@1379
|
54 |
private final String foundType;
|
jtulach@1379
|
55 |
|
jtulach@1379
|
56 |
/**
|
jtulach@1379
|
57 |
* Constructs an AnnotationTypeMismatchException for the specified
|
jtulach@1379
|
58 |
* annotation type element and found data type.
|
jtulach@1379
|
59 |
*
|
jtulach@1379
|
60 |
* @param element the <tt>Method</tt> object for the annotation element
|
jtulach@1379
|
61 |
* @param foundType the (erroneous) type of data found in the annotation.
|
jtulach@1379
|
62 |
* This string may, but is not required to, contain the value
|
jtulach@1379
|
63 |
* as well. The exact format of the string is unspecified.
|
jtulach@1379
|
64 |
*/
|
jtulach@1379
|
65 |
public AnnotationTypeMismatchException(Method element, String foundType) {
|
jtulach@1379
|
66 |
super("Incorrectly typed data found for annotation element " + element
|
jtulach@1379
|
67 |
+ " (Found data of type " + foundType + ")");
|
jtulach@1379
|
68 |
this.element = element;
|
jtulach@1379
|
69 |
this.foundType = foundType;
|
jtulach@1379
|
70 |
}
|
jtulach@1379
|
71 |
|
jtulach@1379
|
72 |
/**
|
jtulach@1379
|
73 |
* Returns the <tt>Method</tt> object for the incorrectly typed element.
|
jtulach@1379
|
74 |
*
|
jtulach@1379
|
75 |
* @return the <tt>Method</tt> object for the incorrectly typed element
|
jtulach@1379
|
76 |
*/
|
jtulach@1379
|
77 |
public Method element() {
|
jtulach@1379
|
78 |
return this.element;
|
jtulach@1379
|
79 |
}
|
jtulach@1379
|
80 |
|
jtulach@1379
|
81 |
/**
|
jtulach@1379
|
82 |
* Returns the type of data found in the incorrectly typed element.
|
jtulach@1379
|
83 |
* The returned string may, but is not required to, contain the value
|
jtulach@1379
|
84 |
* as well. The exact format of the string is unspecified.
|
jtulach@1379
|
85 |
*
|
jtulach@1379
|
86 |
* @return the type of data found in the incorrectly typed element
|
jtulach@1379
|
87 |
*/
|
jtulach@1379
|
88 |
public String foundType() {
|
jtulach@1379
|
89 |
return this.foundType;
|
jtulach@1379
|
90 |
}
|
jtulach@1379
|
91 |
}
|