Enum ReflectionAccessFilter.FilterResult

    • Enum Constant Detail

      • 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:
        AccessibleObject.canAccess(Object)
    • Method Detail

      • values

        public static ReflectionAccessFilter.FilterResult[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ReflectionAccessFilter.FilterResult c : ReflectionAccessFilter.FilterResult.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ReflectionAccessFilter.FilterResult valueOf​(String name)
        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.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null