RFR: JDK-8319516 - Native library suffix impact on the library loading in AIX- Java Class Loader [v2]

Suchismith Roy sroy at openjdk.org
Thu Mar 21 15:54:21 UTC 2024


On Tue, 19 Mar 2024 10:01:31 GMT, Suchismith Roy <sroy at openjdk.org> wrote:

>>> > In AIX, we have an usecase where shared libraries have certain member objects to be referred to. E.g libclang.a(shr_64.o) .
>>> 
>>> Would you happen to know any official documentation which explains that AIX syntax?
>>> 
>> 
>> https://www.ibm.com/docs/en/aix/7.2?topic=l-ld-command
>> Text : 
>> 
>> **autoload: path/file(member) | Automatically load the archive member.
>> -- | --**
>> Autoload is a  flag used to load archive members. The format of the path is mentioned.
>
>> Do you mean some application code is calling the `System.loadLibrary()` method with such values?
> 
> Yes we are trying to install liblcang and also jextract and it fails with errors.
> 
> Exception in thread "main" java.lang.UnsatisfiedLinkError: no clang in java.library.path
>  
>         at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2439)
>         at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916)
>         at java.base/java.lang.System.loadLibrary(System.java:2063)
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.RuntimeHelper.<clinit>(RuntimeHelper.java:65)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.RuntimeHelper.%3cclinit%3e(RuntimeHelper.java:65))
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.constants$17.<clinit>(constants$17.java:46)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.constants$17.%3cclinit%3e(constants$17.java:46))
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.Index_h.clang_getClangVersion$MH(Index_h.java:5690)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.Index_h.clang_getClangVersion$MH(Index_h.java:5690))
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.Index_h.clang_getClangVersion(Index_h.java:5698)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.clang.libclang.Index_h.clang_getClangVersion(Index_h.java:5698))
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.clang.LibClang.version(LibClang.java:93)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.clang.LibClang.version(LibClang.java:93))
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.JextractTool.run(JextractTool.java:362)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.JextractTool.run(JextractTool.java:362))
>         at [org.openjdk.jextract at 22/org.openjdk.jextract.JextractTool.main(JextractTool.java:174)](mailto:org.openjdk.jextract at 22/org.openjdk.jextract.JextractTool.main(JextractTool.java:174))
> 
> 
> The actual member is libclang.a(libclang.so.16)

> Hello @suchismith1993, I haven't fully caught up on the necessity of this change. The current proposed change, renames files in the underlying filesystem in the code flow of `System.loadLibrary()` and I don't think is the right thing to do irrespective of whether we do it in AIX specific code or common code.
> 
> Could you update the JBS issue description to clearly explain what (application?) code is causing what issue? I know you mentioned about jextract here, but it's not clear whether this is some issue in jextract or something else. Having all those details in the JBS issue will be helpful to decide what changes should be pursued.

This is not specific to an application. We are looking to support member objects of AIX shared libraries in the Java ClassLoader. 
As for the renaming, the renaming is necessary because the member object is not part of the actual filename. 
Example : libclang.a(libclang.so.16) 
This member object, is identified only by the dlopen() in the hotspot code. But there is no actual file named libclang.a(libclang.so.16) in the filesystem. 
So when the check is done if file exists, it fails,i.e it checks for libclang.a(libclang.so.16).So i remove the braces and member name to extract the actual name of the file in the filesystem, which is libclang.a. But when welibclang.a and the dlopen ,it will fail to open it. 
Hence i need to rename the file to the name with braces before it passes to dlopen.So i reconstruct it to libclang.a(libclang.so.16)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17945#discussion_r1534186639


More information about the core-libs-dev mailing list