On Sun, 18 Sep 2022 21:23:12 GMT, SWinxy <d...@openjdk.org> wrote:

> `JRSUIUtils.java` structurally does things weirdly. The utility class mostly 
> passes parameters from functions to other functions. The indirection makes 
> things harder to understand the eventual purpose.
> 
> Take `AquaInternalFrameBorderMetrics.java`. It has a `static boolean` that 
> caches a call to `shouldUseLegacyBorderMetrics()`, which returns 
> `isSnowLeopardOrBelow`, itself a cached call to 
> `isMacOSXSnowLeopardOrBelow()`, which is what finally calls 
> `currentMacOSXVersionMatchesGivenVersionRange()`. When looking at the code, 
> it takes time to unravel the path it takes. Instead of that, a `public static 
> final boolean` can expose the cached value and, in doing so, exposes the 
> *meaning* behind the check.
> 
> In `AquaLookAndFeel.java`, the value of `TabbedPaneUI` is calculated using 
> `JRSUIUtils.TabbedPane.shouldUseTabbedPaneContrastUI()`, but that could mean 
> any reason for why `"AquaTabbedPaneContrastUI"` may be the value as opposed 
> to `"AquaTabbedPaneUI"`. Replacing it with `JRSUIUtils.isSnowLeopardOrBelow` 
> reveals that it actually has to do with the OS version being, well, Snow 
> Leopard or below.
> 
> These change makes understanding the code easier and quicker. Also more 
> optimized.
> 
> Changes:
> * add JRSUIConstants.ScrollBarPart.ordinal() to return the property's ordinal 
> value, which is not public
> * change 3 access modifiers in JRSUIControl to public allowing for access 
> outside the package
> * JRSUIConstants.NineSliceMetricsProvider changed to a normal Function<>
> * cache `isMacOSXBigSurOrAbove` rather than calling it twice
> * inline the functions for clarity
> * change static initialization to group all version checks together
> * document JRSUIUtils

https://bugs.openjdk.org/browse/JDK-8298352

I suggest you mark this as draft before linking it to the entry in the system 
though. Trust me when I say you do not want an unfinished change reaching the 
mailing lists, especially with so many test failures

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

PR: https://git.openjdk.org/jdk/pull/10326

Reply via email to