osglworks / java-tool

Some simple common Java utilities
Apache License 2.0
52 stars 18 forks source link

`Generics.buildTypeParamImplLookup` fails to on `ParameterizedTypeImpl` #196

Closed greenlaw110 closed 5 years ago

greenlaw110 commented 5 years ago

Given the following test case:

public class Gh196 extends TestBase {

    public static class GrandParent<T> {
        T t;
    }

    public static class Parent<K, V, M extends Map<K, V>> extends GrandParent<M> {
    }

    public static class Me extends Parent<String, Integer, TreeMap<String, Integer>> {}

    @Test
    public void test() {
        Map<String, Class> lookup = Generics.buildTypeParamImplLookup(Me.class);
        eq(String.class, lookup.get("K"));
        eq(Integer.class, lookup.get("V"));
        eq(TreeMap.class, lookup.get("M"));
    }

}

It will fail at eq(TreeMap.class, lookup.get("M"); line