Top Description Fields Constructors Methods
java.security

public Class PrivilegedActionException

extends Exception
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, jdk.internal.access.SharedSecrets

This exception is thrown by doPrivileged(PrivilegedExceptionAction) and doPrivileged(PrivilegedExceptionAction, AccessControlContext context) to indicate that the action being performed threw a checked exception. The exception thrown by the action can be obtained by calling the getException method. In effect, an PrivilegedActionException is a "wrapper" for an exception thrown by a privileged action.
Since
1.2
See Also
PrivilegedExceptionAction, AccessController#doPrivileged(PrivilegedExceptionAction), AccessController#doPrivileged(PrivilegedExceptionAction, AccessControlContext)

Field Summary

Modifier and TypeField and Description
private static final ObjectStreamField[]
serialPersistentFields

The exception thrown by the privileged computation that resulted in this PrivilegedActionException.

private static final long

Constructor Summary

AccessConstructor and Description
public
PrivilegedActionException(Exception
The exception thrown
exception
)

Constructs a new PrivilegedActionException "wrapping" the specific Exception.

Method Summary

Modifier and TypeMethod and Description
public Exception

Returns:

the exception thrown by the privileged computation that resulted in this PrivilegedActionException.
getException
()

Returns the exception thrown by the privileged computation that resulted in this PrivilegedActionException.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Hides java.lang.Throwable.readObject.

Reconstitutes the PrivilegedActionException instance from a stream and initialize the cause properly when deserializing from an older version.

public String
toString()

Overrides java.lang.Throwable.toString.

Returns a short description of this throwable.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to which data is written
out
)

Hides java.lang.Throwable.writeObject.

To maintain compatibility with older implementation, write a serial "exception" field with the cause as the value.

Field Detail

serialPersistentFieldsback to summary
private static final ObjectStreamField[] serialPersistentFields

The exception thrown by the privileged computation that resulted in this PrivilegedActionException.

Annotations
@Serial
Serial Fields:
exception:Exception
the thrown Exception
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Annotations
@Serial

Constructor Detail

PrivilegedActionExceptionback to summary
public PrivilegedActionException(Exception exception)

Constructs a new PrivilegedActionException "wrapping" the specific Exception.

Parameters
exception:Exception

The exception thrown

Method Detail

getExceptionback to summary
public Exception getException()

Returns the exception thrown by the privileged computation that resulted in this PrivilegedActionException.

API Note

This method predates the general-purpose exception chaining facility. The Throwable#getCause() method is now the preferred means of obtaining this information.

Returns:Exception

the exception thrown by the privileged computation that resulted in this PrivilegedActionException.

See Also
PrivilegedExceptionAction, AccessController#doPrivileged(PrivilegedExceptionAction), AccessController#doPrivileged(PrivilegedExceptionAction, AccessControlContext)
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Hides java.lang.Throwable.readObject.

Reconstitutes the PrivilegedActionException instance from a stream and initialize the cause properly when deserializing from an older version.

The getException and getCause method returns the private "exception" field in the older implementation and PrivilegedActionException::cause was set to null.

Parameters
s:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
toStringback to summary
public String toString()

Overrides java.lang.Throwable.toString.

Doc from java.lang.Throwable.toString.

Returns a short description of this throwable. The result is the concatenation of:

  • the name of the class of this object
  • ": " (a colon and a space)
  • the result of invoking this object's getLocalizedMessage method
If getLocalizedMessage returns null, then just the class name is returned.
Returns:String

a string representation of this throwable.

writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException

Hides java.lang.Throwable.writeObject.

To maintain compatibility with older implementation, write a serial "exception" field with the cause as the value.

Parameters
out:ObjectOutputStream

the ObjectOutputStream to which data is written

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs