From owner-freebsd-java@FreeBSD.ORG Sat Mar 29 07:04:53 2008 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F05D1065688 for ; Sat, 29 Mar 2008 07:04:53 +0000 (UTC) (envelope-from funkyrod@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.227]) by mx1.freebsd.org (Postfix) with ESMTP id A5ED98FC1E for ; Sat, 29 Mar 2008 07:04:52 +0000 (UTC) (envelope-from funkyrod@gmail.com) Received: by wx-out-0506.google.com with SMTP id h29so634983wxd.13 for ; Sat, 29 Mar 2008 00:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=MrMpzsA0Atbk6vTUsNA7Md4fPAe6sqFLiN0Q3Z6QrgI=; b=oLaYw8OBdwh1DqIvedL5DxW1u1umBVp6u8PRgMGz0IFbe3My8bnQffq+F850aQETTPMfu3Be6mmFqzl7vHFVJfwtozuujfw7FB46h993qtkcYvJb2Q1setWosSlj82yqriNNcztmrtgw3hlCcPsLqaKzJCwvXZHZZoMoossvBu4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:mime-version:content-type; b=R3FERskKW/KXjVhSogMB05XaWRv/Sm6Ew2W0KwZJrhRbrh9bjBEos5wd3FEhsK+UidPshMCy03WK7lj1s6tscSq38uWX4Uvzujtt6RnGMadQx5tUr7gREezRcmCYShvrAuMNNfVS6BopCeTiPHG5orhonKARH7Ug8B6EaFn6AeQ= Received: by 10.70.72.11 with SMTP id u11mr4370812wxa.39.1206772571627; Fri, 28 Mar 2008 23:36:11 -0700 (PDT) Received: by 10.70.75.7 with HTTP; Fri, 28 Mar 2008 23:36:11 -0700 (PDT) Message-ID: Date: Sat, 29 Mar 2008 06:36:11 +0000 From: Rod To: freebsd-java@freebsd.org. MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Is JNI (Java Native Interface) Known to Work in Both Directions on FreeBSD (to invoke the JVM from native software)? X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Mar 2008 07:04:53 -0000 I'm having trouble using JNI software on FreeBSD. In summary: - I'm able to call native routines from a Java VM via JNI - However in the other direction JNI seems not to work. I can't create a JVM via JNI from native software. Admittedly, I'm using one specific software (R with rJava) and haven't tried running my own JNI software. What I'm noticing is that a call to JNI_CreateJavaVM () in /usr/local/jdk1.6.0/jre/lib/i386/client/libjvm.so results in SIGSYS, Bad Sytem Call. Here's my output from running R with rJava under gdb with a stack backtrace. It all seems to go pear-shaped at JNI_CreateJavaVM () : # R -d gdb GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-marcel-freebsd"...(no debugging symbols found)... (gdb) run Starting program: /usr/local/lib/R/bin/exec/R R version 2.6.0 (2007-10-03) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(rJava) [New LWP 100145] [New Thread 0x28909300 (LWP 100145)] > .jinit() ######(calls code to invoke the JVM) [New Thread 0x28909200 (LWP 100169)] [New Thread 0x28909500 (LWP 100170)] [New Thread 0x28909600 (LWP 100171)] Program received signal SIGSYS, Bad system call. [Switching to Thread 0x28909300 (LWP 100145)] 0x2830a86b in ksem_init () from /lib/libc.so.7 (gdb) bt #0 0x2830a86b in ksem_init () from /lib/libc.so.7 #1 0x28300229 in sem_init () from /lib/libc.so.7 #2 0x29ab0e59 in os::signal_init_pd () from /usr/local/jdk1.6.0/jre/lib/i386/client/libjvm.so #3 0x29aaeb62 in os::signal_init () from /usr/local/jdk1.6.0/jre/lib/i386/client/libjvm.so #4 0x29b39342 in Threads::create_vm () from /usr/local/jdk1.6.0/jre/lib/i386/client/libjvm.so #5 0x299aa736 in JNI_CreateJavaVM () from /usr/local/jdk1.6.0/jre/lib/i386/client/libjvm.so #6 0xbfbfd66b in ?? () #7 0x00000000 in ?? () #8 0x00000000 in ?? () #9 0xbfbfd584 in ?? () #10 0x00000009 in ?? () #11 0xffffffff in ?? () #12 0x299a91cf in JNI_GetDefaultJavaVMInitArgs () from /usr/local/jdk1.6.0/jre/lib/i386/client/libjvm.so Previous frame inner to this frame (corrupt stack?) (gdb) I'm running this under a clean install of 7-Release I386: # uname -a FreeBSD 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 I was getting the same result on my existing installation, so in case it was some mix-up with libraries I tried new installations of 7-Release and also PCBSD-1.5 (based on 6.3), both with the same result. I've tried Java 1.6 built from ports (usr/ports/java/jdk16) # java -version java version "1.6.0_03-p3" Java(TM) SE Runtime Environment (build 1.6.0_03-p3-root_16_feb_2008_09_59-b00) Java HotSpot(TM) Client VM (build 1.6.0_03-p3-root_16_feb_2008_09_59-b00, mixed mode) I've also tried Diablo-Java1.5 as follows, with exactly the same result as above. # java -version java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.5.0-b01) Java HotSpot(TM) Client VM (build diablo-1.5.0_07-b01, mixed mode) Both jdk1.5 and jdk1.6 gave exactly the same result. I'm going to check with the rJava developers to see if they can assist, but I thought I'd check on this list if there are any known special issues to get JNI working fully under FreeBSD (specifically to create a JVM and use Java objects from native software), or if it is known not to work? Thanks for any help Rod.