core :: Sys :: create_default_jvm
jvm
and jni_env
to instantiate a Java Virtual Machine.Used mostly for the FFI with Java.
# Called by `jvm` and `jni_env` to instantiate a Java Virtual Machine.
# Used mostly for the FFI with Java.
protected fun create_default_jvm
do
var builder = new JavaVMBuilder
# By default, look for Java classes in a jar file the same directory as the executable
builder.options.add "-Djava.class.path={sys.program_name}.jar"
var jvm = builder.create_jvm
assert jvm != null else print "JVM creation failed"
self.jvm = jvm
assert not jvm.address_is_null
self.jni_env = jvm.env
assert not jni_env.address_is_null
end
lib/java/ffi_support.nit:55,2--71,4
# We cannot create a JVM on Android
#
# This method is not reachable on this platform anyway.
# `Sys::jvm` is implemented by the main activity modules.
redef fun create_default_jvm do abort
lib/android/dalvik.nit:34,2--38,38