BehaviorCache { @CheckForNull public MethodBehavior peek(String signature) { MethodBehavior mb = behaviors.get(signature); if (mb != null) { return mb; } return hardcodedBehaviors().get(signature); }  void setFileContext(@Nullable SymbolicExecutionVisitor sev); void cleanup(); MethodBehavior methodBehaviorForSymbol(Symbol.MethodSymbol symbol); @CheckForNull MethodBehavior get(Symbol.MethodSymbol symbol); @CheckForNull MethodBehavior get(String signature); @CheckForNull MethodBehavior peek(String signature); @VisibleForTesting
  final Map<String, MethodBehavior> behaviors; }
@Test void test_peek() throws Exception { Set<String> testedPre = new HashSet<>(); Set<String> testedPost = new HashSet<>(); SECheck check = new SECheck() { @Override public ProgramState checkPreStatement(CheckerContext context, Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.METHOD_INVOCATION)) { Symbol.MethodSymbol symbol = (Symbol.MethodSymbol) ((MethodInvocationTree) syntaxNode).symbol(); MethodBehavior peekMethodBehavior = ((CheckerDispatcher) context).peekMethodBehavior(symbol); if ("isBlank".equals(symbol.name())) { assertThat(peekMethodBehavior).isNotNull(); } else { assertThat(peekMethodBehavior).isNull(); } testedPre.add(symbol.name()); } return context.getState(); } @Override public ProgramState checkPostStatement(CheckerContext context, Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.METHOD_INVOCATION)) { Symbol.MethodSymbol symbol = (Symbol.MethodSymbol) ((MethodInvocationTree) syntaxNode).symbol(); String methodName = symbol.name(); MethodBehavior peekMethodBehavior = ((CheckerDispatcher) context).peekMethodBehavior(symbol); if ("foo".equals(methodName) || "isBlank".equals(methodName)) { assertThat(peekMethodBehavior.isComplete()).isTrue(); } else if ("bar".equals(methodName)) { assertThat(peekMethodBehavior).isNull(); } testedPost.add(methodName); } return super.checkPostStatement(context, syntaxNode); } }; SymbolicExecutionVisitor sev = createSymbolicExecutionVisitor("src/test/files/se/BehaviorCachePeek.java", check); assertThat(sev.behaviorCache.peek("org.apache.commons.lang.StringUtils#isBlank(Ljava/lang/String;)Z").isComplete()).isTrue(); assertThat(sev.behaviorCache.peek("org.foo.A#foo()Z").isComplete()).isTrue(); assertThat(sev.behaviorCache.peek("org.foo.A#bar()Z")).isNull(); assertThat(sev.behaviorCache.peek("org.foo.A#unknownMethod()Z")).isNull(); assertThat(sev.behaviorCache.behaviors.keySet()).containsOnly("org.foo.A#foo()Z"); assertThat(testedPre).containsOnly("foo", "bar", "isBlank"); assertThat(testedPost).containsOnly("foo", "bar", "isBlank"); }