The visibility of a library class is decreased by modifying its access modifier.
The public access modifier of the top-level Person class in the library project has been removed.
-public class Person { }
+class Person { }
Hereafter, we list the broken uses that are currently detected by Maracas.
The public access modifier of the inner Person class in the library project is changed to private.
public Organization {
- public class Person { }
+ private class Person { }
}
The Team class—defined in a client project—declares the members field of type List<Organization.Person>.
The constructor of the class receives a list of Organization.Person objects as parameter.
Then, broken uses are reported pointing to the field declaration and the constructor declaration.
public class Team {
// Broken use reported here
List<Organization.Person> members;
// Broken use reported here
public Team(List<Organization.Person> members) {
this.members = members;
}
}
The public access modifier of the top-level Person class in the library project has been removed.
-public class Person { }
+class Person { }
The Team class—defined in a client project—declares the members field of type List<Person>.
The constructor of the class receives a list of Person objects as parameter.
Then, broken uses are reported pointing to the field declaration and the constructor declaration given that the Team class is not located in the same package as the Person class.
public class Team {
// Broken use reported here
List<Person> members;
// Broken use reported here
public Team(List<Person> members) {
this.members = members;
}
}
The public access modifier of the inner Person class in the library project is changed to protected.
public Organization {
- public class Person { }
+ protected class Person { }
}
The Team class—defined in a client project—declares the members field of type List<Organization.Person>.
The constructor of the class receives a list of Organization.Person objects as parameter.
Then, broken uses are reported pointing to the field declaration and the constructor declaration given that the Team class is not a subtype of Organization.
public class Team {
// Broken use reported here
List<Person> members;
// Broken use reported here
public Team(List<Person> members) {
this.members = members;
}
}