Getting different results for getStackTrace()[2].getMethodName() : <p>For logging purposes, I created a method logTitle() that prints out the calling method name for our TestNG tests.  Sample code is below.</p>

<pre><code>@Test
public void test1() throws Exception {
    method1();
}

public static void method1() throws Exception {
    Utils.logTitle(2);
}
</code></pre>

<p>...</p>

<pre><code>public static void logTitle(Integer level) throws Exception {

    // Gets calling method name
    String method = Thread.currentThread().getStackTrace()[2].getMethodName();
    // This would get current method name
    switch (level) {
    case 1:
        logger.info("=======================================================");
        logger.info(method);
        logger.info("=======================================================");
        break;
    case 2:
        logger.info("------------------------------------");
        logger.info(method);
        logger.info("------------------------------------");
        break;
    case 3:
        logger.info("---------------------");
        logger.info(method);
        logger.info("---------------------");
        break;
    case 4:
        logger.info("--------- " + method + " ------------");
        break;
    default:
        logger.info(method);
    }
}
</code></pre>

<p>The problem is I am getting different results for logTitle() on two different machines.</p>

<p>Everyone's laptop returns correctly:</p>

<pre><code>2016-06-20 14:22:06 INFO  - ------------------------------------
2016-06-20 14:22:06 INFO  - method1
2016-06-20 14:22:06 INFO  - ------------------------------------
</code></pre>

<p>Our dev unix box returns differently:</p>

<pre><code>2016-06-20 14:42:26 INFO  - ------------------------------------
2016-06-20 14:42:26 INFO  - logTitle
2016-06-20 14:42:26 INFO  - ------------------------------------
</code></pre>

<p>This works correctly on everyone else's laptop, just not the dev unix box.    I think the dev unix box is using IBM's version of Java, while everyone else is using Oracle's version of Java, but not sure if that is the culprit or not.</p>

<p>Any ideas?</p>
