fix recognition of inner class this guarded-by strings

Reviewed By: peterogithub

Differential Revision: D3620955

fbshipit-source-id: 374d078
master
Sam Blackshear 8 years ago committed by Facebook Github Bot 4
parent fa8ae3e5e9
commit 4490d9b033

@ -634,10 +634,12 @@ let add_guarded_by_constraints prop lexp pdesc =
(* programmers write @GuardedBy("MyClass.class") when the field is guarded by the class *)
guarded_by_str_is_class guarded_by_str (Procname.java_get_class_name java_pname)
| _ -> false in
(** return true if [guarded_by_str] is "<name_of_current_proc>.this" *)
(** return true if [guarded_by_str] is as suffix of "<name_of_current_proc>.this" *)
let guarded_by_str_is_current_class_this guarded_by_str = function
| Procname.Java java_pname ->
guarded_by_str = (Printf.sprintf "%s.this" (Procname.java_get_class_name java_pname))
let fully_qualified_this =
Printf.sprintf "%s.this" (Procname.java_get_class_name java_pname) in
string_is_suffix guarded_by_str fully_qualified_this
| _ -> false in
let extract_guarded_by_str item_annot =
let annot_extract_guarded_by_str (annot, _) =

@ -308,6 +308,36 @@ public class GuardedByExample {
nonExpression.toString();
}
// outer class this tests
@GuardedBy("GuardedByExample.this")
Object guardedByOuterThis;
synchronized void okOuterAccess() {
guardedByOuterThis = null;
}
// inner class this tests
private class Inner {
@GuardedBy("this")
Object guardedByInnerThis1;
@GuardedBy("Inner.this")
Object guardedByInnerThis2;
@GuardedBy("GuardedByExample$Inner.this")
Object guardedByInnerThis3;
synchronized void okAccess1() {
guardedByInnerThis1 = null;
}
synchronized void okAccess2() {
guardedByInnerThis2 = null;
}
synchronized void okAccess3() {
guardedByInnerThis3 = null;
}
}
// TODO: report on these cases
/*

Loading…
Cancel
Save