Skip to content

8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication#24768

Closed
plummercj wants to merge 18 commits intoopenjdk:masterfrom
plummercj:8355071_bp_for_com
Closed

8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication#24768
plummercj wants to merge 18 commits intoopenjdk:masterfrom
plummercj:8355071_bp_for_com

Conversation

@plummercj
Copy link
Contributor

@plummercj plummercj commented Apr 19, 2025

Remove the need for many nsk/jdi tests to discover the main thread, resulting in the test needing to be run with includevirtualthreads=y. Details in first comment.

Tested with all tier2, tier3, and tier5 svc tests


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-8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication (Enhancement - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24768

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 19, 2025

👋 Welcome back cjplummer! 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 Apr 19, 2025

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

8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication

Reviewed-by: lmesnik, amenkov

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 60 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 changed the title 8355071 8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication. Apr 19, 2025
@openjdk
Copy link

openjdk bot commented Apr 19, 2025

@plummercj The following label will be automatically applied to this pull request:

  • serviceability

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 serviceability serviceability-dev@openjdk.org label Apr 19, 2025
@plummercj
Copy link
Contributor Author

The PR is related to JDK-8353955, which is attempting to no longer run all jdk/jdi tests with includevirtualthreads=y, allowing the default to be includevirtualthreads=n, and tests that require includevirtualthreads=y to explicitly specify that need.

The changes in this PR will reduce the number of tests that need to specify includevirtualthreads=y from about 350 to about 180. It does not make the change to have the default be includevirtualthreads=n, which will be left for JDK-8353955 once all tests are either fixed to work with includevirtualthreads=n or specify the need for includevirtualthreads=y.

The changes in this PR relate to a common pattern in the nsk/jdi tests:

    String bPointMethod = "methodForCommunication";
    String lineForComm = "lineForComm";

    ThreadReference mainThread = debuggee.threadByNameOrThrow("main");

    BreakpointRequest bpRequest = settingBreakpoint(mainThread,
                                         debuggeeClass,
                                         bPointMethod, lineForComm, "zero");

All tests that do this require includevirtualthreads=y because of the thread lookup. There is no need for mainThread in this code. null can be used instead for a global breakpoint. Once this is done, there is usually no need to run the test with includevirtualthreads=y, although in a few tests there are other calls to thread lookup API that result in the test still needing includevirtualthreads=y.

I replaced the above code with a call to a new API in JDIBase:

    setupBreakpointForCommunication(debuggeeClass);

This represents the bulk of the changes in this CR. Some tests had other references to mainThread that then needed to be addressed. For most, the thread was already stored in bpEvent and could be fetched from there:

breakpointForCommunication();
ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication()

@plummercj plummercj changed the title 8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication. 8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication Apr 19, 2025
Copy link
Member

@sendaoYan sendaoYan left a comment

Choose a reason for hiding this comment

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

Should we update the copyright year from 2024 to 2025.

@plummercj
Copy link
Contributor Author

Should we update the copyright year from 2024 to 2025.

I plan on doing that after the reviews are done. Given the large number of files being changed, I thought it would be easier to review without the noise of copyright updates in nearly every file.

@plummercj plummercj marked this pull request as ready for review April 21, 2025 16:56
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 21, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 21, 2025

Webrevs

Copy link
Member

@lmesnik lmesnik left a comment

Choose a reason for hiding this comment

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

Good to see more simplification of common code patterns.
See my small comment inline.
Also, you need to update a copyrights for changed files.

breakpRequest = eventRManager.createBreakpointRequest(lineLocation);
breakpRequest.putProperty("number", property);
breakpRequest.addThreadFilter(thread);
if (thread != null) {
Copy link
Member

Choose a reason for hiding this comment

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

The change might hide failure if thread is not set in the test.
I would prefer to have
private settingBreakpoint(ThreadReference thread,.,.) that allows null
and

protected final BreakpointRequest settingBreakpoint(ThreadReference thread,
                                                     ReferenceType testedClass,
                                                     String methodName,
                                                     String bpLine,
                                                     String property)

that still fails early if thread is null. (I think now it should fail in
breakpRequest.addThreadFilter(thread);
string.
So for any test that don't have proper thread - test fails early when setting breakpoint and not because it hasn't find it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I updated to use a different API that implies no thread.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 22, 2025
@plummercj
Copy link
Contributor Author

Thank you for the reviews Leonid and Alex!

/integrate

@openjdk
Copy link

openjdk bot commented Apr 22, 2025

Going to push as commit b7e8952.
Since your change was applied there have been 60 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 Apr 22, 2025
@openjdk openjdk bot closed this Apr 22, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 22, 2025
@openjdk
Copy link

openjdk bot commented Apr 22, 2025

@plummercj Pushed as commit b7e8952.

💡 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

integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

4 participants