Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make instance variables in ClojureReflector final

  • Loading branch information...
commit 25db2b151fc68308a85cdcf505e66d8ef0050cd2 1 parent 6eecfdb
@stuartsierra authored
View
3  src/main/java/org/clojure/maven/ClojureCompileTask.java
@@ -18,9 +18,10 @@ public ClojureCompileTask(Log log, String outputDirectory, String[] namespaces)
}
public void run() {
- ClojureReflector clojure = new ClojureReflector();
+ ClojureReflector clojure = null;
boolean bindingsPushed = false;
try {
+ clojure = new ClojureReflector();
Object bindings =
clojure.
map(clojure.compilePathVar,
View
89 src/main/java/org/clojure/maven/ClojureReflector.java
@@ -13,54 +13,49 @@
private static final String WARN_ON_REFLECTION_PROP = "clojure.compile.warn-on-reflection";
private static final String UNCHECKED_MATH_PROP = "clojure.compile.unchecked-math";
- private Class RTClass;
- private Class VarClass;
-
- private Method mapMethod;
- private Method varMethod;
-
- private Method invoke0;
- private Method invoke1;
- private Method invoke2;
- private Method invoke3;
- private Method invoke4;
- private Method invoke5;
-
- public Object compileVar;
- public Object compilePathVar;
- public Object pushThreadBindingsVar;
- public Object popThreadBindingsVar;
- public Object symbolVar;
- public Object uncheckedMathVar;
- public Object warnOnReflectionVar;
-
- public ClojureReflector() {
+ private final Class RTClass;
+ private final Class VarClass;
+
+ private final Method mapMethod;
+ private final Method varMethod;
+
+ private final Method invoke0;
+ private final Method invoke1;
+ private final Method invoke2;
+ private final Method invoke3;
+ private final Method invoke4;
+ private final Method invoke5;
+
+ public final Object compileVar;
+ public final Object compilePathVar;
+ public final Object pushThreadBindingsVar;
+ public final Object popThreadBindingsVar;
+ public final Object symbolVar;
+ public final Object uncheckedMathVar;
+ public final Object warnOnReflectionVar;
+
+ public ClojureReflector() throws Exception {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
- try {
- RTClass = classloader.loadClass("clojure.lang.RT");
- VarClass = classloader.loadClass("clojure.lang.Var");
-
- mapMethod = RTClass.getMethod("map", new Class[]{Object[].class});
- varMethod = RTClass.getMethod("var", new Class[]{String.class, String.class});
-
- invoke0 = VarClass.getMethod("invoke", new Class[]{});
- invoke1 = VarClass.getMethod("invoke", new Class[]{Object.class});
- invoke2 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class});
- invoke3 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class, Object.class});
- invoke4 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class, Object.class, Object.class});
- invoke5 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class, Object.class, Object.class, Object.class});
-
- compileVar = var("clojure.core", "compile");
- compilePathVar = var("clojure.core", "*compile-path*");
- pushThreadBindingsVar = var("clojure.core", "push-thread-bindings");
- popThreadBindingsVar = var("clojure.core", "pop-thread-bindings");
- symbolVar = var("clojure.core", "symbol");
- uncheckedMathVar = var("clojure.core", "*unchecked-math*");
- warnOnReflectionVar = var("clojure.core", "*warn-on-reflection*");
- } catch (Exception e) {
- System.err.println("Failed to load Clojure");
- e.printStackTrace();
- }
+ RTClass = classloader.loadClass("clojure.lang.RT");
+ VarClass = classloader.loadClass("clojure.lang.Var");
+
+ mapMethod = RTClass.getMethod("map", new Class[]{Object[].class});
+ varMethod = RTClass.getMethod("var", new Class[]{String.class, String.class});
+
+ invoke0 = VarClass.getMethod("invoke", new Class[]{});
+ invoke1 = VarClass.getMethod("invoke", new Class[]{Object.class});
+ invoke2 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class});
+ invoke3 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class, Object.class});
+ invoke4 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class, Object.class, Object.class});
+ invoke5 = VarClass.getMethod("invoke", new Class[]{Object.class, Object.class, Object.class, Object.class, Object.class});
+
+ compileVar = var("clojure.core", "compile");
+ compilePathVar = var("clojure.core", "*compile-path*");
+ pushThreadBindingsVar = var("clojure.core", "push-thread-bindings");
+ popThreadBindingsVar = var("clojure.core", "pop-thread-bindings");
+ symbolVar = var("clojure.core", "symbol");
+ uncheckedMathVar = var("clojure.core", "*unchecked-math*");
+ warnOnReflectionVar = var("clojure.core", "*warn-on-reflection*");
}
/** Returns the Clojure Var with the given namespace and name. */
Please sign in to comment.
Something went wrong with that request. Please try again.