google / error-prone

Catch common Java mistakes as compile-time errors
https://errorprone.info
Apache License 2.0
6.86k stars 744 forks source link

A contrary for GuardedBy #366

Open AndreasMager opened 9 years ago

AndreasMager commented 9 years ago

A new annotation would be nice to mark a piece of code for deadlock problems.

example:

@NeverBy("this")
Object canCauseDeadlock = ...

...
synchronized (this) {
   canCauseDealock...   // <-- Warning
}
cushon commented 9 years ago

+1, sounds like a good addition.

The clang thread safety analysis calls that EXCLUDES(...) [1]. It's especially useful when your locks aren't re-entrant, but it'd still be nice to have in Java.

[1] http://clang.llvm.org/docs/ThreadSafetyAnalysis.html#excludes