Open kumarshantanu opened 10 years ago
While at it, I suggest you make separate switches for reflection warnings in repl and compilation if this is feasible. e.g. :warn-on-reflection true ;; both are true :warn-on-reflection {:when-compiling true :in-repl false} or soimething like that.
@akaranta The implementation seems to be alright as per this: http://clojureclr.blogspot.in/2012/01/compiling-and-loading-in-clojureclr.html -- do you have a public project where I can see why it's failing? For different behavior during compilation and REPL, Leiningen profiles should be useful, for example:
:profiles {:cc {:clr {:warn-on-reflection true}}
:cr {:clr {:warn-on-reflection false}}}
alternatively,
:profiles {:cc {:warn-on-reflection true}
:cr {:warn-on-reflection false}}
C:\work>lein with-profile cc clr compile
C:\work>lein with-profile cr clr repl
Unfortunately I don't have anything public you could use. But that does not matter - the problem is easily demonstrable by creating a new lein clr project and then compiling / starting repl on that. I just rechecked this on a fresh project where I inserted :warn-on-reflection false in the hash under the :clr key.
Do e.g. this in repl
(def e (Exception. "foo")) (.Message e)
and you will get a reflection warning printed.
The only changes I did was to change the clojure clr to be fetched as a dependency and to use the latest version thereof.
If you wish I can send you the project file.
I tried to reproduce this error but am not able to. One pitfall you might want to watch out for is -- when you run lein new lein-clr foo
to create the project, the project.clj
file is already populated (on line number 7) with :warn-on-reflection true
. Make sure to edit that value, or comment that out if you add an entry later.
If the above does not impact you, please share your project.clj
here or by email (mentioned here).
You were right, I had changed the :warn-on-reflection key under the :clr hash. However, when I try to set it to false in defproject I get
Unhandled Exception: clojure.lang.Compiler+CompilerException: System.InvalidOperationException: Unab le to resolve symbol: -r in this context at clojure.lang.Compiler.ResolveIn(Namespace n, Symbol symbol, Boolean allowPrivate) in d:\work\c lojure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 416 at clojure.lang.Compiler.AnalyzeSymbol(Symbol symbol) in d:\work\clojure-clr\Clojure\Clojure\CljC ompiler\Compiler.cs:line 1710 at clojure.lang.Compiler.Analyze(ParserContext pcontext, Object form, String name) in d:\work\clo jure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 1633, compiling: (NO_SOURCE_PATH:0:0) ---> Sys tem.InvalidOperationException: Unable to resolve symbol: -r in this context at clojure.lang.Compiler.ResolveIn(Namespace n, Symbol symbol, Boolean allowPrivate) in d:\work\c lojure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 416 at clojure.lang.Compiler.AnalyzeSymbol(Symbol symbol) in d:\work\clojure-clr\Clojure\Clojure\CljC ompiler\Compiler.cs:line 1710 at clojure.lang.Compiler.Analyze(ParserContext pcontext, Object form, String name) in d:\work\clo jure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 1633 --- End of inner exception stack trace --- at clojure.lang.Compiler.Analyze(ParserContext pcontext, Object form, String name) in d:\work\clo jure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 1665 at clojure.lang.Compiler.eval(Object form) in d:\work\clojure-clr\Clojure\Clojure\CljCompiler\Com piler.cs:line 911 at clojure/main$eval_opt21467.invoke(Object ) at clojure/main$initialize21485.invoke(Object , Object ) at clojure/main$null_opt21531.invoke(Object , Object ) at clojure/main$main21569.doInvoke(Object ) at clojure.lang.AFn.ApplyToHelper(IFn fn, ISeq argList) in d:\work\clojure-clr\Clojure\Clojure\Li b\AFn.cs:line 202 at Clojure.CljMain.Main(String[] args) in d:\work\clojure-clr\Clojure\Clojure.Main\Main.cs:line 34
I attached the project file.
::Antti::
@akaranta I did not receive the project.clj
file. Could you please email that to me separately?
Hi,
Ok, here is the project.clj file again. I'll copy paste it inline, too, in case there is some problem with attachments. Here:
(defproject foo "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [] :warn-on-reflection false :min-lein-version "2.0.0" :plugins [[lein-clr "0.2.1"]] :clr {:cmd-templates { ;;:clj-exe [[?PATH "mono"] [CLJCLR14_40 %1]] :clj-dep [[?PATH "mono"] ["target/clr/clj/Release" %1]] :clj-url " http://sourceforge.net/projects/clojureclr/files/clojure-clr-1.5.0-Release-4.0.zip/download " :clj-zip "clojure-clr-1.5.0-Release-4.0.zip" :curl ["curl" "--insecure" "-f" "-L" "-o" %1 %2] :nuget-ver [[?PATH "mono"] [PATH "nuget.exe"] "install" %1 "-Version" %2] :nuget-any [[?PATH "mono"] [PATH "nuget.exe"] "install" %1] :unzip ["unzip" "-d" %1 %2] :wget ["wget" "--no-check-certificate" "--no-clobber" "-O" %1 %2]} :warn-on-reflection false ;; for automatic download/unzip of ClojureCLR, ;; 1. make sure you have curl or wget installed and on PATH, ;; 2. uncomment deps in :deps-cmds, and ;; 3. use :clj-dep instead of :clj-exe in :main-cmd and :compile-cmd :deps-cmds [ [:wget :clj-zip :clj-url] ; edit to use :curl instead of :wget [:unzip "../clj" :clj-zip] ] :main-cmd [:clj-dep "Clojure.Main.exe"] :compile-cmd [:clj-dep "Clojure.Compile.exe"]})
Reported here: https://groups.google.com/forum/#!topic/clojure-clr/P98TZFSujb8
Also,
sample.project.clj
has no mention of:warn-on-reflection
and:unchecked-math
.