Fork me on GitHub
#clojure
<
2019-07-14
>
tyler00:07:31

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

(import '(software.amazon.awscdk.services.lambda Runtime))
But I get the error:
Runtime already refers to: class java.lang.Runtime

vemv00:07:22

(ns-unmap *ns* 'Runtime)

(import '(software.amazon.awscdk.services.lambda Runtime))

tyler00:07:13

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

vemv00:07:11

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

g7s06:07:08

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

pinkfrog15:07:59

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?

andy.fingerhut23:07:52

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

andy.fingerhut16:07:53

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.

g7s16:07:39

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

andy.fingerhut18:07:37

@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.

andy.fingerhut18:07:40

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 "." "/")
                           ".class")
        rsrc (.getResource loader resource-name)]
    {:klass klass :loader loader :resource-name resource-name
     :resource rsrc}))

dominicm15:07:03

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

dominicm15:07:10

or rather, there's code

Bravi20:07:15

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

Bravi21:07:39

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

Bravi21:07:46

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

Bravi21:07:54

for some reason I remembered that it was built in