Skip to content

Commit bc9d571

Browse files
committed
configury: use javac -h when possible
javah is no more available from Java 10, so try javac -h first (available since Java 8) and fallback on javah Refs. #5000 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 44a1c78 commit bc9d571

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

config/opal_setup_java.m4

Lines changed: 21 additions & 5 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 (c) 2017 FUJITSU LIMITED. All rights reserved.
2121
dnl $COPYRIGHT$
@@ -37,7 +37,7 @@ AC_DEFUN([OPAL_SETUP_JAVA_BANNER],[
3737
AC_DEFUN([OPAL_SETUP_JAVA],[
3838
AC_REQUIRE([OPAL_SETUP_JAVA_BANNER])
3939

40-
OPAL_VAR_SCOPE_PUSH([opal_java_bad opal_java_found opal_java_dir opal_java_jnih opal_java_PATH_save opal_java_CPPFLAGS_save])
40+
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])
4141
AC_ARG_ENABLE(java,
4242
AC_HELP_STRING([--enable-java],
4343
[Enable Java-based support in the system - use this option to disable all Java-based compiler tests (default: enabled)]))
@@ -161,13 +161,13 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
161161
AS_IF([test -n "$with_jdk_bindir" && test "$with_jdk_bindir" != "yes" && test "$with_jdk_bindir" != "no"],
162162
[PATH="$with_jdk_bindir:$PATH"])
163163
AC_PATH_PROG(JAVAC, javac)
164-
AC_PATH_PROG(JAVAH, javah)
165164
AC_PATH_PROG(JAR, jar)
166165
AC_PATH_PROG(JAVADOC, javadoc)
166+
AC_PATH_PROG(JAVAH, javah)
167167
PATH=$opal_java_PATH_save
168168

169-
# Check to see if we have all 4 programs.
170-
AS_IF([test -z "$JAVAC" || test -z "$JAVAH" || test -z "$JAR" || test -z "$JAVADOC"],
169+
# Check to see if we have all 3 programs.
170+
AS_IF([test -z "$JAVAC" || test -z "$JAR" || test -z "$JAVADOC"],
171171
[opal_java_happy=no
172172
HAVE_JAVA_SUPPORT=0],
173173
[opal_java_happy=yes
@@ -178,6 +178,21 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
178178
[opal_java_CPPFLAGS_save=$CPPFLAGS
179179
# silence a stupid Mac warning
180180
CPPFLAGS="$CPPFLAGS -DTARGET_RT_MAC_CFM=0"
181+
AC_MSG_CHECKING([javac -h])
182+
cat > Conftest.java << EOF
183+
public final class Conftest {
184+
public native void conftest();
185+
}
186+
EOF
187+
AS_IF([$JAVAC -d . -h . Conftest.java > /dev/null 2>&1],
188+
[AC_MSG_RESULT([yes])],
189+
[AC_MSG_RESULT([no])
190+
AS_IF([test -n "$JAVAH"],
191+
[opal_javah_happy=yes],
192+
[opal_java_happy=no])])
193+
rm -f Conftest.java Conftest.class Conftest.h
194+
195+
181196
AS_IF([test -n "$with_jdk_headers" && test "$with_jdk_headers" != "yes" && test "$with_jdk_headers" != "no"],
182197
[OPAL_JDK_CPPFLAGS="-I$with_jdk_headers"
183198
# Some flavors of JDK also require -I<blah>/linux.
@@ -216,5 +231,6 @@ AC_DEFUN([OPAL_SETUP_JAVA],[
216231

217232
AC_DEFINE_UNQUOTED([OPAL_HAVE_JAVA_SUPPORT], [$HAVE_JAVA_SUPPORT], [do we have Java support])
218233
AM_CONDITIONAL(OPAL_HAVE_JAVA_SUPPORT, test "$opal_java_happy" = "yes")
234+
AM_CONDITIONAL(OPAL_HAVE_JAVAH_SUPPORT, test "$opal_javah_happy" = "yes")
219235
OPAL_VAR_SCOPE_POP
220236
])

ompi/mpi/java/java/Makefile.am

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# Copyright (c) 2015 Los Alamos National Security, LLC. All rights
55
# reserved.
66
# Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
7+
# Copyright (c) 2018 Research Organization for Information Science
8+
# and Technology (RIST). All rights reserved.
79
# $COPYRIGHT$
810
#
911
# Additional copyrights may follow
@@ -148,11 +150,20 @@ mpi/MPI.class: $(JAVA_SRC_FILES)
148150
# Similar to above, all the generated .h files are dependent upon the
149151
# token mpi/MPI.class file. Hence, all the classes will be generated
150152
# first, then we'll individually generate each of the .h files.
153+
154+
if OPAL_HAVE_JAVAH_SUPPORT
151155
$(JAVA_H): mpi/MPI.class
152156
$(OMPI_V_JAVAH) sourcename=mpi.`echo $@ | sed -e s/^mpi_// -e s/.h$$//`; \
153157
CLASSPATH=. ; \
154158
export CLASSPATH ; \
155159
$(JAVAH) -d . -jni $$sourcename
160+
else
161+
$(JAVA_H): mpi/MPI.class
162+
$(OMPI_V_JAVAC) sourcename=$(top_srcdir)/ompi/mpi/java/java/`echo $@ | sed -e s/^mpi_// -e s/.h$$//`.java; \
163+
CLASSPATH=. ; \
164+
export CLASSPATH ; \
165+
$(JAVAC) -d . -h . $$sourcename
166+
endif # OPAL_HAVE_JAVAH_SUPPORT
156167

157168
# Generate the .jar file from all the class files. List mpi/MPI.class
158169
# as a dependency so that it fires the rule above that will generate

0 commit comments

Comments
 (0)