Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cider-find-var doesn't work for all java classes #1666

Closed
expez opened this issue Apr 12, 2016 · 24 comments
Closed

cider-find-var doesn't work for all java classes #1666

expez opened this issue Apr 12, 2016 · 24 comments

Comments

@expez
Copy link
Member

expez commented Apr 12, 2016

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  compare-strings("*" nil nil nil 0 1 nil)
  string-prefix-p("*" nil)
  cider--jump-to-loc-from-info((dict "status" ("done") "class" "org.joda.time.Period" "id" "2535" "interfaces" ("org.joda.time.ReadablePeriod" "java.io.Serializable") "javadoc" "org/joda/time/Period.html" "modifiers" "#{:public :final}" "name" "Period" "package" "org.joda.time" "session" "450c9c46-a161-4bda-9ad8-e961666d6a52" "super" "org.joda.time.base.BasePeriod"))
  cider--find-var("org.joda.time.Period")
  cider-read-symbol-name("Symbol" cider--find-var)
  cider-find-var(nil)
  call-interactively(cider-find-var nil nil)
  command-execute(cider-find-var)

Not entirely sure what's special with Period. Jumping to e.g. java.lang.Exception works fine. Perhaps it's that it's in a jar.

;; Connected to nREPL server - nrepl://localhost:51749
;; CIDER 0.12.0snapshot (package: 20160410.2022), nREPL 0.2.12
;; Clojure 1.7.0, Java 1.8.0_66
@expez expez added the bug label Apr 12, 2016
@bbatsov
Copy link
Member

bbatsov commented Apr 12, 2016

Likely the source jar is not on the classpath.

@expez
Copy link
Member Author

expez commented Apr 13, 2016

Likely the source jar is not on the classpath.

This happened with org.joda.time.Period IIRC. Does it not work because that jar is pulled in by clj-time?

@bbatsov
Copy link
Member

bbatsov commented Apr 28, 2016

Probably. It likely pulled just the compiled classes, but you also need the source jar for source lookup to work.

@bbatsov
Copy link
Member

bbatsov commented Apr 28, 2016

Btw, you shouldn't be getting an error, but some message saying the source can't be found. That's odd...

@bbatsov
Copy link
Member

bbatsov commented Apr 28, 2016

I tested this and got a No source location message (as expected). Maybe we can improve this message a bit...

@vspinu
Copy link
Contributor

vspinu commented Sep 10, 2016

Is there a known workaround for this? I have manually built and installed maven project which contains both source and javadoc jars. CIDER cannot locate neither source nor javadoc.

@vspinu
Copy link
Contributor

vspinu commented Sep 10, 2016

Just found a rudimentary workaround by manually adding jar files to lein's :resource-paths.

@bbatsov
Copy link
Member

bbatsov commented Oct 8, 2016

Guess we can close this then. Unless someone wants to contribute some documentation on the subject?

@dpsutton
Copy link
Contributor

dpsutton commented Oct 8, 2016

I'll have to get up to speed but I can do it tomorrow

On Oct 8, 2016 12:25 PM, "Bozhidar Batsov" notifications@github.com wrote:

Guess we can close this then. Unless someone wants to contribute some
documentation on the subject?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1666 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGFPTcAUxsuCmd54yxLRvm52RN-uHxqGks5qx9IUgaJpZM4IFO1w
.

@bbatsov
Copy link
Member

bbatsov commented Oct 8, 2016

@dpsutton Sounds good.

@dpsutton
Copy link
Contributor

dpsutton commented Oct 9, 2016

I've been trying to figure this out. I've built a project mvn install and then referenced it. I got no errors, just info that no documentation was found when trying to view docs. @vspinu can you help shed some light on circumstances that could trigger an error?

@bbatsov
Copy link
Member

bbatsov commented Oct 10, 2016

I think a larger point is that we haven't documented at all how one can add source jars to their lein/boot project.

@expez
Copy link
Member Author

expez commented Oct 19, 2016

@vspinu I tried adding paths to jars in :resource-paths and I still can't jump to the java source nor view its documentation. What did you do?

@vspinu
Copy link
Contributor

vspinu commented Oct 19, 2016

Just that, added full paths to the :resource-paths

  :resource-paths ["/home/vspinu/.m2/repository/com/interactivebrokers/tws-api/9.71.1/tws-api-9.71.1-sources.jar"
                  "/home/vspinu/.m2/repository/com/interactivebrokers/tws-api/9.71.1/tws-api-9.71.1-javadoc.jar"]

Did the trick for me, both for refs and javadocs.

@vspinu
Copy link
Contributor

vspinu commented Oct 19, 2016

Documenting this is just passing the ball to the user. How hard would it be to check for -sources.jar or-javadoc.jar and add them to the classpath dynamically?

@expez
Copy link
Member Author

expez commented Oct 20, 2016

Thanks, the mistake was mine, I added the wrong jar (with only .class files).

It would be easy to check for jars, but where would we check?

@vspinu
Copy link
Contributor

vspinu commented Oct 20, 2016

but where would we check?

In the parent directory of the class jar.

@vspinu
Copy link
Contributor

vspinu commented May 18, 2018

The trick with :resource-path no longer works. Has something changed in the java-ref lookup in the past 7 months or so?

I now see a lot "bad source file" errors like this when I first call cider-find-var:

  bad source file: /home/vspinu/.m2/repository/io/netty/netty-transport/4.1.22.Final/netty-transport-4.1.22.Final-sources.jar(io/netty/channel/ChannelFactory.java)
    file does not contain class io.netty.channel.ChannelFactory
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.

If I check manually I do see an interface ChannelFactory in that java file.

@vspinu
Copy link
Contributor

vspinu commented May 18, 2018

Another simple workaround for this is to use tags instead

## fetch sources and javadocs
lein pom
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

## build tags
mkdir java-sources && cd java-sources
jar -xvf ~/.m2/repository/io/netty/netty-all/4.0.23.Final/netty-all-4.0.23.Final-sources.jar
ctags -eR 

@stale
Copy link

stale bot commented May 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale label May 8, 2019
@bbatsov
Copy link
Member

bbatsov commented May 14, 2019

The trick with :resource-path no longer works. Has something changed in the java-ref lookup in the past 7 months or so?

@jeffvalk is our resident expert here. I don't recall any changes in this area for quite a while until very recently. It still seems to me that the only thing needed for the lookup to work should be for the source artifacts to be on the classpath.

@stale stale bot removed the stale label May 14, 2019
@jeffvalk
Copy link
Contributor

jeffvalk commented May 14, 2019

Is this still an issue? If the source is on the classpath, info should work for java sources. The JDK sources are added to classpath by Orchard. Anything else, the user would need to add in project.clj, etc.

@stale
Copy link

stale bot commented Aug 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale label Aug 20, 2019
@stale
Copy link

stale bot commented Sep 19, 2019

This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.

@stale stale bot closed this as completed Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants