octave in java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

octave in java

Ernst Reissner
Hi all,

I just tried in octave:

octave:1> debug_java(1)
octave:2>
javaMethod('load','java.lang.System','/home/ernst/Octave/octave/.build/libinterp/.libs/liboctinterp.so')
ans = [](0x0)
octave:3>  oct=javaObject('org.octave.Octave')
oct =

<Java object: org.octave.Octave>

octave:4>  javaMethod('needThreadedInvocation',oct)
ans = 1

What means that one can invoke from within octave the java function
needThreadedInvocation'

which in turn is defined native in the java class org.octave.Octave

and which is provided by liboctinterp.so.


So far so good.

Then I try the (much more interesting) method doEvalString and use it to
evaluate sin(1).

The result is

octave:10> javaMethod('doEvalString','org.octave.Octave','sin(1)')
error: 'nargin' undefined near line 36 column 7
terminate called after throwing an instance of 'octave_execution_exception'
panic: Aborted -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Aborted

I do not at all understand this output.

Seems to have to do with the fact, that doEvalString has an input argument.

I presume that it is for sin that nargin is undefined.

I tried also with pi instead of sin(1), same effect.


What works out relatively ok is 42:

octave:3>  javaMethod('doEvalString','org.octave.Octave','42')
ans =  42
ans = [](0x0)
octave:4>
The second ans is the output of function javaMethod.

I can also do

javaMethod('doEvalString','org.octave.Octave','b=42;');


and then

octave:8> b
b =  42


so the problem is just invocation of functions.


Who can help?






Reply | Threaded
Open this post in threaded view
|

Re: octave in java

Ernst Reissner

additional information:

If i try the following java code:


   public static void main(String[] args) throws Exception {// NOPMD
System.load("/home/ernst/Octave/octave/.build/libinterp/.libs/liboctinterp.so");
    org.octave.Octave o = new org.octave.Octave();
    System.out.println("need threaded invocation: "
               + o.needThreadedInvocation());
    o.doEvalString("sin(42);");


this results in


need threaded invocation: true
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fcacc4847ba, pid=23120, tid=140509548140288
#
# JRE version: OpenJDK Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14)
# Java VM: OpenJDK 64-Bit Server VM (25.91-b14 mixed mode linux-amd64
compressed oops)
# Derivative: IcedTea 3.0.1
# Distribution: Custom build (Fri May  6 08:03:59 UTC 2016)
# Problematic frame:
# C  [liboctinterp.so.3.0.0+0x31e7ba]
octave::application::interactive()+0xa
#
# Failed to write core dump. Core dumps have been disabled. To enable
core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/ernst/Software/src/main/java/eu/simuline/octave/hs_err_pid23120.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Process eu.simuline.octave.OctaveInterfaceTester aborted

so needThreadedInvocation() can still be invoked whereas doEvalString
can not.

Even o.doEvalString("42;");


does not work.

Any suggestions?


Ernst