On Thu, 8 Oct 2026 08:52:39 GMT, Serguei Spitsyn <[email protected]> wrote:

>> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/FlatArray.java line 
>> 37:
>> 
>>> 35: // A FlatArray is an array containing flattened value objects.
>>> 36: 
>>> 37: public class FlatArray extends ObjArray {
>> 
>> Q: Changing the inherited class from `Array` to `ObjArray` is suspisious.
>> The following methods may need overriding: `isObjArray()`, 
>> `getOopHandleAt()`, and `getObjAt()`.
>> Also, you may need to check `instanceof ObjArray` use-sites to correctly 
>> handle `FlatArray` cases:
>> 
>>    public Object readObject(Oop oop) throws ClassNotFoundException {
>>       . . .
>>       } else if (oop instanceof ObjArray){
>>          return readObjectArray((ObjArray)oop);
>>       } else {
>>          return null;
>>       }
>>    }
>>   . . .
>>                     public boolean doObj(Oop oop) {
>>                         try {
>>                             
>> writeHeapRecordPrologue(calculateOopDumpRecordSize(oop));
>>                             if (oop instanceof TypeArray) {
>>                                 writePrimitiveArray((TypeArray)oop);
>>                             } else if (oop instanceof ObjArray) {
>>                                 Klass klass = oop.getKlass();
>>                                 ObjArrayKlass oak = (ObjArrayKlass) klass;
>>                                 Klass bottomType = oak.getBottomKlass();
>>                                 if (bottomType instanceof InstanceKlass ||
>>                                     bottomType instanceof TypeArrayKlass) {
>>                                     writeObjectArray((ObjArray)oop);
>>                                 } else {
>>                                     writeInternalObject(oop);
>>                                 }
>>   . . .
>>         if (oop instanceof Instance || oop instanceof TypeArray) {
>>             return true;
>>         } else if (oop instanceof ObjArray) {
>>             ObjArrayKlass oak = (ObjArrayKlass) oop.getKlass();
>>             Klass bottomKlass = oak.getBottomKlass();
>>             return bottomKlass instanceof InstanceKlass ||
>>                    bottomKlass instanceof TypeArrayKlass;
>>         } else {
>>             return false;
>>         }
>>     }
>>   . . .
>>     protected int calculateOopDumpRecordSize(Oop oop) throws IOException {
>>         if (oop instanceof TypeArray taOop) {
>>             return calculatePrimitiveArrayDumpRecordSize(taOop);
>>         } else if (oop instanceof ObjArray oaOop) {
>>             Klass klass = oop.getKlass();
>>             ObjArrayKlass oak =...
>
> Also, do we have a test coverage for the cases above? It is worth to 
> double-check.

`flatArrayOopDesc` in HotSpot inherits `objArrayOopDesc`, so I think SA should 
follow it. Then `isObjArray()` keeps to return `true` in `FlatArray`.

I added both `getOopHandleAt()` and `getObjAt()` in new commit. I haven't seen 
any failures in jtreg tests. They include oop inspection to scan array 
elements. I'm not sure they are enough, but I believe it passed current 
criteria.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32849#discussion_r4225560518

Reply via email to