1 /* |
1 /* |
2 * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package java.lang; |
26 package java.lang; |
27 |
27 |
28 /** |
28 /** |
29 * Thrown when an application attempts to use <code>null</code> in a |
29 * Thrown when an application attempts to use {@code null} in a |
30 * case where an object is required. These include: |
30 * case where an object is required. These include: |
31 * <ul> |
31 * <ul> |
32 * <li>Calling the instance method of a <code>null</code> object. |
32 * <li>Calling the instance method of a {@code null} object. |
33 * <li>Accessing or modifying the field of a <code>null</code> object. |
33 * <li>Accessing or modifying the field of a {@code null} object. |
34 * <li>Taking the length of <code>null</code> as if it were an array. |
34 * <li>Taking the length of {@code null} as if it were an array. |
35 * <li>Accessing or modifying the slots of <code>null</code> as if it |
35 * <li>Accessing or modifying the slots of {@code null} as if it |
36 * were an array. |
36 * were an array. |
37 * <li>Throwing <code>null</code> as if it were a <code>Throwable</code> |
37 * <li>Throwing {@code null} as if it were a {@code Throwable} |
38 * value. |
38 * value. |
39 * </ul> |
39 * </ul> |
40 * <p> |
40 * <p> |
41 * Applications should throw instances of this class to indicate |
41 * Applications should throw instances of this class to indicate |
42 * other illegal uses of the <code>null</code> object. |
42 * other illegal uses of the {@code null} object. |
|
43 * |
|
44 * {@code NullPointerException} objects may be constructed by the |
|
45 * virtual machine as if {@linkplain Throwable#Throwable(String, |
|
46 * Throwable, boolean) suppression were disabled}. |
43 * |
47 * |
44 * @author unascribed |
48 * @author unascribed |
45 * @since JDK1.0 |
49 * @since JDK1.0 |
46 */ |
50 */ |
47 public |
51 public |
48 class NullPointerException extends RuntimeException { |
52 class NullPointerException extends RuntimeException { |
49 private static final long serialVersionUID = 5162710183389028792L; |
53 private static final long serialVersionUID = 5162710183389028792L; |
50 |
54 |
51 /** |
55 /** |
52 * Constructs a <code>NullPointerException</code> with no detail message. |
56 * Constructs a {@code NullPointerException} with no detail message. |
53 */ |
57 */ |
54 public NullPointerException() { |
58 public NullPointerException() { |
55 super(); |
59 super(); |
56 } |
60 } |
57 |
61 |
58 /** |
62 /** |
59 * Constructs a <code>NullPointerException</code> with the specified |
63 * Constructs a {@code NullPointerException} with the specified |
60 * detail message. |
64 * detail message. |
61 * |
65 * |
62 * @param s the detail message. |
66 * @param s the detail message. |
63 */ |
67 */ |
64 public NullPointerException(String s) { |
68 public NullPointerException(String s) { |