You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/09/02 01:52:39 UTC
[groovy] branch master updated: reduce impact of
makeAccessible(AccessibleObject) (closes #1357)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 9fb9e50 reduce impact of makeAccessible(AccessibleObject) (closes #1357)
9fb9e50 is described below
commit 9fb9e506eb2af8e96a593e08d64cfae5b5acf007
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Aug 29 12:38:34 2020 -0500
reduce impact of makeAccessible(AccessibleObject) (closes #1357)
---
.../java/org/codehaus/groovy/reflection/ReflectionUtils.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
index 780e7a7..411b79d 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
@@ -196,8 +196,14 @@ public class ReflectionUtils {
// to be run in PrivilegedAction!
public static Optional<AccessibleObject> makeAccessible(final AccessibleObject ao) {
- AccessibleObject[] result = makeAccessible(new AccessibleObject[] {ao});
- return Optional.ofNullable(result.length == 0 ? null : result[0]);
+ try {
+ if (ao.isAccessible() || trySetAccessible(ao)) {
+ return Optional.of(ao);
+ }
+ } catch (Throwable ignore) {
+ // swallow for strict security managers, module systems, android, etc.
+ }
+ return Optional.empty();
}
// to be run in PrivilegedAction!