changeset 9866:11ac266f4614 jdk-9+125

8158004: Node, Shape and Shape3D need meaningful runtime exception message when application directly extends these classes Reviewed-by: kcr
author ckyang
date Fri, 24 Jun 2016 13:29:28 -0700
parents 666b129d7bd0
children 88f278b168d9 3597495167c7
files modules/graphics/src/main/java/com/sun/javafx/scene/CameraHelper.java modules/graphics/src/main/java/com/sun/javafx/scene/LightBaseHelper.java modules/graphics/src/main/java/com/sun/javafx/scene/NodeHelper.java
diffstat 3 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/scene/CameraHelper.java	Sat Jun 25 00:27:26 2016 +0530
+++ b/modules/graphics/src/main/java/com/sun/javafx/scene/CameraHelper.java	Fri Jun 24 13:29:28 2016 -0700
@@ -59,7 +59,7 @@
 
     @Override
     protected NGNode createPeerImpl(Node node) {
-        throw new UnsupportedOperationException("Application should not extend Camera class directly.");
+        throw new UnsupportedOperationException("Applications should not extend the Camera class directly.");
     }
 
     @Override
--- a/modules/graphics/src/main/java/com/sun/javafx/scene/LightBaseHelper.java	Sat Jun 25 00:27:26 2016 +0530
+++ b/modules/graphics/src/main/java/com/sun/javafx/scene/LightBaseHelper.java	Fri Jun 24 13:29:28 2016 -0700
@@ -57,7 +57,7 @@
 
     @Override
     protected NGNode createPeerImpl(Node node) {
-        throw new UnsupportedOperationException("Application should not extend LightBase class directly.");
+        throw new UnsupportedOperationException("Applications should not extend the LightBase class directly.");
     }
 
     @Override
--- a/modules/graphics/src/main/java/com/sun/javafx/scene/NodeHelper.java	Sat Jun 25 00:27:26 2016 +0530
+++ b/modules/graphics/src/main/java/com/sun/javafx/scene/NodeHelper.java	Fri Jun 24 13:29:28 2016 -0700
@@ -46,6 +46,8 @@
 import javafx.geometry.Bounds;
 import javafx.scene.Node;
 import javafx.scene.SubScene;
+import javafx.scene.shape.Shape;
+import javafx.scene.shape.Shape3D;
 
 /**
  * Used to access internal methods of Node.
@@ -61,7 +63,23 @@
     }
 
     protected static NodeHelper getHelper(Node node) {
-        return nodeAccessor.getHelper(node);
+
+        NodeHelper helper = nodeAccessor.getHelper(node);
+        if (helper == null) {
+            String nodeType;
+            if (node instanceof Shape) {
+                nodeType = "Shape";
+            } else if (node instanceof Shape3D) {
+                nodeType = "Shape3D";
+            } else {
+                nodeType = "Node";
+            }
+
+            throw new UnsupportedOperationException(
+                    "Applications should not extend the "
+                    + nodeType + " class directly.");
+        }
+        return helper;
     }
 
     protected static void setHelper(Node node, NodeHelper nodeHelper) {