<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1519</bug_id>
          
          <creation_ts>2025-07-12 18:22:20 +0200</creation_ts>
          <short_desc>NativeLibrary: Clarify search order, allow added search-path + add property `jogamp.primary.library.path`</short_desc>
          <delta_ts>2025-07-15 08:49:16 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Gluegen</product>
          <component>core</component>
          <version>2.6.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>1510</dependson>
          <blocked>1511</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>mfery</cc>
          
          <cf_type>FEATURE</cf_type>
          <cf_scm_refs>581549571c0a0bd245621a004cc2a9be6d10888b
f051db16085b615e8609b889817d43209ebd1ebf</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7206</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-12 18:22:20 +0200</bug_when>
    <thetext>This feature enhances Bug 1510 further.

+++

NativeLibrary shall allow adding (user) search path to the OS linker facility where supported (Windows).

For this feature, we require to have more information for the `DynamicLinker`
implementation, i.e. the new `NativeLibrary.LibPath` exposing 
- whether its an absolute path, 
- contained directory shall be added to search path (first) and 
- otherwise potential added search path to prepend.

This feature is currently only supported by the Windows native linker,
since the POSIX `dlopen` facility doesn&apos;t allow to modify `LD_LIBRARY_PATH` at runtime.

+++

Add Java property `jogamp.primary.library.path` containing a separated path
in the OS system&apos;s format.

These paths will be searched first, 
allowing to inject custom native libraries at runtime.

+++

NativeLibrary&apos;s search order is not clear, or has a bug in regards to `searchSystemPathFirst`. Here the system and user lib-path is not well separated.

Clarified search order:

 * ## System Search Resolution
 * System search&apos;s behavior depends on `searchOSSystemPath` and `searchSystemPathFirst`.
 *
 * ### OS System Search
 * - System search path direct lookup (absolute path)
 *   - Windows: `PATH`
 *   - MacOS: `DYLD_LIBRARY_PATH`
 *   - Unix: `LD_LIBRARY_PATH`
 * - System search path implicit lookup (relative path)
 * - OSX System search path direct lookup (absolute path)
 *   - `/Library/Frameworks/`
 *   - `/System/Library/Frameworks/`
 *
 * ### System Search
 * - if `searchSystemPathFirst`
 *   - If `searchOSSystemPath`
 *     - Perform described `OS System Search` above
 *   - Java&apos;s ClassLoader `findLibrary` mechanism
 *   - Java&apos;s Java system library path property
 *     - `sun.boot.library.path`
 * - if `!searchSystemPathFirst`
 *   - Java&apos;s Java system library path property
 *     - `sun.boot.library.path`
 *   - Java&apos;s ClassLoader `findLibrary` mechanism
 *   - If `searchOSSystemPath`
 *     - Perform described `OS System Search` above
 *
 * ## Native Library Search Resolution
 * - Absolute path only, if given
 * - JogAmp&apos;s optional primary search path from Java property `jogamp.primary.library.path`
 *   - path is separated via `File.pathseparator`
 * - if `searchSystemPathFirst`
 *   - Perform described `System Search Resolution` above
 * - Java&apos;s Java user library path property
 *   - `java.library.path`
 * - Java&apos;s Java user current working directory
 *   - user: `user.dir`
 *   - user+fat: `user.dir` + File.separator + `natives` + File.separator + `PlatformPropsImpl.os_and_arch`
 * - if `!searchSystemPathFirst`
 *   - Perform described `System Search Resolution` above</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7207</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-12 18:27:42 +0200</bug_when>
    <thetext>Resolved as described in commit 581549571c0a0bd245621a004cc2a9be6d10888b</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7210</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-12 20:49:44 +0200</bug_when>
    <thetext>commit f051db16085b615e8609b889817d43209ebd1ebf

    Bug 1519 - NativeLibrary: `searchPathPrepend` shall act independent of `addToSearchPath`, do a null-check when using (Windows)
    
    Current usage sets both, i.e. addToSearchPath=true and searchPathPrepend=&lt;some-valid-path&gt;.
    However, it shall be used independent offering more flexibility and fail-proof.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7211</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-12 21:00:29 +0200</bug_when>
    <thetext>Produced javadoc:

https://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/classcom_1_1jogamp_1_1common_1_1os_1_1NativeLibrary.html#details</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>