News for hackers. Stuff that matters.
Re: by pron on Sunday January 29, 2023 @06:09AM (#34567015)
Of course they can! They can implement interfaces, which are sealed. In fact, that's one of their most common usages:

    sealed interface Option { 
        record InputFile(Path path) implements Option {}
        record OutputFile(Path path) implements Option {}
        record MaxLines(int maxLines) implements Option {}
        record PrintLineNumbers() implements Option {}
    }
(see https://www.infoq.com/articles/data-oriented-programming-jav...)

The problem of extending classes is that it can introduce hidden state and also result in non-reflexive equality. But interfaces are fine.

Re: by sixbrx on Sunday January 29, 2023 @07:48AM (#34567608)
Thanks for that, I knew I must have been missing something!