Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248017

JFR: Remove Javadoc warnings

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 16
    • hotspot
    • None
    • jfr
    • minimal
    • The access modifiers of two methods are made more restricted, but there was no practical way a user could have taken advantage of the less restricted access.
    • Java API

      Summary

      Add a method parameter description to method jdk.jfr.EventType::getField(string), remove the protected modifier for two methods in the jdk.jfr.consumer package and remove the internal base class jdk.jfr.internal.Control from the inheritance chain of class jdk.jfr.SettingControl.

      Problem

      Some methods and classes are undocumented which results in javadoc warnings even though it is not possible for a user to call or access those classes and methods. Furthermore, a method in the jdk.jfr.EventType class lacks a @param description which results in a Javadoc warning.

      Solution

      1) Add a missing parameter description for the method jdk.jfr.EventType::getField(String name).

      2) The class jdk.jfr.consumer.RecordedObject has a package private constructor which effectively makes the class impossible to subclass outside the package jdk.jfr.consumer. But it has a method RecordedObject::objectAt(int) declared protected. Removing the protected modifier from the method, so it becomes package private, will remove it from the Javadoc. All subclasses of RecordedObject are in the same package and declared final so there is no practical way a user could invoke or override the method. The class jdk.jfr.consumer.RecordedEvent is a subclass to RecordedObject, and the protected modifier of the objectAt(int) method will be removed from there as well. Changing the modifiers should be safe from a compatibility perspective.

      3) The public accessible abstract class jdk.jfr.SettingControl is a subclass of the internal class jdk.jfr.internal.Control and overrides three abstract methods, String combine(Set), setValue(String) and getValue(). This makes the internal class show up in the Javadoc and there are warnings that the abstract methods in the Control class are undocumented. Changing so that SettingControl derives from java.lang.Object and instead use delegation in the implementation will prevent warnings and make the internal class invisible to the outside. Subclasses to SettingControl can't call a method of an internal class due to module boundaries, so the change should be safe. To prevent users from cloning objects of subclasses of SettingControl, the clone method of jdk.jfr.internal.Control class was overridden and made final. This restriction will no longer apply, so an alternative mechanism will be added to ensure that an unsecure object can't be constructed.

      Specification

      jdk.jfr.EventType

      diff --git a/src/jdk.jfr/share/classes/jdk/jfr/EventType.java b/src/jdk.jfr/share/classes/jdk/jfr/EventType.java
      --- a/src/jdk.jfr/share/classes/jdk/jfr/EventType.java
      +++ b/src/jdk.jfr/share/classes/jdk/jfr/EventType.java
      @@ -67,6 +67,8 @@
            * Returns the field with the specified name, or {@code null} if it doesn't
            * exist.
            *
      +     * @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
            */

      jdk.jfr.consumer.RecordededObject

      diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java      
      b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java
      --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java
      +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java
      @@ -254,7 +254,7 @@
               return t;
           }
      
      -    protected Object objectAt(int index) {
      +    Object objectAt(int index) {
               return objects[index];
           }

      jdk.jfr.consumer.RecordedEvent

      diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java
      b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java
      --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java
      +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java
      @@ -120,7 +120,7 @@
               return objectContext.fields;
           }
      
      -    protected final Object objectAt(int index) {
      +    final Object objectAt(int index) {
               if (index == 0) {
                   return startTimeTicks;
               }

      jdk.jfr.SettingControl

      diff --git a/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java
      b/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java
      --- a/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java
      +++ b/src/jdk.jfr/share/classes/jdk/jfr/SettingControl.java
      @@ -139,14 +140,29 @@
        * @since 9
        */
       @MetadataDefinition
      -public abstract class SettingControl extends Control {
      +public abstract class SettingControl {
      +
      +    private final AccessControlContext context;
      +    private final boolean initialized;

            egahlin Erik Gahlin
            egahlin Erik Gahlin
            Markus Grönlund
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: