I understand that using access modifiers is an important practice when writing Java (or most) code, but isn't it effectively made redundant by the fact that you can bypass these modifiers using reflection?
例如,如果我想通过将对象敏感变量设置为私有并提供访问器方法来保护我的对象,则仍然可以轻松地有人使用反射来进入并绕过它,并可能设置不安全的值。为什么Java提供访问修饰符,然后提供绕过它们的工具?不使用它们似乎会更容易。