Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

ChristophLu opened this issue Oct 8, 2015 · 1 comment

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

ChristophLu opened this issue Oct 8, 2015 · 1 comment


Copy link

@ChristophLu ChristophLu commented Oct 8, 2015

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.


This comment has been minimized.

Copy link

@SimFirehawk SimFirehawk commented Oct 8, 2015

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
3 participants
You can’t perform that action at this time.