Permalink
Browse files

More detail with loader problem

  • Loading branch information...
1 parent ca8f02f commit cf3a48c3ff1df4a10a2aaf021e2f7adbf32f959b @frenchy64 frenchy64 committed Jan 4, 2012
Showing with 33 additions and 23 deletions.
  1. +33 −23 src/analyze/examples/load_core.clj
@@ -2,36 +2,46 @@
(:import [clojure.lang Compiler RT DynamicClassLoader])
(:require [analyze.core :as analyze]))
-(defn wall-hack [what class-name member-name & args]
- (letfn [(wall-hack-field [class-name field-name obj]
- (-> class-name (.getDeclaredField (name field-name))
- (doto (.setAccessible true)) (.get obj)))
- (wall-hack-method [class-name method-name types obj args]
- (-> class-name (.getDeclaredMethod (name method-name)
- (into-array Class types))
- (doto (.setAccessible true))
- (.invoke obj (into-array Object args))))]
- (condp = what
- :method
- (wall-hack-method class-name member-name (first args) (fnext args) (nnext args))
- :field
- (wall-hack-field class-name member-name (first args)))))
+;; Reproducible problem, similar to the one we're having loading clojure.core
(defmacro deftesteval
- "Experimental - like defmacro, except defines a named function whose
- body is the expansion, calls to which may be expanded inline as if
- it were a macro. Cannot be used with variadic (&) args."
- {:added "1.0"}
- [name & decl]
- (let [[pre-args [args expr]] (split-with (comp not vector?) decl)]
- `(do
- (defn ~name ~@pre-args ~args )
- (fn ~name ~args ~expr))))
+ [name args expr]
+ `(do
+ (fn ~name ~args ~expr) ;; not sure the minimum reproducible case, but having both these lines trigger it
+ (fn ~name ~args ~expr)))
+;; .. and evaling this first ..
(deftesteval myfn [x] `(+ ~x))
+;; .. followed by analyzing the same form again, in this namespace ..
(analyze/analyze-one '{:ns {:name analyze.examples.load-core} :context :eval}
'(deftesteval myfn [x] `(+ ~x)))
+;; results in ...
+
+;CompilerException java.lang.LinkageError: loader (instance of clojure/lang/DynamicClassLoader): attempted duplicate class definition for name: "analyze/examples/load_core$myfn", compiling:(REPL:5)
+; clojure.lang.Compiler.analyzeSeq (Compiler.java:6416)
+; clojure.lang.Compiler.analyze (Compiler.java:6216)
+; clojure.lang.Compiler.analyzeSeq (Compiler.java:6397)
+; clojure.lang.Compiler.analyze (Compiler.java:6216)
+; clojure.lang.Compiler.analyze (Compiler.java:6177)
+; clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5572)
+; clojure.lang.Compiler.analyzeSeq (Compiler.java:6409)
+; clojure.lang.Compiler.analyze (Compiler.java:6216)
+; clojure.lang.Compiler.analyzeSeq (Compiler.java:6397)
+; clojure.lang.Compiler.analyze (Compiler.java:6216)
+; clojure.lang.Compiler.analyze (Compiler.java:6177)
+; analyze.core/analyze*/invoke-analyze--770 (core.clj:565)
+;Caused by:
+;LinkageError loader (instance of clojure/lang/DynamicClassLoader): attempted duplicate class definition for name: "analyze/examples/load_core$myfn"
+; java.lang.ClassLoader.defineClass1 (ClassLoader.java:-2)
+; java.lang.ClassLoader.defineClassCond (ClassLoader.java:631)
+; java.lang.ClassLoader.defineClass (ClassLoader.java:615)
+; java.lang.ClassLoader.defineClass (ClassLoader.java:465)
+; clojure.lang.DynamicClassLoader.defineClass (DynamicClassLoader.java:46)
+; clojure.lang.Compiler$ObjExpr.getCompiledClass (Compiler.java:4533)
+; clojure.lang.Compiler$FnExpr.parse (Compiler.java:3697)
+; clojure.lang.Compiler.analyzeSeq (Compiler.java:6407)
+; clojure.lang.Compiler.analyze (Compiler.java:6216)
;(def a (analyze/analyze-path "clojure/core.clj" 'clojure.core))

0 comments on commit cf3a48c

Please sign in to comment.