BINARY COMPATIBILITY
Class Body and Member Declarations
13.4.5
To preserve binary compatibility, methods should not be deleted; instead,
 forwarding methods  should be used. In our example, replacing the declaration
of
Super
 with:
class Super extends Hyper {
void hello() { super.hello(); }
}
then recompiling
Super
 and
Hyper
 and executing these new binaries with the
original binary for
Test
, produces the output:
hello from Hyper
as might have naively been expected from the previous example.
The
super
 keyword can be used to access a method declared in a superclass,
bypassing any methods declared in the current class. The expression:
super.
Identifier
is resolved, at compile time, to a method
M
 declared in a particular superclass
S
.
The method
M
 must still be declared in that class at run time or a linkage error will
result. If the method
M
 is an instance method, then the method
MR
 invoked at run
time is the method with the same signature as
M
 that is a member of the direct
superclass of the class containing the expression involving
super
. Thus, if the
program:
class Hyper {
void hello() { System.out.println("hello from Hyper"); }
}
class Super extends Hyper { }
class Test extends Super {
public static void main(String[] args) {
new Test().hello();
}
void hello() {
super.hello();
}
}
is compiled and executed, it produces the output:
hello from Hyper
Suppose that a new version of class
Super
 is produced:
247






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved