[ 
https://issues.apache.org/jira/browse/LANG-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128251#comment-18128251
 ] 

Aryan Ganjoo commented on LANG-1838:
------------------------------------

Verified on current upstream master (8b126aa9c): ClassPathUtilsTest passes 
locally on JDK 17 (29 tests, 0 failures/errors), and the upstream JDK 8 build 
also reports 29 passing ClassPathUtilsTest cases. The unnamed-package behavior 
is covered, including the additional edge cases in af4b2a2. Thanks for 
expanding the tests and documentation. This verifies the fix in master; I have 
not tested a released 3.21.1 artifact. Closing as fixed.

> 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
>            Assignee: Gary D. Gregory
>            Priority: Minor
>             Fix For: 3.21.1
>
>
> 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 JDK 17, the package name is empty 
> and the methods return {{.Test.properties}} and {{/Test.properties}}. The 
> Package overloads also prepend a separator when given an empty-named package. 
> OpenJDK 8 source indicates that {{Class.getPackage()}} is null for an 
> unnamed-package class, so the original Class overloads pass null to a Package 
> overload and throw {{NullPointerException}}; that Java 8 path was not 
> executed locally.
> h3. Expected
> Both methods should return {{Test.properties}} for an unnamed-package 
> context. Named-package behavior should remain unchanged.
> h3. Reproduction and validation
> Place a class in the default package and call both overloads with 
> {{Test.properties}} as the resource name. On Commons Lang master 
> {{9c86ffe308e7c682df3b1cf76f27dfc5bb6a2243}}, the local JDK 17 regression 
> reproduced the leading separators. The corrected patch passed 21 focused 
> tests and 413 adjacent tests on JDK 17; its default Maven build completed 
> successfully. Java 8-target bytecode was compiled and OpenJDK 8 source was 
> inspected, but a Java 8 runtime test was not run locally. Other JDKs and 
> released binaries were not tested.
> h3. Fix
> Treat a null or empty package name as the classpath root without adding a 
> separator, preserving named-package and null-argument behavior. 
> Implementation PR: https://github.com/apache/commons-lang/pull/1824 . AI 
> assistance was used for discovery, implementation, tests, and review; the 
> submitter reviewed the exact revision.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to