[lttng-dev] [PATCH lttng-ust] Fix: build jni libs with openjdk >= 10
Michael Jeanson
mjeanson at efficios.com
Thu May 3 15:42:54 EDT 2018
In openjdk 10, the "javah" utility used to generate c headers from java
classes was removed and replaced with an option of "javac".
When we detect "javac" but no "javah", assume we are working with
openjdk >= 10 and configure the build system to use the proper tool and
switches.
Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
configure.ac | 2 ++
.../java/lttng-ust-agent-common/Makefile.am | 6 ++++++
.../java/lttng-ust-agent-jul/Makefile.am | 6 ++++++
.../java/lttng-ust-agent-log4j/Makefile.am | 6 ++++++
liblttng-ust-java/Makefile.am | 8 ++++++++
5 files changed, 28 insertions(+)
diff --git a/configure.ac b/configure.ac
index 4fc6f9ca..a762b8c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -371,6 +371,8 @@ AS_IF([test "x$jni_interface" = "xyes" || test "x$java_agent_jul" = "xyes" || te
CPPFLAGS="$CPPFLAGS $JNI_CPPFLAGS"
AX_PROG_JAVAH
CPPFLAGS="$saved_CPPFLAGS"
+
+ AM_CONDITIONAL([HAVE_JAVAH], [test "x$JAVAH" != "x"])
])
AS_IF([test "x$java_agent_log4j" = "xyes"], [
diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/Makefile.am b/liblttng-ust-java-agent/java/lttng-ust-agent-common/Makefile.am
index 26b2ef25..ed551eb4 100644
--- a/liblttng-ust-java-agent/java/lttng-ust-agent-common/Makefile.am
+++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/Makefile.am
@@ -50,11 +50,17 @@ classes = $(pkgpath)/*.class \
$(jarfile): classnoinst.stamp
$(JAR) cfm $(JARFLAGS) $@ $(jarfile_manifest) $(classes) && rm -f $(jarfile_symlink) && $(LN_S) $@ $(jarfile_symlink)
+if !HAVE_JAVAH
+# If we don't have javah, assume we are running openjdk >= 10 and use javac
+# to generate the jni header file.
+AM_JAVACFLAGS = -h $(jnioutdir)
+else
context-jni-header.stamp: $(dist_noinst_JAVA)
$(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(jnioutdir) $(JAVAHFLAGS) org.lttng.ust.agent.context.LttngContextApi && \
echo "Context API JNI header generated" > context-jni-header.stamp
all-local: context-jni-header.stamp
+endif
install-data-hook:
cd $(DESTDIR)/$(jardir) && rm -f $(jarfile_symlink) && $(LN_S) $(jarfile) $(jarfile_symlink)
diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-jul/Makefile.am b/liblttng-ust-java-agent/java/lttng-ust-agent-jul/Makefile.am
index 2b6cf235..99fa78cf 100644
--- a/liblttng-ust-java-agent/java/lttng-ust-agent-jul/Makefile.am
+++ b/liblttng-ust-java-agent/java/lttng-ust-agent-jul/Makefile.am
@@ -26,11 +26,17 @@ classes = $(pkgpath)/*.class
$(jarfile): classnoinst.stamp
$(JAR) cfm $(JARFLAGS) $@ $(jarfile_manifest) $(classes) && rm -f $(jarfile_symlink) && $(LN_S) $@ $(jarfile_symlink)
+if !HAVE_JAVAH
+# If we don't have javah, assume we are running openjdk >= 10 and use javac
+# to generate the jni header file.
+AM_JAVACFLAGS = -h $(juljniout)
+else
jul-jni-header.stamp: $(dist_noinst_JAVA)
$(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(juljniout) $(JAVAHFLAGS) org.lttng.ust.agent.jul.LttngJulApi && \
echo "JUL JNI header generated" > jul-jni-header.stamp
all-local: $(stamp)
+endif
install-data-hook:
cd $(DESTDIR)/$(jardir) && rm -f $(jarfile_symlink) && $(LN_S) $(jarfile) $(jarfile_symlink)
diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/Makefile.am b/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/Makefile.am
index 05a18d43..0c9475a3 100644
--- a/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/Makefile.am
+++ b/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/Makefile.am
@@ -26,11 +26,17 @@ classes = $(pkgpath)/*.class
$(jarfile): classnoinst.stamp
$(JAR) cfm $(JARFLAGS) $@ $(jarfile_manifest) $(classes) && rm -f $(jarfile_symlink) && $(LN_S) $@ $(jarfile_symlink)
+if !HAVE_JAVAH
+# If we don't have javah, assume we are running openjdk >= 10 and use javac
+# to generate the jni header file.
+AM_JAVACFLAGS = -h $(log4jjniout)
+else
log4j-jni-header.stamp: $(dist_noinst_JAVA)
$(JAVAH) -classpath $(CLASSPATH):$(srcdir) -d $(log4jjniout) $(JAVAHFLAGS) org.lttng.ust.agent.log4j.LttngLog4jApi && \
echo "Log4j JNI header generated" > log4j-jni-header.stamp
all-local: $(stamp)
+endif
install-data-hook:
cd $(DESTDIR)/$(jardir) && rm -f $(jarfile_symlink) && $(LN_S) $(jarfile) $(jarfile_symlink)
diff --git a/liblttng-ust-java/Makefile.am b/liblttng-ust-java/Makefile.am
index 399b62ca..260774f9 100644
--- a/liblttng-ust-java/Makefile.am
+++ b/liblttng-ust-java/Makefile.am
@@ -17,11 +17,19 @@ liblttng_ust_java_la_LIBADD = -lc -L$(top_builddir)/liblttng-ust/.libs -llttng-u
$(jarfile): classnoinst.stamp
$(JAR) cf $(JARFLAGS) $@ $(pkgpath)/*.class
+if !HAVE_JAVAH
+# If we don't have javah, assume we are running openjdk >= 10 and use javac
+# to generate the jni header file.
+AM_JAVACFLAGS = -h .
+
+org_lttng_ust_LTTngUst.h: $(jarfile)
+else
org_lttng_ust_LTTngUst.h: jni-header.stamp
jni-header.stamp: $(dist_noinst_JAVA)
$(JAVAH) -classpath $(srcdir) $(JAVAHFLAGS) org.lttng.ust.LTTngUst && \
echo "JNI header generated" > jni-header.stamp
+endif
all-local: org_lttng_ust_LTTngUst.h
--
2.17.0
More information about the lttng-dev
mailing list