Skip to content

Commit 5370586

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. #5000 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 132ea1a commit 5370586

File tree

2 files changed

+33
-5
lines changed

2 files changed

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

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

174186
# Convenience for building Javadoc docs
175187
jdoc: doc

0 commit comments

Comments
 (0)