Integrated: 8268368: Adopt cast notation for JavaThread conversions

Guoxiong Li gli at openjdk.java.net
Wed Jun 23 02:24:37 UTC 2021


On Tue, 22 Jun 2021 01:11:30 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> Hi all,
> 
> Considering the consistency of `JavaThread` and other threads, such as WorkerThread and CompilerThread, `JavaThread` could use a method named `cast` to replace the method `Thread::as_Java_thread()`. It can reduce the Thread's knowledge about the subtypes.
> 
> This patch removes two methods, `JavaThread* Thread::as_Java_thread()` and `const JavaThread* Thread::as_Java_thread() const`, of the class `Thread` and adds two static methods, `JavaThread* cast(Thread* t)` and `const JavaThread* cast(const Thread* t)`, to the class `JavaThread`. Correspondingly, the code of the method `JavaThread::current()` need to be adjusted and many places where the method `Thread::as_Java_thread()` is used need to use `JavaThread::cast` instead.
> 
> Test:
> tier1 passed locally.
> 
> Thanks for taking the time to review.
> 
> Best Regards,
> -- Guoxiong

This pull request has now been integrated.

Changeset: cd678a38
Author:    Guoxiong Li <gli at openjdk.org>
Committer: David Holmes <dholmes at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/cd678a383f7b23ea40132b207ddfc041394ba4c1
Stats:     158 lines in 64 files changed: 13 ins; 19 del; 126 mod

8268368: Adopt cast notation for JavaThread conversions

Reviewed-by: dholmes, stefank

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

PR: https://git.openjdk.java.net/jdk/pull/4546


More information about the serviceability-dev mailing list