Class DoubleCheckedLockingRule

All Implemented Interfaces:
AstVisitor, JavaVisitor, Rule, PropertySource

public class DoubleCheckedLockingRule extends AbstractJavaRule
 void method() {
   if (x == null) {
     synchronized(this){
       if (x == null) {
         x = new | method();
       }
     }
   }
 }
 

The error is when one uses the value assigned within a synchronized section, outside of a synchronized section.

 if (x == null) // is outside of synchronized section
   x = new | method();
 

Very very specific check for double checked locking.

Author:
CL Gilbert ([email protected])