During the review of JDK-8252476, it's suggested to perform some refactoring around `as_CompilerThread` so that all `as_*_thread` methods could be consistent (name and location of definition).
The refactoring will basically be:
1. rename `as_CompilerThread` to `as_Compiler_thread`
2. move it to `thread.inline.hpp` (its declaration is in thread.hpp)
Edit: moving the definition to `thread.inline.hpp` causes some circular dependencies, which are non-trivial to solve. Alternatively, one could place a static cast method in the child class, like:
```
// inside CompilerThread class
static CompilerThread* CompilerThread::cast(Thread* t) {
return static_cast<CompilerThread*>(t);
}
```
The same technique is also used for the `heap()` method in the `CollectedHeap` hierachy.
The refactoring will basically be:
1. rename `as_CompilerThread` to `as_Compiler_thread`
2. move it to `thread.inline.hpp` (its declaration is in thread.hpp)
Edit: moving the definition to `thread.inline.hpp` causes some circular dependencies, which are non-trivial to solve. Alternatively, one could place a static cast method in the child class, like:
```
// inside CompilerThread class
static CompilerThread* CompilerThread::cast(Thread* t) {
return static_cast<CompilerThread*>(t);
}
```
The same technique is also used for the `heap()` method in the `CollectedHeap` hierachy.
- relates to
-
JDK-8268164 Adopt cast notation for WorkerThread conversions
-
- Resolved
-
-
JDK-8268368 Adopt cast notation for JavaThread conversions
-
- Resolved
-
-
JDK-8252476 as_Worker_thread() doesn't check what it intends
-
- Resolved
-