Top Inners Fields Constructors Methods
org.newsclub.net.unix

pack-priv final Class NativeLibraryLoader

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Annotations
@SuppressFBWarnings:RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
Imports
java.io.Closeable, .File, .FileNotFoundException, .FileOutputStream, .IOException, .InputStream, .OutputStream, java.net.URL, java.nio.file.Files, java.util.ArrayList, .Collections, .List, .Objects, .Properties, java.util.concurrent.atomic.AtomicBoolean, com.kohlschutter.annotations.compiletime.SuppressFBWarnings

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private abstract static class
private static class

Field Summary

Modifier and TypeField and Description
private static final List<String>
private static final boolean
private static final String
private static final AtomicBoolean
private static final String
private static final String
private static final String
private static final String
private static final String
private static final File

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static List<String>
private static boolean
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private List<NativeLibraryLoader.LibraryCandidate>
findLibraryCandidates(String artifactName, String libraryNameAndVersion, Class<?> providerClass)

pack-priv static List<String>
private static String
getArtifactVersion(Class<?> providerClass, String... artifactNames)

public static String
private UnsatisfiedLinkError
initCantLoadLibraryError(List<Throwable> suppressedThrowables)

private List<NativeLibraryLoader.LibraryCandidate>
initLibraryCandidates(List<Throwable> suppressedThrowables)

pack-priv static boolean
public synchronized void
private Throwable
private static Object
private static String
lookupArchProperty(String key, String defaultVal)

private static String
mapLibraryName(String libraryNameAndVersion)

private String
private synchronized void
setLoaded(String library)

private static synchronized void
setLoaded0(String library)

pack-priv static File

Returns:

The temporary directory.
tempDir
()

Returns the temporary directory where the native library is extracted to; debugging only.

private List<NativeLibraryLoader.LibraryCandidate>
tryProviderClass(String providerClassname, String artifactName)

private static URL
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARCHITECTURE_AND_OSback to summary
private static final List<String> ARCHITECTURE_AND_OS
IS_ANDROIDback to summary
private static final boolean IS_ANDROID
LIBRARY_NAMEback to summary
private static final String LIBRARY_NAME
LOADEDback to summary
private static final AtomicBoolean LOADED
OS_NAME_SIMPLIFIEDback to summary
private static final String OS_NAME_SIMPLIFIED
PROP_LIBRARY_DISABLEback to summary
private static final String PROP_LIBRARY_DISABLE
PROP_LIBRARY_OVERRIDEback to summary
private static final String PROP_LIBRARY_OVERRIDE
PROP_LIBRARY_OVERRIDE_FORCEback to summary
private static final String PROP_LIBRARY_OVERRIDE_FORCE
PROP_LIBRARY_TMPDIRback to summary
private static final String PROP_LIBRARY_TMPDIR
TEMP_DIRback to summary
private static final File TEMP_DIR

Constructor Detail

NativeLibraryLoaderback to summary
pack-priv NativeLibraryLoader()

Method Detail

architectureAndOSback to summary
private static List<String> architectureAndOS()
checkAndroidback to summary
private static boolean checkAndroid()
closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
findLibraryCandidatesback to summary
private List<NativeLibraryLoader.LibraryCandidate> findLibraryCandidates(String artifactName, String libraryNameAndVersion, Class<?> providerClass)
getArchitectureAndOSback to summary
pack-priv static List<String> getArchitectureAndOS()
getArtifactVersionback to summary
private static String getArtifactVersion(Class<?> providerClass, String... artifactNames) throws IOException
getJunixsocketVersionback to summary
public static String getJunixsocketVersion() throws IOException
initCantLoadLibraryErrorback to summary
private UnsatisfiedLinkError initCantLoadLibraryError(List<Throwable> suppressedThrowables)
initLibraryCandidatesback to summary
private List<NativeLibraryLoader.LibraryCandidate> initLibraryCandidates(List<Throwable> suppressedThrowables)
isAndroidback to summary
pack-priv static boolean isAndroid()
loadLibraryback to summary
public synchronized void loadLibrary()
Annotations
@SuppressWarnings:null
loadLibraryOverrideback to summary
private Throwable loadLibraryOverride()
loadLibrarySyncMonitorback to summary
private static Object loadLibrarySyncMonitor()
lookupArchPropertyback to summary
private static String lookupArchProperty(String key, String defaultVal)
mapLibraryNameback to summary
private static String mapLibraryName(String libraryNameAndVersion)
nodepsPathback to summary
private String nodepsPath(String path)
setLoadedback to summary
private synchronized void setLoaded(String library)
setLoaded0back to summary
private static synchronized void setLoaded0(String library)
Annotations
@SuppressFBWarnings:THROWS_METHOD_THROWS_RUNTIMEEXCEPTION
tempDirback to summary
pack-priv static File tempDir()

Returns the temporary directory where the native library is extracted to; debugging only.

Returns:File

The temporary directory.

tryProviderClassback to summary
private List<NativeLibraryLoader.LibraryCandidate> tryProviderClass(String providerClassname, String artifactName) throws IOException, ClassNotFoundException
validateResourceURLback to summary
private static URL validateResourceURL(URL url)
org.newsclub.net.unix back to summary

private final Class NativeLibraryLoader.ClasspathLibraryCandidate

extends LibraryCandidate
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final URL
private final String
Inherited from org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate:
libraryNameAndVersion

Constructor Summary

AccessConstructor and Description
pack-priv
ClasspathLibraryCandidate(String artifactName, String libraryNameAndVersion, String path, URL library)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.close.

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private void
deleteLibTmpDelFiles(File
The directory to check.
libDir
)

Even though we ask the JVM to delete the library file upon VM exit, this may not be honored in all cases (crash, Windows, etc.) Therefore, we attempt to delete these files whenever another JVM using junixsocket starts up.

pack-priv synchronized String
public String
toString()

Overrides org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.toString.

Returns a string representation of the object.

private static void

Field Detail

artifactNameback to summary
private final String artifactName
libraryback to summary
private final URL library
pathback to summary
private final String path

Constructor Detail

ClasspathLibraryCandidateback to summary
pack-priv ClasspathLibraryCandidate(String artifactName, String libraryNameAndVersion, String path, URL library)

Method Detail

closeback to summary
public void close()

Implements abstract org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.close.

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
deleteLibTmpDelFilesback to summary
private void deleteLibTmpDelFiles(File libDir)

Even though we ask the JVM to delete the library file upon VM exit, this may not be honored in all cases (crash, Windows, etc.) Therefore, we attempt to delete these files whenever another JVM using junixsocket starts up. This is simplified by keeping empty marker files next to the temporary shared library file.

Parameters
libDir:File

The directory to check.

loadback to summary
pack-priv synchronized String load() throws IOException, LinkageError

Implements abstract org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.load.

Annotations
@Override
@SuppressWarnings:PMD.CognitiveComplexity
toStringback to summary
public String toString()

Overrides org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryDeleteback to summary
private static void tryDelete(File f)
Annotations
@SuppressFBWarnings:RV_RETURN_VALUE_IGNORED_BAD_PRACTICE
org.newsclub.net.unix back to summary

private abstract Class NativeLibraryLoader.LibraryCandidate

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.newsclub.net.unix.NativeLibraryLoader.StandardLibraryCandidate, org.newsclub.net.unix.NativeLibraryLoader.ClasspathLibraryCandidate

Field Summary

Modifier and TypeField and Description
protected final String

Constructor Summary

AccessConstructor and Description
protected
LibraryCandidate(String libraryNameAndVersion)

Method Summary

Modifier and TypeMethod and Description
public abstract void
close()

Redeclares java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

pack-priv abstract String
load()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

libraryNameAndVersionback to summary
protected final String libraryNameAndVersion

Constructor Detail

LibraryCandidateback to summary
protected LibraryCandidate(String libraryNameAndVersion)

Method Detail

closeback to summary
public abstract void close()

Redeclares java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
loadback to summary
pack-priv abstract String load() throws Exception
Annotations
@SuppressFBWarnings:THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.newsclub.net.unix back to summary

private final Class NativeLibraryLoader.StandardLibraryCandidate

extends LibraryCandidate
Class Inheritance

Field Summary

Inherited from org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate:
libraryNameAndVersion

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.close.

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

pack-priv String
public String
toString()

Overrides org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.toString.

Returns a string representation of the object.

Constructor Detail

StandardLibraryCandidateback to summary
pack-priv StandardLibraryCandidate(String version)

Method Detail

closeback to summary
public void close()

Implements abstract org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.close.

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
loadback to summary
pack-priv String load() throws Exception, LinkageError

Implements abstract org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.load.

Annotations
@Override
@SuppressFBWarnings:THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION
toStringback to summary
public String toString()

Overrides org.newsclub.net.unix.NativeLibraryLoader.LibraryCandidate.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override