equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
54 * @see AccessController#doPrivileged(PrivilegedExceptionAction) |
54 * @see AccessController#doPrivileged(PrivilegedExceptionAction) |
55 * @see AccessController#doPrivileged(PrivilegedExceptionAction,AccessControlContext) |
55 * @see AccessController#doPrivileged(PrivilegedExceptionAction,AccessControlContext) |
56 */ |
56 */ |
57 public class PrivilegedActionException extends Exception { |
57 public class PrivilegedActionException extends Exception { |
58 // use serialVersionUID from JDK 1.2.2 for interoperability |
58 // use serialVersionUID from JDK 1.2.2 for interoperability |
|
59 @java.io.Serial |
59 private static final long serialVersionUID = 4724086851538908602L; |
60 private static final long serialVersionUID = 4724086851538908602L; |
60 |
61 |
61 /** |
62 /** |
62 * Constructs a new PrivilegedActionException "wrapping" |
63 * Constructs a new PrivilegedActionException "wrapping" |
63 * the specific Exception. |
64 * the specific Exception. |
97 /** |
98 /** |
98 * Serializable fields for UndeclaredThrowableException. |
99 * Serializable fields for UndeclaredThrowableException. |
99 * |
100 * |
100 * @serialField undeclaredThrowable Throwable |
101 * @serialField undeclaredThrowable Throwable |
101 */ |
102 */ |
|
103 @java.io.Serial |
102 private static final ObjectStreamField[] serialPersistentFields = { |
104 private static final ObjectStreamField[] serialPersistentFields = { |
103 new ObjectStreamField("exception", Exception.class) |
105 new ObjectStreamField("exception", Exception.class) |
104 }; |
106 }; |
105 |
107 |
106 /* |
108 /* |
110 * |
112 * |
111 * The getException and getCause method returns the private "exception" |
113 * The getException and getCause method returns the private "exception" |
112 * field in the older implementation and PrivilegedActionException::cause |
114 * field in the older implementation and PrivilegedActionException::cause |
113 * was set to null. |
115 * was set to null. |
114 */ |
116 */ |
|
117 @java.io.Serial |
115 private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { |
118 private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { |
116 ObjectInputStream.GetField fields = s.readFields(); |
119 ObjectInputStream.GetField fields = s.readFields(); |
117 Exception exception = (Exception) fields.get("exception", null); |
120 Exception exception = (Exception) fields.get("exception", null); |
118 if (exception != null) { |
121 if (exception != null) { |
119 SharedSecrets.getJavaLangAccess().setCause(this, exception); |
122 SharedSecrets.getJavaLangAccess().setCause(this, exception); |
122 |
125 |
123 /* |
126 /* |
124 * To maintain compatibility with older implementation, write a serial |
127 * To maintain compatibility with older implementation, write a serial |
125 * "exception" field with the cause as the value. |
128 * "exception" field with the cause as the value. |
126 */ |
129 */ |
|
130 @java.io.Serial |
127 private void writeObject(ObjectOutputStream out) throws IOException { |
131 private void writeObject(ObjectOutputStream out) throws IOException { |
128 ObjectOutputStream.PutField fields = out.putFields(); |
132 ObjectOutputStream.PutField fields = out.putFields(); |
129 fields.put("exception", super.getCause()); |
133 fields.put("exception", super.getCause()); |
130 out.writeFields(); |
134 out.writeFields(); |
131 } |
135 } |