Fork me on GitHub

Is there a workaround for conflicts with clojure-required java classes? I’m trying to run:

(import '( Runtime))
But I get the error:
Runtime already refers to: class java.lang.Runtime


(ns-unmap *ns* 'Runtime)

(import '( Runtime))


Works, thanks. Is there anyway to do that as a part of the ns declaration?


don't think so... there's refer-clojure which is only vaguely related. doesn't work for that

Alex Miller (Clojure team)01:07:05

Or just use the fully qualified class name

👍 8
Alex Miller (Clojure team)01:07:15

You don’t have to import


How does one file a ticket in JIRA? It seems that I need some kind of auth


is it possible to make the compiler explicit about which file is buggy by printing the full filepath instead of only the name?

Alex Miller (Clojure team)19:07:50

I actually made a change in this area for 1.10.1 - are you on 1.10.0 or 1.10.1?


I am using 1.10.1, and in stack traces of exceptions I see file names with no directory path leading to them. Are the improvements you are referring to related to printing the fully-namespace-qualified symbol name of the function, or something else?

Alex Miller (Clojure team)00:07:32

I’m talking about the location in the message itself (but it depends some on the source of the exception)

Alex Miller (Clojure team)00:07:42

The particular example above actually must be 1.10.0 as this is a clojure.main failure and should dump to a file

Alex Miller (Clojure team)00:07:19

The stack trace is never full, as that’s in the stack line print


That would be nice -- I suspect it is a JVM limitation somewhere, never looked into the root cause of why a longer path is not shown.


@alexmiller well then I guess I did (wasn't sure if this was the right way)


@i From the class included with most StackTraceElement objects in a stack trace, you can use various Java method calls to try to find the full path to a compiled .class file (if there is one) or a .clj source file, but note that there might be both a ".class" and a ".clj" file in the set of available JVM resources, and nothing in the StackTraceElement can tell you for sure which -- only way I know is to try a few JVM .getResource method calls with a few different names to check what is available. The path name of the .class file need not have any correspondence with a Clojure source file, but often they will be correlated because of the way people typically create the directory structure of their Clojure files.


This code seems to work if there is a .class file, but finds no resource if there is no .class file -- you could make straightforward additions to this code to look for a .clj file if there was no .class file, or whatever order you wanted to try looking for them:

(defn class-info [classname-str]
  (let [klass (Class/forName classname-str)
        loader (.getClassLoader klass)
        resource-name (str (clojure.string/replace classname-str "." "/")
        rsrc (.getResource loader resource-name)]
    {:klass klass :loader loader :resource-name resource-name
     :resource rsrc}))


there's a lot of fancy code in cider which attempts to do this


or rather, there's code


hi everyone. I’m trying to find the syntax that lets you use 2 + 2 instead of (+ 2 2). can someone remind me pls


yeah, that’s what I was looking for! thank you @deleted-user 🙂


I didn’t remember there was actually a repo for this


for some reason I remembered that it was built in