News for hackers. Stuff that matters.
Re:C Isn't a Programming Language Anymore by pjmlp on Tuesday November 08, 2022 @02:41AM (#33516846)
JNI isn't a C ABI from the point of view what is being discussed here, it is a marshaling library.

You don't do OS syscalls via JNI, rather marshal representation of Java objects for consuptiom from native languages.

Re:C Isn't a Programming Language Anymore by cryptonector on Tuesday November 08, 2022 @10:06AM (#33519772)
You clearly haven't written a JNI.

JNI is an API between the JVM and C- or C++-coded plugins that can implement native methods. "Native method" means "written in C (or C++)". There's a) a standard interface that C-coded methods must present (depending on their Java signature) and b) a set of utility C functions provided by the JVM.

Because these plugins are loaded via `dlopen()`/`LoadLibrary_Ex()`/etc. the JNI API has an ABI.

If you don't believe me go look it up. There's a ton of resources on JNI. Here's an example taken from the wikipedia page on JNI:

  extern "C"
  JNIEXPORT void JNICALL Java_ClassName_MethodName
    (JNIEnv *env, jobject obj, jstring javaString)
  {
      const char *nativeString = env->GetStringUTFChars(javaString, 0);
  
      //Do something with the nativeString

      env->ReleaseStringUTFChars(javaString, nativeString);
  }