-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8212895: ChronoField.INSTANT_SECONDS's range doesn't match the range of Instant #18674
Conversation
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
@jaikiran 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 131 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 |
Webrevs
|
Given that this is a observable change through a public API, I think a csr will be needed for this. I'll draft one shortly. |
/csr needed |
@jaikiran has indicated that a compatibility and specification (CSR) request is needed for this pull request. @jaikiran please create a CSR request for issue JDK-8212895 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
@@ -587,7 +587,8 @@ public enum ChronoField implements TemporalField { | |||
* This field is strictly defined to have the same meaning in all calendar systems. | |||
* This is necessary to ensure interoperation between calendars. | |||
*/ | |||
INSTANT_SECONDS("InstantSeconds", SECONDS, FOREVER, ValueRange.of(Long.MIN_VALUE, Long.MAX_VALUE)), | |||
// ValueRange matches the min and max epoch second supported by java.time.Instant |
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.
Would we want to include this in the javadoc?
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 code should reference the constants in Instant.java (though may need to make them package private.)
The javadoc can/should reference Instant.MIN and Instant.MAX (as the test does).
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.
Hello Roger,
The code should reference the constants in Instant.java (though may need to make them package private.)
The ChronoField
class and the Instant
class reside in separate packages, so making these two fields in Instant
, package private will not help. I will have to make them public, which I think probably isn't a good idea. Unless you think we should do it? There is one other place already in the JDK where we have copy/pasted these values src/java.base/share/classes/java/nio/file/attribute/FileTime.java
, so maybe we can continue with this copy/paste here too?
As for the javadoc, after we decide about this field access detail, I'll update it accordingly to note that the values min and max range complies with the min and max epoch seconds supported by Instant
.
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.
Should INSTANT_SECONDS("InstantSeconds", SECONDS, FOREVER, ValueRange.of(Instant.MIN.getEpochSecond(), Instant.MAX.getEpochSecond())),
work?
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.
Hello Naoto, that's a very good point. I was too caught up with the constant values that it didn't occur to me that the Instant.MIN
and Instant.MAX
public fields could be used for this. I have followed your suggestion and updated the PR. I have also updated the javadoc to link to Instant.MIN
and Instant.MAX
as the supported epoch second range.
The test continues to pass with this change and fails (as expected) without the source change.
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.
Good, that was going to be my backup suggestion; trying to avoid a method call even for the init. :)
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.
Thanks, Jai. The code change looks good. (Left a minor nit)
@@ -586,8 +586,11 @@ public enum ChronoField implements TemporalField { | |||
* <p> | |||
* This field is strictly defined to have the same meaning in all calendar systems. | |||
* This is necessary to ensure interoperation between calendars. | |||
* <p> | |||
* Range of {@code InstantSeconds} is between {@link Instant#MIN} and {@link Instant#MAX} |
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.
Nit: InstantSeconds
-> INSTANT_SECONDS
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.
Hello Naoto, I had used InstantSeconds
to keep it consistent with how a similar doc is used for the EPOCH_DAY
field. Let me know if you still prefer this to be INSTANT_SECONDS
and I will update it.
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.
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.
Hello Naoto, that's good point. I've updated the PR to remove {@code}
.
Now that the changes have been finalized, I'll raise the CSR tomorrow. |
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.
Looks good, Jai. Thanks for the fix!
I've now created the CSR https://bugs.openjdk.org/browse/JDK-8330135. I'll move it to Finalized once I get a review for it. |
The CSR for this has been approved. I'll integrate this PR tomorrow (around 24 hours from now). Naoto, Roger, should we consider a release note for this change or is the CSR itself enough? |
I think CSR is enough, as users' chance of encountering any issue is very slim. My $0.02 |
The CSR is enough, no-one else except the filer will even notice. |
Thank you Naoto and Roger for the inputs and the reviews. |
/integrate |
Going to push as commit 89129e3.
Your commit was automatically rebased without conflicts. |
Can I please get a review of this change which proposes to fix the issue noted in https://bugs.openjdk.org/browse/JDK-8212895?
As noted in that issue, the
ChronoField.INSTANT_SECONDS
currently is initialized to have a minimum and maximum values ofLong.MIN_VALUE
andLONG.MAX_VALUE
respectively. However,java.time.Instant
only supports-31557014167219200L
and31556889864403199L
as minimum and maximum values for the epoch second.The commit in this PR updates the
ChronoField.INSTANT_SECONDS
's value range to match the supported min and max values ofInstant
(as suggested by Stephen in that JBS issue). This commit also introduces a test to verify this change. This new test method as well as existing tests in tier1, tier2 and tier3 continue to pass with this change.Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18674/head:pull/18674
$ git checkout pull/18674
Update a local copy of the PR:
$ git checkout pull/18674
$ git pull https://git.openjdk.org/jdk.git pull/18674/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18674
View PR using the GUI difftool:
$ git pr show -t 18674
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18674.diff
Webrev
Link to Webrev Comment