Skip to content

Commit

Permalink
Merge pull request #11188 from JasonFengJ9/npectr
Browse files Browse the repository at this point in the history
NullPointerException(null).getMessage() returns null
  • Loading branch information
gacholio authored Nov 16, 2020
2 parents 0e8f48a + dfec1a1 commit 547bb8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions runtime/vm/extendedMessageNPE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,9 @@ getCompleteNPEMessage(J9VMThread *vmThread, U_8 *bcCurrentPtr, J9ROMClass *romCl

if (J9UTF8_LITERAL_EQUALS(J9UTF8_DATA(definingClassFullQualifiedName), J9UTF8_LENGTH(definingClassFullQualifiedName), "java/lang/NullPointerException")) {
if (J9UTF8_LITERAL_EQUALS(J9UTF8_DATA(methodName), J9UTF8_LENGTH(methodName), "<init>")) {
if (J9UTF8_LITERAL_EQUALS(J9UTF8_DATA(methodSig), J9UTF8_LENGTH(methodSig), "()V")) {
/* No message generated for new NullPointerException().getMessage() */
npeMsgRequired = false;
Trc_VM_GetCompleteNPEMessage_Not_Required(vmThread);
}
/* No message generated for new NullPointerException().getMessage() or new NullPointerException(null).getMessage() */
npeMsgRequired = false;
Trc_VM_GetCompleteNPEMessage_Not_Required(vmThread);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,8 @@ public void test_parameters_4() {
public void test_creation() throws Exception {
Assert.assertNull(new NullPointerException().getMessage(),
"new NullPointerException().getMessage() is not null!");
Assert.assertNull(new NullPointerException(null).getMessage(),
"new NullPointerException(null).getMessage() is not null!");
String npeMsg = new String("NPE creation messsage");
Assert.assertEquals(new NullPointerException(npeMsg).getMessage(), npeMsg);
Exception exception = NullPointerException.class.getDeclaredConstructor().newInstance();
Expand Down

0 comments on commit 547bb8e

Please sign in to comment.