Skip to content

8341778: Some javac tests ignore the result of JavacTask::call #25645

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

Conversation

vicente-romero-oracle
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle commented Jun 4, 2025

Several tests are ignoring the result of invoking com.sun.source.util.JavacTask::call which returns a Boolean. This implies that tests could seem to pass when in reality they are silently failing. This PR is fixing this issue by checking, in all applicable cases the result of the invocation.

TIA


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-8341778: Some javac tests ignore the result of JavacTask::call (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25645

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 4, 2025

👋 Welcome back vromero! 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 Jun 4, 2025

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

8341778: Some javac tests ignore the result of JavacTask::call

Reviewed-by: shade

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 185 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 rfr Pull request is ready for review label Jun 4, 2025
@openjdk
Copy link

openjdk bot commented Jun 4, 2025

@vicente-romero-oracle The following labels will be automatically applied to this pull request:

  • compiler
  • hotspot-gc

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 hotspot-gc hotspot-gc-dev@openjdk.org labels Jun 4, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 4, 2025

Webrevs

Copy link
Member

@shipilev shipilev 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, but I have question about hunks that are not about wrapping call()-s. Those look like fixing the actual test bugs?

@@ -50,7 +50,8 @@ public static void main(String... args) throws Throwable {

final PrintWriter out = new PrintWriter(System.err, true);

Iterable<String> flags = Arrays.asList("-processorpath", testClassDir,
Iterable<String> flags = Arrays.asList("--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
Copy link
Member

Choose a reason for hiding this comment

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

Why --add-exports? Did this test actually failed without us noticing?

Copy link
Contributor Author

@vicente-romero-oracle vicente-romero-oracle Jun 5, 2025

Choose a reason for hiding this comment

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

correct, as we were ignoring the result of the ::call invocation it was returning false but the test went on and seemed to be OK

@@ -75,6 +76,12 @@ public static void main(String... args) throws Exception {
}
}

static final List<String> OPTIONS = List.of(
Copy link
Member

Choose a reason for hiding this comment

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

Same question here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same answer here

@@ -34,7 +34,7 @@

public class SOEDeeplyNestedBlocksTest {

static final int NESTING_DEPTH = 1000;
static final int NESTING_DEPTH = 500;
Copy link
Member

Choose a reason for hiding this comment

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

Same question here.

Copy link

Choose a reason for hiding this comment

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

With a NESTING_DEPTH of 1000 javac will run into a StackOverflowError, but it still completes and task.call() returns false. Using 500 javac can compile without error. Not sure what this test wants to prove. If it wants to show that javac can complete without throwing an SOE then it should keep depth 1000 and test that task.call() returns false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes this one was failing quietly, this test is stressing a code that was modified due to pattern matching. It is testing that javac can deal with deeply nested code without throwing SOE. 1000 depth was too much and the test was quietly failing

Copy link

@jdlib jdlib Jun 5, 2025

Choose a reason for hiding this comment

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

It is testing that javac can deal with deeply nested code without throwing SOE.

The current summary Javac fails with StackOverflowError when compiling deeply nested synchronized blocks is confusing and I don't know how it relates to your statement. Does it describe a bug or does it state the purpose of the test? Anyway, why not test with nesting levels of 500 and 1000, assert that task.call() returns true (500) and false (1000), but in the later case does not panic and terminate with a SOE.

Copy link
Contributor Author

@vicente-romero-oracle vicente-romero-oracle Jun 5, 2025

Choose a reason for hiding this comment

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

the original version of the test was included as part of the fix for [1] as you can see in the related PR [2] method com.sun.tools.javac.jvm.Gen::visitBlock was visiting every block assuming that every one of them had pattern matching expressions in it. This implied a visitBlock with a higher number of local variables even for 90-98% of blocks that didn't have any pattern matching in them. So the test is checking that javac is not failing with SOE while generating code for a method with deeply nested blocks. Testing that javac will produce SOE after a given threshold is passed adds no information as there always be resource limits for any process. This is why I don't see the value of having a test that passes that threshold, which by the way could move over time and then we will need to go back and fix the test. While on the other hand having a test that will keep javac in check, as in being able to still compile without issues a nested enough code, seems more valuable to me.

[1] https://bugs.openjdk.org/browse/JDK-8322992
[2] #18832

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 5, 2025
@shipilev
Copy link
Member

shipilev commented Jun 5, 2025

I believe we are still not in RDP1? Do you want to get it in JDK 25? Put Fix-Versions: 25 into the bug and integrate, if so.

@vicente-romero-oracle
Copy link
Contributor Author

I believe we are still not in RDP1? Do you want to get it in JDK 25? Put Fix-Versions: 25 into the bug and integrate, if so.

I prefer to wait until 26, this is not a high priority issue

@vnkozlov
Copy link
Contributor

vnkozlov commented Jun 5, 2025

Tests P1-P5 can be fixed during RDP1 and RDP2: https://openjdk.org/jeps/3#rdp-2

@vicente-romero-oracle
Copy link
Contributor Author

thanks for the reviews

@vicente-romero-oracle
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 6, 2025

Going to push as commit 8adb052.
Since your change was applied there have been 198 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 6, 2025

@vicente-romero-oracle Pushed as commit 8adb052.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@vicente-romero-oracle vicente-romero-oracle deleted the JDK-8341778 branch June 6, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants