Skip to content
Permalink
Browse files
7403: Fix JFR Parser struct types hashcode
Reviewed-by: jbachorik, jpbempel
  • Loading branch information
thegreystone committed Oct 4, 2021
1 parent 4d413ee commit 90165cfb10f573fb68e1d233e08e8d969ace2811
Showing 2 changed files with 14 additions and 6 deletions.
@@ -58,7 +58,6 @@
import org.openjdk.jmc.common.item.IType;
import org.openjdk.jmc.common.item.ItemCollectionToolkit;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.StructContentType;
import org.openjdk.jmc.common.unit.UnitLookup;
import org.openjdk.jmc.common.util.MemberAccessorToolkit;
import org.openjdk.jmc.flightrecorder.IParserStats.IEventStats;
@@ -363,6 +362,7 @@ public String toString() {
}

private static class ConstantPoolInfo {
@SuppressWarnings("unused")
final long id;
final String name;
final FastAccessNumberMap<Object> constantPool;
@@ -692,10 +692,11 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
ensureParsed();
if (this == obj) {
return true;
} else if (obj instanceof JfrFrame) {
}
if (obj instanceof JfrFrame) {
ensureParsed();
JfrFrame of = (JfrFrame) obj;
return Objects.equals(of.type, type) && Objects.equals(of.method, method)
&& Objects.equals(of.lineNumber, lineNumber) && Objects.equals(of.bytecodeIndex, bytecodeIndex);
@@ -749,10 +750,11 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
ensureParsed();
if (this == obj) {
return true;
} else if (obj instanceof JfrStackTrace) {
}
if (obj instanceof JfrStackTrace) {
ensureParsed();
JfrStackTrace ost = (JfrStackTrace) obj;
return Objects.equals(ost.frames, frames) && Objects.equals(ost.truncated, truncated);
}
@@ -763,9 +765,15 @@ private void ensureParsed() {
if (!isParsed) {
// The 'frames' field is used in hashCode and equality computations but may change when parsed
// Force parsing the field to make the hashCode and equality computations to perform consistently
getFrames();
getFrames().forEach(JfrStackTrace::ensureParsedFrame);
isParsed = true;
}
}

private static void ensureParsedFrame(IMCFrame f) {
if (f instanceof JfrFrame) {
((JfrFrame) f).ensureParsed();
}
}
}
}

0 comments on commit 90165cf

Please sign in to comment.