What concurrency warnings should you expect 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 read, FindBugs understands JCiP annotations (indeed, ship 1.3.9 comes with them), but I do not receive any warnings from the above code. According to, I expect 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. 
+4
source share
1 answer

Please check below code which shows error

 class Test { @net.jcip.annotations.GuardedBy("this") private int field; /** * */ public Test() { } /** * */ public void setField() { field++; } } 
+1
source

Source: https://habr.com/ru/post/1385958/


All Articles