JDK-8131939 : @BeanProperty "required" info is lost; data duplication for "expert" and "hidden"
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-07-20
  • Updated: 2016-05-12
  • Resolved: 2015-09-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Please run:

import java.beans.BeanInfo;
import java.beans.BeanProperty;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.Iterator;

public class Test {
    
    public class C {
        
        private int value;

        @BeanProperty(
                bound     = true,
                expert    = true,
                hidden    = true,
                preferred = true,
                required  = true,
                visualUpdate = true,
                description = "OTHER",
                enumerationValues = {"javax.swing.SwingConstants.EAST"}
                )
        public void setValue(int v) { value = v; }
        public  int getValue()      { return value; }
    }
    
    public static void main(String[] args) throws IntrospectionException {
        
        BeanInfo i = Introspector.getBeanInfo(C.class, Object.class);
        PropertyDescriptor d = i.getPropertyDescriptors()[0];

        Iterator<String> it = d.attributeNames().asIterator();
        while (it.hasNext()) {
            String key = it.next();
            System.out.println(key + ": " + d.getValue(key));
        }
        
        System.out.println("---");
        System.out.println(d.isExpert());
        System.out.println(d.isHidden());
    }
}

Output (JDK9 b72, Win 7):

expert: true
visualUpdate: true
hidden: true
enumerationValues: [Ljava.lang.Object;@3ada9e37
---
true
true

So:
1. the "required" info is lost (we do not have d.isRequired() and d.getValue("required") is obviously null)
2. the "expert" and "hidden" info is duplicated
Comments
The required and visualUpdate were fixed in JDK-8130937. The duplicate of hiddent and expert is intentional. isHidden/etc are old methods which we cannot removed.
13-09-2015

Sorry, incorrect expression. That means only that we can obtain them in two ways: 1. using d.getValue("expert"), d.getValue("hidden") 2. using boolean d.isExpert() and d.isHidden() methods. Does it mean duplication of the stored data? Even if no, it may cause some mess (but this is a cavil, of course).
18-08-2015

Can you provide an additional info what "the "expert" and "hidden" info is duplicated " mean?
18-08-2015

visualUpdate is lost sometimes too: In case if "visualUpdate = false" inside of @BeanProperty, d.getValue("visualUpdate") returns null instead of "false".
22-07-2015

You can also add "R.class" to the "types" array in "main" for jdk/test/java/beans/Introspector/4058433/TestBeanProperty.java, - it will fail
20-07-2015