Skip to content

Commit

Permalink
Merge pull request #66 from hangingman/master
Browse files Browse the repository at this point in the history
Support for Java 11, 17 and earlier versions of Java
  • Loading branch information
nordfalk authored Jun 9, 2023
2 parents 07d4839 + c618ff2 commit cbe6e85
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Make.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ JAVA = @JAVA@
JAVAC = @JAVAC@

# The Java header file generator.
# If Java major version >= 9, use `javac` else `javah`.
JAVAH = @JAVAH@

# javah command was superseded by "javac -h" in jdk9.
# If Java major version >= 9, use `javac -h` else `javah -d`.
JAVAH_OPT = @JAVAH_OPT@

# The Java archive maintainer
JAR = @JAR@

Expand Down
14 changes: 9 additions & 5 deletions Make.rules
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ endif
# Define where libtool is
ifndef LIBTOOL
top_builddir = $(PROJ_BASE_DIR)
LIBTOOL = /bin/sh $(PROJ_BASE_DIR)libtool
LIBTOOL = /bin/bash $(PROJ_BASE_DIR)libtool
endif

# We have to work out the which package we are in
Expand Down Expand Up @@ -142,11 +142,15 @@ CFLAGS += $(INCLUDES)
# Rule to make header files from java class files.
# The originating java source must contain native method specifications.
$(PACKAGE_GENERATED_INPUT_DIR)/$(JNI_HEADER_PREFIX)_%.h: $(JAVA_PACKAGE_DIR)/%.class
@-rm $@ > /dev/null 2>&1
@-rm -f $@ > /dev/null 2>&1
@-mkdir -p $(dir $@)
"$(JAVAH)" -d $(PACKAGE_GENERATED_OUTPUT_DIR) -jni \
-classpath $(JAVA_CLASS_PATH) \
$(JAVA_PACKAGE).$(subst .class,,$(notdir $<))
ifeq ($(notdir $(JAVAH)),javah)
"$(JAVAH)" $(JAVAH_OPT) $(PACKAGE_GENERATED_OUTPUT_DIR) \
-classpath $(JAVA_CLASS_PATH) $(JAVA_PACKAGE).$(subst .class,,$(notdir $<))
else
"$(JAVAH)" $(JAVAH_OPT) $(PACKAGE_GENERATED_OUTPUT_DIR) \
-classpath $(JAVA_CLASS_PATH) $(subst .class,.java,$(notdir $<))
endif

# Rule to compile JNI C files
$(PACKAGE_OBJ_DIR)/%.lo: %.c $(PACKAGE_GENERATED_INPUT_DIR)/%.h
Expand Down
17 changes: 14 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,22 @@ fi
AC_SUBST(JAVAC)

dnl Determine if we have the Java header file generator
AC_PATH_PROG(JAVAH, javah, not_found)
if test ${JAVAH} = not_found; then
AC_MSG_ERROR('No Java header generator (javah) found')
dnl if Java major version >= 9, use `javac -h` instead of `javah -d`
AC_SUBST([JAVA_MAJOR_VERSION],
[$( ${JAVAC} -version 2>&1 | awk '{print $2}' | awk -F. '{print $1}' )])

if test $JAVA_MAJOR_VERSION -ge 9; then
JAVAH="${JAVAC}"
JAVAH_OPT="-h"
else
AC_PATH_PROG(JAVAH, javah, not_found)
if test ${JAVAH} = not_found; then
AC_MSG_ERROR('No Java header generator (javah) found')
fi
JAVAH_OPT="-d"
fi
AC_SUBST(JAVAH)
AC_SUBST(JAVAH_OPT)

dnl Determine if we have jar
AC_PATH_PROG(JAR, jar, not_found)
Expand Down
3 changes: 3 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash

autoreconf -vi
./configure --with-java-home=/usr/lib/jvm/java-1.7.0-openjdk-amd64 --prefix=/build
make
make install

0 comments on commit cbe6e85

Please sign in to comment.