Unfriendly Java cast expection when *compile-path* is set incorrectly

Description

When compile-path is not set to a String but to a java.io.File (that's what boot-clj does at the moment). You get a Cast exception in the compiler when trying to use it from the boot repl. Common wisdom seems to be to not compile from the repl, people say don't use gen-class. I find this unfortunate for when you do want to use gen-class and iterate quickly.

I haven't tested all older versions for this issue, but git blame shows that the code that should help here wasn't changed for 10 years:
https://github.com/clojure/clojure/blame/master/src/clj/clojure/core.clj#L6073
https://github.com/clojure/clojure/blame/master/src/jvm/clojure/lang/Compiler.java#L7643

My workaround now is:

I suggest to put the type check in the 'clojure.core/compile function.

Environment

Mac OS, boot-clj

Activity

Show:
Jeroen van Dijk
October 4, 2018, 8:13 PM
Jeroen van Dijk
October 4, 2018, 10:01 PM

The following works in boot-clj (because of classpath issues not in Leiningen and clj cli): https://gist.github.com/jeroenvandijk/8187413d24433545eeb9579538a903f7#file-repl_compile-clj-L39-L52

Alex Miller
October 5, 2018, 5:13 AM

Can you provide a reproducible example?

Seems like ClassCastException is pretty accurate for having a class of the wrong type.

Jeroen van Dijk
October 5, 2018, 7:12 PM

I've tried to make the example as simple as possible. You are right that the ClassCastException is perfectly accurate, but you realise this only after you have figured out it's about compile-path. This bug report is mostly about managing expectations (of the clojure user).

Assignee

Unassigned

Reporter

Jeroen van Dijk

Labels

Approval

None

Patch

None

Priority

Minor