Enum Class ReflectionAccessFilter.FilterResult

java.lang.Object
java.lang.Enum<ReflectionAccessFilter.FilterResult>
com.google.gson.ReflectionAccessFilter.FilterResult
All Implemented Interfaces:
Serializable, Comparable<ReflectionAccessFilter.FilterResult>, Constable
Enclosing interface:
ReflectionAccessFilter

public static enum ReflectionAccessFilter.FilterResult extends Enum<ReflectionAccessFilter.FilterResult>
Result of a filter check.
  • Enum Constant Details

    • ALLOW

      public static final ReflectionAccessFilter.FilterResult ALLOW
      Reflection access for the class is allowed.

      Note that this does not affect the Java access checks in any way, it only permits Gson to try using reflection for a class. The Java runtime might still deny such access.

    • INDECISIVE

      public static final ReflectionAccessFilter.FilterResult INDECISIVE
      The filter is indecisive whether reflection access should be allowed. The next registered filter will be consulted to get the result. If there is no next filter, this result acts like ALLOW.
    • BLOCK_INACCESSIBLE

      public static final ReflectionAccessFilter.FilterResult BLOCK_INACCESSIBLE
      Blocks reflection access if a member of the class is not accessible by default and would have to be made accessible. This is unaffected by any java command line arguments being used to make packages accessible, or by module declaration directives which open the complete module or certain packages for reflection and will consider such packages inaccessible.

      Note that this only works for Java 9 and higher, for older Java versions its functionality will be limited and it might behave like ALLOW. Access checks are only performed as defined by the Java Language Specification (JLS 11 §6.6), restrictions imposed by a SecurityManager are not considered.

      This result type is mainly intended to help enforce the access checks of the Java Platform Module System. It allows detecting illegal access, even if the used Java version would only log a warning, or is configured to open packages for reflection using command line arguments.

      See Also:
    • BLOCK_ALL

      public static final ReflectionAccessFilter.FilterResult BLOCK_ALL
      Blocks all reflection access for the class. Other means for serializing and deserializing the class, such as a TypeAdapter, have to be used.
  • Constructor Details

    • FilterResult

      private FilterResult()
  • Method Details

    • values

      public static ReflectionAccessFilter.FilterResult[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ReflectionAccessFilter.FilterResult valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null