jdk icon indicating copy to clipboard operation
jdk copied to clipboard

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

Open lahodaj opened this issue 3 years ago • 4 comments

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

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [x] 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

lahodaj avatar Sep 29 '22 14:09 lahodaj

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

bridgekeeper[bot] avatar Sep 29 '22 14:09 bridgekeeper[bot]

@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[bot] avatar Sep 29 '22 14:09 openjdk[bot]

Webrevs

mlbridge[bot] avatar Sep 29 '22 14:09 mlbridge[bot]

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

  • 7e4868de7b0d3c20a35f06671ec0b68cfd441793: 8294847: Fix calculation of G1 effective scanned cards prediction
  • 2f60675e06801b8ee495729d8bff2faec37ce509: 8294997: Improve ECC math operations
  • 94caecbe574227b232e22d9f56361f8ecd507be6: 8294906: Memory leak in PKCS11 NSS TLS server
  • 03e63a2b87e1bef6025722ec9a016312c55ebd81: 8295225: [JVMCI] codeStart should be cleared when entryPoint is cleared
  • 26ac8366360685ef0cf3447ee7db16ba7a7fa1ec: 8291638: Keep-Alive timeout of 0 should close connection immediately
  • 6ae7e4d4aad5712cf2fe6ab9f98dc424fa4170cb: 8293984: Unnecessary Vector usage in PropertyEditorSupport
  • cd1357b0af0d4e3b459fcf88e67510502464bb90: 8295229: Try to verify gtest version
  • 90fb9a085bbaa9d1928a1cec9f00098b80577721: 8295102: Always load @lambda-form-invoker lines from default classlist
  • ac1941425bdb1a25aa3364eef9eb1092ee716761: 8294994: Update Jarsigner and Keytool i18n tests to validate i18n compliance
  • 1961e81e02e707cd0c8241aa3af6ddabf7668589: 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[bot] avatar Oct 07 '22 22:10 openjdk[bot]

/integrate

lahodaj avatar Oct 20 '22 12:10 lahodaj

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

  • c08ff2c7b88e94885f6b4701654a9e47e49567b0: 8294705: Disable an assertion in test/jdk/java/util/DoubleStreamSums/CompensatedSums.java
  • d5a1521fde3f6ff7e810e8257a4722a09c9ef60b: 8295470: Update openjdk.java.net => openjdk.org URLs in test code
  • 9d0cfd1130b63f7acd67a52eb35c1ec38d43e514: 8294948: Document IllegalArgumentException and NullPointerException thrown by URLStreamHandler::parseURL and URLStreamHandler::setURL
  • dcd46501e6a25ac875d61bfbd412555b933ce34c: 8294916: Cancelling a request must eventually cause its response body subscriber to be unregistered
  • 4f994c037023603bb1d1d94ad97aeb01ac604ebd: 8295709: Linux AArch64 builds broken after JDK-8294438
  • 545021b18d6f82ac8013009939ef4e05b8ebf7ce: 8294438: Fix misleading-indentation warnings in hotspot
  • c5e0464098f8f7cd9c568c7b1c3a06139453eaab: 8291456: com/sun/jdi/ClassUnloadEventTest.java failed with: Wrong number of class unload events: expected 10 got 4
  • 8d4c077218748d37617fc1bdb537a165706a5849: 8295302: Do not use ArrayList when LambdaForm has a single ClassData
  • 017e7988b197427f6b464303788a418a1d892ab9: 8293939: Move continuation_enter_setup and friends
  • f872467d69a6d8442f8004609ce819641cab568b: 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[bot] avatar Oct 20 '22 13:10 openjdk[bot]

@lahodaj Pushed as commit 78dc4977863a92f990b355f6b4d2609a674ab19b.

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

openjdk[bot] avatar Oct 20 '22 13:10 openjdk[bot]