We were forced to go from Java 1.6 up to Java 1.8 in my work environment. We did fix most of the code breakage which were introduced in this upgrade, but we now stumbled across following:
In Java 1.6 following were executing correctly:
class TestViz extends TestFrame
{
// this class is abstract
}
class TestChart extends TestViz
{
}
class MyClassTest extends JUnit
{
public MyTest()
{
TestChart chartClone = (TestChart) chart.duplicate();
}
}
Now the chart.duplicate()
returns TestFrame
, hence the cast.
Unfortunately using Java 1.8 this code fails, with the java.lang.ClassCastException
.
Does anybody know what changed in regards to abstract class casting and probably how to fix this code?
Thank you.
EDIT
The error message says:
"TestFrame cannot be cast to TestChart"