You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by cc...@apache.org on 2015/09/13 13:46:17 UTC
[2/2] incubator-groovy git commit: GROOVY-7591: Temporarily disable
use of ClassValue
GROOVY-7591: Temporarily disable use of ClassValue
Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/b8bcf638
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/b8bcf638
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/b8bcf638
Branch: refs/heads/GROOVY_2_4_X
Commit: b8bcf6389682cdebb4bbd1806e01748f84fc496a
Parents: 517faff
Author: Cedric Champeau <cc...@apache.org>
Authored: Sun Sep 13 13:45:35 2015 +0200
Committer: Cedric Champeau <cc...@apache.org>
Committed: Sun Sep 13 13:45:53 2015 +0200
----------------------------------------------------------------------
.../reflection/GroovyClassValueFactory.java | 29 ++++++++++++++------
1 file changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/b8bcf638/src/main/org/codehaus/groovy/reflection/GroovyClassValueFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/reflection/GroovyClassValueFactory.java b/src/main/org/codehaus/groovy/reflection/GroovyClassValueFactory.java
index 03ef9e0..64a1608 100644
--- a/src/main/org/codehaus/groovy/reflection/GroovyClassValueFactory.java
+++ b/src/main/org/codehaus/groovy/reflection/GroovyClassValueFactory.java
@@ -18,23 +18,34 @@
*/
package org.codehaus.groovy.reflection;
-import java.lang.reflect.Constructor;
-
import org.codehaus.groovy.reflection.GroovyClassValue.ComputeValue;
+import java.lang.reflect.Constructor;
+
class GroovyClassValueFactory {
+ /**
+ * This flag is introduced as a (hopefully) temporary workaround for a JVM bug, that is to say that using
+ * ClassValue prevents the classes and classloaders from being unloaded.
+ * See https://bugs.openjdk.java.net/browse/JDK-8136353
+ */
+ private final static boolean USE_CLASSVALUE = Boolean.valueOf(System.getProperty("groovy.use.classvalue", "false"));
+
private static final Constructor groovyClassValueConstructor;
static {
Class groovyClassValueClass;
- try{
- Class.forName("java.lang.ClassValue");
- try{
- groovyClassValueClass = Class.forName("org.codehaus.groovy.reflection.v7.GroovyClassValueJava7");
- }catch(Exception e){
- throw new RuntimeException(e); // this should never happen, but if it does, let it propagate and be fatal
+ if (USE_CLASSVALUE) {
+ try {
+ Class.forName("java.lang.ClassValue");
+ try {
+ groovyClassValueClass = Class.forName("org.codehaus.groovy.reflection.v7.GroovyClassValueJava7");
+ } catch (Exception e) {
+ throw new RuntimeException(e); // this should never happen, but if it does, let it propagate and be fatal
+ }
+ } catch (ClassNotFoundException e) {
+ groovyClassValueClass = GroovyClassValuePreJava7.class;
}
- }catch(ClassNotFoundException e){
+ } else {
groovyClassValueClass = GroovyClassValuePreJava7.class;
}
try{