Next: Tagging and exception handling
Up: Other Changes
Previous: Other Changes
Checking constraints
The incompatible changes in this category are handled by maintaining constraints either explicitly or implicitly, and checking them against the loaded classes during class loading. When any of the constraints are violated, exceptions are raised (VerifyError
, ClassCircularityError
, InstantiationError
, etc).
- (20,41) When compiling a class, we add a constraint for every upward
cast indicating the expected inheritance relationship. During execution, we
have the system maintain all the constraints specified by the currently
loaded classes. When a class is loaded, we check its constraints against the loaded class hierarchy. We also check the newly loaded class against the constraints maintained by the system.
- (21) If the class hierarchy becomes circular due to incompatible changes, we can detect it during class loading.
- (22) If a class inherits a nonfinal class , and is changed to be final, we can detect it during the loading of class .
- (23) Abstract classes cannot be used to create instances.
Similar to what we did for upward casts, we add a constraint for every instance creation indicating that the class being instantiated cannot be an abstract class. These constraints are checked during class loading.
Next: Tagging and exception handling
Up: Other Changes
Previous: Other Changes
Dachuan Yu
2002-05-23