What concurrency warnings should I get from findbugs?

I have the following code:

import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;

@ThreadSafe
public class Aoeu {
    @GuardedBy("this")
    private long aoeu;

    public long getAoeu() {
        return aoeu;
    }

    public void setAoeu(long aoeu) {
        this.aoeu = aoeu;
    }
}

From what I've read, findbugs understands jcip annotations (in fact, they're included with 1.3.9), but I don't get any warnings from the above code According to, I hope to see:

IS: Field not guarded against concurrent access (IS_FIELD_NOT_GUARDED)

This field is annotated with net.jcip.annotations.GuardedBy,but can be accessed in a way that seems to violate the annotation.

Solution

Please check the code below, which shows the error

class Test 
        {
            @net.jcip.annotations.GuardedBy("this")
            private int field;
            /**
             * 
             */
            public test()
            {

            }

            /**
             * 
             */
            public void setField()
            {
                field++;
            }

        }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>