[
https://issues.apache.org/jira/browse/LANG-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128235#comment-18128235
]
Aryan Ganjoo commented on LANG-1838:
------------------------------------
Implementation PR: https://github.com/apache/commons-lang/pull/1824
The revised patch includes regression tests for the Class and Package
overloads. The default Maven build completed successfully on JDK 17; hosted CI
and a Java 8 runtime run remain pending.
> ClassPathUtils mishandles resources in the unnamed package
> ----------------------------------------------------------
>
> Key: LANG-1838
> URL: https://issues.apache.org/jira/browse/LANG-1838
> Project: Commons Lang
> Issue Type: Bug
> Reporter: Aryan Ganjoo
> Priority: Minor
>
> h3. Observed
> For a class in the unnamed (default) package, the Class overloads of
> {{ClassPathUtils.toFullyQualifiedName}} and {{toFullyQualifiedPath}} do not
> produce a classpath-root resource name. On Java 8, {{Class.getPackage()}} is
> null here and both calls throw {{NullPointerException}}. On Java 17, the
> package name is empty and the methods return {{.Test.properties}} and
> {{/Test.properties}} respectively. The Package overloads also prepend a
> separator when given an empty-named package. A class loader can resolve
> {{Test.properties}} at the classpath root, but not the leading-slash path
> produced here.
> h3. Expected
> Both methods should return {{Test.properties}} for an unnamed-package
> context. Named-package behavior should remain unchanged.
> h3. Reproduction
> Place a class in the default package and call both overloads with
> {{Test.properties}} as the resource name. This reproduces on current Commons
> Lang master {{9c86ffe308e7c682df3b1cf76f27dfc5bb6a2243}}. A local regression
> failed on the unmodified Java 8 source (two NPE errors); the corrected
> candidate passed 21 focused tests on Java 8 and Java 17. The Java 8 default
> Maven build also passed. Java 11/21/25 and released binaries were not tested.
> h3. Scope and possible fix
> Treat a null or empty package name as the classpath root without adding a
> separator; preserve named-package behavior. This is a local candidate only,
> not a submitted PR. AI assistance was used for discovery, test and patch
> preparation, and local validation.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)