Hacker News new | ask | show | jobs
by Reason077 2903 days ago
Back in the day, GCC's Java native compiler "GCJ", had an alternative native method interface called CNI.

GCC recognized #extern "Java" in headers generated from class files. You could then call (gcj-compiled) Java classes from C++ as if they were native C++ classes, as well as implement Java "native" methods in natural C++.

The whole thing performed a lot better than JNI since it was, more or less, just using the standard platform calling conventions. Calling a native CNI method from Java had the same overhead as any regular Java virtual method call.

Ultimately, GCJ faded away because there wasn't a great deal of interest in native Java compilation back then, and too many compatibility challenges in the pre-OpenJDK days. But it's interesting to see many of it's ideas coming back now in the form of Graal/GraalVM.

1 comments

There was interest in native Java compilation, not in doing the work for free.

Most third party commercial Java SDKs do have support for native compilation, specially on the embedded space.

Around 2009 GCJ suffered an exodus of developers to OpenJDK.