关于!$assertionsDisabled

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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    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
2
3
4
5
6
7
8
9
10
    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();
    }

你可能感兴趣的:(关于!$assertionsDisabled)