--- /dev/null
+// The Sample-java.java file
+public class Sample
+{
+ // Declaration of the Native (C) function
+ private static native void trace_java_generic_string(String arg);
+ static {
+ System.loadLibrary("ltt-java-string");
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println("Hello world");
+ Sample.trace_java_generic_string("Tracing from java");
+ }
+}
--- /dev/null
+#!/bin/sh
+
+javac Sample.java
+CLASSPATH=.:/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/bin javah -jni Sample
+gcc -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/include \
+ -I /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/include/linux \
+ -shared -Wl,-soname,libltt-java-string \
+ -o libltt-java-string.so ltt-java-string.c \
+ ../ltt-facility-loader-user_generic.c
+LD_LIBRARY_PATH=. java Sample
--- /dev/null
+
+#include <jni.h>
+#include "Sample.h"
+#include <stdio.h>
+#include <unistd.h>
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_generic.h>
+
+JNIEXPORT void JNICALL Java_Sample_trace_1java_1generic_1string
+ (JNIEnv *env, jobject obj, jstring jstr)
+{
+ const char *str;
+ str = (*env)->GetStringUTFChars(env, jstr, NULL);
+ if (str == NULL) return; // out of memory error thrown
+ trace_user_generic_string(str);
+ (*env)->ReleaseStringUTFChars(env, jstr, str);
+}
+