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

原文链接:Well and truly uninstantiable Java classes

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容