RFR: 8299513: Clean up java.io [v9]
Stuart Marks
smarks at openjdk.org
Thu Jan 12 00:16:16 UTC 2023
On Wed, 11 Jan 2023 15:31:22 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> Code in java.io contains many legacy constructs and semantics not recommended including:
>>
>> * C-style array declaration
>> * Unnecessary visibility
>> * Redundant keywords in interfaces (e.g. public, static)
>> * Non-standard naming for constants
>> * Javadoc typos
>> * Missing final declaration
>>
>> These should be fixed as a sanity effort.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Convert field to static and revert copyright year
Some general comments on this PR. It contains a lot of different changes, all mixed together. Some of the changes have more value than others, but since they're all mixed together it can be hard to tease them apart.
Some changes, like anachronistic array declarations (e.g., `int foo[]` instead of `int[] foo`) clearly need to be done. Fixing constants to have CAPITALIZED_SNAKE_CASE is also fairly straightforward and should be done too.
Some renamings are a bit dubious, e.g. `U` => `UNSAFE` in one case. OK well sure `U` might look like a type variable, but in context it was quite clear that `U` was the Unsafe instance. However, renaming to `UNSAFE` isn't necessarily bad, so maybe this is ok.
Some nested classes had `final` added. I'm not sure of the utility of this. Is there some general rule that "everything that can be declared final should be" ? This isn't quite as bad people who insist on declaring every local variable as final, but it seems to be edging in that direction -- specifically, adding clutter without adding value.
In some cases removing `static final` from constants that are declared in interfaces seems like a step in the wrong directly. Formally, an interface that contains a field initialized to a constant expression is public, static, and final. (JLS 9.3.) I think most people accept that it's not necessary to declare everything (redundantly) public in an interface. But it seems to be conventional to have static and final present on the declaration even though they're arguably redundant as well. I'm not sure why this is nor why static and final aren't treated the same way as public. At least, I don't feel the same way about them.
-------------
PR: https://git.openjdk.org/jdk/pull/11848
More information about the core-libs-dev
mailing list