groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [20/50] [abbrv] groovy git commit: GROOVY-7646: remove classes via InvokerHelper when closing the GroovyClassLoader or flushing its cache (closes #445)
Date Thu, 10 Nov 2016 15:13:52 GMT
GROOVY-7646: remove classes via InvokerHelper when closing the GroovyClassLoader or flushing
its cache (closes #445)


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

Branch: refs/heads/parrot
Commit: 4ea1207f21b93a15dbcca17538c379721d9217de
Parents: d4eadc4
Author: Jochen Berger <fooberger@gmail.com>
Authored: Mon Oct 10 11:40:53 2016 +0200
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Tue Oct 11 19:41:36 2016 -0700

----------------------------------------------------------------------
 src/main/groovy/lang/GroovyClassLoader.java | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4ea1207f/src/main/groovy/lang/GroovyClassLoader.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/GroovyClassLoader.java b/src/main/groovy/lang/GroovyClassLoader.java
index ac1f9f9..c75bb2f 100644
--- a/src/main/groovy/lang/GroovyClassLoader.java
+++ b/src/main/groovy/lang/GroovyClassLoader.java
@@ -34,6 +34,7 @@ import org.codehaus.groovy.ast.expr.ConstantExpression;
 import org.codehaus.groovy.classgen.GeneratorContext;
 import org.codehaus.groovy.classgen.Verifier;
 import org.codehaus.groovy.control.*;
+import org.codehaus.groovy.runtime.InvokerHelper;
 import org.codehaus.groovy.runtime.IOGroovyMethods;
 import org.objectweb.asm.ClassVisitor;
 import org.objectweb.asm.ClassWriter;
@@ -969,6 +970,9 @@ public class GroovyClassLoader extends URLClassLoader {
      */
     public void clearCache() {
         synchronized (classCache) {
+            for (Class cl : classCache.values()) {
+                InvokerHelper.removeClass(cl);
+            }
             classCache.clear();
         }
         synchronized (sourceCache) {
@@ -976,6 +980,12 @@ public class GroovyClassLoader extends URLClassLoader {
         }
     }
 
+    @Override
+    public void close() throws IOException {
+        super.close();
+        clearCache();
+    }
+
     private static class TimestampAdder extends CompilationUnit.PrimaryClassNodeOperation
implements Opcodes {
         private final static TimestampAdder INSTANCE = new TimestampAdder();
 


Mime
View raw message