Fix: Make the JNI interface actually work
authorAlexandre Montplaisir <alexandre.montplaisir@polymtl.ca>
Thu, 5 Apr 2012 21:15:57 +0000 (17:15 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 5 Apr 2012 21:21:04 +0000 (17:21 -0400)
Now a user can import LTTngUst.java (which is now in a proper
package) and then define tracepoints in his application with:

LTTngUst.tracepointString(name, args);

We could eventually ship it in a .jar when the JNI interface is
enabled. It's still very basic, only string payloads are
implemented, and there is no mechanism to enable/disable trace
points call sites at runtime (they are always enabled). The event under
which these events appear is "lttng_ust_java:string".

Signed-off-by: Alexandre Montplaisir <alexandre.montplaisir@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-java/.gitignore
liblttng-ust-java/LTTNG_UST.c [deleted file]
liblttng-ust-java/LTTNG_UST.java [deleted file]
liblttng-ust-java/LTTngUst.c [new file with mode: 0644]
liblttng-ust-java/LTTngUst.java [new file with mode: 0644]
liblttng-ust-java/Makefile.am

index ab97d04108ffdbc508f49aa8cc2097390f8aa483..677373ea416b627ca5039cfcb00cbe99b6827e6d 100644 (file)
@@ -1,2 +1,2 @@
-UST.class
-UST.h
+org_lttng_ust_LTTngUst.h
+org/
diff --git a/liblttng-ust-java/LTTNG_UST.c b/liblttng-ust-java/LTTNG_UST.c
deleted file mode 100644 (file)
index af29c1e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <jni.h>
-
-#define TRACEPOINT_DEFINE
-#define TRACEPOINT_CREATE_PROBES
-#include "lttng_ust_java.h"
-
-JNIEXPORT void JNICALL Java_LTTNG_UST_ust_1java_1event (JNIEnv *env,
-                                               jobject jobj,
-                                               jstring ev_name,
-                                               jstring args)
-{
-       jboolean iscopy;
-       const char *ev_name_cstr = (*env)->GetStringUTFChars(env, ev_name,
-                                                       &iscopy);
-       const char *args_cstr = (*env)->GetStringUTFChars(env, args, &iscopy);
-
-       tracepoint(lttng_ust_java, string, ev_name_cstr, args_cstr);
-}
diff --git a/liblttng-ust-java/LTTNG_UST.java b/liblttng-ust-java/LTTNG_UST.java
deleted file mode 100644 (file)
index 7ec6110..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-class LTTNG_UST {
-       public static native void lttng_ust_java_string(String name, String arg);
-       static {
-               System.loadLibrary("lttng-ust-java");
-       }
-}
-
diff --git a/liblttng-ust-java/LTTngUst.c b/liblttng-ust-java/LTTngUst.c
new file mode 100644 (file)
index 0000000..3d23d6a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <jni.h>
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "lttng_ust_java.h"
+
+JNIEXPORT void JNICALL Java_org_lttng_ust_LTTngUst_tracepointString(JNIEnv *env,
+                                               jobject jobj,
+                                               jstring ev_name,
+                                               jstring args)
+{
+       jboolean iscopy;
+       const char *ev_name_cstr = (*env)->GetStringUTFChars(env, ev_name,
+                                                       &iscopy);
+       const char *args_cstr = (*env)->GetStringUTFChars(env, args, &iscopy);
+
+       tracepoint(lttng_ust_java, string, ev_name_cstr, args_cstr);
+
+       (*env)->ReleaseStringUTFChars(env, ev_name, ev_name_cstr);
+       (*env)->ReleaseStringUTFChars(env, args, args_cstr);
+}
diff --git a/liblttng-ust-java/LTTngUst.java b/liblttng-ust-java/LTTngUst.java
new file mode 100644 (file)
index 0000000..d3f1eda
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.lttng.ust;
+
+class LTTngUst {
+       public static native void tracepointString(String name, String arg);
+       static {
+               System.loadLibrary("lttng-ust-java");
+       }
+}
+
index 31915d0d479b256fce1d56c613e25c72ecb872c5..9e01e045e34b78ef5c64cd423dccf6a8b83ec32b 100644 (file)
@@ -3,19 +3,20 @@ if BUILD_JNI_INTERFACE
 AM_CPPFLAGS = -I$(top_srcdir)/include
 
 lib_LTLIBRARIES = liblttng-ust-java.la
-liblttng_ust_java_la_SOURCES = LTTNG_UST.c LTTNG_UST.h lttng_ust_java.h
-dist_noinst_DATA = LTTNG_UST.java
+liblttng_ust_java_la_SOURCES = LTTngUst.c org_lttng_ust_LTTngUst.h lttng_ust_java.h
+dist_noinst_DATA = LTTngUst.java
 liblttng_ust_java_la_LIBADD = -lc -L$(top_builddir)/liblttng-ust/.libs -llttng-ust
 
-all: LTTNG_UST.class LTTNG_UST.h
+all: LTTngUst.class org_lttng_ust_LTTngUst.h
 
 clean-local:
-       rm -rf LTTNG_UST.h LTTNG_UST.class
+       rm  org_lttng_ust_LTTngUst.h
+       rm -rf org/
 
-LTTNG_UST.class: LTTNG_UST.java
-       javac -d "$(builddir)" "$(srcdir)/LTTNG_UST.java"
+LTTngUst.class: LTTngUst.java
+       javac -d "$(builddir)" "$(srcdir)/LTTngUst.java"
 
-LTTNG_UST.h: LTTNG_UST.class
-       javah -classpath ./ -jni LTTNG_UST
+org_lttng_ust_LTTngUst.h: LTTngUst.class
+       javah org.lttng.ust.LTTngUst
 
 endif
This page took 0.028588 seconds and 4 git commands to generate.