Source Home >> Java Source 1.6.0 >> java.lang.reflect.InvocationTargetException V 0.09
  • 01/*
  • 02 * @(#)InvocationTargetException.java 1.20 05/11/17
  • 03 *
  • 04 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  • 05 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  • 06 */
  • 07
  • 08package java.lang.reflect;
  • 09
  • 10/**
  • 11 * InvocationTargetException is a checked exception that wraps
  • 12 * an exception thrown by an invoked method or constructor.
  • 13 *
  • 14 * <p>As of release 1.4, this exception has been retrofitted to conform to
  • 15 * the general purpose exception-chaining mechanism. The "target exception"
  • 16 * that is provided at construction time and accessed via the
  • 17 * {@link #getTargetException()} method is now known as the <i>cause</i>,
  • 18 * and may be accessed via the {@link Throwable#getCause()} method,
  • 19 * as well as the aforementioned "legacy method."
  • 20 *
  • 21 * @see Method
  • 22 * @see Constructor
  • 23 */
  • 24public class InvocationTargetException extends Exception {
  • 25 /**
  • 26 * Use serialVersionUID from JDK 1.1.X for interoperability
  • 27 */
  • 28 private static final long serialVersionUID = 4085088731926701167L;
  • 29
  • 30 /**
  • 31 * This field holds the target if the
  • 32 * InvocationTargetException(Throwable target) constructor was
  • 33 * used to instantiate the object
  • 34 *
  • 35 * @serial
  • 36 *
  • 37 */
  • 38 private Throwable target;
  • 39
  • 40 /**
  • 41 * Constructs an <code>InvocationTargetException</code> with
  • 42 * <code>null</code> as the target exception.
  • 43 */
  • 44 protected InvocationTargetException() {
  • 45 super((Throwable)null); // Disallow initCause
  • 46 }
  • 47
  • 48 /**
  • 49 * Constructs a InvocationTargetException with a target exception.
  • 50 *
  • 51 * @param target the target exception
  • 52 */
  • 53 public InvocationTargetException(Throwable target) {
  • 54 super((Throwable)null); // Disallow initCause
  • 55 this.target = target;
  • 56 }
  • 57
  • 58 /**
  • 59 * Constructs a InvocationTargetException with a target exception
  • 60 * and a detail message.
  • 61 *
  • 62 * @param target the target exception
  • 63 * @param s the detail message
  • 64 */
  • 65 public InvocationTargetException(Throwable target, String s) {
  • 66 super(s, null); // Disallow initCause
  • 67 this.target = target;
  • 68 }
  • 69
  • 70 /**
  • 71 * Get the thrown target exception.
  • 72 *
  • 73 * <p>This method predates the general-purpose exception chaining facility.
  • 74 * The {@link Throwable#getCause()} method is now the preferred means of
  • 75 * obtaining this information.
  • 76 *
  • 77 * @return the thrown target exception (cause of this exception).
  • 78 */
  • 79 public Throwable getTargetException() {
  • 80 return target;
  • 81 }
  • 82
  • 83 /**
  • 84 * Returns the cause of this exception (the thrown target exception,
  • 85 * which may be <tt>null</tt>).
  • 86 *
  • 87 * @return the cause of this exception.
  • 88 * @since 1.4
  • 89 */
  • 90 public Throwable getCause() {
  • 91 return target;
  • 92 }
  • 93}

文件:InvocationTargetException.java
包名:java.lang.reflect
类名:InvocationTargetException
继承:Exception
接口: