Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8254565: JFR: Incorrect verification of mirror events
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Apr 21, 2021
1 parent f45d460 commit 7116321
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java
Expand Up @@ -661,37 +661,38 @@ public static void verifyMirror(Class<?> mirror, Class<?> real) {
Class<?> cMirror = Objects.requireNonNull(mirror);
Class<?> cReal = Objects.requireNonNull(real);

while (cReal != null) {
Map<String, Field> mirrorFields = new HashMap<>();
if (cMirror != null) {
for (Field f : cMirror.getDeclaredFields()) {
if (isSupportedType(f.getType())) {
mirrorFields.put(f.getName(), f);
}
Map<String, Field> mirrorFields = new HashMap<>();
while (cMirror != null) {
for (Field f : cMirror.getDeclaredFields()) {
if (isSupportedType(f.getType())) {
mirrorFields.put(f.getName(), f);
}
}
cMirror = cMirror.getSuperclass();
}
while (cReal != null) {
for (Field realField : cReal.getDeclaredFields()) {
if (isSupportedType(realField.getType())) {
String fieldName = realField.getName();
Field mirrorField = mirrorFields.get(fieldName);
if (mirrorField == null) {
throw new InternalError("Missing mirror field for " + cReal.getName() + "#" + fieldName);
}
if (realField.getType() != mirrorField.getType()) {
throw new InternalError("Incorrect type for mirror field " + fieldName);
}
if (realField.getModifiers() != mirrorField.getModifiers()) {
throw new InternalError("Incorrect modifier for mirror field "+ cMirror.getName() + "#" + fieldName);
throw new InternalError("Incorrect modifier for mirror field " + fieldName);
}
mirrorFields.remove(fieldName);
}
}
if (!mirrorFields.isEmpty()) {
throw new InternalError(
"Found additional fields in mirror class " + cMirror.getName() + " " + mirrorFields.keySet());
}
if (cMirror != null) {
cMirror = cMirror.getSuperclass();
}
cReal = cReal.getSuperclass();
}

if (!mirrorFields.isEmpty()) {
throw new InternalError("Found additional fields in mirror class " + mirrorFields.keySet());
}
}

private static boolean isSupportedType(Class<?> type) {
Expand Down

1 comment on commit 7116321

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.