From 3ef9e3318febb095fec30cb4576929c1ae5ba50e Mon Sep 17 00:00:00 2001 From: rtrimana Date: Fri, 14 Jun 2019 12:32:44 -0700 Subject: [PATCH] Dirty quick fix for getTypeParameters. --- examples/Reflection.java | 9 +++++---- src/peers/gov/nasa/jpf/vm/JPF_java_lang_Class.java | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/Reflection.java b/examples/Reflection.java index 4372665..a5451ea 100644 --- a/examples/Reflection.java +++ b/examples/Reflection.java @@ -39,26 +39,27 @@ public class Reflection { public static void main(String[] args) { - Method[] methods = SampleClass.class.getMethods(); + /*Method[] methods = SampleClass.class.getMethods(); Type[] parameters = methods[0].getGenericParameterTypes(); //Type[] parameters = methods[0].getGenericParameterTypes(); for (int i = 0; i < parameters.length; i++) { System.out.println(parameters[i]); } System.out.println(); - /*Class[] parameterTypes = methods[0].getParameterTypes(); + Class[] parameterTypes = methods[0].getParameterTypes(); for(Class parameterType: parameterTypes){ System.out.println(parameterType.getName()); } - System.out.println(); + System.out.println();*/ TypeVariable[] typeParameters = Generic.class.getTypeParameters(); + System.out.println("Members: " + typeParameters.length); //TypeVariable[] typeParameters = SampleClass.class.getTypeParameters(); for(TypeVariable typeVar: typeParameters){ System.out.println(typeVar); } - System.out.println();*/ + System.out.println(); /* Type returnType = methods[0].getGenericReturnType(); System.out.println(returnType);*/ 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 06ed5a4..aac8d22 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 @@ -110,12 +110,18 @@ public class JPF_java_lang_Class extends NativePeer { } // TODO: Fix for Groovy's model-checking + // TODO: THIS NEEDS TO BE SUBSTITUTED BY THE PROPER METHODS! VERY DIRTY RIGHT NOW! @MJI public int getTypeParameters_____3Ljava_lang_reflect_TypeVariable_2 (MJIEnv env, int robj){ ClassInfo ci = env.getReferredClassInfo( robj); AnnotationInfo[] ai = ci.getAnnotations(); - return 1; + try { + return env.newAnnotationProxies(ai); + } catch (ClinitRequired x){ + env.handleClinitRequest(x.getRequiredClassInfo()); + return MJIEnv.NULL; + } } @MJI -- 2.34.1