DEV Community

Molossus Spondee
Molossus Spondee

Posted on

Well and truly uninstantiable Java classes

public class Privileged {
    public Privileged(){
        super();
        checkPermissions();
    }
}

Is insufficient due to tricks with race conditions.

public class Privileged {
    public Privileged(){
        this(checkPermission());
    }
    private Privileged(Void dummy) {}
}

Is the proper procedure

Top comments (0)