CNI invocation API proposal

Joerg Brunsmann
Tue Apr 17 10:10:00 GMT 2001

Jeff Sturm <> wrote:

> >     1. Do we need to attach/detach threads to the GCJ JVM?
> To avoid that I would prefer not to have both attach and detach methods,
> but rather a single method that will register the calling thread, execute
> a callback function, then unregister itself, similar to what JvRunMain
> does now (but without spawning a new thread).

To be honest, my simplemindedness doesn't allow me to understand that.
The JvRunMain method looks like this:

JvRunMain (jclass klass, int argc, const char **argv)

  _Jv_argv = argv;
  _Jv_argc = argc;

  main_init ();
  char exec_name[20];
  sprintf (exec_name, "/proc/%d/exe", getpid ());
  _Jv_ThisExecutable (exec_name);
  _Jv_ThisExecutable (argv[0]);

  arg_vec = JvConvertArgv (argc - 1, argv + 1);
  main_thread = new gnu::gcj::runtime::FirstThread (klass, arg_vec);

  _Jv_ThreadWait ();

  int status = (int) java::lang::ThreadGroup::had_uncaught_exception;
  java::lang::Runtime::getRuntime ()->_exit (status);

Ok, main_init() will be executed only once when the JavaVM is
created. Then the main_thread is created and started which
waits for termination of all other threads.

How would you foresee a method which registers the calling
thread, runs a callback and unregiester itself?

> >     3. Is it possible and reasonable to build a JNI based 
> >        invocation interface upon the CNI based approach?
> I think so, provided you can safely implement attach/detach and
> dynamically load the VM (i.e. dlload

Do you anticipate high hurdles while realising this approach?

Thanks a lot,


Do You Yahoo!?
Gesendet von Yahoo! Mail -

More information about the Java mailing list