Module jdk.jfr

Class RecordedObject

    • Method Detail

      • hasField

        public boolean hasField​(String name)
        Returns true if a field with given name exists, false otherwise.
        Parameters:
        name - name of the field
        Returns:
        true if the field exists, false otherwise.
        See Also:
        getFields()
      • getValue

        public final <T> T getValue​(String name)
        Returns the value of the field with the given name.

        The return type may be a primitive type or a subclass of RecordedObject.

        Callers of this method should not assume that a field will always remain, for instance a field may be removed in a future JDK version.

        It's possible to index into a nested object using ".", for instance "thread.group.parent.name".

        Example,

         
         if (event.hasField("intValue") {
           int intValue = event.getValue("intValue");
           System.out.println("Int value: " + intValue);
         }
        
         if (event.hasField("objectClass") {
           RecordedClass clazz = event.getValue("objectClass");
           System.out.println("Class name: " + clazz.getName());
         }
        
         if (event.hasField("sampledThread") {
           RecordedThread sampledThread= event.getValue("sampledThread");
           System.out.println("Sampled thread: " + sampledThread.getName());
         }
         
         
        Type Parameters:
        T - the return type
        Parameters:
        name - name of the field to get, not null
        Returns:
        value the value, can be null
        Throws:
        IllegalArgumentException - if there is no field called name .
        See Also:
        hasField(String)
      • getFields

        public List<ValueDescriptor> getFields​()
        Returns an immutable list of the fields for this object.
        Returns:
        the fields, not null
      • toString

        public final String toString​()
        Returns a textual representation of this object.
        Overrides:
        toString in class Object
        Returns:
        textual description of thsi object