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

8297974: ClassCastException in com.sun.tools.javac.comp.AttrRecover.doRecovery #11479

Closed
wants to merge 1 commit into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Dec 2, 2022

Considering code like:

class RecoveryTest {

    interface I {
        int convert(int i);
    }

    void t(I f, String e) {
        t(param -> param); //a parameter missing here
    }

}

This is clearly wrong (the invocation of t is missing a parameter). But, running this crashes the compiler in addition to reporting the error:

$ javac -XDdev RecoveryTest.java 
/tmp/RecoveryTest.java:8: error: method t in class RecoveryTest cannot be applied to given types;
        t(param -> param);
        ^
  required: I,String
  found:    (param)->param
  reason: actual and formal argument lists differ in length
1 error
An exception has occurred in the compiler (20-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCIdent cannot be cast to class com.sun.tools.javac.tree.JCTree$JCBlock (com.sun.tools.javac.tree.JCTree$JCIdent and com.sun.tools.javac.tree.JCTree$JCBlock are in module jdk.compiler of loader 'app')
        at jdk.compiler/com.sun.tools.javac.comp.AttrRecover.doRecovery(AttrRecover.java:161)
        at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:738)
...

The reason is that AttrRecovery will try to temporarily tweak the AST, so that it can be more correctly attributed. In particular, it will try to add a return statement into the lambda - but as the lambda is not a block lambda, and it crashes.

It seems it is enough to avoid adding the return statement into the expression lambdas, the recovery should still be reasonable, and the crash will be avoided. So, this is what the patch is doing.


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

Issue

  • JDK-8297974: ClassCastException in com.sun.tools.javac.comp.AttrRecover.doRecovery

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11479

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 2, 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 Dec 2, 2022
@openjdk
Copy link

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

mlbridge bot commented Dec 2, 2022

Webrevs

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.

looks good

@openjdk
Copy link

openjdk bot commented Dec 2, 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:

8297974: ClassCastException in com.sun.tools.javac.comp.AttrRecover.doRecovery

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 31 new commits pushed to the master branch:

  • 6065696: 8297982: Exclude vmTestbase/nsk/monitoring/stress/lowmem/ with ZGC until 8297979 is fixed
  • 415cfd2: 8297285: Shenandoah pacing causes assertion failure during VM initialization
  • df07255: 8297984: Turn on warnings as errors for javadoc
  • 227364d: 8297953: Fix several C2 IR matching tests for RISC-V
  • 1370228: 8297941: Add override modifier in space.hpp
  • 319faa5: 8296084: javax/swing/JSpinner/4788637/bug4788637.java fails intermittently on a VM
  • b73363f: 8297686: JFR: Improve documentation of EventStream::onMetadata(Consumer)
  • 1376f33: 8297911: Memory leak in JfrUpcalls::on_retransform
  • 5c0ff26: 8291444: GHA builds/tests won't run manually if disabled from automatic running
  • 6d0fbb2: 8297645: Drop the test/jdk/java/net/httpclient/reactivestreams-tck-tests/TckDriver.java test
  • ... and 21 more: https://git.openjdk.org/jdk/compare/2cb64a75578ccc15a1dfc8c2843aa11d05ca8aa7...master

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 Dec 2, 2022
@lahodaj
Copy link
Contributor Author

lahodaj commented Dec 5, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Dec 5, 2022

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

  • 17666fb: 8297794: Deprecate JMX Management Applets for Removal
  • 619b68c: 8294540: Remove Opaque2Node: it is broken and triggers assert
  • 82561de: 8296384: [TESTBUG] sun/security/provider/SecureRandom/AbstractDrbg/SpecTest.java intermittently timeout
  • 61b7093: 8297872: Non-local G1MonotonicArenaFreePool::_freelist_pool has non-trivial ctor/dtor
  • 3b3bbe5: 8296907: VMError: add optional callstacks, siginfo for secondary errors
  • a573923: 8297264: C2: Cast node is not processed again in CCP and keeps a wrong too narrow type which is later replaced by top
  • b49fd92: 8298055: AArch64: fastdebug build fails after JDK-8247645
  • 914ef07: 8297609: Add application/wasm MIME type for wasm file extension
  • a71d91b: 8298067: Persistent test failures after 8296012
  • 87572d4: 8298068: ProblemList tests failing due to JDK-8297235
  • ... and 40 more: https://git.openjdk.org/jdk/compare/2cb64a75578ccc15a1dfc8c2843aa11d05ca8aa7...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 5, 2022

@lahodaj Pushed as commit 777fb52.

💡 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