- java.lang.Object
-
- java.lang.Enum<ReflectionAccessFilter.FilterResult>
-
- com.google.gson.ReflectionAccessFilter.FilterResult
-
- All Implemented Interfaces:
Serializable
,Comparable<ReflectionAccessFilter.FilterResult>
- Enclosing interface:
- ReflectionAccessFilter
public static enum ReflectionAccessFilter.FilterResult extends Enum<ReflectionAccessFilter.FilterResult>
Result of a filter check.- Since:
- 2.9.1
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ALLOW
Reflection access for the class is allowed.BLOCK_ALL
Blocks all reflection access for the class.BLOCK_INACCESSIBLE
Blocks reflection access if a member of the class is not accessible by default and would have to be made accessible.INDECISIVE
The filter is indecisive whether reflection access should be allowed.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ReflectionAccessFilter.FilterResult
valueOf(String name)
Returns the enum constant of this type with the specified name.static ReflectionAccessFilter.FilterResult[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 likeALLOW
.
-
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 anyjava
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 aSecurityManager
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)
-
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 aTypeAdapter
, have to be used.
-
-
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 nameNullPointerException
- if the argument is null
-
-