src/java.base/share/classes/java/lang/NullPointerException.java
changeset 58664 e3618c902d17
parent 57956 e0b8b019d2f5
child 58679 9c3209ff7550
child 59201 b24f4caa1411
equal deleted inserted replaced
58663:11a574b352d0 58664:e3618c902d17
    68      * @param   s   the detail message.
    68      * @param   s   the detail message.
    69      */
    69      */
    70     public NullPointerException(String s) {
    70     public NullPointerException(String s) {
    71         super(s);
    71         super(s);
    72     }
    72     }
       
    73 
       
    74     /**
       
    75      * Returns the detail message string of this throwable.
       
    76      *
       
    77      * <p> If a non-null message was supplied in a constructor it is
       
    78      * returned. Otherwise, an implementation specific message or
       
    79      * {@code null} is returned.
       
    80      *
       
    81      * @implNote
       
    82      * If no explicit message was passed to the constructor, and as
       
    83      * long as certain internal information is available, a verbose
       
    84      * description of the null reference is returned.
       
    85      * The internal information is not available in deserialized
       
    86      * NullPointerExceptions.
       
    87      *
       
    88      * @return the detail message string, which may be {@code null}.
       
    89      */
       
    90     public String getMessage() {
       
    91         String message = super.getMessage();
       
    92         if (message == null) {
       
    93             return getExtendedNPEMessage();
       
    94         }
       
    95         return message;
       
    96     }
       
    97 
       
    98     /**
       
    99      * Get an extended exception message. This returns a string describing
       
   100      * the location and cause of the exception. It returns null for
       
   101      * exceptions where this is not applicable.
       
   102      */
       
   103     private native String getExtendedNPEMessage();
    73 }
   104 }