is this Singleton resistant to both Serialization and Reflection Attacks?

后端 未结 5 392
死守一世寂寞
死守一世寂寞 2021-02-04 22:25

Is the following code resistant to both Serialization and Reflection Attacks?

public class Example{
  private static Example instance=new Example();

  private E         


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 22:35

    As far as reflection is concerned , the singleton in context is NOT reflection proof. U can use setAccssible(true) to get hold of private constructor and instantiate the singleton. You can get more details about this thing at - http://technonstop.com/java-singleton-reflection-and-lazy-initialization

提交回复
热议问题