Skip to content

Commit

Permalink
Integrate OpenJCEPlus into Semeru OpenJDK module openjceplus
Browse files Browse the repository at this point in the history
Signed-off-by: Tao Liu <[email protected]>

Integrate the building of OpenJCEPlus with Semeru OpenJDK as a module “openjceplus”. The java codes will be built with Semeru OpenJDK as a jmod, and the native codes will be built as a “.so” library.
  • Loading branch information
taoliult committed Nov 7, 2023
1 parent 1cd3f35 commit 8977d34
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# exclude all source directories
/omr
/openj9
/OpenJCEPlus
/openssl
# exclude optional eclipse project file
/.project
Expand Down
27 changes: 27 additions & 0 deletions closed/autoconf/custom-hook.m4
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ AC_DEFUN_ONCE([CUSTOM_EARLY_HOOK],
OPENJ9_CONFIGURE_INLINE_TYPES
OPENJ9_THIRD_PARTY_REQUIREMENTS
OPENJ9_CHECK_NASM_VERSION
OPENJCEPLUS_SETUP
])

AC_DEFUN([OPENJ9_CONFIGURE_CMAKE],
Expand Down Expand Up @@ -818,3 +819,29 @@ AC_DEFUN([OPENJ9_GENERATE_TOOL_WRAPPERS],
OPENJ9_GENERATE_TOOL_WRAPPER([nasm], [$NASM])
OPENJ9_GENERATE_TOOL_WRAPPER([rc], [$RC])
])

AC_DEFUN([OPENJCEPLUS_SETUP],
[
BUILD_JGSKIT=false
GSKIT_HOME=
OPENJCEPLUS_TOPDIR=
OPENJCEPLUS_TOPDIR_JAVA=
OPENJCEPLUS_TOPDIR="$TOPDIR/OpenJCEPlus"
OPENJCEPLUS_TOPDIR_JAVA="$TOPDIR/OpenJCEPlus/src/main"
GSKIT_HOME="$TOPDIR/OpenJCEPlus/icc/jgsk_sdk"
AC_MSG_CHECKING([if OpenJCEPlus will be built with Semeru])
if ! test -d "$OPENJCEPLUS_TOPDIR" ; then
BUILD_JGSKIT=false
AC_MSG_RESULT([no])
else
BUILD_JGSKIT=true
AC_MSG_RESULT([yes])
fi
AC_SUBST(BUILD_JGSKIT)
AC_SUBST(GSKIT_HOME)
AC_SUBST(OPENJCEPLUS_TOPDIR)
AC_SUBST(OPENJCEPLUS_TOPDIR_JAVA)
])
7 changes: 7 additions & 0 deletions closed/autoconf/custom-spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ WARNING_MODULES := \
openj9.dtfj \
openj9.dtfjview \
openj9.traceformat \
openjceplus \
#

ifneq (,$(filter $(WARNING_MODULES),$(MODULE)))
Expand Down Expand Up @@ -182,3 +183,9 @@ J9JCL_SOURCES_DONEFILE := $(MAKESUPPORT_OUTPUTDIR)/j9jcl.done

# Disable all hotspot features.
JVM_FEATURES_server :=

# required by OpenJCEPlus
BUILD_JGSKIT := @BUILD_JGSKIT@
GSKIT_HOME := @GSKIT_HOME@
OPENJCEPLUS_TOPDIR := @OPENJCEPLUS_TOPDIR@
OPENJCEPLUS_TOPDIR_JAVA := @OPENJCEPLUS_TOPDIR_JAVA@
50 changes: 50 additions & 0 deletions closed/custom/Main.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,53 @@ ifneq (,$(HEALTHCENTER_JAR))
# The content must be extracted before module-info can be compiled.
ibm.healthcenter-java : ibm.healthcenter-copy
endif # HEALTHCENTER_JAR

ifeq (true,$(BUILD_JGSKIT))

# Identify the desired JGSKIT target platform.
JGSKIT_TARGET :=
JGSKIT_MAKE := jgskit.mak
JGSKIT_MAKE_PATH := $(OPENJCEPLUS_TOPDIR)/src/main/native/
JCE_CLASSPATH := $(OPENJCEPLUS_TOPDIR)/src/main/java:$(TOPDIR)/src/java.base/share/classes
JCE_CLASSPATH_WIN64 := "$(call MixedPath,$(OPENJCEPLUS_TOPDIR)/src/main/java)\;$(call MixedPath,$(TOPDIR)/src/java.base/share/classes)"

ifeq ($(OPENJDK_TARGET_OS), aix)
JGSKIT_TARGET := ppc-aix64
else ifeq ($(OPENJDK_TARGET_OS), linux)
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
JGSKIT_TARGET := x86-linux64
else ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
JGSKIT_TARGET := ppcle-linux64
endif
else ifeq ($(OPENJDK_TARGET_OS), windows)
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
JGSKIT_TARGET := win64
JGSKIT_MAKE := jgskit.win64.mak
JCE_CLASSPATH := $(JCE_CLASSPATH_WIN64)
GSKIT_HOME := $(call MixedPath,$(GSKIT_HOME))
BOOT_JDK := $(call MixedPath,$(BOOT_JDK))
endif
endif # OPENJDK_TARGET_OS

ifeq (,$(JGSKIT_TARGET))
$(error Unsupported platform $(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU))
endif # JGSKIT_TARGET

.PHONY : clean-openjceplus openjceplus-libs

clean : clean-openjceplus

clean-openjceplus :
@$(ECHO) Cleaning OpenJCEPlus native
@$(RM) -f $(addprefix $(JGSKIT_MAKE_PATH), com_ibm_crypto_plus_provider_icc_NativeInterface.h com_ibm_crypto_plus_provider_icc_FastJNIBuffer.h libjgskit.x)
$(MAKE) -C $(JGSKIT_MAKE_PATH) -f $(JGSKIT_MAKE) cleanAll

openjceplus-copy : openjceplus-libs

openjceplus-libs :
@$(ECHO) Compiling OpenJCEPlus native
export PLATFORM=$(JGSKIT_TARGET) JAVA_HOME=$(BOOT_JDK) GSKIT_HOME=$(GSKIT_HOME) JCE_CLASSPATH=$(JCE_CLASSPATH) \
&& $(MAKE) -j1 -C $(JGSKIT_MAKE_PATH) -f $(JGSKIT_MAKE) all
@$(ECHO) OpenJCEplus compile complete

endif # BUILD_JGSKIT
3 changes: 2 additions & 1 deletion closed/custom/common/Modules.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ===========================================================================
# (c) Copyright IBM Corp. 2017, 2022 All Rights Reserved
# (c) Copyright IBM Corp. 2017, 2023 All Rights Reserved
# ===========================================================================
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
Expand Down Expand Up @@ -54,6 +54,7 @@ MODULES_FILTER += \

TOP_SRC_DIRS += \
$(J9JCL_SOURCES_DIR) \
$(OPENJCEPLUS_TOPDIR_JAVA) \
#

.PHONY : generate-j9jcl-sources
Expand Down
63 changes: 63 additions & 0 deletions closed/get_j9_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ usage() {
echo " -omr-branch the OpenJ9/omr git branch: openj9"
echo " -omr-sha a commit SHA for the omr repository"
echo " -omr-reference a local repo to use as a clone reference"
echo " -openjceplus-repo the OpenJCEPlus repository url"
echo " -openjceplus-branch the OpenJCEPlus git branch"
echo " -openjceplus-sha a commit SHA for the OpenJCEPlus repository"
echo " -openjceplus-reference a local repo to use as a clone reference"
echo " -with-gskit-bin the GSKit binary url"
echo " -with-gskit-sdk-bin the GSKIT SDK binary url"
echo " -with-gskit-bin-credential the credential for downloading the GSKit and GSKit SDK"
echo " -parallel (boolean) if 'true' then the clone j9 repository commands run in parallel, default is false"
echo ""
exit 1
Expand Down Expand Up @@ -108,6 +115,34 @@ for i in "$@" ; do
references[omr]="${i#*=}"
;;

-openjceplus-repo=* )
git_urls[OpenJCEPlus]="${i#*=}"
;;

-openjceplus-branch=* )
branches[OpenJCEPlus]="${i#*=}"
;;

-openjceplus-sha=* )
shas[OpenJCEPlus]="${i#*=}"
;;

-with-gskit-bin=* )
gskit_bin="${i#*=}"
;;

-with-gskit-sdk-bin=* )
gskit_sdk_bin="${i#*=}"
;;

-with-gskit-bin-credential=* )
gskit_bin_credential="${i#*=}"
;;

-openjceplus-reference=* )
references[OpenJCEPlus]="${i#*=}"
;;

-parallel=* )
pflag="${i#*=}"
;;
Expand Down Expand Up @@ -173,6 +208,34 @@ if [ ${pflag} = true ] ; then
wait
fi

# Download ICC binaries and create Java module folder
openjceplus_source="OpenJCEPlus"
if [ "${git_urls[$openjceplus_source]}" ]; then

echo
echo "$openjceplus_source exists, download ICC binaries"
echo

cd $openjceplus_source
mkdir -p ./icc/jgsk_sdk/lib64/

if [ $gskit_bin_credential ]; then
curl -H "Authorization: Bearer $gskit_bin_credential" -H "Accept: application/octet-stream" -L $gskit_bin --output ./icc/jgsk_crypto.tar
curl -H "Authorization: Bearer $gskit_bin_credential" -H "Accept: application/octet-stream" -L $gskit_sdk_bin --output ./icc/jgsk_crypto_sdk.tar
else
echo "-with-gskit-bin-credential is empty, will add curl command HERE without credential once there are binaries in open repo."
fi

tar -xf ./icc/jgsk_crypto_sdk.tar -C ./icc/
tar -xf ./icc/jgsk_crypto.tar -C ./icc/jgsk_sdk/lib64/

# Create OpenJCEPlus Java module folder
mkdir -p ./src/main/openjceplus/share/classes/
cp -r ./src/main/java/* ./src/main/openjceplus/share/classes/

cd ..
fi

END_TIME=$(date +%s)
date "+[%F %T] OpenJ9 clone repositories finished in $(($END_TIME - $START_TIME)) seconds"

Expand Down
44 changes: 44 additions & 0 deletions closed/make/modules/openjceplus/Copy.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ===========================================================================
# (c) Copyright IBM Corp. 2021, 2023 All Rights Reserved
# ===========================================================================
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# IBM designates this particular file as subject to the "Classpath" exception
# as provided by IBM in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, see <http://www.gnu.org/licenses/>.
# ===========================================================================

include $(TOPDIR)/closed/CopySupport.gmk

ifeq (true,$(BUILD_JGSKIT))
# Copy OpenJCEPlus native libraries
$(eval $(call SetupCopyFiles, COPY_JGSKIT_LIBS, \
SRC := $(OPENJCEPLUS_TOPDIR), \
FILES := $(filter %.so %.x,$(call FindFiles, $(OPENJCEPLUS_TOPDIR))), \
FLATTEN := true, \
DEST := $(LIB_DST_DIR), \
))

TARGETS += $(COPY_JGSKIT_LIBS)

# Bundle GSKIT library
ICC_DIR := $(GSKIT_HOME)/lib64

$(eval $(call SetupCopyFiles, COPY_ICC, \
SRC := $(ICC_DIR), \
DEST := $(LIB_DST_DIR)/icc, \
FILES := $(call FindFiles, $(ICC_DIR)), \
))

TARGETS += $(COPY_ICC)
endif # BUILD_JGSKIT
11 changes: 9 additions & 2 deletions get_source.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# ===========================================================================
# (c) Copyright IBM Corp. 2017, 2022 All Rights Reserved
# (c) Copyright IBM Corp. 2017, 2023 All Rights Reserved
# ===========================================================================
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,6 +40,13 @@ usage() {
echo " -omr-branch the OpenJ9/omr git branch: openj9"
echo " -omr-sha a commit SHA for the omr repository"
echo " -omr-reference a local repo to use as a clone reference"
echo " -openjceplus-repo the OpenJCEPlus repository url"
echo " -openjceplus-branch the OpenJCEPlus git branch"
echo " -openjceplus-sha a commit SHA for the OpenJCEPlus repository"
echo " -openjceplus-reference a local repo to use as a clone reference"
echo " -with-gskit-bin the GSKit binary url"
echo " -with-gskit-sdk-bin the GSKIT SDK binary url"
echo " -with-gskit-bin-credential the credential for downloading the GSKit and GSKit SDK"
echo " -parallel (boolean) if 'true' then the clone j9 repository commands run in parallel, default is false"
echo " --openssl-repo Specify the OpenSSL repository to download from"
echo " --openssl-version Specify the version of OpenSSL source to download"
Expand All @@ -57,7 +64,7 @@ for i in "$@" ; do
usage
;;

-openj9-repo=* | -openj9-branch=* | -openj9-sha=* | -openj9-reference=* | -omr-repo=* | -omr-branch=* | -omr-sha=* | -omr-reference=* | -parallel=* )
-openj9-repo=* | -openj9-branch=* | -openj9-sha=* | -openj9-reference=* | -omr-repo=* | -omr-branch=* | -omr-sha=* | -omr-reference=* | -openjceplus-repo=* | -openjceplus-branch=* | -openjceplus-sha=* | -openjceplus-reference=* | -with-gskit-bin=* | -with-gskit-sdk-bin=* | -with-gskit-bin-credential=* | -parallel=* )
j9options="${j9options} ${i}"
;;

Expand Down
29 changes: 19 additions & 10 deletions src/java.base/share/classes/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
* ===========================================================================
*/

Expand Down Expand Up @@ -141,7 +141,8 @@
// see make/gensrc/GenModuleInfo.gmk

exports com.sun.crypto.provider to
jdk.crypto.cryptoki;
jdk.crypto.cryptoki,
openjceplus;
exports sun.invoke.util to
jdk.compiler,
jdk.incubator.foreign;
Expand Down Expand Up @@ -216,7 +217,8 @@
jdk.nio.mapmode,
jdk.unsupported,
jdk.internal.vm.ci,
jdk.incubator.foreign;
jdk.incubator.foreign,
openjceplus;
exports jdk.internal.module to
java.instrument,
java.management.rmi,
Expand Down Expand Up @@ -310,14 +312,17 @@
jdk.crypto.ec,
jdk.incubator.foreign;
exports sun.security.internal.interfaces to
jdk.crypto.cryptoki;
jdk.crypto.cryptoki,
openjceplus;
exports sun.security.internal.spec to
jdk.crypto.cryptoki;
jdk.crypto.cryptoki,
openjceplus;
exports sun.security.jca to
java.smartcardio,
jdk.crypto.ec,
jdk.crypto.cryptoki,
jdk.naming.dns;
jdk.naming.dns,
openjceplus;
exports sun.security.pkcs to
jdk.crypto.ec,
jdk.jartool;
Expand All @@ -326,7 +331,8 @@
java.security.jgss,
jdk.crypto.cryptoki,
jdk.crypto.ec,
jdk.security.auth;
jdk.security.auth,
openjceplus;
exports sun.security.provider.certpath to
java.naming,
jdk.jartool;
Expand All @@ -348,15 +354,17 @@
jdk.crypto.cryptoki,
jdk.jartool,
jdk.security.auth,
jdk.security.jgss;
jdk.security.jgss,
openjceplus;
exports sun.security.util.math to
jdk.crypto.ec;
exports sun.security.util.math.intpoly to
jdk.crypto.ec;
exports sun.security.x509 to
jdk.crypto.ec,
jdk.crypto.cryptoki,
jdk.jartool;
jdk.jartool,
openjceplus;
exports sun.security.validator to
jdk.jartool;
exports sun.util.cldr to
Expand All @@ -375,7 +383,8 @@
jdk.incubator.foreign;
exports openj9.internal.security to
jdk.crypto.cryptoki,
jdk.crypto.ec;
jdk.crypto.ec,
openjceplus;

// the service types defined by the APIs in this module

Expand Down

0 comments on commit 8977d34

Please sign in to comment.