Skip to content

Commit

Permalink
Merge pull request #272 from JasonFengJ9/mergetmp
Browse files Browse the repository at this point in the history
Merge master jdk-17.0.9+9 into openj9-staging
  • Loading branch information
keithc-ca committed Oct 18, 2023
2 parents 73b1959 + d8c51e6 commit f215a7e
Show file tree
Hide file tree
Showing 61 changed files with 1,404 additions and 376 deletions.
4 changes: 4 additions & 0 deletions closed/JPP.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ J9TOOLS_DIR := $(SUPPORT_OUTPUTDIR)/j9tools
JPP_JAR := $(J9TOOLS_DIR)/jpp.jar
JPP_TAGS := PLATFORM-$(OPENJ9_PLATFORM_CODE)

ifeq (true,$(OPENJ9_ENABLE_CRAC_SUPPORT))
JPP_TAGS += CRAC_SUPPORT
endif # OPENJ9_ENABLE_CRAC_SUPPORT

ifeq (true,$(OPENJ9_ENABLE_CRIU_SUPPORT))
JPP_TAGS += CRIU_SUPPORT
endif # OPENJ9_ENABLE_CRIU_SUPPORT
Expand Down
13 changes: 13 additions & 0 deletions closed/OpenJ9.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ else
SPEC_SED_SCRIPT += $(call SedDisable,opt_valhallaValueTypes)
endif

# Adjust CRAC Support enablement flags.
ifeq (true,$(OPENJ9_ENABLE_CRAC_SUPPORT))
FEATURE_SED_SCRIPT += $(call SedEnable,opt_cracSupport)
else # OPENJ9_ENABLE_CRAC_SUPPORT
FEATURE_SED_SCRIPT += $(call SedDisable,opt_cracSupport)
endif # OPENJ9_ENABLE_CRAC_SUPPORT

# Adjust CRIU Support enablement flags.
ifeq (true,$(OPENJ9_ENABLE_CRIU_SUPPORT))
FEATURE_SED_SCRIPT += $(call SedEnable,opt_criuSupport)
Expand Down Expand Up @@ -447,6 +454,12 @@ ifeq (true,$(OPENJ9_ENABLE_CMAKE))
CMAKE_ARGS += -DJ9VM_OPT_VALHALLA_VALUE_TYPES=OFF
endif # OPENJ9_ENABLE_INLINE_TYPES

ifeq (true,$(OPENJ9_ENABLE_CRAC_SUPPORT))
CMAKE_ARGS += -DJ9VM_OPT_CRAC_SUPPORT=ON
else # OPENJ9_ENABLE_CRAC_SUPPORT
CMAKE_ARGS += -DJ9VM_OPT_CRAC_SUPPORT=OFF
endif # OPENJ9_ENABLE_CRAC_SUPPORT

ifeq (true,$(OPENJ9_ENABLE_CRIU_SUPPORT))
CMAKE_ARGS += -DJ9VM_OPT_CRIU_SUPPORT=ON
else # OPENJ9_ENABLE_CRIU_SUPPORT
Expand Down
30 changes: 29 additions & 1 deletion closed/autoconf/custom-hook.m4
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ AC_DEFUN_ONCE([CUSTOM_EARLY_HOOK],
OPENJ9_PLATFORM_SETUP
OPENJ9_CONFIGURE_CMAKE
OPENJ9_CONFIGURE_COMPILERS
OPENJ9_CONFIGURE_CRAC_SUPPORT
OPENJ9_CONFIGURE_CRIU_SUPPORT
OPENJ9_CONFIGURE_CUDA
OPENJ9_CONFIGURE_DDR
Expand Down Expand Up @@ -340,10 +341,37 @@ AC_DEFUN([OPENJ9_PLATFORM_EXTRACT_VARS_FROM_CPU],
esac
])

AC_DEFUN([OPENJ9_CONFIGURE_CRAC_SUPPORT],
[
AC_MSG_CHECKING([for CRAC support])
AC_ARG_ENABLE([crac-support], [AS_HELP_STRING([--enable-crac-support], [enable CRAC support @<:@platform dependent@:>@])])
OPENJ9_ENABLE_CRAC_SUPPORT=false
if test "x$enable_crac_support" = xyes ; then
AC_MSG_RESULT([yes (explicitly enabled)])
OPENJ9_ENABLE_CRAC_SUPPORT=true
elif test "x$enable_crac_support" = xno ; then
AC_MSG_RESULT([no (explicitly disabled)])
elif test "x$enable_crac_support" = x ; then
case "$OPENJ9_PLATFORM_CODE" in
xa64)
AC_MSG_RESULT([yes (default)])
OPENJ9_ENABLE_CRAC_SUPPORT=true
;;
*)
AC_MSG_RESULT([no (default)])
;;
esac
else
AC_MSG_ERROR([--enable-crac-support accepts no argument])
fi
AC_SUBST(OPENJ9_ENABLE_CRAC_SUPPORT)
])

AC_DEFUN([OPENJ9_CONFIGURE_CRIU_SUPPORT],
[
AC_MSG_CHECKING([for CRIU support])
AC_ARG_ENABLE([criu-support], [AS_HELP_STRING([--enable-criu-support], [enable CRIU support @<:@disabled@:>@])])
AC_ARG_ENABLE([criu-support], [AS_HELP_STRING([--enable-criu-support], [enable CRIU support @<:@platform dependent@:>@])])
OPENJ9_ENABLE_CRIU_SUPPORT=false
if test "x$enable_criu_support" = xyes ; then
Expand Down
1 change: 1 addition & 0 deletions closed/autoconf/custom-spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export GDK_HOME := @OPENJ9_GDK_HOME@
endif

# feature enablement flags
OPENJ9_ENABLE_CRAC_SUPPORT := @OPENJ9_ENABLE_CRAC_SUPPORT@
OPENJ9_ENABLE_CRIU_SUPPORT := @OPENJ9_ENABLE_CRIU_SUPPORT@
OPENJ9_ENABLE_DDR := @OPENJ9_ENABLE_DDR@
OPENJ9_ENABLE_DEMOS := @OPENJ9_ENABLE_DEMOS@
Expand Down
2 changes: 1 addition & 1 deletion closed/openjdk-tag.gmk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OPENJDK_TAG := jdk-17.0.9+7
OPENJDK_TAG := jdk-17.0.9+9
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,13 @@ public KeyPair generateKeyPair() {
return this.javaImplementation.generateKeyPair();
}

boolean absent;
long nativePointer = NativeECUtil.encodeGroup(this.params);

if (nativePointer == -1) {
absent = NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
if (!absent) {
throw new ProviderException("Could not encode group");
}
NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
if (nativeCryptTrace) {
System.err.println(this.curve +
" is not supported by OpenSSL, using Java crypto implementation.");
System.err.println("Could not encode group for curve " + this.curve
+ " in OpenSSL, using Java crypto implementation.");
}
try {
this.initializeJavaImplementation();
Expand All @@ -193,13 +189,10 @@ public KeyPair generateKeyPair() {
} else if (field instanceof ECFieldF2m) {
fieldType = NativeCrypto.ECField_F2m;
} else {
absent = NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
if (!absent) {
throw new ProviderException("Field type not supported");
}
NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
if (nativeCryptTrace) {
System.err.println(this.curve +
" is not supported by OpenSSL, using Java crypto implementation.");
System.err.println("Field type not supported for curve " + this.curve
+ " by OpenSSL, using Java crypto implementation.");
}
try {
this.initializeJavaImplementation();
Expand All @@ -224,13 +217,10 @@ public KeyPair generateKeyPair() {
fieldType);

if (ret == -1) {
absent = NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
if (!absent) {
throw new ProviderException("Could not generate key pair");
}
NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
if (nativeCryptTrace) {
System.err.println(this.curve +
" is not supported by OpenSSL, using Java crypto implementation for key generation.");
System.err.println("Could not generate key pair for curve " + this.curve
+ " using OpenSSL, using Java crypto implementation for key generation.");
}
try {
this.initializeJavaImplementation();
Expand Down
2 changes: 1 addition & 1 deletion make/conf/version-numbers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0
DEFAULT_VERSION_DOCS_API_SINCE=11
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17"
DEFAULT_JDK_SOURCE_TARGET_VERSION=17
DEFAULT_PROMOTED_VERSION_PRE=ea
DEFAULT_PROMOTED_VERSION_PRE=
27 changes: 21 additions & 6 deletions src/java.base/share/classes/com/sun/crypto/provider/DESKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,6 +25,8 @@

package com.sun.crypto.provider;

import java.io.IOException;
import java.io.InvalidObjectException;
import java.lang.ref.Reference;
import java.security.MessageDigest;
import java.security.KeyRep;
Expand All @@ -44,7 +46,7 @@
final class DESKey implements SecretKey {

@java.io.Serial
static final long serialVersionUID = 7724971015953279128L;
private static final long serialVersionUID = 7724971015953279128L;

private byte[] key;

Expand Down Expand Up @@ -113,7 +115,7 @@ public int hashCode() {
for (int i = 1; i < this.key.length; i++) {
retval += this.key[i] * i;
}
return(retval ^= "des".hashCode());
return(retval ^ "des".hashCode());
}

public boolean equals(Object obj) {
Expand All @@ -134,15 +136,28 @@ public boolean equals(Object obj) {
}

/**
* readObject is called to restore the state of this key from
* a stream.
* Restores the state of this object from the stream.
*
* @param s the {@code ObjectInputStream} from which data is read
* @throws IOException if an I/O error occurs
* @throws ClassNotFoundException if a serialized class cannot be loaded
*/
@java.io.Serial
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
if ((key == null) || (key.length != DESKeySpec.DES_KEY_LEN)) {
throw new InvalidObjectException("Wrong key size");
}
key = key.clone();

DESKeyGenerator.setParityBit(key, 0);

// Use the cleaner to zero the key when no longer referenced
final byte[] k = key;
CleanerFactory.cleaner().register(this,
() -> java.util.Arrays.fill(k, (byte)0x00));
}

/**
Expand Down
29 changes: 23 additions & 6 deletions src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,6 +25,8 @@

package com.sun.crypto.provider;

import java.io.IOException;
import java.io.InvalidObjectException;
import java.lang.ref.Reference;
import java.security.MessageDigest;
import java.security.KeyRep;
Expand All @@ -44,7 +46,7 @@
final class DESedeKey implements SecretKey {

@java.io.Serial
static final long serialVersionUID = 2463986565756745178L;
private static final long serialVersionUID = 2463986565756745178L;

private byte[] key;

Expand Down Expand Up @@ -112,7 +114,7 @@ public int hashCode() {
for (int i = 1; i < this.key.length; i++) {
retval += this.key[i] * i;
}
return(retval ^= "desede".hashCode());
return(retval ^ "desede".hashCode());
}

public boolean equals(Object obj) {
Expand All @@ -134,15 +136,30 @@ public boolean equals(Object obj) {
}

/**
* readObject is called to restore the state of this key from
* a stream.
* Restores the state of this object from the stream.
*
* @param s the {@code ObjectInputStream} from which data is read
* @throws IOException if an I/O error occurs
* @throws ClassNotFoundException if a serialized class cannot be loaded
*/
@java.io.Serial
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
if ((key == null) || (key.length != DESedeKeySpec.DES_EDE_KEY_LEN)) {
throw new InvalidObjectException("Wrong key size");
}
key = key.clone();

DESKeyGenerator.setParityBit(key, 0);
DESKeyGenerator.setParityBit(key, 8);
DESKeyGenerator.setParityBit(key, 16);

// Use the cleaner to zero the key when no longer referenced
final byte[] k = key;
CleanerFactory.cleaner().register(this,
() -> java.util.Arrays.fill(k, (byte)0x00));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -41,16 +41,14 @@
* algorithm.
*
* @author Jan Luehe
*
*
* @see DHPublicKey
* @see java.security.KeyAgreement
*/
final class DHPrivateKey implements PrivateKey,
javax.crypto.interfaces.DHPrivateKey, Serializable {

@java.io.Serial
static final long serialVersionUID = 7565477590005668886L;
private static final long serialVersionUID = 7565477590005668886L;

// only supported version of PKCS#8 PrivateKeyInfo
private static final BigInteger PKCS8_VERSION = BigInteger.ZERO;
Expand All @@ -65,10 +63,10 @@ final class DHPrivateKey implements PrivateKey,
private byte[] encodedKey;

// the prime modulus
private BigInteger p;
private final BigInteger p;

// the base generator
private BigInteger g;
private final BigInteger g;

// the private-value length (optional)
private int l;
Expand Down Expand Up @@ -336,4 +334,28 @@ private Object writeReplace() throws java.io.ObjectStreamException {
getFormat(),
encodedKey);
}

/**
* Restores the state of this object from the stream.
* <p>
* JDK 1.5+ objects use <code>KeyRep</code>s instead.
*
* @param stream the {@code ObjectInputStream} from which data is read
* @throws IOException if an I/O error occurs
* @throws ClassNotFoundException if a serialized class cannot be loaded
*/
@java.io.Serial
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
if ((key == null) || (key.length == 0)) {
throw new InvalidObjectException("key not deserializable");
}
this.key = key.clone();
if ((encodedKey == null) || (encodedKey.length == 0)) {
throw new InvalidObjectException(
"encoded key not deserializable");
}
this.encodedKey = encodedKey.clone();
}
}
Loading

0 comments on commit f215a7e

Please sign in to comment.