RFR: 8252476: as_Worker_thread() doesn't check what it intends

David Holmes dholmes at openjdk.java.net
Tue May 25 01:21:06 UTC 2021


On Mon, 24 May 2021 15:18:00 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

> Convert `as_Worker_thread` to non-virtual, like other `as_*_thread` methods.

Hi Albert,

Thanks for fixing this. A couple of nits on the details.

David

src/hotspot/share/runtime/thread.hpp line 1593:

> 1591: 
> 1592: inline WorkerThread* Thread::as_Worker_thread() const {
> 1593:   assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");

More than dubious I would say, just plain wrong.

src/hotspot/share/runtime/thread.hpp line 1594:

> 1592: inline WorkerThread* Thread::as_Worker_thread() const {
> 1593:   assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
> 1594:   return (WorkerThread*)this;

Can you use static_cast here rather the C-style cast please.

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

Changes requested by dholmes (Reviewer).

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


More information about the hotspot-runtime-dev mailing list