Summary
Clarify that RecordedObject::hasField(String) can access nested fields and add support for nested field access to EventType::getField(String).
Problem
JDK Flight Recorder can emit events with composite/struct values, for example methods and classes. To index into a nested value it is possible to use a ".", for example RecordedEvent::getValue("allocatedClass.name").
It is however not possible to access metadata about a value the same way, for example RecordedObject::hasField("allocatedClass.name") or EventType::getField("allocationClass.name"). This is inconvenient if you want to check if a field exist before you call getValue(String), or if you want to access metadata about a value, for example the unit.
Solution
The solution is to update the specification for RecordedObject:hasField(String) so it says that it is possible to use nested access, the implementation already supports it.
Also add support for nested field access for EventType::getField(String) and update the specification accordingly.
Specification
jdk.jfr.RecordedObject
/**
* Returns {@code true} if a field with the given name exists, {@code false} otherwise.
+ * <p>
+ * It's possible to index into a nested field by using {@code "."} (for
+ * instance {@code "thread.group.parent.name}").
*
* @param name name of the field to get, not {@code null}
*
* @return {@code true} if the field exists, {@code false} otherwise
*
* @see #getFields()
*/
public boolean hasField(String name) {
jdk.jfr.EventType
/**
* Returns the field with the specified name, or {@code null} if it doesn't
* exist.
+ * <p>
+ * It's possible to index into a nested field by using {@code "."} (for
+ * instance {@code "thread.group.parent.name}").
*
* @param name of the field to get, not {@code null}
*
* @return a value descriptor that describes the field, or {@code null} if
* the field with the specified name doesn't exist
*/
public ValueDescriptor getField(String name) {
- csr of
-
JDK-8253762 JFR: getField(String) should be able to access subfields
-
- Resolved
-