On Fri, 13 Mar 2026 09:29:47 GMT, Stefan Karlsson <[email protected]> wrote:

>> src/hotspot/share/gc/shared/collectedHeap.inline.hpp line 42:
>> 
>>> 40: 
>>> 41: inline oop CollectedHeap::array_allocate(Klass* klass, size_t size, int 
>>> length, bool do_zero, TRAPS) {
>>> 42:   assert(!klass->is_unrefined_objArray_klass(), "ObjArrayKlass must 
>>> never be used to allocate array instances directly");
>> 
>> Nit: double negative, I'd prefer `klass->is_refined_objArray_klass()`.
>
> That would not work. The assert also accepts the klass to be a TypeArrayKlass 
> and if I change to `klass->is_refined_objArray_klass()` then the assert will 
> fail whenever one of those classes are passed in.

We use this for `TypeArrays` as well, so that assert would not work 
(`klass->is_refined_objArray_klass()` is not the same as 
`!klass->is_unrefined_objArray_klass()`). We could and maybe should 
`precond(klass->is_array_klass())`.

Or even better, change 

-oop CollectedHeap::array_allocate(Klass* klass, size_t size, int length, bool 
do_zero, TRAPS);
+oop CollectedHeap::array_allocate(ArrayKlass* klass, size_t size, int length, 
bool do_zero, TRAPS);

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2207#discussion_r2930062482

Reply via email to