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 2019/07/03 23:15:25 UTC

[groovy] 02/02: Refine the switch according to @paulk-asert's suggestion

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

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 54ed0f8839082316419e8cad07399f6028bfda1d
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Jul 3 23:00:49 2019 +0800

    Refine the switch according to @paulk-asert's suggestion
---
 src/main/java/groovy/lang/MetaClassImpl.java | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 8516472..b0ab132 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -142,6 +142,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
     };
     private static final MetaMethod[] EMPTY = MetaMethod.EMPTY_ARRAY;
     private static final MetaMethod AMBIGUOUS_LISTENER_METHOD = new DummyMetaMethod();
+    private static final boolean PERMISSIVE_PROPERTY_ACCESS = SystemUtil.getBooleanSafe("groovy.permissive.property.access");
 
     protected final Class theClass;
     protected final CachedClass theCachedClass;
@@ -173,6 +174,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
     private MetaMethod propertyMissingSet;
     private MetaMethod methodMissing;
     private MetaMethodIndex.Header mainClassMethodHeader;
+    private boolean permissivePropertyAccess = PERMISSIVE_PROPERTY_ACCESS;
 
      /**
       * Constructor
@@ -2211,7 +2213,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
 //                }
             }
 
-            if (!ALLOW_ILLEGAL_ACCESS_PROPERTIES) {
+            if (!permissivePropertyAccess) {
                 if (element instanceof MetaBeanProperty) {
                     MetaBeanProperty mbp = (MetaBeanProperty) element;
                     boolean getterAccessible = canAccessLegally(mbp.getGetter());
@@ -2226,8 +2228,6 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
         return ret;
     }
 
-    private static final boolean ALLOW_ILLEGAL_ACCESS_PROPERTIES = SystemUtil.getBooleanSafe("groovy.allow.illegal.access.properties");
-
     private static boolean canAccessLegally(MetaMethod accessor) {
         boolean accessible = true;
         if (accessor instanceof CachedMethod) {
@@ -4084,4 +4084,12 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
     private enum InvokeMethodResult {
         NONE
     }
+
+    public boolean isPermissivePropertyAccess() {
+        return permissivePropertyAccess;
+    }
+
+    public void setPermissivePropertyAccess(boolean permissivePropertyAccess) {
+        this.permissivePropertyAccess = permissivePropertyAccess;
+    }
 }