In the Java reflection world -
how do we find out if a Field object has the transient modifier?
http://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html
the documentation is not helping.
Transient in Java is used to indicate that a field should not be part of the serialization process. The modifier Transient can be applied to member variables of a class to turn off serialization on these member variables. Every field that is marked as transient will not be serialized.
There are several modifiers that may be part of a field declaration: Access modifiers: public , protected , and private. Field-specific modifiers governing runtime behavior: transient and volatile. Modifier restricting to one instance: static.
Reflection is a feature in the Java programming language. It allows an executing Java program to examine or "introspect" upon itself, and manipulate internal properties of the program. For example, it's possible for a Java class to obtain the names of all its members and display them.
import java.lang.reflect.Field; import java.lang.reflect.Modifier; Field field = YourClass.class.getField("fieldName"); boolean isTransient = Modifier.isTransient(field.getModifiers());
For more details see Class Modifier
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With