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

8274363: Transitively sealed classes not considered exhaustive in switches #5717

Closed
wants to merge 3 commits into from

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Sep 27, 2021

Consider code like:

public class SwitchCoverage {
    sealed interface A {}
    sealed interface B1 extends A {}
    sealed interface B2 extends A {}
    sealed interface C extends A {}
    final class D1 implements B1, C {}
    final class D2 implements B2, C {}
    
    void test(A arg) {
        int i = switch (arg) {
            case B1 b1 -> 1;
            case B2 b2 -> 2;
        };
    }
    
} 

Note that B1 covers D1 and B2 covers D2. So, B1 and B2 cover C, and hence B1 and B2 cover A. To detect this, when looking for coverage of permitted types of A, we need to transitively look if any of the permitted type is covered.

The check uses the DeferredCompletionFailureHandler, because if don't want to fail the compilation on unresolvable permitted subclass. (In case the permitted subclass is covered by some other means, of course.)


Progress

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

Issue

  • JDK-8274363: Transitively sealed classes not considered exhaustive in switches

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5717/head:pull/5717
$ git checkout pull/5717

Update a local copy of the PR:
$ git checkout pull/5717
$ git pull https://git.openjdk.java.net/jdk pull/5717/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5717

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5717.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 27, 2021

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

Loading

@openjdk openjdk bot added the rfr label Sep 27, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Sep 27, 2021

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

Loading

@openjdk openjdk bot added the compiler label Sep 27, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Sep 27, 2021

Webrevs

Loading


if (hasAll && covered.add(sup.tsym)) {
if (sup.tsym.kind == TYP) {
if (isTransitivellyCovered(sup.tsym, covered) &&
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle Sep 27, 2021

Choose a reason for hiding this comment

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

typo: Transitively?

Loading

Copy link
Contributor

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

looks good to me

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Sep 27, 2021

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

8274363: Transitively sealed classes not considered exhaustive in switches

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

  • 2e690ba: 8274322: Problems with oopDesc construction
  • a8edd1b: 8274527: Minimal VM build fails after JDK-8273459
  • 7326481: 8274393: Suppress more warnings on non-serializable non-transient instance fields in security libs
  • 8215b2e: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs
  • 9573022: 8253197: vmTestbase/nsk/jvmti/StopThread/stopthrd007/TestDescription.java fails with "ERROR: DebuggeeSleepingThread: ThreadDeath lost"
  • f08180f: 8274501: c2i entry barriers read int as long on AArch64
  • c57ed22: 8274528: Add comment to explain an HKDF optimization in SSLSecretDerivation
  • 9180d9a: 8273216: JCMD does not work across container boundaries with Podman
  • 3e0d7c3: 8270290: NTLM authentication fails if HEAD request is used
  • bfd6163: 8274196: Crashes in VM_HeapDumper::work after JDK-8252842
  • ... and 182 more: https://git.openjdk.java.net/jdk/compare/14dc5178cf28c60a791502b9922879371493e925...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.

Loading

@openjdk openjdk bot added the ready label Sep 27, 2021
@lahodaj
Copy link
Contributor Author

@lahodaj lahodaj commented Oct 1, 2021

/integrate

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Oct 1, 2021

Going to push as commit 292d7bb.
Since your change was applied there have been 195 commits pushed to the master branch:

  • 1887028: 8269113: Javac throws when compiling switch (null)
  • b7b78ff: 8274561: sun/net/ftp/TestFtpTimeValue.java timed out on slow machines
  • 5e4b514: 8274550: c2i entry barriers read int as long on PPC
  • 2e690ba: 8274322: Problems with oopDesc construction
  • a8edd1b: 8274527: Minimal VM build fails after JDK-8273459
  • 7326481: 8274393: Suppress more warnings on non-serializable non-transient instance fields in security libs
  • 8215b2e: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs
  • 9573022: 8253197: vmTestbase/nsk/jvmti/StopThread/stopthrd007/TestDescription.java fails with "ERROR: DebuggeeSleepingThread: ThreadDeath lost"
  • f08180f: 8274501: c2i entry barriers read int as long on AArch64
  • c57ed22: 8274528: Add comment to explain an HKDF optimization in SSLSecretDerivation
  • ... and 185 more: https://git.openjdk.java.net/jdk/compare/14dc5178cf28c60a791502b9922879371493e925...master

Your commit was automatically rebased without conflicts.

Loading

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

@openjdk openjdk bot commented Oct 1, 2021

@lahodaj Pushed as commit 292d7bb.

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

Loading

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