Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

jaikiran
Copy link
Member

@jaikiran jaikiran commented Apr 8, 2024

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 of Long.MIN_VALUE and LONG.MAX_VALUE respectively. However, java.time.Instant only supports -31557014167219200L and 31556889864403199L 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 of Instant (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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8330135 to be approved

Issues

  • JDK-8212895: ChronoField.INSTANT_SECONDS's range doesn't match the range of Instant (Bug - P4)
  • JDK-8330135: ChronoField.INSTANT_SECONDS's range doesn't match the range of Instant (CSR)

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

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 8, 2024

👋 Welcome back jpai! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 8, 2024

@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:

8212895: ChronoField.INSTANT_SECONDS's range doesn't match the range of Instant

Reviewed-by: rriggs, naoto

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 master branch:

  • 76cbe48: 8329430: MetaspaceShared::preload_and_dump should clear pending exception
  • f7c8413: 8326116: JFR: Add help option to -XX:StartFlightRecording
  • 941bee1: 8327640: Allow NumberFormat strict parsing
  • 2ede143: 8330279: Typo in java.text.Bidi class description
  • 90df3b7: 8329190: (ch) DatagramChannel.receive should throw ClosedChannelException when called on closed channel
  • f11a496: 8180450: secondary_super_cache does not scale well
  • bfff02e: 8330165: C2: make superword consistently use PhaseIdealLoop::register_new_node()
  • e073d5b: 8329665: fatal error: memory leak: allocating without ResourceMark
  • 6e77d91: 8330261: Clean up linking steps
  • 61fa4d4: 8330351: Remove the SHARED_LIBRARY and STATIC_LIBRARY macros
  • ... and 121 more: https://git.openjdk.org/jdk/compare/d771ec6296bd3bb17ac2dd79671fdb6f154b4ea5...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 8, 2024
@openjdk
Copy link

openjdk bot commented Apr 8, 2024

@jaikiran The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

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.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Apr 8, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 8, 2024

Webrevs

@jaikiran
Copy link
Member Author

jaikiran commented Apr 8, 2024

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.

@jaikiran
Copy link
Member Author

jaikiran commented Apr 8, 2024

/csr needed

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Apr 8, 2024
@openjdk
Copy link

openjdk bot commented Apr 8, 2024

@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
Copy link
Member

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?

Copy link
Contributor

@RogerRiggs RogerRiggs Apr 8, 2024

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).

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Contributor

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. :)

Copy link
Member

@naotoj naotoj left a 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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: InstantSeconds -> INSTANT_SECONDS

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the @code tag, I initially thought it can be used programmatically, but apparently, it was simply an Enum name. Users may not notice it till they see the source (or run its toString()). I am fine with either way, but probably keep consistent with EPOCH_DAY where it is not using @code tag.

Copy link
Member Author

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}.

@jaikiran
Copy link
Member Author

Now that the changes have been finalized, I'll raise the CSR tomorrow.

Copy link
Member

@naotoj naotoj left a 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!

@jaikiran
Copy link
Member Author

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.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Apr 15, 2024
@jaikiran
Copy link
Member Author

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?

@naotoj
Copy link
Member

naotoj commented Apr 16, 2024

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

@RogerRiggs
Copy link
Contributor

The CSR is enough, no-one else except the filer will even notice.

@jaikiran
Copy link
Member Author

Thank you Naoto and Roger for the inputs and the reviews.

@jaikiran
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Apr 17, 2024

Going to push as commit 89129e3.
Since your change was applied there have been 149 commits pushed to the master branch:

  • 9445047: 8330163: C2: improve CMoveNode::Value() when condition is always true or false
  • d2f9a1e: Merge
  • 33d7127: 8322122: Enhance generation of addresses
  • 8de2f6f: 8319851: Improve exception logging
  • 0203c7e: 8318340: Improve RSA key implementations
  • 2885469: 8315708: Enhance HTTP/2 client usage
  • e4021ad: 8330272: Wrong javadoc for ValueLayout.JAVA_LONG/JAVA_DOUBLE on x86 32bit
  • 3ccbc6d: 8330280: SharedRuntime::get_resolved_entry should not return c2i entry if the callee is special native intrinsic
  • 7744b00: 8327946: containers/docker/TestJFREvents.java fails when host kernel config vm.swappiness=0 after JDK-8325139
  • 9d63fee: 8330262: C2: simplify transfer of GC barrier data from Ideal to Mach nodes
  • ... and 139 more: https://git.openjdk.org/jdk/compare/d771ec6296bd3bb17ac2dd79671fdb6f154b4ea5...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 17, 2024
@openjdk openjdk bot closed this Apr 17, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 17, 2024
@openjdk
Copy link

openjdk bot commented Apr 17, 2024

@jaikiran Pushed as commit 89129e3.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jaikiran jaikiran deleted the 8212895 branch April 17, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants