lowerBoundASTs = lbs;
}
- /**
- * Static factory.
- */
public static WildcardTypeImpl make(FieldTypeSignature[] ubs,
FieldTypeSignature[] lbs,
GenericsFactory f) {
throw new UnsupportedOperationException();
}
- public native Type[] getUpperBounds();
+ public Type[] getUpperBounds() {
+ return upperBounds;
+ }
- public native Type[] getLowerBounds();
+ public Type[] getLowerBounds() {
+ return lowerBounds;
+ }
public String toString() {
Type[] lowerBounds = getLowerBounds();
return "?";
}
- assert bounds.length > 0;
+ // TODO: Commented out since it's producing <clinit> that blocks us from getting a new object without
+ // TODO: initializing it through the constructor.
+ //assert bounds.length > 0;
boolean first = true;
for(Type bound: bounds) {
String typeParamSig = parameterizedType.concat(":");
return signature.contains(typeParamSig);
}
+
+ public static boolean isWildcardType(String signature) {
+ return (signature.startsWith("+L") || signature.equals("*"));
+ }
+
+ public static String getWildcardType(String signature) {
+ if (signature.equals("*")) {
+ return "java.lang.Object";
+ }
+ return signature.replace("+L", "");
+ }
// TODO: Fix for Groovy's model-checking
}
String methodGenericSig = mi.getGenericSignature();
for(int j = 0; j < parameterizedTypes.length; j++) {
if (Types.isTypeParameter(parameterizedTypes[j], methodGenericSig) ||
- Types.isTypeParameter(parameterizedTypes[j], classGenericSig)) {
+ Types.isTypeParameter(parameterizedTypes[j], classGenericSig)) {
types[j] = getTypeVariableImplObject(env, objRef, parameterizedTypes[j]);
+ } else if (Types.isWildcardType(parameterizedTypes[j])) {
+ String wildcardType = Types.getWildcardType(parameterizedTypes[j]);
+ types[j] = getWildcardTypeImplObject(env, objRef, wildcardType);
} else {
ClassInfo pci = cli.getResolvedClassInfo(parameterizedTypes[j]);
if (!pci.isRegistered()) {
return paramTypeRef;
}
+ private static int getWildcardTypeImplObject(MJIEnv env, int objRef, String wildcardType) {
+ ThreadInfo ti = env.getThreadInfo();
+ ClassLoaderInfo cli = env.getSystemClassLoaderInfo();
+ ClassInfo ci = cli.getResolvedClassInfo("sun.reflect.generics.reflectiveObjects.WildcardTypeImpl");
+
+ int wildcardRef = env.newObject(ci);
+ ElementInfo ei = env.getModifiableElementInfo(wildcardRef);
+ int uRef = env.newObjectArray("Ljava/lang/reflect/Type;", 1);
+ ClassInfo uci = cli.getResolvedClassInfo(wildcardType);
+ if (!uci.isRegistered()) {
+ uci.registerClass(ti);
+ }
+ env.setReferenceArrayElement(uRef, 0, uci.getClassObjectRef());
+ ei.setReferenceField("upperBounds", uRef);
+ int lRef = env.newObjectArray("Ljava/lang/reflect/Type;", 0);
+ ei.setReferenceField("lowerBounds", lRef);
+
+ return wildcardRef;
+ }
+
private static int getTypeVariableImplObject(MJIEnv env, int objRef, String parameterizedType) {
ClassLoaderInfo cli = env.getSystemClassLoaderInfo();
static int getGenericParameterTypes( MJIEnv env, int objRef, MethodInfo mi) {
ThreadInfo ti = env.getThreadInfo();
- String name = mi.getName();
String[] argTypeNames = mi.getArgumentGenericTypeNames();
int[] ar = new int[argTypeNames.length];
import gov.nasa.jpf.annotation.MJI;
-public class JPF_sun_reflect_generics_reflectiveObjects_WildcardTypeImpl {
+public class JPF_sun_reflect_generics_reflectiveObjects_WildcardTypeImpl extends NativePeer {
- // TODO: Need to fix the following 2 methods!!!
-
- @MJI
+ // TODO: Need to fix the following 2 methods if needed!!!
+ /*@MJI
public int getUpperBounds_____3Ljava_lang_reflect_Type_2 (MJIEnv env, int objRef){
ThreadInfo ti = env.getThreadInfo();
ClassInfo ci = ClassLoaderInfo.getCurrentResolvedClassInfo("java.lang.Object");
env.setReferenceArrayElement(aRef, 0, MJIEnv.NULL);
return aRef;
- }
+ }*/
}