On Sun, 1 Apr 2001, [EMAIL PROTECTED] wrote:
> Using a user-mode-linux kernel as a test-bed, I'm trying to start a
> JavaVM as the first process instead of init. I appears to be hanging
> on JNI_CreateJavaVM. I'm not sure what initial conditions need to be
> set, so I've played around a bit unsuccessfully. I have a program,
> though, that duplicates this behavior from the command-line. It
> comes down to this: if I create a VM from a process spawned directly
> from a shell, it works. If my program forks then calls
> JNI_CreateJavaVM, it hangs. The attached program will duplicate
> this. Run without command-line args to fork and with command-line
> args for no fork.
>
> any ideas? I've tried this with every linux JVM 1.2.2 and newer
> (including sun, bd, and ibm and 1.3.0 versions).
Works fine for me with our classic native threads VM:
,----
| % gcc -o jvmtest jvmtest.c `j2sdk-config --cflags` `j2sdk-config -classic --libs`
| % LD_LIBRARY_PATH=`j2sdk-config -classic --ld-library-path` ./jvmtest
| waiting for jvm
| 0)
| 1) (0)
| 2)
|(/usr/lib/j2re1.3/lib/rt.jar:/usr/lib/j2re1.3/lib/i18n.jar:/usr/lib/j2re1.3/lib/sunrsasign.jar:/usr/lib/j2re1.3/classes:/opt/sys)
| 3) (0)
| Can't find "init" class
| exit (14890)
`----
HotSpot only supports JNI_VERSION_1_2 (0x00010002). If I change the init
code to
,----
| JavaVMInitArgs vm_args;
| JavaVMOption options[2];
| JavaVM* vm;
| JNIEnv* env;
|
| options[0].optionString = "-Djava.class.path=."; // user classes
| options[1].optionString = "-verbose:jni"; // print JNI-related messages
|
| vm_args.version = JNI_VERSION_1_2;
| vm_args.options = options;
| vm_args.nOptions = 2;
| vm_args.ignoreUnrecognized = JNI_FALSE;
|
| res = JNI_CreateJavaVM(&vm, (void**) &env, &vm_args);
`----
it works with HotSpot too:
,----
| % gcc -o jvmtest jvmtest.c `j2sdk-config --cflags` `j2sdk-config --libs`
| % LD_LIBRARY_PATH=`j2sdk-config --ld-library-path` ./jvmtest
| waiting for jvm
| [Dynamic-linking native method java.lang.StrictMath.sin ... JNI]
| [Dynamic-linking native method java.lang.StrictMath.cos ... JNI]
| [Dynamic-linking native method java.lang.Float.intBitsToFloat ... JNI]
| [...]
| [Dynamic-linking native method java.io.FileInputStream.available ... JNI]
| [Dynamic-linking native method java.lang.ClassLoader.defineClass0 ... JNI]
| Can't find "init" class
| exit (18092)
`----
Juergen
--
Juergen Kreileder, Blackdown Java-Linux Team
http://www.blackdown.org/java-linux.html
JVM'01: http://www.usenix.org/events/jvm01/
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]