Repository: groovy
Updated Branches:
  refs/heads/master 40507e0b8 -> 7ced8a2ca


GROOVY-7735: Generate closures as public classes

Access to closures is currently cached by the Groovy runtime in 
org.codehaus.groovy.reflection.CachedMethod.
If closures are generated as package-private classes, invoking the cached 
method from CachedMethod only works
if the suppressAccessChecks permission is granted to the security manager, a 
permission which is dangerous
as it completely disables standard language access checks.


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7ced8a2c
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7ced8a2c
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7ced8a2c

Branch: refs/heads/master
Commit: 7ced8a2cacbe0c2cf824eceac431d8a2f02de8f4
Parents: 40507e0
Author: Yannick Welsch <yann...@elastic.co>
Authored: Mon Jan 25 17:27:41 2016 +0100
Committer: pascalschumacher <pascalschumac...@gmx.net>
Committed: Mon Feb 8 22:44:36 2016 +0100

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/classgen/asm/ClosureWriter.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7ced8a2c/src/main/org/codehaus/groovy/classgen/asm/ClosureWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/ClosureWriter.java 
b/src/main/org/codehaus/groovy/classgen/asm/ClosureWriter.java
index 777411e..8d1369f 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/ClosureWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/ClosureWriter.java
@@ -77,8 +77,10 @@ public class ClosureWriter {
         MethodVisitor mv = controller.getMethodVisitor();
         ClassNode classNode = controller.getClassNode();
         AsmClassGenerator acg = controller.getAcg();
-        
-        ClassNode closureClass = getOrAddClosureClass(expression, 0);
+
+        // generate closure as public class to make sure it can be properly 
invoked by classes of the
+        // Groovy runtime without circumventing JVM access checks (see 
CachedMethod for example).
+        ClassNode closureClass = getOrAddClosureClass(expression, ACC_PUBLIC);
         String closureClassinternalName = 
BytecodeHelper.getClassInternalName(closureClass);
         List constructors = closureClass.getDeclaredConstructors();
         ConstructorNode node = (ConstructorNode) constructors.get(0);

Reply via email to