java

package java
Supporting services for the FFI with Java and to access Java libraries

Concerns

  • java: Supporting services for the FFI with Java and to access Java libraries
    • ffi_support: Core supporting services for the FFI with Java
    • collections: Basic Java collections
    • io: Services from the java.io package
    • java: Supporting services for the FFI with Java and to access Java libraries

java::ffi_support

module ffi_support

Core supporting services for the FFI with Java

This module must be imported by modules using the Java FFI. Some might prefer to import the whole java package as it provides other useful services.

Redefines
  • Sys: The main class of the program.
  • JavaObject: Represens a jni jobject
  • JniEnv: Represents a jni JNIEnv, which is a thread in a JavaVM
  • CString: C string char *
  • Text: High-level abstraction for all text representations

java::collections

module collections

Basic Java collections

var coll = new JavaArray(2)

assert coll[0].is_java_null
coll[0] = "zero".to_java_string
coll[1] = "one".to_java_string

assert coll.length == 2
assert coll.first.to_s == "zero"
assert coll[1].to_s == "one"
assert [for e in coll do e.to_s] == ["zero", "one"]

java::java

module java

Supporting services for the FFI with Java and to access Java libraries

This modules relies on Sys::jvm, Sys::jni_env and Sys::create_default_jvm to get a handle on a JVM. You can adapt the behavior of the FFI and services in this module by redefing Sys::create_default_jvm and supply your own JVM object. You can manage multiple java thread by switching the current environment in a redef of Sys::jni_env, and multiple JVM using Sys::jvm.

See also, the module jvm to control the JVM instances and access JNI functions. You can use it to further customize the behavior of your code.