Hi

I try to compile a file that generate a class with gen-class that include 
class name
 at different places in the file here is a simplified version of the 
problem:

lein init test-gen

then edit the core.clj with
----------------------
(ns test-gen.core
  (:gen-class
   :name test-gen.Tata
   :init pre-init
   :constructors {
                 [Integer] [Integer]
                [test-gen.Tata] [Integer]
    }
   )
)

(defn -pre-init
  [x]
  (test-gen.Tata. 9)
  9)
----------------------
add ":aot [test-gen.core]" in project.clj

then compile with lein compile:

Compiling test-gen.core
Exception in thread "main" java.lang.ClassNotFoundException: test-gen.Tata, 
compiling:(test_gen/core.clj:1)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
    at clojure.lang.Compiler.analyze(Compiler.java:6262)
    at clojure.lang.Compiler.analyze(Compiler.java:6223)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5618)
    at clojure.lang.Compiler$TryExpr$Parser.parse(Compiler.java:2136)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455)
    at clojure.lang.Compiler.analyze(Compiler.java:6262)
    at clojure.lang.Compiler.analyze(Compiler.java:6223)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5618)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5054)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3674)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453)
    at clojure.lang.Compiler.analyze(Compiler.java:6262)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443)
    at clojure.lang.Compiler.analyze(Compiler.java:6262)
    at clojure.lang.Compiler.analyze(Compiler.java:6223)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3497)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6457)
    at clojure.lang.Compiler.analyze(Compiler.java:6262)
    at clojure.lang.Compiler.analyze(Compiler.java:6223)
    at clojure.lang.Compiler.compile1(Compiler.java:7030)
    at clojure.lang.Compiler.compile1(Compiler.java:7025)
    at clojure.lang.Compiler.compile(Compiler.java:7097)
    at clojure.lang.RT.compile(RT.java:387)
    at clojure.lang.RT.load(RT.java:427)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$compile$fn__4895.invoke(core.clj:5426)
    at clojure.core$compile.invoke(core.clj:5425)
    at user$eval7.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.eval(Compiler.java:6477)
    at clojure.core$eval.invoke(core.clj:2797)
    at clojure.main$eval_opt.invoke(main.clj:297)
    at clojure.main$initialize.invoke(main.clj:316)
    at clojure.main$null_opt.invoke(main.clj:349)
    at clojure.main$main.doInvoke(main.clj:427)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassNotFoundException: test-gen.Tata
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:266)
    at clojure.lang.RT.classForName(RT.java:2039)
    at clojure.core$the_class.invoke(genclass.clj:99)
    at clojure.core$map$fn__4087.invoke(core.clj:2432)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:473)
    at clojure.lang.RT.countFrom(RT.java:526)
    at clojure.lang.RT.count(RT.java:519)
    at clojure.core$generate_class$to_types__5402.invoke(genclass.clj:131)
    at clojure.core$generate_class.invoke(genclass.clj:293)
    at clojure.core$gen_class.doInvoke(genclass.clj:622)
    at clojure.lang.RestFn.invoke(RestFn.java:1557)
    at clojure.lang.Var.invoke(Var.java:477)
    at clojure.lang.AFn.applyToHelper(AFn.java:277)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.lang.Compiler.macroexpand1(Compiler.java:6366)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6441)
    ... 45 more
Compilation failed: Subprocess failed

The problem seems to be that i am using  a class that doesn't exist yet.
If i comment all lines referring to test-gen.Tata; compile; uncommment 
those lines; compile; again then it works. 
Is there a way a better to compile self referring class ?

Regards

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to