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

Go To Type Definition opens .class instead of .java #93

Closed
vorburger opened this issue Feb 9, 2024 · 5 comments
Closed

Go To Type Definition opens .class instead of .java #93

vorburger opened this issue Feb 9, 2024 · 5 comments

Comments

@vorburger
Copy link
Contributor

In https://github.com/enola-dev/enola/, when I Go To Type Definition e.g. in some **/src/test/java/**/*.java editor on a "symbol" that is something in the src/main (instead of /test) of the same module/project/whatever, then instead of .java it opens some read-only .class (read-only, but not decompiled; it's the correct source text).

I'm not sure how to describe this more accurately - let me know if some... screenshots (?), or something, would help to clarify.

@guw

@vorburger
Copy link
Contributor Author

Hm, this strangely only seems to happen in some cases, and I haven't found out the correlation why, yet:

For example, when common/common/src/test/java/dev/enola/common/io/resource/ClasspathUrlResourceTest.java is open and I F12 on that UrlResource in line 44, then it correctly opens common/common/src/main/java/dev/enola/common/io/resource/UrlResource.java.

However when I'm in core/impl/src/test/java/dev/enola/core/meta/TypeRepositoryTest.java (which is not yet on the main branch as of writing this, but will eventually be merged in, from enola-dev/enola#451) and Ctrl-Click on the TypeRepositoryBuilder, then instead of core/impl/src/main/java/dev/enola/core/type/TypeRepositoryBuilder.java, it opens a TypeRepositoryBuilder.class from somewhere... check out this screenshot:

Screenshot from 2024-02-09 15-33-55

so apparently, in some cases, it doesn't set up the Inter-Project Dependency in the underlying JDT correctly?

Looks like for the this ^^^ case it references this libimpl-ijar.jar, whereas in the case where it works it "does the right thing", and jumps into the project, instead of opening a class from (in that case) libcommon-ijar.jar.

The BUILD for those 2 modules look very similar though... it's a [java_test( with a "simple" deps = [":common", respectively deps = [ ":impl",.

Strange.

@vorburger
Copy link
Contributor Author

What makes this more annoying than simply Navigating is that when one makes changes (like adds new methods, or whatever) to code under test in main/java code, they are not "visible" (red) in test/java, until a full rebuild - that's quite a PITA.

@guw
Copy link
Collaborator

guw commented Feb 15, 2024

@vorburger I tried to reproduce but I ran into an issue:

ERROR: .../enola/tools/hello/BUILD:29:13: Compiling Java headers tools/hello/libhello_lib-hjar.jar (1 source file) failed: (Exit 1): java failed: error executing Turbine command (from target //tools/hello:hello_lib) external/local_jdk/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 47 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
tools/hello/src/main/java/dev/enola/common/hello/Library.java:27: error: unexpected input: {
        return STR."hello, \{planet}";
                            ^

and

enola/web/ui/BUILD:19:13: Compiling Java headers web/ui/libui-hjar.jar (2 source files) failed: (Exit 1): java failed: error executing Turbine command (from target //web/ui:ui) external/local_jdk/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 60 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
<>:1: error: unexpected input: {
<a href="/TODO">\{
                 ^

@vorburger
Copy link
Contributor Author

vorburger commented Feb 15, 2024

@vorburger I tried to reproduce but I ran into an issue:

See enola-dev/enola#452, but...

... even if you are on a commit from before that fix, you should never see this.

Could this be due to some Bazel/ Bazelisk version discrepancy between us? E.g. related to #88?

Having said that... I (now) can no longer reproduce this problem (the originally reported one) myself - huh?!

Unless you are interested in digging more, let's close this? I'll comment when (if) I see it again, hopefully then with a clear(er) reproducer.

@guw
Copy link
Collaborator

guw commented Feb 18, 2024

Going to the .class usually happens when the .java source is not properly set up as project. It can also happen if there is a bug in classpath resolution and Bazel Eclipse fails to resolve a jar dependency to an Eclipse project. Please re-open when you have such a case.

@guw guw closed this as completed Feb 18, 2024
@guw guw closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants