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

Michael Froh commented on CODEC-324:
------------------------------------

I've been struggling to reproduce it within the commons-codec project itself. 
I'm not very good with Maven (being more of an Ant/Gradle person) and I'm 
pretty new to JPMS (besides the debugging through BuiltInClassLoader I did 
yesterday).

I was able to reproduce it pretty easily with a tiny project that depends on 
commons-codec and loads it as a module: 
https://github.com/msfroh/commons-codec-test/commit/ad95b12204191996d20ecf7a111811806a3ce2fd

I'm going to see if I can figure out how to modify the generated 
module-info.java for commons-codec to "open" access to the resources for 
getResourceAsStream.

> 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)

Reply via email to