RFR: 8283700: Add final or sealed modifier to appropriate java.awt API classes

Rémi Forax forax at openjdk.java.net
Mon Mar 28 20:58:53 UTC 2022


On Mon, 28 Mar 2022 20:39:26 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> JDK 17 delivered JEP 409: Sealed Classes : https://openjdk.java.net/jeps/409
>> In essence this JEP allows a class to limit which classes can subclass it.
>> If a class has no subclasses and cannot be subclassed outside the JDK it can also be made final.
>> Suitable classes across the JDK are being retro-fitted to be sealed (or made final) where it can be done compatibly.
>> This fix takes care of several AWT classes which were identified.
>> If later we need to remove sealed or make a class non-final that will also be a compatible change,
>> so we aren't locking ourselves into this.
>> 
>> All our automated regression tests - plus JCK tests have been run.
>> 
>> This will require a CSR
>
> I wonder do we have some javac checks which may show some warnings related to these updated classes like not all subclasses are covered by the switch/unnecessary default branch/etc?

@mrserb, you mean to detect that you can not add a new subclass without breaking the source backward compatibility.
You can add a test that switch over all the cases with no "default", if a new subclass is added, the test will not compile anymore.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7998



More information about the client-libs-dev mailing list