On Tue, 3 Mar 2026 06:44:14 GMT, Ivan Walulya <[email protected]> wrote:
>> Please review these simple changes to some of the JNI functions:
>>
>> - JNI `AllocObject` should not throw `InstantiationException` for value
>> types (and I've added a very simple test for that)
>> - JNI `NewObject*` had leftover code to explicitly throw
>> `InstantiationException` but that is already handled inside
>> `allocate_instance`
>>
>> Also fixed some alignment/whitespace issues that had crept in.
>>
>> Thanks
>
> src/hotspot/share/prims/jni.cpp line 2398:
>
>> 2396: oop v = JNIHandles::resolve(value);
>> 2397: if (a->is_within_bounds(index)) {
>> 2398: Klass* ek = a->is_flatArray() ?
>> FlatArrayKlass::cast(a->klass())->element_klass() :
>> RefArrayKlass::cast(a->klass())->element_klass();
>
> Suggestion:
>
> assert(a->klass()->is_refined_objArray_klass(), "must be");
> Klass* ek = ObjArrayKlass::cast(a->klass())->element_klass();
>
> suggestion for further cleanup
@walulyai that suggestion is not related to my change - I only fixed the
indentation of this piece of code. A seperate issue can be filed if you think
this change is worthwhile.
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/2190#discussion_r2880563565