1 /* |
|
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.mirror.type; |
|
27 |
|
28 |
|
29 import java.lang.annotation.Annotation; |
|
30 |
|
31 import com.sun.mirror.declaration.Declaration; |
|
32 |
|
33 |
|
34 /** |
|
35 * Thrown when an application attempts to access the {@link Class} object |
|
36 * corresponding to a {@link TypeMirror}. |
|
37 * |
|
38 * @deprecated All components of this API have been superseded by the |
|
39 * standardized annotation processing API. The replacement for the |
|
40 * functionality of this exception is {@link |
|
41 * javax.lang.model.type.MirroredTypeException}. |
|
42 * |
|
43 * @see MirroredTypesException |
|
44 * @see Declaration#getAnnotation(Class) |
|
45 */ |
|
46 @Deprecated |
|
47 @SuppressWarnings("deprecation") |
|
48 public class MirroredTypeException extends RuntimeException { |
|
49 |
|
50 private static final long serialVersionUID = 1; |
|
51 |
|
52 private transient TypeMirror type; // cannot be serialized |
|
53 private String name; // type's qualified "name" |
|
54 |
|
55 /** |
|
56 * Constructs a new MirroredTypeException for the specified type. |
|
57 * |
|
58 * @param type the type being accessed |
|
59 */ |
|
60 public MirroredTypeException(TypeMirror type) { |
|
61 super("Attempt to access Class object for TypeMirror " + type); |
|
62 this.type = type; |
|
63 name = type.toString(); |
|
64 } |
|
65 |
|
66 /** |
|
67 * Returns the type mirror corresponding to the type being accessed. |
|
68 * The type mirror may be unavailable if this exception has been |
|
69 * serialized and then read back in. |
|
70 * |
|
71 * @return the type mirror, or <tt>null</tt> if unavailable |
|
72 */ |
|
73 public TypeMirror getTypeMirror() { |
|
74 return type; |
|
75 } |
|
76 |
|
77 /** |
|
78 * Returns the fully qualified name of the type being accessed. |
|
79 * More precisely, returns the canonical name of a class, |
|
80 * interface, array, or primitive, and returns <tt>"void"</tt> for |
|
81 * the pseudo-type representing the type of <tt>void</tt>. |
|
82 * |
|
83 * @return the fully qualified name of the type being accessed |
|
84 */ |
|
85 public String getQualifiedName() { |
|
86 return name; |
|
87 } |
|
88 } |
|