From 196c0e5544cc4d4bda2afac3d8e24d94275b903b Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Wed, 18 Apr 2018 04:48:04 -0700 Subject: [PATCH] [starvation] harmonize java formatting in tests Reviewed By: ddino Differential Revision: D7667305 fbshipit-source-id: efee0f8 --- .../java/starvation/Interclass.java | 32 ++++++++++------- .../java/starvation/Interproc.java | 36 +++++++++++-------- .../java/starvation/Intraproc.java | 32 +++++++++++------ .../java/starvation/LocalLock.java | 12 +++---- .../codetoanalyze/java/starvation/issues.exp | 6 ++-- 5 files changed, 71 insertions(+), 47 deletions(-) diff --git a/infer/tests/codetoanalyze/java/starvation/Interclass.java b/infer/tests/codetoanalyze/java/starvation/Interclass.java index eafe8632d..f75f7f767 100644 --- a/infer/tests/codetoanalyze/java/starvation/Interclass.java +++ b/infer/tests/codetoanalyze/java/starvation/Interclass.java @@ -8,37 +8,43 @@ */ class Interclass { - synchronized void interclass1_bad(InterclassA a) { - a.interclass1_bad(); + synchronized void interclass1Bad(InterclassA a) { + a.interclass1Bad(); } - synchronized void interclass2_bad() {} + synchronized void interclass2Bad() {} - synchronized void interclass1_ok(InterclassB b) { - b.interclass1_ok(); + synchronized void interclass1Ok(InterclassB b) { + b.interclass1Ok(); } - void interclass2_ok(InterclassB b) { + void interclass2Ok(InterclassB b) { synchronized(b) {} } - void reentrant_ok(InterclassB b) { - synchronized(this) { synchronized(b) { b.interclass1_ok(); } } + void reentrantOk(InterclassB b) { + synchronized(this) { + synchronized(b) { + b.interclass1Ok(); + } + } } } class InterclassA { - synchronized void interclass1_bad() {} + synchronized void interclass1Bad() {} - synchronized void interclass2_bad(Interclass i) { - i.interclass2_bad(); + synchronized void interclass2Bad(Interclass i) { + i.interclass2Bad(); } } class InterclassB { - synchronized void interclass1_ok() {} + synchronized void interclass1Ok() {} void interclass2_ok(Interclass c) { - synchronized(c) { c.interclass2_ok(this); } + synchronized(c) { + c.interclass2Ok(this); + } } } diff --git a/infer/tests/codetoanalyze/java/starvation/Interproc.java b/infer/tests/codetoanalyze/java/starvation/Interproc.java index d53c0bc38..a350d9b9f 100644 --- a/infer/tests/codetoanalyze/java/starvation/Interproc.java +++ b/infer/tests/codetoanalyze/java/starvation/Interproc.java @@ -8,43 +8,49 @@ */ class Interproc { - synchronized void interproc1_bad(InterprocA a) { - interproc2_bad(a); + synchronized void interproc1Bad(InterprocA a) { + interproc2Bad(a); } - void interproc2_bad(InterprocA b) { + void interproc2Bad(InterprocA b) { synchronized(b) {} } - synchronized void interproc1_ok(InterprocB a) { - interproc2_ok(a); + synchronized void interproc1Ok(InterprocB a) { + interproc2Ok(a); } - void interproc2_ok(InterprocB b) { + void interproc2Ok(InterprocB b) { synchronized(b) {} } - void reentrant1_ok(InterprocB b) { - synchronized(this) { synchronized(b) { reentrant2_ok(); } } + void reentrant1Ok(InterprocB b) { + synchronized(this) { + synchronized(b) { + reentrant2Ok(); + } + } } - synchronized void reentrant2_ok() {} + synchronized void reentrant2Ok() {} } class InterprocA { - synchronized void interproc1_bad(Interproc c) { - interproc2_bad(c); + synchronized void interproc1Bad(Interproc c) { + interproc2Bad(c); } - void interproc2_bad(Interproc d) { + void interproc2Bad(Interproc d) { synchronized(d) {} } } class InterprocB { - void interproc1_ok(Interproc c) { - synchronized(c) { interproc2_ok(c); } + void interproc1Ok(Interproc c) { + synchronized(c) { + interproc2Ok(c); + } } - synchronized void interproc2_ok(Interproc d) {} + synchronized void interproc2Ok(Interproc d) {} } diff --git a/infer/tests/codetoanalyze/java/starvation/Intraproc.java b/infer/tests/codetoanalyze/java/starvation/Intraproc.java index 6d4d9e008..5afaf5201 100644 --- a/infer/tests/codetoanalyze/java/starvation/Intraproc.java +++ b/infer/tests/codetoanalyze/java/starvation/Intraproc.java @@ -8,27 +8,39 @@ */ class Intraproc { - void intra_bad(IntraprocA o) { - synchronized(this) { synchronized(o) {} } + void intraBad(IntraprocA o) { + synchronized(this) { + synchronized(o) {} + } } - void intra_ok(IntraprocB o) { - synchronized(this) { synchronized(o) {} } + void intraOk(IntraprocB o) { + synchronized(this) { + synchronized(o) {} + } } - void reentrant_ok(IntraprocB b) { - synchronized(this) { synchronized(b) { synchronized(this) {} } } + void reentrantOk(IntraprocB b) { + synchronized(this) { + synchronized(b) { + synchronized(this) {} + } + } } } class IntraprocA { - void intra_bad(Intraproc o) { - synchronized(this) { synchronized(o) {} } + void intraBad(Intraproc o) { + synchronized(this) { + synchronized(o) {} + } } } class IntraprocB { - void intra_ok(Intraproc o) { - synchronized(o) { synchronized(this) {} } + void intraOk(Intraproc o) { + synchronized(o) { + synchronized(this) {} + } } } diff --git a/infer/tests/codetoanalyze/java/starvation/LocalLock.java b/infer/tests/codetoanalyze/java/starvation/LocalLock.java index 3b7c9b0fc..69f95be91 100644 --- a/infer/tests/codetoanalyze/java/starvation/LocalLock.java +++ b/infer/tests/codetoanalyze/java/starvation/LocalLock.java @@ -10,23 +10,23 @@ class LocalLock { Object lock1, lock2; - Object get_lock1() { + Object getLock1() { return lock1; } - void local_lock_outer_ok() { - synchronized(get_lock1()) { + void localLockOuterOk() { + synchronized(getLock1()) { synchronized(this) {} } } - Object get_lock2() { + Object getLock2() { return lock2; } - void local_lock_inner_ok() { + void localLockInnerOk() { synchronized(this) { - synchronized(get_lock2()) {} + synchronized(getLock2()) {} } } } diff --git a/infer/tests/codetoanalyze/java/starvation/issues.exp b/infer/tests/codetoanalyze/java/starvation/issues.exp index a778c7796..ce1c6c227 100644 --- a/infer/tests/codetoanalyze/java/starvation/issues.exp +++ b/infer/tests/codetoanalyze/java/starvation/issues.exp @@ -1,6 +1,6 @@ codetoanalyze/java/starvation/InnerClass.java, void InnerClass$InnerClassA.innerOuterBad(), 0, STARVATION, ERROR, [[Trace 1] Locks this in class InnerClass$InnerClassA*,Method call: void InnerClass.bar(),Locks this in class InnerClass*,[Trace 2] Locks this in class InnerClass*,Method call: void InnerClass$InnerClassA.baz(),Locks this in class InnerClass$InnerClassA*] codetoanalyze/java/starvation/InnerClass.java, void InnerClass.outerInnerBad(InnerClass$InnerClassA), 0, STARVATION, ERROR, [[Trace 1] Locks this in class InnerClass*,Method call: void InnerClass$InnerClassA.baz(),Locks this in class InnerClass$InnerClassA*,[Trace 2] Method start: InnerClass$InnerClassA.(InnerClass,Object),Locks this in class InnerClass$InnerClassA*,Method call: void InnerClass.bar(),Locks this in class InnerClass*] -codetoanalyze/java/starvation/Interclass.java, void Interclass.interclass1_bad(InterclassA), 0, STARVATION, ERROR, [[Trace 1] Locks this in class Interclass*,Method call: void InterclassA.interclass1_bad(),Locks this in class InterclassA*,[Trace 2] Locks this in class InterclassA*,Method call: void Interclass.interclass2_bad(),Locks this in class Interclass*] -codetoanalyze/java/starvation/Interproc.java, void Interproc.interproc1_bad(InterprocA), 0, STARVATION, ERROR, [[Trace 1] Locks this in class Interproc*,Method call: void Interproc.interproc2_bad(InterprocA),Locks b in class InterprocA*,[Trace 2] Locks this in class InterprocA*,Method call: void InterprocA.interproc2_bad(Interproc),Locks d in class Interproc*] -codetoanalyze/java/starvation/Intraproc.java, void IntraprocA.intra_bad(Intraproc), 0, STARVATION, ERROR, [[Trace 1] Method start: void IntraprocA.intra_bad(Intraproc),Locks this in class IntraprocA*,Locks o in class Intraproc*,[Trace 2] Method start: void Intraproc.intra_bad(IntraprocA),Locks this in class Intraproc*,Locks o in class IntraprocA*] +codetoanalyze/java/starvation/Interclass.java, void InterclassA.interclass2Bad(Interclass), 0, STARVATION, ERROR, [[Trace 1] Locks this in class InterclassA*,Method call: void Interclass.interclass2Bad(),Locks this in class Interclass*,[Trace 2] Locks this in class Interclass*,Method call: void InterclassA.interclass1Bad(),Locks this in class InterclassA*] +codetoanalyze/java/starvation/Interproc.java, void Interproc.interproc1Bad(InterprocA), 0, STARVATION, ERROR, [[Trace 1] Locks this in class Interproc*,Method call: void Interproc.interproc2Bad(InterprocA),Locks b in class InterprocA*,[Trace 2] Locks this in class InterprocA*,Method call: void InterprocA.interproc2Bad(Interproc),Locks d in class Interproc*] +codetoanalyze/java/starvation/Intraproc.java, void IntraprocA.intraBad(Intraproc), 0, STARVATION, ERROR, [[Trace 1] Method start: void IntraprocA.intraBad(Intraproc),Locks this in class IntraprocA*,Locks o in class Intraproc*,[Trace 2] Method start: void Intraproc.intraBad(IntraprocA),Locks this in class Intraproc*,Locks o in class IntraprocA*] codetoanalyze/java/starvation/StaticLock.java, void StaticLock.lockOtherClassOneWayBad(), 0, STARVATION, ERROR, [[Trace 1] Method start: void StaticLock.lockOtherClassOneWayBad(),Locks StaticLock$0 in class java.lang.Class*,Locks this in class StaticLock*,[Trace 2] Locks this in class StaticLock*,Method call: void StaticLock.staticSynced(),Locks StaticLock$0 in class java.lang.Class*]