static final boolean $assertionsDisabled; /* synthetic field */
if(!$assertionsDisabled && ((WeakReference)oIterActive).get() != iter)
throw new AssertionError();
static
{
$assertionsDisabled = !(SafeHashMap.class).desiredAssertionStatus();
}
|
to
1 | assert ((WeakReference)oIterActive).get() == iter;//注意条件相反
|
又一例:
1 | protected String getStackTrace(Throwable e)
{
if(!$assertionsDisabled && e == null)
{
throw new AssertionError();
} else
{
StringWriter writer = new StringWriter();
PrintWriter stream = new PrintWriter(writer);
e.printStackTrace(stream);
stream.flush();
stream.close();
return writer.toString();
}
}
|
to
1 | protected String getStackTrace(Throwable e)
{
assert(e!=null);
StringWriter writer = new StringWriter();
PrintWriter stream = new PrintWriter(writer);
e.printStackTrace(stream);
stream.flush();
stream.close();
return writer.toString();
} |