Get the operation attempted in case of NPE : <p>Consider the below code:</p>

<pre><code>String s = null;
s.toLowerCase();
</code></pre>

<p>It throws a NPE:</p>

<blockquote>
  <p>Exception in thread "main" java.lang.NullPointerException<br>
    at pracJava1.Prac.main(Prac.java:7)</p>
</blockquote>

<p>The question is: Why can't the JVM also put a helper message saying: </p>

<blockquote>
  <p>Exception in thread "main" java.lang.NullPointerException. Attempted <code>toLowerCase() on null</code></p>
</blockquote>

<p>This is useful in cases like <code>obj.setName(s.toLowerCase())</code>, where the line number is not sufficient to guess if <code>obj</code> was null or <code>s</code>.</p>

<hr>

<p>On the feasibility of it, lets look at the byte code generated:</p>

<pre><code>      stack=1, locals=2, args_size=1
     0: aconst_null
     1: astore_1
     2: aload_1
     3: invokevirtual #2    // Method java/lang/String.toLowerCase:()Ljava/lang/String;
</code></pre>

<p>So may be it does know, the method name it attempted the operation on. JVM experts, what's your opinion?</p>
