I have a java class named Test
which has a single, private constructor because I require it to be a singleton, like this:
class Test {
private static final Test INSTANCE = new Test();
private Test() { }
public static Test getInstance() { return INSTANCE; }
// other code
}
How to prevent others from instantiating Test
through reflection in Java?