Class HeldLockAnalyzer.ExpectedLockCalculator
java.lang.Object
com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer.ExpectedLockCalculator
- Enclosing class:
HeldLockAnalyzer
Utility for discovering the lock expressions that needs to be held when accessing specific
guarded members.
- Author:
- cushon@google.com (Liam Miller-Cushon)
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
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++; }
-