how do I find out if a Java field has the transient modifier?

java, reflection, transient

Solution

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

Problem

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.

Original source