Class HeldLockAnalyzer.ExpectedLockCalculator

Enclosing class:

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 Details

    • from

      public static Optional<GuardedByExpression> from​( 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:

       class MyClass {
         final Object mu = new Object();
         int x;
       void m(MyClass myClass) {
      To determine the lock that must be held when accessing myClass.x, from is called with "myClass.x" and "mu", and returns "".