title: Is an Exception's stack trace reliable to get calling method name?
body: <p>I know that stacktraces can be used to retrieve current executing method with something like this:</p>
  
  <pre><code>Thread.currentThread().getStackTrace()[what you want]
  </code></pre>
  
  <p>However not every JVM provides this stack trace so this way of getting a method's name is pretty much unreliable.
  Anyway...what about exceptions? My need is to log the caller method name and, in order to provide some code maintenance, I'd like to avoid to just write that name down like this:</p>
  
  <pre><code>public void myMethod(){
    ...
  
  }catch(anException ex){
        log.error("myMethod failed!");
  }
  </code></pre>
  
  <p>But rather something like:</p>
  
  <pre><code>}catch(anException ex){
        log.error("{} failed!", ex.getStackTrace()[0].getMethodName()); //0 should be my method, the caller
  }
  </code></pre>
  
  <p>Is this reliable? I think that, at least for exceptions, JVM should be expected to provide said stack trace...</p>