RFR: JDK-8304959: Public API in javafx.css.Match should not return private API class PseudoClassState [v7]
John Hendrikx
jhendrikx at openjdk.org
Wed May 17 22:15:58 UTC 2023
On Wed, 17 May 2023 21:22:15 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> John Hendrikx has updated the pull request incrementally with three additional commits since the last revision:
>>
>> - Override hashCode with a comment explaining why
>> - Fix style issues
>> - Restore removed public method
>
> modules/javafx.graphics/src/main/java/javafx/css/Match.java line 54:
>
>> 52: final int specificity;
>> 53:
>> 54: Match(final Selector selector, Set<PseudoClass> pseudoClasses, int idCount, int styleClassCount) {
>
> just curious: do we really need a 'final' for an effectively final argument?
`final` here will just warn you if you try to reassign the parameter. It was present in the original code.
Reassigning locals and parameters should generally be avoided. For the first, you can have your IDE generate a warning or error. For the second, I have the habit of always assigning a variable when it is declared. In the rare cases where this can't be done, the `final` keyword offers little benefit.
The keyword does not offer any further benefits on parameters and locals, and it hasn't since Java added the concept of effectively final (in Java 8 I think). Before this, you sometimes needed to add `final` so a local could be referred to in anonymous subclasses.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1070#discussion_r1197105574
More information about the openjfx-dev
mailing list