1 package sun.reflect.generics.reflectiveObjects;
3 import java.lang.annotation.*;
4 import java.lang.reflect.AnnotatedType;
5 import java.lang.reflect.Constructor;
6 import java.lang.reflect.GenericDeclaration;
7 import java.lang.reflect.Method;
8 import java.lang.reflect.Type;
9 import java.lang.reflect.TypeVariable;
10 import java.util.Objects;
11 import sun.reflect.generics.factory.GenericsFactory;
12 import sun.reflect.generics.tree.FieldTypeSignature;
15 * MJI model class for sun.reflect.generics.reflectiveObjects.TypeVariableImpl
17 * This is a JPF specific version of a system class because we can't use the real,
18 * platform VM specific version (it's native all over the place, its field
19 * structure isn't documented, most of its methods are private, hence we can't
20 * even instantiate it properly).
22 * Note that this class never gets seen by the real VM - it's for JPF's eyes only.
24 * For now this only supports a few basic methods.
26 public class TypeVariableImpl<D extends GenericDeclaration>
27 extends LazyReflectiveObjectGenerator implements TypeVariable<D> {
32 // constructor is private to enforce access through static factory
33 private TypeVariableImpl(D decl, String n, FieldTypeSignature[] bs,
36 genericDeclaration = decl;
41 private FieldTypeSignature[] getBoundASTs() {
42 throw new UnsupportedOperationException();
48 public static <T extends GenericDeclaration>
49 TypeVariableImpl<T> make(T decl, String name,
50 FieldTypeSignature[] bs,
53 if (!((decl instanceof Class) ||
54 //(decl instanceof Method) ||
55 (decl instanceof Constructor))) {
56 throw new AssertionError("Unexpected kind of GenericDeclaration" +
57 decl.getClass().toString());
59 return new TypeVariableImpl<T>(decl, name, bs, f);
63 public Type[] getBounds() {
64 throw new UnsupportedOperationException();
67 public D getGenericDeclaration(){
68 throw new UnsupportedOperationException();
71 public String getName() { return name; }
73 public String toString() {return getName();}
76 public boolean equals(Object o) {
77 if (o instanceof TypeVariable &&
78 o.getClass() == TypeVariableImpl.class) {
79 TypeVariable<?> that = (TypeVariable<?>) o;
81 GenericDeclaration thatDecl = that.getGenericDeclaration();
82 String thatName = that.getName();
84 return Objects.equals(genericDeclaration, thatDecl) &&
85 Objects.equals(name, thatName);
92 public int hashCode() {
93 return genericDeclaration.hashCode() ^ name.hashCode();
96 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
97 throw new UnsupportedOperationException();
100 public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
101 throw new UnsupportedOperationException();
105 public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
106 throw new UnsupportedOperationException();
110 public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
111 throw new UnsupportedOperationException();
114 public Annotation[] getAnnotations() {
115 throw new UnsupportedOperationException();
118 public Annotation[] getDeclaredAnnotations() {
119 throw new UnsupportedOperationException();
122 public AnnotatedType[] getAnnotatedBounds() {
123 throw new UnsupportedOperationException();