Skip to content

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Oct 11, 2021

When JShell processes int strictfp = 0; (which is obviously erroneous), it will speculativelly try to parse and attribute code along these lines:

package REPL;
import java.io.*;import java.math.*;import java.net.*;import java.nio.file.*;import java.util.*;import java.util.concurrent.*;import java.util.function.*;import java.util.prefs.*;import java.util.regex.*;import java.util.stream.*;
class $JShell$DOESNOTMATTER {
    public static Object do_it$() throws Throwable {
        return int strictfp = 0;
    }
}

This crashes Attr, as the strictfp will be wrapped in JCModifiers, wrapped inside an erroneous tree, and Attr does not handle modifiers.

The proposal is to let Attr "handle" the JCModifiers in an error-recovery situation.


Progress

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

Issue

  • JDK-8273039: JShell crashes when naming variable or method "abstract" or "strictfp"

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5897

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 11, 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
Copy link

openjdk bot commented Oct 11, 2021

@lahodaj The following labels will be automatically applied to this pull request:

  • compiler
  • kulla

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.

@openjdk openjdk bot added compiler compiler-dev@openjdk.org kulla kulla-dev@openjdk.org labels Oct 11, 2021
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 13, 2021
@mlbridge
Copy link

mlbridge bot commented Oct 13, 2021

Webrevs

}

@Override
public void visitModifiers(JCModifiers tree) {
Copy link
Contributor

Choose a reason for hiding this comment

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

question can't we report this error when the erroneous code is being parsed? adding this method to Attr makes me feel a bit uncomfortable, I can understand if this is the only / best way though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parser will report the error, and will wrap the (presumed) modifiers into an erroneous tree, so the AST is reasonable. But JShell runs javac with --should-stop=at=FLOW, so the error in parser will not stop the processing, and when Attr will look into the erroneous tree, it will fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks for the clarification

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.

lgtm

@openjdk
Copy link

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

8273039: JShell crashes when naming variable or method "abstract" or "strictfp"

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 425 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.

➡️ 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 5, 2021
@lahodaj
Copy link
Contributor Author

lahodaj commented Nov 19, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Nov 19, 2021

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

  • f34f119: 8277213: CompileTask_lock is acquired out of order with MethodCompileQueue_lock
  • 47564ca: 8275643: C2's unaryOp vector intrinsic does not properly handle LongVector.neg
  • 2f0bde1: 8277102: Dubious PrintCompilation output
  • 839033b: 8276976: Rename LIR_OprDesc to LIR_Opr
  • 89b125f: 8275527: Refactor forward pointer access
  • 36bd4a3: 8277404: Test VMDeprecatedOptions.java failing with Unable to create shared archive file
  • 57eb864: 8276927: [PPC64] Port shenandoahgc to linux on ppc64le
  • 8db0c36: 8277414: ProblemList runtime/CommandLine/VMDeprecatedOptions.java on windows-x64
  • 03473b4: 8270874: JFrame paint artifacts when dragged from standard monitor to HiDPI monitor
  • ce0f00f: 8276093: Improve naming in closures to iterate over card sets
  • ... and 590 more: https://git.openjdk.java.net/jdk/compare/8f7a37c92f5713f7728f54d4a5924484a535e968...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 19, 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 Nov 19, 2021
@openjdk
Copy link

openjdk bot commented Nov 19, 2021

@lahodaj Pushed as commit 2f20b0d.

💡 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 kulla kulla-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants