Java Reference
In-Depth Information
13.4.26. Evolution of Enums
Adding or reordering constants in an enum type will not break compatibility with pre-ex-
isting binaries.
If a pre-existing binary attempts to access an enum constant that no longer exists, the client
will fail at run time with a
NoSuchFieldError
. Therefore such a change is not recommended
for widely distributed enums.
In all other respects, the binary compatibility rules for enums are identical to those for
classes.
13.5. Evolution of Interfaces
This section describes the impact of changes to the declaration of an interface and its mem-
bers on pre-existing binaries.
13.5.1.
public
Interfaces
Changing an interface that is not declared
public
to be declared
public
does not break com-
patibility with pre-existing binaries.
If an interface that is declared
public
is changed to not be declared
public
, then an
IllegalAc-
cessError
is thrown if a pre-existing binary is linked that needs but no longer has access to
the interface type, so such a change is not recommended for widely distributed interfaces.
13.5.2. Superinterfaces
Changes to the interface hierarchy cause errors in the same way that changes to the class
perinterface of a class no longer being a superinterface can break compatibility with pre-
existing binaries, resulting in a
VerifyError
.
13.5.3. Interface Members
Adding a method to an interface does not break compatibility with pre-existing binaries.
A field added to a superinterface of
C
may hide a field inherited from a superclass of
C
. If
the original reference was to an instance field, an
IncompatibleClassChangeError
will result. If
the original reference was an assignment, an
IllegalAccessError
will result.
Deleting a member from an interface may cause linkage errors in pre-existing binaries.