cracking singleton with other ways

后端 未结 6 720
情深已故
情深已故 2020-12-07 05:20

I was doing research on singleton and I have developed a very basic singleton class..

public class SingletonObject {
    private static SingletonObject ref;
         


        
6条回答
  •  不思量自难忘°
    2020-12-07 06:07

    You can make the singleton constructor public using byte code engineering libraries.

    Also, in some older Java versions (this used to work in 1.3), you can simply create a class with the same name, with public constructor and the compile against that class. At runtime this allowed you to create instances of the real class (this loophole has been fixed in the bytecode verification in later JRE versions).

提交回复
热议问题