Skip to content

Conversation

@lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Dec 5, 2025

Consider a case like this:

package test;
public class Intermediate<T> extends Base<T> {}

package test;
public class Base<T> {
    public void t(Missing<T> m) {}
}
package test;
public class Missing<T> {}

this is compiled, and then Missing is deleted. Then a test file is compiled with the above classes on the classpath:

$ cat src/test/Test.java 
package test;
public class Test extends Intermediate<String> {
    private void test() {
        while (true) { break; }
    }
}
$ javac -XDdev -XDshould-stop.at=FLOW -d classes -classpath classes src/test/Test.java
src/test/Test.java:2: error: cannot access Missing
public class Test extends Intermediate<String> {
       ^
  class file for test.Missing not found
1 error
An exception has occurred in the compiler (25.0.1). 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.AssertionError
        at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.clearPendingExits(Flow.java:631)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitMethodDef(Flow.java:619)
...

The reason is that the CompletionFailure will be thrown from chk.checkCompatibleSupertypes(tree.pos(), c.type);, and since that's before attributing the method bodies, the method bodies will remain blank. And hence the break will have no target set, and Flow will fail on it.

I spent some time trying to figure out if we could improve handling on CompletionFailures more generally, so that we would not need to catch them on more-or-less arbitrary places. But everything I was able to do so far didn't really improve the situation. So the proposal herein is to catch and handle the CompletionFailure on some place.


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

Warning

 ⚠️ Found leading lowercase letter in issue title for 8373094: javac may fail because of unattributed break in a loop

Issue

  • JDK-8373094: javac may fail because of unattributed break in a loop (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28680

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 5, 2025

👋 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 Dec 5, 2025

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

8373094: javac may fail because of unattributed break in a loop

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 22 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 compiler compiler-dev@openjdk.org label Dec 5, 2025
@openjdk
Copy link

openjdk bot commented Dec 5, 2025

@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 rfr Pull request is ready for review label Dec 5, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 5, 2025

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.

lgtm

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler compiler-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants