I am a novice in Java, so the below question may look trivial.
Background:
Scenario 1:
I have a abstract base class C1 in Java with say N interface member functions.
The client uses this class as a package and implements Client1 the client business logic.
So Client1 using the package Package1 (which contains C1 class definition) is able to work with jar JAR1.
Scenario 2:
I want to understand the impact of adding new member functions to class C1. The class C1 with additional members (say we call C2) contains N+M member functions (which assume the client does not use) has jar file JAR2.
Now there can exists multiple combination of deployment –
Client1 (built on Package1) runs in environment of JAR1
Client1 (built on Package1) runs in environment of JAR2
etc
I am basically from a C++ background and there, the concept of vptr and its impact would be studied in details when a new interface is added to class which is exposed to clients.
Question:
a. How does these extension needs to be analyzed and implemented in case of JAVA (any material on the same is very helpful).
b. If this is a “safe option” in java, what are the other considerations we need to handle in such type of situation.
To answer both questions:
a) This article describes how the JVM loads and links class files: http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html.
b) As long as the signature of methods/public members doesn’t change, calling code will still work. Changing these will result in runtime exceptions when the class is loaded.