On Fri, 24 Jun 2022 20:32:02 GMT, Ryan Ernst <d...@openjdk.org> wrote:
>> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java >> line 540: >> >>> 538: Iterator<Field> itr = null; >>> 539: // loader + signer + protectionDomain + 2 reserved + >>> fieldSize + cpool entris number >>> 540: size += (int) (OBJ_ID_SIZE * 5 + INT_SIZE + SHORT_SIZE); >> >> Why are INT_SIZE and SHORT_SIZE longs? It seems that making them int (along >> with all the other related _SIZE fields) is the proper fix for this and the >> changes below. > > These come from ObjectHeap. I do agree it would be better to change these > upstream (all the type sizes there are currently `long`), but that would be a > much more invasive change. I'm happy to try that, but it looked like a can of > worms. Unfortunately that eventually leads to Type.getSize(), which returns a long. I don't think you can change it to return an int, because some types (nonscalar) could need a long to fit their size, so you do need an int cast some point later. Probably the cast should be in the following code since we know all of these fit an in int: public ObjectHeap(TypeDataBase db) throws WrongTypeException { // Get commonly used sizes of basic types oopSize = VM.getVM().getOopSize(); byteSize = db.getJByteType().getSize(); charSize = db.getJCharType().getSize(); booleanSize = db.getJBooleanType().getSize(); intSize = db.getJIntType().getSize(); shortSize = db.getJShortType().getSize(); longSize = db.getJLongType().getSize(); floatSize = db.getJFloatType().getSize(); doubleSize = db.getJDoubleType().getSize(); } ------------- PR: https://git.openjdk.org/jdk/pull/9280