Java Reference
In-Depth Information
System.out.println("float");
}
}
class Test {
public static void main(String[] args) {
Super.out(2);
}
}
This program produces the output:
float
Suppose that a new version of class
Super
is produced:
class Super {
static void out(float f) { System.out.println("float"); }
static void out(int i) { System.out.println("int"); }
}
If
Super
is recompiled but not
Test
, then running the new binary with the existing binary
of Test still produces the output:
float
However, if
Test
is then recompiled, using this new
Super
, the output is then:
int
as might have been naively expected in the previous case.
13.4.24. Method Overriding
If an instance method is added to a subclass and it overrides a method in a superclass, then
the subclass method will be found by method invocations in pre-existing binaries, and these
binaries are not impacted.
If a class method is added to a class, then this method will not be found unless the qualify-
ing type of the reference is the subclass type.
13.4.25. Static Initializers
Adding, deleting, or changing a static initializer (ยง
8.7
) of a class does not impact pre-exist-
ing binaries.