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;
14 // TODO: Fix for Groovy's model-checking
16 * MJI model class for sun.reflect.generics.reflectiveObjects.TypeVariableImpl
18 * This is a JPF specific version of a system class because we can't use the real,
19 * platform VM specific version (it's native all over the place, its field
20 * structure isn't documented, most of its methods are private, hence we can't
21 * even instantiate it properly).
23 * Note that this class never gets seen by the real VM - it's for JPF's eyes only.
25 * For now this only supports a few basic methods.
27 public class TypeVariableImpl<D extends GenericDeclaration>
28 extends LazyReflectiveObjectGenerator implements TypeVariable<D> {
33 // constructor is private to enforce access through static factory
34 private TypeVariableImpl(D decl, String n, FieldTypeSignature[] bs,
37 genericDeclaration = decl;
42 private FieldTypeSignature[] getBoundASTs() {
43 throw new UnsupportedOperationException();
49 public static <T extends GenericDeclaration>
50 TypeVariableImpl<T> make(T decl, String name,
51 FieldTypeSignature[] bs,
54 if (!((decl instanceof Class) ||
55 //(decl instanceof Method) ||
56 (decl instanceof Constructor))) {
57 throw new AssertionError("Unexpected kind of GenericDeclaration" +
58 decl.getClass().toString());
60 return new TypeVariableImpl<T>(decl, name, bs, f);
63 public native Type[] getBounds();
65 public D getGenericDeclaration(){
66 return genericDeclaration;
69 public String getName() {
73 public String toString() {
78 public boolean equals(Object o) {
79 if (o instanceof TypeVariable &&
80 o.getClass() == TypeVariableImpl.class) {
81 TypeVariable<?> that = (TypeVariable<?>) o;
83 GenericDeclaration thatDecl = that.getGenericDeclaration();
84 String thatName = that.getName();
86 return Objects.equals(genericDeclaration, thatDecl) &&
87 Objects.equals(name, thatName);
94 public int hashCode() {
95 return genericDeclaration.hashCode() ^ name.hashCode();
98 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
99 throw new UnsupportedOperationException();
102 public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
103 throw new UnsupportedOperationException();
107 public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
108 throw new UnsupportedOperationException();
112 public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
113 throw new UnsupportedOperationException();
116 public Annotation[] getAnnotations() {
117 throw new UnsupportedOperationException();
120 public Annotation[] getDeclaredAnnotations() {
121 throw new UnsupportedOperationException();
124 public AnnotatedType[] getAnnotatedBounds() {
125 throw new UnsupportedOperationException();