Skip to content

Commit 90165cf

Browse files
committed
7403: Fix JFR Parser struct types hashcode
Reviewed-by: jbachorik, jpbempel
1 parent 4d413ee commit 90165cf

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/ParserStats.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.openjdk.jmc.common.item.IType;
5959
import org.openjdk.jmc.common.item.ItemCollectionToolkit;
6060
import org.openjdk.jmc.common.unit.IQuantity;
61-
import org.openjdk.jmc.common.unit.StructContentType;
6261
import org.openjdk.jmc.common.unit.UnitLookup;
6362
import org.openjdk.jmc.common.util.MemberAccessorToolkit;
6463
import org.openjdk.jmc.flightrecorder.IParserStats.IEventStats;
@@ -363,6 +362,7 @@ public String toString() {
363362
}
364363

365364
private static class ConstantPoolInfo {
365+
@SuppressWarnings("unused")
366366
final long id;
367367
final String name;
368368
final FastAccessNumberMap<Object> constantPool;

core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/StructTypes.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,11 @@ public int hashCode() {
692692

693693
@Override
694694
public boolean equals(Object obj) {
695-
ensureParsed();
696695
if (this == obj) {
697696
return true;
698-
} else if (obj instanceof JfrFrame) {
697+
}
698+
if (obj instanceof JfrFrame) {
699+
ensureParsed();
699700
JfrFrame of = (JfrFrame) obj;
700701
return Objects.equals(of.type, type) && Objects.equals(of.method, method)
701702
&& Objects.equals(of.lineNumber, lineNumber) && Objects.equals(of.bytecodeIndex, bytecodeIndex);
@@ -749,10 +750,11 @@ public int hashCode() {
749750

750751
@Override
751752
public boolean equals(Object obj) {
752-
ensureParsed();
753753
if (this == obj) {
754754
return true;
755-
} else if (obj instanceof JfrStackTrace) {
755+
}
756+
if (obj instanceof JfrStackTrace) {
757+
ensureParsed();
756758
JfrStackTrace ost = (JfrStackTrace) obj;
757759
return Objects.equals(ost.frames, frames) && Objects.equals(ost.truncated, truncated);
758760
}
@@ -763,9 +765,15 @@ private void ensureParsed() {
763765
if (!isParsed) {
764766
// The 'frames' field is used in hashCode and equality computations but may change when parsed
765767
// Force parsing the field to make the hashCode and equality computations to perform consistently
766-
getFrames();
768+
getFrames().forEach(JfrStackTrace::ensureParsedFrame);
767769
isParsed = true;
768770
}
769771
}
772+
773+
private static void ensureParsedFrame(IMCFrame f) {
774+
if (f instanceof JfrFrame) {
775+
((JfrFrame) f).ensureParsed();
776+
}
777+
}
770778
}
771779
}

0 commit comments

Comments
 (0)