This is because you are not checking if the protectedBuffer field is available when you do firstBaseField.isAccessible();
What happens here is that you are checking the AccessibleObject value, which is the base class for the field. This flag does not tell you if the field is accessible using java access modifiers, it tells you whether these modifiers are ignored.
When you get false on firstBaseField.isAccessible() , it just means that the Java access rules are still in place and are not overridden by reflection mechanisms.
setAccessible ()
Set the available flag for this object to the specified boolean value. A value of true indicates that the reflected object should suppress access checks for the Java language when it is used. A value of false indicates that the reflected object should provide access control for the Java language.
Edit
To check if a field is accessible using java access modifiers, you can try to access it and catch an IllegalAccessException , as in the example below.
Field field = instance.getClass().getDeclaredField("someField");
source share