From: | johann at myrkraverk(dot)com (Johann 'Myrkraverk' Oskarsson) |
---|---|
To: | |
Subject: | [Pljava-dev] Java VM stalls during |
Date: | 2010-12-15 16:09:01 |
Message-ID: | AANLkTinctdKu7Ox++p6071ZkDF=V=8DzYWN98-+G8prk@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pljava-dev |
Hi,
On Fri, Dec 10, 2010 at 5:32 AM, Anantha <chantanand at gmail.com> wrote:
> When i check the code with log, ?"initializeJavaVM" function makes the call
> to JNI_createVM which calls "JNI_CreateJavaVM" function and looks like
> control waits there in loop indefinitely. ?As "JNI_CreateJavaVM" function is
> in "libjvm.so", could it be JDK issue? I have followed build procedures
> stated by FreeBSD ports makefile, compiled and installed JDK-1.5 (64bit
> version). Would there be any issue in FreeBSD JDK source?
Unfortunately, I can't run amd64 FreeBSD in VirtualBox since my CPU
doesn't have VT-x (or whatever it's called) so I'm flying blind here.
I can help further/faster with shell access to amd64 FreeBSD machine.
I don't need root, only Postgres 9 sources (maybe not if it's
installed) as well as PL/Java and what it takes to build it.
Does the following JNI application work? You'll need to adjust the
Makefile. And please excuse the cut&paste instead of attachments.
Johann
# File: Makefile
# Adjust these for your system.
STUDIO_HOME=/opt/myrkraverk/solstudio12.2
JAVA_HOME=/opt/myrkraverk/jdk1.5.0_22/
# Adjust these for your compiler.
# -m64 is for amd64 binaries on Solaris, whether compiled with
# Studio or GCC.
CC=${STUDIO_HOME}/bin/cc
CFLAGS=-I${JAVA_HOME}/include -I${JAVA_HOME}/include/solaris -m64
# This may need to be adjusted for non-Solaris platforms.
# For GCC you can try -rpath.
# Another option is to pass it directly to the linker with -Wl for example.
RPATH=-R${JAVA_HOME}/jre/lib/amd64/server
# This should not need to be modified
JAVAC=${JAVA_HOME}/bin/amd64/javac
JAVA=${JAVA_HOME}/bin/amd64/java
invoke: invoke.c Prog.class
${CC} -o invoke ${CFLAGS} invoke.c -L${JAVA_HOME}/jre/lib/amd64 \
-R${JAVA_HOME}/jre/lib/amd64 \
-L${JAVA_HOME}/jre/lib/amd64/server ${RPATH} \
-L${JAVA_HOME}/jre/lib/amd64/native_threads
-R${JAVA_HOME}/jre/lib/amd64\native_threads \
-ljvm
Prog.class: Prog.java
${JAVAC} -g Prog.java
# End of File: Makefile
// File: Prog.java
public class Prog {
public static void main(String[] args)
{
System.out.println("Hello World " + args[0]);
}
}
// End of file: Prog.java
/* File: invoke.c */
#include <jni.h>
#define PATH_SEPARATOR ':' /* define it to be ';' on Windows */
#define USER_CLASSPATH "." /* where Prog.class is */
int main( int argc, char *argv[] )
{
JNIEnv *env;
JavaVM *jvm;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jclass stringClass;
jobjectArray args;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString =
"-Djava.class.path=" USER_CLASSPATH;
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
exit(1);
}
cls = (*env)->FindClass(env, "Prog");
if (cls == NULL) {
goto destroy;
}
mid = (*env)->GetStaticMethodID(env, cls, "main",
"([Ljava/lang/String;)V");
if (mid == NULL) {
goto destroy;
}
jstr = (*env)->NewStringUTF(env, " from C!");
if (jstr == NULL) {
goto destroy;
}
stringClass = (*env)->FindClass(env, "java/lang/String");
args = (*env)->NewObjectArray(env, 1, stringClass, jstr);
if (args == NULL) {
goto destroy;
}
(*env)->CallStaticVoidMethod(env, cls, mid, args);
destroy:
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
}
(*jvm)->DestroyJavaVM(jvm);
}
/* End of file: invoke.c */
From | Date | Subject | |
---|---|---|---|
Next Message | Krzysztof | 2010-12-16 13:52:40 | [Pljava-dev] Returning complex complex objects |
Previous Message | Johann 'Myrkraverk' Oskarsson | 2010-12-15 15:42:40 | [Pljava-dev] Returning complex complex objects |