equal
deleted
inserted
replaced
37 |
37 |
38 import jdk.jfr.EventType; |
38 import jdk.jfr.EventType; |
39 import jdk.jfr.internal.MetadataDescriptor; |
39 import jdk.jfr.internal.MetadataDescriptor; |
40 import jdk.jfr.internal.Type; |
40 import jdk.jfr.internal.Type; |
41 import jdk.jfr.internal.consumer.ChunkHeader; |
41 import jdk.jfr.internal.consumer.ChunkHeader; |
|
42 import jdk.jfr.internal.consumer.FileAccess; |
42 import jdk.jfr.internal.consumer.RecordingInput; |
43 import jdk.jfr.internal.consumer.RecordingInput; |
43 |
44 |
44 /** |
45 /** |
45 * A recording file. |
46 * A recording file. |
46 * <p> |
47 * <p> |
79 * @throws SecurityException if a security manager exists and its |
80 * @throws SecurityException if a security manager exists and its |
80 * {@code checkRead} method denies read access to the file. |
81 * {@code checkRead} method denies read access to the file. |
81 */ |
82 */ |
82 public RecordingFile(Path file) throws IOException { |
83 public RecordingFile(Path file) throws IOException { |
83 this.file = file.toFile(); |
84 this.file = file.toFile(); |
84 this.input = new RecordingInput(this.file); |
85 this.input = new RecordingInput(this.file, FileAccess.UNPRIVILIGED); |
85 findNext(); |
86 findNext(); |
86 } |
87 } |
87 |
88 |
88 /** |
89 /** |
89 * Reads the next event in the recording. |
90 * Reads the next event in the recording. |
132 public List<EventType> readEventTypes() throws IOException { |
133 public List<EventType> readEventTypes() throws IOException { |
133 ensureOpen(); |
134 ensureOpen(); |
134 MetadataDescriptor previous = null; |
135 MetadataDescriptor previous = null; |
135 List<EventType> types = new ArrayList<>(); |
136 List<EventType> types = new ArrayList<>(); |
136 HashSet<Long> foundIds = new HashSet<>(); |
137 HashSet<Long> foundIds = new HashSet<>(); |
137 try (RecordingInput ri = new RecordingInput(file)) { |
138 try (RecordingInput ri = new RecordingInput(file, FileAccess.UNPRIVILIGED)) { |
138 ChunkHeader ch = new ChunkHeader(ri); |
139 ChunkHeader ch = new ChunkHeader(ri); |
139 aggregateEventTypeForChunk(ch, null, types, foundIds); |
140 aggregateEventTypeForChunk(ch, null, types, foundIds); |
140 while (!ch.isLastChunk()) { |
141 while (!ch.isLastChunk()) { |
141 ch = ch.nextHeader(); |
142 ch = ch.nextHeader(); |
142 previous = aggregateEventTypeForChunk(ch, previous, types, foundIds); |
143 previous = aggregateEventTypeForChunk(ch, previous, types, foundIds); |
148 List<Type> readTypes() throws IOException { |
149 List<Type> readTypes() throws IOException { |
149 ensureOpen(); |
150 ensureOpen(); |
150 MetadataDescriptor previous = null; |
151 MetadataDescriptor previous = null; |
151 List<Type> types = new ArrayList<>(); |
152 List<Type> types = new ArrayList<>(); |
152 HashSet<Long> foundIds = new HashSet<>(); |
153 HashSet<Long> foundIds = new HashSet<>(); |
153 try (RecordingInput ri = new RecordingInput(file)) { |
154 try (RecordingInput ri = new RecordingInput(file, FileAccess.UNPRIVILIGED)) { |
154 ChunkHeader ch = new ChunkHeader(ri); |
155 ChunkHeader ch = new ChunkHeader(ri); |
155 ch.awaitFinished(); |
156 ch.awaitFinished(); |
156 aggregateTypeForChunk(ch, null, types, foundIds); |
157 aggregateTypeForChunk(ch, null, types, foundIds); |
157 while (!ch.isLastChunk()) { |
158 while (!ch.isLastChunk()) { |
158 ch = ch.nextHeader(); |
159 ch = ch.nextHeader(); |