G
gg9h0st
simeple code here
-----------------------------------------------------------
class IncompInterfaceTest {
void doTest() {
ClassB b = new ClassB();
InterfaceA a = (InterfaceA)b;
}
}
interface InterfaceA{}
class ClassB{}
-----------------------------------------------------------
javac issues "ClassCastException" on runtime rather than compile
error.
as i know incompatible type casting may be caught at runtime and
compiler shows the error.
but why compiler doesn't do it's job for interfaces? it's just so
clear to be compile error to me.
-----------------------------------------------------------
class IncompInterfaceTest {
void doTest() {
ClassB b = new ClassB();
InterfaceA a = (InterfaceA)b;
}
}
interface InterfaceA{}
class ClassB{}
-----------------------------------------------------------
javac issues "ClassCastException" on runtime rather than compile
error.
as i know incompatible type casting may be caught at runtime and
compiler shows the error.
but why compiler doesn't do it's job for interfaces? it's just so
clear to be compile error to me.