-
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 record components are not exposed to annotation processors during header JAR compilation #23246
Comments
I have an initial fix that I verified against the original repro (using the steps in bazelbuild/java_tools#43 (comment), if anyone knows a better way to have tested that I'm all ears):
One complication is that the easiest way to support those APIs in turbine is to raise the minimum supported JDK version to JDK 17. I'm not sure if that's fine at this point, or if that will mean using older versions of turbine in some configurations. |
Since this would only affect the JDK used for compilation, I wouldn't consider this a problem. But if you have concerns, I could work out the diff required to keep Turbine compatible with Java 8. |
Thanks, I don't have a current sense of which JDK versions people are relying on for compilation, I will try raising the min JDK for turbine and see how that goes. If it came to it, one option would be to create a Java 8-compatible branch of turbine and then backport any essential bug fixes to it. Most of the recent changes have been related to newer language features, I don't think many changes will be required for Java 8 support. |
https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/lang/model/element/TypeElement.html#getRecordComponents() See bazelbuild/bazel#23246 Startblock: * unknown commit is submitted PiperOrigin-RevId: 661267054
https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/lang/model/element/TypeElement.html#getRecordComponents() See bazelbuild/bazel#23246 Startblock: * unknown commit is submitted PiperOrigin-RevId: 661267054
https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/lang/model/element/TypeElement.html#getRecordComponents() See bazelbuild/bazel#23246 Startblock: * unknown commit is submitted PiperOrigin-RevId: 661267054
https://docs.oracle.com/en/java/javase/17/docs/api/java.compiler/javax/lang/model/element/TypeElement.html#getRecordComponents() See bazelbuild/bazel#23246 Startblock: * unknown commit is submitted PiperOrigin-RevId: 667702947
https://github.com/google/turbine/releases/tag/v0.7.0 ``` REPIN=1 bazelisk run @unpinned_maven//:pin && bazelisk mod deps --lockfile_mode=update ``` #23246 Closes #23430. PiperOrigin-RevId: 667834396 Change-Id: I7f620651870e1ac055654ec5000e942b48875d15
@cushon Is there anything else we need for this issue? |
I don't think so, I also took a pass over other recently added annotation processing APIs and made a couple of other fixes that didn't make it into 0.7.0, but that's distinct from |
Description of the bug:
record-builder, an annotation processor that generates code for Java records, produces incorrect output when it runs in the processing environment Bazel uses to generate header JARs. For example, the API for a record's generated builder in a header JAR will be missing all methods related to the source record's components.
The processing environment used to generate header JARs seems to be Turbine 0.6.0 in the latest version of Bazel (7.2.1). Record Builder uses TypeElement.getRecordComponents() to access record components, but Turbine returns an empty list from this method (because it does not implement it). Record Builder also uses RecordComponentElement to read annotations on the record component's accessor, but Turbine does not seem to be able to return this type.
Which category does this issue belong to?
Java Rules
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Modifying the java-maven example:
Then running:
Produces error:
Which operating system are you running Bazel on?
macOS 14.5 (23F79)
What is the output of
bazel info release
?release 7.2.1
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 HEAD
?No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: