From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d64f05c7c9260fb5,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-19 04:33:31 PST Path: archiver1.google.com!newsfeed.google.com!postnews1.google.com!not-for-mail From: lin@post.com (Lin) Newsgroups: comp.lang.ada Subject: Ada creating JVM in NT vs. in Linux Date: 19 Aug 2001 04:33:31 -0700 Organization: http://groups.google.com/ Message-ID: <86772402.0108190333.1c81edc7@posting.google.com> NNTP-Posting-Host: 144.32.177.174 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 998220811 11426 127.0.0.1 (19 Aug 2001 11:33:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 19 Aug 2001 11:33:31 GMT Xref: archiver1.google.com comp.lang.ada:12101 Date: 2001-08-19T11:33:31+00:00 List-Id: I've a problem related to create JVM. I declare the struct "JNIEnv" and "JavaVM" in "jni.h" as dummy record in Ada, it works well in WinNT when creating JVM, either using import"stdcall" to create JVM directly, or using import "C" to create JVM. But when the program works in Linux, there's segmentation error, I think it's a problem of initialization of "JNIEnv" and "JavaVM". In NT, the pointer parameters passing to JNI_CreateJavaVM(..) can be initialized when calling JNI_CreateJavaVM(..) of "jni.h", so it doesn't matter whatever content in the record "JNIEnv" and "JavaVM" declared in Ada. Therefore, I assume that the pointer(**) pointing to "JNIEnv/JavaVM" will be initialized until calling the JNI_CreateJavaVM(..) method of "jni.h". But in Linux, I assume that the pointer(**) pointing to "JNIEnv/JavaVM" will be initialized in Ada side rather than in jni.h. Therefore, the record "JNIEnv/JavaVM" declared in Ada should totally match the conresponding structs declared in "jni.h". If it doesn't match, the segmentation error appears. I try the program either in JDK1.2 and JDK1.1.x, but I meet the same problem, the code listed below is for JDK1.1.x. I'm not sure if my assumption is right, it will be great if anybody can give me some clues. I list the related code of "jni.ads" in Ada and related function in C below: -------------- ---jni.ads--- -------------- type JNIEnv_1 is record null; end record; type JNIEnv is access all JNIEnv_1; type access_JNIEnv is access all JNIEnv; type JavaVM_1 is record null; end record; type JavaVM is access all JavaVM_1; type function My_JNI_CreateJavaVM ( jvm : in access_JavaVM; jenv : in access_JNIEnv; VMInitArgs : in JDK1_1InitArgs) return jint; pragma Import (C, My_JNI_CreateJavaVM); ------------------- ----------- --jni_c.c-- ----------- #include "jni.h" jint My_JNI_CreateJavaVM(JavaVM **jvm, JNIEnv **env, JDK1_1InitArgs *Ia){ return JNI_CreateJavaVM(jvm,env,Ia); }