JNI call changes Fortran program behavior dependent on locale

Hello,
we observed a strange problem with a Fortran code calling Java methods via JNI. The code is reading strings (e.g. 2.726), converting them into double values. Until Java7 everything was fine with this code, but since Java7 the double values were suddenly cut to what appeared to us as integer values as soon as JNI_CreateJavaVM was called. Changing between Java6 and 7 (libjvm) really made the difference. Looking into the problem we now noticed that under Java7 the behaviour is dependent on the system locale. When we used de_DE the values were cut, under POSIX,C,en_US etc. they were converted properly. This dependency was not existing in Java6. We created a testcase to reproduce this problem, which can be found here: http://planck.mpa-garching.mpg.de/testcase.tgz - just modify JAVAPATH in the Makefile and run it.
Our temporary solution is to make sure that LC_ALL (or more specific LC_NUMERIC) is set to a working value, but we wonder if this is a bug which was introduced recently or if this is intended.
Best regards.

OK, I will explain in detail what we are doing (basically our testcase):
We have a Fortran program which defines a character and a double variable. We fill the char with "2.726". Convert this via Fortran read Method to double. Print the resulting double, which is 2.726.
Now we call a C Wrapper which does nothing else than just creating a JVM.
We do the same test as above in the Fortran program, just now the resulting double value is 2.000
To prevent misunderstandings, I will also copy the code of both programs here:
Fortran:
character(len=4096)::tstr
double precision tdbl
tstr="2.726"
read (tstr,*) tdbl
print *,"before JVM creation: result=",tdbl
call cfunc
tstr="2.726"
read (tstr,*) tdbl
print *,"after JVM creation: result=",tdbl
end program
C part:
#include <jni.h>
JavaVM *jvm;
JNIEnv *env;
int cfunc()
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = "-Djava.compiler=NONE";           /* disable JIT */
vm_args.version = JNI_VERSION_1_4;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = 0;
JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
return 0;

Similar Messages

  • Core dump on solaris 8/7 making JNI call.

    Hi,
    I am running solaris 8 and solaris 7 with Java 1.3.1. I have required solaris patches installed on the machine for java 1.3.1.
    From a C program I am making some JNI calls and when I run the program it core dumps at the very first JNI call. C program that make JNI calls are in a .so file.
    Same C code with Java 1.3.1 is running fine on window 2000, AIX 5.1, RedHat Advanced Server 2.1 and SuSE Enterprise Linux 7.
    Any help will be greatly appriciated.
    Thanks

    Hiya,
    Any resolution to this post , we have a native JNI call on a Websphere server running on Solaris 8 .. and same thing happening .. random core dump on the box ..
    No warning , no explanation
    Thanks so much for your help
    (btw . running Sun jvm 1.4.2_13)

  • Linking with a fortran program

    I have made a java program that generate an input file when a botton is clicked. This input file is used by a fortran program to generate results.
    Now the question is how can I link my java program so that when I press the button the input file that is generated and also the fortran program start running. Is it possible to run a program in some other language from code inside my java program.
    I dont want to write my fortran program again in java.
    thanks

    If you want to run an application, the same as running it from the command line, then you can use Runtime.exec(). If you need to 'link' to a library then you will need to use JNI to create a wrapper in C and that C code actually calls the library (fortran library.)

  • Creating JVM to Make JNI calls

    I am trying to create a JVM to make JNI calls to Java. When I try to link my C++ program with jvm.lib, I am getting following error. Please advise.
    "fatal error LNK1106: invalid file or disk full"
    I am sure the disk is not full.

    What IDE are you using? I am using MS VC++ 5.0 with jdk 1.3 and I got the same error. After trying several things (including recreating my project)I realized that jdk 1.3 was created after VC++ 5.0. So on a wild hunch I installed jdk 1.2.2. I then removed all project referrences to jdk 1.3. Closed all my files. Reopend them. Made sure the jni.h external dependency was pointing to 1.2.2 (you may have to do a build to force it) and then everything linked fine.

  • How to call a concurrent program from a Custom JSP page.

    Hi,
    I have a custom JSP page which i have deployed by creating a form function with the path of the JSP Page
    and added the JSP Page to the OA_HTML top.
    Now, i need to call a concurrent program from the JSP Page, i have all the parameters in my page and i am using the standard class as below:
    ConcurrentRequest cr= new ConcurrentRequest(con);
    int requestId= cr.submitRequest("XXINV",programName,null,null,false,vec);
    I have verified my connection object and it is OK but i am getting the exception that user is not set to run the program.
    I tried the below code in my JSP page and getting -1 for all test variables :-
    int userId = wctx.getUserId();
    int respApplId = wctx.getRespApplId();
    int respId = wctx.getRespId();
    I think i need to set the context in JSP page to run the program..
    Pls help ....
    Regards
    Saurabh Jaiswal

    Hi,
    Thanks for the reply,,,
    This is a possible solution but this will allow to run the program anyhow.
    But the procedure which i call thru callable statement will start with
    fnd_global.apps_initialize (3825, 50603, 704);
    fnd_request.submit_request API call.
    Now, the values of user and Responsibilty is required in the program and it changes.
    With this approach we have to hardcode the user and resp.
    The same JSP page is attached to other responsibilities and there the concurrent program would get fired as if fired from the resp Id hardcoded as above.
    Need to capture user Id and RespId.
    How can i set the apps Context in JSP page???
    Regards
    Saurabh Jaiswal

  • The order of execution (of PL/SQL function calls) changes...why??

    select e.EMPID empid,
    e.name name,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e
    where e.empid = 101
    order by e.name;
    when I execute this select statement...the order of function calls is as follows:
    setvalues 1st (call no:1)
    test1 (call no:2)
    test2 (call no:3)
    test3 (call no:4)
    Now...I introduce a join between the two tacles as mentioned in the query
    select e.EMPID empid,
    e.name name,
    e2.deptno deptid,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e, emp2 e2
    where e.empid = e2.empid
    order by e.name;
    The order of execution of function calls changes to
    (I observed this using DBMS_OUTPUT.PUT_LINE)
    test3 (call no:1)
    setvalues 1st (call no:2)
    test1 (call no:3)
    test2 (call no:4) (the first and last calls swap!)
    i.e: it calls the last function in the select statement at the beginning
    instead of calling it at the last. Is it the normal behaviour? or whats going on
    here?
    Can somebody explain me, please....
    Details:
    the following four functions are defined in a package called 'aatest' and compiled.
    aatest.SETVALUES(2)
    aatest.TEST1()
    aatest.TEST2()
    aatest.TEST3()
    the Tables EMP and EMP2 are two tables defined in the same schema.

    Your "thinking" is wrong here. You can not use the column order to model your program flow. As SQL is set/tupel based, there is no given sequence of the execution order. Otoh you want to have a specific order in wich your functions must be executed otherwise the result will be wrong (or undefined). Thus here you need a procedural approach. This can be done by using PL/SQL for example.
    You would code your functions in that way, that they are working correctly independent from the place where they are called ie if function1 needs the setvalues function, this function must be called inside the function1 then.
    Are you sure you need all these functions in this procedural approach inside the sql-statement? This is mostly not needed and can be accomplished by using pure SQL. If not, may be your design is broken.

  • Calling an Executable program in a Web dynpro

    Hi
    We would like to change the initial screen of one of our functionalities (kilometre claims), but the info after you submit the selection info does not need to change.  We have an executable program with the detail of the screen.
    I created a new Web dynpro application with the select options that must be entered; if you then click on a Submit button, I would like to call the current executable program, but I am not sure how I must do this.
    Example:
    To call a method, I always use: Call method ZCL_WD_PA=>ZHRPA_UPDATE_IT9004, but I am not sure how to call an executable program and with info is needed.
    Could anyone please assist?
    Regards
    Debbie

    Hi
    We have a functionality via Employee Self-Service (Portal ECC6) where an employee can view their Kilometre claimsin a Report format.
    To get the info to be displayed, someone else created a Program via the GUi SE38 (Attribute is an Executable program).  The front screen (selection screen) where the dates for which you would like to run the report for, needs to be changed.  It is not a nice screen to look at.  On that same screen which I would like to change, is a submit button.  If you click on that, it shows info and that info must not be changed at all.
    So I will also have a submit button on my new Web dynpro functionality where I am building hopefully a nicer selection screen.  I will also have a Submit button and I wanted to add something when clicking on this submit button to call the existing program that will show the info selected.
    Regards
    Debbie

  • Call a c program in java

    i am trying to call a c program in java,can anyone tell me how ot do this using jni

    That has nothing to do with JNI nor java.
    However if you mean an executable, then the will be an OS call, specific to your OS, which allows you to run a process/application. That is the only way you can do it.

  • How to call a C program in java?

    I would like to call a C program (which does not return anything back to the Java program) from a Java class? Or is there any simple example just to do such a task online?
    Thanks.

    two options:
    1) Use JNI and call your C routines directly
    2) Make an executable and call it using Runtime.exec()

  • How can I call a C program or call a C function in my JAVA code?

    Could I call a C program or a C function in my JAVA code?
    somebody told me that I should define a native() method, but what should I do in this native() method?
    could u give me an example?
    thanks in advance.

    Maybe these will give a clue:
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    http://java.sun.com/j2se/1.3/docs/guide/jni/

  • How to call a java program in javafx class(Urgent) and even vice versa

    Hi all,
    Here I have two questions:
    1)
    Please let me know how to call a javafx in java program...
    I tried with the following code but it is not working..
    The below is the java program in which I made a call to the Fx program.
    FxMainLauncher.java
    import net.java.javafx.FXShell;
    public class FxMainLauncher {
    public static void main(String[] args) throws Exception {
    FXShell.main(new String[] {"HelloWorld.fx"});
    2) How to call a java program in javafx class
    Here is my javafx program
    import check.*;
    import javafx.ui.*
    var instance = new MyJava();
    //visible:true
    System.out.println("Number is: {instance}");
    Here is my java program
    public class MyJava {
    public static void main(String args[])
    System.out.println("JAVAFX TO JAVA");
    Even this is not working please let me know ASAP
    Thanks in advance,
    V.Srilakshmi

    GOT IT !!!
    I had to change the name of the method in .h file generated by javah command. On doing
    javac -d ../../classes HelloWorld.java
    go to the ../../classes directory (where you have the class file) and do
    javah HelloWorld
    I got a HelloWorld.h file in which I had
    JNIEXPORT void JNICALL Java_HelloWorld_display(JNIEnv *, jobject);
    I added the package name too:
    JNIEXPORT void JNICALL Java_GUI_HelloWorld_display(JNIEnv *, jobject);
    The HelloWorldImp.c file should have the same name (ie with package) and be in the same directory(ie ../../classes)
    compile and build the shared library to get "libhello.so" file
    gcc -c -fPIC -I/usr/lib/j2sdk1.3/include -I/usr/lib/j2sdk1.3/include/linux HelloWorldImp.c
    gives .o file
    gcc -shared -o libhello.so HelloWorldImp.o
    gives .so file
    then run java with the command in my first message. It works.
    Thanks for the reply "thedracle".

  • Call module  pool program from report

    Hi,
    Iam calling module pool program from a report, while passing values to module pool program, one of the field doesn't have parameter id, how to pass value to it. and also please let me know how to call module pool program.
    Appreciate your help.
    Thanks in advance
    jog

    Hi Jog,
    Module pool program can be run in background. Most of the BDC's are written on module pool programs and they run in the background.
    Also regarrding copying the standard program, if you require to make the changes for every user then instead of copying the program make modification in standard program as copied program are much harder to maintain during support pack implementation or upgrade that modification to standard program.
    Reward points if useful.
    Regards,
    Atish

  • Change Pointer Program for IDOC creation..??

    To All
    Where does the message type is assigned, which allow that type of IDOC getting created in WPMU...??
    Can COND_A be created in Change pointer Program...??
    If possible ..How...??
    Thanks
    Sumeet

    3)
    RBDMOIND to confirm whether idocs have been successfully
    dispatched to the receiver..and v can also use this program to change the status of idoc from 3 to 12....
    RSNATED is the program used for triggering IDOC for the output type..where the output medium is 6.
    And the subroutine that triggers the IDOC in the program is EDI_PROCESSING.
    RSNASTED itself determines the associated IDoc outbound function module, executes it to fill the EDIDx tables and passes the prepared IDoc to the port.
    You can call the standard processing routines from any ABAP, by executing the following call to the routine. You only have to make sure that the structure NAST is declared with the tables statement in the calling routine and that you fill the at least the key part and the routing information before.
    TABLES NAST.
    NAST-MANDT = SY-MANDT.
    NAST-KSCHL = 'ZEDIK'.
    NAST-KAPPL = 'V1'.
    NAST-OBJKY = '0012345678'.
    NAST-PARNR = 'D012345678'.
    PERFORM einzelnachricht_screen(RSNAST00).
    Calling einzelnachricht_screen determines how the message is processed. If you want to force the IDoc-processing you can call it directly:
    TNAPR-PROGN = ''.
    TNAPR-ROUTN = 'ENTRY'.
    PERFORM edi_processing(RSNASTED).
    ~~Guduri

  • Is there a way to call a SQL Program from an Oracle Report?

    Morning friends. I had a question about Oracle Reports and them calling a SQL Program. Here is the problem at hand. I am hoping to not have to change the existing program a whole lot!
    Currently, here is what is happening. I have a .sh file which calls the Oracle Report first and then goes on to call a .sql program. I am using Oracle Reports 10g and the call to run the report is RWCLIENT. This was earlier being called using RWRUN.
    Because of certain issues of synchronicity with RWCLIENT, I am now looking to move the call to the .sql program to the Oracle Report (Ideally the AFTER_REPORT trigger). Is this possible?
    The Oracle Report basically outputs a listing and the .sql program does a spool and creates a text file which is later used as attachment to the email and sent out to the person who submitted the Report.
    Here is the shell script.
    # Accept system input parameters
    p_gradapp_user_id=$1
    p_gradapp_job_id=$2
    program_unit='GRAD001A'
    rwrun.exe module=$GRADAPP_PATH/GRAD001A userid=$p_gradapp_user_id paramform=no desformat=$GRADAPP_PRINTER(GRAD001,1) destype=file desname=grad001-$p_job_id-1-1.lis p_gradapp_job_id=$p_gradapp_job_id p_gradapp_user_id=$p_gradapp_user_id batch=yes
    exit_status=$?
    program_unit='GRAD001B'
    sqlplus.exe -s $p_gradapp_user_id @$GRADAPP_PATH/grad001b.sql $p_gradapp_user_id $p_gradapp_job_id
    exit_status=$?
    exit 0

    If you are going to use rwclient try BACKGROUND=NO as an extra parameter:
    background=NO: Runs the report synchronously. The client waits for the report to queue, be assigned to a runtime engine, run, and finish.
    See: http://download.oracle.com/docs/cd/B14099_19/bi.1012/b14048/pbr_cla.htm#i656436

  • Stack overflow in JNI call

    Hi,
    I am doing a wrapper with JNI for a Windows library of image compression. I have a test program running correctly in C. This program compress data and it can move a lot of memory. If I call this program from a JNI functions I obtain a JNI error:
    An unrecoverable stack overflow has occurred.
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_STACK_OVERFLOW (0xc00000fd) occurred at PC=0x5FF88497
    Function=unpack_data+0x189D7
    Library=C:\WINDOWS\system32\NCSEcw.dll
    This error is produce inside my compression library. I try to adjust the parameters (-Xms -Xmx -Xss) of the JVM but in any case before the process ends it shows this exception. I have done other JNI interfaces and I never found with this problem before. Can anybody help me?
    Thanks in advance.

    I found in this forum a piece of code with a same kind problem but It is simpler than mine. I have proved this program in Windows and it produce the same error. In Linux it runs but if I enlarge the array largebuf it ends with the same error. In Linux I can reserve until 2 MB (in windows +-256K). Is there any way to increase the stack size in a jni call?.
    #include <stdio.h>
    #include <jni.h>
    #include "test.h"
    int myprint2(int a, int b){
         char extrabuf[100];
         printf("got here next\n");
         extrabuf;
         return 0;
    int myprint(int a, int b){
         char largebuf[260000];
         printf("got here\n");
         myprint2(1,1);
         largebuf;
         return 0;
    JNIEXPORT jint JNICALL Java_test_init(JNIEnv *env, jobject obj){
         myprint(1,1);
         return 1;
    test.java
    public class test{
         public native int init();
         public static void main(String []args){
              new test();
         public test(){
              System.loadLibrary("Nat");
              System.out.println(this.init());
    }

Maybe you are looking for

  • Automatic item addition in a PM notification

    Hello there! I'm trying develop an automatically item addition in a PM notification... But I have to do it during a dialog process (via IW21/22 transaction)! I mean, when user adds a new item in a notification, some other items must be automatically

  • Installed new software, after restart black screen with Darwin/BSD promt

    Hi I have been struggling with thisissue. I installed some new software, a webcam driver called ilook 1321. I restarted my computer but forgot to take the disc out! Now when I start my ibook G4 i get the black screen with Darwin/BSD (localhost) (cons

  • 1440 x 852 resolution

    i have a mbpro 15,4 high resolution. I've 49 and my eyesight is not like a young. I can't work all day long with the 1680 x 1050 resolution so i use 1440 x 852 ( why not 1440 x 900) but the desktop doesn't occupy all the screen; there are two black s

  • UN-pairing wireless mouse and keyboard ?

    I have a new(ish) 27" iMac, OS X 10.6.3 [ with two-tone display ...but that's another story ] I set it up with the wireless mouse and wireless keyboard that came with it. The instructions were pretty clear how to "pair" the mouse and keyboard. So I p

  • Two computers - desktop for songs, laptop for podcasts

    Hi - I'm sure that for a while I was succesfully synch'ing just songs from my desktop and just podcasts from my laptop. Now everytime I synch the desktop it wipes all my podcasts. Whats going wrong? Thanks, Darren