comp.lang.ada
 help / color / mirror / Atom feed
* Ada creating JVM in NT vs. in Linux
@ 2001-08-19 11:33 Lin
  2001-08-20 11:31 ` Mattias Sjosvard
  0 siblings, 1 reply; 2+ messages in thread
From: Lin @ 2001-08-19 11:33 UTC (permalink / raw)


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);
 }



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ada creating JVM in NT vs. in Linux
  2001-08-19 11:33 Ada creating JVM in NT vs. in Linux Lin
@ 2001-08-20 11:31 ` Mattias Sjosvard
  0 siblings, 0 replies; 2+ messages in thread
From: Mattias Sjosvard @ 2001-08-20 11:31 UTC (permalink / raw)


Shooting from the hip and judging your naming conventions, it doesn't
look as if
you pass the last argument as an access type (it should be an 'access
JDK1_1InitArgs').
This may or may not work depending on what the interfacing pragma says
and how the
local C compiler handles the passing of structures (I don't have the RM
at my side
now).
Hope this helps
/Seasword


Lin wrote:

>
>   function My_JNI_CreateJavaVM (
>      jvm : in access_JavaVM;
>      jenv : in access_JNIEnv;
>      VMInitArgs : in JDK1_1InitArgs) return jint;
>   pragma Import (C, My_JNI_CreateJavaVM);



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-08-20 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-19 11:33 Ada creating JVM in NT vs. in Linux Lin
2001-08-20 11:31 ` Mattias Sjosvard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox