结论:
直接使用 assert field != null; 可以快速的check属性,但是该方法会在使用反射的时候多一个属性
"$assertionsDisabled"
分析:
public class Assert { static final boolean $assertionsDisabled = !Assert.class.desiredAssertionStatus(); public static void main(String[] args) { if (!$assertionsDisabled) { if (System.currentTimeMillis() != 0L) { throw new AssertionError(); } } } }