RFR: 8339603: Seal the class hierarchy of Node, Camera, LightBase, Shape, Shape3D
Michael Strauß
mstrauss at openjdk.org
Thu Sep 5 17:48:08 UTC 2024
On Thu, 5 Sep 2024 17:24:50 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
> What is the benefit of this change?
It enforces a system invariant at compile-time instead of run-time.
> Also, this change is breaking. One can currently create a Node:
>
> ```
> public class CanCreateNode extends Application {
> @Override
> public void init() {
> Node n1 = new Node() {
> };
> class Yo extends Node {
> }
> Yo n2 = new Yo();
> }
> ```
You can't do anything meaningful with this node. As soon as you add it to a scene graph, you'll get a runtime exception. The fact that you can't extend `Node` is a system invariant, finding pathological situations in which you won't get an exception is just a loophole.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1556#issuecomment-2332310139
More information about the openjfx-dev
mailing list