RFR: 8355773: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee
Chris Plummer
cjplummer at openjdk.org
Tue Apr 29 17:46:27 UTC 2025
In an effort go get rid of calls to Debugee.threadByName() or Debugee.threadByNameOrThrow(), I found that many tests store the thread being looked up in a static field of the debuggee. The test can fetch the ThreadReference from the static field instead of looking it up using APIs that rely on vm.allThreads().
Most of the changes take advantage of the following common pattern:
In the debugger:
String threadName1 = "thread1";
thread1 = debuggee.threadByNameOrThrow(threadName1);
In the debuggee:
static Thread thread1 = null;
thread1 = JDIThreadFactory.newThread(new Thread1addcountfilter001a("thread1"));
Note that the static field name for the Thread is the same as the thread name. Thus we can easily switch from looking up by thread name to instead looking up by static field name since they both use the same name.
-------------
Commit messages:
- update copyright
- update copyright
- fix type in last commit
- undo hashcode001 change
- fix jcheck errors
- Use static field in the debuggee to look up ThreadReference.
Changes: https://git.openjdk.org/jdk/pull/24935/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24935&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8355773
Stats: 79 lines in 31 files changed: 34 ins; 1 del; 44 mod
Patch: https://git.openjdk.org/jdk/pull/24935.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24935/head:pull/24935
PR: https://git.openjdk.org/jdk/pull/24935
More information about the serviceability-dev
mailing list