GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-java.cc File Reference

Provides Octave's Java interface. More...

#include <algorithm>
#include <array>
#include <fstream>
#include <map>
#include <string>
#include <vector>
#include <clocale>
#include "Cell.h"
#include "builtin-defun-decls.h"
#include "cmd-edit.h"
#include "defaults.h"
#include "defun.h"
#include "error.h"
#include "errwarn.h"
#include "file-ops.h"
#include "file-stat.h"
#include "fpucw-wrappers.h"
#include "interpreter.h"
#include "interpreter-private.h"
#include "load-path.h"
#include "lo-sysdep.h"
#include "oct-env.h"
#include "oct-process.h"
#include "oct-shlib.h"
#include "ov-java.h"
#include "parse.h"
#include "variables.h"
#include <jni.h>
Include dependency graph for ov-java.cc:

Go to the source code of this file.

Classes

class  java_local_ref< T >
 
class  JVMArgs
 

Macros

#define BOX_PRIMITIVE_ARRAY(JAVA_TYPE, JAVA_ID, JAVA_TYPE_CAP, OCTAVE_ID)
 
#define LIBJVM_FILE_NAME   "libjvm.so"
 
#define TO_JAVA(obj)   dynamic_cast<octave_java *> ((obj).internal_rep ())
 
#define TO_JCLASS(obj)   reinterpret_cast<jclass> (obj)
 
#define TO_JNIENV(env)   reinterpret_cast<JNIEnv *> (env)
 
#define TO_JOBJECT(obj)   reinterpret_cast<jobject> (obj)
 
#define UNBOX_PRIMITIVE_ARRAY(METHOD_T, OCTAVE_T, JAVA_T, JAVA_T_CAP)
 
#define UNBOX_PRIMITIVE_SCALAR(OCTAVE_T, METHOD_T, JAVA_T, JAVA_CON)
 

Typedefs

typedef java_local_ref< jbyteArray > jbyteArray_ref
 
typedef java_local_ref< jclass > jclass_ref
 
typedef java_local_ref< jdoubleArray > jdoubleArray_ref
 
typedef java_local_ref< jintArray > jintArray_ref
 
typedef jint(JNICALL * JNI_CreateJavaVM_t) (JavaVM **pvm, JNIEnv **penv, void *args)
 
typedef jint(JNICALL * JNI_GetCreatedJavaVMs_t) (JavaVM **pvm, jsize bufLen, jsize *nVMs)
 
typedef java_local_ref< jobject > jobject_ref
 
typedef java_local_ref< jobjectArray > jobjectArray_ref
 
typedef java_local_ref< jstring > jstring_ref
 
typedef java_local_ref< jthrowable > jthrowable_ref
 

Functions

static octave_value box (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg)
 Convert the Java object pointed to by jobj_arg with class jcls_arg to an Octave value. More...
 
static octave_value box_more (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg=nullptr)
 
static octave_value check_exception (JNIEnv *jni_env)
 
static dim_vector compute_array_dimensions (JNIEnv *jni_env, jobject obj)
 
static octave_value convert_to_string (JNIEnv *jni_env, jobject m_java_object, bool force, char type)
 
OCTAVE_EXPORT octave_value_list F__java2mat__ (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list F__java_exit__ (const octave_value_list &, int)
 
OCTAVE_EXPORT octave_value_list F__java_get__ (const octave_value_list &args, int)
 
OCTAVE_NAMESPACE_BEGIN OCTAVE_EXPORT octave_value_list F__java_init__ (const octave_value_list &, int)
 
OCTAVE_EXPORT octave_value_list F__java_set__ (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fdebug_java (const octave_value_list &args, int nargout)
 
static jclass find_octave_class (JNIEnv *jni_env, const char *name)
 
OCTAVE_EXPORT octave_value_list Fisjava (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list Fjava_matrix_autoconversion (const octave_value_list &args, int nargout)
 
OCTAVE_EXPORT octave_value_list Fjava_unsigned_autoconversion (const octave_value_list &args, int nargout)
 
OCTAVE_EXPORT octave_value_list FjavaMethod (const octave_value_list &args, int)
 
OCTAVE_EXPORT octave_value_list FjavaObject (const octave_value_list &args, int)
 
static octave_value get_array_elements (JNIEnv *jni_env, jobject jobj, const octave_value_list &idx)
 
static long get_current_thread_ID (JNIEnv *jni_env)
 Returns the id of the current thread. More...
 
static string_vector get_invoke_list (JNIEnv *jni_env, void *jobj_arg)
 
static std::string get_jvm_lib_path_in_subdir (std::string java_home_path)
 
static std::string initial_class_path (void)
 Return the initial classpath. More...
 
static OCTAVE_NAMESPACE_END std::string initial_java_dir (void)
 The java initialization directory is given by the environment variable OCTAVE_JAVA_DIR if defined; otherwise it is the directory of Octave's m-files defining Java functions. More...
 
static void initialize_java (void)
 Initialize java including the virtual machine (jvm) if necessary. More...
 
static void initialize_jvm (void)
 Initialize the java virtual machine (jvm) and field jvm if necessary. More...
 
static bool is_auto_convertible_number (JNIEnv *jni_env, jobject jobj)
 Return whether jobj shall be automatically converted to an Octave numeric value. More...
 
static int java_event_hook (void)
 Run the java method org.octave.Octave.checkPendingAction(). More...
 
JNIEXPORT jboolean JNICALL Java_org_octave_Octave_call (JNIEnv *, jclass, jstring, jobjectArray, jobjectArray)
 
JNIEXPORT void JNICALL Java_org_octave_Octave_doEvalString (JNIEnv *, jclass, jstring)
 
JNIEXPORT void JNICALL Java_org_octave_Octave_doInvoke (JNIEnv *, jclass, jint, jobjectArray)
 
JNIEXPORT jboolean JNICALL Java_org_octave_Octave_needThreadedInvokation (JNIEnv *, jclass)
 
JNIEXPORT void JNICALL Java_org_octave_OctaveReference_doFinalize (JNIEnv *, jclass, jint)
 
static std::string jstring_to_string (JNIEnv *jni_env, jobject obj)
 
static std::string jstring_to_string (JNIEnv *jni_env, jstring s)
 Converts a Java string object to std::string. More...
 
static jobject make_java_index (JNIEnv *jni_env, const octave_value_list &idx)
 
static std::string read_classpath_txt (const std::string &filepath)
 Return the classpath in the given file filepath as a string. More...
 
static octave_value set_array_elements (JNIEnv *jni_env, jobject jobj, const octave_value_list &idx, const octave_value &rhs)
 
static void terminate_jvm (void)
 Terminate the current jvm, if there is any. More...
 
static JNIEnv * thread_jni_env (void)
 } More...
 
static bool unbox (JNIEnv *jni_env, const octave_value &val, jobject_ref &jobj, jclass_ref &jcls)
 
static bool unbox (JNIEnv *jni_env, const octave_value_list &args, jobjectArray_ref &jobjs, jobjectArray_ref &jclss)
 

Variables

static JavaVM * jvm = nullptr
 The pointer to a java virtual machine either created in the current thread or attached this thread to it. More...
 
static bool jvm_attached = false
 Whether the current thread is attached to the jvm given by jvm. More...
 
static octave::dynamic_library jvm_lib
 Need to keep hold of the shared library handle until exit. More...
 
static std::map< int, octave_valuelistener_map
 
static int octave_java_refcount = 0
 
static std::map< int, octave_valueoctave_ref_map
 
static long octave_thread_ID = -1
 The thread id of the currently executing thread or -1 if this is unknown. More...
 
bool Vdebug_java = false
 
bool Vjava_matrix_autoconversion = false
 
bool Vjava_unsigned_autoconversion = true
 

Detailed Description

Provides Octave's Java interface.

Definition in file ov-java.cc.

Macro Definition Documentation

◆ BOX_PRIMITIVE_ARRAY

#define BOX_PRIMITIVE_ARRAY (   JAVA_TYPE,
  JAVA_ID,
  JAVA_TYPE_CAP,
  OCTAVE_ID 
)
Value:
cls = jni_env->FindClass (JAVA_ID); \
if (jni_env->IsInstanceOf (jobj, cls)) \
{ \
const JAVA_TYPE ## Array jarr = reinterpret_cast<JAVA_TYPE ## Array> (jobj); \
const jsize len = jni_env->GetArrayLength (jarr); \
OCTAVE_ID ## NDArray d (dim_vector (len, 1)); \
JAVA_TYPE *buffer = reinterpret_cast<JAVA_TYPE *> (d.fortran_vec ()); \
jni_env->Get ## JAVA_TYPE_CAP ## ArrayRegion (jarr, 0, len, buffer); \
retval = d; \
break; \
}
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:129
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T len
Definition: xerbla.cc:61

◆ LIBJVM_FILE_NAME

#define LIBJVM_FILE_NAME   "libjvm.so"

Definition at line 83 of file ov-java.cc.

◆ TO_JAVA

#define TO_JAVA (   obj)    dynamic_cast<octave_java *> ((obj).internal_rep ())

Definition at line 1327 of file ov-java.cc.

◆ TO_JCLASS

#define TO_JCLASS (   obj)    reinterpret_cast<jclass> (obj)

Definition at line 87 of file ov-java.cc.

◆ TO_JNIENV

#define TO_JNIENV (   env)    reinterpret_cast<JNIEnv *> (env)

Definition at line 89 of file ov-java.cc.

◆ TO_JOBJECT

#define TO_JOBJECT (   obj)    reinterpret_cast<jobject> (obj)

Definition at line 86 of file ov-java.cc.

◆ UNBOX_PRIMITIVE_ARRAY

#define UNBOX_PRIMITIVE_ARRAY (   METHOD_T,
  OCTAVE_T,
  JAVA_T,
  JAVA_T_CAP 
)
Value:
do \
{ \
const OCTAVE_T ## NDArray v = val.METHOD_T ## array_value (); \
JAVA_T ## Array jarr = jni_env->New ## JAVA_T_CAP ## Array (v.numel ()); \
const JAVA_T *jv = reinterpret_cast<const JAVA_T *> (v.data ()); \
jni_env->Set ## JAVA_T_CAP ## ArrayRegion (jarr, 0, v.numel (), jv); \
jobj = reinterpret_cast<jobject> (jarr); \
jcls = jni_env->GetObjectClass (jobj); \
} \
while (0)
class OCTARRAY_API Array
Definition: Array-fwd.h:40

◆ UNBOX_PRIMITIVE_SCALAR

#define UNBOX_PRIMITIVE_SCALAR (   OCTAVE_T,
  METHOD_T,
  JAVA_T,
  JAVA_CON 
)
Value:
do \
{ \
const OCTAVE_T ov = val.METHOD_T ## _value (); \
jclass_ref dcls (jni_env, jni_env->FindClass (JAVA_T)); \
const jfieldID fid = jni_env->GetStaticFieldID (dcls, "TYPE", "Ljava/lang/Class;"); \
const jmethodID mid = jni_env->GetMethodID (dcls, "<init>", JAVA_CON); \
jcls = reinterpret_cast<jclass> (jni_env->GetStaticObjectField (dcls, fid)); \
jobj = jni_env->NewObject (dcls, mid, ov); \
} \
while (0)

Typedef Documentation

◆ jbyteArray_ref

typedef java_local_ref<jbyteArray> jbyteArray_ref

Definition at line 152 of file ov-java.cc.

◆ jclass_ref

typedef java_local_ref<jclass> jclass_ref

Definition at line 148 of file ov-java.cc.

◆ jdoubleArray_ref

typedef java_local_ref<jdoubleArray> jdoubleArray_ref

Definition at line 153 of file ov-java.cc.

◆ jintArray_ref

typedef java_local_ref<jintArray> jintArray_ref

Definition at line 151 of file ov-java.cc.

◆ JNI_CreateJavaVM_t

typedef jint(JNICALL * JNI_CreateJavaVM_t) (JavaVM **pvm, JNIEnv **penv, void *args)

Definition at line 91 of file ov-java.cc.

◆ JNI_GetCreatedJavaVMs_t

typedef jint(JNICALL * JNI_GetCreatedJavaVMs_t) (JavaVM **pvm, jsize bufLen, jsize *nVMs)

Definition at line 94 of file ov-java.cc.

◆ jobject_ref

typedef java_local_ref<jobject> jobject_ref

Definition at line 147 of file ov-java.cc.

◆ jobjectArray_ref

typedef java_local_ref<jobjectArray> jobjectArray_ref

Definition at line 150 of file ov-java.cc.

◆ jstring_ref

typedef java_local_ref<jstring> jstring_ref

Definition at line 149 of file ov-java.cc.

◆ jthrowable_ref

typedef java_local_ref<jthrowable> jthrowable_ref

Definition at line 154 of file ov-java.cc.

Function Documentation

◆ box()

static octave_value box ( JNIEnv *  jni_env,
void *  jobj_arg,
void *  jcls_arg 
)
static

Convert the Java object pointed to by jobj_arg with class jcls_arg to an Octave value.

Parameters
jni_envJNI environment pointer.
jobj_argPointer to a Java object.
jcls_argOptional pointer to the Java class of jobj_arg.
Returns
  • numeric value as a double if jobj_arg is of type Byte, Short, Integer, Long, Float or Double
  • logical value if jobj_arg is of type Boolean
  • string value if jobj_arg is of type Character or String
  • Octave array of numeric, logical, or char type if jobj_arg is a Java array of primitive types
  • Octave matrix if jobj_arg is of type org.octave.Matrix and Vjava_matrix_autoconversion is enabled
  • Octave object if jobj_arg is of type org.octave.OctaveReference
  • octave_java object wrapping the Java object otherwise.

Definition at line 1386 of file ov-java.cc.

References BOX_PRIMITIVE_ARRAY, octave_value::convert_to_str(), find_octave_class(), Array< T, Alloc >::fortran_vec(), is_auto_convertible_number(), octave_value::is_undefined(), jstring_to_string(), Matrix, dim_vector::ndims(), Array< T, Alloc >::numel(), octave_ref_map, octave_value(), dim_vector::resize(), TO_JCLASS, TO_JOBJECT, Vjava_matrix_autoconversion, and Vjava_unsigned_autoconversion.

Referenced by octave::CheckBoxControl::CheckBoxControl(), octave::PopupMenuControl::PopupMenuControl(), box_more(), octave_java::do_java_get(), octave_java::do_javaMethod(), get_array_elements(), Java_org_octave_Octave_call(), Java_org_octave_Octave_doInvoke(), octave::ft_text_renderer::render(), set_array_elements(), octave::shortcut_manager::shortcut_dialog(), octave::ft_text_renderer::text_to_pixels(), octave::ft_text_renderer::text_to_strlist(), octave::CheckBoxControl::update(), and octave::PopupMenuControl::update().

◆ box_more()

static octave_value box_more ( JNIEnv *  jni_env,
void *  jobj_arg,
void *  jcls_arg = nullptr 
)
static

◆ check_exception()

◆ compute_array_dimensions()

static dim_vector compute_array_dimensions ( JNIEnv *  jni_env,
jobject  obj 
)
static

◆ convert_to_string()

static octave_value convert_to_string ( JNIEnv *  jni_env,
jobject  m_java_object,
bool  force,
char  type 
)
static

◆ F__java2mat__()

OCTAVE_EXPORT octave_value_list F__java2mat__ ( const octave_value_list args,
int   
)

◆ F__java_exit__()

OCTAVE_EXPORT octave_value_list F__java_exit__ ( const octave_value_list ,
int   
)

Definition at line 3067 of file ov-java.cc.

References err_disabled_feature(), ovl(), and terminate_jvm().

◆ F__java_get__()

◆ F__java_init__()

OCTAVE_NAMESPACE_BEGIN OCTAVE_EXPORT octave_value_list F__java_init__ ( const octave_value_list ,
int   
)

Definition at line 3041 of file ov-java.cc.

References err_disabled_feature(), and initialize_java().

◆ F__java_set__()

◆ Fdebug_java()

OCTAVE_EXPORT octave_value_list Fdebug_java ( const octave_value_list args,
int  nargout 
)

Definition at line 3447 of file ov-java.cc.

References err_disabled_feature(), set_internal_variable(), and Vdebug_java.

◆ find_octave_class()

static jclass find_octave_class ( JNIEnv *  jni_env,
const char *  name 
)
static

◆ Fisjava()

OCTAVE_EXPORT octave_value_list Fisjava ( const octave_value_list args,
int   
)

Definition at line 3472 of file ov-java.cc.

References ovl(), and print_usage().

◆ Fjava_matrix_autoconversion()

OCTAVE_EXPORT octave_value_list Fjava_matrix_autoconversion ( const octave_value_list args,
int  nargout 
)

◆ Fjava_unsigned_autoconversion()

OCTAVE_EXPORT octave_value_list Fjava_unsigned_autoconversion ( const octave_value_list args,
int  nargout 
)

◆ FjavaMethod()

◆ FjavaObject()

OCTAVE_EXPORT octave_value_list FjavaObject ( const octave_value_list args,
int   
)

◆ get_array_elements()

static octave_value get_array_elements ( JNIEnv *  jni_env,
jobject  jobj,
const octave_value_list idx 
)
static

◆ get_current_thread_ID()

static long get_current_thread_ID ( JNIEnv *  jni_env)
static

Returns the id of the current thread.

Parameters
jni_envThe current environment or nullptr.
Returns
The id of the current thread or -1 otherwise. The latter happens if jni_env is nullptr, for example.

Definition at line 1950 of file ov-java.cc.

Referenced by initialize_java(), and Java_org_octave_Octave_needThreadedInvokation().

◆ get_invoke_list()

static string_vector get_invoke_list ( JNIEnv *  jni_env,
void *  jobj_arg 
)
static

◆ get_jvm_lib_path_in_subdir()

static std::string get_jvm_lib_path_in_subdir ( std::string  java_home_path)
static

Definition at line 512 of file ov-java.cc.

References LIBJVM_FILE_NAME.

Referenced by initialize_jvm().

◆ initial_class_path()

static std::string initial_class_path ( void  )
static

Return the initial classpath.

The initial classpath starts with a pointer to octave.jar which is located in the initial java directory given by #java_init_dir().

Attention
This is nowhere documented and also the script javaclasspath.m drops this. On the other hand, this is vital because octave.jar contains the java core classes of octave's java interface.

The rest of the classpath is read sequentially from files javaclasspath.txt located in either:

  • the current directory,
  • the user's home directory,
  • the initial java directory returned by initial_java_dir()
Returns
The initial classpath.

Definition at line 423 of file ov-java.cc.

References octave::sys::file_ops::dir_sep_str(), error(), octave::sys::env::get_current_directory(), octave::sys::env::get_home_directory(), initial_java_dir(), read_classpath_txt(), and octave::sys::file_ops::tilde_expand().

Referenced by initialize_jvm().

◆ initial_java_dir()

static OCTAVE_NAMESPACE_END std::string initial_java_dir ( void  )
static

The java initialization directory is given by the environment variable OCTAVE_JAVA_DIR if defined; otherwise it is the directory of Octave's m-files defining Java functions.

The Java initialization directory is the directory where resides:

  • octave.jar, defining the java classes implementing octave's java interface,
  • javaclasspath.txt, defining the installation defined portion of the (static) classpath,
  • java.opts, defining the configurable options of the java virtual machine.

Note that the (static) java classpath of the java virtual machine starts with octave.jar, and that the static java classpath ends with what is read from javaclasspath.txt located in the initial java directory. Moreover, the java virtual machine is created essentially with the options given by java.opts.

Definition at line 344 of file ov-java.cc.

References octave::sys::file_ops::dir_sep_str(), config::fcn_file_dir(), and octave::sys::env::getenv().

Referenced by initial_class_path(), and initialize_jvm().

◆ initialize_java()

static void initialize_java ( void  )
static

Initialize java including the virtual machine (jvm) if necessary.

Initializes the fields jvm, jvm_attached, jvm_lib, and octave_thread_ID. To ensure that java is initialized, this method is used as part of octave functions javaObject, javaMethod, __java_get__, __java_set__, and __java2mat__.

Definition at line 2005 of file ov-java.cc.

References octave::command_editor::add_event_hook(), error(), get_current_thread_ID(), initialize_jvm(), java_event_hook(), jvm, octave_set_default_fpucw(), octave_thread_ID, and thread_jni_env().

Referenced by F__java2mat__(), F__java_get__(), F__java_init__(), F__java_set__(), FjavaMethod(), and FjavaObject().

◆ initialize_jvm()

static void initialize_jvm ( void  )
static

Initialize the java virtual machine (jvm) and field jvm if necessary.

If the jvm exists and is initialized, jvm points to it, i.e. is not 0 and there is nothing to do.

If jvm is 0 and if at least one jvm exists, attach the current thread to it by setting jvm_attached. Otherwise, create a jvm with some hard- coded options:

Further options are read from the file java.opts in the directory given by #java_init_dir().

Note that initial_class_path() determines the initial classpath. This is the static classpath which cannot be changed. Elements of the dynamic classpath can be added and removed using the m-file scripts javaaddpath.m and javarmpath.m.

See also
terminate_jvm()

The number of created jvm's.

Definition at line 669 of file ov-java.cc.

References octave::sys::file_ops::dir_sep_str(), error(), octave::process_execution_result::exit_status(), get_jvm_lib_path_in_subdir(), octave::sys::env::getenv(), initial_class_path(), initial_java_dir(), jvm, jvm_attached, jvm_lib, LIBJVM_FILE_NAME, octave::run_command_and_return_output(), octave::dynamic_library::search(), and octave::process_execution_result::stdout_output().

Referenced by initialize_java().

◆ is_auto_convertible_number()

static bool is_auto_convertible_number ( JNIEnv *  jni_env,
jobject  jobj 
)
static

Return whether jobj shall be automatically converted to an Octave numeric value.

If jobj is an instance of any of the numeric wrapper classes Byte, Integer, Long, Short, Float, or Double, then it will be converted using the java.lang.Number.doubleValue() method.

Parameters
jobjJava object being returned to Octave
Returns
true if jobj shall be converted into a numeric value automatically, false otherwise

Definition at line 1340 of file ov-java.cc.

Referenced by box().

◆ java_event_hook()

static int java_event_hook ( void  )
static

Run the java method org.octave.Octave.checkPendingAction().

Returns
0 in any case for good reason.

Definition at line 1978 of file ov-java.cc.

References find_octave_class(), octave_set_default_fpucw(), and thread_jni_env().

Referenced by initialize_java().

◆ Java_org_octave_Octave_call()

JNIEXPORT jboolean JNICALL Java_org_octave_Octave_call ( JNIEnv *  env,
jclass  ,
jstring  funcName,
jobjectArray  argin,
jobjectArray  argout 
)

Definition at line 2029 of file ov-java.cc.

References box(), octave::feval(), jstring_to_string(), and unbox().

◆ Java_org_octave_Octave_doEvalString()

JNIEXPORT void JNICALL Java_org_octave_Octave_doEvalString ( JNIEnv *  env,
jclass  ,
jstring  cmd 
)

Definition at line 2096 of file ov-java.cc.

References octave::__get_interpreter__(), and jstring_to_string().

◆ Java_org_octave_Octave_doInvoke()

JNIEXPORT void JNICALL Java_org_octave_Octave_doInvoke ( JNIEnv *  env,
jclass  ,
jint  ID,
jobjectArray  args 
)

◆ Java_org_octave_Octave_needThreadedInvokation()

JNIEXPORT jboolean JNICALL Java_org_octave_Octave_needThreadedInvokation ( JNIEnv *  env,
jclass   
)

Definition at line 2107 of file ov-java.cc.

References get_current_thread_ID(), and octave_thread_ID.

◆ Java_org_octave_OctaveReference_doFinalize()

JNIEXPORT void JNICALL Java_org_octave_OctaveReference_doFinalize ( JNIEnv *  ,
jclass  ,
jint  ID 
)

Definition at line 2050 of file ov-java.cc.

References octave_ref_map.

◆ jstring_to_string() [1/2]

static std::string jstring_to_string ( JNIEnv *  jni_env,
jobject  obj 
)
static

Definition at line 870 of file ov-java.cc.

References jstring_to_string().

◆ jstring_to_string() [2/2]

static std::string jstring_to_string ( JNIEnv *  jni_env,
jstring  s 
)
static

◆ make_java_index()

static jobject make_java_index ( JNIEnv *  jni_env,
const octave_value_list idx 
)
static

◆ read_classpath_txt()

static std::string read_classpath_txt ( const std::string &  filepath)
static

Return the classpath in the given file filepath as a string.

In the classpath file, each line which is neither empty nor a comment, is interpreted as a segment of a path. Comment lines are those starting with a # or with a % in the very first column.

Parameters
filepathThe path to the file (usually classpath.txt) containing a portion of the classpath.
Returns
A string consisting of the lines of filepath which are neither comments nor empty without trailing whitespace separated by 'octave::directory_path::path_sep_str()'. The returned string also starts with that path separator.

Definition at line 375 of file ov-java.cc.

References octave::sys::ifstream(), octave::directory_path::path_sep_str(), and octave::sys::file_ops::tilde_expand().

Referenced by initial_class_path().

◆ set_array_elements()

static octave_value set_array_elements ( JNIEnv *  jni_env,
jobject  jobj,
const octave_value_list idx,
const octave_value rhs 
)
static

◆ terminate_jvm()

static void terminate_jvm ( void  )
static

Terminate the current jvm, if there is any.

Otherwise, detach the jvm if this thread is attached to it and unload it if this thread created it itself.

See also
initialize_jvm()

Definition at line 831 of file ov-java.cc.

References octave::dynamic_library::close(), jvm, jvm_attached, jvm_lib, and octave_set_default_fpucw().

Referenced by F__java_exit__().

◆ thread_jni_env()

static JNIEnv * thread_jni_env ( void  )
inlinestatic

◆ unbox() [1/2]

static bool unbox ( JNIEnv *  jni_env,
const octave_value val,
jobject_ref jobj,
jclass_ref jcls 
)
static

Definition at line 1688 of file ov-java.cc.

References octave_value::array_value(), octave_value::cellstr_value(), octave_value::class_name(), octave_value::columns(), java_local_ref< T >::detach(), octave_value::dims(), error(), find_octave_class(), Array< T, Alloc >::fortran_vec(), octave_value::int32_array_value(), octave_value::int8_array_value(), octave_value::is_bool_scalar(), octave_value::is_double_type(), octave_value::is_int16_type(), octave_value::is_int32_type(), octave_value::is_int64_type(), octave_value::is_int8_type(), octave_value::is_matrix_type(), octave_value::is_range(), octave_value::is_real_matrix(), octave_value::is_real_scalar(), octave_value::is_string(), octave_value::is_uint16_type(), octave_value::is_uint32_type(), octave_value::is_uint64_type(), octave_value::is_uint8_type(), octave_value::iscellstr(), octave_value::isempty(), octave_value::isfloat(), octave_value::isjava(), octave_value::islogical(), octave_value::isreal(), dim_vector::isvector(), octave_value::matrix_value(), dim_vector::ndims(), octave_value::numel(), Array< T, Alloc >::numel(), octave_java_refcount, octave_ref_map, octave_value::rows(), octave_value::string_value(), TO_JAVA, octave_java::to_java(), TO_JOBJECT, octave_value::uint8_array_value(), UNBOX_PRIMITIVE_ARRAY, UNBOX_PRIMITIVE_SCALAR, and Vjava_matrix_autoconversion.

Referenced by octave_java::do_java_set(), octave_java::do_javaMethod(), octave_java::do_javaObject(), Java_org_octave_Octave_call(), set_array_elements(), and unbox().

◆ unbox() [2/2]

static bool unbox ( JNIEnv *  jni_env,
const octave_value_list args,
jobjectArray_ref jobjs,
jobjectArray_ref jclss 
)
static

Definition at line 1912 of file ov-java.cc.

References octave_value_list::length(), and unbox().

Variable Documentation

◆ jvm

JavaVM* jvm = nullptr
static

The pointer to a java virtual machine either created in the current thread or attached this thread to it.

Definition at line 198 of file ov-java.cc.

Referenced by initialize_java(), initialize_jvm(), terminate_jvm(), and thread_jni_env().

◆ jvm_attached

bool jvm_attached = false
static

Whether the current thread is attached to the jvm given by jvm.

This is false also if no jvm exists, i.e. if jvm is nullptr.

See also
initialize_jvm()
terminate_jvm()

Definition at line 205 of file ov-java.cc.

Referenced by initialize_jvm(), and terminate_jvm().

◆ jvm_lib

octave::dynamic_library jvm_lib
static

Need to keep hold of the shared library handle until exit.

See also
initialize_jvm()
terminate_jvm()

Definition at line 211 of file ov-java.cc.

Referenced by initialize_jvm(), and terminate_jvm().

◆ listener_map

std::map<int,octave_value> listener_map
static

Definition at line 213 of file ov-java.cc.

◆ octave_java_refcount

int octave_java_refcount = 0
static

Definition at line 215 of file ov-java.cc.

Referenced by unbox().

◆ octave_ref_map

std::map<int,octave_value> octave_ref_map
static

◆ octave_thread_ID

long octave_thread_ID = -1
static

The thread id of the currently executing thread or -1 if this is unknown.

See also
initialize_java()

Definition at line 221 of file ov-java.cc.

Referenced by initialize_java(), and Java_org_octave_Octave_needThreadedInvokation().

◆ Vdebug_java

bool Vdebug_java = false

Definition at line 225 of file ov-java.cc.

Referenced by check_exception(), Fdebug_java(), JVMArgs::read_java_opts(), and JVMArgs::update().

◆ Vjava_matrix_autoconversion

bool Vjava_matrix_autoconversion = false

Definition at line 223 of file ov-java.cc.

Referenced by box(), Fjava_matrix_autoconversion(), and unbox().

◆ Vjava_unsigned_autoconversion

bool Vjava_unsigned_autoconversion = true

Definition at line 224 of file ov-java.cc.

Referenced by box(), and Fjava_unsigned_autoconversion().