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

8277105: Inconsistent handling of missing permitted subclasses #6418

Closed
wants to merge 4 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Nov 16, 2021

Consider a sealed interface, when one (or more) of the permitted subtypes is not available.:

public abstract sealed class Lib permits Impl1, Impl2 {}
final class Impl1 extends Lib {}
final class Impl2 extends Lib {}

When compiling against this Lib, consider that Impl1 is missing. Then there is an inconsistency between cast and pattern switch in reported errors:

public class Test1 {
    public void test(Lib lib) {
        Runnable r = (Runnable) lib;
    }
}

$ javac -d out -classpath out --enable-preview -source 17 test/Test1.java
test/Test1.java:3: error: cannot access Impl1
        Runnable r = (Runnable) lib;
                     ^
  class file for Impl1 not found
1 error
public class Test2 {
    public void test(Lib lib) {
        switch (lib) {
            case Impl2 i -> {}
        }
    }
}

$ javac -d out -classpath out --enable-preview -source 17 test/Test2.java
test/Test2.java:3: error: the switch statement does not cover all possible input values
        switch (lib) {
        ^
Note: test/Test2.java uses preview features of Java SE 17.
Note: Recompile with -Xlint:preview for details.
1 error

The pattern matching switch tries to recover from the missing permitted subtype, but that is not right - it is generally not possible to determine reliably if a cast is valid, or a switch is exhaustive, when a permitted subtype is missing. So the "not found" error should be reported also for the pattern switch case.

The CompletionFailure still needs to be handled somehow in Flow, as there's nothing else that would catch the exception, and the compilation would fail with an exception if not handled.


Progress

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

Issue

  • JDK-8277105: Inconsistent handling of missing permitted subclasses

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6418

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 16, 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 16, 2021
@openjdk
Copy link

openjdk bot commented Nov 16, 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.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Nov 16, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 16, 2021

Webrevs

Copy link
Contributor

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

looks good

@openjdk
Copy link

openjdk bot commented Nov 18, 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:

8277105: Inconsistent handling of missing permitted subclasses

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

  • 286a26c: 8278277: G1: Simplify implementation of G1GCPhaseTimes::record_or_add_time_secs
  • d14f06a: 8278031: MultiThreadedRefCounter should not use relaxed atomic decrement
  • 8d190dd: 8277496: Remove duplication in c1 Block successor lists

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Nov 18, 2021
@lahodaj
Copy link
Contributor Author

lahodaj commented Dec 6, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Dec 6, 2021

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

  • adf3952: 8277372: Add getters for BOT and card table members
  • 7c6f57f: 8275610: C2: Object field load floats above its null check resulting in a segfault
  • a885aab: 8276125: RunThese24H.java SIGSEGV in JfrThreadGroup::thread_group_id
  • 6994d80: 8278291: compiler/uncommontrap/TraceDeoptimizationNoRealloc.java fails with release VMs after JDK-8154011
  • 286a26c: 8278277: G1: Simplify implementation of G1GCPhaseTimes::record_or_add_time_secs
  • d14f06a: 8278031: MultiThreadedRefCounter should not use relaxed atomic decrement
  • 8d190dd: 8277496: Remove duplication in c1 Block successor lists

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Dec 6, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 6, 2021
@openjdk
Copy link

openjdk bot commented Dec 6, 2021

@lahodaj Pushed as commit ab78187.

💡 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