File: synchronized.testsuite

package info (click to toggle)
nice 0.9.12-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,220 kB
  • ctags: 6,894
  • sloc: java: 42,767; xml: 3,508; lisp: 1,079; sh: 736; makefile: 673; cpp: 21; awk: 3
file content (58 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/// PASS
  String s = "A";
  synchronized(s) { }

/// FAIL
  // COMMENT Synchronization cannot be done on primitive values.
  int i = 0;
  synchronized(/* /// FAIL HERE */ i) { }

/// FAIL
  // COMMENT Synchronization must be done on non-null values.
  synchronized(/* /// FAIL HERE */ null) { }

/// FAIL
  // COMMENT Synchronization must be done on non-null values.
  ?String s = "S";
  synchronized(/* /// FAIL HERE */ s) { }

/// PASS
  assert f("") == "";
  /// Toplevel
String f(String s)
{
  synchronized (s) {
    return s;
  }
}

/// PASS
  /// Toplevel
  class SharedBuffer {}

  class Producer extends Thread {
    SharedBuffer buffer;
    run() { } 
  }

  class Consumer extends Thread {
    SharedBuffer buffer;
    run() {
      synchronized(buffer) { }
    } 
  }

/// PASS
  /// Toplevel
class Foo {}

int bar (Foo obj)
{
  synchronized(obj)
  {
    ?Throwable exn = new Exception();
    if (exn != null)
      throw exn;
    return 1;
  }
}