Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Build Custom JNI Functions in SWT

I'm not an expert on this, but I'm betting the default target in build.xml doesn't rebuild the native libraries.

On Fri, May 21, 2010 at 2:43 PM, Belcher, Josh <Josh.Belcher@xxxxxxxxxx> wrote:
Hi All,

I am attempting to make a custom JNI function that integrates with swt - I modified OS.java and OS_Custom.c (See code below).  After I run build.xml (which says "BUILD SUCCESSFUL") I attempt to call my new function but get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.eclipse.swt.internal.win32.OS.newFunction()[I

Am I missing something to be able to write my own custom function?  Is there a good example of being able to do so? It seems as though after 3 days of searching that there wouldn't be an answer, but I hope I'm close.  Thanks.

Josh


OS.java Added:

/** @method flags=no_gen */
private static final native int[] newFunction();

OS_Custom.c Added:

#ifndef NO_newFunction
JNIEXPORT jintArray JNICALL OS_NATIVE(newFunction)
       (JNIEnv *env, jclass that)
{
       jintArray iarr = (*env)->NewIntArray(env, 256); //just to test
       int i;

       if (iarr == NULL)
       {
               return NULL; /* out of memory error thrown */
       }
       jint tmp[256];
       for (i = 0; i < 256; i++)
       {
               tmp[i] = i + 100;
       }
       (*env)->SetIntArrayRegion(env, iarr, 0, 256, tmp);

       return iarr;
}
#endif

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top