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);
62 public Type[] getBounds() {
64 throw new UnsupportedOperationException();
68 public D getGenericDeclaration(){
69 throw new UnsupportedOperationException();
72 public String getName() { return name; }
74 public String toString() {return getName();}
77 public boolean equals(Object o) {
78 if (o instanceof TypeVariable &&
79 o.getClass() == TypeVariableImpl.class) {
80 TypeVariable<?> that = (TypeVariable<?>) o;
82 GenericDeclaration thatDecl = that.getGenericDeclaration();
83 String thatName = that.getName();
85 return Objects.equals(genericDeclaration, thatDecl) &&
86 Objects.equals(name, thatName);
93 public int hashCode() {
94 return genericDeclaration.hashCode() ^ name.hashCode();
97 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
98 throw new UnsupportedOperationException();
101 public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
102 throw new UnsupportedOperationException();
106 public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
107 throw new UnsupportedOperationException();
111 public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
112 throw new UnsupportedOperationException();
115 public Annotation[] getAnnotations() {
116 throw new UnsupportedOperationException();
119 public Annotation[] getDeclaredAnnotations() {
120 throw new UnsupportedOperationException();
123 public AnnotatedType[] getAnnotatedBounds() {
124 throw new UnsupportedOperationException();