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

"GenericArrayTypeImpl cannot be cast to Class" when MockUp<GENERIC_AS_SUPER> #347

Closed
YangZhong opened this issue Sep 28, 2016 · 2 comments
Closed
Assignees
Labels
bug

Comments

@YangZhong
Copy link

@YangZhong YangZhong commented Sep 28, 2016

Please provide the following information:

  • Version of JMockit that was used:
    1.28 1.27 1.26 1.25
    Java "1.8.0_102"
  • Description of the problem or enhancement request:
    "java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl cannot be cast to java.lang.Class" when MockUp<GENERIC_AS_SUPER>.
    That's a regression because 1.24 works perfectly.

public class GENERIC_AS_SUPER extends SUPER<GENERIC>
{...}
public class TEST extends Assert
{

@BeforeClass  //  jUnit 4.12
static public void SET_UP() throws Exception
{
    new MockUp<GENERIC_AS_SUPER>()
    {
        @Mock
        void $init()
        {}
        ...
    };
}
...

}

@rliesenfeld

This comment has been minimized.

Copy link
Member

@rliesenfeld rliesenfeld commented Sep 28, 2016

I cannot reproduce the problem. How are the "SUPER" and "GENERIC" types defined?

@YangZhong

This comment has been minimized.

Copy link
Author

@YangZhong YangZhong commented Sep 28, 2016

Thanks to Rogério for trying to reproduce. A SUPER<GENERIC> example is HashMap<Object,Collection<Object>[][]>. In order to simplify regression reproducing & any fix verification, here's a simplified Test Case and could you remove "could not reproduce" tag please:

public class Regression {
  @Test  //  jUnit 4.12
  public void works1_24() {
    new MockUp<HashMap<Object,Collection<Object>[][]>>(){};
  }
}
@rliesenfeld rliesenfeld added bug and removed could not reproduce labels Sep 28, 2016
@rliesenfeld rliesenfeld self-assigned this Sep 28, 2016
@jmockit jmockit deleted a comment from YangZhong Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.