Skip to content

NotJavadoc Regression in 2.49.0 #5739

@no-longer-human

Description

@no-longer-human

NotJavadoc in 2.49.0 refuses javadoc on statics in enum constants.

Example

package org.example;

/** Enum. */
@SuppressWarnings("unused")
public enum MyEnum {

  /** Value. */
  VALUE {

    /** Static variable. */
    static final int STATIC_1 = 1;
  }
}

This code is allowed in 2.48.0, but is rejected in 2.49.0 with the following message:

[NotJavadoc] Avoid using `/**` for comments which aren't actually Javadoc.
    (see https://errorprone.info/bugpattern/NotJavadoc)
  Did you mean '/* Static variable. */'?

Note that making the static variable public does not resolve the issue (it just results in a new EffectivelyPrivate error.)

Workaround

Static can be moved out of enum constant scope, if name is kept unique within the enum:

package org.example;

/** Enum. */
@SuppressWarnings("unused")
public enum MyEnum {

  /** Value. */
  VALUE {};

  /** Static variable. */
  static final int STATIC_1 = 1;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions