You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/09/08 05:50:16 UTC

[groovy] branch danielsun/avoid-unnecessary-security-checks created (now d7d8fd5)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch danielsun/avoid-unnecessary-security-checks
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at d7d8fd5  Avoid unnecessary security checks for each invocation

This branch includes the following new commits:

     new d7d8fd5  Avoid unnecessary security checks for each invocation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[groovy] 01/01: Avoid unnecessary security checks for each invocation

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch danielsun/avoid-unnecessary-security-checks
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d7d8fd555ae60cd90fc307d6fd1036b52ad170a8
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Sep 8 13:48:54 2021 +0800

    Avoid unnecessary security checks for each invocation
---
 src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java | 1 +
 src/main/java/org/codehaus/groovy/reflection/CachedField.java       | 1 +
 src/main/java/org/codehaus/groovy/reflection/CachedMethod.java      | 1 +
 3 files changed, 3 insertions(+)

diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java b/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java
index 1546bd4..33938f2 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java
@@ -125,6 +125,7 @@ public class CachedConstructor extends ParameterTypes {
     private boolean makeAccessibleDone = false;
     private void makeAccessibleIfNecessary() {
         if (!makeAccessibleDone) {
+            if (cachedConstructor.isAccessible()) cachedConstructor.setAccessible(true);
             makeAccessibleInPrivilegedAction(cachedConstructor);
             makeAccessibleDone = true;
         }
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedField.java b/src/main/java/org/codehaus/groovy/reflection/CachedField.java
index 6c666aa..793fdb1 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedField.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedField.java
@@ -95,6 +95,7 @@ public class CachedField extends MetaProperty {
     private transient boolean madeAccessible;
     private void makeAccessibleIfNecessary() {
         if (!madeAccessible) {
+            if (field.isAccessible()) field.setAccessible(true);
             makeAccessibleInPrivilegedAction(field);
             madeAccessible = true;
         }
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java b/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
index 838db6a..0f1404c 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
@@ -394,6 +394,7 @@ public class CachedMethod extends MetaMethod implements Comparable {
     private boolean makeAccessibleDone = false;
     private void makeAccessibleIfNecessary() {
         if (!makeAccessibleDone) {
+            if (cachedMethod.isAccessible()) cachedMethod.setAccessible(true);
             makeAccessibleInPrivilegedAction(cachedMethod);
             makeAccessibleDone = true;
         }