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

8246788: ZoneRules invariants can be broken #2191

Closed

Conversation

@stuart-marks
Copy link
Member

@stuart-marks stuart-marks commented Jan 22, 2021

Tighten up argument checking in constructor.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2191/head:pull/2191
$ git checkout pull/2191

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 22, 2021

👋 Welcome back smarks! 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 openjdk bot added the rfr label Jan 22, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 22, 2021

@stuart-marks 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.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 22, 2021

Webrevs

@openjdk
Copy link

@openjdk openjdk bot commented Jan 22, 2021

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

8246788: ZoneRules invariants can be broken

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 31 new commits pushed to the master branch:

  • 0ea5862: 8260053: Optimize Tokens' use of Names
  • 18eb6d9: 8255348: NPE in PKIXCertPathValidator event logging code
  • a97f3c1: 8258853: Support separate function declaration and definition with ENABLE_IF-based SFINAE
  • 154e1d6: 8259009: G1 heap summary should be shown in "Heap Parameters" window on HSDB
  • acbcde8: 8256111: Create implementation for NSAccessibilityStaticText protocol
  • f928265: 8260009: InstanceKlass::has_as_permitted_subclass() fails if subclass was redefined
  • 7ed8ba1: 8256814: WeakProcessorPhases may be redundant
  • bfac3fb: 8260212: Shenandoah: resolve-only UpdateRefsMode is not used
  • 58ceb25: 8259842: Remove Result cache from StringCoding
  • d066f2b: 8260030: Improve stringStream buffer handling
  • ... and 21 more: https://git.openjdk.java.net/jdk/compare/35c9da70316da21a6be2fd92a5e5b5f193bdd9d6...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 ready label Jan 22, 2021
Object[] temp = lastRules.toArray();
ZoneOffsetTransitionRule[] rulesArray = Arrays.copyOf(temp, temp.length, ZoneOffsetTransitionRule[].class);
Comment on lines +262 to +263

This comment has been minimized.

@dfuch

dfuch Jan 22, 2021
Member

LGTM. Could be replaced by:

ZoneOffsetTransitionRule[] rulesArray = (ZoneOffsetTransitionRule[])lastRules.toArray(new ZoneOffsetTransitionRule[0]).clone();

if you wanted - but what you currently have is good for me.

This comment has been minimized.

@efge

efge Jan 22, 2021

Or even maybe rulesArray = lastRules.toArray(ZoneOffsetTransitionRule[]::new);?

This comment has been minimized.

@dfuch

dfuch Jan 22, 2021
Member

Good point - but that would be:

ZoneOffsetTransitionRule[] rulesArray = lastRules.toArray(ZoneOffsetTransitionRule[]::new).clone();

This comment has been minimized.

@stuart-marks

stuart-marks Jan 22, 2021
Author Member

Interesting. This last one is more concise, but it's a bit harder to reason about. The lastRules implementation could return an array of a type other than ZOTR[]. If it's unrelated or a supertype, this would result in ClassCastException -- probably not a problem. If it were a subtype of ZOTR[], this would get stored in the object's field. Is this a problem? Turns out it can't happen, since ZOTR is final. While not wrong, I don't think this is the right idiom.

It occurs to me that there should by another overload Arrays.copyOf(array, newType) that changes the type without changing the length. This would let us get rid of the local variable.

@naotoj
naotoj approved these changes Jan 22, 2021
@stuart-marks
Copy link
Member Author

@stuart-marks stuart-marks commented Jan 22, 2021

/integrate

@openjdk openjdk bot closed this Jan 22, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jan 22, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 22, 2021

@stuart-marks Since your change was applied there have been 34 commits pushed to the master branch:

  • 874aef4: 8259707: LDAP channel binding does not work with StartTLS extension
  • c5ad713: 8260250: Duplicate check in DebugInformationRecorder::recorders_frozen
  • bf5e801: 8259922: MethodHandles.collectArguments does not throw IAE if pos is outside the arity range
  • 0ea5862: 8260053: Optimize Tokens' use of Names
  • 18eb6d9: 8255348: NPE in PKIXCertPathValidator event logging code
  • a97f3c1: 8258853: Support separate function declaration and definition with ENABLE_IF-based SFINAE
  • 154e1d6: 8259009: G1 heap summary should be shown in "Heap Parameters" window on HSDB
  • acbcde8: 8256111: Create implementation for NSAccessibilityStaticText protocol
  • f928265: 8260009: InstanceKlass::has_as_permitted_subclass() fails if subclass was redefined
  • 7ed8ba1: 8256814: WeakProcessorPhases may be redundant
  • ... and 24 more: https://git.openjdk.java.net/jdk/compare/35c9da70316da21a6be2fd92a5e5b5f193bdd9d6...master

Your commit was automatically rebased without conflicts.

Pushed as commit a887177.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants