Skip to content

Commit

Permalink
Merge pull request #587 from ibmruntimes/openj9
Browse files Browse the repository at this point in the history
Merge jdk-11.0.17+8 to 0.35
  • Loading branch information
JasonFengJ9 committed Oct 19, 2022
2 parents 2f0b34c + 469a711 commit 3f75abe
Show file tree
Hide file tree
Showing 35 changed files with 874 additions and 289 deletions.
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-11.0.17+7
OPENJDK_TAG := jdk-11.0.17+8
2 changes: 1 addition & 1 deletion make/autoconf/version-numbers
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ DEFAULT_VERSION_DATE=2022-10-18
DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
DEFAULT_VERSION_CLASSFILE_MINOR=0
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11"
DEFAULT_PROMOTED_VERSION_PRE=ea
DEFAULT_PROMOTED_VERSION_PRE=

LAUNCHER_NAME=openjdk
PRODUCT_NAME=OpenJDK
Expand Down
1 change: 1 addition & 0 deletions make/launcher/LauncherCommon.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ endif

LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher
LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \
-I$(TOPDIR)/src/java.desktop/share/native/include \
-I$(TOPDIR)/src/java.base/share/native/libjli \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \
Expand Down
4 changes: 4 additions & 0 deletions make/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
common/awt/debug \
common/font \
common/java2d/opengl \
include \
#

LIBAWT_HEADLESS_CFLAGS := $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) $(X_CFLAGS) \
Expand Down Expand Up @@ -585,6 +586,7 @@ LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
libawt/java2d \
libawt/java2d/pipe \
libawt/java2d/loops \
include \
#

LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS)
Expand Down Expand Up @@ -775,6 +777,8 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
common/awt/systemscale \
#

LIBSPLASHSCREEN_HEADER_DIRS += include

ifeq ($(USE_EXTERNAL_LIBGIF), false)
LIBSPLASHSCREEN_HEADER_DIRS += libsplashscreen/giflib
else
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/share/classes/com/sun/security/ntlm/Client.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, 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 @@ -117,9 +117,10 @@ public byte[] type1() {
* {@code nonce} is null for NTLM v1.
*/
public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException {
if (type2 == null || (v != Version.NTLM && nonce == null)) {
if (type2 == null || (v != Version.NTLM && nonce == null) ||
(nonce != null && nonce.length != 8)) {
throw new NTLMException(NTLMException.PROTOCOL,
"type2 and nonce cannot be null");
"type2 cannot be null, and nonce must be 8-byte long");
}
debug("NTLM Client: Type 2 received\n");
debug(type2);
Expand Down
12 changes: 8 additions & 4 deletions src/java.base/share/classes/com/sun/security/ntlm/NTLM.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,27 @@ void writeBytes(int offset, byte[] data) {
System.arraycopy(data, 0, internal, offset, data.length);
}

void writeSecurityBuffer(int offset, byte[] data) {
void writeSecurityBuffer(int offset, byte[] data) throws NTLMException {
if (data == null) {
writeShort(offset+4, current);
writeInt(offset+4, current);
} else {
int len = data.length;
if (len > 65535) {
throw new NTLMException(NTLMException.INVALID_INPUT,
"Invalid data length " + len);
}
if (current + len > internal.length) {
internal = Arrays.copyOf(internal, current + len + 256);
}
writeShort(offset, len);
writeShort(offset+2, len);
writeShort(offset+4, current);
writeInt(offset+4, current);
System.arraycopy(data, 0, internal, current, len);
current += len;
}
}

void writeSecurityBuffer(int offset, String str, boolean unicode) {
void writeSecurityBuffer(int offset, String str, boolean unicode) throws NTLMException {
writeSecurityBuffer(offset, str == null ? null : str.getBytes(
unicode ? StandardCharsets.UTF_16LE
: StandardCharsets.ISO_8859_1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public final class NTLMException extends GeneralSecurityException {
*/
public static final int PROTOCOL = 6;

/**
* If an invalid input is provided.
*/
public static final int INVALID_INPUT = 7;

private int errorCode;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/com/sun/security/ntlm/Server.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, 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 @@ -85,9 +85,9 @@ public Server(String version, String domain) throws NTLMException {
* {@code nonce} is null.
*/
public byte[] type2(byte[] type1, byte[] nonce) throws NTLMException {
if (nonce == null) {
if (nonce == null || nonce.length != 8) {
throw new NTLMException(NTLMException.PROTOCOL,
"nonce cannot be null");
"nonce must be 8-byte long");
}
debug("NTLM Server: Type 1 received\n");
if (type1 != null) debug(type1);
Expand Down
62 changes: 47 additions & 15 deletions src/java.base/share/classes/java/math/BigDecimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
package java.math;

import static java.math.BigInteger.LONG_MASK;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
import java.io.StreamCorruptedException;
import java.util.Arrays;
import java.util.Objects;

Expand Down Expand Up @@ -1000,6 +1004,15 @@ public BigDecimal(double val, MathContext mc) {
this.precision = prec;
}

/**
* Accept no subclasses.
*/
private static BigInteger toStrictBigInteger(BigInteger val) {
return (val.getClass() == BigInteger.class) ?
val :
new BigInteger(val.toByteArray().clone());
}

/**
* Translates a {@code BigInteger} into a {@code BigDecimal}.
* The scale of the {@code BigDecimal} is zero.
Expand All @@ -1009,8 +1022,8 @@ public BigDecimal(double val, MathContext mc) {
*/
public BigDecimal(BigInteger val) {
scale = 0;
intVal = val;
intCompact = compactValFor(val);
intVal = toStrictBigInteger(val);
intCompact = compactValFor(intVal);
}

/**
Expand All @@ -1026,7 +1039,7 @@ public BigDecimal(BigInteger val) {
* @since 1.5
*/
public BigDecimal(BigInteger val, MathContext mc) {
this(val,0,mc);
this(toStrictBigInteger(val), 0, mc);
}

/**
Expand All @@ -1040,8 +1053,8 @@ public BigDecimal(BigInteger val, MathContext mc) {
*/
public BigDecimal(BigInteger unscaledVal, int scale) {
// Negative scales are now allowed
this.intVal = unscaledVal;
this.intCompact = compactValFor(unscaledVal);
this.intVal = toStrictBigInteger(unscaledVal);
this.intCompact = compactValFor(this.intVal);
this.scale = scale;
}

Expand All @@ -1061,6 +1074,7 @@ public BigDecimal(BigInteger unscaledVal, int scale) {
* @since 1.5
*/
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
unscaledVal = toStrictBigInteger(unscaledVal);
long compactVal = compactValFor(unscaledVal);
int mcp = mc.precision;
int prec = 0;
Expand Down Expand Up @@ -4199,9 +4213,13 @@ private static class UnsafeHolder {
= unsafe.objectFieldOffset(BigDecimal.class, "intCompact");
private static final long intValOffset
= unsafe.objectFieldOffset(BigDecimal.class, "intVal");
private static final long scaleOffset
= unsafe.objectFieldOffset(BigDecimal.class, "scale");

static void setIntCompact(BigDecimal bd, long val) {
unsafe.putLong(bd, intCompactOffset, val);
static void setIntValAndScale(BigDecimal bd, BigInteger intVal, int scale) {
unsafe.putObject(bd, intValOffset, intVal);
unsafe.putInt(bd, scaleOffset, scale);
unsafe.putLong(bd, intCompactOffset, compactValFor(intVal));
}

static void setIntValVolatile(BigDecimal bd, BigInteger val) {
Expand All @@ -4217,15 +4235,29 @@ static void setIntValVolatile(BigDecimal bd, BigInteger val) {
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// Read in all fields
s.defaultReadObject();
// validate possibly bad fields
if (intVal == null) {
String message = "BigDecimal: null intVal in stream";
throw new java.io.StreamCorruptedException(message);
// [all values of scale are now allowed]
// prepare to read the fields
ObjectInputStream.GetField fields = s.readFields();
BigInteger serialIntVal = (BigInteger) fields.get("intVal", null);

// Validate field data
if (serialIntVal == null) {
throw new StreamCorruptedException("Null or missing intVal in BigDecimal stream");
}
UnsafeHolder.setIntCompact(this, compactValFor(intVal));
// Validate provenance of serialIntVal object
serialIntVal = toStrictBigInteger(serialIntVal);

// Any integer value is valid for scale
int serialScale = fields.get("scale", 0);

UnsafeHolder.setIntValAndScale(this, serialIntVal, serialScale);
}

/**
* Serialization without data not supported for this class.
*/
private void readObjectNoData()
throws ObjectStreamException {
throw new InvalidObjectException("Deserialized BigDecimal objects need data");
}

/**
Expand Down
44 changes: 26 additions & 18 deletions src/java.base/share/classes/java/math/BigInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
package java.math;

import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
import java.io.ObjectStreamException;
import java.util.Arrays;
import java.util.Objects;
import java.util.Random;
Expand Down Expand Up @@ -4645,17 +4647,21 @@ private void readObject(java.io.ObjectInputStream s)
// prepare to read the alternate persistent fields
ObjectInputStream.GetField fields = s.readFields();

// Read the alternate persistent fields that we care about
int sign = fields.get("signum", -2);
byte[] magnitude = (byte[])fields.get("magnitude", null);
// Read and validate the alternate persistent fields that we
// care about, signum and magnitude

// Validate signum
// Read and validate signum
int sign = fields.get("signum", -2);
if (sign < -1 || sign > 1) {
String message = "BigInteger: Invalid signum value";
if (fields.defaulted("signum"))
message = "BigInteger: Signum not present in stream";
throw new java.io.StreamCorruptedException(message);
}

// Read and validate magnitude
byte[] magnitude = (byte[])fields.get("magnitude", null);
magnitude = magnitude.clone(); // defensive copy
int[] mag = stripLeadingZeroBytes(magnitude, 0, magnitude.length);
if ((mag.length == 0) != (sign == 0)) {
String message = "BigInteger: signum-magnitude mismatch";
Expand All @@ -4664,18 +4670,23 @@ private void readObject(java.io.ObjectInputStream s)
throw new java.io.StreamCorruptedException(message);
}

// Equivalent to checkRange() on mag local without assigning
// this.mag field
if (mag.length > MAX_MAG_LENGTH ||
(mag.length == MAX_MAG_LENGTH && mag[0] < 0)) {
throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
}

// Commit final fields via Unsafe
UnsafeHolder.putSign(this, sign);
UnsafeHolder.putSignAndMag(this, sign, mag);
}

// Calculate mag field from magnitude and discard magnitude
UnsafeHolder.putMag(this, mag);
if (mag.length >= MAX_MAG_LENGTH) {
try {
checkRange();
} catch (ArithmeticException e) {
throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
}
}
/**
* Serialization without data not supported for this class.
*/
private void readObjectNoData()
throws ObjectStreamException {
throw new InvalidObjectException("Deserialized BigInteger objects need data");
}

// Support for resetting final fields while deserializing
Expand All @@ -4687,11 +4698,8 @@ private static class UnsafeHolder {
private static final long magOffset
= unsafe.objectFieldOffset(BigInteger.class, "mag");

static void putSign(BigInteger bi, int sign) {
static void putSignAndMag(BigInteger bi, int sign, int[] magnitude) {
unsafe.putInt(bi, signumOffset, sign);
}

static void putMag(BigInteger bi, int[] magnitude) {
unsafe.putObject(bi, magOffset, magnitude);
}
}
Expand Down
Loading

0 comments on commit 3f75abe

Please sign in to comment.