-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Java: Overriding record toString() can't be referred to as a dependency #17181
Comments
Similar (probably related) issue involving extra constructors: MyRecord.java:
ExtraConstructor.java:
Compiling both in a rule works. If
|
…records These methods are only emitted if they don't already exist, per JLS 8.10.3. bazelbuild/bazel#17181 PiperOrigin-RevId: 501571162
…records These methods are only emitted if they don't already exist, per JLS 8.10.3. bazelbuild/bazel#17181 PiperOrigin-RevId: 501618070
Thanks for looking at this @cushon!. Are there more steps needed? I tried building with HEAD bazel and I still see the same error. Any way I can test this locally? |
This will require a java_tools release, I think it's going to be included in bazelbuild/java_tools#60 Until then, testing this requires additional steps: bazelbuild/java_tools#43 |
Thanks, I was indeed looking at the outdated documentation on how to run a local java_tools. Can confirm an updated java_tools fixes the issue in the bug. The related error in my first comment is still there, so opening up a separate issue for that (#17250). |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 30 days. It will be closed in the next 7 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". |
…records These methods are only emitted if they don't already exist, per JLS 8.10.3. bazelbuild/bazel#17181 PiperOrigin-RevId: 501618070
Description of the bug:
The compiler complains about an ambiguous reference when trying to refer to an overriden
toString()
method of arecord
. The error only happens when therecord
class is a dependency, not when it is listed insrcs
.What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Empty
WORKSPACE
. (It also fails when loadingrules_java
5.4.0.bazelrc:
MyRecord.java:
DoubleToString.java:
BUILD.bazel:
Doing a
bazel build :record_to_string_fails
results in the following output:Building
:no_dep_to_string_works
works just fine.Which operating system are you running Bazel on?
Ubuntu 22.04.1 LTS
What is the output of
bazel info release
?release 6.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No
Any other information, logs, or outputs that you want to share?
Ran into this issue when trying to convert a maven project to bazel.
Building with
javac
works, even whenMyRecord.java
is removed after compilingMyRecord.class
.The text was updated successfully, but these errors were encountered: