81 public ClassNotFoundException(String s) { 82 super(s, null); // Disallow initCause 83 } 84 85 /** 86 * Constructs a <code>ClassNotFoundException</code> with the 87 * specified detail message and optional exception that was 88 * raised while loading the class. 89 * 90 * @param s the detail message 91 * @param ex the exception that was raised while loading the class 92 * @since 1.2 93 */ 94 public ClassNotFoundException(String s, Throwable ex) { 95 super(s, null); // Disallow initCause 96 this.ex = ex; 97 } 98 99 /** 100 * Returns the exception that was raised if an error occurred while 101 * attempting to load the class. Otherwise, returns <tt>null</tt>. 102 * 103 * <p>This method predates the general-purpose exception chaining facility. 104 * The {@link Throwable#getCause()} method is now the preferred means of 105 * obtaining this information. 106 * 107 * @return the <code>Exception</code> that was raised while loading a class 108 * @since 1.2 109 */ 110 public Throwable getException() { 111 return ex; 112 } 113 114 /** 115 * Returns the cause of this exception (the exception that was raised 116 * if an error occurred while attempting to load the class; otherwise 117 * <tt>null</tt>). 118 * 119 * @return the cause of this exception. 120 * @since 1.4 121 */ 122 public Throwable getCause() { 123 return ex; 124 } 125 } | 81 public ClassNotFoundException(String s) { 82 super(s, null); // Disallow initCause 83 } 84 85 /** 86 * Constructs a <code>ClassNotFoundException</code> with the 87 * specified detail message and optional exception that was 88 * raised while loading the class. 89 * 90 * @param s the detail message 91 * @param ex the exception that was raised while loading the class 92 * @since 1.2 93 */ 94 public ClassNotFoundException(String s, Throwable ex) { 95 super(s, null); // Disallow initCause 96 this.ex = ex; 97 } 98 99 /** 100 * Returns the exception that was raised if an error occurred while 101 * attempting to load the class. Otherwise, returns {@code null}. 102 * 103 * <p>This method predates the general-purpose exception chaining facility. 104 * The {@link Throwable#getCause()} method is now the preferred means of 105 * obtaining this information. 106 * 107 * @return the <code>Exception</code> that was raised while loading a class 108 * @since 1.2 109 */ 110 public Throwable getException() { 111 return ex; 112 } 113 114 /** 115 * Returns the cause of this exception (the exception that was raised 116 * if an error occurred while attempting to load the class; otherwise 117 * {@code null}). 118 * 119 * @return the cause of this exception. 120 * @since 1.4 121 */ 122 public Throwable getCause() { 123 return ex; 124 } 125 } |