Compiler Error J0114

Cannot reference 'this' in constructor call

The compiler detected an improper reference to this in a constructor. The this statement is usually used in a constructor to access methods and fields of the constructor's class. Usage of this(this) or super(this) in a constructor will cause this error to occur because the instance of the class has not yet been created and thus cannot be passed to another constructor.

The following example illustrates this error:

class SuperSimple {
   SuperSimple(){}
   SuperSimple(Object o) { }
}

public class Simple extends SuperSimple {
   int x;
   public Simple()
   {
      this(10); //this is OK; calls another constructor
      super(this);
      //error: cannot pass this to a super constructor
      this.x = 1; //this is OK
      this.method1(); //this is OK too
   }
   public Simple(int arg1){
      this.x = arg1; //this is OK
   }
   public void method1(){}
}