Synopsis: | Avoid protected fields in a final class. Change to private or package access |
Language: | Java |
Severity Level: | 2 |
Category: | Design |
Description: |
Do not use protected fields in final classes since they cannot be subclassed.
Clarify your intent by using private or package access modifiers instead.public final class Bar { private int x; protected int y; // <-- Bar cannot be subclassed, so is y really private or package visible??? Bar() {} } |