Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JDK 17 jdk.jfr.jmod - JFR Module
JDK 17 jdk.jfr.jmod is the JMOD file for JDK 17 JFR module.
JDK 17 JFR module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.jfr.jmod.
JDK 17 JFR module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 JFR module source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.jfr.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/jfr/internal/MetadataReader.java
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package jdk.jfr.internal;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_CONSTANT_POOL;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_DIMENSION;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_ID;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_NAME;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_SIMPLE_TYPE;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_SUPER_TYPE;
import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_TYPE_ID;
import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_ANNOTATION;
import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_FIELD;
import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_SETTING;
import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_TYPE;
import java.io.DataInput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.jfr.AnnotationElement;
import jdk.jfr.SettingDescriptor;
import jdk.jfr.ValueDescriptor;
import jdk.jfr.internal.MetadataDescriptor.Element;
import jdk.jfr.internal.consumer.RecordingInput;
import jdk.jfr.internal.consumer.StringParser;
/**
* Parses metadata.
*
*/
final class MetadataReader {
private final DataInput input;
private final List<String> pool;
private final MetadataDescriptor descriptor;
private final Map<Long, Type> types = new HashMap<>();
public MetadataReader(RecordingInput input) throws IOException {
this.input = input;
int size = input.readInt();
input.require(size, "Metadata string pool size %d exceeds available data" );
this.pool = new ArrayList<>(size);
StringParser p = new StringParser(null, false);
for (int i = 0; i < size; i++) {
this.pool.add((String) p.parse(input));
}
descriptor = new MetadataDescriptor();
Element root = createElement();
Element metadata = root.elements("metadata").get(0);
declareTypes(metadata);
defineTypes(metadata);
annotateTypes(metadata);
buildEvenTypes();
Element time = root.elements("region").get(0);
descriptor.gmtOffset = time.attribute(MetadataDescriptor.ATTRIBUTE_GMT_OFFSET, 1);
descriptor.locale = time.attribute(MetadataDescriptor.ATTRIBUTE_LOCALE, "");
descriptor.root = root;
if (Logger.shouldLog(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE)) {
List<Type> ts = new ArrayList<>(types.values());
Collections.sort(ts, (x,y) -> x.getName().compareTo(y.getName()));
for (Type t : ts) {
t.log("Found", LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE);
}
}
}
private String readString() throws IOException {
return pool.get(readInt());
}
private int readInt() throws IOException {
return input.readInt();
}
private Element createElement() throws IOException {
String name = readString();
Element e = new Element(name);
int attributeCount = readInt();
for (int i = 0; i < attributeCount; i++) {
e.addAttribute(readString(), readString());
}
int childrenCount = readInt();
for (int i = 0; i < childrenCount; i++) {
e.add(createElement());
}
return e;
}
private void annotateTypes(Element metadata) throws IOException {
for (Element typeElement : metadata.elements(ELEMENT_TYPE)) {
Type type = getType(ATTRIBUTE_ID, typeElement);
ArrayList<AnnotationElement> aes = new ArrayList<>();
for (Element annotationElement : typeElement.elements(ELEMENT_ANNOTATION)) {
aes.add(makeAnnotation(annotationElement));
}
aes.trimToSize();
type.setAnnotations(aes);
int index = 0;
if (type instanceof PlatformEventType pType) {
List<SettingDescriptor> settings = pType.getAllSettings();
for (Element settingElement : typeElement.elements(ELEMENT_SETTING)) {
ArrayList<AnnotationElement> annotations = new ArrayList<>();
for (Element annotationElement : settingElement.elements(ELEMENT_ANNOTATION)) {
annotations.add(makeAnnotation(annotationElement));
}
annotations.trimToSize();
PrivateAccess.getInstance().setAnnotations(settings.get(index), annotations);
index++;
}
}
index = 0;
List<ValueDescriptor> fields = type.getFields();
for (Element fieldElement : typeElement.elements(ELEMENT_FIELD)) {
ArrayList<AnnotationElement> annotations = new ArrayList<>();
for (Element annotationElement : fieldElement.elements(ELEMENT_ANNOTATION)) {
annotations.add(makeAnnotation(annotationElement));
}
annotations.trimToSize();
PrivateAccess.getInstance().setAnnotations(fields.get(index), annotations);
index++;
}
}
}
private AnnotationElement makeAnnotation(Element annotationElement) throws IOException {
Type annotationType = getType(ATTRIBUTE_TYPE_ID, annotationElement);
List<Object> values = new ArrayList<>();
for (ValueDescriptor v : annotationType.getFields()) {
if (v.isArray()) {
List<Object> list = new ArrayList<>();
int index = 0;
while (true) {
String text = annotationElement.attribute(v.getName() + "-" + index);
if (text == null) {
break;
}
list.add(objectify(v.getTypeName(), text));
index++;
}
Object object = Utils.makePrimitiveArray(v.getTypeName(), list);
if (object == null) {
throw new IOException("Unsupported type " + list + " in array");
}
values.add(object);
} else {
String text = annotationElement.attribute(v.getName());
values.add(objectify(v.getTypeName(), text));
}
}
return PrivateAccess.getInstance().newAnnotation(annotationType, values, false);
}
private Object objectify(String typeName, String text) throws IOException {
try {
switch (typeName) {
case "int":
return Integer.valueOf(text);
case "long":
return Long.valueOf(text);
case "double":
return Double.valueOf(text);
case "float":
return Float.valueOf(text);
case "short":
return Short.valueOf(text);
case "char":
if (text.length() != 1) {
throw new IOException("Unexpected size of char");
}
return text.charAt(0);
case "byte":
return Byte.valueOf(text);
case "boolean":
return Boolean.valueOf(text);
case "java.lang.String":
return text;
}
} catch (IllegalArgumentException iae) {
throw new IOException("Could not parse text representation of " + typeName);
}
throw new IOException("Unsupported type for annotation " + typeName);
}
private Type getType(String attribute, Element element) {
long id = element.longValue(attribute);
Type type = types.get(id);
if (type == null) {
String name = element.attribute("type");
throw new IllegalStateException("Type '" + id + "' is not defined for " + name);
}
return type;
}
private void buildEvenTypes() {
for (Type type : descriptor.types) {
if (type instanceof PlatformEventType pType) {
descriptor.eventTypes.add(PrivateAccess.getInstance().newEventType(pType));
}
}
}
private void defineTypes(Element metadata) {
for (Element typeElement : metadata.elements(ELEMENT_TYPE)) {
long id = typeElement.attribute(ATTRIBUTE_ID, -1);
Type t = types.get(id);
for (Element fieldElement : typeElement.elements(ELEMENT_SETTING)) {
String name = fieldElement.attribute(ATTRIBUTE_NAME);
String defaultValue = fieldElement.attribute(ATTRIBUTE_NAME);
Type settingType = getType(ATTRIBUTE_TYPE_ID, fieldElement);
PlatformEventType eventType = (PlatformEventType) t;
eventType.add(PrivateAccess.getInstance().newSettingDescriptor(settingType, name, defaultValue, new ArrayList<>(2)));
}
for (Element fieldElement : typeElement.elements(ELEMENT_FIELD)) {
String name = fieldElement.attribute(ATTRIBUTE_NAME);
Type fieldType = getType(ATTRIBUTE_TYPE_ID, fieldElement);
long dimension = fieldElement.attribute(ATTRIBUTE_DIMENSION, 0);
boolean constantPool = fieldElement.attribute(ATTRIBUTE_CONSTANT_POOL) != null;
// Add annotation later, because they may refer to undefined
// types at this stage
t.add(PrivateAccess.getInstance().newValueDescriptor(name, fieldType, new ArrayList<>(), (int) dimension, constantPool, null));
}
t.trimFields();
}
}
private void declareTypes(Element metadata) {
for (Element typeElement : metadata.elements(ELEMENT_TYPE)) {
String typeName = typeElement.attribute(ATTRIBUTE_NAME);
String superType = typeElement.attribute(ATTRIBUTE_SUPER_TYPE);
boolean simpleType = typeElement.attribute(ATTRIBUTE_SIMPLE_TYPE) != null;
long id = typeElement.attribute(ATTRIBUTE_ID, -1);
Type t;
if (Type.SUPER_TYPE_EVENT.equals(superType)) {
t = new PlatformEventType(typeName, id, false, false);
} else {
t = new Type(typeName, superType, id, simpleType);
}
types.put(id, t);
descriptor.types.add(t);
}
}
public MetadataDescriptor getDescriptor() {
return descriptor;
}
}
⏎ jdk/jfr/internal/MetadataReader.java
Or download all of them as a single archive file:
File name: jdk.jfr-17.0.5-src.zip File size: 363343 bytes Release date: 2022-09-13 Download
⇒ JDK 17 jdk.jlink.jmod - JLink Tool
2023-04-17, ≈104🔥, 0💬
Popular Posts:
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
How to display types defined in an XML Schema file with the xs\QueryXS.java provided in the Apache X...
JDK 11 java.management.jmod is the JMOD file for JDK 11 Management module. JDK 11 Management module ...
Apache Commons CLI Source Code Files are provided in the source package file commons-cli-1.5.0-sourc. ..
Java Servlet 3.0 Specification API. JAR File Size and Download Location: File name: servlet-api.jar,...