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

8253584: Redunant errors for partial member selects #333

Closed
wants to merge 2 commits into from

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Sep 24, 2020

For code like:

package t;

class Test {

    void t() {
        if (true) {
            s().
        } else {
        }
    }

    String s() {
        return null;
    }
} 

(note the missing member name after s().), javac will produce a number of compile-time errors:

$ javac /tmp/Test.java
/tmp/Test.java:7: error: <identifier> expected
            s().
                ^
/tmp/Test.java:7: error: not a statement
            s().
               ^
/tmp/Test.java:8: error: ';' expected
        } else {
         ^
/tmp/Test.java:8: error: 'else' without 'if'
        } else {
          ^
/tmp/Test.java:12: error: ';' expected
    String s() {
            ^
/tmp/Test.java:15: error: reached end of file while parsing
}
 ^
6 errors 

The reason is that after not seeing an identifier after the . javac will skip the token that follows the dot. This was done to improve errors in https://bugs.openjdk.java.net/browse/JDK-8081769 . But here, reading the next token will skip the closing }, and the parser will de-synchronize with the braces, leading to the follow-up errors.

The proposal here is to handle incorrect .class specially, and avoid reading the next token when an identifier is no specified in a member select, except when the next token is class.

The errors with this patch are:

$ javac /tmp/Test.java 
/tmp/Test.java:7: error: <identifier> expected
            s().
                ^
/tmp/Test.java:7: error: not a statement
            s().
               ^
2 errors

This seems much better.


Progress

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

Issue

  • JDK-8253584: Redunant errors for partial member selects

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/333/head:pull/333
$ git checkout pull/333

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 24, 2020

👋 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 24, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Sep 24, 2020

@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 (add|remove) "label" command.

Loading

@openjdk openjdk bot added the compiler label Sep 24, 2020
@mlbridge
Copy link

@mlbridge mlbridge bot commented Sep 24, 2020

Webrevs

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 25, 2020

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

After integration, the commit message for the final commit will be:

8253584: Redunant errors for partial member selects

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.

Loading

@openjdk openjdk bot added the ready label Sep 25, 2020
@lahodaj
Copy link
Contributor Author

@lahodaj lahodaj commented Sep 29, 2020

/integrate

Loading

@openjdk openjdk bot closed this Sep 29, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Sep 29, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Sep 29, 2020

@lahodaj Since your change was applied there have been 7 commits pushed to the master branch:

  • ebf443a: 8253590: java/foreign tests are still failing on x86_32 after foreign-memaccess integration
  • 431338b: 8212107: VMThread issues and cleanup
  • 6bddeb7: 8238761: Asynchronous handshakes
  • 6d19fe6: 8253763: ParallelObjectIterator should have virtual destructor
  • 55c90a1: 6514600: AbstractAction can throw NullPointerException when clone()d
  • b659132: 8252888: Collapse G1MMUTracker class hierarchy
  • e63b90c: 8251358: Clean up Access configuration after Shenandoah barrier change

Your commit was automatically rebased without conflicts.

Pushed as commit 86491a5.

💡 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