Mark as loaded BEFORE loading to prevent recursive loading.
When load method is called by usb4java-javax then the loading of the JNI library (Triggered by the load method) triggers the load method again. This results in a crash. Setting the loaded flag before loading the JNI lib prevents this.
This commit is contained in:
parent
03efe3683a
commit
649be57dc2
@ -339,13 +339,15 @@ public final class Loader
|
||||
* @throws LoaderException
|
||||
* When loading the native wrapper libraries failed.
|
||||
*/
|
||||
public static void load()
|
||||
public synchronized static void load()
|
||||
{
|
||||
// Do nothing if already loaded (or still loading)
|
||||
if (loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
loaded = true;
|
||||
final String platform = getPlatform();
|
||||
final String lib = getLibName();
|
||||
final String extraLib = getExtraLibName();
|
||||
@ -354,6 +356,5 @@ public final class Loader
|
||||
System.load(extractLibrary(platform, extraLib));
|
||||
}
|
||||
System.load(extractLibrary(platform, lib));
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user