Description: selecting the unversioned jars instead of the versioned ones,
 taking profit of the ranks of '.' and '-'.
Author: Pierre Gruet <pgt@debian.org>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030205
Forwarded: not-needed
Last-Update: 2023-03-10

--- a/scilab/m4/java-thirdparty.m4
+++ b/scilab/m4/java-thirdparty.m4
@@ -239,7 +239,8 @@
 
     DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find  /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
    
-    jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name '$1.jar' -or -name 'lib$1.jar' -or -name 'lib$1-java.jar' -or -name '$1*.jar' \) 2>/dev/null |tr '\n' ':')."
+    # sorting jars in reverse order so that unversioned jars are before versioned ones.
+    jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name '$1.jar' -or -name 'lib$1.jar' -or -name 'lib$1-java.jar' -or -name '$1*.jar' \) 2>/dev/null | sort -r |tr '\n' ':')."
 
     if test ! -f conftestSharedChecker.class ; then
 	AC_JAVA_COMPILE_CHECKER_CLASS()
