1 package sun.reflect.generics.reflectiveObjects;
3 import java.lang.reflect.GenericArrayType;
4 import java.lang.reflect.Type;
5 import java.util.Objects;
8 * MJI model class for sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl
10 * This is a JPF specific version of a system class because we can't use the real,
11 * platform VM specific version (it's native all over the place, its field
12 * structure isn't documented, most of its methods are private, hence we can't
13 * even instantiate it properly).
15 * Note that this class never gets seen by the real VM - it's for JPF's eyes only.
17 * For now this only supports a few basic methods.
19 public class GenericArrayTypeImpl
20 implements GenericArrayType {
21 private final Type genericComponentType;
23 // private constructor enforces use of static factory
24 private GenericArrayTypeImpl(Type ct) {
25 genericComponentType = ct;
28 public static GenericArrayTypeImpl make(Type ct) {
29 return new GenericArrayTypeImpl(ct);
32 public Type getGenericComponentType() {
33 return genericComponentType; // return cached component type
36 public String toString() {
37 Type componentType = getGenericComponentType();
38 StringBuilder sb = new StringBuilder();
40 if (componentType instanceof Class)
41 sb.append(((Class)componentType).getName() );
43 sb.append(componentType.toString());
49 public boolean equals(Object o) {
50 if (o instanceof GenericArrayType) {
51 GenericArrayType that = (GenericArrayType) o;
53 return Objects.equals(genericComponentType, that.getGenericComponentType());
59 public int hashCode() {
60 return Objects.hashCode(genericComponentType);