pg.ddx.io  pljava-dev@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Subject: [Pljava-dev] Java VM stalls during
Date: Wed, 15 Dec 2010 16:09:01 +0000
Message-ID: <AANLkTinctdKu7Ox++p6071ZkDF=V=8DzYWN98-+G8prk@mail.gmail.com> (raw)
In-Reply-To: <1291959132968-3299847.post@n5.nabble.com>
References: <AANLkTim7a8zeXKQb35bFdSGuGj2WD2x4ZPP9i_Tr+xcy@mail.gmail.com>
	<1291615093757-3293612.post@n5.nabble.com>
	<AANLkTi=yWfCoownj+R8GLgmZp0X8xwF2yDNhhYg0wQs1@mail.gmail.com>
	<1291783942566-3296921.post@n5.nabble.com>
	<1291959132968-3299847.post@n5.nabble.com>

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 */




view thread (10+ messages)  latest in thread

Message-ID: <AANLkTinctdKu7Ox++p6071ZkDF=V=8DzYWN98-+G8prk@mail.gmail.com>
Permalink:  ../AANLkTinctdKu7Ox++p6071ZkDF=V=8DzYWN98-+G8prk@mail.gmail.com/
Also on:    postgresql.org/message-id/AANLkTinctdKu7Ox++p6071ZkDF=V=8DzYWN98-+G8prk@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] Java VM stalls during
  In-Reply-To: <AANLkTinctdKu7Ox++p6071ZkDF=V=8DzYWN98-+G8prk@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox