--- a/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java Thu Jul 19 16:22:19 2018 +0800
+++ b/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java Thu Jul 19 09:20:08 2018 -0700
@@ -25,6 +25,8 @@
package java.lang.invoke;
import java.io.Serializable;
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@@ -223,7 +225,7 @@
return capturedArgs[i];
}
- private Object readResolve() throws ReflectiveOperationException {
+ private Object readResolve() throws ObjectStreamException {
try {
Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
@Override
@@ -235,12 +237,13 @@
});
return deserialize.invoke(null, this);
- }
- catch (PrivilegedActionException e) {
+ } catch (ReflectiveOperationException roe) {
+ ObjectStreamException ose = new InvalidObjectException("ReflectiveOperationException during deserialization");
+ ose.initCause(roe);
+ throw ose;
+ } catch (PrivilegedActionException e) {
Exception cause = e.getException();
- if (cause instanceof ReflectiveOperationException)
- throw (ReflectiveOperationException) cause;
- else if (cause instanceof RuntimeException)
+ if (cause instanceof RuntimeException)
throw (RuntimeException) cause;
else
throw new RuntimeException("Exception in SerializedLambda.readResolve", e);