The
final
modifier is added to the declaration of a library field.
The final
modifier is added to the declaration of the field name
in the library class Person
.
public class Person {
- public String name;
+ public final String name;
public Person(String name) {
this.name = name
}
}
Hereafter, we list the broken uses that are currently detected by Maracas.
The method addLastName
—defined in the PeopleInfo
class in a client project—accesses the name
field.
Then, a broken use is reported pointing to the field access expression given that the value of name
has already been initialized when instantiating the object.
public class PeopleInfo {
public void addLastName(Person person, String lastname) {
// Broken use reported here
person.name += " " + lastname;
}
}