I have a function named “Java_com_microej_example_hello_HelloWorld_SNI_CALL_TEST” in C code, and I tried to call it in java code by the name “SNI_CALL_TEST”.
However, the error happend as showed below, then I changed the function’s name to the specified in the KEIL error message–“Java_com_microej_example_hello_HelloWorld_SNI_1CALL_1TEST”, the build got ok and java called the function correctly.
Why do I need to add the Bold characters above to the function’s name in C code? It’s not the right way to use the SNI as described in Example-Standalone-Java-C-Interface.
Hi @MJ163,
The 1 is added because you use an underscore _ in your java method’s name. We need to do so to avoid conflict in our naming convention. The naming convention is defined in the specification of the ESR (Chapter 3.3 http://www.e-s-r.net/download/specification/ESR-SPE-0012-SNI_GT-1.2-H.pdf).
We have a tool to generate the function to implements:
- Open your .platform
- In modules, check Java-to-C -> MicroEJ Java H
- Build your platform
- Create a new MicroEJ Tool (Run -> Run Configuration)
- Select your platform
- Select the settings “MicroEJ Java H”
- in configuration tab, Go to Classpath
- Add the folder where you define your native in java
- Run
- Your header file will be generated
Regards,
Pierre