History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-3684
Type: New Feature New Feature
Status: Open Open
Priority: Critical Critical
Assignee: Unassigned
Reporter: Keith Lea
Votes: 0
Watchers: 0
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

Add inspection for "field accessed within different locks" with respect to final fields and inner classes

Created: 03 Apr 06 22:45   Updated: 30 Jun 06 18:22
Component/s: Code Analysis. Inspection
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 4,167
Severity: Medium


 Description  « Hide
This code has a bug:
class Outer {
  int field;
  synchronized void outer() {
    if (field > 2) field *= -1;
  }

  class Inner {
    synchronized void inner() {
      field++;
    }
  }
}

However, when not stripped down to this test case, it can be hard to notice. IDEA should highlight the field, or highlight each synchronized keyword, or each field access, to notify the developer of the bug. Hopefully the inspection could track synchronization on (final) fields as well as on "this" for any inner class, so this case would be caught:

class Tester {
  final Object obj = new Object();
  int field;
  void first() {
    synchronized(obj) {
      field++;
    }
  }
  void second() {
    synchronized(this) {
      field--;
    }
  }
}


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.