How private writeObject method of Serializable object called by object of ObjectOutputStream

前端 未结 3 1666
眼角桃花
眼角桃花 2020-12-10 10:22

When i run this demo it\'s call TestBean\'s writeObject method which is private

How is it possible ?

Here is the Code:

import j         


        
3条回答
  •  伪装坚强ぢ
    2020-12-10 10:28

    It uses reflection. private and public are not security measures. That is only a contract for class users.

提交回复
热议问题