/[classpath]/classpath/java/security/PrivilegedActionException.java
ViewVC logotype

Diff of /classpath/java/security/PrivilegedActionException.java

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

revision 1.4 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.5 by ericb, Sun Feb 24 04:25:17 2002 UTC
# Line 1  Line 1 
1  /* PrivilegedActionException.java -- An exception occurred in a  /* PrivilegedActionException.java -- wrap an exception in a privileged action
2     privileged action.     Copyright (C) 1998, 2002 Free Software Foundation, Inc.
    Copyright (C) 1998 Free Software Foundation, Inc.  
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 38  exception statement from your version. * Line 37  exception statement from your version. *
37    
38  package java.security;  package java.security;
39    
 import java.io.PrintStream;  
 import java.io.PrintWriter;  
   
40  /**  /**
41   * This exception is thrown when an exception is thrown during a   * This exception is thrown when an exception is thrown during a
42   * privileged action being performed with the   * privileged action being performed with the
43   * <code>AccessController.doPrivileged()</code> method.  It wrappers the   * <code>AccessController.doPrivileged()</code> method.  It wraps the
44   * actual exception thrown in the privileged code.   * actual exception thrown in the privileged code.
45   *   *
46   * @version 0.0   * @author Aaron M. Renn <arenn@urbanophile.com>
47   *   * @author Eric Blake <ebb9@email.byu.edu>
48   * @author Aaron M. Renn (arenn@urbanophile.com)   * @see PrivilegedExceptionAction
49     * @see AccessController#doPrivileged(PrivilegedExceptionAction)
50     * @see AccessController#doPrivileged(PrivilegedExceptionAction, AccessControlContext)
51     * @status updated to 1.4
52   */   */
53  public class PrivilegedActionException extends Exception  public class PrivilegedActionException extends Exception
54  {  {
   
55    /**    /**
56     * This is the actual exception that occurred     * Compatible with JDK 1.1+.
57     */     */
58    private Exception e;    private static final long serialVersionUID = 4724086851538908602L;
59    
60    /**    /**
61     * This method initializes a new instance of <code>PrivilegedActionException</code>     * This is the actual exception that occurred.
    * that wrappers the specified <code>Exception</code>.  
62     *     *
63     * @param e The <code>Exception</code> to wrapper     * @serial the wrapped exception
64     */     */
65    public PrivilegedActionException(Exception e)    private Exception exception;
   {  
     this.e = e;  
   }  
66    
67    /**    /**
68     * This method returns the underlying <code>Exception</code> that caused     * Create a new instance that wraps the specified <code>Exception</code>.
    * this exception to be raised.  
69     *     *
70     * @return The wrappered <code>Exception</code>.     * @param e the <code>Exception</code> to wrap
71     */     */
72    public Exception getException()    public PrivilegedActionException(Exception e)
73    {    {
74      return (e);      super(e);
75        exception = e;
76    }    }
77    
78    /**    /**
79     * This method prints the stack trace of the wrappered exception.     * Get the underlying <code>Exception</code> that caused this one. This
80       * is a legacy method, the preferred way is {@link #getCause()}.
81       *
82       * @return the cause
83     */     */
84    public void printStackTrace()    public Exception getException()
85    {    {
86      e.printStackTrace();      return exception;
87    }    }
88    
89    /**    /**
90     * This method prints the stack trace of the wrappered exception to the     * Gets the cause of this exception.
    * specified <code>PrintStream</code>.  
91     *     *
92     * @param ps The <code>PrintStream</code> to print the stack trace to.     * @return the cause
93       * @since 1.4
94     */     */
95    public void printStackTrace(PrintStream ps)    public Throwable getCause()
96    {    {
97      e.printStackTrace(ps);      return exception;
98    }    }
99    
100    /**    /**
101     * This method prints the stack trace of the wrappered exception to the     * Convert this to a String.
    * specified <code>PrintWriter</code>.  
102     *     *
103     * @param pw The <code>PrintWriter</code> to print the stack trace to.     * @return the string representation
104     */     */
105    public void printStackTrace(PrintWriter pw)    public String toString()
106    {    {
107      e.printStackTrace(pw);      return super.toString();
108    }    }
109  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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