8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec
authorserb
Wed, 03 Jun 2015 23:17:52 +0300
changeset 31166 6448eff013a8
parent 31165 42e11a4250b7
child 31167 4fe9ebd79f86
8076312: The behavior of the javax.swing.SwingContainer.delegate contradicts spec Reviewed-by: alexsch, malenkov
jdk/src/java.desktop/share/classes/java/beans/BeanDescriptor.java
jdk/test/java/beans/Introspector/4058433/TestSwingContainer.java
--- a/jdk/src/java.desktop/share/classes/java/beans/BeanDescriptor.java	Wed Jun 03 18:45:27 2015 +0400
+++ b/jdk/src/java.desktop/share/classes/java/beans/BeanDescriptor.java	Wed Jun 03 23:17:52 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, 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
@@ -81,10 +81,7 @@
         SwingContainer container = beanClass.getAnnotation(SwingContainer.class);
         if (container != null) {
             setValue("isContainer", container.value());
-            String delegate = container.delegate();
-            if (!delegate.isEmpty()) {
-                setValue("containerDelegate", delegate);
-            }
+            setValue("containerDelegate", container.delegate());
         }
     }
 
--- a/jdk/test/java/beans/Introspector/4058433/TestSwingContainer.java	Wed Jun 03 18:45:27 2015 +0400
+++ b/jdk/test/java/beans/Introspector/4058433/TestSwingContainer.java	Wed Jun 03 23:17:52 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -20,24 +20,31 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 import java.beans.BeanDescriptor;
 import java.beans.BeanInfo;
 import java.beans.Introspector;
 import java.util.Objects;
 import javax.swing.SwingContainer;
-/*
+
+/**
  * @test
  * @bug 4058433
  * @summary Tests the SwingContainer annotation
  * @author Sergey Malenkov
  */
 public class TestSwingContainer {
+
     public static void main(String[] args) throws Exception {
         test(X.class, null, null);
-        test(T.class, true, null);
-        test(D.class, true, "method");
-        test(F.class, false, null);
-        test(A.class, false, "method");
+        test(H.class, true, "");
+        test(G.class, true, "");
+        test(F.class, true, "method");
+        test(E.class, false, "");
+        test(D.class, false, "");
+        test(C.class, true, "");
+        test(B.class, false, "method");
+        test(A.class, true, "method");
     }
 
     private static void test(Class<?> type, Object iC, Object cD) throws Exception {
@@ -50,7 +57,7 @@
 
     private static void test(BeanDescriptor bd, String name, Object expected) {
         Object value = bd.getValue(name);
-        System.out.println(name + " = " + value);
+        System.out.println("\t" + name + " = " + value);
         if (!Objects.equals(value, expected)) {
             throw new Error(name + ": expected = " + expected + "; actual = " + value);
         }
@@ -60,18 +67,34 @@
     }
 
     @SwingContainer()
-    public static class T {
+    public static class H {
+    }
+
+    @SwingContainer(delegate = "")
+    public static class G {
     }
 
     @SwingContainer(delegate = "method")
-    public static class D {
+    public static class F {
     }
 
     @SwingContainer(false)
-    public static class F {
+    public static class E {
+    }
+
+    @SwingContainer(value = false, delegate = "")
+    public static class D {
+    }
+
+    @SwingContainer(value = true, delegate = "")
+    public static class C {
     }
 
     @SwingContainer(value = false, delegate = "method")
+    public static class B {
+    }
+
+    @SwingContainer(value = true, delegate = "method")
     public static class A {
     }
 }