RFR: 8339603: Seal the class hierarchy of Node, Camera, LightBase, Shape, Shape3D
Kevin Rushforth
kcr at openjdk.org
Fri Sep 6 15:15:11 UTC 2024
On Thu, 5 Sep 2024 12:01:23 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> None of these classes can be extended by user code, and any attempt to do so will fail at runtime with an exception. For this reason, we can seal the class hierarchy and remove the run-time checks to turn this into a compile-time error instead.
>
> In some cases, `Node` and `Shape` are extended by JavaFX classes in other modules, preventing those derived classes from being permitted subclasses. A non-exported `AbstractNode` and `AbstractShape` class is provided just for these scenarios. Note that introducing a new superclass is a source- and binary-compatible change (see [JLS ch. 13](https://docs.oracle.com/javase/specs/jls/se22/html/jls-13.html)).
>
> I'm not sure if this change requires a CSR, as it doesn't change the specification in any meaningful way. There can be no valid JavaFX program that is affected by this change.
If this PR goes forward, it will need a CSR, since it does impact source code compatibility. As you point out, you can't usefully extend Node today, since you will get a runtime exception as soon as you try to create an instance of a subclassed Node, so what this does is move a runtime error to compile time. That's generally a good thing, but..is it worth doing? We can continue to discuss.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1556#issuecomment-2334276448
More information about the openjfx-dev
mailing list