Class HeldLockAnalyzer.ExpectedLockCalculator
- java.lang.Object
-
- com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer.ExpectedLockCalculator
-
- Enclosing class:
- HeldLockAnalyzer
public static final class HeldLockAnalyzer.ExpectedLockCalculator extends Object
Utility for discovering the lock expressions that needs to be held when accessing specific guarded members.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<GuardedByExpression>
from(com.sun.tools.javac.tree.JCTree.JCExpression guardedMemberExpression, GuardedByExpression guard, VisitorState state, GuardedByFlags flags)
Determine the lock expression that needs to be held when accessing a specific guarded member.
-
-
-
Method Detail
-
from
public static Optional<GuardedByExpression> from(com.sun.tools.javac.tree.JCTree.JCExpression guardedMemberExpression, GuardedByExpression guard, VisitorState state, GuardedByFlags flags)
Determine the lock expression that needs to be held when accessing a specific guarded member.If the lock expression resolves to an instance member, the result will be a select expression with the same base as the original guarded member access.
For example:
To determine the lock that must be held when accessing myClass.x, from is called with "myClass.x" and "mu", and returns "myClass.mu".class MyClass { final Object mu = new Object(); @GuardedBy("mu") int x; } void m(MyClass myClass) { myClass.x++; }
-
-