You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2019/07/03 06:39:02 UTC

[GitHub] [groovy] paulk-asert commented on a change in pull request #934: GROOVY-9103: CLONE - CLONE - Fix warning "An illegal reflective acces…

paulk-asert commented on a change in pull request #934: GROOVY-9103: CLONE - CLONE - Fix warning "An illegal reflective acces…
URL: https://github.com/apache/groovy/pull/934#discussion_r299796556
 
 

 ##########
 File path: src/main/java/groovy/lang/MetaClassImpl.java
 ##########
 @@ -2207,11 +2210,34 @@ private static MetaMethod getCategoryMethodSetter(Class sender, String name, boo
 //                    element = new MetaBeanProperty(mp.getName(), mp.getType(), null, mp.getSetter());
 //                }
             }
+
+            if (!ALLOW_ILLEGAL_ACCESS_PROPERTIES) {
+                if (element instanceof MetaBeanProperty) {
+                    MetaBeanProperty mbp = (MetaBeanProperty) element;
+                    boolean getterAccessible = canAccessLegally(mbp.getGetter());
+                    boolean setterAccessible = canAccessLegally(mbp.getSetter());
+
+                    if (!(getterAccessible && setterAccessible)) continue;
+                }
+            }
+
             ret.add(element);
         }
         return ret;
     }
 
+    private static final boolean ALLOW_ILLEGAL_ACCESS_PROPERTIES = SystemUtil.getBooleanSafe("groovy.allow.illegal.access.properties");
 
 Review comment:
   This all looks good - my only suspicion is that some folks will want to turn this feature on very selectively.
   We could make an instance property which is set by the system property but could be toggled on an individual metaclass basis. I am also wondering whether "groovy.permissive.property.access" would be a better name. In future JDK versions the access might not be allowed at all - for us it is indicating that we will attempt to access the property.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services