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

8294550: Sealed check for casts isn't applied to array components #10490

Closed
wants to merge 1 commit into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Sep 29, 2022

For code like:

sealed interface I permits A {}
final class A implements I {}
interface J {}

J j = null;
I i = (I) j; //error reported here, as no instance of J can implement I
J[] jj = null;
I[] i = (I[]) jj; //incorrectly no error reported here, despite JLS saying there must be a narrowing conversion from J to I in this case, which there isn't as per the case above

The cause for this is that we check the sealed constraints at the end of Types.isCastable, and only for classes, not for arrays. It would be possible to enhance the check to include array types, but feels clearer and more reliable to recurse, and do a full castability check on the element types.

A sketch of a CSR is here:
https://bugs.openjdk.org/browse/JDK-8294586

Feedback is welcome!


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 a CSR request to be approved

Issues

  • JDK-8294550: Sealed check for casts isn't applied to array components
  • JDK-8294586: Sealed check for casts isn't applied to array components (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10490/head:pull/10490
$ git checkout pull/10490

Update a local copy of the PR:
$ git checkout pull/10490
$ git pull https://git.openjdk.org/jdk pull/10490/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10490

View PR using the GUI difftool:
$ git pr show -t 10490

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10490.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 29, 2022

👋 Welcome back jlahoda! 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 csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels Sep 29, 2022
@openjdk
Copy link

openjdk bot commented Sep 29, 2022

@lahodaj The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Sep 29, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 29, 2022

Webrevs

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

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

looks sensible

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Oct 7, 2022
@openjdk
Copy link

openjdk bot commented Oct 7, 2022

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

8294550: Sealed check for casts isn't applied to array components

Reviewed-by: vromero

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

  • 7e4868d: 8294847: Fix calculation of G1 effective scanned cards prediction
  • 2f60675: 8294997: Improve ECC math operations
  • 94caecb: 8294906: Memory leak in PKCS11 NSS TLS server
  • 03e63a2: 8295225: [JVMCI] codeStart should be cleared when entryPoint is cleared
  • 26ac836: 8291638: Keep-Alive timeout of 0 should close connection immediately
  • 6ae7e4d: 8293984: Unnecessary Vector usage in PropertyEditorSupport
  • cd1357b: 8295229: Try to verify gtest version
  • 90fb9a0: 8295102: Always load @lambda-form-invoker lines from default classlist
  • ac19414: 8294994: Update Jarsigner and Keytool i18n tests to validate i18n compliance
  • 1961e81: 8289509: Improve test coverage for XPath Axes: descendant, descendant-or-self, following, following-sibling
  • ... and 226 more: https://git.openjdk.org/jdk/compare/91a23d775fbf482244ace5758f7b3084ea564460...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 Pull request is ready to be integrated label Oct 7, 2022
@lahodaj
Copy link
Contributor Author

lahodaj commented Oct 20, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Oct 20, 2022

Going to push as commit 78dc497.
Since your change was applied there have been 345 commits pushed to the master branch:

  • c08ff2c: 8294705: Disable an assertion in test/jdk/java/util/DoubleStreamSums/CompensatedSums.java
  • d5a1521: 8295470: Update openjdk.java.net => openjdk.org URLs in test code
  • 9d0cfd1: 8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL
  • dcd4650: 8294916: Cancelling a request must eventually cause its response body subscriber to be unregistered
  • 4f994c0: 8295709: Linux AArch64 builds broken after JDK-8294438
  • 545021b: 8294438: Fix misleading-indentation warnings in hotspot
  • c5e0464: 8291456: com/sun/jdi/ClassUnloadEventTest.java failed with: Wrong number of class unload events: expected 10 got 4
  • 8d4c077: 8295302: Do not use ArrayList when LambdaForm has a single ClassData
  • 017e798: 8293939: Move continuation_enter_setup and friends
  • f872467: 8255746: Make PrintCompilation available on a per method level
  • ... and 335 more: https://git.openjdk.org/jdk/compare/91a23d775fbf482244ace5758f7b3084ea564460...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Oct 20, 2022

@lahodaj Pushed as commit 78dc497.

💡 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
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
2 participants