RFR: 8323965: modify fix for 8317771 to remove reflection instantiation of the inner class

Artem Semenov asemenov at openjdk.org
Mon Apr 22 10:00:29 UTC 2024


On Fri, 19 Apr 2024 20:24:38 GMT, Chen Liang <liach at openjdk.org> wrote:

>> I replaced reflection with using an accessor
>> @azuev-java please review
>
> src/java.desktop/share/classes/sun/swing/SwingAccessor.java line 331:
> 
>> 329:         var access = accessibleJTreeNodeCreateAccessor;
>> 330:         if (access == null) {
>> 331:             ensureClassInitialized(JTree.class);
> 
> This probably doesn't work as JTree class initialization does not seem to trigger AccessibleJTree class initialization. The other one for AccessibleJTreeNode is dubious too, maybe it just happens that all accesses are correctly made only after the related classes are initialized.

This line calls the ```ensureClassInitialized()``` method, which performs a full initialization of the class... It calls: ```MethodHandles.lookup().ensureInitialized()```, which, as stated in the documentation , performs a full initialization.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18867#discussion_r1574478565


More information about the client-libs-dev mailing list