Limitations
Limited complex return types
Mosel can only directly understand basic Java data-types: boolean, integer, real, string and text. Although your method can return any Java class into a 'jvmobject' variable, the main operations you can do with the object are turning it into a text/string or passing it back to a static Java method.
If you need to return a large data-set then your options would be to format it in some standard format (e.g. CSV, XML, JSON), and return it as 'text' then use Mosel's standard modules to parse it, or to write it to a file that can be read later by the Mosel model.
Arguments passed by value
Method arguments are input-only—so when you make changes to an array from within a Java function, this does not affect the array in the Mosel model. Similarly when you pass a Mosel text object, it becomes a Java String and cannot be modified from Java.
Standard output streams
If you send output to the Java stream System.out within a Java method called through mosjvm, the output will be sent to the Mosel model's standard output stream. However, if the Java virtual machine generates output from a different thread, this will not be captured by any Mosel stream.
Similarly, output you send to System.err will go to the the Mosel model's error stream. If another thread generates output to System.err, it will be sent to the Mosel instance's error stream.
Working directories
The initial working directory of the Java virtual machine will be the working directory of the Mosel process; this may be different from the working directories of the Mosel models (controlled by the workdir parameter). When passing filenames between the Mosel and Java environments, it is recommended to always use absolute paths.
Static methods only
mosjvm can only be used to call public static methods. It is not possible to call instance methods on a Java object directly from a Mosel model.
JVM shut down
In normal usage, once the Java virtual machine has started up, it will not be shut down until the Mosel process exits.
Incompatible with com.dashoptimization.XPRM
If you are calling Mosel using the Mosel Java Library classes in the com.dashoptimization package, you cannot use the mosjvm module.
Incompatible with other JVMs
The mosjvm module can only interact with a Java virtual machine that it itself has started. If there is already a Java virtual machine running in the Mosel process, attempting to use the mosjvm module will result in an error.
Supported Java version
The mosjvm module is only supported with Oracle or OpenJDK Java 8. It has not been tested with other versions of Java.
Window and Linux only
The mosjvm module is only available with Windows and Linux versions of Xpress. It is not available for other platforms.
Limited ThreadLocal value support
By default, every Java call made using the mosjvm module occurs in a separate Java thread that is terminated after the Java method completes. This means that you cannot use ThreadLocal objects to share values between multiple jvmcall<type> invocations from the same model. However, if you force Java calls from Mosel to fire on the same Java thread by using the jvmattachthread procedure, then ThreadLocal values can be used.
Not supported in FICO Analytic Cloud
The use of mosjvm is not supported by applications running within the FICO Analytic Cloud.
System.exit may not be called
Calling System.exit from the JVM started by mosjvm will not work; an exception will be thrown.