Android `ResourceShrinker` fails with `IllegalAccessError` on JDK 17
Maintainers usually reply within 6 days
Nobody has claimed this yet.
- #178 by @arunkumar9t2 — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- build-system, mobile
Research direction
Start in src/tools/android/java/com/google/devtools/build/android/BUILD.tools at the ResourceProcessorBusyBox definition and inspect its jvm_flags. Reproduce with an android_binary using shrink_resources=1 and Java 17, then verify the build completes without the ResourceShrinker IllegalAccessError on the reported Bazel 7.0.2 setup.
Written by the indexing model from the issue text.
Description
Description of the bug:
When switching our Android builds from JDK 11 to JDK 17, we get the following error when building android_binary targets with resource shrinking enabled:
ERROR: /Users/spotify-buildagent/buildAgent/work/dci-wd/android/client-android/src/main/java/com/spotify/app/music/app/BUILD.bazel:41:12: Shrinking resources for //src/main/java/com/spotify/app/music/app:app failed: (Exit 1): ResourceProcessorBusyBox failed: error executing ResourceShrinker command (from target //src/main/java/com/spotify/app/music/app:app)
ate/var/tmp/_bazel_spotify-buildagent/985b781559c7830232d18af8d0be54d9/sandbox/darwin-sandbox/51832/execroot/client_android && \
exec env - \
BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN='' \
PATH=/bin:/usr/bin:/usr/local/bin \
bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox @bazel-out/darwin_arm64-opt/bin/src/main/java/com/spotify/app/music/app/app_shrunk.ap_-0.params)
# Configuration: 90658d1367aa8bc9900aca7af82ba46f945ae0750452ba93c59ddba269cacbf4
# Execution platform: @@local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Exception in thread "main" java.lang.IllegalAccessError: superclass access check failed: class com.google.devtools.build.android.aapt2.ProtoResourceUsageAnalyzer$1 (in unnamed module @0x300ffa5d) cannot access class com.sun.org.apache.xerces.internal.dom.AttrImpl (in module java.xml) because module java.xml does not export com.sun.org.apache.xerces.internal.dom to unnamed module @0x300ffa5d
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at com.google.devtools.build.android.aapt2.ProtoResourceUsageAnalyzer.createSimpleAttr(ProtoResourceUsageAnalyzer.java:381)
at com.google.devtools.build.android.aapt2.ProtoResourceUsageAnalyzer.lambda$shrink$4(ProtoResourceUsageAnalyzer.java:152)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at com.google.devtools.build.android.aapt2.ProtoResourceUsageAnalyzer.shrink(ProtoResourceUsageAnalyzer.java:153)
at com.google.devtools.build.android.ResourcesZip.shrinkUsingProto(ResourcesZip.java:237)
at com.google.devtools.build.android.Aapt2ResourceShrinkingAction.main(Aapt2ResourceShrinkingAction.java:78)
at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$9.call(ResourceProcessorBusyBox.java:118)
at com.google.devtools.build.android.ResourceProcessorBusyBox.processRequest(ResourceProcessorBusyBox.java:237)
at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:184)
The issue can be fixed by adding
--add-exports=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED"
to jvm_flags of ResourceProcessorBusyBox in src/tools/android/java/com/google/devtools/build/android/BUILD.tools.
Which category does this issue belong to?
Android
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
In short, build an android_binary with shrink_resources set to 1 and java_runtime_version / --tool_java_runtime_version set to 17. I can provide an example if needed.
Which operating system are you running Bazel on?
MacOS 13.6.4
What is the output of bazel info release?
release 7.0.2-24a18ed
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
We have a custom built version of the Bazel binary with close to 20 patches on top of 7.0.2, most of which are related to Android builds.
What's the output of git remote get-url origin; 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
- Dominant language
- Java
- Stars
- 205
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bazelbuild/rules_android
-
build_java8_legacy_dex.sh does not set JAVA_RUNFILES for the d8/r8 launchersPossibly taken @TrapsterDK claimed this 17 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bazelbuild/rules_android#599 ·
Maintainers usually reply within 6 days
-
`Desugar` actions don't run on multiplex workersPossibly taken @lukaciko claimed this 46 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bazelbuild/rules_android#539 · 2 comments ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bazelbuild/rules_android#535 · 2 reactions ·
Maintainers usually reply within 6 days
-
desugar_globals output is not reproducible (zip entry order varies)Possibly taken @TrapsterDK claimed this 6 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
bazelbuild/rules_android#610 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
bazelbuild/rules_android#602 ·
Maintainers usually reply within 6 days
All issues in bazelbuild/rules_android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Lincoln-cn/JAiRouter#1473 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
exercism/java-analyzer#379 ·
-
area: ui bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
tetsuji16/microProject#1893 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
liberation-data/fornax4j#325 ·
Maintainers usually reply within 1 day
-
[Bug]: FE and Kinesis extraction pipes render flow starting at the centre and scroll the source arm backwardsPossibly taken @chonkzillaofficial claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
BCCE-team/BuildCraft#85 ·