jasper_initialize(
-JVM)
jasper_initialize(
+Options,
-JVM)
classpath(<classpath>)
<classpath>
is an atom it will be added (unmodified) to
the Java VM's classpath. If <classpath>
is a list, each
element will be expanded using absolute_file_name/2
and
concatenated using the Java VM's path-separator. Example:
classpath([library('jasper/examples'),'$HOME/joe'])
In addition to the classpaths specified here, Jasper will automatically
add jasper.jar
to the classpath together with the contents of the
CLASSPATH environment variable.
if_exists(
option)
jasper_initialize
or because
Prolog have been called from Java. If a JVM already exists then the
other options are ignored.
ok
fail
jasper_initialize/2
fails.
error
jasper_initialize/2
throws an exception
(java_exception(
some text)
).
if_not_exists(
option)
ok
fail
jasper_initialize/2
fails.
error
jasper_initialize/2
throws an exception
(java_exception(
some text)
).
As an example, to access the currently running JVM and to give an error
if there is no running JVM use
jasper_initialize([if_exists(ok),if_not_exists(error)], JVM)
.
jasper_initialize(['-Dkenny.is.dead=42'],JVM),
There is currently no support for creating multiple JVMs (few JDKs, if
any, supports this).
jasper_deinitialize(
+JVM)
De-initialize Java. Do not call this, current versions of the JVM does
not support deinitialization.
jasper_call(
+JVM,
+Method,
+TypeInfo,
+Args)
jasper_initialize/[1,2]
.
Note that for an instance method the first argument must be an
object reference (specified with +object(
Class)
). In this
case the class is ignored but should still be an atom, e.g.
''
.
method(
ClassName,
MethodName,
Flags)
that identifies the method to call.
java/lang/String
) of the object or where to look for the static
method. Note that you need to surround the atom with single
quotes since it contains /
characters. The class is ignored when
calling instance methods but should still be an atom, e.g.
''
.
[instance]
for
instance methods and [static]
for static methods.
jasper_new_object(
+JVM,
+ClassName,
+TypeInfo,
+Args,
-Object)
See jasper_call/4
above for an explanation of the arguments
JVM, ClassName, TypeInfo and Args.
As an example, the following code creates a
java/lang/Integer
object initialized from a string of digits. It
then calls the instance method doubleValue
to obtain the floating
point representation of the Integer.
| ?- Chars = "4711", %% get existing JVM jasper_initialize([if_not_exists(error)], JVM), jasper_new_object(JVM, 'java/lang/Integer', init(+chars), init(Chars), S), jasper_call(JVM, method('java/lang/Integer', doubleValue, [instance]), to_double(+object('java/lang/Integer'), [-double]), to_double(S,X)). S = '$java_object'(135875344), X = 4711.0, % note that this is now a floating point number JVM = '$jvm'(1076414148), Chars = [52,55,49,49] % a.k.a. "4711"
jasper_create_global_ref(
+JVM,
+Ref,
-GlobalRef)
jasper_delete_global_ref(
+JVM,
+GlobalRef)
jasper_create_local_ref(
+JVM,
+Ref,
-LocalRef)
jasper_delete_local_ref(
+JVM,
+GlobalRef)
jasper_is_jvm(
+JVM)
jasper_is_object(
+Object)
jasper_is_object(
+JVM,
+Object)
jasper_is_object/1
to recognize objects instead of relying on the
internal representation. Currently the JVM argument is
ignored. If, and when, multiple JVMs becomes a possibility
jasper_is_object/2
will verify that Object is an object in
a particular JVM.
jasper_is_same_object(
+JVM,
+Object1,
+Object2)
==/2
can
not be used to reliably detect if two object references refer to
the same object.
jasper_is_instance_of(
+JVM,
+Object,
+ClassName)
jasper_call/4
.
jasper_object_class_name(
+JVM,
+Object,
-ClassName)
Returns the fully qualified name of the class of +Object as an
atom.
jasper_null(
+JVM,
-NullRef)
Create a null object reference.
jasper_is_null(
+JVM,
+Ref)
Succeeds if Ref is a null object reference, fails otherwise, e.g. if Ref is not an object reference.