From 30841742e735e70b3946d16711089960084e894c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 9 Feb 2013 06:17:45 +0100 Subject: Bug 681: Add Elf Parsing for other OS than Linux, if ARM and !ANDROID using /proc/self/exe (Linux) or a found java/jvm native lib. - PlatformPropsImpl.queryABITypeImpl: Check Elf Header for ARM + !ANDROID (i.e. add other OS than Linux, use native java/jmv lib) - NativeLibrary.enumerateLibraryPaths: Add 'sun.boot.library.path' to enumeration! - TestElfReader01: Add test for finding java/jvm native lib and parse it --- src/java/com/jogamp/common/os/NativeLibrary.java | 54 ++++++++++++++++++------ 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'src/java/com') diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 49ec860..130812c 100755 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -277,11 +277,11 @@ public class NativeLibrary implements DynamicLookupHelper { /** Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system. */ - public static List enumerateLibraryPaths(String windowsLibName, - String unixLibName, - String macOSXLibName, - boolean searchSystemPathFirst, - ClassLoader loader) { + public static List enumerateLibraryPaths(final String windowsLibName, + final String unixLibName, + final String macOSXLibName, + final boolean searchSystemPathFirst, + final ClassLoader loader) { List paths = new ArrayList(); String libName = selectName(windowsLibName, unixLibName, macOSXLibName); if (libName == null) { @@ -312,17 +312,43 @@ public class NativeLibrary implements DynamicLookupHelper { } // Add entries from java.library.path - String javaLibraryPath = - AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - return System.getProperty("java.library.path"); + final String[] javaLibraryPaths = + AccessController.doPrivileged(new PrivilegedAction() { + public String[] run() { + int count = 0; + final String usrPath = System.getProperty("java.library.path"); + if(null != usrPath) { + count++; + } + final String sysPath = System.getProperty("sun.boot.library.path"); + if(null != sysPath) { + count++; + } + final String[] res = new String[count]; + int i=0; + if (searchSystemPathFirst) { + if(null != sysPath) { + res[i++] = sysPath; + } + } + if(null != usrPath) { + res[i++] = usrPath; + } + if (!searchSystemPathFirst) { + if(null != sysPath) { + res[i++] = sysPath; + } + } + return res; } }); - if (javaLibraryPath != null) { - StringTokenizer tokenizer = new StringTokenizer(javaLibraryPath, File.pathSeparator); - while (tokenizer.hasMoreTokens()) { - addPaths(tokenizer.nextToken(), baseNames, paths); - } + if ( null != javaLibraryPaths ) { + for( int i=0; i < javaLibraryPaths.length; i++ ) { + final StringTokenizer tokenizer = new StringTokenizer(javaLibraryPaths[i], File.pathSeparator); + while (tokenizer.hasMoreTokens()) { + addPaths(tokenizer.nextToken(), baseNames, paths); + } + } } // Add current working directory -- cgit v1.2.3