RFE: compiler check for redundant locking

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 1.1
    • Component/s: tools
    • None
    • sparc
    • solaris_2.5

      The compiler could check for me if I'm already inside a synchronized method or block and am trying to enter a synchronized block that locks the same lock as the outer lock (e.g. this). Yes, I know the spec says you can grab a lock more than once. The point is there's almost always a mistake when someone writes:

      public class SyncSync {
      public synchronized void method() {
      System.out.println("before");
      synchronized (this) {
      System.out.println("inside");
      }
      System.out.println("after");
      }

      because the before and after code is really inside the locked region, or they don't need the inner synchronized block.

      ... peter 10/11/96

            Assignee:
            David Stoutamire (Inactive)
            Reporter:
            Peter Kessler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: