Skip to content

Conversation

@hopper-signifyd
Copy link

@hopper-signifyd hopper-signifyd commented Oct 27, 2025

In Java, it's perfectly valid for a class in one package to reference another class in the same package without importing it. However, our current dependency inference code doesn't support this. Suppose we have two classes com.example.A and com.example.B and A references B without importing it. The Pants Java backend won't figure out on its own that A.java depends on B.java without an explicit dependency reference.

This PR aims to enhance our first party dependency inference logic such that Pants will know that A.java depends on B.java even if we don't explicitly mention it or explicitly import com.example.B in A.java.

This is my first contribution, so let me know if I'm missing anything obvious.

I ran /pants test src/python/pants/backend/java/:: and all of those tests are passing.

I plan on testing this in a local repo with real code tomorrow.

@hopper-signifyd hopper-signifyd marked this pull request as draft October 27, 2025 22:33
@hopper-signifyd
Copy link
Author

I'm moving this into a draft status for now. There's something off with my real-world test project. I'll move this out of draft once that verification test is passing

@benjyw
Copy link
Contributor

benjyw commented Oct 28, 2025

Thanks for the contribution! Let us know here when this is ready for review (feel free to cc me by name to get my attention).

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.

2 participants