From: Rahmadi Trimananda Date: Fri, 21 Jun 2019 01:18:31 +0000 (-0700) Subject: Adding getGenericSuperclass and getGenericInterface methods but without the Parameter... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=commitdiff_plain;h=48c7130ad03404a653a8e6298fb42592efc8dd67;hp=a3fa2183399d94577d22734074e0e71bfb571801 Adding getGenericSuperclass and getGenericInterface methods but without the ParameterizedTypeImpl option. --- diff --git a/src/classes/java/lang/Class.java b/src/classes/java/lang/Class.java index 0231de7..00a55b0 100644 --- a/src/classes/java/lang/Class.java +++ b/src/classes/java/lang/Class.java @@ -274,13 +274,15 @@ public final class Class implements Serializable, GenericDeclaration, Type, A // TODO: Fix for Groovy's model-checking public native TypeVariable>[] getTypeParameters(); - public Type getGenericSuperclass() { + public native Type getGenericSuperclass(); + /*public Type getGenericSuperclass() { throw new UnsupportedOperationException(); - } - - public Type[] getGenericInterfaces() { + }*/ + + public native Type[] getGenericInterfaces(); + /*public Type[] getGenericInterfaces() { throw new UnsupportedOperationException(); - } + }*/ public Object[] getSigners() { throw new UnsupportedOperationException(); diff --git a/src/peers/gov/nasa/jpf/vm/JPF_java_lang_Class.java b/src/peers/gov/nasa/jpf/vm/JPF_java_lang_Class.java index 10d63c7..ccc9815 100644 --- a/src/peers/gov/nasa/jpf/vm/JPF_java_lang_Class.java +++ b/src/peers/gov/nasa/jpf/vm/JPF_java_lang_Class.java @@ -108,6 +108,39 @@ public class JPF_java_lang_Class extends NativePeer { } // TODO: Fix for Groovy's model-checking + @MJI + public int getGenericSuperclass____Ljava_lang_reflect_Type_2 (MJIEnv env, int robj){ + // TODO: Need to add ParameterizedTypeImpl + ClassInfo ci = env.getReferredClassInfo( robj); + ClassInfo sci = ci.getSuperClass(); + if (sci != null) { + return sci.getClassObjectRef(); + } else { + return MJIEnv.NULL; + } + } + + @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 interfaces = ci.getInterfaceClassInfos(); + aref = env.newObjectArray("Ljava/lang/Class;", interfaces.size()); + + int i=0; + for (ClassInfo ifc: interfaces){ + env.setReferenceArrayElement(aref, i++, ifc.getClassObjectRef()); + } + + return aref; + } + @MJI public int getTypeParameters_____3Ljava_lang_reflect_TypeVariable_2 (MJIEnv env, int robj){ // Get the ClassInfo for this class