8281853: serviceability/sa/ClhsdbThreadContext.java failed with NullPointerException: Cannot invoke "sun.jvm.hotspot.gc.shared.GenCollectedHeap.getGen(int)" because "this.heap" is null

Reviewed-by: kevinw, sspitsyn
This commit is contained in:
Chris Plummer 2022-03-29 18:38:42 +00:00
parent f9f439a19d
commit 2fef5d4a33
2 changed files with 4 additions and 4 deletions

View File

@ -87,6 +87,7 @@ public class PointerFinder {
if (heap instanceof GenCollectedHeap) {
GenCollectedHeap genheap = (GenCollectedHeap) heap;
if (genheap.isIn(a)) {
loc.heap = heap;
for (int i = 0; i < genheap.nGens(); i++) {
Generation g = genheap.getGen(i);
if (g.isIn(a)) {

View File

@ -107,22 +107,21 @@ public class PointerLocation {
}
public boolean isInHeap() {
return (heap != null || (gen != null));
return (heap != null);
}
public boolean isInNewGen() {
return ((gen != null) && (gen == ((GenCollectedHeap)heap).getGen(0)));
return ((gen != null) && (gen.equals(((GenCollectedHeap)heap).getGen(0))));
}
public boolean isInOldGen() {
return ((gen != null) && (gen == ((GenCollectedHeap)heap).getGen(1)));
return ((gen != null) && (gen.equals(((GenCollectedHeap)heap).getGen(1))));
}
public boolean inOtherGen() {
return (!isInNewGen() && !isInOldGen());
}
/** Only valid if isInHeap() */
public Generation getGeneration() {
return gen;
}