[jira] [Comment Edited] (GROOVY-8186) Builder ExternalStrategy constructors have trouble with private fields

2017-05-14 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16009898#comment-16009898
 ] 

Paul King edited comment on GROOVY-8186 at 5/15/17 1:21 AM:


For case (1), which is when the builder class and buildee class are in the same 
compilation unit, you are correct that JavaBean properties aren't considered, 
just standard Groovy properties. We probably should change this. I suspect what 
we do for {{@ToString}}, where the underlying transform calls 
{{BeanUtils.getAllProperties}} to get the complete set of properties, is the 
way to go.

For case (2), it isn't really Groovy vs Java but whether the class is 
pre-compiled or not. When pre-compiled, {{@Builder}} uses standard JavaBean 
introspection to find the properties. If the parameter type of the setter 
doesn't match with the return type of the getter, the property is deemed 
read-only from a JavaBean perspective (and there just happens to be a 
setter-like named method also existing with a different parameter type):
{code}
def personClass = new GroovyShell().evaluate '''
class GroovyPerson {
private Set pets
//Collection getPets() { pets }
Set getPets() { pets }
//void setPets(Set pets) {
void setPets(Collection pets) {
this.pets = pets == null ? Collections.emptySet() : new 
LinkedHashSet(pets)
}
}
GroovyPerson
'''
java.beans.Introspector.getBeanInfo(personClass).propertyDescriptors.each { pd 
->
if (!['class', 'metaClass'].contains(pd.name))
println "$pd.name $pd.propertyType.name $pd.writeMethod"
}
{code}
The null {{writeMethod}} indicates a read-only property. Uncomment either of 
the commented out lines (and remove the appropriate existing line) to see the 
property reappear.
I suspect we don't want to change that but I haven't checked what case (1) does 
in that situation yet - if we were to fix it as per above.


was (Author: paulk):
For case (1), which is when the builder class and buildee class are in the same 
compilation unit, you are correct that JavaBean properties aren't considered, 
just standard Groovy properties. We probably should change this. I suspect what 
we do for {{@ToString}}, where the underlying transform calls 
{{BeanUtils.getAllProperties}} to get the complete set of properties, is the 
way to go.

For case (2), it isn't really Groovy vs Java but whether the class is 
pre-compiled or not. When pre-compiled, {{@Builder}} uses standard JavaBean 
introspection to find the properties. If the parameter type of the setter 
doesn't match with the return type of the getter, the property is deemed 
read-only from a JavaBean perspective (and there just happens to be a 
setter-like named method also existing with a different parameter type):
{code}
def personClass = new GroovyShell().evaluate '''
class GroovyPerson {
private Set pets
//Collection getPets() { pets }
Set getPets() { pets }
//void setPets(Set pets) {
void setPets(Collection pets) {
this.pets = pets == null ? Collections.emptySet() : new 
LinkedHashSet(pets)
}
}
GroovyPerson
'''
java.beans.Introspector.getBeanInfo(personClass).propertyDescriptors.each { pd 
->
if (!['class', 'metaClass'].contains(pd.name))
println "$pd.name $pd.propertyType.name $pd.writeMethod"
}
{code}
The null {{writeMethod}} indicates a read-only property. Uncomment either of 
the commented out lines to see the property reappear.
I suspect we don't want to change that but I haven't checked what case (1) does 
in that situation yet.

> Builder ExternalStrategy constructors have trouble with private fields
> --
>
> Key: GROOVY-8186
> URL: https://issues.apache.org/jira/browse/GROOVY-8186
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.x, 2.5.x
>Reporter: Jason Terhune-Wold
>Priority: Minor
>
> An undocumented feature of @Builder is that the builder's constructor can set 
> default values for the fields. See 
> http://stackoverflow.com/questions/3504/default-values-in-groovy-builder-ast
> I tried creating an ExternalStrategy @Builder annotation for 
> [BaseClientDetails|http://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/client/BaseClientDetails.html]
>  with a constructor that set a default scope. I received a 
> MissingMethodException exception, which I thought was odd.
> I added some tests to BuilderTransformTest that demonstrate apparent problems 
> using the external builder in two situations:
> 1) A groovy class with private fields and manually defined setters.
> 2) A java class with a private Set field and a setter that takes a Collection
> The tests are here: 
> https://github.com/jterhune/groovy/commit/5b2eb74cc8184235b5235b7fd4c80b241799bbc5
> I noticed this in 2.4.x. My 

[jira] [Commented] (GROOVY-8186) Builder ExternalStrategy constructors have trouble with private fields

2017-05-14 Thread Paul King (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16009898#comment-16009898
 ] 

Paul King commented on GROOVY-8186:
---

For case (1), which is when the builder class and buildee class are in the same 
compilation unit, you are correct that JavaBean properties aren't considered, 
just standard Groovy properties. We probably should change this. I suspect what 
we do for {{@ToString}}, where the underlying transform calls 
{{BeanUtils.getAllProperties}} to get the complete set of properties, is the 
way to go.

For case (2), it isn't really Groovy vs Java but whether the class is 
pre-compiled or not. When pre-compiled, {{@Builder}} uses standard JavaBean 
introspection to find the properties. If the parameter type of the setter 
doesn't match with the return type of the getter, the property is deemed 
read-only from a JavaBean perspective (and there just happens to be a 
setter-like named method also existing with a different parameter type):
{code}
def personClass = new GroovyShell().evaluate '''
class GroovyPerson {
private Set pets
//Collection getPets() { pets }
Set getPets() { pets }
//void setPets(Set pets) {
void setPets(Collection pets) {
this.pets = pets == null ? Collections.emptySet() : new 
LinkedHashSet(pets)
}
}
GroovyPerson
'''
java.beans.Introspector.getBeanInfo(personClass).propertyDescriptors.each { pd 
->
if (!['class', 'metaClass'].contains(pd.name))
println "$pd.name $pd.propertyType.name $pd.writeMethod"
}
{code}
The null {{writeMethod}} indicates a read-only property. Uncomment either of 
the commented out lines to see the property reappear.
I suspect we don't want to change that but I haven't checked what case (1) does 
in that situation yet.

> Builder ExternalStrategy constructors have trouble with private fields
> --
>
> Key: GROOVY-8186
> URL: https://issues.apache.org/jira/browse/GROOVY-8186
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.x, 2.5.x
>Reporter: Jason Terhune-Wold
>Priority: Minor
>
> An undocumented feature of @Builder is that the builder's constructor can set 
> default values for the fields. See 
> http://stackoverflow.com/questions/3504/default-values-in-groovy-builder-ast
> I tried creating an ExternalStrategy @Builder annotation for 
> [BaseClientDetails|http://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/client/BaseClientDetails.html]
>  with a constructor that set a default scope. I received a 
> MissingMethodException exception, which I thought was odd.
> I added some tests to BuilderTransformTest that demonstrate apparent problems 
> using the external builder in two situations:
> 1) A groovy class with private fields and manually defined setters.
> 2) A java class with a private Set field and a setter that takes a Collection
> The tests are here: 
> https://github.com/jterhune/groovy/commit/5b2eb74cc8184235b5235b7fd4c80b241799bbc5
> I noticed this in 2.4.x. My tests fail in the 2.5.x branch also.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (GROOVY-7670) CLONE - dash in script filename

2017-05-14 Thread Cazacu Mihai (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16009776#comment-16009776
 ] 

Cazacu Mihai commented on GROOVY-7670:
--

Is there any progress on this? It would be nice to have language agnostic file 
names.

> CLONE - dash in script filename
> ---
>
> Key: GROOVY-7670
> URL: https://issues.apache.org/jira/browse/GROOVY-7670
> Project: Groovy
>  Issue Type: Bug
>  Components: class generator
>Affects Versions: 2.4.5
> Environment: Oracle Java 8, Windows (although OS is not relevant IMHO)
>Reporter: Christoph Grothaus
>Priority: Minor
> Attachments: fibonacci_numbers.groovy, fibonacci-numbers.groovy
>
>
> Cannot create script with dash ("-") in filename.
> Please try to run the two attached groovy scripts. The one with an underscore 
> in the filename runs happily (don't wonder, it gives no output). The one with 
> a dash in the filename gives this error: {noformat}$ groovy 
> fibonacci-numbers.groovy
> Caught: java.lang.ClassFormatError: Illegal class name 
> "fibonacci-numbers$fib" in class file fibonacci-numbers$fib
> java.lang.ClassFormatError: Illegal class name "fibonacci-numbers$fib" in 
> class file fibonacci-numbers$fib
> at fibonacci-numbers.run(fibonacci-numbers.groovy:5){noformat}
> It really took me some time to figure out that the dash was causing this. I 
> would like to see Groovy allowing dashes in script filenames. If that should 
> be impossible, at least the error message should cleary indicate that I have 
> used an illegal character in the script filename.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Comment Edited] (GROOVY-8163) Groovy scripts can disable java security manager and escape sandbox

2017-05-14 Thread Dimitry Polivaev (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16009694#comment-16009694
 ] 

Dimitry Polivaev edited comment on GROOVY-8163 at 5/14/17 11:57 AM:


{{doPrivileged}} blocks in the test are needed to ignore any access checks for 
JUnit Runner which belong to different protection domains and depend on how the 
test execution is started (by gradle or by IDE) . They do not influence checks 
for called groovy scripts.

After I updated my test project to Version 2.4.11 the {{GroovyBeanTest}} still 
fails with MissingPropertyException.


was (Author: dpolivaev):
{{doPrivileged}} blocks in the test are needed to ignore checks for JUnit 
Runner which belong to different protection domains and depend on how the test 
execution is started (by gradle or by IDE) . 

After I updated my test project to Version 2.4.11 the {{GroovyBeanTest}} still 
fails with MissingPropertyException.

> Groovy scripts can disable java security manager and escape sandbox
> ---
>
> Key: GROOVY-8163
> URL: https://issues.apache.org/jira/browse/GROOVY-8163
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.0-alpha-1, 2.4.9, 2.4.10
>Reporter: Dimitry Polivaev
>
> Consider following test
> {code}
> package groovytest;
> import groovy.util.Eval;
> import org.junit.*;
> import java.net.URL;
> import java.security.AccessController;
> import java.security.PrivilegedAction;
> public class GroovySecurityTest {
>   public static final String 
> RESTRICTED_PERMISSIONS_FOR_SCRIPT_ONLY_POLICY = 
> "/restrictedPermissionsForScriptOnlyPolicy.txt";
>   public static final String POLICY = 
> RESTRICTED_PERMISSIONS_FOR_SCRIPT_ONLY_POLICY;
>   @BeforeClass
>   public static void setPolicy() throws Exception {
>   final String dirTest = 
> GroovySecurityTest.class.getProtectionDomain().getCodeSource().getLocation().toString();
>   final String dirGroovy = 
> Eval.class.getProtectionDomain().getCodeSource().getLocation().toString();
>   System.setProperty("dir.test",dirTest + "-");
>   System.setProperty("dir.groovy",dirGroovy);
>   final URL policy = GroovySecurityTest.class.getResource(POLICY);
>   System.setProperty("java.security.policy", policy.toString());
>   }
>   
>   
>   @Before
>   public void setSecurityManager() throws Exception {
>   System.setSecurityManager(new SecurityManager());
>   }
>   @After
>   public void removeSecurityManager() throws Exception {
>   AccessController.doPrivileged(new PrivilegedAction() {
>   @Override
>   public Void run() {
>   System.setSecurityManager(null);
>   return null;
>   }
>   });
>   }
>   @Test
>   public void doesNotChangeScriptPermissionsUsungPrivateFieldAccess() 
> throws Exception {
>   try {
>   AccessController.doPrivileged(new 
> PrivilegedAction() {
> @Override
> public Void run() {
> Eval.me("getClass().protectionDomain0.hasAllPerm = true;"
> + "System.setSecurityManager(null);"
> + "1");
> return null;
> }
> });
>   } catch (Exception e) {
>   }
>   Assert.assertNotNull(System.getSecurityManager());
>   }
> }
> {code}
> with following policy file restrictedPermissionsForScriptOnlyPolicy.txt
> {code}
> grant codeBase "${dir.test}" {
>   permission java.security.AllPermission;
> };
> grant codeBase "${dir.groovy}" {
>   permission java.security.AllPermission;
> };
> grant {
> };
> {code}
> It fails: security manager is not set any more when the test assertion is 
> checked.
> It happens because CachedField from org.codehaus.groovy.reflection is created 
> withing trusted code base (groovy jar) and gives access to the field to 
> untrusted scripts without any security checks. The same problem relates to 
> CachedMethod which would allow any script to access protected method 
> java.lang.ClassLoader#defineClass(java.lang.String, byte[], int, int, 
> java.security.ProtectionDomain) that can be misused to manipulate code 
> sources of classes loaded from script to give them all permissions.
> It also appears that if I remove permissions from groovy.jar using more 
> restrictive policy using following policy file restrictedPermissionsPolicy.txt
> {code}
> grant  codeBase "${dir.test}" {
> permission java.lang.RuntimePermission "*";
> permission java.security.SecurityPermission 

[jira] [Commented] (GROOVY-8163) Groovy scripts can disable java security manager and escape sandbox

2017-05-14 Thread Dimitry Polivaev (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16009695#comment-16009695
 ] 

Dimitry Polivaev commented on GROOVY-8163:
--

Need for patching {{MetaClassImpl}} if {{GroovyRuntimeException}} is thrown 
instead of {{IllegalArgumentException}} as suggested in the review is 
demonstrated by the following test added to {{GroovySecurityTest}} : 

{code}
@Test
public void returnsLoggerClassName() throws Exception {
AccessController.doPrivileged(new PrivilegedAction() {

@Override
public Void run() {
Assert.assertEquals("java.util.logging.Logger", 
Eval.x(Logger.getGlobal(), "x.class.name"));
return null;
}
});
}

{code}

> Groovy scripts can disable java security manager and escape sandbox
> ---
>
> Key: GROOVY-8163
> URL: https://issues.apache.org/jira/browse/GROOVY-8163
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.0-alpha-1, 2.4.9, 2.4.10
>Reporter: Dimitry Polivaev
>
> Consider following test
> {code}
> package groovytest;
> import groovy.util.Eval;
> import org.junit.*;
> import java.net.URL;
> import java.security.AccessController;
> import java.security.PrivilegedAction;
> public class GroovySecurityTest {
>   public static final String 
> RESTRICTED_PERMISSIONS_FOR_SCRIPT_ONLY_POLICY = 
> "/restrictedPermissionsForScriptOnlyPolicy.txt";
>   public static final String POLICY = 
> RESTRICTED_PERMISSIONS_FOR_SCRIPT_ONLY_POLICY;
>   @BeforeClass
>   public static void setPolicy() throws Exception {
>   final String dirTest = 
> GroovySecurityTest.class.getProtectionDomain().getCodeSource().getLocation().toString();
>   final String dirGroovy = 
> Eval.class.getProtectionDomain().getCodeSource().getLocation().toString();
>   System.setProperty("dir.test",dirTest + "-");
>   System.setProperty("dir.groovy",dirGroovy);
>   final URL policy = GroovySecurityTest.class.getResource(POLICY);
>   System.setProperty("java.security.policy", policy.toString());
>   }
>   
>   
>   @Before
>   public void setSecurityManager() throws Exception {
>   System.setSecurityManager(new SecurityManager());
>   }
>   @After
>   public void removeSecurityManager() throws Exception {
>   AccessController.doPrivileged(new PrivilegedAction() {
>   @Override
>   public Void run() {
>   System.setSecurityManager(null);
>   return null;
>   }
>   });
>   }
>   @Test
>   public void doesNotChangeScriptPermissionsUsungPrivateFieldAccess() 
> throws Exception {
>   try {
>   AccessController.doPrivileged(new 
> PrivilegedAction() {
> @Override
> public Void run() {
> Eval.me("getClass().protectionDomain0.hasAllPerm = true;"
> + "System.setSecurityManager(null);"
> + "1");
> return null;
> }
> });
>   } catch (Exception e) {
>   }
>   Assert.assertNotNull(System.getSecurityManager());
>   }
> }
> {code}
> with following policy file restrictedPermissionsForScriptOnlyPolicy.txt
> {code}
> grant codeBase "${dir.test}" {
>   permission java.security.AllPermission;
> };
> grant codeBase "${dir.groovy}" {
>   permission java.security.AllPermission;
> };
> grant {
> };
> {code}
> It fails: security manager is not set any more when the test assertion is 
> checked.
> It happens because CachedField from org.codehaus.groovy.reflection is created 
> withing trusted code base (groovy jar) and gives access to the field to 
> untrusted scripts without any security checks. The same problem relates to 
> CachedMethod which would allow any script to access protected method 
> java.lang.ClassLoader#defineClass(java.lang.String, byte[], int, int, 
> java.security.ProtectionDomain) that can be misused to manipulate code 
> sources of classes loaded from script to give them all permissions.
> It also appears that if I remove permissions from groovy.jar using more 
> restrictive policy using following policy file restrictedPermissionsPolicy.txt
> {code}
> grant  codeBase "${dir.test}" {
> permission java.lang.RuntimePermission "*";
> permission java.security.SecurityPermission "*";
>  permission java.io.FilePermission "<>", "read";
> permission 

[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377499
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -124,6 +131,12 @@ public String getSignature() {
 }
 
 public final Method setAccessible() {
+try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to method" 
+ cachedMethod.getName());
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377497
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -90,6 +91,12 @@ public CachedClass getDeclaringClass() {
 
 public final Object invoke(Object object, Object[] arguments) {
 try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new InvokerInvocationException(new 
IllegalArgumentException("Illegal access to method" + cachedMethod.getName()));
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377501
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -324,6 +337,12 @@ else if (o2 instanceof CachedMethod)
 }
 
 public Method getCachedMethod() {
+try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to method" 
+ cachedMethod.getName());
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377495
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedField.java ---
@@ -65,6 +72,12 @@ public Object getProperty(final Object object) {
  * @throws RuntimeException if the property could not be set
  */
 public void setProperty(final Object object, Object newValue) {
+try {
+AccessPermissionChecker.checkAccessPermission(field);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to field" + 
" " + field.getName());
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377482
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedField.java ---
@@ -51,6 +52,12 @@ public int getModifiers() {
  */
 public Object getProperty(final Object object) {
 try {
+AccessPermissionChecker.checkAccessPermission(field);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to field" + 
" " + field.getName());
--- End diff --

To use GroovyRuntimeException we need to patch also 
MetaClassImpl.getProperty . It was not possible with byte buddy, but as a 
groovy patch it is possible. I shall do it in a separate commit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377418
  
--- Diff: 
src/main/org/codehaus/groovy/reflection/AccessPermissionChecker.java ---
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.reflection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ReflectPermission;
+
+import groovy.lang.GroovyObject;
+
+class AccessPermissionChecker {
+
+   private static final ReflectPermission REFLECT_PERMISSION = new 
ReflectPermission("suppressAccessChecks");
+
+   static private void checkAccessPermission(Class declaringClass, 
final int modifiers, boolean isAccessible) {
+   final SecurityManager securityManager = 
System.getSecurityManager();
--- End diff --

Signature changed. The check is performed only if (securityManager != null 
&& isAccessible)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---