comp.lang.ada
 help / color / mirror / Atom feed
From: lin@post.com (Lin)
Subject: Ada creating JVM in NT vs. in Linux
Date: 19 Aug 2001 04:33:31 -0700
Date: 2001-08-19T11:33:31+00:00	[thread overview]
Message-ID: <86772402.0108190333.1c81edc7@posting.google.com> (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);
 }



             reply	other threads:[~2001-08-19 11:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-19 11:33 Lin [this message]
2001-08-20 11:31 ` Ada creating JVM in NT vs. in Linux Mattias Sjosvard
replies disabled

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