Generics doesn't work properly in chained method calls #213

ChristophLu opened this Issue Oct 8, 2015 · 1 comment


None yet

3 participants


With JMockit 1.19 I have the following test code:

public class MockTest {
    public interface Baz {

    public interface Bar {

        public Baz getBaz(String name);

    public interface Foo {

        public <DataT> Bar getBar(DataT model); // this does not work: "baz" is null
        // public Bar getBar(String model); // this works!

    public void test_cascading_class(@Mocked Foo foo) {
        final Bar bar = foo.getBar("blah");
        final Baz baz = bar.getBaz("foo"); // "baz" is null

The third assertion is null if using getBar() with generics. If I use the method without generics all works fine.


I can confirm it. The problem should still be existing in version 1.20. It is related to MockedTypeCascade in method getGenericReturnType specific in line 105.
The return value of getInternalReturnTypeCodeAndName(..) is used, but it should return only the name without the type code.

@rliesenfeld rliesenfeld added the bug label Oct 8, 2015
@rliesenfeld rliesenfeld self-assigned this Oct 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment