public enum RequiresOptIn.Level extends Enum

Severity of the diagnostic that should be reported on usages of opt-in API which did not explicitly accept the opt-in aspect of that API either by:

  • Propagating the opt-in aspect by annotating the usage with the marker annotation, thus becoming part of the marked opt-in API surface or
  • Suppressing propagation of the opt-in aspect by annotating the usage with [OptIn] and specifying the marker annotation

    Summary

    Enum Values

    ERROR

    Specifies that an error should be reported on incorrect usages of this opt-in API.

    WARNING

    Specifies that a warning should be reported on incorrect usages of this opt-in API.

    Enum Values

    Public methods

    valueOf

    public final @NonNull RequiresOptIn.Level valueOf(@NonNull String value)

    Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

    values

    public final @NonNull RequiresOptIn.Level[] values()

    Returns an array containing the constants of this enum type, in the order they're declared.

    This method may be used to iterate over the constants.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.