2

Will Java 8 check for the existence and correct type signature of statically loaded C/C++ functions from static JNI libraries, and produce a compile error if the correct function is not available?

As far as I can make out JEP 178, with its statically loaded libraries has been accepted and implemented in Java 8.

In response to EJP's comment. If necessary it could be a complier warning, but a better option would be if the error message gave the correct C/C++ function signature then javah wouldn't be needed for native static code.

Rich Oliver
  • 6,001
  • 4
  • 34
  • 57
  • It doesn't seem possible. The .class file is needed to run javah, which is needed to produce the DLL. Your suggestion is circular. – user207421 Nov 17 '13 at 02:47
  • I don't see how it could: JNI functions are compiled with C linkage and carry no type information for their arguments or return value. – marko Nov 17 '13 at 19:36
  • Sorry, it still doesn't make sense. You might be compiling on one platform but deploying on another. Java itself is an example of that. The JNI libraries are built later and may not be available at compile time for the .java code. Or there may be multiple versions for various reasons, not just limited to different platforms: for example, debug and release. It isn't feasible. – user207421 Nov 17 '13 at 20:07
  • There are no “statically loaded C/C++ functions from static JNI libraries” in Java. All libraries are loaded dynamically. – Holger Nov 18 '13 at 13:13
  • Statically linked JNI libraries are indeed supported in Java 8. – Stuart Marks Jul 03 '14 at 04:34

1 Answers1

1

Java SE 8 supports static linking of libraries containing native methods. See my answer to another question.

Community
  • 1
  • 1
Stuart Marks
  • 127,867
  • 37
  • 205
  • 259