Calling a Java function from C++ using CNI

Tom Tromey
Tue Aug 10 16:57:00 GMT 2004

>>>>> "Shaun" == Shaun Jackman <> writes:

Shaun> What does JvCreateJavaVM accomplish?

It initializes the GC, the thread system, signals; sets up some global
constants (like primitive classes); and a few other miscellaneous

Shaun> Could it be called lazily, simply
Shaun> called the first time a Java object is created or a Java static
Shaun> function is called?

I don't think so, as that would mean adding overhead all over.
Perhaps we could make the startup sequence shorter though.

BTW, in your example, you probably want to initialize the class
before calling a static method on it.  In gcj, the caller must ensure
the class is initialized, and CNI doesn't do this checking -- you
must do it manually (this bites me from time to time :-)


More information about the Java mailing list