From 49555c1bf7ad63ce727bedfb9d72288b5be605c3 Mon Sep 17 00:00:00 2001 From: Rahmadi Trimananda Date: Sat, 22 Jun 2019 11:12:34 -0700 Subject: [PATCH] Fixing bug in recognizing Class as a WilcardTypeImpl. --- examples/Reflection.java | 6 +++--- src/main/gov/nasa/jpf/vm/MethodInfo.java | 2 +- src/main/gov/nasa/jpf/vm/Types.java | 15 ++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/Reflection.java b/examples/Reflection.java index bebd776..2c90e54 100644 --- a/examples/Reflection.java +++ b/examples/Reflection.java @@ -24,13 +24,13 @@ public class Reflection { class SampleClass { private String sampleField; - public Generic setSampleField(Class clazz, List listString, Map mapString, + 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 String getSampleField() { return sampleField; @@ -73,7 +73,7 @@ public class Reflection { Method[] methods = Class.class.getMethods(); Method method = null; for(Method mth : methods) { - if (mth.getName().equals("isAnnotationPresent")) { + if (mth.getName().equals("isAssignableFrom")) { method = mth; } } diff --git a/src/main/gov/nasa/jpf/vm/MethodInfo.java b/src/main/gov/nasa/jpf/vm/MethodInfo.java index 4176f68..428301c 100644 --- a/src/main/gov/nasa/jpf/vm/MethodInfo.java +++ b/src/main/gov/nasa/jpf/vm/MethodInfo.java @@ -507,7 +507,7 @@ public class MethodInfo extends InfoObject implements GenericSignatureHolder { 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("") || genericSignature.contains("<*>")) + if (genericSignature == null || genericSignature.equals("")) return getArgumentTypeNames(); // We need to first find the start of the method parameters in the signature String methodParameters = genericSignature.substring(genericSignature.indexOf('(')); diff --git a/src/main/gov/nasa/jpf/vm/Types.java b/src/main/gov/nasa/jpf/vm/Types.java index 948b42e..61a17a8 100644 --- a/src/main/gov/nasa/jpf/vm/Types.java +++ b/src/main/gov/nasa/jpf/vm/Types.java @@ -1109,11 +1109,16 @@ public class Types { int semicolon = signature.indexOf(';', idx); // TODO: Fix for Groovy's model-checking // Check if this is a generic! - if (signature.substring(idx,semicolon).indexOf('<') != -1) { - int generic = signature.indexOf('>', semicolon); - if (generic != -1) { - // Advance one character past the ';' - semicolon = generic + 1; + int genericStart = signature.substring(idx,semicolon).indexOf('<'); + if (genericStart != -1) { + if (signature.charAt(genericStart + 2) == '*') { + semicolon = genericStart + 4; + } else { + int generic = signature.indexOf('>', semicolon); + if (generic != -1) { + // Advance one character past the ';' + semicolon = generic + 1; + } } } -- 2.34.1