Suppose you have legacy Java code that cannot be compiled with an updated version of java. eg.
public class ProviderUnavailableException extends Exception { private int cause; public int getCause(){ return cause; }
Back during Java 1.3, this code was valid.
In Java 1.4, the Throwable class overrides the getCause () method. It looks like this:
public Throwable getCause()
Now legacy code is invalid (since "int" is not a subtype of "Throwable"), but does not lead to run-time problems. Or can this happen in some circumstances?
Is it correct that the compilation time was back, the compiler generated byte code to handle the execution of the getCause method only in this class and, therefore, “knows” that the super-class should not be called?
EDIT
i checked the byte code of the legacy code with "javap -c".
public int getCause(); Code: 0: aload_0 1: getfield #2;
So, it returns a local field. Seems good to me.
source share