Skip to content
Permalink
Browse files
8254565: JFR: Incorrect verification of mirror events
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Apr 21, 2021
1 parent f45d460 commit 71163213cbbc587842ea2dd5ce90e314ab52f6d5
Showing 1 changed file with 16 additions and 15 deletions.
@@ -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) {

1 comment on commit 7116321

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 7116321 Apr 21, 2021

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.