You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of the problem:
ClassCastException when calling a method on a mocked object when it has a particular class hierarchy. The following code can be used to reproduce the issue:
`
import org.junit.Test;
import mockit.Mocked;
public class WeirdClassCastErrorTest {
@Mocked
private Class object;
@Test
public void testCreateProduct() {
object.method();
}
private class Class extends BaseClass implements Interface<OtherClass> {
}
private abstract class BaseClass {
public OtherClass method() {
return new OtherClass();
}
}
private interface Interface<T> {
T method();
}
private class OtherClass {
}
}
`
Output from running the code -
java.lang.ClassCastException: WeirdClassCastErrorTest$Class cannot be cast to WeirdClassCastErrorTest$OtherClass
at WeirdClassCastErrorTest$BaseClass.method(WeirdClassCastErrorTest.java)
at WeirdClassCastErrorTest.testCreateProduct(WeirdClassCastErrorTest.java:19)
The text was updated successfully, but these errors were encountered:
1.30
ClassCastException when calling a method on a mocked object when it has a particular class hierarchy. The following code can be used to reproduce the issue:
`
import org.junit.Test;
import mockit.Mocked;
public class WeirdClassCastErrorTest {
}
`
Output from running the code -
java.lang.ClassCastException: WeirdClassCastErrorTest$Class cannot be cast to WeirdClassCastErrorTest$OtherClass
The text was updated successfully, but these errors were encountered: