Skip to content
Permalink
Browse files

8223066: "jfr metadata" output the @name annotation twice

Co-authored-by: Chihiro Ito <chiroito107@gmail.com>
Reviewed-by: mgronlun, egahlin
  • Loading branch information
Erik Gahlin and chiroito committed Feb 25, 2020
1 parent 53ee0c4 commit dd8dbb66ebdc80c8de61cc06214c8f0cb3f27cf8
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
import jdk.jfr.DataAmount;
import jdk.jfr.Frequency;
import jdk.jfr.MemoryAddress;
import jdk.jfr.Name;
import jdk.jfr.Percentage;
import jdk.jfr.ValueDescriptor;
import jdk.jfr.consumer.RecordedClass;
@@ -143,15 +144,17 @@ private void printCommentRef(int commentIndex, long typeId) {

private void printAnnotations(int commentIndex, List<AnnotationElement> annotations) {
for (AnnotationElement a : annotations) {
printIndent();
print("@");
print(makeSimpleType(a.getTypeName()));
List<ValueDescriptor> vs = a.getValueDescriptors();
if (!vs.isEmpty()) {
printAnnotation(a);
printCommentRef(commentIndex, a.getTypeId());
} else {
println();
if (!Name.class.getName().equals(a.getTypeName())) {
printIndent();
print("@");
print(makeSimpleType(a.getTypeName()));
List<ValueDescriptor> vs = a.getValueDescriptors();
if (!vs.isEmpty()) {
printAnnotation(a);
printCommentRef(commentIndex, a.getTypeId());
} else {
println();
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
package jdk.jfr.tool;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;

import jdk.jfr.EventType;
import jdk.jfr.consumer.RecordingFile;
@@ -59,5 +61,18 @@ public static void main(String[] args) throws Throwable {
output.shouldContain(name);
}
}
Set<String> annotations = new HashSet<>();
int lineNumber = 1;
for (String line : output.asLines()) {
if (line.startsWith("@")) {
if (annotations.contains(line)) {
throw new Exception("Line " + lineNumber + ":" + line + " repeats annotation");
}
annotations.add(line);
} else {
annotations.clear();
}
lineNumber++;
}
}
}

0 comments on commit dd8dbb6

Please sign in to comment.