[
https://issues.apache.org/jira/browse/CODEC-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17908486#comment-17908486
]
Gary D. Gregory edited comment on CODEC-324 at 12/27/24 7:38 PM:
-----------------------------------------------------------------
Hello [~msfroh]
Thank you for your report.
Can you provide a PR or patch for a failing test? I'll pick it up from there.
I wonder how the test passes on Java 21 and 23 with:
{noformat}
mvn test -Dtest=DaitchMokotoffSoundexTest
{noformat}
Aside:
{quote}the Lang class uses reflection to load language rules.
{quote}
We don't use reflection here, we use
{{java.lang.ClassLoader.getResourceAsStream(String)}}
See also {{org.apache.commons.codec.ResourcesTest}}
If I modify this test like this:
{code:java}
public class ResourcesTest {
public static void main(String[] args) throws IOException {
new
ResourcesTest().testGetInputStream("org/apache/commons/codec/language/dmrules.txt");
System.out.println("Done.");
}
static List<String> getResourceNames() {
return Arrays.asList("org/apache/commons/codec/language/dmrules.txt",
"org/apache/commons/codec/language/bm/lang.txt");
}
@ParameterizedTest
@MethodSource("getResourceNames")
public void testGetInputStream(final String resName) throws IOException {
try (InputStream in = Resources.getInputStream(resName)) {
// empty
}
}
{code}
and tun:
{noformat}
mvn clean package
java -cp target/commons-codec-1.17.2-SNAPSHOT.jar:target/test-classes
org.apache.commons.codec.ResourcesTest
{noformat}
Using:
{noformat}
openjdk version "23.0.1" 2024-10-15
OpenJDK Runtime Environment Homebrew (build 23.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 23.0.1, mixed mode, sharing)
{noformat}
It works:
{noformat}
Done.
{noformat}
was (Author: garydgregory):
Hello [~msfroh]
Thank you for your report.
Can you provide a PR or patch for a failing test? I'll pick it up from there.
I wonder how the test passes on Java 21 and 23 with:
{noformat}
mvn test -Dtest=DaitchMokotoffSoundexTest
{noformat}
Aside:
{quote}the Lang class uses reflection to load language rules.
{quote}
We don't use reflection here, we use
{{java.lang.ClassLoader.getResourceAsStream(String)}}
See also {{org.apache.commons.codec.ResourcesTest}}
> BeiderMorse engine doesn't work with JPMS enabled
> -------------------------------------------------
>
> Key: CODEC-324
> URL: https://issues.apache.org/jira/browse/CODEC-324
> Project: Commons Codec
> Issue Type: Bug
> Affects Versions: 1.16.1, 1.17.0, 1.17.1
> Environment: Corretto JDK21
> JPMS enabled
> Reporter: Michael Froh
> Priority: Major
>
> With the upgrade of commons-parent from 58 to 66 in the 1.16.1 release,
> commons-codec started using Moditect to generate a modules-info.class file as
> part of the jar (which I think was added in commons-parent 59).
> A decompiled version of the modules-info looks like:
> {code:java}
> module org.apache.commons.codec {
> exports org.apache.commons.codec;
> exports org.apache.commons.codec.binary;
> exports org.apache.commons.codec.cli;
> exports org.apache.commons.codec.digest;
> exports org.apache.commons.codec.language;
> exports org.apache.commons.codec.language.bm;
> exports org.apache.commons.codec.net;
> }
> {code}
> Unfortunately, the Lang class uses reflection to load language rules.
> Eventually, it gets to the isOpen check in BuiltinClassLoader (called from
> BuiltInClassLoader's findResource), which finds that the commons-codec module
> is not open and the org.apache.commons.codec.language.bm package is not open.
> As a result, attempting to load any of the language rule files returns
> `null`, and the Resources class throws an IllegalArgumentException.
> You can see a stack trace of one such failure when trying to upgrade Lucene
> to commons-codec 1.16.1: https://github.com/apache/lucene/pull/13269
> I think there might need to be a way to pass a hint to commons-parent's pom
> to specify "opensResources" configuration for Moditect to allow the language
> rules to be loaded.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)