Integrated: 8355773: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee
Chris Plummer
cjplummer at openjdk.org
Wed Apr 30 17:18:51 UTC 2025
On Mon, 28 Apr 2025 18:27:26 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: 50145bb7
Author: Chris Plummer <cjplummer at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/50145bb74ad87f5b3f80ed910f6ebb95e406b802
Stats: 78 lines in 31 files changed: 34 ins; 1 del; 43 mod
8355773: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee
Reviewed-by: sspitsyn, amenkov
-------------
PR: https://git.openjdk.org/jdk/pull/24935
More information about the serviceability-dev
mailing list