mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8344011: Remove usage of security manager from Class and reflective APIs
Reviewed-by: liach, yzheng, rriggs
This commit is contained in:
parent
c977ef7b45
commit
abacece826
26 changed files with 163 additions and 1251 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -28,9 +28,6 @@ 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;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
@ -265,25 +262,11 @@ public final class SerializedLambda implements Serializable {
|
|||
@java.io.Serial
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
|
||||
@Override
|
||||
public Method run() throws Exception {
|
||||
Method m = capturingClass.getDeclaredMethod("$deserializeLambda$", SerializedLambda.class);
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
}
|
||||
});
|
||||
|
||||
Method deserialize = capturingClass.getDeclaredMethod("$deserializeLambda$", SerializedLambda.class);
|
||||
deserialize.setAccessible(true);
|
||||
return deserialize.invoke(null, this);
|
||||
} catch (ReflectiveOperationException roe) {
|
||||
throw new InvalidObjectException("ReflectiveOperationException during deserialization", roe);
|
||||
} catch (PrivilegedActionException e) {
|
||||
Exception cause = e.getException();
|
||||
if (cause instanceof RuntimeException re)
|
||||
throw re;
|
||||
else
|
||||
throw new RuntimeException("Exception in SerializedLambda.readResolve", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue