• No se han encontrado resultados

Rule Change Affected Error/Notice Other

abstract classes

(Rule E) Non-changed to abstract class abstract. Pre-existing binaries that attempt to create new instances of that class.

InstantiationError at link time, or InstantiationException at run time. Changing abstract classes to non- abstract does not break BC. final classes (Rule

F) Non-changed to final class final. Subclasses of that class.

VerifyError thrown at compile time. Changing final to non-final does not break BC.

Rule Change Affected Error/Notice Other

public classes

(Rule G) publicto non- class changed public. Pre-existing binary that needs but no longer has access to the class.

IllegalAccessError thrown at link

time. Changing non-public to public does not break BC.

Superclasses and

superinterfaces Class made a superclass of itself. Itself. ClassCircularityErrorload time. thrown at Changing direct superclasses does not break BC, provided the superclass loses no members.

To a direct superclass, resulting in any other class (including this one) to no longer being a superclass.

Various. Various link-time errors. See example in 13.4.4.

Class body and member

declarations

Deleting a class member or constructor that is

not declared private.

Binary using the member or constructor.

Linkage errors. Adding an instance/static member that has same name, access, signature and return type as a member of a superclass or subclass.

See 13.4.5 for further discussion.

Rule Change Affected Error/Notice Other

Access to members and constructors (Rule I)

Changing the declared access of a member to permit less access.

Pre-existing binaries

requiring access to this member.

Linkage errors when the binary is resolved. Access order – private < default < protected < public Also, changing member to be more accessible causes no linkage error when a subclass already defines a method to have less access.

Field declarations Adding a field to a class. Pre-existing

binaries that are not recompiled.

Linkage errors. See 13.4.7 for further discussion.

Rule Change Affected Error/Notice Other

final fields and

constants Non-changed to final fields final. Pre-existing binaries that attempt to assign values to that field.

IllegalAccessError thrown at

runtime. Changing to non-finalfinal or changing the initial value does not break BC. However, pre- existing binaries will have to be recompiled to see the new value. See 13.4.8 for further discussion.

static fields Non-private, non-

static fields changed to static. Pre-existing binary expecting a non- static field. IncompatibleClassChangeError thrown at link time.

transient fields Non-transient

changed to transient, or vice

versa.

Rule Change Affected Error/Notice Other Method and Constructor Declarations Adding a method to a subclass of a superclass that has a method referenced by a further subclass, where the new method is either less accessible than the old one or static (when the old one was not).

The lower subclass, making

the reference.

Linkage errors.

Deleting a method from

a class. Any pre-existing binary which referenced the method.

NoSuchMethodError thrown at

linking. Only thrown if no method with the deleted methods signature is found in a superclass. Creating a constructor

with no parameters, with less accessibility as the class of its declaration.

Pre-existing binaries

requesting the constructor.

IllegalAccessErrors thrown. The new constructor replaces the default one provided by the java compiler. This constructor had the same access as its enclosing class.

Rule Change Affected Error/Notice Other

Method and constructor

parameters

Changing the name of a method, the type of a formal parameter to that method, or adding or deleting a parameter. Pre-existing binaries requiring the method.

NoSuchMethodErrors thrown. Same as deleting the method and creating a new one.

Method result type Changing the type of a result, or changing a void to a type, or vice versa.

Pre-existing binaries

requiring the method.

NoSuchMethodErrors thrown. Same as deleting the method and creating a new one.

abstract methods Non-abstract

method changed to abstract. Pre-existing binaries invoking the method.

AbstractMethodErrors thrown. Changing an abstract

method to a non- abstract one does not break BC.

final methods Non-final method

changed to final. Existing binaries that depend on the ability to override this method.

VerifyError at runtime. Changing a static method from non-final to final does not break BC. Removing a final modifier does not break BC.

nativemethods Adding or deleting a

Rule Change Affected Error/Notice Other

static methods Non-private

static method changed to non- static.

Pre-existing

binaries that use this method.

IncompatibleClassChangeError thrown at link time.

synchronized

methods Adding or deleting a synchronized modifier.

None. None. Method and

constructor throws Changes to the clause of throw methods/constructors.

None. None. These clauses are

checked at compile time.

Method and

constructor body Changes to a body of a method/constructor. None. None. Method and

constructor overloading

Adding new methods or constructors that overload existing methods.

None. None. Does not break BC, as the signature of the method to be

used was determined at compile time – the new methods will not be used.

Rule Change Affected Error/Notice Other

Method overriding Class method added to a subclass, which overrides an existing method in a superclass.

Pre-existing

binaries that call the method.

The pre-existing binary will not find the

new method. The binary will find the method if the qualifying type is of the subclass type. Also a static method that overrides a method will be found, and the binary will be unaffected.

static intialisers Adding, deleting or changing a static initialiser.

None. None.

Table A 1 - Evolution of Classes

Documento similar