Skip to content

Commit a246c90

Browse files
committed
configury: use javac vs javah whenever possible
javah is no more available from Java 10, so try javac -h first (available since Java 8) and fallback on javah Refs. open-mpi#5000 Signed-off-by: Gilles Gouaillardet <[email protected]> (back-ported from commit open-mpi/ompi@5370586)
1 parent b033dec commit a246c90

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

config/opal_setup_java.m4

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dnl reserved.
1515
dnl Copyright (c) 2007-2012 Oracle and/or its affiliates. All rights reserved.
1616
dnl Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
1717
dnl Copyright (c) 2013 Intel, Inc. All rights reserved.
18-
dnl Copyright (c) 2015 Research Organization for Information Science
18+
dnl Copyright (c) 2015-2018 Research Organization for Information Science
1919
dnl and Technology (RIST). All rights reserved.
2020
dnl $COPYRIGHT$
2121
dnl
@@ -36,7 +36,7 @@ AC_DEFUN([OPAL_SETUP_JAVA_BANNER],[
3636
AC_DEFUN([OPAL_SETUP_JAVA],[
3737
AC_REQUIRE([OPAL_SETUP_JAVA_BANNER])
3838

39-
OPAL_VAR_SCOPE_PUSH([opal_java_bad opal_java_found opal_java_dir opal_java_jnih opal_java_PATH_save opal_java_CPPFLAGS_save])
39+
OPAL_VAR_SCOPE_PUSH([opal_java_bad opal_javah_happy opal_java_found opal_java_dir opal_java_jnih opal_java_PATH_save opal_java_CPPFLAGS_save])
4040
AC_ARG_ENABLE(java,
4141
AC_HELP_STRING([--enable-java],
4242
[Enable Java-based support in the system - use this option to disable all Java-based compiler tests (default: enabled)]))
@@ -158,12 +158,13 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
158158
AS_IF([test -n "$with_jdk_bindir" && test "$with_jdk_bindir" != "yes" && test "$with_jdk_bindir" != "no"],
159159
[PATH="$with_jdk_bindir:$PATH"])
160160
AC_PATH_PROG(JAVAC, javac)
161-
AC_PATH_PROG(JAVAH, javah)
162161
AC_PATH_PROG(JAR, jar)
162+
AC_PATH_PROG(JAVADOC, javadoc)
163+
AC_PATH_PROG(JAVAH, javah)
163164
PATH=$opal_java_PATH_save
164165

165166
# Check to see if we have all 3 programs.
166-
AS_IF([test -z "$JAVAC" || test -z "$JAVAH" || test -z "$JAR"],
167+
AS_IF([test -z "$JAVAC" || test -z "$JAR" || test -z "$JAVADOC"],
167168
[opal_java_happy=no
168169
HAVE_JAVA_SUPPORT=0],
169170
[opal_java_happy=yes
@@ -174,6 +175,21 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
174175
[opal_java_CPPFLAGS_save=$CPPFLAGS
175176
# silence a stupid Mac warning
176177
CPPFLAGS="$CPPFLAGS -DTARGET_RT_MAC_CFM=0"
178+
AC_MSG_CHECKING([javac -h])
179+
cat > Conftest.java << EOF
180+
public final class Conftest {
181+
public native void conftest();
182+
}
183+
EOF
184+
AS_IF([$JAVAC -d . -h . Conftest.java > /dev/null 2>&1],
185+
[AC_MSG_RESULT([yes])],
186+
[AC_MSG_RESULT([no])
187+
AS_IF([test -n "$JAVAH"],
188+
[opal_javah_happy=yes],
189+
[opal_java_happy=no])])
190+
rm -f Conftest.java Conftest.class Conftest.h
191+
192+
177193
AS_IF([test -n "$with_jdk_headers" && test "$with_jdk_headers" != "yes" && test "$with_jdk_headers" != "no"],
178194
[OPAL_JDK_CPPFLAGS="-I$with_jdk_headers"
179195
# Some flavors of JDK also require -I<blah>/linux.
@@ -212,5 +228,6 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
212228

213229
AC_DEFINE_UNQUOTED([OPAL_HAVE_JAVA_SUPPORT], [$HAVE_JAVA_SUPPORT], [do we have Java support])
214230
AM_CONDITIONAL(OPAL_HAVE_JAVA_SUPPORT, test "$opal_java_happy" = "yes")
231+
AM_CONDITIONAL(OPAL_HAVE_JAVAH_SUPPORT, test "$opal_javah_happy" = "yes")
215232
OPAL_VAR_SCOPE_POP
216233
])

ompi/mpi/java/java/Makefile.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ ompi__v_JAVADOC_QUIET_0 = -quiet
139139
# in. This, along with the fact that the .java files seem to have
140140
# circular references, prevents us from using a .foo.bar: generic
141141
# Makefile rule. :-(
142+
if OPAL_HAVE_JAVAH_SUPPORT
142143
mpi/MPI.class: $(JAVA_SRC_FILES)
143144
$(OMPI_V_JAVAC) CLASSPATH=. ; \
144145
export CLASSPATH ; \
@@ -147,11 +148,18 @@ mpi/MPI.class: $(JAVA_SRC_FILES)
147148
# Similar to above, all the generated .h files are dependent upon the
148149
# token mpi/MPI.class file. Hence, all the classes will be generated
149150
# first, then we'll individually generate each of the .h files.
151+
150152
$(JAVA_H): mpi/MPI.class
151153
$(OMPI_V_JAVAH) sourcename=mpi.`echo $@ | sed -e s/^mpi_// -e s/.h$$//`; \
152154
CLASSPATH=. ; \
153155
export CLASSPATH ; \
154156
$(JAVAH) -d . -jni $$sourcename
157+
else
158+
mpi/MPI.class: $(JAVA_SRC_FILES)
159+
$(OMPI_V_JAVAC) CLASSPATH=. ; \
160+
export CLASSPATH ; \
161+
$(JAVAC) -h . -d . $(top_srcdir)/ompi/mpi/java/java/*.java
162+
endif # OPAL_HAVE_JAVAH_SUPPORT
155163

156164
# Generate the .jar file from all the class files. List mpi/MPI.class
157165
# as a dependency so that it fires the rule above that will generate
@@ -170,7 +178,11 @@ java_DATA = mpi.jar
170178
# List all the header files in BUILT_SOURCES so that Automake's "all"
171179
# target will build them. This will also force the building of the
172180
# mpi/*.class files (for the jar file).
181+
if OPAL_HAVE_JAVAH_SUPPORT
173182
BUILT_SOURCES = $(JAVA_H) doc
183+
else
184+
BUILT_SOURCES = mpi/MPI.class doc
185+
endif
174186

175187
# Convenience for building Javadoc docs
176188
jdoc: doc

0 commit comments

Comments
 (0)