Private Member Access Java

后端 未结 7 2262
盖世英雄少女心
盖世英雄少女心 2020-12-05 16:29

Is the private member access at the class level or at the object level. If it is at the object level, then the following code should not compile

    class Pr         


        
7条回答
  •  天命终不由人
    2020-12-05 17:03

    Note that you don't even need source level access to mess with private fields. By using java.lang.reflect.AccessibleObject.setAccessibe(), all code can access all private members of all other code unless you specify a security policy that disallows it.

    private is not by itself a security feature! It is merely a strong hint to other developers that something is an internal implementation detail that other parts on the code should not depend on.

提交回复
热议问题