-
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
platformclasspath
is incorrectly based on --tool_java_runtime_version
#19537
Comments
CC @hvadehra |
Looking into https://github.com/openjdk/jdk/blob/8dfde28b289cbb53173f0ab759156088bbaf74f1/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java#L886, it seems that |
Nice find. I can reproduce running DumpPlatformClassPath standalone:
It is not clear to me that the way we're relying on I think there is a more direct way to implement that logic using the JRT filesystem instead of going through the filemanager to get the classes: bazelbuild/rules_java#131 |
I observed that as well, but it looked like it was still being passed on the command line (in addition to |
Yes, they're both currently passed as inputs corresponding to javac's I'm not sure how to figure out which one to pass without doing javac option parsing in the rule logic. It'd be nice to avoid that complexity, but I guess it's something we could consider if avoiding the input would be a big improvement. All of this will some day go away when we stop supporting JDK 8, but that will be a while. WDYT, do you have any better ideas? |
That got merged as bazelbuild/rules_java@325a9e1 |
Thanks for the explanation, I don't. But once this particular bug is fixed, I agree that it shouldn't really matter anymore to have the bootstrap classpath as an input.
We need this functionality as well (transitively, because the tools we provide need to be compatible with Java 8), so I won't complain.
Thanks for the quick fix! Happy to add some tests when this is picked up by Bazel. Currently, it is possible to compile and run a However, I checked that at least |
That workaround is not guaranteed to be safe in general. I dug up some of the history, inside Google we have at least one tool that relies on For Bazel we could try removing the workaround and see if there are still any affected use-cases. The newer class file versions will only show up in But otherwise, you're right that it will likely cause problems eventually as the JDK APIs depend on newer language features, and if tools relying on |
This was fixed by a recent rules_java update in Bazel. |
Description of the bug:
The contents of the
platformclasspath.jar
seem to depend on the Java runtime specified via--tool_java_runtime_version
, not the one specified via--java_runtime_version
(as long as--java_runtime_version
specifies a version >= 9). This is incorrect as the latter controls the runtime environment for regular Java targets built in the Java configuration.As a result, Java cross-compilation for the specified Java runtime can succeed even though the target will fail at runtime.
Which category does this issue belong to?
Team-Java
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Invalid
platformclasspath.jar
contents:USE_BAZEL_VERSION=500967715d64874b384e9a4c43d96ed6531c0f77 bazel build @rules_java//toolchains:platformclasspath --java_runtime_version=remotejdk_20
.java/util/HexFormat.class
, which was added in Java 17.USE_BAZEL_VERSION=500967715d64874b384e9a4c43d96ed6531c0f77 bazel build @rules_java//toolchains:platformclasspath --java_runtime_version=remotejdk_20 --tool_java_runtime_version=remotejdk_20
.java/util/HexFormat.class
.Cross-compilation only failing at runtime:
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?dev (last_green)
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
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
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: