Java Code Examples for jdk.jfr.ValueDescriptor#getAnnotationElements()

The following examples show how to use jdk.jfr.ValueDescriptor#getAnnotationElements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeLibrary.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void addUserFields(Class<?> clazz, Type type, List<ValueDescriptor> dynamicFields) {
    Map<String, ValueDescriptor> dynamicFieldSet = new HashMap<>();
    for (ValueDescriptor dynamicField : dynamicFields) {
        dynamicFieldSet.put(dynamicField.getName(), dynamicField);
    }
    List<Type> newTypes = new ArrayList<>();
    for (Field field : Utils.getVisibleEventFields(clazz)) {
        ValueDescriptor vd = dynamicFieldSet.get(field.getName());
        if (vd != null) {
            if (!vd.getTypeName().equals(field.getType().getName())) {
                throw new InternalError("Type expected to match for field " + vd.getName() + " expected "  + field.getName() + " but got " + vd.getName());
            }
            for (AnnotationElement ae : vd.getAnnotationElements()) {
                newTypes.add(PrivateAccess.getInstance().getType(ae));
            }
            newTypes.add(PrivateAccess.getInstance().getType(vd));
        } else {
            vd = createField(field);
        }
        if (vd != null) {
            type.add(vd);
        }
    }
    addTypes(newTypes);
}
 
Example 2
Source File: TypeLibrary.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void addUserFields(Class<?> clazz, Type type, List<ValueDescriptor> dynamicFields) {
    Map<String, ValueDescriptor> dynamicFieldSet = new HashMap<>();
    for (ValueDescriptor dynamicField : dynamicFields) {
        dynamicFieldSet.put(dynamicField.getName(), dynamicField);
    }
    List<Type> newTypes = new ArrayList<>();
    for (Field field : Utils.getVisibleEventFields(clazz)) {
        ValueDescriptor vd = dynamicFieldSet.get(field.getName());
        if (vd != null) {
            if (!vd.getTypeName().equals(field.getType().getName())) {
                throw new InternalError("Type expected to match for field " + vd.getName() + " expected "  + field.getName() + " but got " + vd.getName());
            }
            for (AnnotationElement ae : vd.getAnnotationElements()) {
                newTypes.add(PrivateAccess.getInstance().getType(ae));
            }
            newTypes.add(PrivateAccess.getInstance().getType(vd));
        } else {
            vd = createField(field);
        }
        if (vd != null) {
            type.add(vd);
        }
    }
    addTypes(newTypes);
}
 
Example 3
Source File: TypeLibrary.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void addUserFields(Class<?> clazz, Type type, List<ValueDescriptor> dynamicFields) {
    Map<String, ValueDescriptor> dynamicFieldSet = new HashMap<>();
    for (ValueDescriptor dynamicField : dynamicFields) {
        dynamicFieldSet.put(dynamicField.getName(), dynamicField);
    }
    List<Type> newTypes = new ArrayList<>();
    for (Field field : Utils.getVisibleEventFields(clazz)) {
        ValueDescriptor vd = dynamicFieldSet.get(field.getName());
        if (vd != null) {
            if (!vd.getTypeName().equals(field.getType().getName())) {
                throw new InternalError("Type expected to match for field " + vd.getName() + " expected "  + field.getName() + " but got " + vd.getName());
            }
            for (AnnotationElement ae : vd.getAnnotationElements()) {
                newTypes.add(PrivateAccess.getInstance().getType(ae));
            }
            newTypes.add(PrivateAccess.getInstance().getType(vd));
        } else {
            vd = createField(field);
        }
        if (vd != null) {
            type.add(vd);
        }
    }
    addTypes(newTypes);
}
 
Example 4
Source File: MetadataWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void makeFieldElement(Element typeElement, ValueDescriptor v) {
    Element element = typeElement.newChild(ELEMENT_FIELD);
    element.addAttribute(ATTRIBUTE_NAME, v.getName());
    element.addAttribute(ATTRIBUTE_TYPE_ID, v.getTypeId());
    if (v.isArray()) {
        element.addAttribute(ATTRIBUTE_DIMENSION, 1);
    }
    if (PrivateAccess.getInstance().isConstantPool(v)) {
        element.addAttribute(ATTRIBUTE_CONSTANT_POOL, true);
    }
    for (AnnotationElement a : v.getAnnotationElements()) {
        makeAnnotation(element, a);
    }
}
 
Example 5
Source File: Events.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static AnnotationElement getAnnotation(ValueDescriptor v, Class<?> clazz) throws Exception {
    for (AnnotationElement a : v.getAnnotationElements()) {
        if (a.getTypeName().equals(clazz.getName())) {
            return a;
        }
    }

    throw new Exception("Could not find annotation " + clazz.getName());
}
 
Example 6
Source File: MetadataWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void makeFieldElement(Element typeElement, ValueDescriptor v) {
    Element element = typeElement.newChild(ELEMENT_FIELD);
    element.addAttribute(ATTRIBUTE_NAME, v.getName());
    element.addAttribute(ATTRIBUTE_TYPE_ID, v.getTypeId());
    if (v.isArray()) {
        element.addAttribute(ATTRIBUTE_DIMENSION, 1);
    }
    if (PrivateAccess.getInstance().isConstantPool(v)) {
        element.addAttribute(ATTRIBUTE_CONSTANT_POOL, true);
    }
    for (AnnotationElement a : v.getAnnotationElements()) {
        makeAnnotation(element, a);
    }
}
 
Example 7
Source File: Events.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static AnnotationElement getAnnotation(ValueDescriptor v, Class<?> clazz) throws Exception {
    for (AnnotationElement a : v.getAnnotationElements()) {
        if (a.getTypeName().equals(clazz.getName())) {
            return a;
        }
    }

    throw new Exception("Could not find annotation " + clazz.getName());
}
 
Example 8
Source File: MetadataWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void makeFieldElement(Element typeElement, ValueDescriptor v) {
    Element element = typeElement.newChild(ELEMENT_FIELD);
    element.addAttribute(ATTRIBUTE_NAME, v.getName());
    element.addAttribute(ATTRIBUTE_TYPE_ID, v.getTypeId());
    if (v.isArray()) {
        element.addAttribute(ATTRIBUTE_DIMENSION, 1);
    }
    if (PrivateAccess.getInstance().isConstantPool(v)) {
        element.addAttribute(ATTRIBUTE_CONSTANT_POOL, true);
    }
    for (AnnotationElement a : v.getAnnotationElements()) {
        makeAnnotation(element, a);
    }
}
 
Example 9
Source File: Events.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static AnnotationElement getAnnotation(ValueDescriptor v, Class<?> clazz) throws Exception {
    for (AnnotationElement a : v.getAnnotationElements()) {
        if (a.getTypeName().equals(clazz.getName())) {
            return a;
        }
    }

    throw new Exception("Could not find annotation " + clazz.getName());
}