/[classpath]/classpath/java/lang/reflect/InvocationTargetException.java
ViewVC logotype

Diff of /classpath/java/lang/reflect/InvocationTargetException.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.9 by ericb, Sun Feb 24 04:25:16 2002 UTC
# Line 1  Line 1 
1  /* InvocationTargetException.java - Wrapper exception for reflection  /* InvocationTargetException.java -- Wrapper exception for reflection
2     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.lang.reflect;  package java.lang.reflect;
40    
 import java.io.PrintStream;  
 import java.io.PrintWriter;  
   
41  /**  /**
42   * InvocationTargetException is sort of a way to "wrap" whatever exception   * InvocationTargetException is sort of a way to "wrap" whatever exception
43   * comes up when a method or constructor is called via Reflection. As of   * comes up when a method or constructor is called via Reflection. As of
44   * JDK 1.4, it was retrofitted to match the exception chaining of all other   * JDK 1.4, it was retrofitted to match the exception chaining of all other
45   * exceptions, but <code>getTargetException()</code> still works.   * exceptions, but <code>getTargetException()</code> still works.
# Line 53  import java.io.PrintWriter; Line 50  import java.io.PrintWriter;
50   * @see Method#invoke(Object,Object[])   * @see Method#invoke(Object,Object[])
51   * @see Constructor#newInstance(Object[])   * @see Constructor#newInstance(Object[])
52   * @since 1.1   * @since 1.1
53   * @status stuck at 1.3; awaiting exception chaining in Throwable   * @status updated to 1.4
54   */   */
55    public class InvocationTargetException extends Exception
 public class InvocationTargetException  
   extends Exception  
56  {  {
57    /**    /**
58     * Compatible with JDK 1.1.     * Compatible with JDK 1.1+.
59     */     */
60    private static final long serialVersionUID = 4085088731926701167L;    private static final long serialVersionUID = 4085088731926701167L;
61    
62    /**    /**
63     * The chained exception. This field is only around for serial compatibility.     * The chained exception. This field is only around for serial compatibility.
64       *
65     * @serial the chained exception     * @serial the chained exception
66     */     */
67    private final Throwable target;    private final Throwable target;
68    
69    /**    /**
70     * Construct an exception with null as the cause.     * Construct an exception with null as the cause. The cause is initialized
71       * to null.
72     */     */
73    protected InvocationTargetException()    protected InvocationTargetException()
74    {    {
75      // XXX Use this implementation when Throwable is ready.      this(null, null);
     // this(null);  
   
     super();  
     target = null;  
76    }    }
77      
78    /**    /**
79     * Create an <code>InvocationTargetException</code> using another     * Create an <code>InvocationTargetException</code> using another
80     * exception.     * exception.
81     *     *
82     * @param targetException the exception to wrap     * @param targetException the exception to wrap
83     */     */
84    public InvocationTargetException(Throwable targetException)    public InvocationTargetException(Throwable targetException)
85    {    {
86      // XXX Use this implementation when Throwable is ready.      this(targetException, null);
     // super(targetException);  
     // target = targetException;  
   
     super(targetException.toString());  
     target = targetException;  
87    }    }
88      
89    /**    /**
90     * Create an <code>InvocationTargetException</code> using another     * Create an <code>InvocationTargetException</code> using another
91     * exception and an error message.     * exception and an error message.
92     *     *
93     * @param targetException the exception to wrap     * @param targetException the exception to wrap
94     * @param err an extra reason for the exception-throwing     * @param err an extra reason for the exception-throwing
95     */     */
96    public InvocationTargetException(Throwable targetException, String err)    public InvocationTargetException(Throwable targetException, String err)
97    {    {
98      // XXX Use this implementation when Throwable is ready.      super(err, targetException);
     // super(err, targetException);  
     // target = targetException;  
   
     super(err);  
99      target = targetException;      target = targetException;
100    }    }
101    
102    /**    /**
103     * Get the wrapped (targeted) exception.     * Get the wrapped (targeted) exception.
104     *     *
105     * @return the targeted exception.     * @return the targeted exception
106     * @see #getCause()     * @see #getCause()
107     */     */
108    public Throwable getTargetException()    public Throwable getTargetException()
109    {    {
110      return target;      return target;
111    }    }
# Line 129  public class InvocationTargetException Line 113  public class InvocationTargetException
113    /**    /**
114     * Returns the cause of this exception (which may be null).     * Returns the cause of this exception (which may be null).
115     *     *
116     * @return the cause.     * @return the cause
117     * @since 1.4     * @since 1.4
118     */     */
119    public Throwable getCause()    public Throwable getCause()

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26