-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8316557: Make fields final in 'sun.util' package #15736
Conversation
👋 Welcome back aturbanov! A progress list of the required criteria for merging this PR into |
@turbanoff The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
@@ -73,7 +68,7 @@ public CharsetEncoder newEncoder() { | |||
|
|||
private final class PropertiesFileDecoder extends CharsetDecoder { | |||
|
|||
private CharsetDecoder cdUTF_8 = UTF_8.INSTANCE.newDecoder() | |||
private final CharsetDecoder cdUTF_8 = UTF_8.INSTANCE.newDecoder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be static as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. Why do you think so? CharsetDecoder is not thread-safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UTF8 decoder does not perform any internal state mutation during decoding; in addition, if this field is static final, the decoder's error actions are published when the class is initialized, while publishing in a final field does not guarantee the internal state of the charset is visible to other threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UTF8 decoder does not perform any internal state mutation during decoding;
Are you sure? I think CharsetDecoder::decode
will modify the status
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, it does have a state
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CharsetDecoder is specified to be not safe for use by multiple concurrent threads, would be too fragile to assume behavior of a specific implementation.
Webrevs
|
@turbanoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Can I get a review? |
@@ -47,8 +45,8 @@ | |||
*/ | |||
public class CLDRCalendarDataProviderImpl extends CalendarDataProviderImpl { | |||
|
|||
private static Map<String, Integer> firstDay = new ConcurrentHashMap<>(); | |||
private static Map<String, Integer> minDays = new ConcurrentHashMap<>(); | |||
private static final Map<String, Integer> firstDay = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might rename these fields to FIRST_DAY etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Usually CAPS naming is used only on immutable constants, but here we have mutable field. (See google style guide for example - https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names).
I like old naming approach.
@@ -60,7 +60,7 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { | |||
private final LocaleDataMetaInfo nonBaseMetaInfo; | |||
|
|||
// parent locales map | |||
private static volatile Map<Locale, Locale> parentLocalesMap; | |||
private static final Map<Locale, Locale> parentLocalesMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to PARENT_LOCALES_MAP?
@@ -100,7 +100,7 @@ protected K normalizeKey(K key) { | |||
} | |||
|
|||
private static class CacheEntry<K, V> extends SoftReference<V> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class itself might be final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think making classes final
is out of scope of this PR.
@@ -31,9 +31,9 @@ | |||
package sun.util.locale; | |||
|
|||
public class StringTokenIterator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class may be final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. See comments though.
@turbanoff This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 862 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
rename 'firstDay' to 'firstDays' to match 'minDays' naming
@@ -47,8 +45,8 @@ | |||
*/ | |||
public class CLDRCalendarDataProviderImpl extends CalendarDataProviderImpl { | |||
|
|||
private static Map<String, Integer> firstDay = new ConcurrentHashMap<>(); | |||
private static Map<String, Integer> minDays = new ConcurrentHashMap<>(); | |||
private static final Map<String, Integer> firstDays = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct. "First Day" is the first day of the week and should not be plural.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The map contains several entries so I think the plural form is appropriate here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current naming highlights the difference in values in this maps: FIRST_DAY_OF_WEEK
vs MINIMAL_DAYS_IN_FIRST_WEEK
.
I like this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe firstDayMap
/minDaysMap
would clarify more, but either way is fine with me
"First Day" is the first day of the week and should not be plural
/integrate |
Going to push as commit 6c5e15c.
Your commit was automatically rebased without conflicts. |
@turbanoff Pushed as commit 6c5e15c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
A few classes in
sun.util
package have non-final fields which could easily be markedfinal
.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15736/head:pull/15736
$ git checkout pull/15736
Update a local copy of the PR:
$ git checkout pull/15736
$ git pull https://git.openjdk.org/jdk.git pull/15736/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15736
View PR using the GUI difftool:
$ git pr show -t 15736
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15736.diff
Webrev
Link to Webrev Comment