title: How do I fix a Java.lang.StackOverFlow exception?
body: <p>Im not sure what to do here. I've looked at the logcat cat and I know that its between my MainActivity class and my DrawingTools class. I've also listed the line numbers to help identify which lines are which. My question is how do I fix this error java.lang.StackOverflow?</p>
  
  <p>Here is my Logcat:</p>
  
  <pre><code>07-05 00:55:17.852: E/AndroidRuntime(15504): FATAL EXCEPTION: main
  07-05 00:55:17.852: E/AndroidRuntime(15504): java.lang.StackOverflowError
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at java.lang.ref.FinalizerReference.add(FinalizerReference.java:48)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at android.os.StrictMode$InstanceTracker.&lt;init&gt;(StrictMode.java:2155)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at android.os.StrictMode.trackActivity(StrictMode.java:1857)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at android.app.Activity.&lt;init&gt;(Activity.java:768)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:13)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.DrawingTools.&lt;init&gt;(DrawingTools.java:9)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testcad.MainActivity.&lt;init&gt;(MainActivity.java:22)
  07-05 00:55:17.852: E/AndroidRuntime(15504):    at com.example.testc
  </code></pre>
  
  <p>Here is my MainActivity class:</p>
  
  <pre><code>13    public class MainActivity extends Activity implements OnClickListener {
  14  
  15   Handler uiHandler;
  16   EditText cl;
  17   TextView info;
  18   Button enter;
  19   Button line;
  20   Button arc;
  21   DrawingUtils callDU = new DrawingUtils();
  22   DrawingTools callDT= new DrawingTools();
  23   EditTools callET = new EditTools();
  24   Conversion callConversion = new Conversion();
  25   
  26  @Override
  27  protected void onCreate(Bundle savedInstanceState) {
  28      super.onCreate(savedInstanceState);
  29      setContentView(R.layout.canvas);
  30                                                                                                               31 info = (TextView) findViewById(R.id.info);                                                                                             32        enter = (Button)findViewById(R.id.enter);
  33       line = (Button) findViewById(R.id.line);
  34        arc = (Button) findViewById(R.id.arc);
  35        cl = (EditText)findViewById(R.id.cl);
  36        
  37        uiHandler = new Handler() { public void handleMessage(Message msg) {
  38       switch (msg.what) {
  39        
  40        } Bundle bundle = msg.getData(); String string1 =
  41        bundle.getString("P1Key"); String string2 =
  42        bundle.getString("P2Key"); info.setText(string1);
  43        info.setText(string2); } };
  44       
  45  }
  46
  47  @Override
  48  public void onClick(View v) {
  49      switch (v.getId()) {
  50      case R.id.enter:
  51          String input = cl.getText().toString();
  52          synchronized (callDU.string) {
  53              String[] In = input.split(",");
  54              callDU.setX(In[0]);
  55              callDU.setY(In[1]);
  56              callDU.setZ(In[2]);
  57              callDU.string.notifyAll();
  58          }
  59
  60          break;
  61      case R.id.line:
  62
  63          break;
  64      case R.id.arc:
  65
  66          break;
  67      }
  68  };
  69     }
  </code></pre>
  
  <p>Here is my DrawingTools class:</p>
  
  <pre><code> 7    public class DrawingTools {
   8  DrawingUtils callDU = new DrawingUtils();
   9  MainActivity callMain = new MainActivity();
  10  public class Line extends Thread {
  11      Thread line = new Thread();
  12      @Override
  13      public void run() {
  14          // TODO Auto-generated method stub
  15          super.run();
  16          //Set Text To (Enter Point 1)
  17          Message msg = Message.obtain();
  18          Bundle bundle = new Bundle();
  19          String setTextP1 = "Enter Point 1.";
  20          bundle.putString("P1Key", setTextP1);
  21          msg.setData(bundle);
  22          //callMain.uiHandler.sendMessage(msg);
  23          synchronized(callDU.string){
  24              try {
  25                  callDU.string.wait();
  26              } catch (InterruptedException e) {
  27                  // TODO Auto-generated catch block
  28                  e.printStackTrace();
  29              }
  30              
  31          String X1 = callDU.getX();
  32          String Y1 = callDU.getY();
  33          String Z1 = callDU.getZ();
  34          callDU.point.add(X1);
  35          callDU.point.add(Y1);
  36          callDU.point.add(Z1);
  37          
  38          }
  39          Message msg1 = Message.obtain();
  40          Bundle bundle1 = new Bundle();
  41          String setTextP2 = "Enter Point 2.";
  42          bundle1.putString("P2Key", setTextP2);
  43          msg1.setData(bundle1);
  44          //callMain.uiHandler.sendMessage(msg1);
  45          synchronized(callDU.string){
  46              try {
  47                  callDU.string.wait();
  48              } catch (InterruptedException e) {
  49                  // TODO Auto-generated catch block
  50                  e.printStackTrace();
  51              }   
  52          String X2 = callDU.getX();
  53          String Y2 = callDU.getY();
  54          String Z2 = callDU.getZ();
  55          callDU.point.add(X2);
  56          callDU.point.add(Y2);
  57          callDU.point.add(Z2);
  58          }
  59      }   
  60  }
  </code></pre>