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

JavaResourceJar broken when enabling path mapping (--experimental_output_paths=strip) #23286

Closed
malt3 opened this issue Aug 13, 2024 · 1 comment
Labels
team-Rules-Java Issues for Java rules type: bug

Comments

@malt3
Copy link
Contributor

malt3 commented Aug 13, 2024

Description of the bug:

Without path mapping, a java_library with no srcs but resources would result in an action with mnemonic JavaResourceJar.
When enabling path mapping, the build fails:

bazel build :foo -s
INFO: Analyzed target //:foo (0 packages loaded, 0 targets configured).
SUBCOMMAND: # //:foo [action 'Building libfoo-class.jar ()', configuration: 79f4dcc0afed0cf3698fedd0369bedac590bfd9d6152eefc68c5e3060c12cef4, execution platform: @@platforms//host:host, mnemonic: Javac]
(cd /REDACTED/execroot/_main && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
  external/rules_java~~toolchains~remotejdk21_linux/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' '-Dsun.io.useCanonCaches=false' -XX:-CompactStrings -Xlog:disable '-Xlog:all=warning:stderr:uptime,level,tags' -jar external/rules_java~~toolchains~remote_java_tools/java_tools/JavaBuilder_deploy.jar @bazel-out/cfg/bin/libfoo-class.jar-0.params @bazel-out/cfg/bin/libfoo-class.jar-1.params)
# Configuration: 79f4dcc0afed0cf3698fedd0369bedac590bfd9d6152eefc68c5e3060c12cef4
# Execution platform: @@platforms//host:host
ERROR: /REDACTED/BUILD:149:13: output 'libfoo-class.jar' was not created
ERROR: /REDACTED/BUILD:149:13: output 'libfoo-native-header.jar' was not created
ERROR: /REDACTED/BUILD:149:13: output 'libfoo.jar_manifest_proto' was not created
ERROR: /REDACTED/BUILD:149:13: Building libfoo-class.jar () failed: not all outputs were created or valid
Target //:foo failed to build

Without path mapping, this is the output:

bazel build :foo -s
INFO: Analyzed target //:foo (0 packages loaded, 6212 targets configured).
SUBCOMMAND: # @@rules_java~//toolchains:platformclasspath [action 'JavaToolchainCompileClasses external/rules_java~/toolchains/platformclasspath_classes', configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37, execution platform: @@platforms//host:host, mnemonic: JavaToolchainCompileClasses]
(cd /REDACTED/execroot/_main && \
  exec env - \
  external/rules_java~~toolchains~remotejdk11_linux/bin/javac -source 8 -target 8 -Xlint:-options -J-XX:-UsePerfData -d bazel-out/k8-dbg/bin/external/rules_java~/toolchains/platformclasspath_classes external/rules_java~/toolchains/DumpPlatformClassPath.java)
# Configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37
# Execution platform: @@platforms//host:host
SUBCOMMAND: # @@rules_java~//toolchains:platformclasspath [action 'JavaToolchainCompileBootClasspath external/rules_java~/toolchains/platformclasspath.jar', configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37, execution platform: @@platforms//host:host, mnemonic: JavaToolchainCompileBootClasspath]
(cd /REDACTED/execroot/_main && \
  exec env - \
  external/rules_java~~toolchains~remotejdk11_linux/bin/java -XX:+IgnoreUnrecognizedVMOptions -XX:-UsePerfData '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' -cp bazel-out/k8-dbg/bin/external/rules_java~/toolchains/platformclasspath_classes DumpPlatformClassPath bazel-out/k8-dbg/bin/external/rules_java~/toolchains/platformclasspath.jar external/rules_java~~toolchains~local_jdk)
# Configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37
# Execution platform: @@platforms//host:host
SUBCOMMAND: # //:foo [action 'Building libfoo-class.jar ()', configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37, execution platform: @@platforms//host:host, mnemonic: Javac]
(cd /REDACTED/execroot/_main && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
  external/rules_java~~toolchains~remotejdk21_linux/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' '-Dsun.io.useCanonCaches=false' -XX:-CompactStrings -Xlog:disable '-Xlog:all=warning:stderr:uptime,level,tags' -jar external/rules_java~~toolchains~remote_java_tools/java_tools/JavaBuilder_deploy.jar @bazel-out/k8-dbg/bin/libfoo-class.jar-0.params @bazel-out/k8-dbg/bin/libfoo-class.jar-1.params)
# Configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37
# Execution platform: @@platforms//host:host
SUBCOMMAND: # //:foo [action 'Building Java resource jar', configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37, execution platform: @@platforms//host:host, mnemonic: JavaResourceJar]
(cd /REDACTED/execroot/_main && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
  external/rules_java~~toolchains~remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local --normalize --dont_change_compression --exclude_build_data --output bazel-out/k8-dbg/bin/libfoo.jar --sources bazel-out/k8-dbg/bin/libfoo-class.jar --resources file.txt)
# Configuration: a39759fe87cfd0cdf3036e15136e0419b560858bafad55049fd08d2252aa2b37
# Execution platform: @@platforms//host:host
INFO: Found 1 target...
Target //:foo up-to-date:
  bazel-bin/libfoo.jar
INFO: Elapsed time: 2.742s, Critical Path: 1.98s
INFO: 5 processes: 1 internal, 3 linux-sandbox, 1 worker.
INFO: Build completed successfully, 5 total actions

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.

BUILD.bazel:

java_library(
  name = "foo",
  resources = ["file.txt"],
)

file.txt:

this is a test

.bazelrc:

common --experimental_output_paths=strip

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 7.3.0

If bazel info release returns development 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 ?

n/a

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

This was most likely introduced with Bazel 7 (in this PR #18098, commit 29f1db2)

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@malt3
Copy link
Contributor Author

malt3 commented Aug 13, 2024

I since learned that it works using --strategy=Javac=sandboxed, so this is likely just an error on my side.

The document about the state of path mapping also has this sentence:

the default Java toolchain doesn't enable support for multiplex sandboxing yet

So I guess this works as intended.

@malt3 malt3 closed this as completed Aug 13, 2024
@malt3 malt3 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-Java Issues for Java rules type: bug
Projects
None yet
Development

No branches or pull requests

5 participants