Skip to content

Prevent DexFileSplitter from dropping colliding class names - #548

Open
oscarthecat wants to merge 1 commit into
bazelbuild:mainfrom
oscarthecat:fix/dex-splitter-class-name-collision
Open

Prevent DexFileSplitter from dropping colliding class names#548
oscarthecat wants to merge 1 commit into
bazelbuild:mainfrom
oscarthecat:fix/dex-splitter-class-name-collision

Conversation

@oscarthecat

Copy link
Copy Markdown

Problem

DexFileSplitter stores input entries in a TreeMap using ZipEntryComparator::compareClassNames, then inserts them with putIfAbsent. The comparator replaces $ with 0 before comparing names.

When generated nested class names include entries such as Foo$2$1$1.class.dex and Foo$2$101.class.dex, both normalize to the same value. The comparator therefore returns zero, the TreeMap treats the distinct classes as the same key, and putIfAbsent silently drops one. The resulting APK can fail at runtime with NoClassDefFoundError for 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 TreeMap shape used by DexFileSplitter and verifies that both remain present.

Testing

  • Passed a self-contained javac regression check against the modified ZipEntryComparator.
  • Added the collision case to DexFileSplitterTest.
  • Attempted bazel test //src/tools/javatests/com/google/devtools/build/android/dexer:AllTests --test_output=errors; repository analysis could not complete locally because connections to maven.google.com timed out before compilation or test execution.

@google-cla

google-cla Bot commented Aug 21, 2026

Copy link
Copy Markdown

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
oscarthecat force-pushed the fix/dex-splitter-class-name-collision branch from ae0903e to 140e6c0 Compare August 21, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant