|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cryptix.provider.md.NativeLink
A class to handle loading and versioning of native code in a VM-independent way.
SECURITY: this class must be package-private, and not accessible to untrusted code. Therefore the source file must be copied to each package that needs it, with the package statement adjusted accordingly. Make sure that any changes are reflected in all copies.
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.10 $
Constructor Summary | |
(package private) |
NativeLink(java.lang.String libname,
int major,
int minor)
Constructs a NativeLink object that can be used to load the given native library. |
Method Summary | |
(package private) static void |
|
(package private) boolean |
attemptLoad()
Tries to load the native library, if it is enabled. |
(package private) void |
check(java.lang.String reason)
If reason is null, this method returns silently. |
void |
checkNative()
Checks that the native library is being used (i.e. it loaded successfully, has valid version numbers, and has not been disabled). |
(package private) void |
checkVersion(int major,
int minor)
Sets the actual major and minor version numbers of the library. |
(package private) void |
fail(java.lang.Throwable e)
Marks the library as having failed a test. |
java.lang.String |
getLibraryName()
Returns the library name. |
java.lang.String |
getLinkErrorString()
Returns an error string describing why the library failed to load, or null if there was no error. |
int |
getMajorVersion()
Returns the actual major version number. |
int |
getMinorVersion()
Returns the actual minor version number. |
int |
getRequiredMajorVersion()
Returns the required major version number. |
int |
getRequiredMinorVersion()
Returns the required minor version number. |
boolean |
isLibraryCorrect()
Returns true if the library was loaded successfully. |
boolean |
isLibraryLoaded()
Returns true if the library was loaded. |
void |
setNative(boolean wanted)
Enables or disables the native code. |
boolean |
useNative()
Returns true if native code is being used. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
NativeLink(java.lang.String libname, int major, int minor)
libname
- the library namemajor
- the required major version numberminor
- the required minor version numberMethod Detail |
static void()
public int getRequiredMajorVersion()
LinkStatus
getRequiredMajorVersion
in interface LinkStatus
public int getRequiredMinorVersion()
LinkStatus
getRequiredMinorVersion
in interface LinkStatus
public java.lang.String getLibraryName()
LinkStatus
getLibraryName
in interface LinkStatus
public int getMajorVersion()
LinkStatus
getMajorVersion
in interface LinkStatus
public int getMinorVersion()
LinkStatus
getMinorVersion
in interface LinkStatus
public boolean isLibraryLoaded()
LinkStatus
isLibraryLoaded
in interface LinkStatus
public boolean isLibraryCorrect()
LinkStatus
isLibraryCorrect
in interface LinkStatus
public java.lang.String getLinkErrorString()
LinkStatus
getLinkErrorString
in interface LinkStatus
cryptix.util.core.LinkStatus
void checkVersion(int major, int minor)
The major version must match the required major version exactly, and the minor version must be at least the required minor version, in order for the library to be compatible.
major
- the actual major version numberminor
- the actual minor version numbervoid check(java.lang.String reason)
This is useful for handling native methods that return null on success, or an error String on failure.
reason
- either null or an error messagevoid fail(java.lang.Throwable e)
e
- the exception that was thrown to indicate the failure.public void checkNative()
LinkStatus
checkNative
in interface LinkStatus
cryptix.util.core.LinkStatus
java.lang.UnsatisfiedLinkError
- if the library is not being usedpublic boolean useNative()
LinkStatus
useNative
in interface LinkStatus
public void setNative(boolean wanted)
LinkStatus
setNative
in interface LinkStatus
cryptix.util.core.LinkStatus
enable
- true if native code should be used.boolean attemptLoad()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |