matthiasblaesing commented on issue #5774: URL: https://github.com/apache/netbeans/issues/5774#issuecomment-1564856713
@mrserb I reread your comment and still don't get it. > The order of methods returned by the "ClassInfo" should not affect the selection of "read" and "write" methods. It is just a "stable" wrapper over "Class.getMethods()" since the returned order is not specified and is random for that method. The order varies between JDK 17 and JDK 19: 17: ``` public javax.swing.plaf.PanelUI javax.swing.JPanel.getUI() public javax.swing.plaf.ComponentUI javax.swing.JPanel.getUI() ``` 19: ``` public javax.swing.plaf.ComponentUI javax.swing.JPanel.getUI() public javax.swing.plaf.PanelUI javax.swing.JPanel.getUI() ``` For both cases in the constructor of `PropertyDescriptor` `getReadMethod` is invoked, which more or less directly delegates to `Introspector#findMethod` which delegates to `Introspector#internalFindMethod`: https://github.com/openjdk/jdk/blob/a92363461dbe67d8736a6b0c3cbe1c3ad7aa28ae/src/java.desktop/share/classes/java/beans/Introspector.java#L1156-L1184 The first method, that has the right name and arguments is returned. And here is the difference between JDK 17 and 19 (see order above). For 17 you will get the getter, that returns `javax.swing.plaf.PanelUI` and for 19 you will get `javax.swing.plaf.ComponentUI`. Now execution returns to the `PropertyDescriptor` constructor and invokes `getWriteMethod`. It will first deduce the property type from the read method (the return type discussed in the previous paragraph) and now it tries to find the write method, that takes the property type as parameter. So for 17 it looks for `setUI(javax.swing.plaf.PanelUI)` and for 19 it will look for `setUI(javax.swing.plaf.ComponentUI)`. Only the former can be satisfied: ``` public void javax.swing.JPanel.setUI(javax.swing.plaf.PanelUI) ``` I still think, that the introspector is wrong. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
