RFR: 8256156: JFR: Allow 'jfr' tool to show metadata without a recording [v7]

Erik Gahlin egahlin at openjdk.java.net
Tue Feb 2 17:54:46 UTC 2021


On Tue, 2 Feb 2021 05:04:54 GMT, Yang Yi <github.com+5010047+kelthuzadx at openjdk.org> wrote:

>> Hi all,
>> 
>> May I please have a review for this minor patch?
>> 
>> It simplifies the use of subcommand `metadata` of jfr tool. Recording 
>> file is no longer mandatory, users can directly use `jfr metadata` to 
>> output JDK builtin meta information. As JDK-8256156 mentioned, it also 
>> supports events and categories filters:
>> $ jfr metadata 
>> $ jfr metadata recording.jfr # compatible
>> $ jfr metadata --events jdk.ThreadStart,jdk.ThreadEnd
>> $ jfr metadata --events jdk.ThreadStart,jdk.ThreadEnd recording.jfr
>> $ jfr metadata --categories GC,Detailed
>> $ jfr metadata --categories GC,Detailed recording.jfr
>
> Yang Yi has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.

src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Metadata.java line 213:

> 211:             if (file != null) {
> 212:                 try (RecordingFile rf = new RecordingFile(file)) {
> 213:                     types = rf.readEventTypes();

Maybe move this part into a separate method and remove the null check.

List<EventType> types = useEvenTypes(file);

private void useEventTypes(Path file) {
    if (file == null) {
       return new ArrayList<?>(FlightRecorder.getEventTypes());
   }
   try (RecordingFile rf = new RecordingFile(file)) {
           return rf.readEventTypes();
   } catch (IOException ioe) {
        couldNotReadError(file, ioe);
   }
}

src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Metadata.java line 225:

> 223:                 Collections.sort(types, new TypeComparator());
> 224:             }
> 225:             for (EventType type : types) {

This looks like a change of behavior, the metadata command no longer prints all the types, only event types.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1904


More information about the hotspot-jfr-dev mailing list