java: support OpenJDK 10+

Starting OpenJDK 10, the 'javah' utility is no more provided [1], and
its functionality is provided by 'javac' itself.  Hence, do not error
out on missing 'javah', and store whether it was found; in case it is
not, then:
1) assume 'javac' has the -h parameter to generate the C header, and
   make use of it
2) tell the buildsystem that com_redhat_et_libguestfs_GuestFS.h depends
   on the JAR, since the the header is generated at the step (1)

[1] https://bugs.java.com/view_bug.do?bug_id=JDK-8182758
This commit is contained in:
Pino Toscano
2018-05-04 17:04:42 +02:00
committed by Hilko Bengen
parent 784f18156e
commit 662dc5d0bf
2 changed files with 13 additions and 3 deletions

View File

@@ -77,6 +77,9 @@ if HAVE_JAVA
JAVAC_FLAGS = $(EXTRA_JAVAC_FLAGS) -encoding utf-8
JAVADOC_FLAGS = -encoding utf-8
if !HAVE_JAVAH
JAVAC_FLAGS += -h .
endif
# Java source.
@@ -125,10 +128,18 @@ libguestfs_jni_la_LDFLAGS = -version-info $(JNI_VERSION_INFO) -shared
BUILT_SOURCES = com_redhat_et_libguestfs_GuestFS.h
if HAVE_JAVAH
com_redhat_et_libguestfs_GuestFS.h: $(java_prefix)/GuestFS.class
rm -f $@
$(JAVAH) -classpath $(srcdir):. com.redhat.et.libguestfs.GuestFS
else
com_redhat_et_libguestfs_GuestFS.h: libguestfs-${VERSION}.jar
endif
# Documentation.
noinst_SCRIPTS = doc-stamp

View File

@@ -73,9 +73,7 @@ if test "x$with_java" != "xno"; then
else
JAVAC="$JAVA/bin/javac"
fi
if test ! -x "$JAVA/bin/javah"; then
AC_MSG_ERROR([missing $JAVA/bin/javah binary])
else
if test -x "$JAVA/bin/javah"; then
JAVAH="$JAVA/bin/javah"
fi
if test ! -x "$JAVA/bin/javadoc"; then
@@ -165,4 +163,5 @@ if test "x$with_java" != "xno"; then
AC_SUBST(JNI_VERSION_INFO)
fi
AM_CONDITIONAL([HAVE_JAVAH],[test -n "$JAVAH"])
AM_CONDITIONAL([HAVE_JAVA],[test "x$with_java" != "xno" && test -n "$JAVAC"])