Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.cldc.jna
Class NativeLibrary

    java.lang.Object
      com.sun.cldc.jna.NativeLibrary

    public class NativeLibrary

extends Object

Represents a handle to a runtime library (for example, as returned by the POSIX function "dlopen" http://www.opengroup.org/onlinepubs/009695399/functions/dlopen.html

### Differences from JNA

- Throws RuntimeExceptions instead of UnsatisfiedLinkErrors. Are link errors really "unrecoverable"? Platform independant code might want to work around missing functions.
- Search paths unimplemented
- Calling conventions unimplemented
- no finalization in cldc, need to call dispose() explicitly (could add a shutdownhook though).
- no parseVersion();
- no getFile()

Method Summary
`void` | `dispose()` Close the library, as in dlclose.
`static String` | `errorStr()` Get any error message provided by the platform (as in dlerror).
`BlockingFunction` | `getBlockingFunction(String funcName)` Dynamically look up a blocking native function by name.
`static NativeLibrary` | `getDefaultInstance()` Return reference to the "default" library.
`Function` | `getFunction(String funcName)` Dynamically look up a native function by name.
`VarPointer` | `getGlobalVariableAddress(String varName, int size)` Dynamically look up a native variable by name.
`static NativeLibrary` | `getInstance(String name)` Look up a native libray named "name".
`String` | `toString()` Returns a string representation of the object.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getFunction

    public Function getFunction(String funcName)

  Dynamically look up a native function by name. WARNING: Do NOT use for calling C functions that may block (or take a "long" time). Use the "blocking" version instead. Look up the symbol in the specified library

  Parameters:
    `funcName` -
  Returns:
    an object that can be used to call the named function
  Throws:
    `RuntimeException` - if there is no function by that name.

### getBlockingFunction

    public BlockingFunction getBlockingFunction(String funcName)

  Dynamically look up a blocking native function by name. Look up the symbol in the specified library

  Parameters:
    `funcName` -
  Returns:
    an object that can be used to call the named function
  Throws:
    `RuntimeException` - if there is no function by that name.

### getGlobalVariableAddress

    public VarPointer getGlobalVariableAddress(String varName,
                                               int size)

  Dynamically look up a native variable by name. Look up the symbol in the default list of loaded libraries.

  Parameters:
    `varName` -
    `size` - the size of the variable in bytes
  Returns:
    an objecta that can be used to call the named function
  Throws:
    `RuntimeException` - if there is no function by that name.

### getInstance

    public static NativeLibrary getInstance(String name)

  Look up a native libray named "name". Load if not loaded. Name can be a path or a libray name. The Library will be looked up in a platform-dependant manor.

  Parameters:
    `name` - short library name, full file name, or path to the library file
  Returns:
    NativeLibrary

### getDefaultInstance

    public static NativeLibrary getDefaultInstance()

  Return reference to the "default" library. All lookups in the default library will follow the platform's default getFunction semantics. The Library will be looked up in a platform-dependant maner.

  Returns:
    NativeLibrary

### dispose

    public void dispose()

  Close the library, as in dlclose.

  Throws:
    `RuntimeException` - if dlcose fails

### errorStr

    public static String errorStr()

  Get any error message provided by the platform (as in dlerror). If no error, then return null. Note that calling this method clears the error state, so calling two times without calling any other platform getFunction method (getInstance(), getFunction(), getGlobalVariableAddress(), dispose()) will result in returning null.

  Returns:
    String (may be null)

### toString

    public String toString()

  Description copied from class: `Object`
  Returns a string representation of the object. In general, the `toString` method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

  The `toString` method for class `Object` returns a string consisting of the name of the class of which the object is an instance, the at-sign character ``@`', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

  >      getClass().getName() + '@' + Integer.toHexString(hashCode())

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of the object.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"