Repository navigation
[LANG-1838] Fix resource paths for unnamed packages - #1824
Merged
garydgregory merged 1 commit intoOct 17, 2026
Merged
Conversation
Return the unprefixed resource name for an empty Package name, and handle Java 8 unnamed-package classes whose getPackage() is null. Add focused regressions for class and Package overloads while retaining named-package and null behavior. AI-Assisted-by: OpenAI Codex
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The localized changes preserve existing behavior outside unnamed packages, with regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes ClassPathUtils resource construction for unnamed packages while preserving named-package and null-argument behavior.
Changes:
- Avoids leading separators for unnamed packages.
- Handles Java 8 unnamed-package classes with a null package.
- Adds regression tests and an unnamed-package fixture.
| File | Description |
|---|---|
| src/test/java/org/apache/commons/lang3/ClassPathUtilsTest.java | Tests unnamed packages and primitive/array behavior. |
| src/test/java/ClassPathUtilsDefaultPackage.java | Adds an unnamed-package fixture. |
| src/main/java/org/apache/commons/lang3/ClassPathUtils.java | Corrects resource-name and path construction. |
Review effort: Balanced
garydgregory
added a commit
that referenced
this pull request
Oct 17, 2026
Member
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.
Summary
Fix
ClassPathUtilsresource-name and path construction for classes andPackageobjects in the unnamed package. The existing methods added a leading.or/(and a Java 8 unnamed-package class could have a nullgetPackage()result). The corrected methods return the resource name unchanged for an unnamed package while preserving named-package and null-argument behavior.Jira: LANG-1838
Verification
Class<?>andPackageoverloads; existing named-package, primitive/array and null cases remain covered.ClassPathUtilsTest,ClassLoaderUtilsTest, andClassUtilsTest: 413 tests passed on JDK 17; Checkstyle passed.Contributor checklist