Update java lookups to use new nativez mechanism.
authorMichael Zucchi <michael@swordfish.com.au>
Mon, 22 Apr 2019 09:22:05 +0000 (18:52 +0930)
committerMichael Zucchi <michael@swordfish.com.au>
Mon, 22 Apr 2019 09:22:05 +0000 (18:52 +0930)
Fix a bunch of erronous variable names.
Use *MethodA() instead of varargs calls.
Fix generic type safety on getExtension() calls.
Update java.make.

config.make
java.make
src/notzed.zcl/classes/au/notzed/zcl/CLCommandQueue.java
src/notzed.zcl/classes/au/notzed/zcl/CLContext.java
src/notzed.zcl/classes/au/notzed/zcl/CLExtendable.java
src/notzed.zcl/classes/au/notzed/zcl/CLPlatform.java
src/notzed.zcl/jni/jni.make
src/notzed.zcl/jni/zcl-generate
src/notzed.zcl/jni/zcl-jni.c
src/notzed.zcl/jni/zcl-jni.def [new file with mode: 0644]

index ce5b5d1..efc723d 100644 (file)
@@ -5,36 +5,35 @@ JAVA_HOME ?= /usr/local/jdk-11.0.2
 JAVAFX_HOME ?= /usr/local/javafx-sdk-11.0.2
 FFMPEG_HOME ?= /opt/ffmpeg/4.0
 
+# See also JAVACFLAGS --module-path
 NATIVEZ_HOME=../nativez/bin/notzed.nativez/$(TARGET)
 
-JAVACFLAGS+= --module-path ../nativez/bin/notzed.nativez
-JAVACFLAGS+= -source 11
+JAVACFLAGS += --module-path ../nativez/bin/notzed.nativez
+JAVACFLAGS += -source 11
 
 JAVAC ?= javac
 JAR ?= jar
 JMOD ?= jmod
 
-
 # Linux options
 linux-amd64_CPPFLAGS = \
        -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
-linux-amd64_CFLAGS = -fPIC -Wall
+linux-amd64_CFLAGS = -fPIC -Os -Wall
 linux-amd64_CC = cc
 linux-amd64_LD = ld
 
 linux-amd64_SO = .so
 linux-amd64_LIB = lib
-linux-amd64_JMOD_LIBS = --libs
 
 # Windows options
-windows-amd64_CPPFLAGS= \
+windows-amd64_CPPFLAGS = \
        -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \
        -DHAVE_ALIGNED_MALLOC \
        -DWIN32
+windows-amd64_CFLAGS = -Os -Wall
 windows-amd64_CC = x86_64-w64-mingw32-gcc
 windows-amd64_LD = x86_64-w64-mingw32-ld
 windows-amd64_LDFLAGS = -Wl,--subsystem,windows
 
 windows-amd64_SO = .dll
 windows-amd64_LIB =
-windows-amd64_JMOD_LIBS = --cmds
index ac60f16..7228203 100644 (file)
--- a/java.make
+++ b/java.make
@@ -62,7 +62,8 @@
 # <module>_jnidir      Location for jni generated files (per target).
 # <module>_objdir      Location for c objects (per target).
 # <module>_incdir      Location for output includes, .jmod staging.
-# <module>_libdir      Location for output libraries, .jmod staging.
+# <module>_libdir      Location for output libraries, .jmod staging.  May point to _bindir.
+# <module>_bindir      Location for output commands, .jmod staging.
 
 # Define libraries
 # ----------------
@@ -92,6 +93,7 @@
 
 # <library>_SOURCES    .c, .cc, .C - source files for library.  Paths are relative to src/<module>/jni.
 # <library>_HEADERS    header files for jmod
+# <library>_COMMANDS   commands/bin/scripts for jmod
 
 # <library>_LDFLAGS    link flags
 # <library>_LIBADD     extra objects to add to link line
@@ -155,7 +157,8 @@ $(1)_genjavadir:=bin/gen/$(1)/classes
 $(1)_jnidir:=bin/$(1)/$(TARGET)/jni
 $(1)_objdir:=bin/$(1)/$(TARGET)/obj
 $(1)_incdir:=bin/$(1)/$(TARGET)/include
-$(1)_libdir:=bin/$(1)/$(TARGET)/lib
+$(1)_libdir:=$$(if $$(filter windows-%,$(TARGET)),bin/$(1)/$(TARGET)/bin,bin/$(1)/$(TARGET)/lib)
+$(1)_bindir:=bin/$(1)/$(TARGET)/bin
 ifndef $(1)_JAVA
 $(1)_JAVA := $$(shell find src/$(1)/classes -type f -name '*.java')
 endif
@@ -211,7 +214,8 @@ bin/$(1)/$(TARGET)/$(1).jmod: bin/status/$(1).classes bin/status/$(1).data
          --class-path bin/modules/$(1) \
          $$(if $$(wildcard bin/$(1)/$(TARGET)/include),--header-files bin/$(1)/$(TARGET)/include) \
          $$(if $$(wildcard src/$(1)/legal),--legal-notices src/$(1)/legal) \
-         $$($(TARGET)_JMOD_LIBS) bin/$(1)/$(TARGET)/lib \
+         $$(if $$(wildcard $$($(1)_bindir)),--cmds $$($(1)_bindir)) \
+         $$(if $$(wildcard $$($(1)_libdir)),--libs $$($(1)_libdir)) \
          $$@
 
 # Create an IDE source zip, paths have to match --module-source-path
@@ -289,7 +293,9 @@ $($(1)_objdir)/%.d: src/$(1)/jni/%.c bin/status/$(1).classes
                $($(TARGET)_CPPFLAGS) $($(2)_CPPFLAGS) $$< -o $$@.d 2>/dev/null
        @sed 's,\($$*\.o\) *:,\1 $$@ : ,g' $$@.d > $$@ ; rm $$@.d
 
-bin jni $(1) bin/$(1)/$(TARGET)/$(1).jmod: $($(1)_libdir)/$(LIB)$(2)$(SO) $(addprefix $($(1)_incdir)/,$($(2)_HEADERS))
+bin jni $(1) bin/$(1)/$(TARGET)/$(1).jmod: $($(1)_libdir)/$(LIB)$(2)$(SO) \
+       $(addprefix $($(1)_incdir)/,$($(2)_HEADERS)) \
+       $(addprefix $($(1)_bindir)/,$($(2)_COMMANDS))
 
 $(if $(filter clean dist gen,$(MAKECMDGOALS)),,-include $$($(2)_OBJS:.o=.d))
 endef
index b8eadf5..ed2539b 100644 (file)
@@ -1027,7 +1027,7 @@ public class CLCommandQueue extends CLExtendable {
        }
 
        protected GLSharing getGLSharing() {
-               return getExtension(CLPlatform.cl_khr_gl_sharing);
+               return getExtension(GLSharing.class, CLPlatform.cl_khr_gl_sharing);
        }
 
        /*
index 08153d2..a2d51c3 100644 (file)
@@ -422,11 +422,11 @@ public class CLContext extends CLExtendable {
        }
 
        protected GLSharing getGLSharing() {
-               return getExtension(CLPlatform.cl_khr_gl_sharing);
+               return getExtension(GLSharing.class, CLPlatform.cl_khr_gl_sharing);
        }
 
        protected GLEvent getGLEvent() {
-               return getExtension(CLPlatform.cl_khr_gl_event);
+               return getExtension(GLEvent.class, CLPlatform.cl_khr_gl_event);
        }
 
        /*
index f5a45ec..85e073e 100644 (file)
@@ -52,14 +52,15 @@ public abstract class CLExtendable extends CLObject {
        }
 
        /**
-        * Retrieve an extension interface for this object. Used by implementors of
+        * Retrieve an extension interface for this object.Used by implementors of
         * CLExtenable.
         *
         * @param <T>
+        * @param klass
         * @param id The extension id code on CLPlatform.
         * @return
         */
-       protected <T extends CLExtension> T getExtension(int id) {
-               return platform.getExtension(id);
+       protected <T extends CLExtension> T getExtension(Class<T> klass, int id) {
+               return platform.getExtension(klass, id);
        }
 }
index 04c538a..001b037 100644 (file)
@@ -194,12 +194,12 @@ public class CLPlatform extends CLObject {
 
        native CLExtension createExtension(int extension); // throws something
 
-       public <T extends CLExtension> T getExtension(int id) {
+       public <T extends CLExtension> T getExtension(Class<T> klass, int id) {
                synchronized (extensions) {
                        if (extensions[id] == null) {
                                extensions[id] = createExtension(id);
                        }
-                       return (T) extensions[id];
+                       return klass.cast(extensions[id]);
                }
        }
 
@@ -207,17 +207,18 @@ public class CLPlatform extends CLObject {
         * Retrieve an extension by name.
         *
         * @param <T>
+        * @param klass Required type of extension
         * @param name
         * @return
         */
-       public <T extends CLExtension> T getExtension(String name) {
+       public <T extends CLExtension> T getExtension(Class<T> klass, String name) {
                switch (name) {
                case GLSharing.NAME:
-                       return getExtension(cl_khr_gl_sharing);
+                       return getExtension(klass, cl_khr_gl_sharing);
                case au.notzed.zcl.khr.GLEvent.NAME:
-                       return getExtension(cl_khr_gl_event);
+                       return getExtension(klass, cl_khr_gl_event);
                }
                return null;
        }
-
+       
 }
index 6ba9d17..297b4bf 100644 (file)
 notzed.zcl_JNI_LIBRARIES=zcl
 
 linux-amd64_zcl_SOURCES = zcl-init-so.c
-linux-amd64_zcl_LDFLAGS = -ldl
+linux-amd64_zcl_LDLIBS = -L$(NATIVEZ_HOME)/lib -lnativez -dl
 
 windows-amd64_zcl_SOURCES = zcl-init-dll.c
+windows-amd64_zcl_LDLIBS = -L$(NATIVEZ_HOME)/bin -lnativez
 
 zcl_SOURCES=zcl-jni.c                          \
        zcl-khr-gl-event.c                      \
@@ -26,12 +27,21 @@ zcl_SOURCES=zcl-jni.c                               \
        $($(TARGET)_zcl_SOURCES)
 
 zcl_CPPFLAGS=-Isrc/notzed.zcl/jni/include      \
+       -I$(notzed.zcl_jnidir)                  \
        -Wno-deprecated-declarations            \
        -I$(NATIVEZ_HOME)/include
 
-zcl_LDLIBS=-L$(NATIVEZ_HOME)/lib -lnativez $($(TARGET)_zcl_LDFLAGS)
+zcl_LDLIBS=$($(TARGET)_zcl_LDLIBS)
+zcl_DEFS=zcl-jni.def
 
-bin/status/notzed.zcl.classes: bin/include/notzed.zcl/zcl-functions.h
+zcl_makedep=$(notzed.zcl_objdir)/$(1).o: $(notzed.zcl_jnidir)/$(1).h
+$(foreach def,$(zcl_DEFS),$(eval $(call zcl_makedep,$(def:.def=))))
+$(notzed.zcl_jnidir)/%.h: src/notzed.zcl/jni/%.def
+       @install -d $(@D)
+       $(NATIVEZ_HOME)/bin/nativez-gen -J $< > $@ || ( rm $@ ; exit 1)
+
+$(addprefix $(notzed.zcl_objdir)/,$(zcl_SOURCES:.c=.o)): bin/include/notzed.zcl/zcl-functions.h
 bin/include/notzed.zcl/zcl-functions.h: src/notzed.zcl/jni/include/CL/cl.h src/notzed.zcl/jni/zcl-generate
-       install -d $(@D)
-       src/notzed.zcl/jni/zcl-generate $< > $@.tmp && mv $@.tmp $@
+       @install -d $(@D)
+       src/notzed.zcl/jni/zcl-generate $< > $@.tmp
+       install -C $@.tmp $@
index cfe2b82..fc0de43 100755 (executable)
@@ -29,7 +29,7 @@ $cl_h = $ARGV[0];
 $fnprefix = {};
 $fnsuffix = {};
 
-open H, "<$cl_h" || die;
+open (H, "$cl_h") || die ("Can't open");
 while (<H>) {
     if (m/^extern (CL_API_ENTRY.*)/) {
        $start = $1;
index 363f21c..b4e6fce 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "zcl-extension.h"
 #include "zcl-functions.h"
+#include "zcl-jni.h"
 
 // "real" version isn't what cl.h reports
 #ifdef VERSION_IS_1_0
@@ -180,158 +181,6 @@ static jmethodID CLContext_new_pn;
 /* special constructor for handling buffer */
 static jmethodID CLBuffer_new_jb;
 
-//static jclass CLNative_classid;
-//jfieldID CLNative_p;
-
-//static jclass CLObject_classid;
-
-static jclass CLExtendable_classid;
-jfieldID CLExtendable_apiVersion;
-
-static jclass CLMemory_classid;
-
-static jclass Object_classid;
-static jclass byte_a_classid;  /* byte[] / [B */
-
-//static jclass ByteBuffer_classid;
-//static jmethodID ByteBuffer_order;
-//static jmethodID ByteBuffer_positionI;
-//static jmethodID ByteBuffer_position;
-//static jmethodID ByteBuffer_limit;
-//static jobject nativeOrder; // ByteOrder.nativeOrder()
-
-// for primitive boxing
-static jclass Long_classid;
-static jmethodID Long_valueOf;
-static jclass Integer_classid;
-static jmethodID Integer_valueOf;
-
-static jclass CLProperty_classid;
-static jmethodID CLProperty_toIntPtr; // depends on word size, toLong or toInt
-
-static jclass CLContextProperty_classid;
-
-static jclass CLContextProperty_TagValue_classid;
-static jmethodID CLContextProperty_TagValue_new_jj;
-
-static jclass CLDeviceProperty_classid;
-
-static jclass CLDeviceProperty_TagValue_classid;
-static jmethodID CLDeviceProperty_TagValue_new_jj;
-
-static jclass CLDeviceProperty_PartitionByCounts_classid;
-static jmethodID CLDeviceProperty_PartitionByCounts_new_I;
-
-static jclass CLImageDesc_classid;
-static jfieldID CLImageDesc_imageType;
-static jfieldID CLImageDesc_imageWidth;
-static jfieldID CLImageDesc_imageHeight;
-static jfieldID CLImageDesc_imageDepth;
-static jfieldID CLImageDesc_imageArraySize;
-static jfieldID CLImageDesc_imageRowPitch;
-static jfieldID CLImageDesc_imageSlicePitch;
-static jfieldID CLImageDesc_numMipLevels;
-static jfieldID CLImageDesc_numSamples;
-static jfieldID CLImageDesc_memObject;
-
-static jclass CLImageFormat_classid;
-static jfieldID CLImageFormat_channelOrder;
-static jfieldID CLImageFormat_channelDataType;
-static jmethodID CLImageFormat_new_ii;
-
-static jclass CLBufferInfoRegion_classid;
-static jfieldID CLBufferInfoRegion_origin;
-static jfieldID CLBufferInfoRegion_size;
-
-static jclass CLEventList_classid;
-static jfieldID CLEventList_index;
-static jfieldID CLEventList_events;
-static jmethodID CLEventList_add;
-
-static jclass CLContextNotify_classid;
-static jmethodID CLContextNotify_notify;
-
-static jclass CLEventNotify_classid;
-static jmethodID CLEventNotify_notify;
-
-static jclass CLNotify_classid;
-static jmethodID CLNotify_notify;
-
-static jclass CLNativeKernel_classid;
-static jmethodID CLNativeKernel_invoke;
-
-static const NZRefTable reftable[] = {
-
-       JCLASS(CLExtendable_classid, "au/notzed/zcl/CLExtendable"),
-       JFIELD(CLExtendable_apiVersion, "apiVersion", "I"),
-
-       JCLASS(CLMemory_classid, "au/notzed/zcl/CLMemory"),
-
-       JCLASS(Object_classid, "java/lang/Object"),
-       JCLASS(Long_classid, "java/lang/Long"),
-       JSMETHOD(Long_valueOf, "valueOf", "(J)Ljava/lang/Long;"),
-       JCLASS(Integer_classid, "java/lang/Integer"),
-       JSMETHOD(Integer_valueOf, "valueOf", "(I)Ljava/lang/Integer;"),
-       JCLASS(byte_a_classid, "[B"),
-
-       JCLASS(CLProperty_classid, "au/notzed/zcl/CLProperty"),
-#if UINTPTR_MAX == 0xffffffffU
-       JSMETHOD(CLProperty_toIntPtr, "toInt", "([Ljava/lang/Object;)[I"),
-#else
-       JSMETHOD(CLProperty_toIntPtr, "toLong", "([Ljava/lang/Object;)[J"),
-#endif
-
-       JCLASS(CLContextProperty_classid, "au/notzed/zcl/CLContextProperty"),
-       JCLASS(CLContextProperty_TagValue_classid, "au/notzed/zcl/CLContextProperty$TagValue"),
-       JMETHOD(CLContextProperty_TagValue_new_jj, "<init>", "(JJ)V"),
-
-       JCLASS(CLDeviceProperty_classid, "au/notzed/zcl/CLDeviceProperty"),
-       JCLASS(CLDeviceProperty_TagValue_classid, "au/notzed/zcl/CLDeviceProperty$TagValue"),
-       JMETHOD(CLDeviceProperty_TagValue_new_jj, "<init>", "(JJ)V"),
-       JCLASS(CLDeviceProperty_PartitionByCounts_classid, "au/notzed/zcl/CLDeviceProperty$PartitionByCounts"),
-       JMETHOD(CLDeviceProperty_PartitionByCounts_new_I, "<init>", "([I)V"),
-       
-       JCLASS(CLImageDesc_classid, "au/notzed/zcl/CLImageDesc"),
-       JFIELD(CLImageDesc_imageType, "imageType", "I"),
-       JFIELD(CLImageDesc_imageWidth, "imageWidth", "I"),
-       JFIELD(CLImageDesc_imageHeight, "imageHeight", "I"),
-       JFIELD(CLImageDesc_imageDepth, "imageDepth", "I"),
-       JFIELD(CLImageDesc_imageArraySize, "imageArraySize", "I"),
-       JFIELD(CLImageDesc_imageRowPitch, "imageRowPitch", "I"),
-       JFIELD(CLImageDesc_imageSlicePitch, "imageSlicePitch", "I"),
-       JFIELD(CLImageDesc_numMipLevels, "numMipLevels", "I"),
-       JFIELD(CLImageDesc_numSamples, "numSamples", "I"),
-       JFIELD(CLImageDesc_memObject, "memObject", "Lau/notzed/zcl/CLMemory;"),
-
-       JCLASS(CLImageFormat_classid, "au/notzed/zcl/CLImageFormat"),
-       JMETHOD(CLImageFormat_new_ii, "<init>", "(II)V"),
-       JFIELD(CLImageFormat_channelOrder, "channelOrder", "I"),
-       JFIELD(CLImageFormat_channelDataType, "channelDataType", "I"),
-
-       JCLASS(CLBufferInfoRegion_classid, "au/notzed/zcl/CLBufferInfo$Region"),
-       JFIELD(CLBufferInfoRegion_origin, "origin", "J"),
-       JFIELD(CLBufferInfoRegion_size, "size", "J"),
-
-       JCLASS(CLEventList_classid, "au/notzed/zcl/CLEventList"),
-       JMETHOD(CLEventList_add, "add", "(J)V"),
-       JFIELD(CLEventList_index, "index", "I"),
-       JFIELD(CLEventList_events, "events", "[J"),
-
-       JCLASS(CLContextNotify_classid, "au/notzed/zcl/CLContextNotify"),
-       JMETHOD(CLContextNotify_notify, "notify", "(Ljava/lang/String;Ljava/nio/ByteBuffer;)V"),
-
-       JCLASS(CLEventNotify_classid, "au/notzed/zcl/CLEventNotify"),
-       JMETHOD(CLEventNotify_notify, "notify", "(Lau/notzed/zcl/CLEvent;I)V"),
-
-       JCLASS(CLNotify_classid, "au/notzed/zcl/CLNotify"),
-       JMETHOD(CLNotify_notify, "notify", "(Ljava/lang/Object;)V"),
-
-       JCLASS(CLNativeKernel_classid, "au/notzed/zcl/CLNativeKernel"),
-       JMETHOD(CLNativeKernel_invoke, "invoke", "([Ljava/lang/Object;)V"),
-
-       JEND
-};
-
 static int debug_sync = 0;
 
 /* ********************************************************************** */
@@ -367,7 +216,7 @@ jint JNI_OnLoad(JavaVM *vmi, void *reserved) {
 
        if (nativez_OnLoad(vmi, env)
            || init_dynamic(env)
-           || nativez_ResolveReferences(env, reftable) != 0)
+           || nativez_ResolveReferences(env, java_names, &java) != 0)
                return 0;
 
        char *s = getenv("ZCL_SYNC");
@@ -485,15 +334,15 @@ jobject toObject(JNIEnv *env, int ctype, size_t size, void *value) {
                //case  au_notzed_zcl_CLObject_CTYPE_BYTE:
        case  au_notzed_zcl_CLObject_CTYPE_INT:
                jarg.i = ((cl_int *)value)[0];
-               jres = (*env)->CallStaticObjectMethodA(env, Integer_classid, Integer_valueOf, &jarg);
+               jres = (*env)->CallStaticObjectMethodA(env, Integer_classid, Integer_valueOf_i, &jarg);
                break;
        case  au_notzed_zcl_CLObject_CTYPE_LONG:
                jarg.j = ((cl_long *)value)[0];
-               jres = (*env)->CallStaticObjectMethodA(env, Long_classid, Long_valueOf, &jarg);
+               jres = (*env)->CallStaticObjectMethodA(env, Long_classid, Long_valueOf_j, &jarg);
                break;
        case  au_notzed_zcl_CLObject_CTYPE_SIZE_T:
                jarg.j = ((size_t *)value)[0];
-               jres = (*env)->CallStaticObjectMethodA(env, Long_classid, Long_valueOf, &jarg);
+               jres = (*env)->CallStaticObjectMethodA(env, Long_classid, Long_valueOf_j, &jarg);
                break;
        default:
                jres = toCLObject(env, ctype, ((void **)value)[0]);
@@ -573,12 +422,12 @@ jobject toArray(JNIEnv *env, int ctype, size_t size, void *value) {
 
 /* Convert a tag/value property array to a primitive array */
 void *fromPropertyArray(JNIEnv *env, jobjectArray jpropArray) {
-#if UINTPTR_MAX == 0xffffffff
+#if UINTPTR_MAX == 0xffffffffU
        jint *res = NULL;
        
        if (jpropArray) {
                jvalue jargs = { .l = jpropArray };
-               jlongArray ptmp = (*env)->CallStaticObjectMethodA(env, CLProperty_classid, CLProperty_toIntPtr, &jargs);
+               jlongArray ptmp = (*env)->CallStaticObjectMethodA(env, CLProperty_classid, CLProperty_toInt__l, &jargs);
                
                if (!(*env)->ExceptionCheck(env)) {
                        jint plen = (*env)->GetArrayLength(env, ptmp);
@@ -595,7 +444,7 @@ void *fromPropertyArray(JNIEnv *env, jobjectArray jpropArray) {
        
        if (jpropArray) {
                jvalue jargs = { .l = jpropArray };
-               jlongArray ptmp = (*env)->CallStaticObjectMethodA(env, CLProperty_classid, CLProperty_toIntPtr, &jargs);
+               jlongArray ptmp = (*env)->CallStaticObjectMethodA(env, CLProperty_classid, CLProperty_toLong__l, &jargs);
                
                if (!(*env)->ExceptionCheck(env)) {
                        jint plen = (*env)->GetArrayLength(env, ptmp);
@@ -689,7 +538,7 @@ int events_post(JNIEnv *env, struct events_info *einfo, jobject jevents) {
        if (jevents) {
                jvalue arg = { .j = (uintptr_t)einfo->event };
 
-               (*env)->CallVoidMethodA(env, jevents, CLEventList_add, &arg);
+               (*env)->CallVoidMethodA(env, jevents, CLEventList_add_j, &arg);
        }
 
        return 0;
@@ -737,11 +586,11 @@ static void build_notify_hook(cl_program prog, void *data) {
                /* For linking, this is the first time we've seen the program */
                jvalue arg = { .l = toCLObject(env, au_notzed_zcl_CLObject_CTYPE_PROGRAM, prog) };
 
-               (*env)->CallVoidMethodA(env, info->jnotify, CLNotify_notify, &arg);
+               (*env)->CallVoidMethodA(env, info->jnotify, CLNotify_notify_l, &arg);
        } else if (info->prog == prog) {
                jvalue arg = { .l = info->jprog };
 
-               (*env)->CallVoidMethodA(env, info->jnotify, CLNotify_notify, &arg);
+               (*env)->CallVoidMethodA(env, info->jnotify, CLNotify_notify_l, &arg);
        } else {
                fprintf(stderr, "build_notify_hook given wrong cl_program\n");
        }
@@ -978,7 +827,7 @@ static jobjectArray getInfoProperties
 
                        jo = (*env)->NewObject(env,
                                               CLDeviceProperty_PartitionByCounts_classid,
-                                              CLDeviceProperty_PartitionByCounts_new_I,
+                                              CLDeviceProperty_PartitionByCounts_new__i,
                                               jcounts);
                        break;
                }
@@ -1303,7 +1152,12 @@ static void context_notify_hook(const char *error_info, const void *private_info
        if (private_info && private_size)
                jprivate_info = nativez_NewDirectBuffer(env, (void *)private_info, private_size);
 
-       (*env)->CallVoidMethod(env, jnotify, CLContextNotify_notify, jerror_info, jprivate_info);
+       jvalue args[2] = {
+               { .l = jerror_info },
+               { .l = jprivate_info }
+       };
+
+       (*env)->CallVoidMethodA(env, jnotify, CLContextNotify_notify_ll, args);
 }
 
 JNIEXPORT jobject JNICALL Java_au_notzed_zcl_CLContext_createContext
@@ -2278,7 +2132,7 @@ static void destroy_notify_hook(cl_mem mem, void *data) {
        if (info->mem == mem) {
                jvalue arg = { .l = info->jmem };
 
-               (*env)->CallVoidMethodA(env, info->jnotify, CLNotify_notify, &arg);
+               (*env)->CallVoidMethodA(env, info->jnotify, CLNotify_notify_l, &arg);
        } else
                fprintf(stderr, "destroy_notify_hook given wrong cl_mem\n");
 
@@ -2971,9 +2825,13 @@ static void event_notify_hook(cl_event event, cl_int status, void *data) {
                return;
        }
 
-       if (info->event == event)
-               (*env)->CallVoidMethod(env, info->jnotify, CLEventNotify_notify, info->jevent, status);
-       else
+       if (info->event == event) {
+               jvalue args[2] = {
+                       { .l = info->jevent },
+                       { .i = status }
+               };
+               (*env)->CallVoidMethodA(env, info->jnotify, CLEventNotify_notify_li, args);
+       } else
                fprintf(stderr, "destroy_notify_hook given wrong cl_mem\n");
 
        (*env)->DeleteGlobalRef(env, info->jnotify);
@@ -3996,7 +3854,7 @@ static void native_kernel_hook(void *data) {
        }
 
        jvalue arg = { .l = kargs };
-       (*env)->CallVoidMethodA(env, info->jkernel, CLNativeKernel_invoke, &arg);
+       (*env)->CallVoidMethodA(env, info->jkernel, CLNativeKernel_invoke__l, &arg);
 
        native_kernel_free(env, info);
 }
diff --git a/src/notzed.zcl/jni/zcl-jni.def b/src/notzed.zcl/jni/zcl-jni.def
new file mode 100644 (file)
index 0000000..4b58795
--- /dev/null
@@ -0,0 +1,73 @@
+java CLExtendable au/notzed/zcl/CLExtendable {
+        apiVersion, I
+}
+java CLMemory au/notzed/zcl/CLMemory {
+}
+
+java Object java/lang/Object {
+}
+java Long java/lang/Long {
+       static valueOf, (J)Ljava/lang/Long;
+}
+java Integer java/lang/Integer {
+       static valueOf, (I)Ljava/lang/Integer;
+}
+java byte_a [B {
+}
+
+java CLProperty au/notzed/zcl/CLProperty {
+       static toInt, ([Ljava/lang/Object;)[I
+       static toLong, ([Ljava/lang/Object;)[J
+}
+java CLContextProperty au/notzed/zcl/CLContextProperty {
+}
+java CLContextProperty_TagValue au/notzed/zcl/CLContextProperty$TagValue {
+        <init>, (JJ)V
+}
+java CLDeviceProperty au/notzed/zcl/CLDeviceProperty {
+}
+java CLDeviceProperty_TagValue au/notzed/zcl/CLDeviceProperty$TagValue {
+        <init>, (JJ)V
+}
+java CLDeviceProperty_PartitionByCounts au/notzed/zcl/CLDeviceProperty$PartitionByCounts {
+        <init>, ([I)V
+}
+java CLImageDesc au/notzed/zcl/CLImageDesc {
+        imageType, I
+        imageWidth, I
+        imageHeight, I
+        imageDepth, I
+        imageArraySize, I
+        imageRowPitch, I
+        imageSlicePitch, I
+        numMipLevels, I
+        numSamples, I
+        memObject, Lau/notzed/zcl/CLMemory;
+}
+java CLImageFormat au/notzed/zcl/CLImageFormat {
+        <init>, (II)V
+        channelOrder, I
+        channelDataType, I
+}
+java CLBufferInfoRegion au/notzed/zcl/CLBufferInfo$Region {
+        origin, J
+        size, J
+}
+java CLEventList au/notzed/zcl/CLEventList {
+        add, (J)V
+        index, I
+        events, [J
+}
+java CLContextNotify au/notzed/zcl/CLContextNotify {
+        notify, (Ljava/lang/String;Ljava/nio/ByteBuffer;)V
+}
+java CLEventNotify au/notzed/zcl/CLEventNotify {
+        notify, (Lau/notzed/zcl/CLEvent;I)V
+}
+java CLNotify au/notzed/zcl/CLNotify {
+        notify, (Ljava/lang/Object;)V
+}
+java CLNativeKernel au/notzed/zcl/CLNativeKernel {
+        invoke, ([Ljava/lang/Object;)V
+}
+