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

8338981: Access to private classes should be permitted inside the permits clause of the enclosing top-level class #20718

Closed

Conversation

Evemose
Copy link
Contributor

@Evemose Evemose commented Aug 26, 2024

Fix involves adding new flag to after context that indicates that currently resolved symbol is in permits clause


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

Issues

  • JDK-8338981: Access to private classes should be permitted inside the permits clause of the enclosing top-level class (Bug - P3)
  • JDK-8341669: Access to private classes and interfaces should be permitted inside the permits clause of the enclosing class or interface (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20718

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 26, 2024

👋 Welcome back Evemose! 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
Copy link

openjdk bot commented Aug 26, 2024

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

8338981: Access to private classes should be permitted inside the permits clause of the enclosing top-level class

Reviewed-by: vromero, mcimadamore

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 156 new commits pushed to 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vicente-romero-oracle, @lahodaj, @mcimadamore) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 26, 2024
@openjdk
Copy link

openjdk bot commented Aug 26, 2024

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

@mlbridge
Copy link

mlbridge bot commented Aug 26, 2024

@lahodaj
Copy link
Contributor

lahodaj commented Aug 27, 2024

Others may have a different opinion, but this seems a bit too hacky to me (given we would need to maintain this for a long time).

I would suggest to try to add a new flag into AttrContext, along the lines of permitPrivateAccessInHeader, and set it while attributing the permitted types. Not sure how invasive that'd be, but hopefully not terribly much. And it should be clear (and documented) what's happening.

@Evemose
Copy link
Contributor Author

Evemose commented Aug 27, 2024

Others may have a different opinion, but this seems a bit too hacky to me (given we would need to maintain this for a long time).

I would suggest to try to add a new flag into AttrContext, along the lines of permitPrivateAccessInHeader, and set it while attributing the permitted types. Not sure how invasive that'd be, but hopefully not terribly much. And it should be clear (and documented) what's happening.

Honestly, I agree with you, I just didnt know how much invasive changes to existing code could be. I will look into AttrContext later today

@Evemose
Copy link
Contributor Author

Evemose commented Aug 28, 2024

Others may have a different opinion, but this seems a bit too hacky to me (given we would need to maintain this for a long time).

I would suggest to try to add a new flag into AttrContext, along the lines of permitPrivateAccessInHeader, and set it while attributing the permitted types. Not sure how invasive that'd be, but hopefully not terribly much. And it should be clear (and documented) what's happening.

I have decided to write tests before reworking fix. Could you please suggest where could i put it? I have found tools/javac/diags/examples folder, but it seems to only contain negative tests, while I need positive ones. Is there any suitable place for this kind of thing?

@vicente-romero-oracle
Copy link
Contributor

Others may have a different opinion, but this seems a bit too hacky to me (given we would need to maintain this for a long time).
I would suggest to try to add a new flag into AttrContext, along the lines of permitPrivateAccessInHeader, and set it while attributing the permitted types. Not sure how invasive that'd be, but hopefully not terribly much. And it should be clear (and documented) what's happening.

I have decided to write tests before reworking fix. Could you please suggest where could i put it? I have found tools/javac/diags/examples folder, but it seems to only contain negative tests, while I need positive ones. Is there any suitable place for this kind of thing?

most tests for sealed classes are under:
test/langtools/tools/javac/sealed/

@Evemose
Copy link
Contributor Author

Evemose commented Sep 12, 2024

@lahodaj could you review please?

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.

I think this change needs more test cases so that we can be sure that we are testing most of the possible combinations

@openjdk openjdk bot removed the rfr Pull request is ready for review label Sep 28, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 28, 2024
@Evemose
Copy link
Contributor Author

Evemose commented Sep 29, 2024

I think this change needs more test cases so that we can be sure that we are testing most of the possible combinations

I have tried to imagine some test cases where something could go wrong. Not really sure how to verify everything concidering the fact that permits is the last clause before attributing class code, which is allowed to access any private members, but I added some test cases veryfying everything from a different angles

@jddarcy
Copy link
Member

jddarcy commented Oct 1, 2024

If this fix is proposing to align javac behavior with the JLS, while no spec change would be needed. A CSR would need to be filed for the behavioral change.

@Evemose
Copy link
Contributor Author

Evemose commented Oct 2, 2024

If this fix is proposing to align javac behavior with the JLS, while no spec change would be needed. A CSR would need to be filed for the behavioral change.

Hello! I am not familiar with CSR process. I tried to find a way to file it using java bug database, but could not find anything. Could you tell me what should I do and where, please?

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Overall, I think this is good. Left some comments to make the test and style similar to what is generally used in javac, at least in my opinion. Thanks for doing this change!

@lahodaj
Copy link
Contributor

lahodaj commented Oct 2, 2024

If this fix is proposing to align javac behavior with the JLS, while no spec change would be needed. A CSR would need to be filed for the behavioral change.

Hello! I am not familiar with CSR process. I tried to find a way to file it using java bug database, but could not find anything. Could you tell me what should I do and where, please?

In JBS, in the bug, there is "More", and if you click on that, there is "Create CSR". Click on that, and fill in the details in the text, as described in the template. When reviewing, I'll try to fill any flags that need to be filled (so that you know what gets filled next time).

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Oct 25, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 26, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 26, 2024
@Evemose
Copy link
Contributor Author

Evemose commented Oct 28, 2024

By the way, does anyone know why ci fails? It fails on generate report, not on tests. I tried to sync branch with master but it seems like it has not had any affect

@vicente-romero-oracle
Copy link
Contributor

@Evemose I was waiting for the results of the tests after your last change, all green, we are good to go

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.

thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 31, 2024
@Evemose
Copy link
Contributor Author

Evemose commented Oct 31, 2024

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 31, 2024
@openjdk
Copy link

openjdk bot commented Oct 31, 2024

@Evemose
Your change (at version 0889133) is now ready to be sponsored by a Committer.

@Evemose
Copy link
Contributor Author

Evemose commented Oct 31, 2024

@Evemose I was waiting for the results of the tests after your last change, all green, we are good to go

Glad we are finally done with this one. Got a bit busy lately, pr could`ve taken much less time, thanks for your patience. Would you mind sponsoring?

@vicente-romero-oracle
Copy link
Contributor

/sponsor

@vicente-romero-oracle
Copy link
Contributor

@Evemose I was waiting for the results of the tests after your last change, all green, we are good to go

Glad we are finally done with this one. Got a bit busy lately, pr could`ve taken much less time, thanks for your patience. Would you mind sponsoring?

thanks to you!

@openjdk
Copy link

openjdk bot commented Oct 31, 2024

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Oct 31, 2024

@vicente-romero-oracle @Evemose Pushed as commit b269493.

💡 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 [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants