Where can I find a document to understand about JAVA/Reflection like below code ?
Field.class.getDeclaredField("modifiers")
What is getDeclaredField does?
What is a term "modifiers" do ?
I have seen reflection code in action from here
Where can I find a document to understand about JAVA/Reflection like below code ?
Field.class.getDeclaredField("modifiers")
What is getDeclaredField does?
What is a term "modifiers" do ?
I have seen reflection code in action from here
From the javadoc which should be the first place you look when something is puzzling you.
What is
getDeclaredField
does?
The method getDeclaredField(String name)
Returns a
Field
object that reflects the specified declared field of the class or interface represented by thisClass
object.
What is a term "modifiers" do ?
"modifiers" here represents the name of the field to retrieve, as stated into the javadoc:
The name parameter is a
String
that specifies the simple name of the desired field.
To summarize Field.class.getDeclaredField("modifiers")
, will get by reflection the field modifiers
from the class Field
.
public final class Field extends AccessibleObject implements Member {
...
private int modifiers; <-- this
...