8131347: new @BeanProperty annotation: inconsistent behavior for "enumerationValues"
authorserb
Thu, 15 Dec 2016 20:09:13 +0300
changeset 42934 cd1c9fab50ca
parent 42933 96d0c48f3ebc
child 42935 b98bdba7ce61
8131347: new @BeanProperty annotation: inconsistent behavior for "enumerationValues" Reviewed-by: avstepan
jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java
jdk/test/java/beans/Introspector/8130937/TestBooleanBeanProperties.java
--- a/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Wed Dec 14 08:48:08 2016 -0800
+++ b/jdk/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java	Thu Dec 15 20:09:13 2016 +0300
@@ -183,9 +183,10 @@
             setShortDescription(description.toString());
         }
         Object values = info.get(PropertyInfo.Name.enumerationValues);
-        if (values != null) {
-            setValue(PropertyInfo.Name.enumerationValues.name(), values);
+        if (values == null) {
+            values = new Object[0];
         }
+        setValue(PropertyInfo.Name.enumerationValues.name(), values);
         this.baseName = base;
     }
 
--- a/jdk/test/java/beans/Introspector/8130937/TestBooleanBeanProperties.java	Wed Dec 14 08:48:08 2016 -0800
+++ b/jdk/test/java/beans/Introspector/8130937/TestBooleanBeanProperties.java	Thu Dec 15 20:09:13 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
 
 /**
  * @test
- * @bug 8130937
+ * @bug 8130937 8131347
  * @summary Tests the booleans properties of the BeanProperty annotation
  * @library ..
  */
@@ -76,6 +76,9 @@
         if (getValue(pd, "visualUpdate") != isVS) {
             throw new RuntimeException("required should be: " + isVS);
         }
+        if (pd.getValue("enumerationValues") == null) {
+            throw new RuntimeException("enumerationValues should be empty array");
+        }
     }
 
     private static boolean getValue(PropertyDescriptor pd, String value) {
@@ -107,7 +110,8 @@
         }
 
         @BeanProperty(bound = true, expert = true, hidden = true,
-                      preferred = true, required = true, visualUpdate = true)
+                      preferred = true, required = true, visualUpdate = true,
+                      enumerationValues = {})
         public void setValue(int value) {
             this.value = value;
         }