title: Why does Exception.fillInStackTrace return Throwable?
body: <p>I think Exception.fillInStackTrace should return Exception or derived Exception objects. Considering the two functions below,</p>
  
  <pre><code>public static void f() throws Throwable {
      try {
          throw new Throwable();
      } catch (Exception e) {
          System.out.println("catch exception e");
          e.printStackTrace();
      } 
  }
  public static void g() throws Throwable {
      try {
          try {
              throw new Exception("exception");
          } catch (Exception e) {
              System.out.println("inner exception handler");
              throw e.fillInStackTrace();
          }
      } catch (Exception e) {
          System.out.println("outer exception handler");
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <ol>
  <li>The <code>exception handler</code> could not catch the <code>new Throwable()</code> in the first function <code>f()</code>.</li>
  <li>The <code>exception handler</code> could catch the <code>e.fillInstackTrace()</code> in the second function <code>g()</code>.</li>
  <li>But the second function <code>g()</code> would still need to <code>throws Throwable</code>. This is really strange, since we could catch <code>e.fillInstackTrace()</code>.</li>
  </ol>
  
  <p>So my question is why doesn't Exception.fillInStackTrace return Exception or Exception-derived instead of developing such a strange syntax?</p>
  
  <p><strong>EDIT</strong>:<br>
  To <strong>clarify</strong> my question:  What I mean by "strange syntax" are</p>
  
  <ol>
  <li>Since <code>Exception.fillInStackTrace()</code> return <code>Throwable</code> reference,the exception handler which recieve <code>Exception</code> reference should not be able to catch the exception.Because java does not allow implict downcast,it should be something like <code>return (Exception)e.fillInstackTrace()</code>.</li>
  <li>Since it is designed that the exception handler recieving <code>Exception</code> reference could handle the <code>Throwable</code> exception,there is no need to mark the method <code>g()</code> throws <code>Throwable</code> exception.But java compiler would enforce us to do so.</li>
  </ol>
  
  <p>thanks.</p>