Uploaded image for project: 'Java Mission Control'
  1. Java Mission Control
  2. JMC-7246

ClassCastException when opening heap dump

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 8.0.0
    • None
    • Mission Control Client
    • None

        As reported on the jmc-dev mailing list (https://mail.openjdk.java.net/pipermail/jmc-dev/2021-April/003530.html) by Tobias Stadler, a ClassCastException can be thrown when opening a heap dump with JOverflow:

        java.lang.ClassCastException: class java.lang.Integer cannot be cast to class org.openjdk.jmc.joverflow.heap.model.JavaHeapObject (java.lang.Integer is in module java.base of loader 'bootstrap'; org.openjdk.jmc.joverflow.heap.model.JavaHeapObject is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @718ad3a6)
        at org.openjdk.jmc.joverflow.heap.model.Snapshot.getObjectForId(Snapshot.java:208)
        at org.openjdk.jmc.joverflow.heap.model.Snapshot.dereferenceField(Snapshot.java:311)
        at org.openjdk.jmc.joverflow.heap.model.JavaObject.parseFields(JavaObject.java:253)
        at org.openjdk.jmc.joverflow.heap.model.JavaObject.getFields(JavaObject.java:83)
        at org.openjdk.jmc.joverflow.stats.BreadthFirstHeapScanner.scanObjectsFromRootObj(BreadthFirstHeapScanner.java:110)
        at org.openjdk.jmc.joverflow.stats.HeapScaner.analyzeViaAllObjectsEnum(HeapScaner.java:132)
        at org.openjdk.jmc.joverflow.stats.DetailedStatsCalculator.calculate(DetailedStatsCalculator.java:142)
        at org.openjdk.jmc.joverflow.stats.StandardStatsCalculator.calculate(StandardStatsCalculator.java:74)
        at org.openjdk.jmc.joverflow.ui.model.ModelLoader.run(ModelLoader.java:103)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)

        He proposes the following fix:
        diff --git a/application/org.openjdk.jmc.joverflow/src/main/java/org/openjdk/jmc/joverflow/heap/model/Snapshot.java b/application/org.openjdk.jmc.joverflow/src/main/java/org/openjdk/jmc/joverflow/heap/model/Snapshot.java
        index 16f56b57..64330571 100644
        — a/application/org.openjdk.jmc.joverflow/src/main/java/org/openjdk/jmc/joverflow/heap/model/Snapshot.java
        +++ b/application/org.openjdk.jmc.joverflow/src/main/java/org/openjdk/jmc/joverflow/heap/model/Snapshot.java
        @@ -771,7 +771,7 @@ public class Snapshot {
        }

        // Create fake instance class

        • return new JavaClass(name, 0, 0, 0, 0, fields, JavaClass.NO_FIELDS, JavaClass.NO_VALUES, instSize,
          + return new JavaClass(classID, name, 0, 0, 0, 0, fields, JavaClass.NO_FIELDS, JavaClass.NO_VALUES, instSize,
          getInMemoryInstanceSize(instSize));
          }

              hirt Marcus Hirt
              hirt Marcus Hirt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: