1 /* |
1 /* |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
47 |
47 |
48 import jdk.jfr.AnnotationElement; |
48 import jdk.jfr.AnnotationElement; |
49 import jdk.jfr.SettingDescriptor; |
49 import jdk.jfr.SettingDescriptor; |
50 import jdk.jfr.ValueDescriptor; |
50 import jdk.jfr.ValueDescriptor; |
51 import jdk.jfr.internal.MetadataDescriptor.Element; |
51 import jdk.jfr.internal.MetadataDescriptor.Element; |
|
52 import jdk.jfr.internal.consumer.RecordingInput; |
|
53 import jdk.jfr.internal.consumer.StringParser; |
52 |
54 |
53 /** |
55 /** |
54 * Parses metadata. |
56 * Parses metadata. |
55 * |
57 * |
56 */ |
58 */ |
59 private final DataInput input; |
61 private final DataInput input; |
60 private final List<String> pool; |
62 private final List<String> pool; |
61 private final MetadataDescriptor descriptor; |
63 private final MetadataDescriptor descriptor; |
62 private final Map<Long, Type> types = new HashMap<>(); |
64 private final Map<Long, Type> types = new HashMap<>(); |
63 |
65 |
64 public MetadataReader(DataInput input) throws IOException { |
66 public MetadataReader(RecordingInput input) throws IOException { |
65 this.input = input; |
67 this.input = input; |
66 int size = input.readInt(); |
68 int size = input.readInt(); |
67 this.pool = new ArrayList<>(size); |
69 this.pool = new ArrayList<>(size); |
|
70 StringParser p = new StringParser(null, false); |
68 for (int i = 0; i < size; i++) { |
71 for (int i = 0; i < size; i++) { |
69 this.pool.add(input.readUTF()); |
72 this.pool.add((String) p.parse(input)); |
70 } |
73 } |
71 descriptor = new MetadataDescriptor(); |
74 descriptor = new MetadataDescriptor(); |
72 Element root = createElement(); |
75 Element root = createElement(); |
73 Element metadata = root.elements("metadata").get(0); |
76 Element metadata = root.elements("metadata").get(0); |
74 declareTypes(metadata); |
77 declareTypes(metadata); |