From de917f5cdaeec3cc90141ed5d63b59bc681fb1e0 Mon Sep 17 00:00:00 2001 From: Rahmadi Trimananda Date: Sat, 22 Jun 2019 11:23:44 -0700 Subject: [PATCH] Fixing another bug for getGenericReturnType so that it recognizes Class as WildcardTypeImpl. --- examples/Reflection.java | 22 ++++++++++++---------- src/main/gov/nasa/jpf/vm/ClassInfo.java | 4 +--- src/main/gov/nasa/jpf/vm/MethodInfo.java | 6 +----- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/examples/Reflection.java b/examples/Reflection.java index 2c90e54..5687436 100644 --- a/examples/Reflection.java +++ b/examples/Reflection.java @@ -24,11 +24,13 @@ public class Reflection { class SampleClass { private String sampleField; - public Generic setSampleField(Class clazz, List listString, Map mapString, - Generic test, - String sampleField, int one, short two, double three, Object obj) { - this.sampleField = sampleField; - return test; + public Class setSampleField(Class clazz, + List listString, Map mapString, + Generic test, + String sampleField, int one, short two, double three, Object obj) { + + this.sampleField = sampleField; + return clazz; } @@ -70,10 +72,10 @@ public class Reflection { System.out.println(interfaces[i]); }*/ - Method[] methods = Class.class.getMethods(); + Method[] methods = SampleClass.class.getMethods(); Method method = null; for(Method mth : methods) { - if (mth.getName().equals("isAssignableFrom")) { + if (mth.getName().equals("setSampleField")) { method = mth; } } @@ -101,10 +103,10 @@ public class Reflection { for (Type bound : bounds) { System.out.println(bound); } - System.out.println(); - Type returnType = methods[0].getGenericReturnType(); + System.out.println();*/ + Type returnType = method.getGenericReturnType(); System.out.println(returnType); - */ + } } diff --git a/src/main/gov/nasa/jpf/vm/ClassInfo.java b/src/main/gov/nasa/jpf/vm/ClassInfo.java index eaaa3d0..abc9499 100644 --- a/src/main/gov/nasa/jpf/vm/ClassInfo.java +++ b/src/main/gov/nasa/jpf/vm/ClassInfo.java @@ -2601,9 +2601,7 @@ public class ClassInfo extends InfoObject implements Iterable, Gener // TODO: Fix for Groovy's model-checking public String[] getGenericTypeVariableNames () { - // TODO: We need to double check but for some reason Groovy has a type of generic signature with "<*>" - // TODO: in the class file. - if (genericSignature == null || genericSignature.equals("") || genericSignature.contains("<*>")) + if (genericSignature == null || genericSignature.equals("")) return new String[0]; if (!genericSignature.contains(":")) return new String[0]; diff --git a/src/main/gov/nasa/jpf/vm/MethodInfo.java b/src/main/gov/nasa/jpf/vm/MethodInfo.java index 428301c..367f584 100644 --- a/src/main/gov/nasa/jpf/vm/MethodInfo.java +++ b/src/main/gov/nasa/jpf/vm/MethodInfo.java @@ -505,8 +505,6 @@ public class MethodInfo extends InfoObject implements GenericSignatureHolder { // TODO: Fix for Groovy's model-checking public String[] getArgumentGenericTypeNames () { - // TODO: We need to double check but for some reason Groovy has a type of generic signature with "<*>" - // TODO: in the class file. if (genericSignature == null || genericSignature.equals("")) return getArgumentTypeNames(); // We need to first find the start of the method parameters in the signature @@ -592,9 +590,7 @@ public class MethodInfo extends InfoObject implements GenericSignatureHolder { } public String getGenericReturnTypeName () { - // TODO: We need to double check but for some reason Groovy has a type of generic signature with "<*>" - // TODO: in the class file. - if (genericSignature == null || genericSignature.equals("") || genericSignature.contains("<*>")) + if (genericSignature == null || genericSignature.equals("")) return Types.getReturnTypeName(signature); return Types.getGenericReturnTypeName(genericSignature); } -- 2.34.1