1 package sun.reflect.generics.reflectiveObjects;
3 import java.lang.reflect.GenericArrayType;
4 import java.lang.reflect.Type;
5 import java.util.Objects;
7 // TODO: Fix for Groovy's model-checking
9 * MJI model class for sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl
11 * This is a JPF specific version of a system class because we can't use the real,
12 * platform VM specific version (it's native all over the place, its field
13 * structure isn't documented, most of its methods are private, hence we can't
14 * even instantiate it properly).
16 * Note that this class never gets seen by the real VM - it's for JPF's eyes only.
18 * For now this only supports a few basic methods.
20 public class GenericArrayTypeImpl
21 implements GenericArrayType {
22 private final Type genericComponentType;
24 // private constructor enforces use of static factory
25 private GenericArrayTypeImpl(Type ct) {
26 genericComponentType = ct;
29 public static GenericArrayTypeImpl make(Type ct) {
30 return new GenericArrayTypeImpl(ct);
33 public Type getGenericComponentType() {
34 return genericComponentType; // return cached component type
37 public String toString() {
38 Type componentType = getGenericComponentType();
39 StringBuilder sb = new StringBuilder();
41 if (componentType instanceof Class)
42 sb.append(((Class)componentType).getName() );
44 sb.append(componentType.toString());
50 public boolean equals(Object o) {
51 if (o instanceof GenericArrayType) {
52 GenericArrayType that = (GenericArrayType) o;
54 return Objects.equals(genericComponentType, that.getGenericComponentType());
60 public int hashCode() {
61 return Objects.hashCode(genericComponentType);