Skip to content

Preserve exact dependency class names containing dollar signs - #296

Open
wilx wants to merge 2 commits into
apache:masterfrom
wilx:mdep-840-kotlin-inner-class
Open

Preserve exact dependency class names containing dollar signs#296
wilx wants to merge 2 commits into
apache:masterfrom
wilx:mdep-840-kotlin-inner-class

Conversation

@wilx

@wilx wilx commented Aug 2, 2026

Copy link
Copy Markdown

Fixes apache/maven-dependency-plugin#1345

Summary

Preserve exact JVM binary class names when collecting dependency usages and dependency artifact contents.

The analyzer previously assumed that every $ in a binary class name denoted an inner class and discarded or folded that name into its presumed container. Kotlin can emit bytecode that references only a nested class, so the corresponding artifact was incorrectly reported as unused. The assumption was also invalid for legal top-level Java class names containing $.

Artifact lookup already deduplicates usages by artifact, so retaining the exact binary name correctly handles both nested classes and top-level names without independently inferring the source-level compilation unit.

The change adds:

  • a Kotlin integration test reproducing the nested-class-only reference;
  • an integration test for a genuine top-level Java class containing $;
  • unit coverage for exact usage collection and exploded dependency directories.

Verification

  • mvn -Prun-its verify with JDK 17: 128 unit tests and all 21 invoker builds passed.
  • Focused Kotlin and top-level-dollar integration tests passed with JDK 8 and JDK 17.
  • The original Dropwizard/Kotlin reproducer completed without dependency-analysis warnings.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@wilx
wilx marked this pull request as ready for review August 2, 2026 13:58
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.

[MDEP-840] Unused declared dependencies found but dependency is used?

1 participant