Top Description Inners Fields Constructors Methods
com.kenai.jffi.internal

public Class StubLoader

extends Object
Class Inheritance
Imports
com.kenai.jffi.Platform, .Util, java.io.CharArrayWriter, .File, .FileInputStream, .FileOutputStream, .IOException, .InputStream, .PrintWriter, java.nio.channels.Channels, .ReadableByteChannel, java.security.DigestInputStream, .MessageDigest, .NoSuchAlgorithmException, java.util.ArrayList, .Arrays, .Collection, .Collections, .List, .Properties

Loads the native stub library. This is intended to only ever be called reflectively, so it cannot access other jffi classes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
StubLoader.CPU

The common names of cpu architectures

Note

The names of the enum values are used in other parts of the code to determine where to find the native stub library.

public static enum

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static volatile StubLoader.CPU
private static volatile Throwable
private static final String
private static final String
private static final File
private static final String
private static volatile boolean
private static final Locale
private static volatile StubLoader.OS
private static final String
private static final String
private static final String
public static final String
private static final String
public static final String
public static final int
public static final int
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static File
calculateExtractPath(File tmpDirFile, String jffiExtractName)

pack-priv static File
private static StubLoader.CPU

Returns:

A member of the CPU enum.
determineCPU
()

Determines the CPU architecture the JVM is running on.

private static StubLoader.OS

Returns:

An member of the OS enum.
determineOS
()

Determines the operating system jffi is running on

private static SecurityException
pack-priv static String
private static String
private static String
public static StubLoader.CPU
public static final Throwable
public static StubLoader.OS
public static String

Returns:

The name of this platform.
getPlatformName
()

Gets the name of this Platform.

private static InputStream
private static String

Returns:

The name of the stub library as a String
getStubLibraryName
()

Gets the name of the stub library.

private static String

Returns:

The path of the jar file.
getStubLibraryPath
()

Gets the path within the jar file of the stub native library.

private static InputStream

Returns:

A new InputStream
getStubLibraryStream
()

Gets an InputStream representing the stub library image stored in the jar file.

private static int
public static final boolean
pack-priv static void
load()

Loads the stub library

private static boolean
loadFromBootPath(String libName, String bootPath, Collection<Throwable> errors)

private static void
loadFromJar(File tmpDirFile)

private static SecurityException
sizeMismatchError(File dstFile, int sourceSize, int targetSize)

private static UnsatisfiedLinkError
private static IOException
private static void
unpackLibrary(File dstFile, InputStream sourceIS)

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

Field Detail

bootLibraryPropertyNameback to summary
private static final String bootLibraryPropertyName
bootPropertyFilenameback to summary
private static final String bootPropertyFilename
cpuback to summary
private static volatile StubLoader.CPU cpu
failureCauseback to summary
private static volatile Throwable failureCause
JFFI_EXTRACT_DIRback to summary
private static final String JFFI_EXTRACT_DIR
JFFI_EXTRACT_NAMEback to summary
private static final String JFFI_EXTRACT_NAME
jffiExtractDirback to summary
private static final File jffiExtractDir
jffiExtractNameback to summary
private static final String jffiExtractName
loadedback to summary
private static volatile boolean loaded
LOCALEback to summary
private static final Locale LOCALE
osback to summary
private static volatile StubLoader.OS os
stubLibraryNameback to summary
private static final String stubLibraryName
TMPDIRback to summary
private static final String TMPDIR
TMPDIR_ENVback to summary
private static final String TMPDIR_ENV
TMPDIR_EXEC_ERRORback to summary
public static final String TMPDIR_EXEC_ERROR
TMPDIR_RECOMMENDATIONback to summary
private static final String TMPDIR_RECOMMENDATION
TMPDIR_WRITE_ERRORback to summary
public static final String TMPDIR_WRITE_ERROR
VERSION_MAJORback to summary
public static final int VERSION_MAJOR
VERSION_MINORback to summary
public static final int VERSION_MINOR
versionClassNameback to summary
private static final String versionClassName

Constructor Detail

StubLoaderback to summary
public StubLoader()

Method Detail

calculateExtractPathback to summary
pack-priv static File calculateExtractPath(File tmpDirFile, String jffiExtractName) throws IOException
calculateExtractPathback to summary
pack-priv static File calculateExtractPath(File tmpDirFile) throws IOException
determineCPUback to summary
private static StubLoader.CPU determineCPU()

Determines the CPU architecture the JVM is running on. This normalizes all the variations that are equivalent (e.g. i386, x86, i86pc) into a common cpu type.

Returns:StubLoader.CPU

A member of the CPU enum.

determineOSback to summary
private static StubLoader.OS determineOS()

Determines the operating system jffi is running on

Returns:StubLoader.OS

An member of the OS enum.

digestMismatchErrorback to summary
private static SecurityException digestMismatchError(File dstFile)
dlExtensionback to summary
pack-priv static String dlExtension()
getAlternateLibraryPathback to summary
private static String getAlternateLibraryPath(String path)
getBootPathback to summary
private static String getBootPath()
getCPUback to summary
public static StubLoader.CPU getCPU()
getFailureCauseback to summary
public static final Throwable getFailureCause()
getOSback to summary
public static StubLoader.OS getOS()
getPlatformNameback to summary
public static String getPlatformName()

Gets the name of this Platform.

Returns:String

The name of this platform.

getResourceAsStreamback to summary
private static InputStream getResourceAsStream(String resourceName)
getStubLibraryNameback to summary
private static String getStubLibraryName()

Gets the name of the stub library.

Returns:String

The name of the stub library as a String

getStubLibraryPathback to summary
private static String getStubLibraryPath()

Gets the path within the jar file of the stub native library.

Returns:String

The path of the jar file.

getStubLibraryStreamback to summary
private static InputStream getStubLibraryStream()

Gets an InputStream representing the stub library image stored in the jar file.

Returns:InputStream

A new InputStream

getVersionFieldback to summary
private static int getVersionField(String name)
isLoadedback to summary
public static final boolean isLoaded()
loadback to summary
pack-priv static void load()

Loads the stub library

loadFromBootPathback to summary
private static boolean loadFromBootPath(String libName, String bootPath, Collection<Throwable> errors)
loadFromJarback to summary
private static void loadFromJar(File tmpDirFile) throws IOException, LinkageError
sizeMismatchErrorback to summary
private static SecurityException sizeMismatchError(File dstFile, int sourceSize, int targetSize)
tempLoadErrorback to summary
private static UnsatisfiedLinkError tempLoadError(UnsatisfiedLinkError ule)
tempReadonlyErrorback to summary
private static IOException tempReadonlyError(IOException ioe)
unpackLibraryback to summary
private static void unpackLibrary(File dstFile, InputStream sourceIS) throws IOException
verifyExistingLibraryback to summary
private static void verifyExistingLibrary(File dstFile, InputStream sourceIS) throws IOException
com.kenai.jffi.internal back to summary

public final Enum StubLoader.CPU

extends Enum<StubLoader.CPU>
Class Inheritance

The common names of cpu architectures

Note

The names of the enum values are used in other parts of the code to determine where to find the native stub library. Do not rename.

Field Summary

Modifier and TypeField and Description
public static final StubLoader.CPU
AARCH64

AArch64

public static final StubLoader.CPU
ARM

ARM

public static final StubLoader.CPU
I386

Intel ia32

public static final StubLoader.CPU
MIPS64EL

MIPS 64-bit little endian

public static final StubLoader.CPU
PPC

Power PC 32 bit

public static final StubLoader.CPU
PPC64

Power PC 64 bit

public static final StubLoader.CPU
PPC64LE

Power PC 64 bit little endian

public static final StubLoader.CPU
S390X

IBM zSeries S/390 64 bit

public static final StubLoader.CPU
SPARC

Sun sparc 32 bit

public static final StubLoader.CPU
SPARCV9

Sun sparc 64 bit

public static final StubLoader.CPU
UNKNOWN

Unknown CPU

public static final StubLoader.CPU
X86_64

AMD 64 bit (aka EM64T/X64)

Constructor Summary

AccessConstructor and Description
private
CPU()

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static StubLoader.CPU
public static StubLoader.CPU[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

AARCH64back to summary
public static final StubLoader.CPU AARCH64

AArch64

ARMback to summary
public static final StubLoader.CPU ARM

ARM

I386back to summary
public static final StubLoader.CPU I386

Intel ia32

MIPS64ELback to summary
public static final StubLoader.CPU MIPS64EL

MIPS 64-bit little endian

PPCback to summary
public static final StubLoader.CPU PPC

Power PC 32 bit

PPC64back to summary
public static final StubLoader.CPU PPC64

Power PC 64 bit

PPC64LEback to summary
public static final StubLoader.CPU PPC64LE

Power PC 64 bit little endian

S390Xback to summary
public static final StubLoader.CPU S390X

IBM zSeries S/390 64 bit

SPARCback to summary
public static final StubLoader.CPU SPARC

Sun sparc 32 bit

SPARCV9back to summary
public static final StubLoader.CPU SPARCV9

Sun sparc 64 bit

UNKNOWNback to summary
public static final StubLoader.CPU UNKNOWN

Unknown CPU

X86_64back to summary
public static final StubLoader.CPU X86_64

AMD 64 bit (aka EM64T/X64)

Constructor Detail

CPUback to summary
private CPU()

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static StubLoader.CPU valueOf(String name)
valuesback to summary
public static StubLoader.CPU[] values()
com.kenai.jffi.internal back to summary

public final Enum StubLoader.OS

extends Enum<StubLoader.OS>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final StubLoader.OS
AIX

IBM AIX

public static final StubLoader.OS
DARWIN

MacOSX

public static final StubLoader.OS
DRAGONFLY

DragonFly

public static final StubLoader.OS
FREEBSD

FreeBSD

public static final StubLoader.OS
IBMI

IBM i

public static final StubLoader.OS
LINUX

Linux

public static final StubLoader.OS
NETBSD

NetBSD

public static final StubLoader.OS
OPENBSD

OpenBSD

public static final StubLoader.OS
SOLARIS

Solaris (and OpenSolaris)

public static final StubLoader.OS
UNKNOWN

No idea what the operating system is

public static final StubLoader.OS
WINDOWS

The evil borg operating system

public static final StubLoader.OS
ZLINUX

IBM zOS

Constructor Summary

AccessConstructor and Description
private
OS()

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static StubLoader.OS
public static StubLoader.OS[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

AIXback to summary
public static final StubLoader.OS AIX

IBM AIX

DARWINback to summary
public static final StubLoader.OS DARWIN

MacOSX

DRAGONFLYback to summary
public static final StubLoader.OS DRAGONFLY

DragonFly

FREEBSDback to summary
public static final StubLoader.OS FREEBSD

FreeBSD

IBMIback to summary
public static final StubLoader.OS IBMI

IBM i

LINUXback to summary
public static final StubLoader.OS LINUX

Linux

NETBSDback to summary
public static final StubLoader.OS NETBSD

NetBSD

OPENBSDback to summary
public static final StubLoader.OS OPENBSD

OpenBSD

SOLARISback to summary
public static final StubLoader.OS SOLARIS

Solaris (and OpenSolaris)

UNKNOWNback to summary
public static final StubLoader.OS UNKNOWN

No idea what the operating system is

WINDOWSback to summary
public static final StubLoader.OS WINDOWS

The evil borg operating system

ZLINUXback to summary
public static final StubLoader.OS ZLINUX

IBM zOS

Constructor Detail

OSback to summary
private OS()

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static StubLoader.OS valueOf(String name)
valuesback to summary
public static StubLoader.OS[] values()