On Mon, 9 Feb 2026 22:02:37 GMT, Frederic Parain <[email protected]> wrote:
>> First batch of changes to remove potentially dangerous calls to >> objArrayOopDesc::obj_at(). >> Changes are more extensive than intended. In most cases, code modifications >> consist in using a refArrayOop type instead of a objArrayOop type, because >> most of the arrays the JVM deals with for its own purpose are always >> reference arrays (because they are arrays of identity type elements). The >> patch also adds a new API allowing the VM to request the allocation of a >> reference array. >> Code dealing with user provided arrays must be ready to handle exceptions >> when accessing objArrays. >> >> This is a short term fix, fixing a few bugs, and trying to make the code >> more robust using the meta-data types. For the long term, a better solution >> is needed. Accesses to both arrays and fields are becoming more and more >> complex because of the introduction of flattening, multiple layouts, >> additional properties. Forcing enforcement at each access would be expensive >> and wasteful, as the JVM usually operates on well-known objects or arrays. >> But because of the increasing complexity, having a way to quickly check the >> validity of an access would help making the VM code more robust. > > Frederic Parain has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase. The pull request contains 12 additional > commits since the last revision: > > - Comments update > - Rename new_default_refArray to new_refArray with overload > - Fixes issues mentioned in reviews > - Remove force_refarray and add array klass creation from ArrayDescription > - Fix merge > - Merge remote-tracking branch 'upstream/lworld' into refarray_factory > - Revert foreign methods signature changes > - Foreign API and other fixes > - CI fixes > - More fixes in serviceability code > - ... and 2 more: > https://git.openjdk.org/valhalla/compare/c0e18eb8...bd5f33d0 src/hotspot/share/oops/objArrayKlass.cpp line 421: > 419: assert(is_refArray_klass() || is_flatArray_klass(), "Must be a > concrete array klass"); > 420: return this; > 421: } If a understand this patch correctly, we now allow having both RefArrays and FlatArrays with the same properties. (We really only care about DEFAULT, but never the less). Why is this exit condition correct, and not something like: ```c++ if (properties() == props && ((ad._layout_kind == LayoutKind::REFERENCE && is_refArray_klass()) || (ad._layout_kind != LayoutKind::REFERENCE && is_flatArray_klass()))) { return this; } ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2033#discussion_r2798832479
