On Thu, 29 Jan 2026 09:01:20 GMT, Alan Bateman <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/Thread.java line 2218:
>>
>>> 2216: }
>>> 2217: Object trace = getStackTrace0();
>>> 2218: if (trace instanceof StackTraceElement[] stackTrace) {
>>
>> What can this return other than a `StackTraceElement[]` ??
>
> It can only return a StackTraceElement[] or null. Using a type pattern seemed
> nicer here to avoid a null check + explicit cast.
Sorry I have to disagree - a type check screams to me that this could be some
other type when it can't. A null check would be better IMO.
On the matter of the cast, why doesn't getStackTrace0 return STE[] instead of
object?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29461#discussion_r2744587005