< prev index next >
modules/graphics/src/main/java/com/sun/glass/utils/NativeLibLoader.java
Print this page
rev 9619 : [mq]: 9-jake.patch
*** 41,50 ****
--- 41,51 ----
}
}
private static boolean verbose = false;
+ private static boolean usingModules = false;
private static File libDir = null;
private static String libPrefix = "";
private static String libSuffix = "";
static {
*** 87,100 ****
}
private static void loadLibraryInternal(String libraryName) {
// Look for the library in the same directory as the jar file
// containing this class.
! // If that fails, then try System.loadLibrary as a last resort.
try {
loadLibraryFullPath(libraryName);
} catch (UnsatisfiedLinkError ex) {
// NOTE: First attempt to load the libraries from the java.library.path.
// This allows FX to find more recent versions of the shared libraries
// from java.library.path instead of ones that might be part of the JRE
//
String [] libPath = initializePath("java.library.path");
--- 88,107 ----
}
private static void loadLibraryInternal(String libraryName) {
// Look for the library in the same directory as the jar file
// containing this class.
! // If that fails, then try System.loadLibrary.
try {
+ // FIXME: We should eventually remove this legacy path, since
+ // it isn't applicable to Jigsaw.
loadLibraryFullPath(libraryName);
} catch (UnsatisfiedLinkError ex) {
+ if (verbose && !usingModules) {
+ System.err.println("WARNING: " + ex);
+ }
+
// NOTE: First attempt to load the libraries from the java.library.path.
// This allows FX to find more recent versions of the shared libraries
// from java.library.path instead of ones that might be part of the JRE
//
String [] libPath = initializePath("java.library.path");
*** 113,131 ****
} catch (UnsatisfiedLinkError ex3) {
// Fail silently and try the next directory in java.library.path
}
}
! // Try System.loadLibrary as a last resort. If it succeeds, then
! // print a warning. If it fails, rethrow the exception from
! // the earlier System.load()
try {
System.loadLibrary(libraryName);
if (verbose) {
! System.err.println("WARNING: " + ex.toString());
! System.err.println(" using System.loadLibrary("
! + libraryName + ") as a fallback");
}
} catch (UnsatisfiedLinkError ex2) {
//On iOS we link all libraries staticaly. Presence of library
//is recognized by existence of JNI_OnLoad_libraryname() C function.
//If libraryname contains hyphen, it needs to be translated
--- 120,135 ----
} catch (UnsatisfiedLinkError ex3) {
// Fail silently and try the next directory in java.library.path
}
}
! // Finally we will use System.loadLibrary.
try {
System.loadLibrary(libraryName);
if (verbose) {
! System.err.println("System.loadLibrary("
! + libraryName + ") succeeded");
}
} catch (UnsatisfiedLinkError ex2) {
//On iOS we link all libraries staticaly. Presence of library
//is recognized by existence of JNI_OnLoad_libraryname() C function.
//If libraryname contains hyphen, it needs to be translated
*** 138,166 ****
return;
} catch (UnsatisfiedLinkError ex3) {
throw ex3;
}
}
! // Rethrow original exception
! throw ex;
}
}
}
/**
* Load the native library from the same directory as the jar file
* containing this class.
*/
private static void loadLibraryFullPath(String libraryName) {
try {
if (libDir == null) {
// Get the URL for this class, if it is a jar URL, then get the
// filename associated with it.
String theClassFile = "NativeLibLoader.class";
Class theClass = NativeLibLoader.class;
String classUrlString = theClass.getResource(theClassFile).toString();
! if (!classUrlString.startsWith("jar:file:") || classUrlString.indexOf('!') == -1){
throw new UnsatisfiedLinkError("Invalid URL for class: " + classUrlString);
}
// Strip out the "jar:" and everything after and including the "!"
String tmpStr = classUrlString.substring(4, classUrlString.lastIndexOf('!'));
// Strip everything after the last "/" or "\" to get rid of the jar filename
--- 142,178 ----
return;
} catch (UnsatisfiedLinkError ex3) {
throw ex3;
}
}
! // Rethrow exception
! throw ex2;
}
}
}
/**
* Load the native library from the same directory as the jar file
* containing this class.
*/
private static void loadLibraryFullPath(String libraryName) {
try {
+ if (usingModules) {
+ throw new UnsatisfiedLinkError("ignored");
+ }
if (libDir == null) {
// Get the URL for this class, if it is a jar URL, then get the
// filename associated with it.
String theClassFile = "NativeLibLoader.class";
Class theClass = NativeLibLoader.class;
String classUrlString = theClass.getResource(theClassFile).toString();
! if (classUrlString.startsWith("jrt:")) {
! // Suppress warning messages
! usingModules = true;
! throw new UnsatisfiedLinkError("ignored");
! }
! if (!classUrlString.startsWith("jar:file:") || classUrlString.indexOf('!') == -1) {
throw new UnsatisfiedLinkError("Invalid URL for class: " + classUrlString);
}
// Strip out the "jar:" and everything after and including the "!"
String tmpStr = classUrlString.substring(4, classUrlString.lastIndexOf('!'));
// Strip everything after the last "/" or "\" to get rid of the jar filename
< prev index next >