The type of a field has been changed.
The type of the field type
in the class Vehicle
in the library project is changed from String
to int
.
public class Vehicle {
- public String type;
+ public int type;
}
Hereafter, we list the broken uses that are currently detected by Maracas.
The method displayType()
—defined in the VehicleInfo
class in a client project—accesses the type
field of a Vehicle
object and assigns its value to a variable of type String
.
Then, a broken use is reported pointing to the variable assignment.
public class VehicleInfo {
public static void displayType(Vehicle vehicle) {
// Broken use reported here
String type = vehicle.type;
System.out.println(type);
}
}
The method changeType()
—defined in the VehicleInfo
class in a client project—assigns a new String
value to the type
field of a Vehicle
object.
Then, a broken use is reported pointing to the field assignment.
public class VehicleInfo {
public static void changeType(Vehicle vehicle, String type) {
// Broken use reported here
vehicle.type = type;
}
}