Listing 3

(a)
HelloWorld.java
package noodleglue.examples.helloWorld;
import noodle.noodleGlue.*;
/** Generated from non-class methods */
public class HelloWorld extends Bridgable
{
     // Call to Library loader on <cinit>
     static
     {
          noodle.noodleGlue.library.HelloWorldJNILibrary.loadNativeLibrary();
     }
     
     //------------------------------ | -----------------------------------
     //------------------------ Native methods ----------------------------
     //------------------------------ | -----------------------------------
     
     static private final native java.lang.String 
            staticNative_HelloWorldHelloWorld18hhelloWorldjava1lang1String();
     
     //------------------------------ | -----------------------------------
     //----- Java bridging methods (which call native methods) ------------
     //------------------------------ | -----------------------------------
     
     //========================= helloWorld ================================
     
     static public java.lang.String helloWorld()
     {
         java.lang.String returnValueVal=
           staticNative_HelloWorldHelloWorld18hhelloWorldjava1lang1String();
         String returnValue=returnValueVal;
         return returnValue;
     }
}


(b)
HelloWorldJNILibrary.java

package noodle.noodleGlue.library;
public class HelloWorldJNILibrary
{
     private static boolean fLoaded = false;
     /** Called statically on class initialisation for each wrapper class,
       * this method loads the native library without user intervention.
       * Synchronized to prevent any native access before library 
       * calls OnJNILoad 
       */
     public static final void loadNativeLibrary()
     {
          if (!fLoaded) synchronized (HelloWorldJNILibrary.class)
          {
               if (noodle.noodleGlue.NativeLibrary.DEBUG_LIBRARIES==true)
                    System.loadLibrary("HelloWorldD");
               else
                    System.loadLibrary("HelloWorld");
               fLoaded=true;
          }
     }
}


(c)
HelloWorldJNI.cpp

#include <NoodleGlue/Bridgable.h>
#include <HelloWorld/HelloWorld.h>
extern "C"
{

//========================== helloWorld =====================================
JNIEXPORT jstring JNICALL Java_noodleglue_examples_
            helloWorld_HelloWorld_staticNative_
            1HelloWorldHelloWorld18hhelloWorldjava1lang1String
            (JNIEnv *jpEnv,jclass jClassRef)
{
    const char* returnValue = ((char*) ::helloWorld());
    jstring returnValueVal;
    returnValueVal=NoodleGlue::CJNIEnv::toJavaString(jpEnv,returnValue);
    return returnValueVal;
}
}