search

Home  >  Q&A  >  body text

java 定义private属性,怎么做到限制其他类的访问?

ringa_leeringa_lee2769 days ago516

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-18 10:41:00

    No detection at runtime, no difference in memory, you can hack it and call the private method

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:41:00

    Yes, it seems that its various attributes will be verified when loading, and then judged based on these attributes at runtime. I can’t remember the details clearly. .

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:41:00

    In the JVM, the definition of a class and the specific objects of this class are placed in different places. When a line of Java code wants to access a property of an object, the JVM will query which class the object belongs to, whether this class has this property, and if so, whether it can be accessed in the context of the code. The judgment of scope during execution is completely consistent with the judgment of scope during compilation.

    reply
    0
  • Cancelreply