Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
j9build committed Apr 2, 2022
2 parents 44e2904 + 6fb8ac2 commit 57d463d
Show file tree
Hide file tree
Showing 128 changed files with 3,539 additions and 2,591 deletions.
24 changes: 20 additions & 4 deletions src/java.base/share/classes/java/lang/AbstractStringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence
*/
byte coder;

/**
* The attribute indicates {@code value} might be compressible to LATIN1 if it is UTF16-encoded.
* An inflated byte array becomes compressible only when those non-latin1 chars are deleted.
* We simply set this attribute in all methods which may delete chars. Therefore, there are
* false positives. Subclasses and String need to handle it properly.
*/
boolean maybeLatin1;

/**
* The count is the number of characters used.
*/
Expand Down Expand Up @@ -132,10 +140,11 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence

final byte initCoder;
if (COMPACT_STRINGS) {
if (seq instanceof AbstractStringBuilder) {
initCoder = ((AbstractStringBuilder)seq).getCoder();
} else if (seq instanceof String) {
initCoder = ((String)seq).coder();
if (seq instanceof AbstractStringBuilder asb) {
initCoder = asb.getCoder();
maybeLatin1 |= asb.maybeLatin1;
} else if (seq instanceof String s) {
initCoder = s.coder();
} else {
initCoder = LATIN1;
}
Expand Down Expand Up @@ -319,6 +328,8 @@ public void setLength(int newLength) {
} else {
StringUTF16.fillNull(value, count, newLength);
}
} else if (count > newLength) {
maybeLatin1 = true;
}
count = newLength;
}
Expand Down Expand Up @@ -528,6 +539,7 @@ public void setCharAt(int index, char ch) {
inflate();
}
StringUTF16.putCharSB(value, index, ch);
maybeLatin1 = true;
}
}

Expand Down Expand Up @@ -597,6 +609,7 @@ AbstractStringBuilder append(AbstractStringBuilder asb) {
inflateIfNeededFor(asb);
asb.getBytes(value, count, coder);
count += len;
maybeLatin1 |= asb.maybeLatin1;
return this;
}

Expand Down Expand Up @@ -907,6 +920,7 @@ public AbstractStringBuilder delete(int start, int end) {
if (len > 0) {
shift(end, -len);
this.count = count - len;
maybeLatin1 = true;
}
return this;
}
Expand Down Expand Up @@ -958,6 +972,7 @@ public AbstractStringBuilder deleteCharAt(int index) {
checkIndex(index, count);
shift(index + 1, -1);
count--;
maybeLatin1 = true;
return this;
}

Expand Down Expand Up @@ -992,6 +1007,7 @@ public AbstractStringBuilder replace(int start, int end, String str) {
shift(end, newCount - count);
this.count = newCount;
putStringAt(start, str);
maybeLatin1 = true;
return this;
}

Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -5281,7 +5281,8 @@ void getBytes(byte[] dst, int srcPos, int dstBegin, byte coder, int length) {
this.coder = LATIN1;
this.value = Arrays.copyOfRange(val, 0, length);
} else {
if (COMPACT_STRINGS) {
// only try to compress val if some characters were deleted.
if (COMPACT_STRINGS && asb.maybeLatin1) {
byte[] buf = StringUTF16.compress(val, 0, length);
if (buf != null) {
this.coder = LATIN1;
Expand Down
4 changes: 1 addition & 3 deletions src/java.base/share/classes/java/lang/StringBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,7 @@ public synchronized StringBuffer reverse() {
@IntrinsicCandidate
public synchronized String toString() {
if (toStringCache == null) {
return toStringCache =
isLatin1() ? StringLatin1.newString(value, 0, count)
: StringUTF16.newString(value, 0, count);
return toStringCache = new String(this, null);
}
return new String(toStringCache);
}
Expand Down
3 changes: 1 addition & 2 deletions src/java.base/share/classes/java/lang/StringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ public StringBuilder reverse() {
@IntrinsicCandidate
public String toString() {
// Create a copy, don't share the array
return isLatin1() ? StringLatin1.newString(value, 0, count)
: StringUTF16.newString(value, 0, count);
return new String(this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/security/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* </pre>
*
* For more information, see
* <a href="http://tools.ietf.org/html/rfc5280">RFC 5280:
* <a href="https://tools.ietf.org/html/rfc5280">RFC 5280:
* Internet X.509 Public Key Infrastructure Certificate and CRL Profile</a>.
*
* <LI>A Format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* Therefore any seed material passed to a {@code SecureRandom} object must be
* unpredictable, and all {@code SecureRandom} output sequences must be
* cryptographically strong, as described in
* <a href="http://tools.ietf.org/html/rfc4086">
* <a href="https://tools.ietf.org/html/rfc4086">
* <i>RFC 4086: Randomness Requirements for Security</i></a>.
*
* <p> Many {@code SecureRandom} implementations are in the form of a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* The CRLReason enumeration specifies the reason that a certificate
* is revoked, as defined in <a href="http://tools.ietf.org/html/rfc5280">
* is revoked, as defined in <a href="https://tools.ietf.org/html/rfc5280">
* RFC 5280: Internet X.509 Public Key Infrastructure Certificate and CRL
* Profile</a>.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class TrustAnchor {
* The name constraints are specified as a byte array. This byte array
* should contain the DER encoded form of the name constraints, as they
* would appear in the NameConstraints structure defined in
* <a href="http://tools.ietf.org/html/rfc5280">RFC 5280</a>
* <a href="https://tools.ietf.org/html/rfc5280">RFC 5280</a>
* and X.509. The ASN.1 definition of this structure appears below.
*
* <pre>{@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* </pre>
* <p>
* More information can be found in
* <a href="http://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509
* <a href="https://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509
* Public Key Infrastructure Certificate and CRL Profile</a>.
* <p>
* The ASN.1 definition of {@code tbsCertList} is:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* {@link CertStore#getCRLs CertStore.getCRLs} or some similar
* method.
* <p>
* Please refer to <a href="http://tools.ietf.org/html/rfc5280">RFC 5280:
* Please refer to <a href="https://tools.ietf.org/html/rfc5280">RFC 5280:
* Internet X.509 Public Key Infrastructure Certificate and CRL Profile</a>
* for definitions of the X.509 CRL fields and extensions mentioned below.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* number. Other unique combinations include the issuer, subject,
* subjectKeyIdentifier and/or the subjectPublicKey criteria.
* <p>
* Please refer to <a href="http://tools.ietf.org/html/rfc5280">RFC 5280:
* Please refer to <a href="https://tools.ietf.org/html/rfc5280">RFC 5280:
* Internet X.509 Public Key Infrastructure Certificate and CRL Profile</a> for
* definitions of the X.509 certificate extensions mentioned below.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
* CA such as a "root" CA.
* <p>
* More information can be found in
* <a href="http://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509
* <a href="https://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509
* Public Key Infrastructure Certificate and CRL Profile</a>.
* <p>
* The ASN.1 definition of {@code tbsCertificate} is:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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 @@ -28,11 +28,11 @@
import java.util.Objects;

/**
* This class specifies a parameter spec for RSASSA-PSS signature scheme,
* This class specifies a parameter spec for the RSASSA-PSS signature scheme,
* as defined in the
* <a href="https://tools.ietf.org/rfc/rfc8017.txt">PKCS#1 v2.2</a> standard.
*
* <p>Its ASN.1 definition in PKCS#1 standard is described below:
* <p>Its ASN.1 definition in the PKCS #1 standard is described below:
* <pre>
* RSASSA-PSS-params ::= SEQUENCE {
* hashAlgorithm [0] HashAlgorithm DEFAULT sha1,
Expand Down Expand Up @@ -64,12 +64,6 @@
* ... -- Allows for future expansion --
* }
* </pre>
* <p>Note: the PSSParameterSpec.DEFAULT uses the following:
* message digest -- "SHA-1"
* mask generation function (mgf) -- "MGF1"
* parameters for mgf -- MGF1ParameterSpec.SHA1
* SaltLength -- 20
* TrailerField -- 1
*
* @see MGF1ParameterSpec
* @see AlgorithmParameterSpec
Expand All @@ -94,17 +88,26 @@ public class PSSParameterSpec implements AlgorithmParameterSpec {
private final int trailerField;

/**
* The {@code TrailerFieldBC} constant as defined in PKCS#1
* The {@code TrailerFieldBC} constant as defined in the PKCS #1 standard.
*
* @since 11
*/
public static final int TRAILER_FIELD_BC = 1;

/**
* The PSS parameter set with all default values
* The PSS parameter set with all default values.
* @deprecated This field uses the default values defined in the PKCS #1
* standard. Some of these defaults are no longer recommended due
* to advances in cryptanalysis -- see the
* <a href="https://tools.ietf.org/rfc/rfc8017.txt">PKCS#1 v2.2</a>
* standard for more details. Thus, it is recommended to create
* a new {@code PSSParameterSpec} with the desired parameter values
* using the
* {@link #PSSParameterSpec(String, String, AlgorithmParameterSpec, int, int)} constructor.
*
* @since 1.5
*/
@Deprecated(since="19")
public static final PSSParameterSpec DEFAULT = new PSSParameterSpec
("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, TRAILER_FIELD_BC);

Expand All @@ -126,7 +129,7 @@ private PSSParameterSpec() {
* @param mgfSpec the parameters for the mask generation function.
* If null is specified, null will be returned by
* getMGFParameters().
* @param saltLen the length of salt
* @param saltLen the length of salt in bytes
* @param trailerField the value of the trailer field
* @throws NullPointerException if {@code mdName}, or {@code mgfName}
* is null
Expand Down Expand Up @@ -157,13 +160,21 @@ public PSSParameterSpec(String mdName, String mgfName,
/**
* Creates a new {@code PSSParameterSpec}
* using the specified salt length and other default values as
* defined in PKCS#1.
* defined in the PKCS #1 standard.
*
* @param saltLen the length of salt in bytes to be used in PKCS#1
* PSS encoding
* @param saltLen the length of salt in bytes
* @throws IllegalArgumentException if {@code saltLen} is
* less than 0
* @deprecated This constructor uses the default values defined in
* the PKCS #1 standard except for the salt length. Some of these
* defaults are no longer recommended due to advances in
* cryptanalysis -- see the
* <a href="https://tools.ietf.org/rfc/rfc8017.txt">PKCS#1 v2.2</a>
* standard for more details. Thus, it is recommended to explicitly
* specify all desired parameter values with the
* {@link #PSSParameterSpec(String, String, AlgorithmParameterSpec, int, int)} constructor.
*/
@Deprecated(since="19")
public PSSParameterSpec(int saltLen) {
this("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, saltLen, TRAILER_FIELD_BC);
}
Expand Down
18 changes: 9 additions & 9 deletions src/java.base/share/classes/java/util/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
* region, or culture.
*
* <p> The {@code Locale} class implements IETF BCP 47 which is composed of
* <a href="http://tools.ietf.org/html/rfc4647">RFC 4647 "Matching of Language
* Tags"</a> and <a href="http://tools.ietf.org/html/rfc5646">RFC 5646 "Tags
* <a href="https://tools.ietf.org/html/rfc4647">RFC 4647 "Matching of Language
* Tags"</a> and <a href="https://tools.ietf.org/html/rfc5646">RFC 5646 "Tags
* for Identifying Languages"</a> with support for the LDML (UTS#35, "Unicode
* Locale Data Markup Language") BCP 47-compatible extensions for locale data
* exchange.
Expand Down Expand Up @@ -280,7 +280,7 @@
* locale matching documentation.
*
* <p>In order to do matching a user's preferred locales to a set of language
* tags, <a href="http://tools.ietf.org/html/rfc4647">RFC 4647 Matching of
* tags, <a href="https://tools.ietf.org/html/rfc4647">RFC 4647 Matching of
* Language Tags</a> defines two mechanisms: filtering and lookup.
* <em>Filtering</em> is used to get all matching locales, whereas
* <em>lookup</em> is to choose the best matching locale.
Expand Down Expand Up @@ -2853,7 +2853,7 @@ public Locale build() {

/**
* This enum provides constants to select a filtering mode for locale
* matching. Refer to <a href="http://tools.ietf.org/html/rfc4647">RFC 4647
* matching. Refer to <a href="https://tools.ietf.org/html/rfc4647">RFC 4647
* Matching of Language Tags</a> for details.
*
* <p>As an example, think of two Language Priority Lists each of which
Expand Down Expand Up @@ -2989,7 +2989,7 @@ public static enum FilteringMode {

/**
* This class expresses a <em>Language Range</em> defined in
* <a href="http://tools.ietf.org/html/rfc4647">RFC 4647 Matching of
* <a href="https://tools.ietf.org/html/rfc4647">RFC 4647 Matching of
* Language Tags</a>. A language range is an identifier which is used to
* select language tag(s) meeting specific requirements by using the
* mechanisms described in <a href="Locale.html#LocaleMatching">Locale
Expand All @@ -2998,7 +2998,7 @@ public static enum FilteringMode {
*
* <p>There are two types of language ranges: basic and extended. In RFC
* 4647, the syntax of language ranges is expressed in
* <a href="http://tools.ietf.org/html/rfc4234">ABNF</a> as follows:
* <a href="https://tools.ietf.org/html/rfc4234">ABNF</a> as follows:
* <blockquote>
* <pre>
* basic-language-range = (1*8ALPHA *("-" 1*8alphanum)) / "*"
Expand Down Expand Up @@ -3164,7 +3164,7 @@ public double getWeight() {
*
* In a weighted list, each language range is given a weight value.
* The weight value is identical to the "quality value" in
* <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a>, and it
* <a href="https://tools.ietf.org/html/rfc2616">RFC 2616</a>, and it
* expresses how much the user prefers the language. A weight value is
* specified after a corresponding language range followed by
* {@code ";q="}, and the default weight value is {@code MAX_WEIGHT}
Expand Down Expand Up @@ -3202,7 +3202,7 @@ public double getWeight() {
*
* @param ranges a list of comma-separated language ranges or a list of
* language ranges in the form of the "Accept-Language" header
* defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
* defined in <a href="https://tools.ietf.org/html/rfc2616">RFC
* 2616</a>
* @return a Language Priority List consisting of language ranges
* included in the given {@code ranges} and their equivalent
Expand All @@ -3223,7 +3223,7 @@ public static List<LanguageRange> parse(String ranges) {
*
* @param ranges a list of comma-separated language ranges or a list
* of language ranges in the form of the "Accept-Language" header
* defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
* defined in <a href="https://tools.ietf.org/html/rfc2616">RFC
* 2616</a>
* @param map a map containing information to customize language ranges
* @return a Language Priority List with customization. The list is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/**
* This class specifies the parameters used with the
* <a href="http://tools.ietf.org/html/rfc2040"><i>RC5</i></a>
* <a href="https://tools.ietf.org/html/rfc2040"><i>RC5</i></a>
* algorithm.
*
* <p> The parameters consist of a version number, a rounds count, a word
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
* of the distinguished name, or by using the ASN.1 DER encoded byte
* representation of the distinguished name. The current specification
* for the string representation of a distinguished name is defined in
* <a href="http://tools.ietf.org/html/rfc2253">RFC 2253: Lightweight
* <a href="https://tools.ietf.org/html/rfc2253">RFC 2253: Lightweight
* Directory Access Protocol (v3): UTF-8 String Representation of
* Distinguished Names</a>. This class, however, accepts string formats from
* both RFC 2253 and <a href="http://tools.ietf.org/html/rfc1779">RFC 1779:
* both RFC 2253 and <a href="https://tools.ietf.org/html/rfc1779">RFC 1779:
* A String Representation of Distinguished Names</a>, and also recognizes
* attribute type keywords whose OIDs (Object Identifiers) are defined in
* <a href="http://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509
* <a href="https://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509
* Public Key Infrastructure Certificate and CRL Profile</a>.
*
* <p> The string representation for this {@code X500Principal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
* <h2>Package Specification</h2>
*
* <ul>
* <li><a href="http://tools.ietf.org/html/rfc1779">
* <li><a href="https://tools.ietf.org/html/rfc1779">
* RFC 1779: A String Representation of Distinguished Names</a></li>
* <li><a href="http://tools.ietf.org/html/rfc2253">
* <li><a href="https://tools.ietf.org/html/rfc2253">
* RFC 2253: Lightweight Directory Access Protocol (v3):
* UTF-8 String Representation of Distinguished Names</a></li>
* <li><a href="http://tools.ietf.org/html/rfc5280">
* <li><a href="https://tools.ietf.org/html/rfc5280">
* RFC 5280: Internet X.509 Public Key Infrastructure
* Certificate and Certificate Revocation List (CRL) Profile</a></li>
* <li><a href="http://tools.ietf.org/html/rfc4512">
* <li><a href="https://tools.ietf.org/html/rfc4512">
* RFC 4512: Lightweight Directory Access Protocol (LDAP):
* Directory Information Models</a></li>
* </ul>
Expand Down
Loading

0 comments on commit 57d463d

Please sign in to comment.