JNI is a more apt name because it currently only supports the JNI. I also believe that CMake uses the terminology JNI here as well. JNI is currently the only way to interact with the JVM through native code, but there is a project called "Project Panama" which aims to be another way for native code to interact with the JVM.pull/10049/head
parent
f9bfeb2add
commit
96b2469544
15 changed files with 100 additions and 64 deletions
@ -0,0 +1,6 @@ |
||||
## JDK System Dependency Renamed from `jdk` to `jni` |
||||
|
||||
The JDK system dependency is useful for creating native Java modules using the |
||||
JNI. Since the purpose is to find the JNI, it has been decided that a better |
||||
name is in fact "jni". Use of `dependency('jdk')` should be replaced with |
||||
`dependency('jni')`. |
@ -1,9 +0,0 @@ |
||||
#include <jni.h> |
||||
|
||||
#include "com_mesonbuild_JdkTest.h" |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_mesonbuild_JdkTest_jdk_1test |
||||
(JNIEnv *env, jclass clazz) |
||||
{ |
||||
return (jint)0xdeadbeef; |
||||
} |
@ -1,18 +0,0 @@ |
||||
sources = [ |
||||
files( |
||||
'native.c', |
||||
'com_mesonbuild_JdkTest.c', |
||||
), |
||||
native_headers |
||||
] |
||||
|
||||
jdkjava = shared_module( |
||||
'jdkjava', |
||||
sources, |
||||
dependencies : [jdk], |
||||
include_directories : [native_header_includes] |
||||
) |
||||
|
||||
jdkjava_dep = declare_dependency( |
||||
link_with : jdkjava, |
||||
) |
@ -1,17 +0,0 @@ |
||||
jdkjar = jar( |
||||
'jdkjar', |
||||
'com' / 'mesonbuild' / 'JdkTest.java', |
||||
main_class : 'com.mesonbuild.JdkTest', |
||||
) |
||||
|
||||
test( |
||||
'jdktest', |
||||
java, |
||||
args: [ |
||||
'-Djava.library.path=@0@'.format(fs.parent(jdkjava.full_path())), |
||||
'-jar', |
||||
jdkjar, |
||||
], |
||||
protocol : 'exitcode', |
||||
depends : [jdkjava], |
||||
) |
@ -0,0 +1,9 @@ |
||||
#include <jni.h> |
||||
|
||||
#include "com_mesonbuild_JniTest.h" |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_mesonbuild_JniTest_jni_1test |
||||
(JNIEnv *env, jclass clazz) |
||||
{ |
||||
return (jint)0xdeadbeef; |
||||
} |
@ -0,0 +1,18 @@ |
||||
sources = [ |
||||
files( |
||||
'native.c', |
||||
'com_mesonbuild_JniTest.c', |
||||
), |
||||
native_headers |
||||
] |
||||
|
||||
jnijava = shared_module( |
||||
'jnijava', |
||||
sources, |
||||
dependencies : [jni_dep], |
||||
include_directories : [native_header_includes] |
||||
) |
||||
|
||||
jnijava_dep = declare_dependency( |
||||
link_with : jnijava |
||||
) |
@ -1,15 +1,15 @@ |
||||
package com.mesonbuild; |
||||
|
||||
public final class JdkTest { |
||||
private static native int jdk_test(); |
||||
public final class JniTest { |
||||
private static native int jni_test(); |
||||
|
||||
public static void main(String[] args) { |
||||
if (jdk_test() != 0xdeadbeef) { |
||||
if (jni_test() != 0xdeadbeef) { |
||||
throw new RuntimeException("jdk_test() did not return 0"); |
||||
} |
||||
} |
||||
|
||||
static { |
||||
System.loadLibrary("jdkjava"); |
||||
System.loadLibrary("jnijava"); |
||||
} |
||||
} |
@ -1,3 +1,3 @@ |
||||
native_headers = javamod.generate_native_headers( |
||||
'JdkTest.java', package: 'com.mesonbuild', classes: ['JdkTest']) |
||||
'JniTest.java', package: 'com.mesonbuild', classes: ['JdkTest']) |
||||
native_header_includes = include_directories('.') |
@ -0,0 +1,17 @@ |
||||
jnijar = jar( |
||||
'jnijar', |
||||
'com' / 'mesonbuild' / 'JniTest.java', |
||||
main_class : 'com.mesonbuild.JniTest', |
||||
) |
||||
|
||||
test( |
||||
'jnitest', |
||||
java, |
||||
args: [ |
||||
'-Djava.library.path=@0@'.format(fs.parent(jnijava.full_path())), |
||||
'-jar', |
||||
jnijar, |
||||
], |
||||
protocol : 'exitcode', |
||||
depends : [jnijava], |
||||
) |
Loading…
Reference in new issue