-// The Sample-java.java file
+// The Sample.java file
public class Sample
{
// Declaration of the Native (C) function
--- /dev/null
+
+import ThreadBrand;
+
+// The Sample.java file
+public class TestBrand
+{
+ public static void main(String[] args)
+ {
+ ThreadBrand.trace_java_generic_thread_brand("Brand_test");
+ }
+}
--- /dev/null
+// The ThreadBrand.java file
+public class ThreadBrand
+{
+ // Declaration of the Native (C) function
+ private static native void trace_java_generic_thread_brand(String arg);
+ static {
+ System.loadLibrary("ltt-java-thread_brand");
+ }
+}
#!/bin/sh
+#Sample
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 \
-o libltt-java-string.so ltt-java-string.c \
../ltt-facility-loader-user_generic.c
LD_LIBRARY_PATH=. java Sample
+
+#TestBrand
+javac TestBrand.java
+CLASSPATH=.:/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/bin javah -jni TestBrand
+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-thread_brand \
+ -o libltt-java-thread_brand.so ltt-java-thread_brand.c \
+ ../ltt-facility-loader-user_generic.c
+LD_LIBRARY_PATH=. java TestBrand
--- /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_ThreadBrand_trace_1java_1generic_1thread_brand
+ (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_thread_brand(str);
+ (*env)->ReleaseStringUTFChars(env, jstr, str);
+}
+