-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8254105: allow static nested declarations #571
8254105: allow static nested declarations #571
Conversation
👋 Welcome back vromero! A progress list of the required criteria for merging this PR into |
@@ -2,8 +2,8 @@ | |||
* @test /nodynamiccopyright/ | |||
* @bug 8242478 | |||
* @summary test for local interfaces | |||
* @compile/fail/ref=LocalInterface.out -XDrawDiagnostics LocalInterface.java | |||
* @compile --enable-preview -source ${jdk.version} LocalInterface.java |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vicente-romero-oracle The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
@@ -0,0 +1,307 @@ | |||
/* | |||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is not strictly related to the patch but this test is just basically testing the changes introduced by Chapter 13 in the record spec. I'm OK moving this to another PR if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet this is related to the extra disjoint test in Check.java - if so, yes, better moved in a different issue, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really but it is true that it is not strictly related to the patch, will create another issue for it
Webrevs
|
/label remove core-libs |
@vicente-romero-oracle |
Mailing list message from David Holmes on compiler-dev: Hi Vincente, On 9/10/2020 10:10 am, Vicente Romero wrote:
I'm rather confused. Is this intended to be the issue under which the ??? Thanks, |
Hi David, This issue is a subtask of JEP 395 along with JDK-8246774. JDK-8246774 is basically removing all the preview annotations from record's code and preview options from the related tests so that records can be used as a standard feature in Java. But issues like this one, and probably another I'm still working on related to annotations on record components, was, IMO, complex enough to deserve a separate review process. I'm OK with creating an umbrella issue, if that sounds better to you, that contains all implementation tasks and make JDK-8246774 and this current task subtasks of that umbrella issue. Thanks, |
/csr |
@vicente-romero-oracle this pull request will not be integrated until the CSR request JDK-8254321 for issue JDK-8254105 has been approved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good, but I have one concern: this patch seem to apply the improvements unconditionally, regardless of the source version - is this what we want? While I understand that the risk is low (this patch makes space of compilable programs bigger), at the same times it feels wrong that when compiling with --source 14
I can now nest static classes inside member classes (which is not compatible with what the SE 14 spec says).
if (sym.owner.owner.kind == PCK || | ||
(sym.owner.flags_field & STATIC) != 0) | ||
mask |= STATIC; | ||
else if ((flags & ENUM) != 0 || (flags & RECORD) != 0) { | ||
log.error(pos, Errors.StaticDeclarationNotAllowedInInnerClasses); | ||
//log.error(pos, Errors.StaticDeclarationNotAllowedInInnerClasses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you get rid of the else if
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, sure
@@ -1307,7 +1302,10 @@ else if ((sym.kind == TYP || | |||
SEALED | NON_SEALED) | |||
&& checkDisjoint(pos, flags, | |||
SEALED, | |||
FINAL | NON_SEALED)) { | |||
FINAL | NON_SEALED) | |||
&& checkDisjoint(pos, flags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this coming from? This seems outside the scope of the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I will remove it
@@ -0,0 +1,307 @@ | |||
/* | |||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet this is related to the extra disjoint test in Check.java - if so, yes, better moved in a different issue, thanks.
As @mcimadamore, I think this should only be allowed for -source 16+, right? |
I agree, I'm working on another iteration to fix the issue, thanks for the comments |
I have pushed a commit addressing the review comments so far. I have re-added code in Attr but this time behind a guard checking if records are allowed in the current source and I have added back some tests I removed before. The tests are now executed with current source and with source 15. Thanks for the comments so far. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good
thanks! |
@vicente-romero-oracle 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:
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 7 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
/integrate |
@vicente-romero-oracle Since your change was applied there have been 9 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 9a19eb6. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review the fix for JDK-8254105. The intention of the fix is to allow static members to be declared inside inner classes. The spec allowing this change can be seen at Local and Nested Static Declarations. This change is part of the Records JEP. The idea is to allow not only records to be defined inside inner classes but also interfaces, enums, static classes and methods.
TIA,
Vicente
PS: the records spec can be accessed here Record Classes. This patch also adds a test to check the changes in the Records spec to Chapter 13 "Binary Compatibility". I'm OK moving that test to a separate PR.
Progress
Testing
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/571/head:pull/571
$ git checkout pull/571