clojure-emacs / refactor-nrepl

nREPL middleware to support refactorings in an editor agnostic way
Eclipse Public License 1.0
257 stars 69 forks source link

Spurious compilation warning printed when using Clojure's "sources" .jar #290

Closed vemv closed 3 years ago

vemv commented 3 years ago

Brief

If a .jar such as [org.clojure/clojure "1.10.1" :classifier "sources"] is in the classpath, the presence of the refactor-nrepl Lein plugin will cause the following spurious warning to be printed:

/Users/vemv/.m2/repository/org/clojure/clojure/1.10/clojure-1.10-sources.jar(clojure/asm/SymbolTable.java):49: error: cannot access Symbol
  private static class Entry extends Symbol {
                                     ^
  bad source file: /Users/vemv/.m2/repository/org/clojure/clojure/1.10/clojure-1.10-sources.jar(clojure/asm/Symbol.java)
    file does not contain class clojure.asm.Symbol
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.

which it's quite a distraction and can leave people wondering if something's actually wrong.

I've only experienced the issue with org.clojure/clojure artifacts (I've tried hundreds of other Java "sources" - they cause no warnings)

Repro

/Users/vemv/.m2/repository/org/clojure/clojure/1.10/clojure-1.10-sources.jar(clojure/asm/SymbolTable.java):49: error: cannot access Symbol
  private static class Entry extends Symbol {
                                     ^
  bad source file: /Users/vemv/.m2/repository/org/clojure/clojure/1.10/clojure-1.10-sources.jar(clojure/asm/Symbol.java)
    file does not contain class clojure.asm.Symbol
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.

Why is it a spurious warning

Because only refactor-nrepl finds that specific warning in that file. If I:

...the dir will be successfully compiled, without printing the problematic warning.

Env

Lein 2.9.5 JDK8 refactor-nrepl @ master (dbafd6e686402dc020d7026e21ee556812fc51da)

vemv commented 3 years ago

I found out that this is a side-effect of requireing orchard.java:

image

Looks like the following is the culprit? https://github.com/clojure-emacs/orchard/blob/f8a85feb613501be0896c3683c8ff7b0bd404061/src/orchard/java.clj#L400-L403

expez commented 3 years ago

Maybe we can wrap body of that future in with-out-str, or something, to redirect the printing that goes to the console. Looks to me like the 'error' itself is safe to ignore.

Does that sound like a plausible solution?

vemv commented 3 years ago

Hi Lars!

Yes, I gave it a shot earlier and that's what I would have done myself. It appears the silencing must be done via System/out / System/err manipulation though (as opposed to *out*, *err*): https://stackoverflow.com/a/4799195

(I'd simply PR this, but I can't these days ⚖️)

vemv commented 3 years ago

@bbatsov : as mentioned over slack, this issue seems best moved to Orchard