}
// TODO: Fix for Groovy's model-checking
- private static int getParameterizedTypeImplObj(String className, String[] parameterizedTypes, String ownerType,
- MJIEnv env, int objRef, int superObjRef) {
+ private static int getParameterizedTypeImplObj(String[] parameterizedTypes, String ownerType,
+ MJIEnv env, int actObjRef, int rawObjRef) {
ThreadInfo ti = env.getThreadInfo();
ClassLoaderInfo cli = env.getSystemClassLoaderInfo();
ElementInfo ei = env.getModifiableElementInfo(paramTypeRef);
// Get field information and fill out the fields
// rawType field
- ei.setReferenceField("rawType", superObjRef);
+ ei.setReferenceField("rawType", rawObjRef);
// actualTypeArguments
int[] types = new int[parameterizedTypes.length];
for(int j = 0; j < parameterizedTypes.length; j++) {
- types[j] = getTypeVariableImplObject(env, objRef, parameterizedTypes[j]);
+ types[j] = getTypeVariableImplObject(env, actObjRef, parameterizedTypes[j]);
}
int aRef = env.newObjectArray("Ljava/lang/reflect/Type;", parameterizedTypes.length);
// Set references for every array element
}
String className = sci.getName();
String ownerType = Types.getOwnerClassName(className);
- int gRef = getParameterizedTypeImplObj(className, typeVars, ownerType, env, ci.getClassObjectRef(),
- sci.getClassObjectRef());
+ int gRef = getParameterizedTypeImplObj(typeVars, ownerType, env, ci.getClassObjectRef(), sci.getClassObjectRef());
return gRef;
} else {
@MJI
public int getGenericInterfaces_____3Ljava_lang_reflect_Type_2 (MJIEnv env, int robj) {
- // TODO: Need to add ParameterizedTypeImpl
ClassInfo ci = env.getReferredClassInfo(robj);
int aref = MJIEnv.NULL;
ThreadInfo ti = env.getThreadInfo();
-
// contrary to the API doc, this only returns the interfaces directly
// implemented by this class, not it's bases
// <2do> this is not exactly correct, since the interfaces should be ordered
Set<ClassInfo> interfaces = ci.getInterfaceClassInfos();
+
aref = env.newObjectArray("Ljava/lang/Class;", interfaces.size());
int i=0;
for (ClassInfo ifc: interfaces){
- env.setReferenceArrayElement(aref, i++, ifc.getClassObjectRef());
+ if (Types.isGenericSignature(ifc.getGenericSignature())) {
+ String className = ifc.getName();
+ String ownerType = Types.getOwnerClassName(className);
+ String[] typeVars = ifc.getGenericTypeVariableNames();
+ int paramTypeObj = getParameterizedTypeImplObj(typeVars, ownerType, env, ci.getClassObjectRef(),
+ ifc.getClassObjectRef());
+ env.setReferenceArrayElement(aref, i++, paramTypeObj);
+ } else {
+ env.setReferenceArrayElement(aref, i++, ifc.getClassObjectRef());
+ }
}
return aref;
return aRef;
}
+
+ @MJI
+ public int getProtectionDomain____Ljava_security_ProtectionDomain_2 (MJIEnv env, int robj) {
+ // Now create a ProtectionDomain object
+ ClassLoaderInfo cli = env.getSystemClassLoaderInfo();
+ ClassInfo pdci = cli.getResolvedClassInfo("java.security.ProtectionDomain");
+
+ int proDomRef = MJIEnv.NULL;
+ /*
+ TODO: Defer the following to future implementations
+ TODO: Currently Groovy runs well without actually instantiating a ProtectionDomain object properly
+ int proDomRef = env.newObject(pdci);
+ ElementInfo ei = env.getModifiableElementInfo(proDomRef);
+ ei.setReferenceField("codesource", MJIEnv.NULL);
+ ei.setReferenceField("classloader", MJIEnv.NULL);
+ ei.setBooleanField("hasAllPerm", true);
+ ei.setBooleanField("staticPermissions", true);
+
+ // Load the Permission (AllPermission class)
+ ClassInfo pci = cli.getResolvedClassInfo("java.security.AllPermission");
+ int permRef = env.newObject(pci);
+ ElementInfo pei = env.getModifiableElementInfo(permRef);
+ pei.setReferenceField("name", env.newString("<all permissions>"));
+ ei.setReferenceField("permissions", permRef);*/
+
+ return proDomRef;
+ }
+ // TODO: Fix for Groovy's model-checking
@MJI
public int getAnnotation__Ljava_lang_Class_2__Ljava_lang_annotation_Annotation_2 (MJIEnv env, int robj,