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

Chris Plummer cjplummer at openjdk.org
Wed May 7 02:24:00 UTC 2025


> A followup to [JDK-8355773](https://bugs.openjdk.org/browse/JDK-8355773). Convert a bunch more tests to fetch the ThreadReference from a static field in the debuggee. [JDK-8355773](https://bugs.openjdk.org/browse/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.

Chris Plummer has updated the pull request incrementally with one additional commit since the last revision:

  undo copyright change

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/24979/files
  - new: https://git.openjdk.org/jdk/pull/24979/files/c43ff38c..3f7c4a03

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24979&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24979&range=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/24979.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24979/head:pull/24979

PR: https://git.openjdk.org/jdk/pull/24979


More information about the serviceability-dev mailing list