Sorry. Could you please check this updated one which is OK here:
public static void main(String[] args) throws Exception
{
java.util.Map lhm = new java.util.LinkedHashMap<>();
Class<?> c = lhm.getClass();
java.lang.reflect.Method m = c.getMethod("keySet");
Object ks = m.invoke(lhm);
java.lang.reflect.Method m2 = m.getReturnType().getMethod("size");
System.out.println("COPY ME 1: " + m2);
Object s = m2.invoke(ks);
System.out.println("COPY ME 2: " + s);
}
then reply back COPY MEs values please. Here I get:
COPY ME 1: public abstract int java.util.Set.size()
COPY ME 2: 0
On 5/23/2018 11:01 PM, Doug Breaux wrote:
>
>
> On 2018/05/23 18:11:34, Yasser Zamani <[email protected]> wrote:
>
>> Thanks. Could you also check if your IBM JDK 8 is able to run this:
>>
>> java.util.Map<String, List<String>> lhm = new
>> java.util.LinkedHashMap<>();
>> Class<? extends LinkedHashMap> c = lhm.getClass();
>> Method m = c.getMethod("keySet");
>> Object ks = m.invoke(lhm);
>> Method m2 = m.getReturnType().getMethod("size");
>> Object s = m2.invoke(ks);
>>
>> System.out.println("COPY ME: " + s);
>>
>
> That actually produces a compile error:
>
> TestForStruts.java:10: error: incompatible types: Class<CAP#1> cannot be
> converted to Class<? extends LinkedHashMap>
> Class<? extends LinkedHashMap> c = lhm.getClass();
> ^
> where CAP#1 is a fresh type-variable:
> CAP#1 extends Map from capture of ? extends Map
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>