< prev index next >
test/hotspot/jtreg/runtime/exceptionMsgs/NullPointerException/NPEInHiddenTopFrameTest.java
Print this page
rev 56281 : 8218628: Add detailed message to NullPointerException describing what is null.
Summary: This is the implementation of JEP 358: Helpful NullPointerExceptions.
Reviewed-by: coleenp
rev 56283 : [mq]: fixes_review_of_16.patch
*** 24,36 ****
/**
* @test
* @summary Test NullPointerException messages thrown in frames that
* are hidden in the backtrace/stackTrace.
* @library /test/lib
* @compile -g NPEInHiddenTopFrameTest.java
! * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-ShowHiddenFrames -XX:-ShowCodeDetailsInExceptionMessages NPEInHiddenTopFrameTest hidden
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+ShowCodeDetailsInExceptionMessages NPEInHiddenTopFrameTest visible
*/
import jdk.test.lib.Asserts;
--- 24,37 ----
/**
* @test
* @summary Test NullPointerException messages thrown in frames that
* are hidden in the backtrace/stackTrace.
+ * @bug 8218628
* @library /test/lib
* @compile -g NPEInHiddenTopFrameTest.java
! * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-ShowHiddenFrames -XX:+ShowCodeDetailsInExceptionMessages NPEInHiddenTopFrameTest hidden
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames -XX:+ShowCodeDetailsInExceptionMessages NPEInHiddenTopFrameTest visible
*/
import jdk.test.lib.Asserts;
*** 66,79 ****
concatter.someMethod(nullString, "validString");
}
} catch (NullPointerException e) {
checkMessage("concatter.someMethod(nullString, \"validString\");", e.getMessage(),
framesAreHidden ?
! // This is the message printed if the wrong method/bci are used:
// "Cannot invoke 'NPEInHiddenTopFrameTest$SomeFunctionalInterface.someMethod(String, String)'" +
// " because 'concatter' is null."
! // With this fix no message is printed.
null :
// This is the correct message, but it describes code generated on-the-fly.
// You get it if you disable hiding frames (-XX:+ShowHiddenframes).
"Cannot invoke 'String.concat(String)' because '<parameter1>' is null." );
e.printStackTrace();
--- 67,81 ----
concatter.someMethod(nullString, "validString");
}
} catch (NullPointerException e) {
checkMessage("concatter.someMethod(nullString, \"validString\");", e.getMessage(),
framesAreHidden ?
! // This is the message that would be printed if the wrong method/bci are used:
// "Cannot invoke 'NPEInHiddenTopFrameTest$SomeFunctionalInterface.someMethod(String, String)'" +
// " because 'concatter' is null."
! // But the NPE message generation now recognizes this situation and skips the
! // message. So we expect null:
null :
// This is the correct message, but it describes code generated on-the-fly.
// You get it if you disable hiding frames (-XX:+ShowHiddenframes).
"Cannot invoke 'String.concat(String)' because '<parameter1>' is null." );
e.printStackTrace();
< prev index next >