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

8178701: Compile error with switch statement on protected enum defined in parent inner class #7621

Closed
wants to merge 3 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Feb 25, 2022

Consider the following code in two packages:

package foo;

import bar.D.E;

public class A {

    public static class B {

        protected enum C {
            X, Y, Z
        }
    }

    public static void main(String... args) {
        new E().run(B.C.X);
    }
}
package bar;

import foo.A.B;

public class D {

    public static class E extends B {

        public void run(C arg) {
            switch (arg) {
                default:
                    System.out.println("OK");
            }
        }
    }
}

Accessing foo.A.B.C in bar.D.E is OK, as it is accessible through the E's superclass. But, for the switch, javac creates a map (array) from runtime ordinals of constants of E to compile-time positions. But, this mapping is in a different class that does not extend B, so internal method lookups fail for it, as the methods are not accessible per Java rules.

But, at runtime, the enum class is effectively public, so I think it is possible to ignore the protected access rules and accept the method invocations while generatting the mapping code, which is what this patch is trying to do.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 reviewer)

Issue

  • JDK-8178701: Compile error with switch statement on protected enum defined in parent inner class

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7621

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 25, 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 the rfr Pull request is ready for review label Feb 25, 2022
@openjdk
Copy link

openjdk bot commented Feb 25, 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 Feb 25, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 25, 2022

Webrevs

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 25, 2022

@lahodaj This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 22, 2022

@lahodaj This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Apr 22, 2022
@lahodaj
Copy link
Contributor Author

lahodaj commented Apr 25, 2022

/open

@openjdk openjdk bot reopened this Apr 25, 2022
@openjdk
Copy link

openjdk bot commented Apr 25, 2022

@lahodaj This pull request is now open

Copy link
Contributor

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

looks good to me

@openjdk
Copy link

openjdk bot commented Apr 26, 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:

8178701: Compile error with switch statement on protected enum defined in parent inner class

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Apr 26, 2022
@lahodaj
Copy link
Contributor Author

lahodaj commented May 16, 2022

/integrate

@openjdk
Copy link

openjdk bot commented May 16, 2022

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

  • f4258a5: 8209137: Add ability to bind to specific local address to HTTP client
  • 65da38d: 8284585: PushPromiseContinuation test fails intermittently in timeout
  • 652044d: 8286297: G1: Simplify parallel and serial verification code paths

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 16, 2022

@lahodaj Pushed as commit 77dfbb4.

💡 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