I was just thinking and I wondered: since access control is only meant to provide protection against accident and not against fraud I was wondering if it is possible to access the values of hidden variables in Java?
Take for example
public Cat {
public int numberOfLegs = 4;
private int numberOfWhiskers = 42;
}
Is it possible to find the value of numberOfWhiskers from outside of this class?
Edit: I have read the thread in the link and I can see that by using SetAccesible() you can obtain the value of any private field you know the name of. Can we find the value of a field of which we do not know the name?
Note: this can be done in some languages such as C++ for example by use of pointers iterating across fields in the class.