--- /dev/null
+package sun.reflect.generics.reflectiveObjects;
+
+import java.lang.annotation.*;
+import java.lang.reflect.AnnotatedType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericDeclaration;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.Objects;
+import sun.reflect.generics.factory.GenericsFactory;
+import sun.reflect.generics.tree.FieldTypeSignature;
+
+/**
+ * MJI model class for sun.reflect.generics.reflectiveObjects.TypeVariableImple
+ *
+ * This is a JPF specific version of a system class because we can't use the real,
+ * platform VM specific version (it's native all over the place, its field
+ * structure isn't documented, most of its methods are private, hence we can't
+ * even instantiate it properly).
+ *
+ * Note that this class never gets seen by the real VM - it's for JPF's eyes only.
+ *
+ * For now this only supports a few basic methods.
+ */
+public class TypeVariableImpl<D extends GenericDeclaration>
+ extends LazyReflectiveObjectGenerator implements TypeVariable<D> {
+ D genericDeclaration;
+ private String name;
+ private Type[] bounds;
+ private FieldTypeSignature[] boundASTs;
+ private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
+
+ // constructor is private to enforce access through static factory
+ private TypeVariableImpl(D decl, String n, FieldTypeSignature[] bs,
+ GenericsFactory f) {
+ super(f);
+ genericDeclaration = decl;
+ name = n;
+ boundASTs = bs;
+ }
+
+ // Accessors
+ private FieldTypeSignature[] getBoundASTs() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Factory method.
+ * @param decl - the reflective object that declared the type variable
+ * that this method should create
+ * @param name - the name of the type variable to be returned
+ * @param bs - an array of ASTs representing the bounds for the type
+ * variable to be created
+ * @param f - a factory that can be used to manufacture reflective
+ * objects that represent the bounds of this type variable
+ * @return A type variable with name, bounds, declaration and factory
+ * specified
+ */
+ public static <T extends GenericDeclaration>
+ TypeVariableImpl<T> make(T decl, String name,
+ FieldTypeSignature[] bs,
+ GenericsFactory f) {
+
+ if (!((decl instanceof Class) ||
+ (decl instanceof Method) ||
+ (decl instanceof Constructor))) {
+ throw new AssertionError("Unexpected kind of GenericDeclaration" +
+ decl.getClass().toString());
+ }
+ return new TypeVariableImpl<T>(decl, name, bs, f);
+ }
+
+
+ public Type[] getBounds() {
+ throw new UnsupportedOperationException();
+ }
+
+ public D getGenericDeclaration(){
+ throw new UnsupportedOperationException();
+ }
+
+
+ /**
+ * Returns the name of this type variable, as it occurs in the source code.
+ *
+ * @return the name of this type variable, as it appears in the source code
+ */
+ public String getName() { return name; }
+
+ public String toString() {return getName();}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof TypeVariable &&
+ o.getClass() == TypeVariableImpl.class) {
+ TypeVariable<?> that = (TypeVariable<?>) o;
+
+ GenericDeclaration thatDecl = that.getGenericDeclaration();
+ String thatName = that.getName();
+
+ return Objects.equals(genericDeclaration, thatDecl) &&
+ Objects.equals(name, thatName);
+
+ } else
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return genericDeclaration.hashCode() ^ name.hashCode();
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+ throw new UnsupportedOperationException();
+ }
+
+ public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation[] getAnnotations() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation[] getDeclaredAnnotations() {
+ throw new UnsupportedOperationException();
+ }
+
+ public AnnotatedType[] getAnnotatedBounds() {
+ throw new UnsupportedOperationException();
+ }
+
+}