Skip to content

Conversation

@plummercj
Copy link
Contributor

@plummercj plummercj commented May 1, 2025

A followup to JDK-8355773. Convert a bunch more tests to fetch the ThreadReference from a static field in the debuggee. JDK-8355773 focused on the easier tests that already had a static field, and the name of the field was the same as the thread name. This batch takes care of a bunch of harder to convert tests where in many cases static field has to be added and usually does not have the same name as the thread name.

Note there was a lot of template copy-n-paste code that I deleted because it was never used. For example, most tests were not using the listIterator variable. There were also many deletions of calls to vm.allThreads(). Some were because the need to iterate over the threads went away, but most were because the result was never used.

There are many places where the original code iterated over all the threads looking for a particular thread rather than calling on of the existing threadByName() APIs, and you'll see this being replaced by calls to the new threadByFieldNameOrThrow() API. One thing to keep in mind is that the old code tried to continue running the test if it failed to find the thread. This would lead to a timeout. threadByFieldNameOrThrow() will throw an exception which forces the test to quickly exit.

I added a 2nd threadByFieldNameOrThrow() API. The original one just took a threadFieldName argument, assuming that the name of the static field and the name of the thread were the same. The new one adds a threadName argument, allowing for the two to be different. The threadName is used just to double check that the Thread fetched from the static field has the expected name. It is not used as part of the lookup.

Tested with CI tier5, which is where all the nsk/jdi testing is done. Also ran locally on linux-x64.


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-8356023: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee: part 2 (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24979

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 1, 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 May 1, 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:

8356023: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee: part 2

Reviewed-by: amenkov, sspitsyn, lmesnik

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 128 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 8355773 8355773: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee May 1, 2025
@openjdk
Copy link

openjdk bot commented May 1, 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 May 1, 2025
break label0;
}
}
thread2 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "test_thread", threadName);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note, mainThread is not reference later in the test so is no longer being looked up (and I deleted the field above). There are a couple more test below where the same is done.

@plummercj plummercj marked this pull request as ready for review May 1, 2025 03:00
@openjdk openjdk bot added the rfr Pull request is ready for review label May 1, 2025
@mlbridge
Copy link

mlbridge bot commented May 1, 2025

Webrevs

@plummercj plummercj changed the title 8355773: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee 8356023 May 1, 2025
@openjdk openjdk bot changed the title 8356023 8356023: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee: part 2 May 1, 2025
Copy link

@alexmenkov alexmenkov 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 in general, good to see all this stuff dropped.
One file has only copyright line change.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.

Choose a reason for hiding this comment

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

There are no changes in the file

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 7, 2025
Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

This is also a nice unification, simplification and cleanup. Looks good.

@plummercj
Copy link
Contributor Author

Thank you for the reviews Alex, Serguei, and Leonid.

/integrate

@openjdk
Copy link

openjdk bot commented May 8, 2025

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

openjdk bot commented May 8, 2025

@plummercj Pushed as commit 9273094.

💡 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