Java Reference
In-Depth Information
13.4.1.
abstract
Classes
If a class that was not declared
abstract
is changed to be declared
abstract
, then pre-existing
binaries that attempt to create new instances of that class will throw either an
InstantiationEr-
ror
at link time, or (if a reflective method is used) an
InstantiationException
at run time; such a
change is therefore not recommended for widely distributed classes.
Changing a class that is declared
abstract
to no longer be declared
abstract
does not break
compatibility with pre-existing binaries.
13.4.2.
final
Classes
If a class that was not declared
final
is changed to be declared
final
, then a
VerifyError
is
thrown if a binary of a pre-existing subclass of this class is loaded, because
final
classes can
have no subclasses; such a change is not recommended for widely distributed classes.
Changing a class that is declared
final
to no longer be declared
final
does not break compat-
ibility with pre-existing binaries.
13.4.3.
public
Classes
Changing a class that is not declared
public
to be declared
public
does not break compatibility
with pre-existing binaries.
If a class that was declared
public
is changed to not be declared
public
, then an
IllegalAccessEr-
ror
is thrown if a pre-existing binary is linked that needs but no longer has access to the
class type; such a change is not recommended for widely distributed classes.
13.4.4. Superclasses and Superinterfaces
A
ClassCircularityError
is thrown at load time if a class would be a superclass of itself.
Changes to the class hierarchy that could result in such a circularity when newly compiled
binaries are loaded with pre-existing binaries are not recommended for widely distributed
classes.
Changing the direct superclass or the set of direct superinterfaces of a class type will not
break compatibility with pre-existing binaries, provided that the total set of superclasses or
superinterfaces, respectively, of the class type loses no members.
If a change to the direct superclass or the set of direct superinterfaces results in any class
or interface no longer being a superclass or superinterface, respectively, then linkage errors
may result if pre-existing binaries are loaded with the binary of the modified class. Such
changes are not recommended for widely distributed classes.