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 followed this small tutorial:

http://www.eclipse.org/swt/jnigen.php

At step 6 it mentions that it compiles the C code… now that I look at it again, it does say to copy the new libraries to the appropriate fragment.  I don’t know where the new libraries would be, or what the appropriate fragment is.  So unless build.xml does that automatically, that might be my issue.  Any thoughts?

 

 

From: platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] On Behalf Of Ryan Levering
Sent: Friday, May 21, 2010 12:56 PM
To: Eclipse Platform SWT component developers list.
Subject: 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