01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package com.sun.mirror.type;
27:
28: import java.lang.annotation.Annotation;
29:
30: import com.sun.mirror.declaration.Declaration;
31:
32: /**
33: * Thrown when an application attempts to access the {@link Class} object
34: * corresponding to a {@link TypeMirror}.
35: *
36: * @see MirroredTypesException
37: * @see Declaration#getAnnotation(Class)
38: */
39: public class MirroredTypeException extends RuntimeException {
40:
41: private static final long serialVersionUID = 1;
42:
43: private transient TypeMirror type; // cannot be serialized
44: private String name; // type's qualified "name"
45:
46: /**
47: * Constructs a new MirroredTypeException for the specified type.
48: *
49: * @param type the type being accessed
50: */
51: public MirroredTypeException(TypeMirror type) {
52: super ("Attempt to access Class object for TypeMirror " + type);
53: this .type = type;
54: name = type.toString();
55: }
56:
57: /**
58: * Returns the type mirror corresponding to the type being accessed.
59: * The type mirror may be unavailable if this exception has been
60: * serialized and then read back in.
61: *
62: * @return the type mirror, or <tt>null</tt> if unavailable
63: */
64: public TypeMirror getTypeMirror() {
65: return type;
66: }
67:
68: /**
69: * Returns the fully qualified name of the type being accessed.
70: * More precisely, returns the canonical name of a class,
71: * interface, array, or primitive, and returns <tt>"void"</tt> for
72: * the pseudo-type representing the type of <tt>void</tt>.
73: *
74: * @return the fully qualified name of the type being accessed
75: */
76: public String getQualifiedName() {
77: return name;
78: }
79: }
|