On Sat, 11 May 2024 17:37:08 GMT, Alexander Scherbatiy <alex...@openjdk.org> wrote:
>> @AlexanderScherbatiy did you see the comment in the CSR about sealed classes >> ? >> I had originally suggested in this PR (search for a comment from a while >> ago) and I don't know if you saw it there either. > > @prrace > > I have updated the fix to make the `OutputBin` class sealed and > `CustomOutputBin` class final. > The `OutputBin` class permits internal `sun.print.CustomOutputBin` class. > The `OutputBin` javadoc that `Implementation- or site-defined names for an > output bin kind attribute may also be created by defining a subclass of class > {@code OutputBin}.` is removed. > If it is an applicable change I will update the CSR as well. > > @AlexanderScherbatiy did you see the comment in the CSR about sealed > > classes ? > > I had originally suggested in this PR (search for a comment from a while > > ago) and I don't know if you saw it there either. > > @prrace There are two things which are not clear for me. > > The first one is that a user can extend `OutputBin` class and provide its own > implementation. Should it be possible to the user provide output bins other > than supported ones? > > The another question relates to `CustomOutputBin` class which is used to > provide a list of supported output bins and which is not public. To make > `OutputBin` class sealed it needs to add `CustomOutputBin` class to > `OutputBin` class permits list: > > ``` > public sealed class OutputBin extends EnumSyntax implements > PrintRequestAttribute, PrintJobAttribute > permits sun.print.CustomOutputBin { > } > > public final class CustomOutputBin extends OutputBin { > } > ``` > > Is it good to use a non public class in the public class permits list? > > I made docs for the jdk with sealed `OutputBin` class. It has the `sealed` > keyword in the javadoc but mentions nothing about internal `CustomOutputBin` > class. > `images/docs/api/java.desktop/javax/print/attribute/standard/OutputBin.html`: > > ``` > public sealed class OutputBin > extends EnumSyntax > implements PrintRequestAttribute, PrintJobAttribute > ``` javadoc knows to not list the permitted class unless it is exported as public API, so it is fine. "Users" should not need to to sub-class OutputBin, the JDK implementation will do this when it finds a printer. If we ever find a use-case that really demands it, the class can be unsealed. "sealing" is like "final" in this regard. You can remove it, but typically you can't add it later. I wish we'd had sealing 20 years ago .. ------------- PR Comment: https://git.openjdk.org/jdk/pull/16166#issuecomment-2105980495