Skip to content

Commit 0c2ef0d

Browse files
committed
isArray() fixed for zero-instance arrays
1 parent c0594dd commit 0c2ef0d

File tree

1 file changed

+13
-3
lines changed
  • visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/heap

1 file changed

+13
-3
lines changed

visualvm/libs.profiler/lib.profiler/src/org/graalvm/visualvm/lib/jfluid/heap/ClassDump.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,25 @@ class ClassDump extends HprofObject implements JavaClass {
9393
//~ Methods ------------------------------------------------------------------------------------------------------------------
9494

9595
public long getAllInstancesSize() {
96-
if (isArray()) {
97-
return ((Long) classDumpSegment.arrayMap.get(this)).longValue();
96+
Long allInstancesSizeArr = (Long) classDumpSegment.arrayMap.get(this);
97+
98+
if (allInstancesSizeArr != null) {
99+
return allInstancesSizeArr.longValue();
98100
}
99101

100102
return ((long)getInstancesCount()) * getInstanceSize();
101103
}
102104

103105
public boolean isArray() {
104-
return classDumpSegment.arrayMap.get(this) != null;
106+
boolean isArrayWithInstances = classDumpSegment.arrayMap.get(this) != null;;
107+
108+
if (isArrayWithInstances) {
109+
return true;
110+
}
111+
if (instances != 0) {
112+
return false;
113+
}
114+
return getName().endsWith("[]");
105115
}
106116

107117
public Instance getClassLoader() {

0 commit comments

Comments
 (0)