Prevent DexFileSplitter from dropping colliding class names - #548
Open
oscarthecat wants to merge 1 commit into
Open
Prevent DexFileSplitter from dropping colliding class names#548oscarthecat wants to merge 1 commit into
oscarthecat wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Fall back to the original class names when lossy dx-style normalization produces an equal result, so TreeMap does not drop distinct entries.
oscarthecat
force-pushed
the
fix/dex-splitter-class-name-collision
branch
from
August 21, 2026 10:01
ae0903e to
140e6c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DexFileSplitterstores input entries in aTreeMapusingZipEntryComparator::compareClassNames, then inserts them withputIfAbsent. The comparator replaces$with0before comparing names.When generated nested class names include entries such as
Foo$2$1$1.class.dexandFoo$2$101.class.dex, both normalize to the same value. The comparator therefore returns zero, theTreeMaptreats the distinct classes as the same key, andputIfAbsentsilently drops one. The resulting APK can fail at runtime withNoClassDefFoundErrorfor the missing class.Change
Keep the existing dx-style normalized ordering. When two normalized names compare equal, fall back to comparing the original names so distinct entries remain distinct. No ordering changes for names whose normalized forms differ.
Add regression coverage that inserts the colliding names into the same
TreeMapshape used byDexFileSplitterand verifies that both remain present.Testing
javacregression check against the modifiedZipEntryComparator.DexFileSplitterTest.bazel test //src/tools/javatests/com/google/devtools/build/android/dexer:AllTests --test_output=errors; repository analysis could not complete locally because connections tomaven.google.comtimed out before compilation or test execution.