JDK-8308152 : PropertyDescriptor should work with overridden generic getter method
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 17.0.7,19,20,21
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2023-04-13
  • Updated: 2024-09-09
  • Resolved: 2023-06-08
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 11 JDK 17 JDK 21
11.0.26-oracleFixed 17.0.14-oracleFixed 21 b26Fixed
Related Reports
Duplicate :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 11, using NetBeans, JDK 19

A DESCRIPTION OF THE PROBLEM :
Please refer to https://github.com/apache/netbeans/issues/5774 for the original post, where I was advised to report this against OpenJDK

Attachments can be found in the above GitHub issue.

When creating a BeanInfo using netbeans, in the getBdescriptor() method, we can set the value "containerDelegate" using the following line of code to delegate to another container.

beanDescriptor.setValue("containerDelegate", "getInnerPanel");
These examples work with all previous JDK versions, except for JDK 19
I also tested JDK 13, 14, 15, 16, 17 and 18 and they all work fine.

REGRESSION : Last worked in version 17.0.6

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Having NetBeans installed, any version, 17 as reference.

Using the Dummy Projects ( From GitHub issue mentioned above)

With any new JPanel, or using MainPanel:

Drag or add a SectionPanel instance to MainPanel
Then add any other widget (i.e. JLabel) from the palette in the SectionPanel instance


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
SectionPanel should be recognized as a Container, therefore the widget should get added into the SectionPanel instance
ACTUAL -
SectionPanel is not recognized as a Container, and no other widget can be added to it when using the widgets palette in NetBeans

---------- BEGIN SOURCE ----------
Attached to https://github.com/apache/netbeans/issues/5774
---------- END SOURCE ----------

FREQUENCY : always



Comments
Fix request (17u) Clean backport. The bugfix for a regression. The fix was verified by the new test, all other "java_desktop" tests are green Review 17u-dev: https://github.com/openjdk/jdk17u-dev/pull/1501
27-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1501 Date: 2023-06-26 19:41:47 +0000
27-06-2023

Changeset: 73dd03cc Author: Sergey Bylokhov <serb@openjdk.org> Date: 2023-06-08 02:51:36 +0000 URL: https://git.openjdk.org/jdk/commit/73dd03cc5afa6d1e01a92d0027dcb82af27a48af
08-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14228 Date: 2023-05-30 19:13:42 +0000
31-05-2023

After integration of the JEP 256 we have two code paths to select the read/write methods for the property. The code path used by the Introspector via PropertyDescriptor(Entry<String,PropertyInfo> entry) can handle overridden getters, but the code path in PropertyDescriptor(String propertyName, Class<?> beanClass, String readMethodName, String writeMethodName) always select the first method.
26-05-2023

The bug can be reproduced by the next small code when the property descriptor is created w/o usage of Introspector new PropertyDescriptor("UI", JPanel.class, "getUI", "setUI"); Introspector works fine. BeanInfo beanInfo = Introspector.getBeanInfo(JPanel.class); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor pd : propertyDescriptors) { Class<?> propertyType = pd.getPropertyType(); if (propertyType !=null && propertyType.toString().contains("UI")) { System.out.println("pd = " + pd); } }
26-05-2023

It should not be important how we sort the methods in the code changed by the JDK-8280132, but instead, we should select the "correct" method later from that list, the fix should be similar to https://bugs.openjdk.org/browse/JDK-8196373 but this time for getters.
25-05-2023

The order of methods was changed in JDK-8280132, which led to this issue. https://github.com/apache/netbeans/issues/5774#issuecomment-1507539540
23-05-2023