Class SealedShouldHavePermitsListCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class SealedShouldHavePermitsListCheck
    extends AbstractCheck
    Checks that sealed classes and interfaces have a permits list.

    Rationale: When a permits clause is omitted from a sealed class, any class within the same compilation unit can extend it. This differs from other sealed classes where permitted subclasses are explicitly declared, making them readily visible to the reader. Without a permits clause, identifying potential subclasses requires searching the entire compilation unit, which can be challenging, especially in large files with complex class hierarchies.

    See the Java Language Specification for more information about sealed classes.

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • sealed.should.have.permits
    Since:
    10.18.0