GNU Octave  9.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 "variables.h"
#include <jni.h>

Go to the source code of this file.

Namespaces

 octave
 

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

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)
 

Variables

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:130
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 82 of file ov-java.cc.

◆ TO_JAVA

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

◆ TO_JCLASS

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

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

◆ TO_JNIENV

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

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

◆ TO_JOBJECT

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

Definition at line 85 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)

◆ 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 151 of file ov-java.cc.

◆ jclass_ref

typedef java_local_ref<jclass> jclass_ref

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

◆ jdoubleArray_ref

typedef java_local_ref<jdoubleArray> jdoubleArray_ref

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

◆ jintArray_ref

typedef java_local_ref<jintArray> jintArray_ref

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

◆ JNI_CreateJavaVM_t

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

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

◆ JNI_GetCreatedJavaVMs_t

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

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

◆ jobject_ref

typedef java_local_ref<jobject> jobject_ref

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

◆ jobjectArray_ref

typedef java_local_ref<jobjectArray> jobjectArray_ref

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

◆ jstring_ref

typedef java_local_ref<jstring> jstring_ref

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

◆ jthrowable_ref

typedef java_local_ref<jthrowable> jthrowable_ref

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

Function Documentation

◆ Java_org_octave_Octave_call()

JNIEXPORT jboolean JNICALL Java_org_octave_Octave_call ( JNIEnv *  ,
jclass  ,
jstring  ,
jobjectArray  ,
jobjectArray   
)

◆ Java_org_octave_Octave_doEvalString()

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

◆ Java_org_octave_Octave_doInvoke()

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

◆ Java_org_octave_Octave_needThreadedInvokation()

JNIEXPORT jboolean JNICALL Java_org_octave_Octave_needThreadedInvokation ( JNIEnv *  ,
jclass   
)

◆ Java_org_octave_OctaveReference_doFinalize()

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

Variable Documentation

◆ Vdebug_java

bool Vdebug_java = false

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

◆ Vjava_matrix_autoconversion

bool Vjava_matrix_autoconversion = false

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

◆ Vjava_unsigned_autoconversion

bool Vjava_unsigned_autoconversion = true

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