The
final
modifier is added to the declaration of a library method.
The abstract class Vehicle
adds the final
modifier to the move
method.
Afterwards, the method’s body is removed.
public abstract class Vehicle {
- public void move() {
+ public final move() {
System.out.println("The vehicle is moving.");
}
}
Hereafter, we list the broken uses that are currently detected by Maracas.
(With or without the explicit use of the @Override
annotation)
The LanVehicle
class—declared in the in a client project—extends the Vehicle
class form the library.
It overrides the move
method coming from the Vehicle
class.
Then, a broken use is reported pointing to the method declaration given that the method cannot be overriden anymore.
public class LandVehicle extends Vehicle {
// Broken use reported here
@Override
public final move() {
System.out.println("The land vehicle is moving.");
}
}