})}.
+ *
* When created, the lazy constant is not initialized, meaning it has no contents.
+ *
* The lazy constant (of type {@code T}) can then be initialized
* (and its contents retrieved) by calling {@linkplain #get() get()}. The first time
* {@linkplain #get() get()} is called, the underlying computing function
* (provided at construction) will be invoked and the result will be used to initialize
- * the constant. Once a lazy constant is initialized, its contents can never change
+ * the constant.
+ *
+ * Once a lazy constant is initialized, its contents can never change
* and will be retrieved over and over again upon subsequent {@linkplain #get() get()}
* invocations.
*
@@ -64,7 +68,7 @@
* // ...
* }
* }
- *}
+ * }
*
* Initially, the lazy constant is not initialized. When {@code logger.get()}
* is first invoked, it evaluates the computing function and initializes the constant to
@@ -121,7 +125,7 @@
* }
*
* }
- *}
+ * }
* Calling {@code BAR.get()} will create the {@code Bar} singleton if it is not already
* created. Upon such a creation, a dependent {@code Foo} will first be created if
* the {@code Foo} does not already exist.
@@ -238,10 +242,11 @@ public sealed interface LazyConstant
// Object methods
/**
- * {@return if this lazy constant is the same as the provided {@code obj}}
+ * {@return {@code true} if this lazy constant is the same instance as
+ * the provided {@code obj}, otherwise {@code false}}
*
* In other words, equals compares the identity of this lazy constant and {@code obj}
- * to determine equality. Hence, two lazy constants with the same contents are
+ * to determine equality. Hence, two distinct lazy constants with the same contents are
* not equal.
*
* This method never triggers initialization of this lazy constant.
diff --git a/src/java.base/share/classes/java/lang/ThreadBuilders.java b/src/java.base/share/classes/java/lang/ThreadBuilders.java
index 62c29651d11..033c237877c 100644
--- a/src/java.base/share/classes/java/lang/ThreadBuilders.java
+++ b/src/java.base/share/classes/java/lang/ThreadBuilders.java
@@ -309,7 +309,7 @@ UncaughtExceptionHandler uncaughtExceptionHandler() {
String nextThreadName() {
if (hasCounter) {
- return name + (long) COUNT.getAndAdd(this, 1);
+ return name + (long) COUNT.getAndAdd(this, 1L);
} else {
return name;
}
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java b/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java
index 1ddd0511d85..43bf1984a00 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java
@@ -32,9 +32,8 @@
* including {@link Attribute}, {@link AttributedElement}, {@link AttributeMapper}, and {@link CustomAttribute}, which
* do not reside in this package.
*
- * Unless otherwise specified, passing {@code null} or an array or collection containing a {@code null} element as an
- * argument to a constructor or method of any Class-File API class or interface will cause a {@link NullPointerException}
- * to be thrown.
+ * APIs in this package perform {@linkplain java.lang.classfile##checks null and unrepresentable argument checks},
+ * unless otherwise noted.
*
*
Reading Attributes
* The general way to obtain attributes is through {@link AttributedElement}. In addition to that, many attributes
diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/package-info.java b/src/java.base/share/classes/java/lang/classfile/constantpool/package-info.java
index 66e72496d3a..0828e04ae22 100644
--- a/src/java.base/share/classes/java/lang/classfile/constantpool/package-info.java
+++ b/src/java.base/share/classes/java/lang/classfile/constantpool/package-info.java
@@ -30,9 +30,8 @@
* {@code class} file format. Constant pool entries are low-level models to faithfully represent the exact structure
* of a {@code class} file.
*
- * Unless otherwise specified, passing {@code null} or an array or collection containing a {@code null} element as an
- * argument to a constructor or method of any Class-File API class or interface will cause a {@link NullPointerException}
- * to be thrown.
+ * APIs in this package perform {@linkplain java.lang.classfile##checks null and unrepresentable argument checks},
+ * unless otherwise noted.
*
*
Reading the constant pool entries
* When read from {@code class} files, the pool entries are lazily inflated; the contents of these entries, besides the
diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/package-info.java b/src/java.base/share/classes/java/lang/classfile/instruction/package-info.java
index e732aadf1ec..990731721a8 100644
--- a/src/java.base/share/classes/java/lang/classfile/instruction/package-info.java
+++ b/src/java.base/share/classes/java/lang/classfile/instruction/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2025, 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
@@ -29,9 +29,8 @@
* The {@code java.lang.classfile.instruction} package contains interfaces describing code instructions.
* Implementations of these interfaces are immutable.
*
- * Unless otherwise specified, passing {@code null} or an array or collection containing a {@code null} element as an
- * argument to a constructor or method of any Class-File API class or interface will cause a {@link NullPointerException}
- * to be thrown.
+ * APIs in this package perform {@linkplain java.lang.classfile##checks null and unrepresentable argument checks},
+ * unless otherwise noted.
*
*
Reading of instructions
* Instructions and pseudo-instructions are usually accessed from a {@link CodeModel}, such as {@link CodeModel#forEach
diff --git a/src/java.base/share/classes/java/lang/classfile/package-info.java b/src/java.base/share/classes/java/lang/classfile/package-info.java
index da9ad7fbf0d..460f6699e7b 100644
--- a/src/java.base/share/classes/java/lang/classfile/package-info.java
+++ b/src/java.base/share/classes/java/lang/classfile/package-info.java
@@ -250,12 +250,6 @@
* the convenience method {@code CodeBuilder.invoke}, which in turn behaves
* as if it calls method {@code CodeBuilder.with}. This composing of method calls on the
* builder enables the composing of transforms (as described later).
- *
- * Unless otherwise noted, passing a {@code null} argument to a constructor
- * or method of any Class-File API class or interface will cause a {@link
- * NullPointerException} to be thrown. Additionally,
- * invoking a method with an array or collection containing a {@code null} element
- * will cause a {@code NullPointerException}, unless otherwise specified.
*
*
Symbolic information
* To describe symbolic information for classes and types, the API uses the
@@ -272,14 +266,22 @@
* symbolic information, one accepting nominal descriptors, and the other
* accepting constant pool entries.
*
- * Consistency checks, syntax checks and verification
- * The Class-File API performs checks to ensure arguments are representable in
- * the {@code class} file format. A value that is lost when it is built to a
- * {@code class} file and re-parsed to a model is rejected with an {@link
- * IllegalArgumentException}. For example, a negative value or a value over
- * {@code 65535} is lost when built to a {@link ##u2 u2} item, with
- * the range {@code [0, 65535]}. In particular, any variable-sized table
- * exceeding its maximum representable size is rejected.
+ * Consistency checks, syntax checks and verification
+ * The Class-File API performs checks to ensure arguments to construct {@code
+ * class} file structures are representable in the {@code class} file format.
+ * An argument value that cannot be representable by its data type is rejected
+ * with an {@link IllegalArgumentException}. For example, an {@code int} value
+ * cannot be out of the range of its {@linkplain java.lang.classfile##data-types
+ * data type}; a {@code List} cannot exceed the maximum representable size of
+ * its table data type, or contain an unrepresentable element. Restrictions
+ * based on underlying data type, such as the {@code int} and {@code List} ones
+ * before, are specified on the corresponding APIs. Unless otherwise noted, in
+ * all structures, a {@code String} cannot exceed {@code 65535} bytes when
+ * represented in modified UTF-8 format.
+ *
+ * Unless otherwise noted, passing null or an array or collection that contains
+ * null as an element to a constructor or method of any Class-File API class or
+ * interface will cause a {@link NullPointerException} to be thrown.
*
* No consistency checks are performed while building or transforming classfiles
* (except for null and representable arguments checks). All builders and
diff --git a/src/java.base/share/classes/java/lang/invoke/MethodType.java b/src/java.base/share/classes/java/lang/invoke/MethodType.java
index 3d15ce68710..afbe63709fd 100644
--- a/src/java.base/share/classes/java/lang/invoke/MethodType.java
+++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java
@@ -1194,10 +1194,6 @@ public static MethodType fromMethodDescriptorString(String descriptor, ClassLoad
static MethodType fromDescriptor(String descriptor, ClassLoader loader)
throws IllegalArgumentException, TypeNotPresentException
{
- if (!descriptor.startsWith("(") || // also generates NPE if needed
- descriptor.indexOf(')') < 0 ||
- descriptor.indexOf('.') >= 0)
- throw newIllegalArgumentException("not a method descriptor: "+descriptor);
List> types = BytecodeDescriptor.parseMethod(descriptor, loader);
Class> rtype = types.remove(types.size() - 1);
Class>[] ptypes = listToArray(types);
diff --git a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
index 1637d26b571..54000b916e2 100644
--- a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
+++ b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
@@ -97,6 +97,8 @@ public class AccessibleObject implements AnnotatedElement {
* objects in the array
* @throws SecurityException if an element in the array is a constructor for {@code
* java.lang.Class}
+ * @throws NullPointerException if {@code array} or any of its elements is
+ * {@code null}
*/
@CallerSensitive
public static void setAccessible(AccessibleObject[] array, boolean flag) {
diff --git a/src/java.base/share/classes/java/lang/reflect/Array.java b/src/java.base/share/classes/java/lang/reflect/Array.java
index 2fbad52c374..4e676c050d7 100644
--- a/src/java.base/share/classes/java/lang/reflect/Array.java
+++ b/src/java.base/share/classes/java/lang/reflect/Array.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, 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
@@ -98,8 +98,8 @@ public static Object newInstance(Class> componentType, int length)
* @param dimensions an array of {@code int} representing the dimensions of
* the new array
* @return the new array
- * @throws NullPointerException if the specified
- * {@code componentType} argument is null
+ * @throws NullPointerException if any of the specified
+ * {@code componentType} or {@code dimensions} arguments is null
* @throws IllegalArgumentException if the specified {@code dimensions}
* argument is a zero-dimensional array, if componentType is {@link
* Void#TYPE}, or if the number of dimensions of the requested array
@@ -117,8 +117,8 @@ public static Object newInstance(Class> componentType, int... dimensions)
*
* @param array the array
* @return the length of the array
- * @throws IllegalArgumentException if the object argument is not
- * an array
+ * @throws NullPointerException if {@code array} is {@code null}
+ * @throws IllegalArgumentException if {@code array} is not an array
*/
@IntrinsicCandidate
public static native int getLength(Object array)
diff --git a/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java b/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java
index 4a63dd157f8..16fe000091c 100644
--- a/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java
+++ b/src/java.base/share/classes/java/lang/reflect/ClassFileFormatVersion.java
@@ -433,6 +433,7 @@ public int major() {
* ClassFileFormatVersion.valueOf(Runtime.Version.parse("17"))}
*
* @param rv runtime version to map to a class file format version
+ * @throws NullPointerException if {@code rv} is {@code null}
* @throws IllegalArgumentException if the feature of version
* argument is greater than the feature of the platform version.
*/
diff --git a/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java b/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java
index 7bc9ea33b2b..29d6eb13602 100644
--- a/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java
+++ b/src/java.base/share/classes/java/lang/reflect/InaccessibleObjectException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2025, 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
@@ -47,7 +47,7 @@ public InaccessibleObjectException() {
* message.
*
* @param msg
- * The detail message
+ * The detail message, may be {@code null}
*/
public InaccessibleObjectException(String msg) {
super(msg);
diff --git a/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java b/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java
index a6ef4fa289c..efdca9bcbd1 100644
--- a/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java
+++ b/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, 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
@@ -62,7 +62,7 @@ protected InvocationTargetException() {
/**
* Constructs a InvocationTargetException with a target exception.
*
- * @param target the target exception
+ * @param target the target exception, may be {@code null}
*/
public InvocationTargetException(Throwable target) {
super((Throwable)null); // Disallow initCause
@@ -73,8 +73,8 @@ public InvocationTargetException(Throwable target) {
* Constructs a InvocationTargetException with a target exception
* and a detail message.
*
- * @param target the target exception
- * @param s the detail message
+ * @param target the target exception, may be {@code null}
+ * @param s the detail message, may be {@code null}
*/
public InvocationTargetException(Throwable target, String s) {
super(s, null); // Disallow initCause
diff --git a/src/java.base/share/classes/java/lang/reflect/MalformedParametersException.java b/src/java.base/share/classes/java/lang/reflect/MalformedParametersException.java
index ae2da8c9279..fa754be5474 100644
--- a/src/java.base/share/classes/java/lang/reflect/MalformedParametersException.java
+++ b/src/java.base/share/classes/java/lang/reflect/MalformedParametersException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2025, 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
@@ -65,7 +65,7 @@ public MalformedParametersException() {}
/**
* Create a {@code MalformedParametersException}.
*
- * @param reason The reason for the exception.
+ * @param reason The reason for the exception, may be {@code null}
*/
public MalformedParametersException(String reason) {
super(reason);
diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java
index dc512e86590..b811deb863d 100644
--- a/src/java.base/share/classes/java/lang/reflect/Proxy.java
+++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java
@@ -897,7 +897,8 @@ private static Module getDynamicModule(ClassLoader loader) {
* of interfaces but in a different order will result in two distinct
* proxy classes.
*
- * @param loader the class loader to define the proxy class
+ * @param loader the class loader to define the proxy class, may be
+ * {@code null} to represent the bootstrap class loader
* @param interfaces the list of interfaces for the proxy class
* to implement
* @param h the invocation handler to dispatch method invocations to
diff --git a/src/java.base/share/classes/java/lang/reflect/UndeclaredThrowableException.java b/src/java.base/share/classes/java/lang/reflect/UndeclaredThrowableException.java
index 0b086330de2..25d8affa474 100644
--- a/src/java.base/share/classes/java/lang/reflect/UndeclaredThrowableException.java
+++ b/src/java.base/share/classes/java/lang/reflect/UndeclaredThrowableException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2025, 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
@@ -61,7 +61,7 @@ public class UndeclaredThrowableException extends RuntimeException {
* specified {@code Throwable}.
*
* @param undeclaredThrowable the undeclared checked exception
- * that was thrown
+ * that was thrown, may be {@code null}
*/
public UndeclaredThrowableException(Throwable undeclaredThrowable) {
super(null, undeclaredThrowable); // Disallow initCause
@@ -72,8 +72,8 @@ public UndeclaredThrowableException(Throwable undeclaredThrowable) {
* specified {@code Throwable} and a detail message.
*
* @param undeclaredThrowable the undeclared checked exception
- * that was thrown
- * @param s the detail message
+ * that was thrown, may be {@code null}
+ * @param s the detail message, may be {@code null}
*/
public UndeclaredThrowableException(Throwable undeclaredThrowable,
String s)
diff --git a/src/java.base/share/classes/java/net/HostPortrange.java b/src/java.base/share/classes/java/net/HostPortrange.java
index 289846841c9..f7a5b911633 100644
--- a/src/java.base/share/classes/java/net/HostPortrange.java
+++ b/src/java.base/share/classes/java/net/HostPortrange.java
@@ -60,6 +60,11 @@ public int hashCode() {
}
HostPortrange(String scheme, String host) {
+ // Defensive validation first
+ if (host == null || host.isEmpty()) {
+ throw new IllegalArgumentException("Invalid URL authority");
+ }
+
// Parse the host name. A name has up to three components, the
// hostname, a port number, or two numbers representing a port
// range. "www.example.com:8080-9090" is a valid host name.
diff --git a/src/java.base/share/classes/java/net/URLPermission.java b/src/java.base/share/classes/java/net/URLPermission.java
index bf87cad8077..ac51d6c60a1 100644
--- a/src/java.base/share/classes/java/net/URLPermission.java
+++ b/src/java.base/share/classes/java/net/URLPermission.java
@@ -527,6 +527,9 @@ static class Authority {
HostPortrange p;
Authority(String scheme, String authority) {
+ if (authority == null || authority.isEmpty()) {
+ throw new IllegalArgumentException("Invalid URL: authority is empty");
+ }
int at = authority.indexOf('@');
if (at == -1) {
p = new HostPortrange(scheme, authority);
diff --git a/src/java.base/share/classes/java/time/MonthDay.java b/src/java.base/share/classes/java/time/MonthDay.java
index a25c9beec95..26ca69bbe0d 100644
--- a/src/java.base/share/classes/java/time/MonthDay.java
+++ b/src/java.base/share/classes/java/time/MonthDay.java
@@ -88,6 +88,8 @@
import java.time.temporal.ValueRange;
import java.util.Objects;
+import jdk.internal.util.DecimalDigits;
+
/**
* A month-day in the ISO-8601 calendar system, such as {@code --12-03}.
*
@@ -764,10 +766,12 @@ public int hashCode() {
*/
@Override
public String toString() {
- return new StringBuilder(10).append("--")
- .append(month < 10 ? "0" : "").append(month)
- .append(day < 10 ? "-0" : "-").append(day)
- .toString();
+ StringBuilder buf = new StringBuilder(10);
+ buf.append("--");
+ DecimalDigits.appendPair(buf, month);
+ buf.append('-');
+ DecimalDigits.appendPair(buf, day);
+ return buf.toString();
}
//-----------------------------------------------------------------------
diff --git a/src/java.base/share/classes/java/time/YearMonth.java b/src/java.base/share/classes/java/time/YearMonth.java
index b3d1aff7bc2..665c8c85544 100644
--- a/src/java.base/share/classes/java/time/YearMonth.java
+++ b/src/java.base/share/classes/java/time/YearMonth.java
@@ -101,6 +101,8 @@
import java.time.temporal.ValueRange;
import java.util.Objects;
+import jdk.internal.util.DecimalDigits;
+
/**
* A year-month in the ISO-8601 calendar system, such as {@code 2007-12}.
*
@@ -1213,18 +1215,17 @@ public int hashCode() {
public String toString() {
int absYear = Math.abs(year);
StringBuilder buf = new StringBuilder(9);
- if (absYear < 1000) {
+ if (absYear < 10000) {
if (year < 0) {
- buf.append(year - 10000).deleteCharAt(1);
- } else {
- buf.append(year + 10000).deleteCharAt(0);
+ buf.append('-');
}
+ DecimalDigits.appendQuad(buf, absYear);
} else {
buf.append(year);
}
- return buf.append(month < 10 ? "-0" : "-")
- .append(month)
- .toString();
+ buf.append('-');
+ DecimalDigits.appendPair(buf, month);
+ return buf.toString();
}
//-----------------------------------------------------------------------
diff --git a/src/java.base/share/classes/java/time/ZoneOffset.java b/src/java.base/share/classes/java/time/ZoneOffset.java
index 4199d17735c..2a45e7cbf82 100644
--- a/src/java.base/share/classes/java/time/ZoneOffset.java
+++ b/src/java.base/share/classes/java/time/ZoneOffset.java
@@ -88,6 +88,7 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReferenceArray;
+import jdk.internal.util.DecimalDigits;
import jdk.internal.vm.annotation.Stable;
/**
@@ -465,12 +466,14 @@ private static String buildId(int totalSeconds) {
StringBuilder buf = new StringBuilder();
int absHours = absTotalSeconds / SECONDS_PER_HOUR;
int absMinutes = (absTotalSeconds / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
- buf.append(totalSeconds < 0 ? "-" : "+")
- .append(absHours < 10 ? "0" : "").append(absHours)
- .append(absMinutes < 10 ? ":0" : ":").append(absMinutes);
+ buf.append(totalSeconds < 0 ? '-' : '+');
+ DecimalDigits.appendPair(buf, absHours);
+ buf.append(':');
+ DecimalDigits.appendPair(buf, absMinutes);
int absSeconds = absTotalSeconds % SECONDS_PER_MINUTE;
if (absSeconds != 0) {
- buf.append(absSeconds < 10 ? ":0" : ":").append(absSeconds);
+ buf.append(':');
+ DecimalDigits.appendPair(buf, absSeconds);
}
return buf.toString();
}
diff --git a/src/java.base/share/classes/java/time/chrono/ChronoLocalDateImpl.java b/src/java.base/share/classes/java/time/chrono/ChronoLocalDateImpl.java
index ca226b70d24..67f08c5cb4f 100644
--- a/src/java.base/share/classes/java/time/chrono/ChronoLocalDateImpl.java
+++ b/src/java.base/share/classes/java/time/chrono/ChronoLocalDateImpl.java
@@ -74,6 +74,8 @@
import java.time.temporal.ValueRange;
import java.util.Objects;
+import jdk.internal.util.DecimalDigits;
+
/**
* A date expressed in terms of a standard year-month-day calendar system.
*
@@ -426,18 +428,22 @@ public int hashCode() {
@Override
public String toString() {
- // getLong() reduces chances of exceptions in toString()
- long yoe = getLong(YEAR_OF_ERA);
- long moy = getLong(MONTH_OF_YEAR);
- long dom = getLong(DAY_OF_MONTH);
+ // Using get() instead of getLong() for performance reasons,
+ // as the values of YEAR_OF_ERA, MONTH_OF_YEAR, and DAY_OF_MONTH
+ // are guaranteed to be within the int range for all chronologies.
+ int yoe = get(YEAR_OF_ERA);
+ int moy = get(MONTH_OF_YEAR);
+ int dom = get(DAY_OF_MONTH);
StringBuilder buf = new StringBuilder(30);
buf.append(getChronology().toString())
.append(" ")
.append(getEra())
.append(" ")
.append(yoe)
- .append(moy < 10 ? "-0" : "-").append(moy)
- .append(dom < 10 ? "-0" : "-").append(dom);
+ .append('-');
+ DecimalDigits.appendPair(buf, moy);
+ buf.append('-');
+ DecimalDigits.appendPair(buf, dom);
return buf.toString();
}
diff --git a/src/java.base/share/classes/java/util/List.java b/src/java.base/share/classes/java/util/List.java
index 6ab80b83ef8..43408de292a 100644
--- a/src/java.base/share/classes/java/util/List.java
+++ b/src/java.base/share/classes/java/util/List.java
@@ -1207,7 +1207,7 @@ static List copyOf(Collection extends E> coll) {
* The provided computing function is guaranteed to be successfully
* invoked at most once per list index, even in a multi-threaded environment.
* Competing threads accessing an element already under computation will block until
- * an element is computed or the computing function completes abnormally
+ * an element is computed or the computing function completes abnormally.
*
* If invoking the provided computing function throws an exception, it is rethrown
* to the initial caller and no value for the element is recorded.
@@ -1235,7 +1235,7 @@ static List copyOf(Collection extends E> coll) {
* one or more lazy elements.
*
* The returned lazy list strongly references its computing
- * function used to compute elements at least so long as there are uninitialized
+ * function used to compute elements at least as long as there are uninitialized
* elements.
*
* The returned List is not {@linkplain Serializable}.
diff --git a/src/java.base/share/classes/java/util/Map.java b/src/java.base/share/classes/java/util/Map.java
index abee819069f..177f0522b1b 100644
--- a/src/java.base/share/classes/java/util/Map.java
+++ b/src/java.base/share/classes/java/util/Map.java
@@ -1788,7 +1788,7 @@ static Map copyOf(Map extends K, ? extends V> map) {
* one or more lazy elements.
*
* The returned lazy map strongly references its underlying
- * computing function used to compute values at least so long as there are
+ * computing function used to compute values at least as long as there are
* uncomputed values.
*
* The returned Map is not {@linkplain Serializable}.
diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
index 4cb7048a798..9295f0deb59 100644
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
@@ -1372,12 +1372,20 @@ public boolean equals(Object o) {
Node[] t;
int f = (t = table) == null ? 0 : t.length;
Traverser it = new Traverser(t, f, 0, f);
- for (Node p; (p = it.advance()) != null; ) {
- V val = p.val;
- Object v = m.get(p.key);
- if (v == null || (v != val && !v.equals(val)))
- return false;
+
+ try {
+ for (Node p; (p = it.advance()) != null; ) {
+ V val = p.val;
+ Object v = m.get(p.key);
+ if (v == null || (v != val && !v.equals(val)))
+ return false;
+ }
+ } catch (ClassCastException | NullPointerException _) {
+ // m.get(p.key) is contractually allowed to throw CCE or NPE
+ // but CHM doesn't allow null keys, so NPE shouldn't occur in practice
+ return false;
}
+
for (Map.Entry,?> e : m.entrySet()) {
Object mk, mv, v;
if ((mk = e.getKey()) == null ||
diff --git a/src/java.base/share/classes/java/util/concurrent/DelayScheduler.java b/src/java.base/share/classes/java/util/concurrent/DelayScheduler.java
index d1f8283489b..1ded0211932 100644
--- a/src/java.base/share/classes/java/util/concurrent/DelayScheduler.java
+++ b/src/java.base/share/classes/java/util/concurrent/DelayScheduler.java
@@ -360,31 +360,36 @@ private static int replace(ScheduledForkJoinTask>[] h, int k, int n) {
u.heapIndex = -1;
}
}
- if (t != null) { // sift down
- for (int cs; (cs = (k << 2) + 1) < n; ) {
- ScheduledForkJoinTask> leastChild = null, c;
+ if (t != null) {
+ while (k > 0) { // sift up if replaced with smaller value
+ ScheduledForkJoinTask> parent; int pk;
+ if ((parent = h[pk = (k - 1) >>> 2]) == null ||
+ parent.when <= d)
+ break;
+ parent.heapIndex = k;
+ h[k] = parent;
+ k = pk;
+ }
+ for (int cs; (cs = (k << 2) + 1) < n; ) { // sift down
+ ScheduledForkJoinTask> leastChild = null;
int leastIndex = 0;
- long leastValue = Long.MAX_VALUE;
- for (int ck = cs, j = 4;;) { // at most 4 children
- if ((c = h[ck]) == null)
- break;
- long cd = c.when;
- if (c.status < 0 && alsoReplace < 0) {
- alsoReplace = ck; // at most once per pass
- c.heapIndex = -1;
- }
- else if (leastChild == null || cd < leastValue) {
+ long leastValue = d; // at most 4 children
+ for (int ck, j = 0; j < 4 && (ck = j + cs) < n; ++j) {
+ ScheduledForkJoinTask> c; long cd;
+ if ((c = h[ck]) != null && (cd = c.when) < leastValue) {
leastValue = cd;
leastIndex = ck;
leastChild = c;
}
- if (--j == 0 || ++ck >= n)
- break;
}
- if (leastChild == null || d <= leastValue)
+ if (leastChild == null) // already ordered
break;
- leastChild.heapIndex = k;
- h[k] = leastChild;
+ if ((h[k] = leastChild).status >= 0 || alsoReplace >= 0)
+ leastChild.heapIndex = k;
+ else {
+ leastChild.heapIndex = -1;
+ alsoReplace = k;
+ }
k = leastIndex;
}
t.heapIndex = k;
@@ -393,6 +398,7 @@ else if (leastChild == null || cd < leastValue) {
k = alsoReplace;
}
}
+ assert checkHeap(h, n);
return n;
}
@@ -451,6 +457,33 @@ private static void cancelAll(ScheduledForkJoinTask>[] h, int n) {
}
}
+ /**
+ * Invariant checks
+ */
+ private static boolean checkHeap(ScheduledForkJoinTask>[] h, int n) {
+ for (int i = 0; i < h.length; ++i) {
+ ScheduledForkJoinTask> t = h[i];
+ if (t == null) { // unused slots all null
+ if (i < n)
+ return false;
+ }
+ else {
+ long v = t.when;
+ int x = t.heapIndex;
+ if (x != i && x >= 0) // valid index unless removing
+ return false;
+ if (i > 0 && h[(i - 1) >>> 2].when > v) // ordered wrt parent
+ return false;
+ int cs = (i << 2) + 1; // ordered wrt children
+ for (int ck, j = 0; j < 4 && (ck = cs + j) < n; ++j) {
+ if (h[ck].when < v)
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
/**
* Task class for DelayScheduler operations
*/
diff --git a/src/java.base/share/classes/java/util/stream/SortedOps.java b/src/java.base/share/classes/java/util/stream/SortedOps.java
index 91892eba44f..1286735ebd9 100644
--- a/src/java.base/share/classes/java/util/stream/SortedOps.java
+++ b/src/java.base/share/classes/java/util/stream/SortedOps.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2025, 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
@@ -108,13 +108,10 @@ private static final class OfRef extends ReferencePipeline.StatefulOp {
* {@code Comparable}.
*/
OfRef(AbstractPipeline, T, ?> upstream) {
- super(upstream, StreamShape.REFERENCE,
- StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SORTED);
- this.isNaturalSort = true;
// Will throw CCE when we try to sort if T is not Comparable
@SuppressWarnings("unchecked")
Comparator super T> comp = (Comparator super T>) Comparator.naturalOrder();
- this.comparator = comp;
+ this(upstream, comp);
}
/**
@@ -123,10 +120,13 @@ private static final class OfRef extends ReferencePipeline.StatefulOp {
* @param comparator The comparator to be used to evaluate ordering.
*/
OfRef(AbstractPipeline, T, ?> upstream, Comparator super T> comparator) {
+ Objects.requireNonNull(comparator);
+ boolean isNaturalSort = Comparator.naturalOrder().equals(comparator);
+ this.comparator = comparator;
+ this.isNaturalSort = isNaturalSort;
super(upstream, StreamShape.REFERENCE,
- StreamOpFlag.IS_ORDERED | StreamOpFlag.NOT_SORTED);
- this.isNaturalSort = false;
- this.comparator = Objects.requireNonNull(comparator);
+ StreamOpFlag.IS_ORDERED |
+ (isNaturalSort ? StreamOpFlag.IS_SORTED : StreamOpFlag.NOT_SORTED));
}
@Override
diff --git a/src/java.base/share/classes/java/util/stream/StreamOpFlag.java b/src/java.base/share/classes/java/util/stream/StreamOpFlag.java
index df98125cbc0..0e7b2f6607b 100644
--- a/src/java.base/share/classes/java/util/stream/StreamOpFlag.java
+++ b/src/java.base/share/classes/java/util/stream/StreamOpFlag.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2025, 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
@@ -24,6 +24,7 @@
*/
package java.util.stream;
+import java.util.Comparator;
import java.util.EnumMap;
import java.util.Map;
import java.util.Spliterator;
@@ -738,9 +739,9 @@ static int toCharacteristics(int streamFlags) {
*
* @implSpec
* If the spliterator is naturally {@code SORTED} (the associated
- * {@code Comparator} is {@code null}) then the characteristic is converted
- * to the {@link #SORTED} flag, otherwise the characteristic is not
- * converted.
+ * {@code Comparator} is {@code null} or {@code Comparator.naturalOrder()}) then
+ * the characteristic is converted to the {@link #SORTED} flag, otherwise
+ * the characteristic is not converted.
*
* @param spliterator the spliterator from which to obtain characteristic
* bit set.
@@ -748,14 +749,15 @@ static int toCharacteristics(int streamFlags) {
*/
static int fromCharacteristics(Spliterator> spliterator) {
int characteristics = spliterator.characteristics();
- if ((characteristics & Spliterator.SORTED) != 0 && spliterator.getComparator() != null) {
- // Do not propagate the SORTED characteristic if it does not correspond
- // to a natural sort order
- return characteristics & SPLITERATOR_CHARACTERISTICS_MASK & ~Spliterator.SORTED;
- }
- else {
- return characteristics & SPLITERATOR_CHARACTERISTICS_MASK;
+ if ((characteristics & Spliterator.SORTED) != 0) {
+ Comparator> comparator = spliterator.getComparator();
+ if (comparator != null && !Comparator.naturalOrder().equals(comparator)) {
+ // Do not propagate the SORTED characteristic if it does not correspond
+ // to a natural sort order
+ return characteristics & SPLITERATOR_CHARACTERISTICS_MASK & ~Spliterator.SORTED;
+ }
}
+ return characteristics & SPLITERATOR_CHARACTERISTICS_MASK;
}
/**
diff --git a/src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
new file mode 100644
index 00000000000..6776ddcdb75
--- /dev/null
+++ b/src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
@@ -0,0 +1,443 @@
+/*
+ * Copyright (c) 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package javax.crypto.spec;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import java.nio.charset.StandardCharsets;
+import java.security.AsymmetricKey;
+import java.security.Key;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import java.util.HexFormat;
+import java.util.Objects;
+
+/**
+ * This immutable class specifies the set of parameters used with a {@code Cipher} for the
+ * Hybrid Public Key Encryption
+ * (HPKE) algorithm. HPKE is a public key encryption scheme for encrypting
+ * arbitrary-sized plaintexts with a recipient's public key. It combines a key
+ * encapsulation mechanism (KEM), a key derivation function (KDF), and an
+ * authenticated encryption with additional data (AEAD) cipher.
+ *
+ * The
+ * standard algorithm name for the cipher is "HPKE". Unlike most other
+ * ciphers, HPKE is not expressed as a transformation string of the form
+ * "algorithm/mode/padding". Therefore, the argument to {@code Cipher.getInstance}
+ * must be the single algorithm name "HPKE".
+ *
+ * In HPKE, the sender's {@code Cipher} is always initialized with the
+ * recipient's public key in {@linkplain Cipher#ENCRYPT_MODE encrypt mode},
+ * while the recipient's {@code Cipher} object is initialized with its own
+ * private key in {@linkplain Cipher#DECRYPT_MODE decrypt mode}.
+ *
+ * An {@code HPKEParameterSpec} object must be provided at HPKE
+ * {@linkplain Cipher#init(int, Key, AlgorithmParameterSpec) cipher initialization}.
+ *
+ * The {@link #of(int, int, int)} static method returns an {@code HPKEParameterSpec}
+ * object with the specified KEM, KDF, and AEAD algorithm identifiers.
+ * The terms "KEM algorithm identifiers", "KDF algorithm identifiers", and
+ * "AEAD algorithm identifiers" refer to their respective numeric values
+ * (specifically, {@code kem_id}, {@code kdf_id}, and {@code aead_id}) as
+ * defined in Section 7
+ * of RFC 9180 and maintained on the
+ * IANA HPKE page.
+ *
+ * Once an {@code HPKEParameterSpec} object is created, additional methods
+ * are available to generate new {@code HPKEParameterSpec} objects with
+ * different features:
+ *
+ * -
+ * Application-supplied information can be provided using the
+ * {@link #withInfo(byte[])} method by both sides.
+ *
-
+ * To authenticate using a pre-shared key ({@code mode_psk}), the
+ * pre-shared key and its identifier must be provided using the
+ * {@link #withPsk(SecretKey, byte[])} method by both sides.
+ *
-
+ * To authenticate using an asymmetric key ({@code mode_auth}),
+ * the asymmetric keys must be provided using the {@link #withAuthKey(AsymmetricKey)}
+ * method. Precisely, the sender must call this method with its own private key
+ * and the recipient must call it with the sender's public key.
+ *
-
+ * To authenticate using both a PSK and an asymmetric key
+ * ({@code mode_auth_psk}), both {@link #withAuthKey(AsymmetricKey)} and
+ * {@link #withPsk(SecretKey, byte[])} methods must be called as described above.
+ *
-
+ * In HPKE, a shared secret is negotiated during the KEM step and a key
+ * encapsulation message must be transmitted from the sender to the recipient
+ * so that the recipient can recover the shared secret. On the sender side,
+ * after the cipher is initialized, the key encapsulation message can be
+ * retrieved using the {@link Cipher#getIV()} method. On the recipient side,
+ * this message must be supplied as part of an {@code HPKEParameterSpec}
+ * object obtained from the {@link #withEncapsulation(byte[])} method.
+ *
+ * For successful interoperability, both sides need to have identical algorithm
+ * identifiers, and supply identical
+ * {@code info}, {@code psk}, and {@code psk_id} or matching authentication
+ * keys if provided. For details about HPKE modes, refer to
+ * Section 5
+ * of RFC 9180.
+ *
+ * If an HPKE cipher is {@linkplain Cipher#init(int, Key) initialized without
+ * parameters}, an {@code InvalidKeyException} is thrown.
+ *
+ * At HPKE cipher initialization, if no HPKE implementation supports the
+ * provided key type, an {@code InvalidKeyException} is thrown. If the provided
+ * {@code HPKEParameterSpec} is not accepted by any HPKE implementation,
+ * an {@code InvalidAlgorithmParameterException} is thrown. For example:
+ *
+ * - An algorithm identifier is unsupported or does not match the provided key type.
+ *
- A key encapsulation message is provided on the sender side.
+ *
- A key encapsulation message is not provided on the recipient side.
+ *
- An attempt to use {@code withAuthKey(key)} is made with an incompatible key.
+ *
- An attempt to use {@code withAuthKey(key)} is made but {@code mode_auth}
+ * or {@code mode_auth_psk} is not supported by the KEM algorithm used.
+ *
+ * After initialization, both the sender and recipient can process multiple
+ * messages in sequence with repeated {@code doFinal} calls, optionally preceded
+ * by one or more {@code updateAAD} and {@code update}. Each {@code doFinal}
+ * performs a complete HPKE encryption or decryption operation using a distinct
+ * IV derived from an internal sequence counter, as specified in
+ * Section 5.2
+ * of RFC 9180. On the recipient side, each {@code doFinal} call must correspond
+ * to exactly one complete ciphertext, and the number and order of calls must
+ * match those on the sender side. This differs from the direct use of an AEAD
+ * cipher, where the caller must provide a fresh IV and reinitialize the cipher
+ * for each message. By managing IVs internally, HPKE allows a single
+ * initialization to support multiple messages while still ensuring IV
+ * uniqueness and preserving AEAD security guarantees.
+ *
+ * This example shows a sender and a recipient using HPKE to securely exchange
+ * messages with an X25519 key pair.
+ * {@snippet lang=java class="PackageSnippets" region="hpke-spec-example"}
+ *
+ * @implNote This class defines constants for some of the standard algorithm
+ * identifiers such as {@link #KEM_DHKEM_P_256_HKDF_SHA256},
+ * {@link #KDF_HKDF_SHA256}, and {@link #AEAD_AES_128_GCM}. An HPKE {@code Cipher}
+ * implementation may support all, some, or none of the algorithm identifiers
+ * defined here. An implementation may also support additional identifiers not
+ * listed here, including private or experimental values.
+ *
+ * @spec https://www.rfc-editor.org/info/rfc9180
+ * RFC 9180: Hybrid Public Key Encryption
+ * @spec security/standard-names.html
+ * Java Security Standard Algorithm Names
+ * @since 26
+ */
+public final class HPKEParameterSpec implements AlgorithmParameterSpec {
+
+ /**
+ * KEM algorithm identifier for DHKEM(P-256, HKDF-SHA256) as defined in RFC 9180.
+ */
+ public static final int KEM_DHKEM_P_256_HKDF_SHA256 = 0x10;
+
+ /**
+ * KEM algorithm identifier for DHKEM(P-384, HKDF-SHA384) as defined in RFC 9180.
+ */
+ public static final int KEM_DHKEM_P_384_HKDF_SHA384 = 0x11;
+
+ /**
+ * KEM algorithm identifier for DHKEM(P-521, HKDF-SHA512) as defined in RFC 9180.
+ */
+ public static final int KEM_DHKEM_P_521_HKDF_SHA512 = 0x12;
+
+ /**
+ * KEM algorithm identifier for DHKEM(X25519, HKDF-SHA256) as defined in RFC 9180.
+ */
+ public static final int KEM_DHKEM_X25519_HKDF_SHA256 = 0x20;
+
+ /**
+ * KEM algorithm identifier for DHKEM(X448, HKDF-SHA512) as defined in RFC 9180.
+ */
+ public static final int KEM_DHKEM_X448_HKDF_SHA512 = 0x21;
+
+ /**
+ * KDF algorithm identifier for HKDF-SHA256 as defined in RFC 9180.
+ */
+ public static final int KDF_HKDF_SHA256 = 0x1;
+
+ /**
+ * KDF algorithm identifier for HKDF-SHA384 as defined in RFC 9180.
+ */
+ public static final int KDF_HKDF_SHA384 = 0x2;
+
+ /**
+ * KDF algorithm identifier for HKDF-SHA512 as defined in RFC 9180.
+ */
+ public static final int KDF_HKDF_SHA512 = 0x3;
+
+ /**
+ * AEAD algorithm identifier for AES-128-GCM as defined in RFC 9180.
+ */
+ public static final int AEAD_AES_128_GCM = 0x1;
+
+ /**
+ * AEAD algorithm identifier for AES-256-GCM as defined in RFC 9180.
+ */
+ public static final int AEAD_AES_256_GCM = 0x2;
+
+ /**
+ * AEAD algorithm identifier for ChaCha20Poly1305 as defined in RFC 9180.
+ */
+ public static final int AEAD_CHACHA20_POLY1305 = 0x3;
+
+ /**
+ * AEAD algorithm identifier for Export-only as defined in RFC 9180.
+ */
+ public static final int EXPORT_ONLY = 0xffff;
+
+ private final int kem_id;
+ private final int kdf_id;
+ private final int aead_id;
+ private final byte[] info; // never null, can be empty
+ private final SecretKey psk; // null if not used
+ private final byte[] psk_id; // never null, can be empty
+ private final AsymmetricKey kS; // null if not used
+ private final byte[] encapsulation; // null if none
+
+ // Note: this constructor does not clone array arguments.
+ private HPKEParameterSpec(int kem_id, int kdf_id, int aead_id, byte[] info,
+ SecretKey psk, byte[] psk_id, AsymmetricKey kS, byte[] encapsulation) {
+ this.kem_id = kem_id;
+ this.kdf_id = kdf_id;
+ this.aead_id = aead_id;
+ this.info = info;
+ this.psk = psk;
+ this.psk_id = psk_id;
+ this.kS = kS;
+ this.encapsulation = encapsulation;
+ }
+
+ /**
+ * A factory method to create a new {@code HPKEParameterSpec} object with
+ * specified KEM, KDF, and AEAD algorithm identifiers in {@code mode_base}
+ * mode with an empty {@code info}.
+ *
+ * @param kem_id algorithm identifier for KEM, must be between 0 and 65535 (inclusive)
+ * @param kdf_id algorithm identifier for KDF, must be between 0 and 65535 (inclusive)
+ * @param aead_id algorithm identifier for AEAD, must be between 0 and 65535 (inclusive)
+ * @return a new {@code HPKEParameterSpec} object
+ * @throws IllegalArgumentException if any input value
+ * is out of range (must be between 0 and 65535, inclusive).
+ */
+ public static HPKEParameterSpec of(int kem_id, int kdf_id, int aead_id) {
+ if (kem_id < 0 || kem_id > 65535) {
+ throw new IllegalArgumentException("Invalid kem_id: " + kem_id);
+ }
+ if (kdf_id < 0 || kdf_id > 65535) {
+ throw new IllegalArgumentException("Invalid kdf_id: " + kdf_id);
+ }
+ if (aead_id < 0 || aead_id > 65535) {
+ throw new IllegalArgumentException("Invalid aead_id: " + aead_id);
+ }
+ return new HPKEParameterSpec(kem_id, kdf_id, aead_id,
+ new byte[0], null, new byte[0], null, null);
+ }
+
+ /**
+ * Creates a new {@code HPKEParameterSpec} object with the specified
+ * {@code info} value.
+ *
+ * For interoperability, RFC 9180 Section 7.2.1 recommends limiting
+ * this value to a maximum of 64 bytes.
+ *
+ * @param info application-supplied information.
+ * The contents of the array are copied to protect
+ * against subsequent modification.
+ * @return a new {@code HPKEParameterSpec} object
+ * @throws NullPointerException if {@code info} is {@code null}
+ * @throws IllegalArgumentException if {@code info} is empty.
+ */
+ public HPKEParameterSpec withInfo(byte[] info) {
+ Objects.requireNonNull(info);
+ if (info.length == 0) {
+ throw new IllegalArgumentException("info is empty");
+ }
+ return new HPKEParameterSpec(kem_id, kdf_id, aead_id,
+ info.clone(), psk, psk_id, kS, encapsulation);
+ }
+
+ /**
+ * Creates a new {@code HPKEParameterSpec} object with the specified
+ * {@code psk} and {@code psk_id} values.
+ *
+ * RFC 9180 Section 5.1.2 requires the PSK MUST have at least 32 bytes
+ * of entropy. For interoperability, RFC 9180 Section 7.2.1 recommends
+ * limiting the key size and identifier length to a maximum of 64 bytes.
+ *
+ * @param psk pre-shared key
+ * @param psk_id identifier for PSK. The contents of the array are copied
+ * to protect against subsequent modification.
+ * @return a new {@code HPKEParameterSpec} object
+ * @throws NullPointerException if {@code psk} or {@code psk_id} is {@code null}
+ * @throws IllegalArgumentException if {@code psk} is shorter than 32 bytes
+ * or {@code psk_id} is empty
+ */
+ public HPKEParameterSpec withPsk(SecretKey psk, byte[] psk_id) {
+ Objects.requireNonNull(psk);
+ Objects.requireNonNull(psk_id);
+ if (psk_id.length == 0) {
+ throw new IllegalArgumentException("psk_id is empty");
+ }
+ if ("RAW".equalsIgnoreCase(psk.getFormat())) {
+ // We can only check when psk is extractable. We can only
+ // check the length and not the real entropy size
+ var keyBytes = psk.getEncoded();
+ assert keyBytes != null;
+ Arrays.fill(keyBytes, (byte)0);
+ if (keyBytes.length < 32) {
+ throw new IllegalArgumentException("psk is too short");
+ }
+ }
+ return new HPKEParameterSpec(kem_id, kdf_id, aead_id,
+ info, psk, psk_id.clone(), kS, encapsulation);
+ }
+
+ /**
+ * Creates a new {@code HPKEParameterSpec} object with the specified
+ * key encapsulation message value that will be used by the recipient.
+ *
+ * @param encapsulation the key encapsulation message.
+ * The contents of the array are copied to protect against
+ * subsequent modification.
+ *
+ * @return a new {@code HPKEParameterSpec} object
+ * @throws NullPointerException if {@code encapsulation} is {@code null}
+ */
+ public HPKEParameterSpec withEncapsulation(byte[] encapsulation) {
+ return new HPKEParameterSpec(kem_id, kdf_id, aead_id,
+ info, psk, psk_id, kS,
+ Objects.requireNonNull(encapsulation).clone());
+ }
+
+ /**
+ * Creates a new {@code HPKEParameterSpec} object with the specified
+ * authentication key value.
+ *
+ * Note: this method does not check whether the KEM algorithm supports
+ * {@code mode_auth} or {@code mode_auth_psk}. If the resulting object is
+ * used to initialize an HPKE cipher with an unsupported mode, an
+ * {@code InvalidAlgorithmParameterException} will be thrown at that time.
+ *
+ * @param kS the authentication key
+ * @return a new {@code HPKEParameterSpec} object
+ * @throws NullPointerException if {@code kS} is {@code null}
+ */
+ public HPKEParameterSpec withAuthKey(AsymmetricKey kS) {
+ return new HPKEParameterSpec(kem_id, kdf_id, aead_id,
+ info, psk, psk_id,
+ Objects.requireNonNull(kS),
+ encapsulation);
+ }
+
+ /**
+ * {@return the algorithm identifier for KEM }
+ */
+ public int kem_id() {
+ return kem_id;
+ }
+
+ /**
+ * {@return the algorithm identifier for KDF }
+ */
+ public int kdf_id() {
+ return kdf_id;
+ }
+
+ /**
+ * {@return the algorithm identifier for AEAD }
+ */
+ public int aead_id() {
+ return aead_id;
+ }
+
+ /**
+ * {@return a copy of the application-supplied information, empty if none}
+ */
+ public byte[] info() {
+ return info.clone();
+ }
+
+ /**
+ * {@return pre-shared key, {@code null} if none}
+ */
+ public SecretKey psk() {
+ return psk;
+ }
+
+ /**
+ * {@return a copy of the identifier for PSK, empty if none}
+ */
+ public byte[] psk_id() {
+ return psk_id.clone();
+ }
+
+ /**
+ * {@return the key for authentication, {@code null} if none}
+ */
+ public AsymmetricKey authKey() {
+ return kS;
+ }
+
+ /**
+ * {@return a copy of the key encapsulation message, {@code null} if none}
+ */
+ public byte[] encapsulation() {
+ return encapsulation == null ? null : encapsulation.clone();
+ }
+
+ @Override
+ public String toString() {
+ return "HPKEParameterSpec{" +
+ "kem_id=" + kem_id +
+ ", kdf_id=" + kdf_id +
+ ", aead_id=" + aead_id +
+ ", info=" + bytesToString(info) +
+ ", " + (psk == null
+ ? (kS == null ? "mode_base" : "mode_auth")
+ : (kS == null ? "mode_psk" : "mode_auth_psk")) + "}";
+ }
+
+ // Returns a human-readable representation of a byte array.
+ private static String bytesToString(byte[] input) {
+ if (input.length == 0) {
+ return "(empty)";
+ } else {
+ for (byte b : input) {
+ if (b < 0x20 || b > 0x7E || b == '"') {
+ // Non-ASCII or control characters are hard to read, and
+ // `"` requires character escaping. If any of these are
+ // present, return only the HEX representation.
+ return HexFormat.of().formatHex(input);
+ }
+ }
+ // Otherwise, all characters are printable and safe.
+ // Return both HEX and ASCII representations.
+ return HexFormat.of().formatHex(input)
+ + " (\"" + new String(input, StandardCharsets.US_ASCII) + "\")";
+ }
+ }
+}
diff --git a/src/java.base/share/classes/javax/crypto/spec/snippet-files/PackageSnippets.java b/src/java.base/share/classes/javax/crypto/spec/snippet-files/PackageSnippets.java
new file mode 100644
index 00000000000..e4074c1c4a9
--- /dev/null
+++ b/src/java.base/share/classes/javax/crypto/spec/snippet-files/PackageSnippets.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import javax.crypto.Cipher;
+import javax.crypto.spec.HPKEParameterSpec;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.util.Arrays;
+import java.util.HexFormat;
+
+class PackageSnippets {
+ public static void main(String[] args) throws Exception {
+
+ // @start region="hpke-spec-example"
+ // Recipient key pair generation
+ KeyPairGenerator g = KeyPairGenerator.getInstance("X25519");
+ KeyPair kp = g.generateKeyPair();
+
+ // The HPKE sender cipher is initialized with the recipient's public
+ // key and an HPKEParameterSpec using specified algorithm identifiers
+ // and application-supplied info.
+ Cipher senderCipher = Cipher.getInstance("HPKE");
+ HPKEParameterSpec ps = HPKEParameterSpec.of(
+ HPKEParameterSpec.KEM_DHKEM_X25519_HKDF_SHA256,
+ HPKEParameterSpec.KDF_HKDF_SHA256,
+ HPKEParameterSpec.AEAD_AES_128_GCM)
+ .withInfo(HexFormat.of().parseHex("010203040506"));
+ senderCipher.init(Cipher.ENCRYPT_MODE, kp.getPublic(), ps);
+
+ // Retrieve the key encapsulation message (from the KEM step) from
+ // the sender.
+ byte[] kemEncap = senderCipher.getIV();
+
+ // The HPKE recipient cipher is initialized with its own private key,
+ // an HPKEParameterSpec using the same algorithm identifiers as used by
+ // the sender, and the key encapsulation message from the sender.
+ Cipher recipientCipher = Cipher.getInstance("HPKE");
+ HPKEParameterSpec pr = HPKEParameterSpec.of(
+ HPKEParameterSpec.KEM_DHKEM_X25519_HKDF_SHA256,
+ HPKEParameterSpec.KDF_HKDF_SHA256,
+ HPKEParameterSpec.AEAD_AES_128_GCM)
+ .withInfo(HexFormat.of().parseHex("010203040506"))
+ .withEncapsulation(kemEncap);
+ recipientCipher.init(Cipher.DECRYPT_MODE, kp.getPrivate(), pr);
+
+ // Encryption and decryption
+ byte[] msg = "Hello World".getBytes(StandardCharsets.UTF_8);
+ byte[] ct = senderCipher.doFinal(msg);
+ byte[] pt = recipientCipher.doFinal(ct);
+
+ assert Arrays.equals(msg, pt);
+ // @end
+ }
+}
diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java
index 962a2057585..ec747d06c21 100644
--- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java
+++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java
@@ -35,6 +35,7 @@
import jdk.internal.constant.ClassOrInterfaceDescImpl;
import jdk.internal.constant.PrimitiveClassDescImpl;
import jdk.internal.util.ArraysSupport;
+import jdk.internal.util.ModifiedUtf;
import jdk.internal.vm.annotation.Stable;
import static java.util.Objects.requireNonNull;
@@ -141,7 +142,7 @@ enum State { RAW, BYTE, CHAR, STRING }
@Stable TypeDescriptor typeSym;
Utf8EntryImpl(ConstantPool cpm, int index,
- byte[] rawBytes, int offset, int rawLen) {
+ byte[] rawBytes, int offset, int rawLen) {
super(cpm, index, 0);
this.rawBytes = rawBytes;
this.offset = offset;
@@ -154,6 +155,10 @@ enum State { RAW, BYTE, CHAR, STRING }
}
Utf8EntryImpl(ConstantPool cpm, int index, String s, int contentHash) {
+ // Prevent creation of unwritable entries
+ if (!ModifiedUtf.isValidLengthInConstantPool(s)) {
+ throw new IllegalArgumentException("utf8 length out of range of u2: " + ModifiedUtf.utfLen(s));
+ }
super(cpm, index, 0);
this.rawBytes = null;
this.offset = 0;
diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java
index b30592a4ebd..6daef5cab9a 100644
--- a/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java
+++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java
@@ -277,10 +277,9 @@ void writeUtfEntry(String str) {
int strlen = str.length();
int countNonZeroAscii = JLA.countNonZeroAscii(str);
long utflenLong = utfLen(str, countNonZeroAscii);
- if (!ExactConversionsSupport.isLongToCharExact(utflenLong)) {
- throw new IllegalArgumentException("utf8 length out of range of u2: " + utflenLong);
- }
- int utflen = (int)utflenLong;
+ // Utf8Entry should always be writable
+ assert ExactConversionsSupport.isLongToCharExact(utflenLong) : utflenLong;
+ int utflen = (int) utflenLong;
reserveSpace(utflen + 3);
int offset = this.offset;
diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java
index 5be14f42baa..e4e67afb17f 100644
--- a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java
+++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2025, 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
@@ -25,12 +25,11 @@
*/
package jdk.internal.classfile.impl;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.classfile.ClassHierarchyResolver;
+import java.lang.classfile.constantpool.ClassEntry;
import java.lang.constant.ClassDesc;
import java.util.Collection;
import java.util.HashMap;
@@ -38,7 +37,6 @@
import java.util.function.Function;
import static java.lang.classfile.ClassFile.ACC_INTERFACE;
-import static java.lang.classfile.constantpool.PoolEntry.*;
import static java.lang.constant.ConstantDescs.CD_Object;
import static java.util.Objects.requireNonNull;
import static jdk.internal.constant.ConstantUtils.referenceClassDesc;
@@ -164,31 +162,12 @@ public ResourceParsingClassHierarchyResolver(Function cl
public ClassHierarchyResolver.ClassHierarchyInfo getClassInfo(ClassDesc classDesc) {
var ci = streamProvider.apply(classDesc);
if (ci == null) return null;
- try (var in = new DataInputStream(new BufferedInputStream(ci))) {
- in.skipBytes(8);
- int cpLength = in.readUnsignedShort();
- String[] cpStrings = new String[cpLength];
- int[] cpClasses = new int[cpLength];
- for (int i = 1; i < cpLength; i++) {
- int tag;
- switch (tag = in.readUnsignedByte()) {
- case TAG_UTF8 -> cpStrings[i] = in.readUTF();
- case TAG_CLASS -> cpClasses[i] = in.readUnsignedShort();
- case TAG_STRING, TAG_METHOD_TYPE, TAG_MODULE, TAG_PACKAGE -> in.skipBytes(2);
- case TAG_METHOD_HANDLE -> in.skipBytes(3);
- case TAG_INTEGER, TAG_FLOAT, TAG_FIELDREF, TAG_METHODREF, TAG_INTERFACE_METHODREF,
- TAG_NAME_AND_TYPE, TAG_DYNAMIC, TAG_INVOKE_DYNAMIC -> in.skipBytes(4);
- case TAG_LONG, TAG_DOUBLE -> {
- in.skipBytes(8);
- i++;
- }
- default -> throw new IllegalStateException("Bad tag (" + tag + ") at index (" + i + ")");
- }
- }
- boolean isInterface = (in.readUnsignedShort() & ACC_INTERFACE) != 0;
- in.skipBytes(2);
- int superIndex = in.readUnsignedShort();
- var superClass = superIndex > 0 ? ClassDesc.ofInternalName(cpStrings[cpClasses[superIndex]]) : null;
+ try (ci) {
+ var reader = new ClassReaderImpl(ci.readAllBytes(), ClassFileImpl.DEFAULT_CONTEXT);
+ boolean isInterface = (reader.flags() & ACC_INTERFACE) != 0;
+ ClassDesc superClass = reader.superclassEntry()
+ .map(ClassEntry::asSymbol)
+ .orElse(null);
return new ClassHierarchyInfoImpl(superClass, isInterface);
} catch (IOException ioe) {
throw new UncheckedIOException(ioe);
diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/TransformImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/TransformImpl.java
index 23387fcb098..4cb0517ec76 100644
--- a/src/java.base/share/classes/jdk/internal/classfile/impl/TransformImpl.java
+++ b/src/java.base/share/classes/jdk/internal/classfile/impl/TransformImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2025, 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
@@ -120,9 +120,9 @@ public ResolvedTransform resolve(ClassBuilder builder) {
@Override
public ClassTransform andThen(ClassTransform next) {
- if (next instanceof ClassMethodTransform cmt)
- return new ClassMethodTransform(transform.andThen(cmt.transform),
- mm -> filter.test(mm) && cmt.filter.test(mm));
+ // Optimized for shared _ -> true filter in ClassTransform.transformingMethods(MethodTransform)
+ if (next instanceof ClassMethodTransform(var nextTransform, var nextFilter) && filter == nextFilter)
+ return new ClassMethodTransform(transform.andThen(nextTransform), filter);
else
return UnresolvedClassTransform.super.andThen(next);
}
@@ -143,9 +143,9 @@ public ResolvedTransform resolve(ClassBuilder builder) {
@Override
public ClassTransform andThen(ClassTransform next) {
- if (next instanceof ClassFieldTransform cft)
- return new ClassFieldTransform(transform.andThen(cft.transform),
- mm -> filter.test(mm) && cft.filter.test(mm));
+ // Optimized for shared _ -> true filter in ClassTransform.transformingFields(FieldTransform)
+ if (next instanceof ClassFieldTransform(var nextTransform, var nextFilter) && filter == nextFilter)
+ return new ClassFieldTransform(transform.andThen(nextTransform), filter);
else
return UnresolvedClassTransform.super.andThen(next);
}
@@ -208,8 +208,8 @@ public ResolvedTransform resolve(MethodBuilder builder) {
@Override
public MethodTransform andThen(MethodTransform next) {
- return (next instanceof TransformImpl.MethodCodeTransform mct)
- ? new TransformImpl.MethodCodeTransform(xform.andThen(mct.xform))
+ return (next instanceof MethodCodeTransform(var nextXform))
+ ? new TransformImpl.MethodCodeTransform(xform.andThen(nextXform))
: UnresolvedMethodTransform.super.andThen(next);
}
diff --git a/src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java b/src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java
index 3edcac2e44c..728ee235547 100644
--- a/src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java
+++ b/src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java
@@ -212,7 +212,9 @@ private static long allocateNativeInternal(long byteSize, long byteAlignment, Me
allocationBase = allocateMemoryWrapper(allocationSize);
result = Utils.alignUp(allocationBase, byteAlignment);
} else {
- allocationSize = alignedSize;
+ // always allocate at least 'byteAlignment' bytes, so that malloc is guaranteed to
+ // return a pointer aligned to that alignment, for cases where byteAlignment > alignedSize
+ allocationSize = Math.max(alignedSize, byteAlignment);
if (shouldReserve) {
AbstractMemorySegmentImpl.NIO_ACCESS.reserveMemory(allocationSize, byteSize);
}
diff --git a/src/java.base/share/classes/jdk/internal/util/DateTimeHelper.java b/src/java.base/share/classes/jdk/internal/util/DateTimeHelper.java
index bbb0b6738d1..4d9d560fded 100644
--- a/src/java.base/share/classes/jdk/internal/util/DateTimeHelper.java
+++ b/src/java.base/share/classes/jdk/internal/util/DateTimeHelper.java
@@ -49,24 +49,23 @@ public static void formatTo(StringBuilder buf, LocalDateTime dateTime) {
* Requires extra capacity of 10 to avoid StringBuilder reallocation.
*/
public static void formatTo(StringBuilder buf, LocalDate date) {
- int year = date.getYear(),
- month = date.getMonthValue(),
- day = date.getDayOfMonth();
- int absYear = Math.abs(year);
- if (absYear < 1000) {
+ int year = date.getYear(),
+ absYear = Math.abs(year);
+ if (absYear < 10000) {
if (year < 0) {
buf.append('-');
}
- buf.repeat('0', absYear < 10 ? 3 : absYear < 100 ? 2 : 1);
- buf.append(absYear);
+ DecimalDigits.appendQuad(buf, absYear);
} else {
if (year > 9999) {
buf.append('+');
}
buf.append(year);
}
- buf.append(month < 10 ? "-0" : "-").append(month)
- .append(day < 10 ? "-0" : "-").append(day);
+ buf.append('-');
+ DecimalDigits.appendPair(buf, date.getMonthValue());
+ buf.append('-');
+ DecimalDigits.appendPair(buf, date.getDayOfMonth());
}
/**
@@ -74,14 +73,14 @@ public static void formatTo(StringBuilder buf, LocalDate date) {
* Requires extra capacity of 18 to avoid StringBuilder reallocation.
*/
public static void formatTo(StringBuilder buf, LocalTime time) {
- int hour = time.getHour(),
- minute = time.getMinute(),
- second = time.getSecond(),
+ DecimalDigits.appendPair(buf, time.getHour());
+ buf.append(':');
+ DecimalDigits.appendPair(buf, time.getMinute());
+ int second = time.getSecond(),
nano = time.getNano();
- buf.append(hour < 10 ? "0" : "").append(hour)
- .append(minute < 10 ? ":0" : ":").append(minute);
if ((second | nano) > 0) {
- buf.append(second < 10 ? ":0" : ":").append(second);
+ buf.append(':');
+ DecimalDigits.appendPair(buf, second);
if (nano > 0) {
buf.append('.');
int zeros = 9 - DecimalDigits.stringSize(nano);
diff --git a/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java b/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java
index 6c0c745651e..b55b6ce63b0 100644
--- a/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java
+++ b/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java
@@ -25,6 +25,8 @@
package jdk.internal.util;
+import jdk.internal.access.JavaLangAccess;
+import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.Stable;
@@ -36,6 +38,7 @@
* @since 21
*/
public final class DecimalDigits {
+ private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
/**
@@ -443,4 +446,56 @@ private static void uncheckedPutCharUTF16(byte[] buf, int charPos, int c) {
assert charPos >= 0 && charPos < (buf.length >> 1);
UNSAFE.putCharUnaligned(buf, ARRAY_BYTE_BASE_OFFSET + ((long) charPos << 1), (char) c);
}
+
+ /**
+ * Appends the two-digit string representation of the {@code int}
+ * argument to the given {@code StringBuilder}.
+ *
+ * The integer {@code v} is formatted as two decimal digits.
+ * Values from 0 to 9 are formatted with a leading zero (e.g., 5 becomes "05"),
+ * and values from 10 to 99 are formatted as regular two-digit numbers.
+ * If the value is outside the range 0-99, the behavior is unspecified.
+ *
+ * @param buf the {@code StringBuilder} to append to.
+ * @param v the {@code int} value (should be between 0 and 99 inclusive).
+ */
+ public static void appendPair(StringBuilder buf, int v) {
+ // The & 0x7f operation keeps the index within the safe range [0, 127] for the DIGITS array,
+ // which allows the JIT compiler to eliminate array bounds checks for performance.
+ int packed = DIGITS[v & 0x7f];
+ // The temporary String and byte[] objects created here are typically eliminated
+ // by the JVM's escape analysis and scalar replacement optimizations during
+ // runtime compilation, avoiding actual heap allocations in optimized code.
+ buf.append(
+ JLA.uncheckedNewStringWithLatin1Bytes(
+ new byte[] {(byte) packed, (byte) (packed >> 8)}));
+ }
+
+ /**
+ * Appends the four-digit string representation of the {@code int}
+ * argument to the given {@code StringBuilder}.
+ *
+ * The integer {@code v} is formatted as four decimal digits.
+ * Values from 0 to 9 are formatted with leading zeros (e.g., 5 becomes "0005"),
+ * values from 10 to 99 add two leading zeros (e.g., 25 becomes "0025"),
+ * values from 100 to 999 add one leading zero (e.g., 123 becomes "0123"),
+ * and values from 1000 to 9999 have no leading zeros.
+ * If the value is outside the range 0-9999, the behavior is unspecified.
+ *
+ * @param buf the {@code StringBuilder} to append to.
+ * @param v the {@code int} value (should be between 0 and 9999 inclusive).
+ */
+ public static void appendQuad(StringBuilder buf, int v) {
+ // The & 0x7f operation keeps the index within the safe range [0, 127] for the DIGITS array,
+ // which allows the JIT compiler to eliminate array bounds checks for performance.
+ int packedHigh = DIGITS[(v / 100) & 0x7f];
+ int packedLow = DIGITS[(v % 100) & 0x7f];
+ // The temporary String and byte[] objects created here are typically eliminated
+ // by the JVM's escape analysis and scalar replacement optimizations during
+ // runtime compilation, avoiding actual heap allocations in optimized code.
+ buf.append(
+ JLA.uncheckedNewStringWithLatin1Bytes(
+ new byte[] {(byte) packedHigh, (byte) (packedHigh >> 8),
+ (byte) packedLow, (byte) (packedLow >> 8)}));
+ }
}
diff --git a/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java b/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java
index 46885e12adf..4221ec22de3 100644
--- a/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java
+++ b/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java
@@ -28,19 +28,17 @@
import jdk.internal.vm.annotation.ForceInline;
-/**
- * Helper to JDK UTF putChar and Calculate length
- *
- * @since 24
- */
-public abstract class ModifiedUtf {
- // Maximum number of bytes allowed for a Modified UTF-8 encoded string
- // in a ClassFile constant pool entry (CONSTANT_Utf8_info).
+/// Utilities for string encoding and decoding with the
+/// [Modified UTF-8][java.io.DataInput##modified-utf-8] format.
+public final class ModifiedUtf {
+ /// Maximum number of bytes allowed for a Modified UTF-8 encoded string
+ /// in a [java.lang.classfile.constantpool.Utf8Entry] or a hotspot `Symbol`.
public static final int CONSTANT_POOL_UTF8_MAX_BYTES = 65535;
private ModifiedUtf() {
}
+ /// Writes a char to the pre-sized modified UTF buffer.
@ForceInline
public static int putChar(byte[] buf, int offset, char c) {
if (c != 0 && c < 0x80) {
@@ -58,11 +56,23 @@ public static int putChar(byte[] buf, int offset, char c) {
return offset;
}
- /**
- * Calculate the utf length of a string
- * @param str input string
- * @param countNonZeroAscii the number of non-zero ascii characters in the prefix calculated by JLA.countNonZeroAscii(str)
- */
+ /// Calculate the encoded length of an input String.
+ /// For many workloads that have fast paths for ASCII-only prefixes,
+ /// [#utfLen(String, int)] skips scanning that prefix.
+ ///
+ /// @param str input string
+ public static long utfLen(String str) {
+ return utfLen(str, 0);
+ }
+
+ /// Calculate the encoded length of trailing parts of an input String,
+ /// after [jdk.internal.access.JavaLangAccess#countNonZeroAscii(String)]
+ /// calculates the number of contiguous single-byte characters in the
+ /// beginning of the string.
+ ///
+ /// @param str input string
+ /// @param countNonZeroAscii the number of non-zero ascii characters in the
+ /// prefix calculated by JLA.countNonZeroAscii(str)
@ForceInline
public static long utfLen(String str, int countNonZeroAscii) {
long utflen = str.length();
@@ -74,11 +84,11 @@ public static long utfLen(String str, int countNonZeroAscii) {
return utflen;
}
- /**
- * Checks whether the Modified UTF-8 encoded length of the given string
- * fits within the ClassFile constant pool limit (u2 length = 65535 bytes).
- * @param str the string to check
- */
+ /// Checks whether an input String can be encoded in a
+ /// [java.lang.classfile.constantpool.Utf8Entry], or represented as a
+ /// hotspot `Symbol` (which has the same length limit).
+ ///
+ /// @param str input string
@ForceInline
public static boolean isValidLengthInConstantPool(String str) {
// Quick approximation: each char can be at most 3 bytes in Modified UTF-8.
@@ -91,7 +101,7 @@ public static boolean isValidLengthInConstantPool(String str) {
return false;
}
// Check exact Modified UTF-8 length.
- long utfLen = utfLen(str, 0);
+ long utfLen = utfLen(str);
return utfLen <= CONSTANT_POOL_UTF8_MAX_BYTES;
}
}
diff --git a/src/java.base/share/classes/sun/invoke/util/BytecodeDescriptor.java b/src/java.base/share/classes/sun/invoke/util/BytecodeDescriptor.java
index bd5ea6d7635..b3671d19333 100644
--- a/src/java.base/share/classes/sun/invoke/util/BytecodeDescriptor.java
+++ b/src/java.base/share/classes/sun/invoke/util/BytecodeDescriptor.java
@@ -63,33 +63,24 @@ public static Class> parseClass(String descriptor, ClassLoader loader) {
/// @throws TypeNotPresentException if a reference type cannot be found by
/// the loader (before the descriptor is found invalid)
public static List> parseMethod(String descriptor, ClassLoader loader) {
- return parseMethod(descriptor, 0, descriptor.length(), loader);
- }
-
- /**
- * @param loader the class loader in which to look up the types (null means
- * bootstrap class loader)
- */
- static List> parseMethod(String bytecodeSignature,
- int start, int end, ClassLoader loader) {
- String str = bytecodeSignature;
- int[] i = {start};
+ int end = descriptor.length(); // implicit null check
+ int[] i = {0};
var ptypes = new ArrayList>();
- if (i[0] < end && str.charAt(i[0]) == '(') {
+ if (i[0] < end && descriptor.charAt(i[0]) == '(') {
++i[0]; // skip '('
- while (i[0] < end && str.charAt(i[0]) != ')') {
- Class> pt = parseSig(str, i, end, loader);
+ while (i[0] < end && descriptor.charAt(i[0]) != ')') {
+ Class> pt = parseSig(descriptor, i, end, loader);
if (pt == null || pt == void.class)
- parseError(str, "bad argument type");
+ parseError(descriptor, "bad argument type");
ptypes.add(pt);
}
++i[0]; // skip ')'
} else {
- parseError(str, "not a method type");
+ parseError(descriptor, "not a method type");
}
- Class> rtype = parseSig(str, i, end, loader);
+ Class> rtype = parseSig(descriptor, i, end, loader);
if (rtype == null || i[0] != end)
- parseError(str, "bad return type");
+ parseError(descriptor, "bad return type");
ptypes.add(rtype);
return ptypes;
}
@@ -115,8 +106,22 @@ private static Class> parseSig(String str, int[] i, int end, ClassLoader loade
if (i[0] == end) return null;
char c = str.charAt(i[0]++);
if (c == 'L') {
- int begc = i[0], endc = str.indexOf(';', begc);
- if (endc < 0) return null;
+ int begc = i[0];
+ int identifierStart = begc;
+ int endc;
+ while (true) {
+ int next = nextNonIdentifier(str, identifierStart, end);
+ if (identifierStart == next || next >= end) return null; // Empty name segment, or the end
+ char ch = str.charAt(next);
+ if (ch == ';') {
+ endc = next;
+ break;
+ } else if (ch == '/') {
+ identifierStart = next + 1; // Next name segment
+ } else {
+ return null; // Bad char [ or .
+ }
+ }
i[0] = endc+1;
String name = str.substring(begc, endc).replace('/', '.');
try {
@@ -148,6 +153,23 @@ private static Class> parseSig(String str, int[] i, int end, ClassLoader loade
}
}
+ private static final int CHECK_OFFSET = 32;
+ private static final long NON_IDENTIFIER_MASK = (1L << ('.' - CHECK_OFFSET))
+ | (1L << ('/' - CHECK_OFFSET))
+ | (1L << (';' - CHECK_OFFSET))
+ | (1L << ('[' - CHECK_OFFSET));
+
+ private static int nextNonIdentifier(String str, int index, int end) {
+ while (index < end) {
+ int check = str.charAt(index) - CHECK_OFFSET;
+ if ((check & -Long.SIZE) == 0 && (NON_IDENTIFIER_MASK & (1L << check)) != 0) {
+ break;
+ }
+ index++;
+ }
+ return index;
+ }
+
public static String unparse(Class> type) {
if (type == Object.class) {
return "Ljava/lang/Object;";
diff --git a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java
index 3e771c015f4..73ca0c6bf16 100644
--- a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java
+++ b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, 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
@@ -627,6 +627,10 @@ public void engineStore(OutputStream stream, char[] password)
dos.write(digest);
dos.flush();
+
+ if (debug != null) {
+ emitWeakKeyStoreWarning();
+ }
}
}
@@ -790,6 +794,10 @@ public void engineLoad(InputStream stream, char[] password)
privateKeyCount + ". trusted key count: " + trustedKeyCount);
}
+ if (debug != null) {
+ emitWeakKeyStoreWarning();
+ }
+
/*
* If a password has been provided, we check the keyed digest
* at the end. If this check fails, the store has been tampered
@@ -838,4 +846,16 @@ private byte[] convertToBytes(char[] password) {
}
return passwdBytes;
}
+
+ private void emitWeakKeyStoreWarning() {
+ String type = this.getClass().getSimpleName().
+ toUpperCase(Locale.ROOT);
+ if (type.equals("JKS")){
+ debug.println("WARNING: JKS uses outdated cryptographic "
+ + "algorithms and will be removed in a future "
+ + "release. Migrate to PKCS12 using:");
+ debug.println("keytool -importkeystore -srckeystore "
+ + "-destkeystore -deststoretype pkcs12");
+ }
+ }
}
diff --git a/src/java.base/share/classes/sun/security/ssl/Alert.java b/src/java.base/share/classes/sun/security/ssl/Alert.java
index ed5e079bf44..d172206326f 100644
--- a/src/java.base/share/classes/sun/security/ssl/Alert.java
+++ b/src/java.base/share/classes/sun/security/ssl/Alert.java
@@ -238,7 +238,7 @@ public void consume(ConnectionContext context,
TransportContext tc = (TransportContext)context;
AlertMessage am = new AlertMessage(tc, m);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Received alert message", am);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/AlpnExtension.java b/src/java.base/share/classes/sun/security/ssl/AlpnExtension.java
index aa5933ddab0..f03a65c8410 100644
--- a/src/java.base/share/classes/sun/security/ssl/AlpnExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/AlpnExtension.java
@@ -157,7 +157,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(SSLExtension.CH_ALPN)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"Ignore client unavailable extension: " +
SSLExtension.CH_ALPN.name);
@@ -170,7 +170,7 @@ public byte[] produce(ConnectionContext context,
String[] laps = chc.sslConfig.applicationProtocols;
if ((laps == null) || (laps.length == 0)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"No available application protocols");
}
@@ -183,7 +183,7 @@ public byte[] produce(ConnectionContext context,
int length = ap.getBytes(alpnCharset).length;
if (length == 0) {
// log the configuration problem
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.severe(
"Application protocol name cannot be empty");
}
@@ -197,7 +197,7 @@ public byte[] produce(ConnectionContext context,
listLength += (length + 1);
} else {
// log the configuration problem
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.severe(
"Application protocol name (" + ap +
") exceeds the size limit (" +
@@ -212,7 +212,7 @@ public byte[] produce(ConnectionContext context,
if (listLength > MAX_AP_LIST_LENGTH) {
// log the configuration problem
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.severe(
"The configured application protocols (" +
Arrays.toString(laps) +
@@ -266,7 +266,7 @@ public void consume(ConnectionContext context,
if (!shc.sslConfig.isAvailable(SSLExtension.CH_ALPN)) {
shc.applicationProtocol = "";
shc.conContext.applicationProtocol = "";
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"Ignore server unavailable extension: " +
SSLExtension.CH_ALPN.name);
@@ -288,7 +288,7 @@ public void consume(ConnectionContext context,
if (noAPSelector && noAlpnProtocols) {
shc.applicationProtocol = "";
shc.conContext.applicationProtocol = "";
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore server unenabled extension: " +
SSLExtension.CH_ALPN.name);
@@ -378,7 +378,7 @@ public byte[] produce(ConnectionContext context,
(AlpnSpec)shc.handshakeExtensions.get(SSLExtension.CH_ALPN);
if (requestedAlps == null) {
// Ignore, this extension was not requested and accepted.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
SSLExtension.SH_ALPN.name);
@@ -423,7 +423,7 @@ public byte[] produce(ConnectionContext context,
// Ignore, no negotiated application layer protocol.
shc.applicationProtocol = "";
shc.conContext.applicationProtocol = "";
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore, no negotiated application layer protocol");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java b/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java
index 2125a148162..2d03d5fef98 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertSignAlgsExtension.java
@@ -94,7 +94,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(
SSLExtension.CH_SIGNATURE_ALGORITHMS_CERT)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"signature_algorithms_cert extension");
@@ -144,7 +144,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(
SSLExtension.CH_SIGNATURE_ALGORITHMS_CERT)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"signature_algorithms_cert extension");
@@ -235,7 +235,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(
SSLExtension.CH_SIGNATURE_ALGORITHMS_CERT)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"signature_algorithms_cert extension");
@@ -283,7 +283,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(
SSLExtension.CH_SIGNATURE_ALGORITHMS_CERT)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"signature_algorithms_cert extension");
diff --git a/src/java.base/share/classes/sun/security/ssl/CertStatusExtension.java b/src/java.base/share/classes/sun/security/ssl/CertStatusExtension.java
index 49713b6db11..d6c1cec5735 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertStatusExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertStatusExtension.java
@@ -144,7 +144,7 @@ private CertStatusRequestSpec(HandshakeContext hc,
if (statusType == CertStatusRequestType.OCSP.id) {
this.statusRequest = new OCSPStatusRequest(statusType, encoded);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"Unknown certificate status request " +
"(status type: " + statusType + ")");
@@ -196,7 +196,7 @@ private CertStatusResponseSpec(HandshakeContext hc,
if (type == CertStatusRequestType.OCSP.id) {
this.statusResponse = new OCSPStatusResponse(type, respData);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"Unknown certificate status response " +
"(status type: " + type + ")");
@@ -557,7 +557,7 @@ public byte[] produce(ConnectionContext context,
}
if (!chc.sslConfig.isAvailable(SSLExtension.CH_STATUS_REQUEST)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
SSLExtension.CH_STATUS_REQUEST.name);
@@ -598,7 +598,7 @@ public void consume(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
if (!shc.sslConfig.isAvailable(SSLExtension.CH_STATUS_REQUEST)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Ignore unavailable extension: " +
SSLExtension.CH_STATUS_REQUEST.name);
}
@@ -656,7 +656,7 @@ public byte[] produce(ConnectionContext context,
shc.handshakeExtensions.get(SSLExtension.CH_STATUS_REQUEST);
if (spec == null) {
// Ignore, no status_request extension requested.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Ignore unavailable extension: " +
SSLExtension.CH_STATUS_REQUEST.name);
}
@@ -666,7 +666,7 @@ public byte[] produce(ConnectionContext context,
// Is it a session resuming?
if (shc.isResumption) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"No status_request response for session resuming");
}
@@ -839,7 +839,7 @@ private CertStatusRequestV2Spec(HandshakeContext hc,
statusRequests.add(
new OCSPStatusRequest(statusType, encoded));
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"Unknown certificate status request " +
"(status type: " + statusType + ")");
@@ -915,7 +915,7 @@ public byte[] produce(ConnectionContext context,
}
if (!chc.sslConfig.isAvailable(SSLExtension.CH_STATUS_REQUEST_V2)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable status_request_v2 extension");
}
@@ -957,7 +957,7 @@ public void consume(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
if (!shc.sslConfig.isAvailable(SSLExtension.CH_STATUS_REQUEST_V2)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable status_request_v2 extension");
}
@@ -1017,7 +1017,7 @@ public byte[] produce(ConnectionContext context,
shc.handshakeExtensions.get(SSLExtension.CH_STATUS_REQUEST_V2);
if (spec == null) {
// Ignore, no status_request_v2 extension requested.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable status_request_v2 extension");
}
@@ -1027,7 +1027,7 @@ public byte[] produce(ConnectionContext context,
// Is it a session resuming?
if (shc.isResumption) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"No status_request_v2 response for session resumption");
}
@@ -1112,7 +1112,7 @@ public byte[] produce(ConnectionContext context,
// Stapling needs to be active and have valid data to proceed
if (shc.stapleParams == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Stapling is disabled for this connection");
}
@@ -1121,7 +1121,7 @@ public byte[] produce(ConnectionContext context,
// There needs to be a non-null CertificateEntry to proceed
if (shc.currentCertEntry == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Found null CertificateEntry in context");
}
return null;
@@ -1139,7 +1139,7 @@ public byte[] produce(ConnectionContext context,
byte[] respBytes = shc.stapleParams.responseMap.get(x509Cert);
if (respBytes == null) {
// We're done with this entry. Clear it from the context
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("No status response found for " +
x509Cert.getSubjectX500Principal());
@@ -1149,7 +1149,7 @@ public byte[] produce(ConnectionContext context,
}
// Build a proper response buffer from the stapling information
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("Found status response for " +
x509Cert.getSubjectX500Principal() +
", response length: " + respBytes.length);
@@ -1208,7 +1208,7 @@ public void consume(ConnectionContext context,
respList.add(spec.statusResponse.encodedResponse);
chc.handshakeSession.setStatusResponses(respList);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignoring stapled data on resumed session");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateAuthoritiesExtension.java b/src/java.base/share/classes/sun/security/ssl/CertificateAuthoritiesExtension.java
index 43bac16f0ea..cc513eb30ba 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateAuthoritiesExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateAuthoritiesExtension.java
@@ -192,7 +192,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(
SSLExtension.CH_CERTIFICATE_AUTHORITIES)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"certificate_authorities extension");
@@ -205,7 +205,7 @@ public byte[] produce(ConnectionContext context,
X509Certificate[] caCerts =
chc.sslContext.getX509TrustManager().getAcceptedIssuers();
if (caCerts.length == 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No available certificate authorities");
}
@@ -216,7 +216,7 @@ public byte[] produce(ConnectionContext context,
List encodedCAs =
CertificateAuthoritiesSpec.getEncodedAuthorities(caCerts);
if (encodedCAs.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"The number of CAs exceeds the maximum size " +
"of the certificate_authorities extension");
@@ -270,7 +270,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(
SSLExtension.CH_CERTIFICATE_AUTHORITIES)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"certificate_authorities extension");
@@ -319,7 +319,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(
SSLExtension.CR_CERTIFICATE_AUTHORITIES)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"certificate_authorities extension");
@@ -332,7 +332,7 @@ public byte[] produce(ConnectionContext context,
X509Certificate[] caCerts =
shc.sslContext.getX509TrustManager().getAcceptedIssuers();
if (caCerts.length == 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No available certificate authorities");
}
@@ -343,7 +343,7 @@ public byte[] produce(ConnectionContext context,
List encodedCAs =
CertificateAuthoritiesSpec.getEncodedAuthorities(caCerts);
if (encodedCAs.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Too many certificate authorities to use " +
"the certificate_authorities extension");
@@ -397,7 +397,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(
SSLExtension.CR_CERTIFICATE_AUTHORITIES)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable " +
"certificate_authorities extension");
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java
index d4587d35ae9..2a2db34cab9 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java
@@ -265,7 +265,7 @@ private byte[] onProduceCertificate(ServerHandshakeContext shc,
shc.handshakeSession.setLocalCertificates(x509Possession.popCerts);
T12CertificateMessage cm =
new T12CertificateMessage(shc, x509Possession.popCerts);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced server Certificate handshake message", cm);
}
@@ -293,7 +293,7 @@ private byte[] onProduceCertificate(ClientHandshakeContext chc,
// an empty cert chain instead.
if (x509Possession == null) {
if (chc.negotiatedProtocol.useTLS10PlusSpec()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 certificate for client authentication, " +
"use empty Certificate message instead");
@@ -302,7 +302,7 @@ private byte[] onProduceCertificate(ClientHandshakeContext chc,
x509Possession =
new X509Possession(null, new X509Certificate[0]);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 certificate for client authentication, " +
"send a no_certificate alert");
@@ -324,7 +324,7 @@ private byte[] onProduceCertificate(ClientHandshakeContext chc,
}
T12CertificateMessage cm =
new T12CertificateMessage(chc, x509Possession.popCerts);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced client Certificate handshake message", cm);
}
@@ -360,13 +360,13 @@ public void consume(ConnectionContext context,
T12CertificateMessage cm = new T12CertificateMessage(hc, message);
if (hc.sslConfig.isClientMode) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming server Certificate handshake message", cm);
}
onCertificate((ClientHandshakeContext)context, cm);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming client Certificate handshake message", cm);
}
@@ -501,7 +501,7 @@ private static boolean isIdentityEquivalent(X509Certificate thisCert,
try {
thisSubjectAltNames = thisCert.getSubjectAlternativeNames();
} catch (CertificateParsingException cpe) {
- if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("handshake")) {
SSLLogger.fine(
"Attempt to obtain subjectAltNames extension failed!");
}
@@ -511,7 +511,7 @@ private static boolean isIdentityEquivalent(X509Certificate thisCert,
try {
prevSubjectAltNames = prevCert.getSubjectAlternativeNames();
} catch (CertificateParsingException cpe) {
- if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("handshake")) {
SSLLogger.fine(
"Attempt to obtain subjectAltNames extension failed!");
}
@@ -980,7 +980,7 @@ private byte[] onProduceCertificate(ServerHandshakeContext shc,
certEnt.extensions.produce(shc, enabledCTExts);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced server Certificate message", cm);
}
@@ -997,7 +997,7 @@ private static SSLPossession choosePossession(
ClientHelloMessage clientHello) {
if (hc.peerRequestedCertSignSchemes == null ||
hc.peerRequestedCertSignSchemes.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No signature_algorithms(_cert) in ClientHello");
}
@@ -1021,7 +1021,7 @@ private static SSLPossession choosePossession(
SSLPossession pos = X509Authentication
.createPossession(hc, supportedKeyTypes);
if (pos == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("No available authentication scheme");
}
}
@@ -1034,14 +1034,14 @@ private byte[] onProduceCertificate(ClientHandshakeContext chc,
SSLPossession pos = choosePossession(chc, clientHello);
X509Certificate[] localCerts;
if (pos == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No available client authentication scheme");
}
localCerts = new X509Certificate[0];
} else {
chc.handshakePossessions.add(pos);
if (!(pos instanceof X509Possession x509Possession)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 certificate for client authentication");
}
@@ -1067,7 +1067,7 @@ private byte[] onProduceCertificate(ClientHandshakeContext chc,
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
"Failed to produce client Certificate message", ce);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced client Certificate message", cm);
}
@@ -1108,13 +1108,13 @@ public void consume(ConnectionContext context,
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
if (hc.sslConfig.isClientMode) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming server Certificate handshake message", cm);
}
onConsumeCertificate((ClientHandshakeContext)context, cm);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming client Certificate handshake message", cm);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java b/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java
index 66b8c048703..a297d9d21b2 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java
@@ -297,7 +297,7 @@ public byte[] produce(ConnectionContext context,
shc.sslContext.getX509TrustManager().getAcceptedIssuers();
T10CertificateRequestMessage crm = new T10CertificateRequestMessage(
shc, caCerts, shc.negotiatedCipherSuite.keyExchange);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced CertificateRequest handshake message", crm);
}
@@ -360,7 +360,7 @@ public void consume(ConnectionContext context,
T10CertificateRequestMessage crm =
new T10CertificateRequestMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateRequest handshake message", crm);
}
@@ -400,7 +400,7 @@ public void consume(ConnectionContext context,
}
if (clientAlias == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("No available client authentication");
}
return;
@@ -408,7 +408,7 @@ public void consume(ConnectionContext context,
PrivateKey clientPrivateKey = km.getPrivateKey(clientAlias);
if (clientPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("No available client private key");
}
return;
@@ -416,7 +416,7 @@ public void consume(ConnectionContext context,
X509Certificate[] clientCerts = km.getCertificateChain(clientAlias);
if ((clientCerts == null) || (clientCerts.length == 0)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("No available client certificate");
}
return;
@@ -655,7 +655,7 @@ public byte[] produce(ConnectionContext context,
T12CertificateRequestMessage crm = new T12CertificateRequestMessage(
shc, caCerts, shc.negotiatedCipherSuite.keyExchange,
certReqSignAlgs);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced CertificateRequest handshake message", crm);
}
@@ -717,7 +717,7 @@ public void consume(ConnectionContext context,
T12CertificateRequestMessage crm =
new T12CertificateRequestMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateRequest handshake message", crm);
}
@@ -784,7 +784,7 @@ private static SSLPossession choosePossession(HandshakeContext hc,
T12CertificateRequestMessage crm) {
if (hc.peerRequestedCertSignSchemes == null ||
hc.peerRequestedCertSignSchemes.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("No signature and hash algorithms " +
"in CertificateRequest");
}
@@ -823,7 +823,7 @@ private static SSLPossession choosePossession(HandshakeContext hc,
SSLPossession pos = X509Authentication
.createPossession(hc, supportedKeyTypes);
if (pos == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("No available authentication scheme");
}
}
@@ -933,7 +933,7 @@ public byte[] produce(ConnectionContext context,
SSLExtension[] extTypes = shc.sslConfig.getEnabledExtensions(
SSLHandshake.CERTIFICATE_REQUEST, shc.negotiatedProtocol);
crm.extensions.produce(shc, extTypes);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced CertificateRequest message", crm);
}
@@ -985,7 +985,7 @@ public void consume(ConnectionContext context,
T13CertificateRequestMessage crm =
new T13CertificateRequestMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateRequest handshake message", crm);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateStatus.java b/src/java.base/share/classes/sun/security/ssl/CertificateStatus.java
index 11b2c5e587d..a1048e423d1 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateStatus.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateStatus.java
@@ -281,7 +281,7 @@ public void consume(ConnectionContext context,
new CertificateStatusMessage(chc, message);
// Log the message
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming server CertificateStatus handshake message",
cst);
@@ -325,7 +325,7 @@ public byte[] produce(ConnectionContext context,
// Create the CertificateStatus message from info in the
CertificateStatusMessage csm = new CertificateStatusMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced server CertificateStatus handshake message", csm);
}
@@ -358,7 +358,7 @@ public void absent(ConnectionContext context,
// status_request[_v2] extension. 2) The CertificateStatus
// message was not sent. This means that cert path checking
// was deferred, but must happen immediately.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Server did not send CertificateStatus, " +
"checking cert chain without status info.");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java b/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java
index 09d07d8e62d..18ea2b9c3de 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java
@@ -248,7 +248,7 @@ public byte[] produce(ConnectionContext context,
if (x509Possession == null ||
x509Possession.popPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 credentials negotiated for CertificateVerify");
}
@@ -258,7 +258,7 @@ public byte[] produce(ConnectionContext context,
S30CertificateVerifyMessage cvm =
new S30CertificateVerifyMessage(chc, x509Possession);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced CertificateVerify handshake message", cvm);
}
@@ -300,7 +300,7 @@ public void consume(ConnectionContext context,
S30CertificateVerifyMessage cvm =
new S30CertificateVerifyMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateVerify handshake message", cvm);
}
@@ -503,7 +503,7 @@ public byte[] produce(ConnectionContext context,
if (x509Possession == null ||
x509Possession.popPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 credentials negotiated for CertificateVerify");
}
@@ -513,7 +513,7 @@ public byte[] produce(ConnectionContext context,
T10CertificateVerifyMessage cvm =
new T10CertificateVerifyMessage(chc, x509Possession);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced CertificateVerify handshake message", cvm);
}
@@ -555,7 +555,7 @@ public void consume(ConnectionContext context,
T10CertificateVerifyMessage cvm =
new T10CertificateVerifyMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateVerify handshake message", cvm);
}
@@ -754,7 +754,7 @@ public byte[] produce(ConnectionContext context,
if (x509Possession == null ||
x509Possession.popPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 credentials negotiated for CertificateVerify");
}
@@ -764,7 +764,7 @@ public byte[] produce(ConnectionContext context,
T12CertificateVerifyMessage cvm =
new T12CertificateVerifyMessage(chc, x509Possession);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced CertificateVerify handshake message", cvm);
}
@@ -806,7 +806,7 @@ public void consume(ConnectionContext context,
T12CertificateVerifyMessage cvm =
new T12CertificateVerifyMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateVerify handshake message", cvm);
}
@@ -1092,7 +1092,7 @@ public byte[] produce(ConnectionContext context,
if (x509Possession == null ||
x509Possession.popPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No X.509 credentials negotiated for CertificateVerify");
}
@@ -1113,7 +1113,7 @@ private byte[] onProduceCertificateVerify(ServerHandshakeContext shc,
X509Possession x509Possession) throws IOException {
T13CertificateVerifyMessage cvm =
new T13CertificateVerifyMessage(shc, x509Possession);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced server CertificateVerify handshake message", cvm);
}
@@ -1130,7 +1130,7 @@ private byte[] onProduceCertificateVerify(ClientHandshakeContext chc,
X509Possession x509Possession) throws IOException {
T13CertificateVerifyMessage cvm =
new T13CertificateVerifyMessage(chc, x509Possession);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced client CertificateVerify handshake message", cvm);
}
@@ -1173,7 +1173,7 @@ public void consume(ConnectionContext context,
T13CertificateVerifyMessage cvm =
new T13CertificateVerifyMessage(hc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming CertificateVerify handshake message", cvm);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ChangeCipherSpec.java b/src/java.base/share/classes/sun/security/ssl/ChangeCipherSpec.java
index 4ea61161c1d..d3eac8f13af 100644
--- a/src/java.base/share/classes/sun/security/ssl/ChangeCipherSpec.java
+++ b/src/java.base/share/classes/sun/security/ssl/ChangeCipherSpec.java
@@ -108,7 +108,7 @@ public byte[] produce(ConnectionContext context,
") and protocol version (" + hc.negotiatedProtocol + ")");
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced ChangeCipherSpec message");
}
@@ -142,7 +142,7 @@ public void consume(ConnectionContext context,
throw tc.fatal(Alert.UNEXPECTED_MESSAGE,
"Malformed or unexpected ChangeCipherSpec message");
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Consuming ChangeCipherSpec message");
}
@@ -237,7 +237,7 @@ public void consume(ConnectionContext context,
throw tc.fatal(Alert.UNEXPECTED_MESSAGE,
"Malformed or unexpected ChangeCipherSpec message");
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Consuming ChangeCipherSpec message");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ClientHello.java b/src/java.base/share/classes/sun/security/ssl/ClientHello.java
index c9432ea3979..421673d625d 100644
--- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java
+++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java
@@ -430,7 +430,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
if (!session.isRejoinable()) {
session = null;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, the session is not rejoinable");
@@ -443,7 +443,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
sessionSuite = session.getSuite();
if (!chc.isNegotiable(sessionSuite)) {
session = null;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, unavailable session cipher suite");
@@ -456,7 +456,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
sessionVersion = session.getProtocolVersion();
if (!chc.isNegotiable(sessionVersion)) {
session = null;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, unavailable protocol version");
@@ -513,7 +513,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
String sessionIdentityAlg =
session.getIdentificationProtocol();
if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("Can't resume, endpoint id" +
" algorithm does not match, requested: " +
@@ -524,7 +524,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
}
if (session != null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("Try resuming session", session);
}
@@ -547,7 +547,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
cipherSuites = List.of(sessionSuite);
}
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"No new session is allowed, so try to resume " +
@@ -634,7 +634,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
SSLHandshake.CLIENT_HELLO, chc.activeProtocols);
chm.extensions.produce(chc, extTypes);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced ClientHello handshake message", chm);
}
@@ -700,7 +700,7 @@ public byte[] produce(ConnectionContext context,
//
// The HelloVerifyRequest consumer should have updated the
// ClientHello handshake message with cookie.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced ClientHello(cookie) handshake message",
chc.initialClientHelloMsg);
@@ -734,7 +734,7 @@ public byte[] produce(ConnectionContext context,
// TLS 1.3
// The HelloRetryRequest consumer should have updated the
// ClientHello handshake message with cookie.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced ClientHello(HRR) handshake message",
chc.initialClientHelloMsg);
@@ -790,7 +790,7 @@ public void consume(ConnectionContext context,
ClientHelloMessage chm =
new ClientHelloMessage(shc, message, enabledExtensions);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Consuming ClientHello handshake message", chm);
}
@@ -820,7 +820,7 @@ private void onClientHello(ServerHandshakeContext context,
negotiateProtocol(context, clientHello.clientVersion);
}
context.negotiatedProtocol = negotiatedProtocol;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Negotiated protocol version: " + negotiatedProtocol.name);
}
@@ -980,7 +980,7 @@ public void consume(ConnectionContext context,
boolean resumingSession =
(previous != null) && previous.isRejoinable();
if (!resumingSession) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
@@ -993,7 +993,7 @@ public void consume(ConnectionContext context,
previous.getProtocolVersion();
if (sessionProtocol != shc.negotiatedProtocol) {
resumingSession = false;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, not the same protocol version");
@@ -1008,7 +1008,7 @@ public void consume(ConnectionContext context,
previous.getPeerPrincipal();
} catch (SSLPeerUnverifiedException e) {
resumingSession = false;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
@@ -1023,7 +1023,7 @@ public void consume(ConnectionContext context,
if ((!shc.isNegotiable(suite)) ||
(!clientHello.cipherSuites.contains(suite))) {
resumingSession = false;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
@@ -1039,7 +1039,7 @@ public void consume(ConnectionContext context,
String sessionIdentityAlg =
previous.getIdentificationProtocol();
if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("Can't resume, endpoint id" +
" algorithm does not match, requested: " +
@@ -1054,7 +1054,7 @@ public void consume(ConnectionContext context,
shc.isResumption = resumingSession;
shc.resumingSession = resumingSession ? previous : null;
- if (!resumingSession && SSLLogger.isOn &&
+ if (!resumingSession && SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Session not resumed.");
}
@@ -1321,7 +1321,7 @@ public void consume(ConnectionContext context,
boolean resumingSession =
(previous != null) && previous.isRejoinable();
if (!resumingSession) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
@@ -1334,7 +1334,7 @@ public void consume(ConnectionContext context,
previous.getProtocolVersion();
if (sessionProtocol != shc.negotiatedProtocol) {
resumingSession = false;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, not the same protocol version");
@@ -1350,7 +1350,7 @@ public void consume(ConnectionContext context,
previous.getPeerPrincipal();
} catch (SSLPeerUnverifiedException e) {
resumingSession = false;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
@@ -1365,7 +1365,7 @@ public void consume(ConnectionContext context,
if ((!shc.isNegotiable(suite)) ||
(!clientHello.cipherSuites.contains(suite))) {
resumingSession = false;
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
diff --git a/src/java.base/share/classes/sun/security/ssl/CookieExtension.java b/src/java.base/share/classes/sun/security/ssl/CookieExtension.java
index d54a1a3e63d..2c22dd121ba 100644
--- a/src/java.base/share/classes/sun/security/ssl/CookieExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/CookieExtension.java
@@ -117,7 +117,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(SSLExtension.CH_COOKIE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable cookie extension");
}
@@ -154,7 +154,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SSLExtension.CH_COOKIE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable cookie extension");
}
@@ -218,7 +218,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SSLExtension.HRR_COOKIE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable cookie extension");
}
@@ -253,7 +253,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(SSLExtension.HRR_COOKIE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable cookie extension");
}
@@ -280,7 +280,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SSLExtension.HRR_COOKIE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable cookie extension");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java
index fb5d6feef55..53f9896a3e4 100644
--- a/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/DHClientKeyExchange.java
@@ -187,7 +187,7 @@ public byte[] produce(ConnectionContext context,
chc.handshakePossessions.add(dhePossession);
DHClientKeyExchangeMessage ckem =
new DHClientKeyExchangeMessage(chc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced DH ClientKeyExchange handshake message", ckem);
}
@@ -268,7 +268,7 @@ public void consume(ConnectionContext context,
DHClientKeyExchangeMessage ckem =
new DHClientKeyExchangeMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming DH ClientKeyExchange handshake message", ckem);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java
index 2df62d50fb8..744ff59f402 100644
--- a/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java
@@ -481,7 +481,7 @@ public byte[] produce(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
DHServerKeyExchangeMessage skem =
new DHServerKeyExchangeMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced DH ServerKeyExchange handshake message", skem);
}
@@ -512,7 +512,7 @@ public void consume(ConnectionContext context,
DHServerKeyExchangeMessage skem =
new DHServerKeyExchangeMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming DH ServerKeyExchange handshake message", skem);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java b/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java
index 4e82fd25a7b..e880f36e846 100644
--- a/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java
@@ -125,7 +125,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
return null;
}
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw read", packet);
}
@@ -150,7 +150,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
int contentLen = ((packet.get() & 0xFF) << 8) |
(packet.get() & 0xFF); // pos: 11, 12
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine("READ: " +
ProtocolVersion.nameOf(majorVersion, minorVersion) +
" " + ContentType.nameOf(contentType) + ", length = " +
@@ -162,7 +162,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
if (this.readEpoch > recordEpoch) {
// Reset the position of the packet buffer.
packet.position(recLim);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine("READ: discard this old record", recordEnS);
}
return null;
@@ -181,7 +181,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
packet.position(recLim);
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Premature record (epoch), discard it.");
}
@@ -223,7 +223,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
plaintextFragment = plaintext.fragment;
contentType = plaintext.contentType;
} catch (GeneralSecurityException gse) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Discard invalid record: " + gse);
}
@@ -241,7 +241,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
// Cleanup the handshake reassembler if necessary.
if ((reassembler != null) &&
(reassembler.handshakeEpoch < recordEpoch)) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Cleanup the handshake reassembler");
}
@@ -273,7 +273,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
if (hsFrag == null) {
// invalid, discard this record
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Invalid handshake message, discard it.");
}
@@ -296,7 +296,7 @@ Plaintext[] decode(ByteBuffer packet) throws SSLProtocolException {
return pt == null ? null : new Plaintext[] { pt };
}
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("The reassembler is not initialized yet.");
}
@@ -356,7 +356,7 @@ private static HandshakeFragment parseHandshakeMessage(
int remaining = plaintextFragment.remaining();
if (remaining < handshakeHeaderSize) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Discard invalid record: " +
"too small record to hold a handshake fragment");
}
@@ -368,7 +368,7 @@ private static HandshakeFragment parseHandshakeMessage(
// Fail fast for unknown handshake message.
byte handshakeType = plaintextFragment.get(); // pos: 0
if (!SSLHandshake.isKnown(handshakeType)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Discard invalid record: " +
"unknown handshake type size, Handshake.msg_type = " +
(handshakeType & 0xFF));
@@ -404,7 +404,7 @@ private static HandshakeFragment parseHandshakeMessage(
((plaintextFragment.get() & 0xFF) << 8) |
(plaintextFragment.get() & 0xFF); // pos: 9-11
if ((remaining - handshakeHeaderSize) < fragmentLength) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Discard invalid record: " +
"not a complete handshake fragment in the record");
}
@@ -748,7 +748,7 @@ void queueUpHandshake(HandshakeFragment hsf) throws SSLProtocolException {
// It's OK to discard retransmission as the handshake hash
// is computed as if each handshake message had been sent
// as a single fragment.
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Have got the full message, discard it.");
}
@@ -769,7 +769,7 @@ void queueUpHandshake(HandshakeFragment hsf) throws SSLProtocolException {
// The ranges SHOULD NOT overlap.
if (hole.offset > hsf.fragmentOffset || hole.limit < fragmentLimit) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Discard invalid record: " +
"handshake fragment ranges are overlapping");
}
@@ -837,7 +837,7 @@ private HandshakeFragment valHello(HandshakeFragment hsf,
}
// Read the random (32 bytes)
if (fragmentData.remaining() < 32) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Rejected client hello fragment (bad random len) " +
"fo=" + hsf.fragmentOffset + " fl=" + hsf.fragmentLength);
}
@@ -861,7 +861,7 @@ private HandshakeFragment valHello(HandshakeFragment hsf,
// Cookie
byte[] cookie = Record.getBytes8(fragmentData);
if (firstHello && cookie.length != 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Rejected initial client hello fragment (bad cookie len) " +
"fo=" + hsf.fragmentOffset + " fl=" + hsf.fragmentLength);
}
@@ -897,7 +897,7 @@ private HandshakeFragment valHello(HandshakeFragment hsf,
}
}
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Rejected client hello fragment " +
"fo=" + hsf.fragmentOffset + " fl=" + hsf.fragmentLength);
}
@@ -1029,7 +1029,7 @@ private boolean isDesirable(RecordFragment rf) throws SSLProtocolException {
int previousEpoch = nextRecordEpoch - 1;
if (rf.recordEpoch < previousEpoch) {
// Too old to use, discard this record.
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Too old epoch to use this record, discard it.");
}
@@ -1075,7 +1075,7 @@ private boolean isDesirable(RecordFragment rf) throws SSLProtocolException {
if (!isDesired) {
// Too old to use, discard this retransmitted record
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Too old retransmission to use, discard it.");
}
@@ -1088,7 +1088,7 @@ private boolean isDesirable(RecordFragment rf) throws SSLProtocolException {
// Previously disordered record for the current epoch.
//
// Should have been retransmitted. Discard this record.
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Lagging behind record (sequence), discard it.");
}
@@ -1126,7 +1126,7 @@ private boolean isEmpty() {
Plaintext acquirePlaintext() throws SSLProtocolException {
if (bufferedFragments.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("No received handshake messages");
}
return null;
@@ -1147,7 +1147,7 @@ Plaintext acquirePlaintext() throws SSLProtocolException {
// Reset the next handshake flight.
resetHandshakeFlight(precedingFlight);
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Received a retransmission flight.");
}
@@ -1159,7 +1159,7 @@ Plaintext acquirePlaintext() throws SSLProtocolException {
}
if (!flightIsReady) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"The handshake flight is not ready to use: " +
handshakeFlight.handshakeType);
@@ -1244,7 +1244,7 @@ private Plaintext acquireCachedMessage() throws SSLProtocolException {
if (readEpoch != rFrag.recordEpoch) {
if (readEpoch > rFrag.recordEpoch) {
// discard old records
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Discard old buffered ciphertext fragments.");
}
@@ -1256,7 +1256,7 @@ private Plaintext acquireCachedMessage() throws SSLProtocolException {
flightIsReady = false;
}
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Not yet ready to decrypt the cached fragments.");
}
@@ -1273,7 +1273,7 @@ private Plaintext acquireCachedMessage() throws SSLProtocolException {
plaintextFragment = plaintext.fragment;
rFrag.contentType = plaintext.contentType;
} catch (GeneralSecurityException gse) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Discard invalid record: ", gse);
}
@@ -1295,7 +1295,7 @@ private Plaintext acquireCachedMessage() throws SSLProtocolException {
if (hsFrag == null) {
// invalid, discard this record
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Invalid handshake fragment, discard it",
plaintextFragment);
@@ -1446,7 +1446,7 @@ boolean flightIsReady() {
if (expectCCSFlight) {
// Have the ChangeCipherSpec/Finished flight been received?
boolean isReady = hasFinishedMessage();
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Has the final flight been received? " + isReady);
}
@@ -1454,7 +1454,7 @@ boolean flightIsReady() {
return isReady;
}
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("No flight is received yet.");
}
@@ -1467,7 +1467,7 @@ boolean flightIsReady() {
// single handshake message flight
boolean isReady = hasCompleted(flightType);
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Is the handshake message completed? " + isReady);
}
@@ -1481,7 +1481,7 @@ boolean flightIsReady() {
if (flightType == SSLHandshake.SERVER_HELLO.id) {
// Firstly, check the first flight handshake message.
if (!hasCompleted(flightType)) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"The ServerHello message is not completed yet.");
}
@@ -1493,7 +1493,7 @@ boolean flightIsReady() {
// an abbreviated handshake
//
if (hasFinishedMessage()) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("It's an abbreviated handshake.");
}
@@ -1507,7 +1507,7 @@ boolean flightIsReady() {
SSLHandshake.SERVER_HELLO_DONE.id);
if ((holes == null) || !holes.isEmpty()) {
// Not yet got the final message of the flight.
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Not yet got the ServerHelloDone message");
}
@@ -1519,7 +1519,7 @@ boolean flightIsReady() {
boolean isReady = hasCompleted(bufferedFragments,
handshakeFlight.minMessageSeq,
handshakeFlight.maxMessageSeq);
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Is the ServerHello flight (message " +
handshakeFlight.minMessageSeq + "-" +
@@ -1542,7 +1542,7 @@ boolean flightIsReady() {
// Firstly, check the first flight handshake message.
if (!hasCompleted(flightType)) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"The ClientKeyExchange or client Certificate " +
"message is not completed yet.");
@@ -1556,7 +1556,7 @@ boolean flightIsReady() {
if (needClientVerify(bufferedFragments) &&
!hasCompleted(SSLHandshake.CERTIFICATE_VERIFY.id)) {
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Not yet have the CertificateVerify message");
}
@@ -1567,7 +1567,7 @@ boolean flightIsReady() {
if (!hasFinishedMessage()) {
// not yet have the ChangeCipherSpec/Finished messages
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Not yet have the ChangeCipherSpec and " +
"Finished messages");
@@ -1580,7 +1580,7 @@ boolean flightIsReady() {
boolean isReady = hasCompleted(bufferedFragments,
handshakeFlight.minMessageSeq,
handshakeFlight.maxMessageSeq);
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Is the ClientKeyExchange flight (message " +
handshakeFlight.minMessageSeq + "-" +
@@ -1594,7 +1594,7 @@ boolean flightIsReady() {
//
// Otherwise, need to receive more handshake messages.
//
- if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Need to receive more handshake messages");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java b/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java
index 691ac32c26b..162dbb58eec 100644
--- a/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java
@@ -92,7 +92,7 @@ void finishHandshake() {
void changeWriteCiphers(SSLWriteCipher writeCipher,
boolean useChangeCipherSpec) {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"change_cipher_spec message");
}
@@ -120,7 +120,7 @@ void changeWriteCiphers(SSLWriteCipher writeCipher,
@Override
void encodeAlert(byte level, byte description) {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"alert message: " + Alert.nameOf(description));
}
@@ -137,7 +137,7 @@ void encodeAlert(byte level, byte description) {
@Override
void encodeChangeCipherSpec() {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"change_cipher_spec message");
}
@@ -154,7 +154,7 @@ void encodeChangeCipherSpec() {
void encodeHandshake(byte[] source,
int offset, int length) {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"handshake message",
ByteBuffer.wrap(source, offset, length));
@@ -179,14 +179,14 @@ Ciphertext encode(
ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws IOException {
if (isClosed) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"application data or cached messages");
}
return null;
} else if (isCloseWaiting) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"application data");
}
@@ -201,7 +201,7 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length,
ByteBuffer destination) throws IOException {
if (writeCipher.authenticator.seqNumOverflow()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
"sequence number extremely close to overflow " +
"(2^64-1 packets). Closing connection.");
@@ -269,7 +269,7 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length,
destination.limit(destination.position());
destination.position(dstContent);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name + " " +
ContentType.APPLICATION_DATA.name +
@@ -282,7 +282,7 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length,
dstPos, dstLim, headerSize,
protocolVersion);
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
ByteBuffer temporary = destination.duplicate();
temporary.limit(temporary.position());
temporary.position(dstPos);
@@ -497,7 +497,7 @@ Ciphertext acquireCiphertext(ByteBuffer dstBuf) throws IOException {
dstBuf.limit(dstBuf.position());
dstBuf.position(dstContent);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name + " " +
ContentType.nameOf(memo.contentType) +
@@ -511,7 +511,7 @@ Ciphertext acquireCiphertext(ByteBuffer dstBuf) throws IOException {
ProtocolVersion.valueOf(memo.majorVersion,
memo.minorVersion));
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
ByteBuffer temporary = dstBuf.duplicate();
temporary.limit(temporary.position());
temporary.position(dstPos);
diff --git a/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java
index e1c1b1377ad..a626f6f34d0 100644
--- a/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java
@@ -199,7 +199,7 @@ public byte[] produce(ConnectionContext context,
ECDHClientKeyExchangeMessage cke =
new ECDHClientKeyExchangeMessage(
chc, sslPossession.encode());
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced ECDH ClientKeyExchange handshake message", cke);
}
@@ -308,7 +308,7 @@ public void consume(ConnectionContext context,
// parse either handshake message containing either EC/XEC.
ECDHClientKeyExchangeMessage cke =
new ECDHClientKeyExchangeMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming ECDH ClientKeyExchange handshake message", cke);
}
@@ -397,7 +397,7 @@ public byte[] produce(ConnectionContext context,
new ECDHClientKeyExchangeMessage(
chc, sslPossession.encode());
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced ECDHE ClientKeyExchange handshake message", cke);
}
@@ -490,7 +490,7 @@ public void consume(ConnectionContext context,
// parse the EC/XEC handshake message
ECDHClientKeyExchangeMessage cke =
new ECDHClientKeyExchangeMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming ECDHE ClientKeyExchange handshake message", cke);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java
index b31c0ba9cb9..a02a8438163 100644
--- a/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java
@@ -489,7 +489,7 @@ public byte[] produce(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
ECDHServerKeyExchangeMessage skem =
new ECDHServerKeyExchangeMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced ECDH ServerKeyExchange handshake message", skem);
}
@@ -522,7 +522,7 @@ public void consume(ConnectionContext context,
// AlgorithmConstraints are checked during decoding
ECDHServerKeyExchangeMessage skem =
new ECDHServerKeyExchangeMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming ECDH ServerKeyExchange handshake message", skem);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ECPointFormatsExtension.java b/src/java.base/share/classes/sun/security/ssl/ECPointFormatsExtension.java
index 580e1d416de..72b7c950374 100644
--- a/src/java.base/share/classes/sun/security/ssl/ECPointFormatsExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/ECPointFormatsExtension.java
@@ -171,7 +171,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(CH_EC_POINT_FORMATS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable ec_point_formats extension");
}
@@ -193,7 +193,7 @@ public byte[] produce(ConnectionContext context,
return extData;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Need no ec_point_formats extension");
}
@@ -221,7 +221,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(CH_EC_POINT_FORMATS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable ec_point_formats extension");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/EncryptedExtensions.java b/src/java.base/share/classes/sun/security/ssl/EncryptedExtensions.java
index d1975b5caa4..b5be927f0aa 100644
--- a/src/java.base/share/classes/sun/security/ssl/EncryptedExtensions.java
+++ b/src/java.base/share/classes/sun/security/ssl/EncryptedExtensions.java
@@ -134,7 +134,7 @@ public byte[] produce(ConnectionContext context,
SSLHandshake.ENCRYPTED_EXTENSIONS,
shc.negotiatedProtocol);
eem.extensions.produce(shc, extTypes);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced EncryptedExtensions message", eem);
}
@@ -168,7 +168,7 @@ public void consume(ConnectionContext context,
EncryptedExtensionsMessage eem =
new EncryptedExtensionsMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming EncryptedExtensions handshake message", eem);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ExtendedMasterSecretExtension.java b/src/java.base/share/classes/sun/security/ssl/ExtendedMasterSecretExtension.java
index ff4694c8c7c..6bacbfbd1d8 100644
--- a/src/java.base/share/classes/sun/security/ssl/ExtendedMasterSecretExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/ExtendedMasterSecretExtension.java
@@ -119,7 +119,7 @@ public byte[] produce(ConnectionContext context,
if (!chc.sslConfig.isAvailable(CH_EXTENDED_MASTER_SECRET) ||
!SSLConfiguration.useExtendedMasterSecret ||
!chc.conContext.protocolVersion.useTLS10PlusSpec()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extended_master_secret extension");
}
@@ -162,7 +162,7 @@ public void consume(ConnectionContext context,
if (!shc.sslConfig.isAvailable(CH_EXTENDED_MASTER_SECRET) ||
!SSLConfiguration.useExtendedMasterSecret ||
!shc.negotiatedProtocol.useTLS10PlusSpec()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Ignore unavailable extension: " +
CH_EXTENDED_MASTER_SECRET.name);
}
@@ -182,7 +182,7 @@ public void consume(ConnectionContext context,
// with a full handshake.
shc.isResumption = false;
shc.resumingSession = null;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"abort session resumption which did not use " +
"Extended Master Secret extension");
@@ -213,7 +213,7 @@ public void absent(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(CH_EXTENDED_MASTER_SECRET) ||
!SSLConfiguration.useExtendedMasterSecret) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Ignore unavailable extension: " +
CH_EXTENDED_MASTER_SECRET.name);
}
@@ -252,7 +252,7 @@ public void absent(ConnectionContext context,
} else { // Otherwise, continue with a full handshake.
shc.isResumption = false;
shc.resumingSession = null;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"abort session resumption, " +
"missing Extended Master Secret extension");
diff --git a/src/java.base/share/classes/sun/security/ssl/Finished.java b/src/java.base/share/classes/sun/security/ssl/Finished.java
index 04fe61760d0..4238ced8f01 100644
--- a/src/java.base/share/classes/sun/security/ssl/Finished.java
+++ b/src/java.base/share/classes/sun/security/ssl/Finished.java
@@ -390,7 +390,7 @@ private byte[] onProduceFinished(ClientHandshakeContext chc,
// Change write cipher and delivery ChangeCipherSpec message.
ChangeCipherSpec.t10Producer.produce(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced client Finished handshake message", fm);
}
@@ -453,7 +453,7 @@ private byte[] onProduceFinished(ServerHandshakeContext shc,
// Change write cipher and delivery ChangeCipherSpec message.
ChangeCipherSpec.t10Producer.produce(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced server Finished handshake message", fm);
}
@@ -542,7 +542,7 @@ public void consume(ConnectionContext context,
private void onConsumeFinished(ClientHandshakeContext chc,
ByteBuffer message) throws IOException {
FinishedMessage fm = new FinishedMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming server Finished handshake message", fm);
}
@@ -602,7 +602,7 @@ private void onConsumeFinished(ServerHandshakeContext shc,
}
FinishedMessage fm = new FinishedMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming client Finished handshake message", fm);
}
@@ -681,7 +681,7 @@ private byte[] onProduceFinished(ClientHandshakeContext chc,
chc.handshakeHash.update();
FinishedMessage fm = new FinishedMessage(chc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced client Finished handshake message", fm);
}
@@ -778,7 +778,7 @@ private byte[] onProduceFinished(ServerHandshakeContext shc,
shc.handshakeHash.update();
FinishedMessage fm = new FinishedMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced server Finished handshake message", fm);
}
@@ -930,7 +930,7 @@ private void onConsumeFinished(ClientHandshakeContext chc,
}
FinishedMessage fm = new FinishedMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming server Finished handshake message", fm);
}
@@ -1073,7 +1073,7 @@ private void onConsumeFinished(ServerHandshakeContext shc,
}
FinishedMessage fm = new FinishedMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming client Finished handshake message", fm);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/HandshakeContext.java b/src/java.base/share/classes/sun/security/ssl/HandshakeContext.java
index 8455ddfc65d..a5f340d5203 100644
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeContext.java
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeContext.java
@@ -284,14 +284,14 @@ private static List getActiveProtocols(
found = true;
break;
}
- } else if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"Ignore unsupported cipher suite: " + suite +
" for " + protocol.name);
}
}
- if (!found && (SSLLogger.isOn) && SSLLogger.isOn("handshake")) {
+ if (!found && (SSLLogger.isOn()) && SSLLogger.isOn("handshake")) {
SSLLogger.fine(
"No available cipher suite for " + protocol.name);
}
@@ -335,7 +335,7 @@ private static List getActiveCipherSuites(
}
if (!isSupported &&
- SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.finest(
"Ignore unsupported cipher suite: " + suite);
}
@@ -556,7 +556,7 @@ private static boolean isActivatable(
cachedStatus.put(groupType, groupAvailable);
if (!groupAvailable &&
- SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine(
"No activated named group in " + groupType);
}
@@ -570,13 +570,13 @@ private static boolean isActivatable(
}
}
- if (!retval && SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ if (!retval && SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("No active named group(s), ignore " + suite);
}
return retval;
- } else if (SSLLogger.isOn && SSLLogger.isOn("verbose")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("verbose")) {
SSLLogger.fine("Ignore disabled cipher suite: " + suite);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java b/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
index 61936442502..2a05881180d 100644
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeOutStream.java
@@ -61,7 +61,7 @@ void complete() throws IOException {
if (!outputRecord.isClosed()) {
outputRecord.encodeHandshake(buf, 0, count);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"handshake messages", ByteBuffer.wrap(buf, 0, count));
}
diff --git a/src/java.base/share/classes/sun/security/ssl/HelloRequest.java b/src/java.base/share/classes/sun/security/ssl/HelloRequest.java
index f4da66b5dd3..39464992db5 100644
--- a/src/java.base/share/classes/sun/security/ssl/HelloRequest.java
+++ b/src/java.base/share/classes/sun/security/ssl/HelloRequest.java
@@ -101,7 +101,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
ServerHandshakeContext shc = (ServerHandshakeContext)context;
HelloRequestMessage hrm = new HelloRequestMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced HelloRequest handshake message", hrm);
}
@@ -137,7 +137,7 @@ public byte[] produce(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
HelloRequestMessage hrm = new HelloRequestMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced HelloRequest handshake message", hrm);
}
@@ -177,7 +177,7 @@ public void consume(ConnectionContext context,
// be sent by the server at any time. Please don't clean up this
// handshake consumer.
HelloRequestMessage hrm = new HelloRequestMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming HelloRequest handshake message", hrm);
}
@@ -190,7 +190,7 @@ public void consume(ConnectionContext context,
}
if (!chc.conContext.secureRenegotiation) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Continue with insecure renegotiation");
}
@@ -206,7 +206,7 @@ public void consume(ConnectionContext context,
//
SSLHandshake.CLIENT_HELLO.produce(context, hrm);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore HelloRequest, handshaking is in progress");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/HelloVerifyRequest.java b/src/java.base/share/classes/sun/security/ssl/HelloVerifyRequest.java
index f28ae16de88..8d3f1048c91 100644
--- a/src/java.base/share/classes/sun/security/ssl/HelloVerifyRequest.java
+++ b/src/java.base/share/classes/sun/security/ssl/HelloVerifyRequest.java
@@ -140,7 +140,7 @@ public byte[] produce(ConnectionContext context,
HelloVerifyRequestMessage hvrm =
new HelloVerifyRequestMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced HelloVerifyRequest handshake message", hvrm);
}
@@ -197,7 +197,7 @@ public void consume(ConnectionContext context,
HelloVerifyRequestMessage hvrm =
new HelloVerifyRequestMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming HelloVerifyRequest handshake message", hvrm);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/KeyShareExtension.java b/src/java.base/share/classes/sun/security/ssl/KeyShareExtension.java
index 98e4693e917..8d785f7515a 100644
--- a/src/java.base/share/classes/sun/security/ssl/KeyShareExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/KeyShareExtension.java
@@ -90,7 +90,7 @@ private byte[] getEncoded() {
Record.putInt16(m, namedGroupId);
Record.putBytes16(m, keyExchange);
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Unlikely IOException", ioe);
}
@@ -222,7 +222,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(SSLExtension.CH_KEY_SHARE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable key_share extension");
}
@@ -237,7 +237,7 @@ public byte[] produce(ConnectionContext context,
namedGroups = chc.clientRequestedNamedGroups;
if (namedGroups == null || namedGroups.isEmpty()) {
// No supported groups.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore key_share extension, no supported groups");
}
@@ -287,7 +287,7 @@ private static byte[] getShare(ClientHandshakeContext chc,
NamedGroup ng) {
SSLKeyExchange ke = SSLKeyExchange.valueOf(ng);
if (ke == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No key exchange for named group " + ng.name);
}
@@ -323,7 +323,7 @@ public void consume(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
if (shc.handshakeExtensions.containsKey(SSLExtension.CH_KEY_SHARE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"The key_share extension has been loaded");
}
@@ -332,7 +332,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SSLExtension.CH_KEY_SHARE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable key_share extension");
}
@@ -346,7 +346,7 @@ public void consume(ConnectionContext context,
NamedGroup ng = NamedGroup.valueOf(entry.namedGroupId);
if (ng == null || !NamedGroup.isActivatable(shc.sslConfig,
shc.algorithmConstraints, ng)) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unsupported named group: " +
@@ -364,7 +364,7 @@ public void consume(ConnectionContext context,
if (!shc.algorithmConstraints.permits(
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
namedGroupCredentials.getPublicKey())) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"key share entry of " + ng + " does not " +
@@ -379,7 +379,7 @@ public void consume(ConnectionContext context,
credentials.add(kaCred);
}
} catch (GeneralSecurityException ex) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Cannot decode named group: " +
NamedGroup.nameOf(entry.namedGroupId));
@@ -522,7 +522,7 @@ public byte[] produce(ConnectionContext context,
SSLExtension.CH_KEY_SHARE);
if (kss == null) {
// Unlikely, no key_share extension requested.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore, no client key_share extension");
}
@@ -531,7 +531,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SSLExtension.SH_KEY_SHARE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore, no available server key_share extension");
}
@@ -542,7 +542,7 @@ public byte[] produce(ConnectionContext context,
if ((shc.handshakeCredentials == null) ||
shc.handshakeCredentials.isEmpty()) {
// Unlikely, HelloRetryRequest should be used earlier.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No available client key share entries");
}
@@ -562,7 +562,7 @@ public byte[] produce(ConnectionContext context,
SSLKeyExchange ke = SSLKeyExchange.valueOf(ng);
if (ke == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No key exchange for named group " + ng.name);
}
@@ -597,7 +597,7 @@ public byte[] produce(ConnectionContext context,
if (keyShare == null) {
// Unlikely, HelloRetryRequest should be used instead earlier.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No available server key_share extension");
}
@@ -708,7 +708,7 @@ public void absent(ConnectionContext context,
ClientHandshakeContext chc = (ClientHandshakeContext)context;
// Cannot use the previous requested key shares anymore.
- if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("handshake")) {
SSLLogger.fine(
"No key_share extension in ServerHello, " +
"cleanup the key shares if necessary");
@@ -801,7 +801,7 @@ public byte[] produce(ConnectionContext context,
for (NamedGroup ng : shc.clientRequestedNamedGroups) {
if (NamedGroup.isActivatable(shc.sslConfig,
shc.algorithmConstraints, ng)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"HelloRetryRequest selected named group: " +
ng.name);
diff --git a/src/java.base/share/classes/sun/security/ssl/KeyUpdate.java b/src/java.base/share/classes/sun/security/ssl/KeyUpdate.java
index 2b17c7406a3..4e5a9683079 100644
--- a/src/java.base/share/classes/sun/security/ssl/KeyUpdate.java
+++ b/src/java.base/share/classes/sun/security/ssl/KeyUpdate.java
@@ -191,7 +191,7 @@ public void consume(ConnectionContext context,
// The consuming happens in client side only.
PostHandshakeContext hc = (PostHandshakeContext)context;
KeyUpdateMessage km = new KeyUpdateMessage(hc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming KeyUpdate post-handshake message", km);
}
@@ -235,7 +235,7 @@ public void consume(ConnectionContext context,
rc.baseSecret = nplus1;
hc.conContext.inputRecord.changeReadCiphers(rc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("KeyUpdate: read key updated");
}
} catch (GeneralSecurityException gse) {
@@ -276,7 +276,7 @@ public byte[] produce(ConnectionContext context,
return null;
}
KeyUpdateMessage km = (KeyUpdateMessage)message;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced KeyUpdate post-handshake message", km);
}
@@ -328,7 +328,7 @@ public byte[] produce(ConnectionContext context,
// changeWriteCiphers() implementation.
wc.baseSecret = nplus1;
hc.conContext.outputRecord.changeWriteCiphers(wc, km.status.id);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("KeyUpdate: write key updated");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/MaxFragExtension.java b/src/java.base/share/classes/sun/security/ssl/MaxFragExtension.java
index a07e81be914..25500c7ac57 100644
--- a/src/java.base/share/classes/sun/security/ssl/MaxFragExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/MaxFragExtension.java
@@ -176,7 +176,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(CH_MAX_FRAGMENT_LENGTH)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable max_fragment_length extension");
}
@@ -213,7 +213,7 @@ public byte[] produce(ConnectionContext context,
} else {
// log and ignore, no MFL extension.
chc.maxFragmentLength = -1;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No available max_fragment_length extension can " +
"be used for fragment size of " +
@@ -243,7 +243,7 @@ public void consume(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
if (!shc.sslConfig.isAvailable(CH_MAX_FRAGMENT_LENGTH)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable max_fragment_length extension");
}
@@ -288,7 +288,7 @@ public byte[] produce(ConnectionContext context,
MaxFragLenSpec spec = (MaxFragLenSpec)
shc.handshakeExtensions.get(CH_MAX_FRAGMENT_LENGTH);
if (spec == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable max_fragment_length extension");
}
@@ -305,7 +305,7 @@ public byte[] produce(ConnectionContext context,
// For better interoperability, abort the maximum
// fragment length negotiation, rather than terminate
// the connection with a fatal alert.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Abort the maximum fragment length negotiation, " +
"may overflow the maximum packet size limit.");
@@ -413,7 +413,7 @@ public void consume(ConnectionContext context,
// For better interoperability, abort the maximum
// fragment length negotiation, rather than terminate
// the connection with a fatal alert.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Abort the maximum fragment length negotiation, " +
"may overflow the maximum packet size limit.");
@@ -455,7 +455,7 @@ public byte[] produce(ConnectionContext context,
MaxFragLenSpec spec = (MaxFragLenSpec)
shc.handshakeExtensions.get(CH_MAX_FRAGMENT_LENGTH);
if (spec == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable max_fragment_length extension");
}
@@ -472,7 +472,7 @@ public byte[] produce(ConnectionContext context,
// For better interoperability, abort the maximum
// fragment length negotiation, rather than terminate
// the connection with a fatal alert.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Abort the maximum fragment length negotiation, " +
"may overflow the maximum packet size limit.");
@@ -578,7 +578,7 @@ public void consume(ConnectionContext context,
// For better interoperability, abort the maximum
// fragment length negotiation, rather than terminate
// the connection with a fatal alert.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Abort the maximum fragment length negotiation, " +
"may overflow the maximum packet size limit.");
diff --git a/src/java.base/share/classes/sun/security/ssl/NamedGroup.java b/src/java.base/share/classes/sun/security/ssl/NamedGroup.java
index 46280a05355..0c708b194cb 100644
--- a/src/java.base/share/classes/sun/security/ssl/NamedGroup.java
+++ b/src/java.base/share/classes/sun/security/ssl/NamedGroup.java
@@ -273,7 +273,7 @@ enum NamedGroup {
| NoSuchAlgorithmException exp) {
if (namedGroupSpec != NamedGroupSpec.NAMED_GROUP_XDH) {
mediator = false;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No AlgorithmParameters for " + name, exp);
}
@@ -294,7 +294,7 @@ enum NamedGroup {
// AlgorithmParameters.getInstance(name);
} catch (NoSuchAlgorithmException nsae) {
mediator = false;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"No AlgorithmParameters for " + name, nsae);
}
@@ -382,7 +382,7 @@ public static List namesOf(String[] namedGroups) {
for (String ss : namedGroups) {
NamedGroup ng = NamedGroup.nameOf(ss);
if (ng == null || !ng.isAvailable) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore the named group (" + ss
@@ -811,7 +811,7 @@ static final class SupportedGroups {
}
if (groupList.isEmpty() &&
- SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("No default named groups");
}
}
diff --git a/src/java.base/share/classes/sun/security/ssl/NewSessionTicket.java b/src/java.base/share/classes/sun/security/ssl/NewSessionTicket.java
index 4c879e0dc4d..89b0a72bb32 100644
--- a/src/java.base/share/classes/sun/security/ssl/NewSessionTicket.java
+++ b/src/java.base/share/classes/sun/security/ssl/NewSessionTicket.java
@@ -202,7 +202,7 @@ static final class T13NewSessionTicketMessage extends NewSessionTicketMessage {
this.ticket = Record.getBytes16(m);
if (ticket.length == 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"No ticket in the NewSessionTicket handshake message");
}
@@ -329,7 +329,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
if (hc instanceof ServerHandshakeContext) {
// Is this session resumable?
if (!hc.handshakeSession.isRejoinable()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No session ticket produced: " +
"session is not resumable");
}
@@ -347,7 +347,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
SSLExtension.PSK_KEY_EXCHANGE_MODES);
if (pkemSpec == null ||
!pkemSpec.contains(PskKeyExchangeMode.PSK_DHE_KE)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No session ticket produced: " +
"client does not support psk_dhe_ke");
}
@@ -358,7 +358,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
// Check if we have sent a PSK already, then we know it is
// using an allowable PSK exchange key mode.
if (!hc.handshakeSession.isPSKable()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No session ticket produced: " +
"No session ticket allowed in this session");
}
@@ -372,7 +372,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
hc.sslContext.engineGetServerSessionContext();
int sessionTimeoutSeconds = sessionCache.getSessionTimeout();
if (sessionTimeoutSeconds > MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No session ticket produced: " +
"session timeout is too long");
}
@@ -459,7 +459,7 @@ private NewSessionTicketMessage generateNST(HandshakeContext hc,
if (!nstm.isValid()) {
hc.statelessResumption = false;
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced NewSessionTicket stateless " +
"post-handshake message", nstm);
}
@@ -474,7 +474,7 @@ private NewSessionTicketMessage generateNST(HandshakeContext hc,
sessionCache.getSessionTimeout(),
hc.sslContext.getSecureRandom(), nonce,
newId.getId());
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced NewSessionTicket " +
"post-handshake message", nstm);
}
@@ -488,7 +488,7 @@ private NewSessionTicketMessage generateNST(HandshakeContext hc,
return nstm;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No NewSessionTicket created");
}
@@ -526,7 +526,7 @@ public byte[] produce(ConnectionContext context,
shc.sslContext.engineGetServerSessionContext();
int sessionTimeoutSeconds = sessionCache.getSessionTimeout();
if (sessionTimeoutSeconds > MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Session timeout is too long. No ticket sent.");
}
@@ -540,7 +540,7 @@ public byte[] produce(ConnectionContext context,
NewSessionTicketMessage nstm = new T12NewSessionTicketMessage(shc,
sessionTimeoutSeconds,
new SessionTicketSpec().encrypt(shc, sessionCopy));
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced NewSessionTicket stateless handshake message",
nstm);
@@ -579,7 +579,7 @@ public void consume(ConnectionContext context,
HandshakeContext hc = (HandshakeContext)context;
NewSessionTicketMessage nstm =
new T13NewSessionTicketMessage(hc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming NewSessionTicket message", nstm);
}
@@ -590,7 +590,7 @@ public void consume(ConnectionContext context,
// discard tickets with timeout 0
if (nstm.ticketLifetime <= 0 ||
nstm.ticketLifetime > MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Discarding NewSessionTicket with lifetime " +
nstm.ticketLifetime, nstm);
@@ -599,7 +599,7 @@ public void consume(ConnectionContext context,
}
if (sessionCache.getSessionTimeout() > MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Session cache lifetime is too long. " +
"Discarding ticket.");
@@ -611,7 +611,7 @@ public void consume(ConnectionContext context,
SecretKey resumptionMasterSecret =
sessionToSave.getResumptionMasterSecret();
if (resumptionMasterSecret == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Session has no resumption master secret. " +
"Ignoring ticket.");
@@ -637,7 +637,7 @@ public void consume(ConnectionContext context,
sessionCopy.setPskIdentity(nstm.ticket);
sessionCache.put(sessionCopy, sessionCopy.isPSK());
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("MultiNST PSK (Server): " +
Utilities.toHexString(Arrays.copyOf(nstm.ticket, 16)));
}
@@ -665,7 +665,7 @@ public void consume(ConnectionContext context,
NewSessionTicketMessage nstm = new T12NewSessionTicketMessage(hc,
message);
if (nstm.ticket.length == 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("NewSessionTicket ticket was empty");
}
return;
@@ -674,7 +674,7 @@ public void consume(ConnectionContext context,
// discard tickets with timeout 0
if (nstm.ticketLifetime <= 0 ||
nstm.ticketLifetime > MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Discarding NewSessionTicket with lifetime " +
nstm.ticketLifetime, nstm);
@@ -686,7 +686,7 @@ public void consume(ConnectionContext context,
hc.sslContext.engineGetClientSessionContext();
if (sessionCache.getSessionTimeout() > MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Session cache lifetime is too long. " +
"Discarding ticket.");
@@ -695,7 +695,7 @@ public void consume(ConnectionContext context,
}
hc.handshakeSession.setPskIdentity(nstm.ticket);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Consuming NewSessionTicket\n" + nstm);
}
}
diff --git a/src/java.base/share/classes/sun/security/ssl/OutputRecord.java b/src/java.base/share/classes/sun/security/ssl/OutputRecord.java
index f2c30b3ff72..416d5d1b5ef 100644
--- a/src/java.base/share/classes/sun/security/ssl/OutputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/OutputRecord.java
@@ -188,7 +188,7 @@ void changeWriteCiphers(SSLWriteCipher writeCipher,
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"change_cipher_spec message");
}
@@ -222,7 +222,7 @@ void changeWriteCiphers(SSLWriteCipher writeCipher,
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"key_update handshake message");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java
index 819fdd589cb..b99c0175838 100644
--- a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java
@@ -341,7 +341,7 @@ public void consume(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SSLExtension.CH_PRE_SHARED_KEY)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable pre_shared_key extension");
}
@@ -393,7 +393,7 @@ public void consume(ConnectionContext context,
}
}
if (b == null || s == null) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Stateless session ticket invalid");
@@ -402,7 +402,7 @@ public void consume(ConnectionContext context,
}
if (s != null && canRejoin(clientHello, shc, s)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Resuming session: ", s);
}
@@ -435,7 +435,7 @@ private static boolean canRejoin(ClientHelloMessage clientHello,
// Check protocol version
if (result && s.getProtocolVersion() != shc.negotiatedProtocol) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("Can't resume, incorrect protocol version");
@@ -449,7 +449,7 @@ private static boolean canRejoin(ClientHelloMessage clientHello,
try {
s.getPeerPrincipal();
} catch (SSLPeerUnverifiedException e) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, " +
@@ -466,7 +466,7 @@ private static boolean canRejoin(ClientHelloMessage clientHello,
if (result &&
!shc.localSupportedCertSignAlgs.containsAll(sessionSigAlgs)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Can't resume. Session uses different " +
"signature algorithms");
}
@@ -480,7 +480,7 @@ private static boolean canRejoin(ClientHelloMessage clientHello,
if (result && identityAlg != null) {
String sessionIdentityAlg = s.getIdentificationProtocol();
if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest("Can't resume, endpoint id" +
@@ -494,7 +494,7 @@ private static boolean canRejoin(ClientHelloMessage clientHello,
// Ensure cipher suite can be negotiated
if (result && (!shc.isNegotiable(s.getSuite()) ||
!clientHello.cipherSuites.contains(s.getSuite()))) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Can't resume, unavailable session cipher suite");
@@ -653,7 +653,7 @@ public byte[] produce(ConnectionContext context,
// The producing happens in client side only.
ClientHandshakeContext chc = (ClientHandshakeContext)context;
if (!chc.isResumption || chc.resumingSession == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No session to resume.");
}
return null;
@@ -663,7 +663,7 @@ public byte[] produce(ConnectionContext context,
Collection sessionSigAlgs =
chc.resumingSession.getLocalSupportedSignatureSchemes();
if (!chc.localSupportedCertSignAlgs.containsAll(sessionSigAlgs)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Existing session uses different " +
"signature algorithms");
}
@@ -673,7 +673,7 @@ public byte[] produce(ConnectionContext context,
// The session must have a pre-shared key
SecretKey psk = chc.resumingSession.getPreSharedKey();
if (psk == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Existing session has no PSK.");
}
return null;
@@ -687,7 +687,7 @@ public byte[] produce(ConnectionContext context,
}
if (chc.pskIdentity == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"PSK has no identity, or identity was already used");
}
@@ -699,7 +699,7 @@ public byte[] produce(ConnectionContext context,
chc.sslContext.engineGetClientSessionContext();
sessionCache.remove(chc.resumingSession.getSessionId(), true);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Found resumable session. Preparing PSK message.");
SSLLogger.fine(
@@ -836,7 +836,7 @@ class CHPreSharedKeyOnLoadAbsence implements HandshakeAbsence {
public void absent(ConnectionContext context,
HandshakeMessage message) throws IOException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Handling pre_shared_key absence.");
}
@@ -901,7 +901,7 @@ public void consume(ConnectionContext context,
}
SHPreSharedKeySpec shPsk = new SHPreSharedKeySpec(chc, buffer);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Received pre_shared_key extension: ", shPsk);
}
@@ -911,7 +911,7 @@ public void consume(ConnectionContext context,
"Selected identity index is not in correct range.");
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Resuming session: ", chc.resumingSession);
}
@@ -925,7 +925,7 @@ public void absent(ConnectionContext context,
HandshakeMessage message) throws IOException {
ClientHandshakeContext chc = (ClientHandshakeContext)context;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Handling pre_shared_key absence.");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java b/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java
index e510fe92b0e..c826d9c89e3 100644
--- a/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java
+++ b/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java
@@ -246,7 +246,7 @@ final class PredefinedDHParameterSpecs {
Matcher spacesMatcher = spacesPattern.matcher(property);
property = spacesMatcher.replaceAll("");
- if (SSLLogger.isOn && SSLLogger.isOn("sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("sslctx")) {
SSLLogger.fine(
"The Security Property " +
PROPERTY_NAME + ": " + property);
@@ -262,7 +262,7 @@ final class PredefinedDHParameterSpecs {
String primeModulus = paramsFinder.group(1);
BigInteger p = new BigInteger(primeModulus, 16);
if (!p.isProbablePrime(PRIME_CERTAINTY)) {
- if (SSLLogger.isOn && SSLLogger.isOn("sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("sslctx")) {
SSLLogger.fine(
"Prime modulus p in Security Property, " +
PROPERTY_NAME + ", is not a prime: " +
@@ -279,7 +279,7 @@ final class PredefinedDHParameterSpecs {
DHParameterSpec spec = new DHParameterSpec(p, g);
defaultParams.put(primeLen, spec);
}
- } else if (SSLLogger.isOn && SSLLogger.isOn("sslctx")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("sslctx")) {
SSLLogger.fine("Invalid Security Property, " +
PROPERTY_NAME + ", definition");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java b/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java
index 07707c5163a..a4f343ccb06 100644
--- a/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/PskKeyExchangeModesExtension.java
@@ -184,7 +184,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(
SSLExtension.PSK_KEY_EXCHANGE_MODES)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable psk_key_exchange_modes extension");
}
@@ -216,7 +216,7 @@ public void consume(ConnectionContext context,
if (!spec.contains(PskKeyExchangeMode.PSK_DHE_KE)) {
shc.isResumption = false;
shc.resumingSession = null;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"abort session resumption, " +
"no supported psk_dhe_ke PSK key exchange mode");
@@ -247,7 +247,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(
SSLExtension.PSK_KEY_EXCHANGE_MODES)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore unavailable psk_key_exchange_modes extension");
}
@@ -287,7 +287,7 @@ public void absent(ConnectionContext context,
if (shc.isResumption) { // resumingSession may not be set
shc.isResumption = false;
shc.resumingSession = null;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"abort session resumption, " +
"no supported psk_dhe_ke PSK key exchange mode");
diff --git a/src/java.base/share/classes/sun/security/ssl/QuicEngineOutputRecord.java b/src/java.base/share/classes/sun/security/ssl/QuicEngineOutputRecord.java
index 893eb282116..7e307ba9d27 100644
--- a/src/java.base/share/classes/sun/security/ssl/QuicEngineOutputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/QuicEngineOutputRecord.java
@@ -75,14 +75,14 @@ void encodeAlert(byte level, byte description) throws IOException {
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"alert message: " + Alert.nameOf(description));
}
return;
}
if (level == Alert.Level.WARNING.level) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Suppressing warning-level " +
"alert message: " + Alert.nameOf(description));
}
@@ -90,7 +90,7 @@ void encodeAlert(byte level, byte description) throws IOException {
}
if (alert != null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Suppressing subsequent alert: " +
description + ", original: " + alert.id);
}
@@ -109,7 +109,7 @@ void encodeHandshake(byte[] source,
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"handshake message",
ByteBuffer.wrap(source, offset, length));
diff --git a/src/java.base/share/classes/sun/security/ssl/QuicKeyManager.java b/src/java.base/share/classes/sun/security/ssl/QuicKeyManager.java
index fb9077af022..4613dcf96ff 100644
--- a/src/java.base/share/classes/sun/security/ssl/QuicKeyManager.java
+++ b/src/java.base/share/classes/sun/security/ssl/QuicKeyManager.java
@@ -244,7 +244,7 @@ void discardKeys() {
if (toDiscard == null) {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("discarding keys (keyphase="
+ toDiscard.writeCipher.getKeyPhase()
+ ") of " + this.keySpace + " key space");
@@ -389,7 +389,7 @@ void discardKeys() {
if (toDiscard == null) {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("discarding keys (keyphase="
+ toDiscard.writeCipher.getKeyPhase()
+ ") of " + this.keySpace + " key space");
@@ -570,7 +570,7 @@ void discardKeys() {
if (series == null) {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("discarding key (series) of " +
this.keySpace + " key space");
}
@@ -611,7 +611,7 @@ void decryptPacket(final long packetNumber, final int keyPhase,
if (series.canUseOldDecryptKey(packetNumber)) {
final QuicReadCipher oldReadCipher = series.old;
assert oldReadCipher != null : "old key is unexpectedly null";
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("using old read key to decrypt packet: " +
packetNumber + ", with incoming key phase: " +
keyPhase + ", current key phase: " +
@@ -633,7 +633,7 @@ void decryptPacket(final long packetNumber, final int keyPhase,
// KEY_UPDATE_ERROR. This indicates that a peer has
// received and acknowledged a packet that initiates a key
// update, but has not updated keys in response.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("peer used incorrect key, was" +
" expected to use updated key of" +
" key phase: " + currentKeyPhase +
@@ -646,7 +646,7 @@ void decryptPacket(final long packetNumber, final int keyPhase,
}
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("detected ONE_RTT key update, current key " +
"phase: " + currentKeyPhase
+ ", incoming key phase: " + keyPhase
@@ -717,7 +717,7 @@ private boolean maybeInitiateKeyUpdate(final KeySeries currentSeries,
}
final long numEncrypted = cipher.getNumEncrypted();
if (numEncrypted >= 0.8 * confidentialityLimit) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("about to reach confidentiality limit, " +
"attempting to initiate a 1-RTT key update," +
" packet number: " +
@@ -732,7 +732,7 @@ private boolean maybeInitiateKeyUpdate(final KeySeries currentSeries,
: "key phase of updated key unexpectedly matches " +
"the key phase "
+ cipher.getKeyPhase() + " of current keys";
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
"1-RTT key update initiated, new key phase: "
+ newKeyPhase);
@@ -755,7 +755,7 @@ private boolean initiateKeyUpdate(final KeySeries series) {
// current key phase. This ensures that keys are
// available to both peers before
// another key update can be initiated.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
"skipping key update initiation because peer " +
"hasn't yet sent us a packet encrypted with " +
@@ -803,7 +803,7 @@ private void decryptUsingNextKeys(
// (we avoid timing attacks by not generating
// keys during decryption, our key generation
// only happens during encryption)
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("next keys unavailable," +
" won't decrypt a packet which appears to be" +
" a key update");
@@ -815,7 +815,7 @@ private void decryptUsingNextKeys(
// use the next keys to attempt decrypting
currentKeySeries.next.readCipher.decryptPacket(packetNumber, packet,
headerLength, output);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
"decrypted using next keys for peer-initiated" +
" key update; will now switch to new key phase: " +
@@ -1025,14 +1025,14 @@ private KeySeries rolloverKeys(final QuicVersion version,
// update the key series
this.keySeries = newSeries;
if (oldReadCipher != null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
"discarding old read key of key phase: " +
oldReadCipher.getKeyPhase());
}
oldReadCipher.discard(false);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("discarding write key of key phase: " +
writeCipherToDiscard.getKeyPhase());
}
diff --git a/src/java.base/share/classes/sun/security/ssl/QuicTLSEngineImpl.java b/src/java.base/share/classes/sun/security/ssl/QuicTLSEngineImpl.java
index 6765f554fcc..18790a58c11 100644
--- a/src/java.base/share/classes/sun/security/ssl/QuicTLSEngineImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/QuicTLSEngineImpl.java
@@ -560,7 +560,7 @@ public void consumeHandshakeBytes(KeySpace keySpace, ByteBuffer payload)
// incoming crypto buffer is null. Validate message type,
// check if size is available
byte messageType = payload.get(payload.position());
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine("Received message of type 0x" +
Integer.toHexString(messageType & 0xFF));
}
@@ -835,7 +835,7 @@ public boolean tryMarkHandshakeDone() {
final boolean confirmed = HANDSHAKE_STATE_HANDLE.compareAndSet(this,
NEED_SEND_HANDSHAKE_DONE, HANDSHAKE_CONFIRMED);
if (confirmed) {
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine("QuicTLSEngine (server) marked handshake " +
"state as HANDSHAKE_CONFIRMED");
}
@@ -853,7 +853,7 @@ public boolean tryReceiveHandshakeDone() {
final boolean confirmed = HANDSHAKE_STATE_HANDLE.compareAndSet(this,
NEED_RECV_HANDSHAKE_DONE, HANDSHAKE_CONFIRMED);
if (confirmed) {
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine(
"QuicTLSEngine (client) received HANDSHAKE_DONE," +
" marking state as HANDSHAKE_DONE");
diff --git a/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java
index 701ba35174e..ec91cb4509a 100644
--- a/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java
@@ -190,7 +190,7 @@ public byte[] produce(ConnectionContext context,
throw chc.conContext.fatal(Alert.ILLEGAL_PARAMETER,
"Cannot generate RSA premaster secret", gse);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced RSA ClientKeyExchange handshake message", ckem);
}
@@ -270,7 +270,7 @@ public void consume(ConnectionContext context,
RSAClientKeyExchangeMessage ckem =
new RSAClientKeyExchangeMessage(shc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming RSA ClientKeyExchange handshake message", ckem);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java
index 311ac97e744..d176d7311d0 100644
--- a/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/RSAKeyExchange.java
@@ -35,7 +35,6 @@
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.interfaces.RSAPublicKey;
-import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
@@ -150,7 +149,7 @@ static RSAPremasterSecret decode(ServerHandshakeContext shc,
needFailover = !KeyUtil.isOracleJCEProvider(
cipher.getProvider().getName());
} catch (InvalidKeyException | UnsupportedOperationException iue) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("The Cipher provider "
+ safeProviderName(cipher)
+ " caused exception: " + iue.getMessage());
@@ -197,7 +196,7 @@ private static String safeProviderName(Cipher cipher) {
try {
return cipher.getProvider().toString();
} catch (Exception e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Retrieving The Cipher provider name" +
" caused exception ", e);
}
@@ -205,7 +204,7 @@ private static String safeProviderName(Cipher cipher) {
try {
return cipher.toString() + " (provider name not available)";
} catch (Exception e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Retrieving The Cipher name" +
" caused exception ", e);
}
@@ -220,7 +219,7 @@ private static SecretKey generatePremasterSecret(
int clientVersion, int serverVersion, byte[] encodedSecret,
SecureRandom generator) throws GeneralSecurityException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Generating a premaster secret");
}
@@ -235,7 +234,7 @@ private static SecretKey generatePremasterSecret(
} catch (InvalidAlgorithmParameterException |
NoSuchAlgorithmException iae) {
// unlikely to happen, otherwise, must be a provider exception
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("RSA premaster secret generation error", iae);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java
index 8633b9458ce..43f2ef95ba8 100644
--- a/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/RSAServerKeyExchange.java
@@ -264,7 +264,7 @@ public byte[] produce(ConnectionContext context,
RSAServerKeyExchangeMessage skem =
new RSAServerKeyExchangeMessage(
shc, x509Possession, rsaPossession);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced RSA ServerKeyExchange handshake message", skem);
}
@@ -296,7 +296,7 @@ public void consume(ConnectionContext context,
RSAServerKeyExchangeMessage skem =
new RSAServerKeyExchangeMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming RSA ServerKeyExchange handshake message", skem);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/RenegoInfoExtension.java b/src/java.base/share/classes/sun/security/ssl/RenegoInfoExtension.java
index e1348badd30..90b9e999925 100644
--- a/src/java.base/share/classes/sun/security/ssl/RenegoInfoExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/RenegoInfoExtension.java
@@ -138,7 +138,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(CH_RENEGOTIATION_INFO)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable renegotiation_info extension");
}
@@ -182,7 +182,7 @@ public byte[] produce(ConnectionContext context,
return extData;
} else { // not secure renegotiation
if (HandshakeContext.allowUnsafeRenegotiation) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("Using insecure renegotiation");
}
@@ -216,7 +216,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(CH_RENEGOTIATION_INFO)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Ignore unavailable extension: " +
CH_RENEGOTIATION_INFO.name);
}
@@ -280,7 +280,7 @@ public void absent(ConnectionContext context,
for (int id : clientHello.cipherSuiteIds) {
if (id ==
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV.id) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Safe renegotiation, using the SCSV signaling");
}
@@ -294,7 +294,7 @@ public void absent(ConnectionContext context,
"Failed to negotiate the use of secure renegotiation");
} // otherwise, allow legacy hello message
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("Warning: No renegotiation " +
"indication in ClientHello, allow legacy ClientHello");
}
@@ -306,13 +306,13 @@ public void absent(ConnectionContext context,
"Inconsistent secure renegotiation indication");
} else { // renegotiation, not secure
if (HandshakeContext.allowUnsafeRenegotiation) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("Using insecure renegotiation");
}
} else {
// Unsafe renegotiation should have been aborted in
// earlier processes.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Terminate insecure renegotiation");
}
throw shc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
@@ -345,7 +345,7 @@ public byte[] produce(ConnectionContext context,
if (requestedSpec == null && !shc.conContext.secureRenegotiation) {
// Ignore, no renegotiation_info extension or SCSV signaling
// requested.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable renegotiation_info extension");
}
@@ -354,7 +354,7 @@ public byte[] produce(ConnectionContext context,
if (!shc.conContext.secureRenegotiation) {
// Ignore, no secure renegotiation is negotiated.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"No secure renegotiation has been negotiated");
}
@@ -515,7 +515,7 @@ public void absent(ConnectionContext context,
"Failed to negotiate the use of secure renegotiation");
} // otherwise, allow legacy hello message
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("Warning: No renegotiation " +
"indication in ServerHello, allow legacy ServerHello");
}
@@ -527,13 +527,13 @@ public void absent(ConnectionContext context,
"Inconsistent secure renegotiation indication");
} else { // renegotiation, not secure
if (HandshakeContext.allowUnsafeRenegotiation) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("Using insecure renegotiation");
}
} else {
// Unsafe renegotiation should have been aborted in
// earlier processes.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Terminate insecure renegotiation");
}
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
index 1d5a4c4e73d..594766ea0fd 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
@@ -454,7 +454,7 @@ private boolean checkRsaSsaPssParams(
.equalsIgnoreCase(paramDigestAlg));
} catch (InvalidParameterSpecException e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Invalid AlgorithmParameters: "
+ parameters + "; Error: " + e.getMessage());
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java
index 4a52a2ea583..5dfa5be3420 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLCipher.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLCipher.java
@@ -392,7 +392,7 @@ enum SSLCipher {
if (values[1].contains(tag[0])) {
index = 0;
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("jdk.tls.keyLimits: Unknown action: " +
entry);
}
@@ -413,13 +413,13 @@ enum SSLCipher {
"Length exceeded limits");
}
} catch (NumberFormatException e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("jdk.tls.keyLimits: " + e.getMessage() +
": " + entry);
}
continue;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("jdk.tls.keyLimits: entry = " + entry +
". " + values[0] + ":" + tag[index] + " = " + size);
}
@@ -468,7 +468,7 @@ private static boolean isTransformationAvailable(String transformation) {
Cipher.getInstance(transformation);
return true;
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Transformation " + transformation + " is" +
" not available.");
}
@@ -860,7 +860,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
"JCE provider " + cipher.getProvider().getName(), sbe);
}
pt.position(pos);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext after DECRYPTION", pt.duplicate());
}
@@ -930,7 +930,7 @@ public int encrypt(byte contentType, ByteBuffer bb) {
authenticator.increaseSequenceNumber();
}
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.finest(
"Padded plaintext before ENCRYPTION", bb.duplicate());
}
@@ -1050,7 +1050,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
"JCE provider " + cipher.getProvider().getName(), sbe);
}
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Padded plaintext after DECRYPTION",
pt.duplicate().position(pos));
@@ -1182,7 +1182,7 @@ public int encrypt(byte contentType, ByteBuffer bb) {
int len = addPadding(bb, blockSize);
bb.position(pos);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Padded plaintext before ENCRYPTION",
bb.duplicate());
@@ -1326,7 +1326,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
"JCE provider " + cipher.getProvider().getName(), sbe);
}
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine("Padded plaintext after DECRYPTION",
pt.duplicate().position(pos));
}
@@ -1478,7 +1478,7 @@ public int encrypt(byte contentType, ByteBuffer bb) {
int len = addPadding(bb, blockSize);
bb.position(pos);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Padded plaintext before ENCRYPTION",
bb.duplicate());
@@ -1650,7 +1650,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
pt.position(pos);
pt.limit(pos + len);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext after DECRYPTION", pt.duplicate());
}
@@ -1737,7 +1737,7 @@ public int encrypt(byte contentType,
// DON'T encrypt the nonce for AEAD mode.
int len, pos = bb.position();
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext before ENCRYPTION",
bb.duplicate());
@@ -1823,7 +1823,7 @@ static final class GcmReadCipher extends SSLReadCipher {
keyLimitCountdown = cipherLimits.getOrDefault(
algorithm.toUpperCase(Locale.ENGLISH) + ":" + tag[0], 0L);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("KeyLimit read side: algorithm = " +
algorithm + ":" + tag[0] +
"\ncountdown value = " + keyLimitCountdown);
@@ -1932,7 +1932,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
contentType = pt.get(i);
pt.limit(i);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext after DECRYPTION", pt.duplicate());
}
@@ -1984,7 +1984,7 @@ private static final class GcmWriteCipher extends SSLWriteCipher {
keyLimitCountdown = cipherLimits.getOrDefault(
algorithm.toUpperCase(Locale.ENGLISH) + ":" + tag[0], 0L);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("KeyLimit write side: algorithm = "
+ algorithm + ":" + tag[0] +
"\ncountdown value = " + keyLimitCountdown);
@@ -2026,7 +2026,7 @@ public int encrypt(byte contentType,
cipher.updateAAD(aad);
int len, pos = bb.position();
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext before ENCRYPTION",
bb.duplicate());
@@ -2182,7 +2182,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
pt.position(pos);
pt.limit(pos + len);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext after DECRYPTION", pt.duplicate());
}
@@ -2231,7 +2231,7 @@ private static final class CC20P1305WriteCipher extends SSLWriteCipher {
keyLimitCountdown = cipherLimits.getOrDefault(
algorithm.toUpperCase(Locale.ENGLISH) + ":" + tag[0], 0L);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("algorithm = " + algorithm +
":" + tag[0] + "\ncountdown value = " +
keyLimitCountdown);
@@ -2273,7 +2273,7 @@ public int encrypt(byte contentType,
// DON'T encrypt the nonce for AEAD mode.
int pos = bb.position();
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext before ENCRYPTION",
bb.duplicate());
@@ -2450,7 +2450,7 @@ public Plaintext decrypt(byte contentType, ByteBuffer bb,
contentType = pt.get(i);
pt.limit(i);
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext after DECRYPTION", pt.duplicate());
}
@@ -2499,7 +2499,7 @@ private static final class CC20P1305WriteCipher extends SSLWriteCipher {
keyLimitCountdown = cipherLimits.getOrDefault(
algorithm.toUpperCase(Locale.ENGLISH) + ":" + tag[0], 0L);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("algorithm = " + algorithm +
":" + tag[0] + "\ncountdown value = " +
keyLimitCountdown);
@@ -2541,7 +2541,7 @@ public int encrypt(byte contentType,
cipher.updateAAD(aad);
int pos = bb.position();
- if (SSLLogger.isOn && SSLLogger.isOn("plaintext")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("plaintext")) {
SSLLogger.fine(
"Plaintext before ENCRYPTION",
bb.duplicate());
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java b/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java
index 6d1834ad2b7..ace60e41af9 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java
@@ -204,7 +204,7 @@ final class SSLConfiguration implements Cloneable {
if (nstServerCount == null || nstServerCount < 0 ||
nstServerCount > 10) {
serverNewSessionTicketCount = SERVER_NST_DEFAULT;
- if (nstServerCount != null && SSLLogger.isOn &&
+ if (nstServerCount != null && SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"jdk.tls.server.newSessionTicketCount defaults to " +
@@ -213,7 +213,7 @@ final class SSLConfiguration implements Cloneable {
}
} else {
serverNewSessionTicketCount = nstServerCount;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"jdk.tls.server.newSessionTicketCount set to " +
serverNewSessionTicketCount);
@@ -586,7 +586,7 @@ private static String[] getCustomizedSignatureScheme(String propertyName) {
String property = System.getProperty(propertyName);
// this method is called from class initializer; logging here
// will occasionally pin threads and deadlock if called from a virtual thread
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")
&& !Thread.currentThread().isVirtual()) {
SSLLogger.fine(
"System property " + propertyName + " is set to '" +
@@ -615,7 +615,7 @@ private static String[] getCustomizedSignatureScheme(String propertyName) {
if (scheme != null && scheme.isAvailable) {
signatureSchemes.add(schemeName);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")
&& !Thread.currentThread().isVirtual()) {
SSLLogger.fine(
"The current installed providers do not " +
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
index d50a9a10b76..be324eb0949 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
@@ -104,11 +104,11 @@ protected void engineInit(KeyManager[] km, TrustManager[] tm,
* first connection to time out and fail. Make sure it is
* primed and ready by getting some initial output from it.
*/
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.finest("trigger seeding of SecureRandom");
}
secureRandom.nextInt();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.finest("done seeding of SecureRandom");
}
@@ -143,7 +143,7 @@ private X509ExtendedKeyManager chooseKeyManager(KeyManager[] kms) {
return (X509ExtendedKeyManager)km;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.warning(
"X509KeyManager passed to SSLContext.init(): need an " +
"X509ExtendedKeyManager for SSLEngine use");
@@ -246,7 +246,7 @@ StatusResponseManager getStatusResponseManager() {
contextLock.lock();
try {
if (statusResponseManager == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.finest(
"Initializing StatusResponseManager");
}
@@ -383,7 +383,7 @@ private static List getApplicableCipherSuites(
suite.name, null)) {
suites.add(suite);
isSupported = true;
- } else if (SSLLogger.isOn &&
+ } else if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,sslctx,verbose")) {
SSLLogger.fine(
"Ignore disabled cipher suite: " + suite.name);
@@ -392,7 +392,7 @@ private static List getApplicableCipherSuites(
break;
}
- if (!isSupported && SSLLogger.isOn &&
+ if (!isSupported && SSLLogger.isOn() &&
SSLLogger.isOn("ssl,sslctx,verbose")) {
SSLLogger.finest(
"Ignore unsupported cipher suite: " + suite);
@@ -410,7 +410,7 @@ private static Collection getCustomizedCipherSuites(
String propertyName) {
String property = System.getProperty(propertyName);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.fine(
"System property " + propertyName + " is set to '" +
property + "'");
@@ -437,7 +437,7 @@ private static Collection getCustomizedCipherSuites(
try {
suite = CipherSuite.nameOf(cipherSuiteNames[i]);
} catch (IllegalArgumentException iae) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.fine(
"Unknown or unsupported cipher suite name: " +
cipherSuiteNames[i]);
@@ -449,7 +449,7 @@ private static Collection getCustomizedCipherSuites(
if (suite != null && suite.isAvailable()) {
cipherSuites.add(suite);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")) {
SSLLogger.fine(
"The current installed providers do not " +
"support cipher suite: " + cipherSuiteNames[i]);
@@ -907,7 +907,7 @@ private static final class DefaultManagersHolder {
tmMediator = getTrustManagers();
} catch (Exception e) {
reserved = e;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.warning(
"Failed to load default trust managers", e);
}
@@ -919,7 +919,7 @@ private static final class DefaultManagersHolder {
kmMediator = getKeyManagers();
} catch (Exception e) {
reserved = e;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.warning(
"Failed to load default key managers", e);
}
@@ -977,7 +977,7 @@ private static KeyManager[] getKeyManagers() throws Exception {
String defaultKeyStore = props.get("keyStore");
String defaultKeyStoreType = props.get("keyStoreType");
String defaultKeyStoreProvider = props.get("keyStoreProvider");
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.fine("keyStore is : " + defaultKeyStore);
SSLLogger.fine("keyStore type is : " +
defaultKeyStoreType);
@@ -1007,7 +1007,7 @@ private static KeyManager[] getKeyManagers() throws Exception {
// Try to initialize key store.
if ((defaultKeyStoreType.length()) != 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.finest("init keystore");
}
if (defaultKeyStoreProvider.isEmpty()) {
@@ -1030,7 +1030,7 @@ private static KeyManager[] getKeyManagers() throws Exception {
/*
* Try to initialize key manager.
*/
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.fine("init keymanager of type " +
KeyManagerFactory.getDefaultAlgorithm());
}
@@ -1068,7 +1068,7 @@ private static final class DefaultSSLContextHolder {
// exception object, which may be not garbage collection
// friendly as 'reservedException' is a static filed.
reserved = new KeyManagementException(e.getMessage());
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.warning(
"Failed to load default SSLContext", e);
}
@@ -1097,7 +1097,7 @@ public DefaultSSLContext() throws Exception {
super.engineInit(DefaultManagersHolder.keyManagers,
DefaultManagersHolder.trustManagers, null);
} catch (Exception e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,defaultctx")) {
SSLLogger.fine("default context init failed: ", e);
}
throw e;
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java
index 4b19f5a9d7b..5e23e6ee37b 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, 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
@@ -330,7 +330,7 @@ private Ciphertext encode(
// application data may be discarded accordingly. As could
// be an issue for some applications. This impact can be
// mitigated by sending the last flight twice.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,verbose")) {
SSLLogger.finest("retransmit the last flight messages");
}
@@ -397,7 +397,7 @@ private HandshakeStatus tryKeyUpdate(
if ((conContext.handshakeContext == null) &&
!conContext.isOutboundClosed() &&
!conContext.isBroken) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("trigger key update");
}
beginHandshake();
@@ -419,7 +419,7 @@ private HandshakeStatus tryNewSessionTicket(
!conContext.isOutboundClosed() &&
!conContext.isInboundClosed() &&
!conContext.isBroken) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("trigger NST");
}
conContext.conSession.updateNST = false;
@@ -612,7 +612,7 @@ private SSLEngineResult readRecord(
} catch (SSLException ssle) {
// Need to discard invalid records for DTLS protocols.
if (sslContext.isDTLS()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,verbose")) {
SSLLogger.finest("Discard invalid DTLS records", ssle);
}
@@ -780,7 +780,7 @@ public void closeInbound() throws SSLException {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("Closing inbound of SSLEngine");
}
@@ -819,7 +819,7 @@ public void closeOutbound() {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("Closing outbound of SSLEngine");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLEngineInputRecord.java b/src/java.base/share/classes/sun/security/ssl/SSLEngineInputRecord.java
index 1bfbd9f51bf..6e08fc71664 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineInputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineInputRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, 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
@@ -172,7 +172,7 @@ private Plaintext[] decode(ByteBuffer packet)
return null;
}
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw read", packet);
}
@@ -209,7 +209,7 @@ private Plaintext[] decodeInputRecord(ByteBuffer packet)
byte minorVersion = packet.get(); // pos: 2
int contentLen = Record.getInt16(packet); // pos: 3, 4
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"READ: " +
ProtocolVersion.nameOf(majorVersion, minorVersion) +
@@ -388,7 +388,7 @@ private Plaintext[] handleUnknownRecord(ByteBuffer packet)
* error message, one that's treated as fatal by
* clients (Otherwise we'll hang.)
*/
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"Requested to negotiate unsupported SSLv2!");
}
@@ -410,7 +410,7 @@ private Plaintext[] handleUnknownRecord(ByteBuffer packet)
ByteBuffer converted = convertToClientHello(packet);
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine(
"[Converted] ClientHello", converted);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java b/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java
index 4a689a84d5f..1c8751e66fe 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, 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
@@ -73,7 +73,7 @@ boolean isClosed() {
@Override
void encodeAlert(byte level, byte description) {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"alert message: " + Alert.nameOf(description));
}
@@ -91,7 +91,7 @@ void encodeAlert(byte level, byte description) {
void encodeHandshake(byte[] source,
int offset, int length) {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"handshake message",
ByteBuffer.wrap(source, offset, length));
@@ -138,7 +138,7 @@ void encodeHandshake(byte[] source,
@Override
void encodeChangeCipherSpec() {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"change_cipher_spec message");
}
@@ -171,14 +171,14 @@ Ciphertext encode(
ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws IOException {
if (isClosed) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"application data or cached messages");
}
return null;
} else if (isCloseWaiting) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"application data");
}
@@ -193,7 +193,7 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length,
ByteBuffer destination) throws IOException {
if (writeCipher.authenticator.seqNumOverflow()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
"sequence number extremely close to overflow " +
"(2^64-1 packets). Closing connection.");
@@ -275,7 +275,7 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length,
destination.limit(destination.position());
destination.position(dstContent);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name + " " +
ContentType.APPLICATION_DATA.name +
@@ -288,7 +288,7 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length,
dstPos, dstLim, headerSize,
protocolVersion);
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
ByteBuffer temporary = destination.duplicate();
temporary.limit(temporary.position());
temporary.position(dstPos);
@@ -317,7 +317,7 @@ private Ciphertext acquireCiphertext(
//
// Please don't change the limit of the destination buffer.
destination.put(SSLRecord.v2NoCipher);
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write", SSLRecord.v2NoCipher);
}
@@ -331,7 +331,7 @@ private Ciphertext acquireCiphertext(
// deliver the SSLv2 format ClientHello message
//
// Please don't change the limit of the destination buffer.
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
if (SSLLogger.isOn("record")) {
SSLLogger.fine(Thread.currentThread().getName() +
", WRITE: SSLv2 ClientHello message" +
@@ -525,7 +525,7 @@ Ciphertext acquireCiphertext(ByteBuffer dstBuf) throws IOException {
dstBuf.limit(dstBuf.position());
dstBuf.position(dstContent);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name + " " +
ContentType.nameOf(memo.contentType) +
@@ -543,7 +543,7 @@ Ciphertext acquireCiphertext(ByteBuffer dstBuf) throws IOException {
memo.encodeCipher.dispose();
}
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
ByteBuffer temporary = dstBuf.duplicate();
temporary.limit(temporary.position());
temporary.position(dstPos);
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLExtension.java b/src/java.base/share/classes/sun/security/ssl/SSLExtension.java
index fb0490d70f1..47a0d0b0e44 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLExtension.java
@@ -844,7 +844,7 @@ private static Collection getDisabledExtensions(
String property = System.getProperty(propertyName);
// this method is called from class initializer; logging here
// will occasionally pin threads and deadlock if called from a virtual thread
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,sslctx")
&& !Thread.currentThread().isVirtual()) {
SSLLogger.fine(
"System property " + propertyName + " is set to '" +
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLExtensions.java b/src/java.base/share/classes/sun/security/ssl/SSLExtensions.java
index 5ad93cfc836..66f6293302e 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLExtensions.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLExtensions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2025, 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
@@ -43,7 +43,7 @@ final class SSLExtensions {
// Extension map for debug logging
private final Map logMap =
- SSLLogger.isOn ? new LinkedHashMap<>() : null;
+ SSLLogger.isOn() ? new LinkedHashMap<>() : null;
SSLExtensions(HandshakeMessage handshakeMessage) {
this.handshakeMessage = handshakeMessage;
@@ -93,7 +93,7 @@ final class SSLExtensions {
// However, the implementation of the limit is complicated
// and inefficient, and may not worthy the maintenance.
isSupported = false;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Received buggy supported_groups extension " +
"in the ServerHello handshake message");
@@ -143,7 +143,7 @@ final class SSLExtensions {
m.get(extData);
logMap.put(extId, extData);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unknown or unsupported extension",
toString(extId, extData));
@@ -171,7 +171,7 @@ void consumeOnLoad(HandshakeContext context,
for (SSLExtension extension : extensions) {
if (context.negotiatedProtocol != null &&
!extension.isAvailable(context.negotiatedProtocol)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unsupported extension: " + extension.name);
}
@@ -181,7 +181,7 @@ void consumeOnLoad(HandshakeContext context,
if (!extMap.containsKey(extension)) {
if (extension.onLoadAbsence != null) {
extension.absentOnLoad(context, handshakeMessage);
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " + extension.name);
}
@@ -190,7 +190,7 @@ void consumeOnLoad(HandshakeContext context,
if (extension.onLoadConsumer == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore unsupported extension: " + extension.name);
}
@@ -200,7 +200,7 @@ void consumeOnLoad(HandshakeContext context,
ByteBuffer m = ByteBuffer.wrap(extMap.get(extension));
extension.consumeOnLoad(context, handshakeMessage, m);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Consumed extension: " + extension.name);
}
}
@@ -215,7 +215,7 @@ void consumeOnTrade(HandshakeContext context,
if (!extMap.containsKey(extension)) {
if (extension.onTradeAbsence != null) {
extension.absentOnTrade(context, handshakeMessage);
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " + extension.name);
}
@@ -223,7 +223,7 @@ void consumeOnTrade(HandshakeContext context,
}
if (extension.onTradeConsumer == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore impact of unsupported extension: " +
extension.name);
@@ -232,7 +232,7 @@ void consumeOnTrade(HandshakeContext context,
}
extension.consumeOnTrade(context, handshakeMessage);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Populated with extension: " + extension.name);
}
}
@@ -245,7 +245,7 @@ void produce(HandshakeContext context,
SSLExtension[] extensions) throws IOException {
for (SSLExtension extension : extensions) {
if (extMap.containsKey(extension)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore, duplicated extension: " +
extension.name);
@@ -254,7 +254,7 @@ void produce(HandshakeContext context,
}
if (extension.networkProducer == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore, no extension producer defined: " +
extension.name);
@@ -267,7 +267,7 @@ void produce(HandshakeContext context,
extMap.put(extension, encoded);
encodedLength += encoded.length + 4; // extension_type (2)
// extension_data length(2)
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
// The extension is not available in the context.
SSLLogger.fine(
"Ignore, context unavailable extension: " +
@@ -284,7 +284,7 @@ void reproduce(HandshakeContext context,
SSLExtension[] extensions) throws IOException {
for (SSLExtension extension : extensions) {
if (extension.networkProducer == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore, no extension producer defined: " +
extension.name);
@@ -305,7 +305,7 @@ void reproduce(HandshakeContext context,
encodedLength += encoded.length + 4;
// extension_type (2)
// extension_data length(2)
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
// The extension is not available in the context.
SSLLogger.fine(
"Ignore, context unavailable extension: " +
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLLogger.java b/src/java.base/share/classes/sun/security/ssl/SSLLogger.java
index f55ab27d297..7fa6fbf91b5 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLLogger.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLLogger.java
@@ -29,8 +29,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import java.lang.System.Logger;
-import java.lang.System.Logger.Level;
import java.nio.ByteBuffer;
import java.security.cert.Certificate;
import java.security.cert.Extension;
@@ -41,6 +39,7 @@
import java.time.format.DateTimeFormatter;
import java.util.*;
+import jdk.internal.vm.annotation.ForceInline;
import sun.security.util.HexDumpEncoder;
import sun.security.util.Debug;
import sun.security.x509.*;
@@ -58,10 +57,13 @@
* logging mechanisms. If the system property "javax.net.debug" is defined
* and non-empty, a private debug logger implemented in this class is used.
*/
-public final class SSLLogger {
+public final class SSLLogger implements System.Logger {
private static final System.Logger logger;
private static final String property;
- public static final boolean isOn;
+ private static final boolean isOn;
+
+ private final String loggerName;
+ private final boolean useCompactFormat;
static {
@@ -76,7 +78,7 @@ public final class SSLLogger {
help();
}
- logger = new SSLConsoleLogger("javax.net.ssl", p);
+ logger = new SSLLogger("javax.net.ssl", p);
}
isOn = true;
} else {
@@ -86,35 +88,10 @@ public final class SSLLogger {
}
}
- private static void help() {
- System.err.println();
- System.err.println("help print the help messages");
- System.err.println("expand expand debugging information");
- System.err.println();
- System.err.println("all turn on all debugging");
- System.err.println("ssl turn on ssl debugging");
- System.err.println();
- System.err.println("The following can be used with ssl:");
- System.err.println("\trecord enable per-record tracing");
- System.err.println("\thandshake print each handshake message");
- System.err.println("\tkeygen print key generation data");
- System.err.println("\tsession print session activity");
- System.err.println("\tdefaultctx print default SSL initialization");
- System.err.println("\tsslctx print SSLContext tracing");
- System.err.println("\tsessioncache print session cache tracing");
- System.err.println("\tkeymanager print key manager tracing");
- System.err.println("\ttrustmanager print trust manager tracing");
- System.err.println("\tpluggability print pluggability tracing");
- System.err.println();
- System.err.println("\thandshake debugging can be widened with:");
- System.err.println("\tdata hex dump of each handshake message");
- System.err.println("\tverbose verbose handshake message printing");
- System.err.println();
- System.err.println("\trecord debugging can be widened with:");
- System.err.println("\tplaintext hex dump of record plaintext");
- System.err.println("\tpacket print raw SSL/TLS packets");
- System.err.println();
- System.exit(0);
+ private SSLLogger(String loggerName, String options) {
+ this.loggerName = loggerName;
+ options = options.toLowerCase(Locale.ENGLISH);
+ this.useCompactFormat = !options.contains("expand");
}
/**
@@ -139,6 +116,11 @@ public static boolean isOn(String checkPoints) {
return true;
}
+ @ForceInline
+ public static boolean isOn() {
+ return isOn;
+ }
+
private static boolean hasOption(String option) {
option = option.toLowerCase(Locale.ENGLISH);
if (property.contains("all")) {
@@ -161,30 +143,30 @@ private static boolean hasOption(String option) {
}
public static void severe(String msg, Object... params) {
- SSLLogger.log(Level.ERROR, msg, params);
+ SSLLogger.log0(Level.ERROR, msg, params);
}
public static void warning(String msg, Object... params) {
- SSLLogger.log(Level.WARNING, msg, params);
+ SSLLogger.log0(Level.WARNING, msg, params);
}
public static void info(String msg, Object... params) {
- SSLLogger.log(Level.INFO, msg, params);
+ SSLLogger.log0(Level.INFO, msg, params);
}
public static void fine(String msg, Object... params) {
- SSLLogger.log(Level.DEBUG, msg, params);
+ SSLLogger.log0(Level.DEBUG, msg, params);
}
public static void finer(String msg, Object... params) {
- SSLLogger.log(Level.TRACE, msg, params);
+ SSLLogger.log0(Level.TRACE, msg, params);
}
public static void finest(String msg, Object... params) {
- SSLLogger.log(Level.TRACE, msg, params);
+ SSLLogger.log0(Level.TRACE, msg, params);
}
- private static void log(Level level, String msg, Object... params) {
+ private static void log0(Level level, String msg, Object... params) {
if (logger != null && logger.isLoggable(level)) {
if (params == null || params.length == 0) {
logger.log(level, msg);
@@ -192,8 +174,8 @@ private static void log(Level level, String msg, Object... params) {
try {
String formatted =
SSLSimpleFormatter.formatParameters(params);
- // use the customized log method for SSLConsoleLogger
- if (logger instanceof SSLConsoleLogger) {
+ // use the customized log method for SSLLogger
+ if (logger instanceof SSLLogger) {
logger.log(level, msg, formatted);
} else {
logger.log(level, msg + ":" + LINE_SEP + formatted);
@@ -205,6 +187,37 @@ private static void log(Level level, String msg, Object... params) {
}
}
+ private static void help() {
+ System.err.println();
+ System.err.println("help print the help messages");
+ System.err.println("expand expand debugging information");
+ System.err.println();
+ System.err.println("all turn on all debugging");
+ System.err.println("ssl turn on ssl debugging");
+ System.err.println();
+ System.err.println("The following can be used with ssl:");
+ System.err.println("\trecord enable per-record tracing");
+ System.err.println("\thandshake print each handshake message");
+ System.err.println("\tkeygen print key generation data");
+ System.err.println("\tsession print session activity");
+ System.err.println("\tdefaultctx print default SSL initialization");
+ System.err.println("\tsslctx print SSLContext tracing");
+ System.err.println("\tsessioncache print session cache tracing");
+ System.err.println("\tkeymanager print key manager tracing");
+ System.err.println("\ttrustmanager print trust manager tracing");
+ System.err.println("\tpluggability print pluggability tracing");
+ System.err.println();
+ System.err.println("\thandshake debugging can be widened with:");
+ System.err.println("\tdata hex dump of each handshake message");
+ System.err.println("\tverbose verbose handshake message printing");
+ System.err.println();
+ System.err.println("\trecord debugging can be widened with:");
+ System.err.println("\tplaintext hex dump of record plaintext");
+ System.err.println("\tpacket print raw SSL/TLS packets");
+ System.err.println();
+ System.exit(0);
+ }
+
static String toString(Object... params) {
try {
return SSLSimpleFormatter.formatParameters(params);
@@ -216,65 +229,55 @@ static String toString(Object... params) {
// Logs a warning message and always returns false. This method
// can be used as an OR Predicate to add a log in a stream filter.
public static boolean logWarning(String option, String s) {
- if (SSLLogger.isOn && SSLLogger.isOn(option)) {
+ if (SSLLogger.isOn() && SSLLogger.isOn(option)) {
SSLLogger.warning(s);
}
return false;
}
- private static class SSLConsoleLogger implements Logger {
- private final String loggerName;
- private final boolean useCompactFormat;
-
- SSLConsoleLogger(String loggerName, String options) {
- this.loggerName = loggerName;
- options = options.toLowerCase(Locale.ENGLISH);
- this.useCompactFormat = !options.contains("expand");
- }
-
- @Override
- public String getName() {
- return loggerName;
- }
+ @Override
+ public String getName() {
+ return loggerName;
+ }
- @Override
- public boolean isLoggable(Level level) {
- return level != Level.OFF;
- }
+ @Override
+ public boolean isLoggable(Level level) {
+ return level != Level.OFF;
+ }
- @Override
- public void log(Level level,
- ResourceBundle rb, String message, Throwable thrwbl) {
- if (isLoggable(level)) {
- try {
- String formatted =
+ @Override
+ public void log(Level level,
+ ResourceBundle rb, String message, Throwable thrwbl) {
+ if (isLoggable(level)) {
+ try {
+ String formatted =
SSLSimpleFormatter.format(this, level, message, thrwbl);
- System.err.write(formatted.getBytes(UTF_8));
- } catch (Exception exp) {
- // ignore it, just for debugging.
- }
+ System.err.write(formatted.getBytes(UTF_8));
+ } catch (Exception exp) {
+ // ignore it, just for debugging.
}
}
+ }
- @Override
- public void log(Level level,
- ResourceBundle rb, String message, Object... params) {
- if (isLoggable(level)) {
- try {
- String formatted =
+ @Override
+ public void log(Level level,
+ ResourceBundle rb, String message, Object... params) {
+ if (isLoggable(level)) {
+ try {
+ String formatted =
SSLSimpleFormatter.format(this, level, message, params);
- System.err.write(formatted.getBytes(UTF_8));
- } catch (Exception exp) {
- // ignore it, just for debugging.
- }
+ System.err.write(formatted.getBytes(UTF_8));
+ } catch (Exception exp) {
+ // ignore it, just for debugging.
}
}
}
private static class SSLSimpleFormatter {
private static final String PATTERN = "yyyy-MM-dd kk:mm:ss.SSS z";
- private static final DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern(PATTERN, Locale.ENGLISH)
- .withZone(ZoneId.systemDefault());
+ private static final DateTimeFormatter dateTimeFormat =
+ DateTimeFormatter.ofPattern(PATTERN, Locale.ENGLISH)
+ .withZone(ZoneId.systemDefault());
private static final MessageFormat basicCertFormat = new MessageFormat(
"""
@@ -290,68 +293,68 @@ private static class SSLSimpleFormatter {
Locale.ENGLISH);
private static final MessageFormat extendedCertFormat =
- new MessageFormat(
- """
- "version" : "v{0}",
- "serial number" : "{1}",
- "signature algorithm": "{2}",
- "issuer" : "{3}",
- "not before" : "{4}",
- "not after" : "{5}",
- "subject" : "{6}",
- "subject public key" : "{7}",
- "extensions" : [
- {8}
- ]
- """,
- Locale.ENGLISH);
+ new MessageFormat(
+ """
+ "version" : "v{0}",
+ "serial number" : "{1}",
+ "signature algorithm": "{2}",
+ "issuer" : "{3}",
+ "not before" : "{4}",
+ "not after" : "{5}",
+ "subject" : "{6}",
+ "subject public key" : "{7}",
+ "extensions" : [
+ {8}
+ ]
+ """,
+ Locale.ENGLISH);
private static final MessageFormat messageFormatNoParas =
- new MessageFormat(
- """
- '{'
- "logger" : "{0}",
- "level" : "{1}",
- "thread id" : "{2}",
- "thread name" : "{3}",
- "time" : "{4}",
- "caller" : "{5}",
- "message" : "{6}"
- '}'
- """,
- Locale.ENGLISH);
+ new MessageFormat(
+ """
+ '{'
+ "logger" : "{0}",
+ "level" : "{1}",
+ "thread id" : "{2}",
+ "thread name" : "{3}",
+ "time" : "{4}",
+ "caller" : "{5}",
+ "message" : "{6}"
+ '}'
+ """,
+ Locale.ENGLISH);
private static final MessageFormat messageCompactFormatNoParas =
- new MessageFormat(
- "{0}|{1}|{2}|{3}|{4}|{5}|{6}" + LINE_SEP,
- Locale.ENGLISH);
+ new MessageFormat(
+ "{0}|{1}|{2}|{3}|{4}|{5}|{6}" + LINE_SEP,
+ Locale.ENGLISH);
private static final MessageFormat messageFormatWithParas =
- new MessageFormat(
- """
- '{'
- "logger" : "{0}",
- "level" : "{1}",
- "thread id" : "{2}",
- "thread name" : "{3}",
- "time" : "{4}",
- "caller" : "{5}",
- "message" : "{6}",
- "specifics" : [
- {7}
- ]
- '}'
- """,
- Locale.ENGLISH);
+ new MessageFormat(
+ """
+ '{'
+ "logger" : "{0}",
+ "level" : "{1}",
+ "thread id" : "{2}",
+ "thread name" : "{3}",
+ "time" : "{4}",
+ "caller" : "{5}",
+ "message" : "{6}",
+ "specifics" : [
+ {7}
+ ]
+ '}'
+ """,
+ Locale.ENGLISH);
private static final MessageFormat messageCompactFormatWithParas =
- new MessageFormat(
- """
- {0}|{1}|{2}|{3}|{4}|{5}|{6} (
- {7}
- )
- """,
- Locale.ENGLISH);
+ new MessageFormat(
+ """
+ {0}|{1}|{2}|{3}|{4}|{5}|{6} (
+ {7}
+ )
+ """,
+ Locale.ENGLISH);
private static final MessageFormat keyObjectFormat = new MessageFormat(
"""
@@ -364,8 +367,8 @@ private static class SSLSimpleFormatter {
// log message
// log message
// ...
- private static String format(SSLConsoleLogger logger, Level level,
- String message, Object ... parameters) {
+ private static String format(SSLLogger logger, Level level,
+ String message, Object... parameters) {
if (parameters == null || parameters.length == 0) {
Object[] messageFields = {
@@ -394,9 +397,9 @@ private static String format(SSLConsoleLogger logger, Level level,
formatCaller(),
message,
(logger.useCompactFormat ?
- formatParameters(parameters) :
- Utilities.indent(formatParameters(parameters)))
- };
+ formatParameters(parameters) :
+ Utilities.indent(formatParameters(parameters)))
+ };
if (logger.useCompactFormat) {
return messageCompactFormatWithParas.format(messageFields);
@@ -414,7 +417,7 @@ private static String formatCaller() {
.findFirst().orElse("unknown caller"));
}
- private static String formatParameters(Object ... parameters) {
+ private static String formatParameters(Object... parameters) {
StringBuilder builder = new StringBuilder(512);
boolean isFirst = true;
for (Object parameter : parameters) {
@@ -425,21 +428,21 @@ private static String formatParameters(Object ... parameters) {
}
if (parameter instanceof Throwable) {
- builder.append(formatThrowable((Throwable)parameter));
+ builder.append(formatThrowable((Throwable) parameter));
} else if (parameter instanceof Certificate) {
- builder.append(formatCertificate((Certificate)parameter));
+ builder.append(formatCertificate((Certificate) parameter));
} else if (parameter instanceof ByteArrayInputStream) {
builder.append(formatByteArrayInputStream(
- (ByteArrayInputStream)parameter));
+ (ByteArrayInputStream) parameter));
} else if (parameter instanceof ByteBuffer) {
- builder.append(formatByteBuffer((ByteBuffer)parameter));
+ builder.append(formatByteBuffer((ByteBuffer) parameter));
} else if (parameter instanceof byte[]) {
builder.append(formatByteArrayInputStream(
- new ByteArrayInputStream((byte[])parameter)));
+ new ByteArrayInputStream((byte[]) parameter)));
} else if (parameter instanceof Map.Entry) {
@SuppressWarnings("unchecked")
Map.Entry mapParameter =
- (Map.Entry)parameter;
+ (Map.Entry) parameter;
builder.append(formatMapEntry(mapParameter));
} else {
builder.append(formatObject(parameter));
@@ -462,7 +465,7 @@ private static String formatThrowable(Throwable throwable) {
Object[] fields = {
"throwable",
builder.toString()
- };
+ };
return keyObjectFormat.format(fields);
}
@@ -479,7 +482,7 @@ private static String formatCertificate(Certificate certificate) {
StringBuilder builder = new StringBuilder(512);
try {
X509CertImpl x509 =
- X509CertImpl.toImpl((X509Certificate)certificate);
+ X509CertImpl.toImpl((X509Certificate) certificate);
X509CertInfo certInfo = x509.getInfo();
CertificateExtensions certExts = certInfo.getExtensions();
if (certExts == null) {
@@ -528,7 +531,7 @@ private static String formatCertificate(Certificate certificate) {
Object[] fields = {
"certificate",
builder.toString()
- };
+ };
return Utilities.indent(keyObjectFormat.format(fields));
}
@@ -591,13 +594,13 @@ private static String formatMapEntry(Map.Entry entry) {
formatted = builder.toString();
} else if (value instanceof byte[]) {
formatted = "\"" + key + "\": \"" +
- Utilities.toHexString((byte[])value) + "\"";
+ Utilities.toHexString((byte[]) value) + "\"";
} else if (value instanceof Byte) {
formatted = "\"" + key + "\": \"" +
- HexFormat.of().toHexDigits((byte)value) + "\"";
+ HexFormat.of().toHexDigits((byte) value) + "\"";
} else {
formatted = "\"" + key + "\": " +
- "\"" + value.toString() + "\"";
+ "\"" + value.toString() + "\"";
}
return Utilities.indent(formatted);
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java b/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java
index db5887c5e8e..4de29b7570a 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLMasterKeyDerivation.java
@@ -29,7 +29,6 @@
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.ProviderException;
-import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import sun.security.internal.spec.TlsMasterSecretParameterSpec;
@@ -152,7 +151,7 @@ public SecretKey deriveKey(String typeNotUsed) throws IOException {
//
// For RSA premaster secrets, do not signal a protocol error
// due to the Bleichenbacher attack. See comments further down.
- if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("handshake")) {
SSLLogger.fine("RSA master secret generation error.", iae);
}
throw new ProviderException(iae);
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java
index 4baa3304fee..f713f723ea0 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java
@@ -339,7 +339,7 @@ private int getDefaults(boolean server) {
if (t < 0 ||
t > NewSessionTicket.MAX_TICKET_LIFETIME) {
timeout = DEFAULT_SESSION_TIMEOUT;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Invalid timeout given " +
"jdk.tls.server.sessionTicketTimeout: " + t +
". Set to default value " + timeout);
@@ -349,7 +349,7 @@ private int getDefaults(boolean server) {
}
} catch (NumberFormatException e) {
setSessionTimeout(DEFAULT_SESSION_TIMEOUT);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Invalid timeout for " +
"jdk.tls.server.sessionTicketTimeout: " + s +
". Set to default value " + timeout);
@@ -363,7 +363,7 @@ private int getDefaults(boolean server) {
if (defaultCacheLimit >= 0) {
return defaultCacheLimit;
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"invalid System Property javax.net.ssl.sessionCacheSize, " +
"use the default session cache size (" +
@@ -371,7 +371,7 @@ private int getDefaults(boolean server) {
}
} catch (Exception e) {
// unlikely, log it for safe
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"the System Property javax.net.ssl.sessionCacheSize is " +
"not available, use the default value (" +
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java
index 1bf561c47e6..f3a4b964158 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java
@@ -223,7 +223,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
this.identificationProtocol = hc.sslConfig.identificationProtocol;
this.boundValues = new ConcurrentHashMap<>();
- if (SSLLogger.isOn && SSLLogger.isOn("session")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("session")) {
SSLLogger.finest("Session initialized: " + this);
}
}
@@ -256,7 +256,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
this.maximumPacketSize = baseSession.maximumPacketSize;
this.boundValues = baseSession.boundValues;
- if (SSLLogger.isOn && SSLLogger.isOn("session")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("session")) {
SSLLogger.finest("Session initialized: " + this);
}
}
@@ -455,7 +455,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
if (same) {
this.localCerts = ((X509Possession) pos).popCerts;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,session")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,session")) {
SSLLogger.fine("Restored " + len
+ " local certificates from session ticket"
+ " for algorithms " + Arrays.toString(certAlgs));
@@ -463,7 +463,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
} else {
this.localCerts = null;
this.invalidated = true;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,session")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,session")) {
SSLLogger.warning("Local certificates can not be restored "
+ "from session ticket "
+ "for algorithms " + Arrays.toString(certAlgs));
@@ -482,7 +482,7 @@ boolean isStatelessable() {
// If there is no getMasterSecret with TLS1.2 or under, do not resume.
if (!protocolVersion.useTLS13PlusSpec() &&
getMasterSecret().getEncoded() == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("No MasterSecret, cannot make stateless" +
" ticket");
}
@@ -490,7 +490,7 @@ boolean isStatelessable() {
}
if (boundValues != null && boundValues.size() > 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("There are boundValues, cannot make" +
" stateless ticket");
}
@@ -862,7 +862,7 @@ CipherSuite getSuite() {
void setSuite(CipherSuite suite) {
cipherSuite = suite;
- if (SSLLogger.isOn && SSLLogger.isOn("session")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("session")) {
SSLLogger.finest("Negotiating session: " + this);
}
}
@@ -1132,7 +1132,7 @@ public void invalidate() {
return;
}
invalidated = true;
- if (SSLLogger.isOn && SSLLogger.isOn("session")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("session")) {
SSLLogger.finest("Invalidated session: " + this);
}
for (SSLSessionImpl child : childSessions) {
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
index be95a09006f..ab01a9d85be 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, 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
@@ -370,7 +370,7 @@ public SSLSession getSession() {
// start handshaking, if failed, the connection will be closed.
ensureNegotiated(false);
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("handshake")) {
SSLLogger.severe("handshake failed", ioe);
}
@@ -573,7 +573,7 @@ public void close() throws IOException {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("duplex close of SSLSocket");
}
@@ -591,7 +591,7 @@ public void close() throws IOException {
}
} catch (IOException ioe) {
// ignore the exception
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("SSLSocket duplex close failed. Debug info only. Exception details:", ioe);
}
} finally {
@@ -601,7 +601,7 @@ public void close() throws IOException {
closeSocket(false);
} catch (IOException ioe) {
// ignore the exception
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("SSLSocket close failed. Debug info only. Exception details:", ioe);
}
} finally {
@@ -696,7 +696,7 @@ void closeNotify(boolean useUserCanceled) throws IOException {
"close_notify message cannot be sent.");
} else {
super.shutdownOutput();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"SSLSocket output duplex close failed: " +
"SO_LINGER timeout, " +
@@ -717,7 +717,7 @@ void closeNotify(boolean useUserCanceled) throws IOException {
// failed to send the close_notify message.
//
conContext.conSession.invalidate();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"Invalidate the session: SO_LINGER timeout, " +
"close_notify message cannot be sent.");
@@ -832,7 +832,7 @@ private void shutdownInput(
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close inbound of SSLSocket");
}
@@ -868,7 +868,7 @@ public void shutdownOutput() throws IOException {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close outbound of SSLSocket");
}
conContext.closeOutbound();
@@ -1027,7 +1027,7 @@ public int read(byte[] b, int off, int len) throws IOException {
// filed is checked here, in case the closing process is
// still in progress.
if (hasDepleted) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("The input stream has been depleted");
}
@@ -1048,7 +1048,7 @@ public int read(byte[] b, int off, int len) throws IOException {
// Double check if the input stream has been depleted.
if (hasDepleted) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("The input stream is closing");
}
@@ -1134,7 +1134,7 @@ public long skip(long n) throws IOException {
@Override
public void close() throws IOException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("Closing input stream");
}
@@ -1142,7 +1142,7 @@ public void close() throws IOException {
SSLSocketImpl.this.close();
} catch (IOException ioe) {
// ignore the exception
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("input stream close failed. Debug info only. Exception details:", ioe);
}
}
@@ -1218,7 +1218,7 @@ private void readLockedDeplete() {
socketInputRecord.deplete(
conContext.isNegotiated && (getSoTimeout() > 0));
} catch (Exception ex) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"input stream close depletion failed", ex);
}
@@ -1327,7 +1327,7 @@ public void write(byte[] b,
@Override
public void close() throws IOException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("Closing output stream");
}
@@ -1335,7 +1335,7 @@ public void close() throws IOException {
SSLSocketImpl.this.close();
} catch (IOException ioe) {
// ignore the exception
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("output stream close failed. Debug info only. Exception details:", ioe);
}
}
@@ -1543,7 +1543,7 @@ private void tryKeyUpdate() throws IOException {
if ((conContext.handshakeContext == null) &&
!conContext.isOutboundClosed() &&
!conContext.isBroken) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("trigger key update");
}
startHandshake();
@@ -1562,7 +1562,7 @@ private void tryNewSessionTicket() throws IOException {
!conContext.isOutboundClosed() &&
!conContext.isInboundClosed() &&
!conContext.isBroken) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("trigger new session ticket");
}
conContext.conSession.updateNST = false;
@@ -1670,7 +1670,7 @@ public void setHost(String host) {
* This method never returns normally, it always throws an IOException.
*/
private void handleException(Exception cause) throws IOException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("handling exception", cause);
}
@@ -1747,7 +1747,7 @@ public boolean useDelegatedTask() {
@Override
public void shutdown() throws IOException {
if (!isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close the underlying socket");
}
@@ -1773,7 +1773,7 @@ public String toString() {
}
private void closeSocket(boolean selfInitiated) throws IOException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close the SSL connection " +
(selfInitiated ? "(initiative)" : "(passive)"));
}
@@ -1828,7 +1828,7 @@ private void closeSocket(boolean selfInitiated) throws IOException {
* transport without waiting for the responding close_notify.
*/
private void waitForClose() throws IOException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("wait for close_notify or alert");
}
@@ -1838,7 +1838,7 @@ private void waitForClose() throws IOException {
try {
Plaintext plainText = decode(null);
// discard and continue
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
"discard plaintext while waiting for close",
plainText);
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java b/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java
index 09223a4485d..ce7ab630730 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, Azul Systems, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -210,7 +210,7 @@ private Plaintext[] decodeInputRecord() throws IOException, BadPaddingException
int contentLen = ((header[3] & 0xFF) << 8) +
(header[4] & 0xFF); // pos: 3, 4
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"READ: " +
ProtocolVersion.nameOf(majorVersion, minorVersion) +
@@ -243,7 +243,7 @@ private Plaintext[] decodeInputRecord() throws IOException, BadPaddingException
readFully(contentLen);
recordBody.flip();
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"READ: " +
ProtocolVersion.nameOf(majorVersion, minorVersion) +
@@ -406,7 +406,7 @@ private Plaintext[] handleUnknownRecord() throws IOException {
*/
os.write(SSLRecord.v2NoCipher); // SSLv2Hello
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
if (SSLLogger.isOn("record")) {
SSLLogger.fine(
"Requested to negotiate unsupported SSLv2!");
@@ -445,7 +445,7 @@ private Plaintext[] handleUnknownRecord() throws IOException {
ByteBuffer converted = convertToClientHello(recordBody);
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine(
"[Converted] ClientHello", converted);
}
@@ -488,13 +488,13 @@ private int readHeader() throws IOException {
private static int read(InputStream is, byte[] buf, int off, int len) throws IOException {
int readLen = is.read(buf, off, len);
if (readLen < 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw read: EOF");
}
throw new EOFException("SSL peer shut down incorrectly");
}
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
ByteBuffer bb = ByteBuffer.wrap(buf, off, readLen);
SSLLogger.fine("Raw read", bb);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java b/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java
index a7809754ed0..e83ad15db22 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, 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
@@ -55,7 +55,7 @@ void encodeAlert(byte level, byte description) throws IOException {
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"alert message: " + Alert.nameOf(description));
}
@@ -67,7 +67,7 @@ void encodeAlert(byte level, byte description) throws IOException {
write(level);
write(description);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine("WRITE: " + protocolVersion.name +
" " + ContentType.ALERT.name +
"(" + Alert.nameOf(description) + ")" +
@@ -81,7 +81,7 @@ void encodeAlert(byte level, byte description) throws IOException {
deliverStream.write(buf, 0, count); // may throw IOException
deliverStream.flush(); // may throw IOException
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write",
(new ByteArrayInputStream(buf, 0, count)));
}
@@ -99,7 +99,7 @@ void encodeHandshake(byte[] source,
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"handshake message",
ByteBuffer.wrap(source, offset, length));
@@ -127,7 +127,7 @@ void encodeHandshake(byte[] source,
int limit = v2ClientHello.limit();
handshakeHash.deliver(record, 2, (limit - 2));
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: SSLv2 ClientHello message" +
", length = " + limit);
@@ -141,7 +141,7 @@ void encodeHandshake(byte[] source,
deliverStream.write(record, 0, limit);
deliverStream.flush();
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write",
(new ByteArrayInputStream(record, 0, limit)));
}
@@ -177,7 +177,7 @@ void encodeHandshake(byte[] source,
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name +
" " + ContentType.HANDSHAKE.name +
@@ -191,7 +191,7 @@ void encodeHandshake(byte[] source,
deliverStream.write(buf, 0, count); // may throw IOException
deliverStream.flush(); // may throw IOException
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write",
(new ByteArrayInputStream(buf, 0, count)));
}
@@ -212,7 +212,7 @@ void encodeChangeCipherSpec() throws IOException {
recordLock.lock();
try {
if (isClosed()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound has closed, ignore outbound " +
"change_cipher_spec message");
}
@@ -231,7 +231,7 @@ void encodeChangeCipherSpec() throws IOException {
deliverStream.write(buf, 0, count); // may throw IOException
// deliverStream.flush(); // flush in Finished
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write",
(new ByteArrayInputStream(buf, 0, count)));
}
@@ -257,7 +257,7 @@ public void flush() throws IOException {
return;
}
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name +
" " + ContentType.HANDSHAKE.name +
@@ -271,7 +271,7 @@ public void flush() throws IOException {
deliverStream.write(buf, 0, count); // may throw IOException
deliverStream.flush(); // may throw IOException
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write",
(new ByteArrayInputStream(buf, 0, count)));
}
@@ -293,7 +293,7 @@ void deliver(byte[] source, int offset, int length) throws IOException {
}
if (writeCipher.authenticator.seqNumOverflow()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
"sequence number extremely close to overflow " +
"(2^64-1 packets). Closing connection.");
@@ -330,7 +330,7 @@ void deliver(byte[] source, int offset, int length) throws IOException {
count = position;
write(source, offset, fragLen);
- if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("record")) {
SSLLogger.fine(
"WRITE: " + protocolVersion.name +
" " + ContentType.APPLICATION_DATA.name +
@@ -345,7 +345,7 @@ void deliver(byte[] source, int offset, int length) throws IOException {
deliverStream.write(buf, 0, count); // may throw IOException
deliverStream.flush(); // may throw IOException
- if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("packet")) {
SSLLogger.fine("Raw write",
(new ByteArrayInputStream(buf, 0, count)));
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLTransport.java b/src/java.base/share/classes/sun/security/ssl/SSLTransport.java
index c248b48fb0a..9298e016f63 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLTransport.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLTransport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2025, 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
@@ -113,7 +113,7 @@ static Plaintext decode(TransportContext context,
// Code to deliver SSLv2 error message for SSL/TLS connections.
if (!context.sslContext.isDTLS()) {
context.outputRecord.encodeV2NoCipher();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("may be talking to SSLv2");
}
}
@@ -161,7 +161,7 @@ static Plaintext decode(TransportContext context,
if (context.handshakeContext != null &&
context.handshakeContext.sslConfig.enableRetransmissions &&
context.sslContext.isDTLS()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,verbose")) {
SSLLogger.finest("retransmitted handshake flight");
}
@@ -181,7 +181,7 @@ static Plaintext decode(TransportContext context,
// Note that JDK does not support 0-RTT yet. Otherwise, it is
// needed to check early_data.
if (!context.isNegotiated) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,verbose")) {
SSLLogger.warning("unexpected application data " +
"before handshake completion");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ServerHello.java b/src/java.base/share/classes/sun/security/ssl/ServerHello.java
index 1d2faa5351f..76c266a628a 100644
--- a/src/java.base/share/classes/sun/security/ssl/ServerHello.java
+++ b/src/java.base/share/classes/sun/security/ssl/ServerHello.java
@@ -365,7 +365,7 @@ public byte[] produce(ConnectionContext context,
shc.sslConfig.getEnabledExtensions(
SSLHandshake.SERVER_HELLO, shc.negotiatedProtocol);
shm.extensions.produce(shc, serverHelloExtensions);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced ServerHello handshake message", shm);
}
@@ -440,7 +440,7 @@ private static KeyExchangeProperties chooseCipherSuite(
}
// The cipher suite has been negotiated.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("use cipher suite " + cs.name);
}
@@ -453,7 +453,7 @@ private static KeyExchangeProperties chooseCipherSuite(
if (ke != null) {
SSLPossession[] hcds = ke.createPossessions(shc);
if ((hcds != null) && (hcds.length != 0)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"use legacy cipher suite " + cs.name);
}
@@ -570,7 +570,7 @@ public byte[] produce(ConnectionContext context,
shc.sslConfig.getEnabledExtensions(
SSLHandshake.SERVER_HELLO, shc.negotiatedProtocol);
shm.extensions.produce(shc, serverHelloExtensions);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Produced ServerHello handshake message", shm);
}
@@ -723,14 +723,14 @@ private static CipherSuite chooseCipherSuite(
}
// The cipher suite has been negotiated.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("use cipher suite " + cs.name);
}
return cs;
}
if (legacySuite != null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"use legacy cipher suite " + legacySuite.name);
}
@@ -783,7 +783,7 @@ public byte[] produce(ConnectionContext context,
shc.sslConfig.getEnabledExtensions(
SSLHandshake.HELLO_RETRY_REQUEST, shc.negotiatedProtocol);
hhrm.extensions.produce(shc, serverHelloExtensions);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced HelloRetryRequest handshake message", hhrm);
}
@@ -845,7 +845,7 @@ public byte[] produce(ConnectionContext context,
shc.sslConfig.getEnabledExtensions(
SSLHandshake.MESSAGE_HASH, shc.negotiatedProtocol);
hhrm.extensions.produce(shc, serverHelloExtensions);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Reproduced HelloRetryRequest handshake message", hhrm);
}
@@ -886,7 +886,7 @@ public void consume(ConnectionContext context,
}
ServerHelloMessage shm = new ServerHelloMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Consuming ServerHello handshake message", shm);
}
@@ -931,7 +931,7 @@ private void onHelloRetryRequest(ClientHandshakeContext chc,
}
chc.negotiatedProtocol = serverVersion;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Negotiated protocol version: " + serverVersion.name);
}
@@ -986,7 +986,7 @@ private void onServerHello(ClientHandshakeContext chc,
chc.conContext.protocolVersion = chc.negotiatedProtocol;
chc.conContext.outputRecord.setVersion(chc.negotiatedProtocol);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Negotiated protocol version: " + serverVersion.name);
}
@@ -1132,7 +1132,7 @@ public void consume(ConnectionContext context,
chc.handshakeSession = new SSLSessionImpl(chc,
chc.negotiatedCipherSuite, newId);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Locally assigned Session Id: " +
newId.toString());
}
@@ -1204,7 +1204,7 @@ public void consume(ConnectionContext context,
private static void setUpPskKD(HandshakeContext hc,
SecretKey psk) throws SSLHandshakeException {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Using PSK to derive early secret");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ServerHelloDone.java b/src/java.base/share/classes/sun/security/ssl/ServerHelloDone.java
index 7136b36ffc2..a86257ab3d0 100644
--- a/src/java.base/share/classes/sun/security/ssl/ServerHelloDone.java
+++ b/src/java.base/share/classes/sun/security/ssl/ServerHelloDone.java
@@ -93,7 +93,7 @@ public byte[] produce(ConnectionContext context,
ServerHandshakeContext shc = (ServerHandshakeContext)context;
ServerHelloDoneMessage shdm = new ServerHelloDoneMessage(shc);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Produced ServerHelloDone handshake message", shdm);
}
@@ -147,7 +147,7 @@ public void consume(ConnectionContext context,
ServerHelloDoneMessage shdm =
new ServerHelloDoneMessage(chc, message);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Consuming ServerHelloDone handshake message", shdm);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/ServerNameExtension.java b/src/java.base/share/classes/sun/security/ssl/ServerNameExtension.java
index 96c3fe2fa6a..1b3c8ec3eba 100644
--- a/src/java.base/share/classes/sun/security/ssl/ServerNameExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/ServerNameExtension.java
@@ -216,7 +216,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(CH_SERVER_NAME)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore unavailable server_name extension");
}
@@ -261,7 +261,7 @@ public byte[] produce(ConnectionContext context,
return extData;
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("Unable to indicate server name");
}
return null;
@@ -287,7 +287,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(CH_SERVER_NAME)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " + CH_SERVER_NAME.name);
}
@@ -305,7 +305,7 @@ public void consume(ConnectionContext context,
if (!shc.sslConfig.sniMatchers.isEmpty()) {
sni = chooseSni(shc.sslConfig.sniMatchers, spec.serverNames);
if (sni != null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"server name indication (" +
sni + ") is accepted");
@@ -322,7 +322,7 @@ public void consume(ConnectionContext context,
// connection with a "missing_extension" alert.
//
// We do not reject client without SNI extension currently.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"no server name matchers, " +
"ignore server name indication");
@@ -347,7 +347,7 @@ public void consume(ConnectionContext context,
// so don't include the pre-shared key in the
// ServerHello handshake message
shc.handshakeExtensions.remove(SH_PRE_SHARED_KEY);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"abort session resumption, " +
"different server name indication used");
@@ -441,7 +441,7 @@ public byte[] produce(ConnectionContext context,
CHServerNamesSpec spec = (CHServerNamesSpec)
shc.handshakeExtensions.get(CH_SERVER_NAME);
if (spec == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable extension: " + SH_SERVER_NAME.name);
}
@@ -451,7 +451,7 @@ public byte[] produce(ConnectionContext context,
// When resuming a session, the server MUST NOT include a
// server_name extension in the server hello.
if (shc.isResumption || shc.negotiatedServerName == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"No expected server name indication response");
}
@@ -528,7 +528,7 @@ public byte[] produce(ConnectionContext context,
CHServerNamesSpec spec = (CHServerNamesSpec)
shc.handshakeExtensions.get(CH_SERVER_NAME);
if (spec == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"Ignore unavailable extension: " + EE_SERVER_NAME.name);
}
@@ -538,7 +538,7 @@ public byte[] produce(ConnectionContext context,
// When resuming a session, the server MUST NOT include a
// server_name extension in the server hello.
if (shc.isResumption || shc.negotiatedServerName == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest(
"No expected server name indication response");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java b/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java
index 9a84bbad8fd..1a0283cf859 100644
--- a/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java
@@ -93,7 +93,7 @@ final class SessionTicketExtension {
kt = Integer.parseInt(s) * 1000; // change to ms
if (kt < 0 ||
kt > NewSessionTicket.MAX_TICKET_LIFETIME) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Invalid timeout for " +
"jdk.tls.server.statelessKeyTimeout: " +
kt + ". Set to default value " +
@@ -103,7 +103,7 @@ final class SessionTicketExtension {
}
} catch (NumberFormatException e) {
kt = TIMEOUT_DEFAULT;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Invalid timeout for " +
"jdk.tls.server.statelessKeyTimeout: " + s +
". Set to default value " + TIMEOUT_DEFAULT +
@@ -252,7 +252,7 @@ byte[] encrypt(HandshakeContext hc, SSLSessionImpl session) {
Integer.BYTES + iv.length + 1, encrypted.length);
return result;
} catch (Exception e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Encryption failed." + e);
}
return new byte[0];
@@ -294,7 +294,7 @@ ByteBuffer decrypt(HandshakeContext hc) {
return out;
} catch (Exception e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Decryption failed." + e);
}
}
@@ -309,7 +309,7 @@ private static byte[] compress(byte[] input) throws IOException {
gos.write(input, 0, decompressedLen);
gos.finish();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("decompressed bytes: " + decompressedLen
+ "; compressed bytes: " + baos.size());
}
@@ -328,7 +328,7 @@ private static ByteBuffer decompress(ByteBuffer input)
new ByteArrayInputStream(bytes))) {
byte[] out = gis.readAllBytes();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("compressed bytes: " + compressedLen
+ "; decompressed bytes: " + out.length);
}
@@ -394,7 +394,7 @@ public byte[] produce(ConnectionContext context,
// If the context does not allow stateless tickets, exit
if (!((SSLSessionContextImpl)chc.sslContext.
engineGetClientSessionContext()).statelessEnabled()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Stateless resumption not supported");
}
return null;
@@ -406,7 +406,7 @@ public byte[] produce(ConnectionContext context,
if (!chc.isResumption || chc.resumingSession == null
|| chc.resumingSession.getPskIdentity() == null
|| chc.resumingSession.getProtocolVersion().useTLS13PlusSpec()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Stateless resumption supported");
}
return new byte[0];
@@ -450,7 +450,7 @@ public void consume(ConnectionContext context,
shc.statelessResumption = true;
if (buffer.remaining() == 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Client accepts session tickets.");
}
return;
@@ -462,11 +462,11 @@ public void consume(ConnectionContext context,
if (b != null) {
shc.resumingSession = new SSLSessionImpl(shc, b);
shc.isResumption = true;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Valid stateless session ticket found");
}
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Invalid stateless session ticket found");
}
}
@@ -546,7 +546,7 @@ public void absent(ConnectionContext context,
// Disable stateless resumption if server doesn't send the extension.
if (chc.statelessResumption) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.info(
"Server doesn't support stateless resumption");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java b/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java
index b298da05e9a..dddeb523516 100644
--- a/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java
@@ -182,7 +182,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(
SSLExtension.CH_SIGNATURE_ALGORITHMS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable signature_algorithms extension");
}
@@ -218,7 +218,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(
SSLExtension.CH_SIGNATURE_ALGORITHMS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable signature_algorithms extension");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java
index 5a8f103082b..b91fc17fd29 100644
--- a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java
+++ b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java
@@ -204,7 +204,7 @@ enum SigAlgParamSpec { // support RSASSA-PSS only now
NoSuchAlgorithmException | RuntimeException exp) {
// Signature.getParameters() may throw RuntimeException.
mediator = false;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"RSASSA-PSS signature with " + hash +
" is not supported by the underlying providers", exp);
@@ -297,7 +297,7 @@ enum SigAlgParamSpec { // support RSASSA-PSS only now
Signature.getInstance(algorithm);
} catch (Exception e) {
mediator = false;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Signature algorithm, " + algorithm +
", is not supported by the underlying providers");
@@ -432,7 +432,7 @@ private static List getSupportedAlgorithms(
for (SignatureScheme ss: schemesToCheck) {
if (!ss.isAvailable) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore unsupported signature scheme: " + ss.name);
@@ -451,12 +451,12 @@ private static List getSupportedAlgorithms(
if (isMatch) {
if (ss.isPermitted(constraints, scopes)) {
supported.add(ss);
- } else if (SSLLogger.isOn &&
+ } else if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore disabled signature scheme: " + ss.name);
}
- } else if (SSLLogger.isOn &&
+ } else if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore inactive signature scheme: " + ss.name);
@@ -476,7 +476,7 @@ static List getSupportedAlgorithms(
for (int ssid : algorithmIds) {
SignatureScheme ss = SignatureScheme.valueOf(ssid);
if (ss == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Unsupported signature scheme: " +
SignatureScheme.nameOf(ssid));
@@ -486,7 +486,7 @@ static List getSupportedAlgorithms(
&& ss.isAllowed(constraints, protocolVersion, scopes)) {
supported.add(ss);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Unsupported signature scheme: " + ss.name);
}
@@ -545,7 +545,7 @@ static Map.Entry getSignerOfPreferableAlgorithm(
}
}
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore the signature algorithm (" + ss +
@@ -574,7 +574,7 @@ static Map.Entry getSignerOfPreferableAlgorithm(
}
}
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore the legacy signature algorithm (" + ss +
@@ -660,7 +660,7 @@ private Signature getSigner(PrivateKey privateKey) {
return signer;
} catch (NoSuchAlgorithmException | InvalidKeyException |
InvalidAlgorithmParameterException nsae) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.finest(
"Ignore unsupported signature algorithm (" +
diff --git a/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java b/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java
index ec200c6e495..d8c4a8ccc3e 100644
--- a/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java
+++ b/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java
@@ -119,13 +119,13 @@ URI getURI(X509Certificate cert) {
if (cert.getExtensionValue(
PKIXExtensions.OCSPNoCheck_Id.toString()) != null) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"OCSP NoCheck extension found. OCSP will be skipped");
}
return null;
} else if (defaultResponder != null && respOverride) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Responder override: URI is " + defaultResponder);
}
@@ -165,7 +165,7 @@ Map get(CertStatusRequestType type,
Map responseMap = new HashMap<>();
List requestList = new ArrayList<>();
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Beginning check: Type = " + type + ", Chain length = " +
chain.length);
@@ -192,7 +192,7 @@ Map get(CertStatusRequestType type,
requestList.add(new OCSPFetchCall(sInfo, ocspReq));
}
} catch (IOException exc) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Exception during CertId creation: ", exc);
}
@@ -219,14 +219,14 @@ Map get(CertStatusRequestType type,
requestList.add(new OCSPFetchCall(sInfo, ocspReq));
}
} catch (IOException exc) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Exception during CertId creation: ", exc);
}
}
}
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("Unsupported status request type: " + type);
}
}
@@ -257,7 +257,7 @@ Map get(CertStatusRequestType type,
// that, otherwise just log the ExecutionException
Throwable cause = Optional.ofNullable(
exc.getCause()).orElse(exc);
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("Exception during OCSP fetch: " +
cause);
}
@@ -266,13 +266,13 @@ Map get(CertStatusRequestType type,
if (info != null && info.responseData != null) {
responseMap.put(info.cert,
info.responseData.ocspBytes);
- } else if (SSLLogger.isOn &&
+ } else if (SSLLogger.isOn() &&
SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Completed task had no response data");
}
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("Found cancelled task");
}
}
@@ -280,7 +280,7 @@ Map get(CertStatusRequestType type,
} catch (InterruptedException intex) {
// Log and reset the interrupted state
Thread.currentThread().interrupt();
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("Interrupt occurred while fetching: " +
intex);
}
@@ -308,7 +308,7 @@ private ResponseCacheEntry getFromCache(CertId cid,
for (Extension ext : ocspRequest.extensions) {
if (ext.getId().equals(
PKIXExtensions.OCSPNonce_Id.toString())) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Nonce extension found, skipping cache check");
}
@@ -323,14 +323,14 @@ private ResponseCacheEntry getFromCache(CertId cid,
// and do not return it as a cache hit.
if (respEntry != null && respEntry.nextUpdate != null &&
respEntry.nextUpdate.before(new Date())) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"nextUpdate threshold exceeded, purging from cache");
}
respEntry = null;
}
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Check cache for SN" + Debug.toString(cid.getSerialNumber())
+ ": " + (respEntry != null ? "HIT" : "MISS"));
@@ -493,7 +493,7 @@ public OCSPFetchCall(StatusInfo info, OCSPStatusRequest request) {
*/
@Override
public StatusInfo call() {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Starting fetch for SN " +
Debug.toString(statInfo.cid.getSerialNumber()));
@@ -505,13 +505,13 @@ public StatusInfo call() {
if (statInfo.responder == null) {
// If we have no URI then there's nothing to do
// but return.
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Null URI detected, OCSP fetch aborted");
}
return statInfo;
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Attempting fetch from " + statInfo.responder);
}
@@ -541,7 +541,7 @@ public StatusInfo call() {
statInfo.cid);
// Get the response status and act on it appropriately
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("OCSP Status: " + cacheEntry.status +
" (" + respBytes.length + " bytes)");
}
@@ -554,7 +554,7 @@ public StatusInfo call() {
addToCache(statInfo.cid, cacheEntry);
}
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("Caught exception: ", ioe);
}
}
@@ -573,12 +573,12 @@ private void addToCache(CertId certId, ResponseCacheEntry entry) {
// If no cache lifetime has been set on entries then
// don't cache this response if there is no nextUpdate field
if (entry.nextUpdate == null && cacheLifetime == 0) {
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine("Not caching this OCSP response");
}
} else {
responseCache.put(certId, entry);
- if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("respmgr")) {
SSLLogger.fine(
"Added response for SN " +
Debug.toString(certId.getSerialNumber()) +
@@ -600,7 +600,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
// is necessary. Also, we will only staple if we're doing a full
// handshake.
if (!shc.sslContext.isStaplingEnabled(false) || shc.isResumption) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("Staping disabled or is a resumed session");
}
return null;
@@ -623,7 +623,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
// selection yet, only accept a request if the ResponderId field
// is empty. Finally, we'll only do this in (D)TLS 1.2 or earlier.
if (statReqV2 != null && !shc.negotiatedProtocol.useTLS13PlusSpec()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.fine("SH Processing status_request_v2 extension");
}
// RFC 6961 stapling
@@ -660,7 +660,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
req = reqItems[ocspIdx];
type = CertStatusRequestType.valueOf(req.statusType);
} else {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Warning: No suitable request " +
"found in the status_request_v2 extension.");
@@ -678,7 +678,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
// we will try processing an asserted status_request.
if ((statReq != null) &&
(ext == null || type == null || req == null)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake,verbose")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake,verbose")) {
SSLLogger.fine("SH Processing status_request extension");
}
ext = SSLExtension.CH_STATUS_REQUEST;
@@ -692,7 +692,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
if (ocspReq.responderIds.isEmpty()) {
req = ocspReq;
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Warning: No suitable request " +
"found in the status_request extension.");
}
@@ -704,7 +704,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
// find a suitable StatusRequest, then stapling is disabled.
// The ext, type and req variables must have been set to continue.
if (type == null || req == null || ext == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine("No suitable status_request or " +
"status_request_v2, stapling is disabled");
}
@@ -721,7 +721,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
}
if (x509Possession == null) { // unlikely
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Warning: no X.509 certificates found. " +
"Stapling is disabled.");
}
@@ -743,7 +743,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
responses = statRespMgr.get(fetchType, req, certs,
shc.statusRespTimeout, TimeUnit.MILLISECONDS);
if (!responses.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Response manager returned " +
responses.size() + " entries.");
}
@@ -752,7 +752,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
if (type == CertStatusRequestType.OCSP) {
byte[] respDER = responses.get(certs[0]);
if (respDER == null || respDER.length == 0) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Warning: Null or zero-length " +
"response found for leaf certificate. " +
@@ -763,7 +763,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
}
params = new StaplingParameters(ext, type, req, responses);
} else {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Warning: no OCSP responses obtained. " +
"Stapling is disabled.");
}
@@ -771,7 +771,7 @@ static StaplingParameters processStapling(ServerHandshakeContext shc) {
} else {
// This should not happen, but if lazy initialization of the
// StatusResponseManager doesn't occur we should turn off stapling.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.finest("Warning: lazy initialization " +
"of the StatusResponseManager failed. " +
"Stapling is disabled.");
diff --git a/src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java b/src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java
index 6bf138f4e45..1fa2356d1de 100644
--- a/src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java
@@ -129,7 +129,7 @@ private static class X509Credentials {
X509Credentials cred = new X509Credentials((PrivateKey) key,
(X509Certificate[]) certs);
credentialsMap.put(alias, cred);
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine("found key for : " + alias, (Object[]) certs);
}
}
@@ -315,7 +315,7 @@ private String[] getAliases(List keyTypes, Principal[] issuers,
}
if (results == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine("KeyMgr: no matching key found");
}
return null;
diff --git a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java
index 57e5f8c9093..67cb37988a1 100644
--- a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java
@@ -164,7 +164,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(CH_SUPPORTED_GROUPS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable supported_groups extension");
}
@@ -177,7 +177,7 @@ public byte[] produce(ConnectionContext context,
for (String name : chc.sslConfig.namedGroups) {
NamedGroup ng = NamedGroup.nameOf(name);
if (ng == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unspecified named group: " + name);
}
@@ -193,14 +193,14 @@ public byte[] produce(ConnectionContext context,
ng.isSupported(chc.activeCipherSuites) &&
ng.isPermitted(chc.algorithmConstraints)) {
namedGroups.add(ng);
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore inactive or disabled named group: " + ng.name);
}
}
if (namedGroups.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("no available named group");
}
@@ -244,7 +244,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(CH_SUPPORTED_GROUPS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable supported_groups extension");
}
@@ -319,7 +319,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(EE_SUPPORTED_GROUPS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable supported_groups extension");
}
@@ -335,7 +335,7 @@ public byte[] produce(ConnectionContext context,
for (String name : shc.sslConfig.namedGroups) {
NamedGroup ng = NamedGroup.nameOf(name);
if (ng == null) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unspecified named group: " + name);
@@ -352,14 +352,14 @@ public byte[] produce(ConnectionContext context,
ng.isSupported(shc.activeCipherSuites) &&
ng.isPermitted(shc.algorithmConstraints)) {
namedGroups.add(ng);
- } else if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ } else if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore inactive or disabled named group: " + ng.name);
}
}
if (namedGroups.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning("no available named group");
}
@@ -399,7 +399,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(EE_SUPPORTED_GROUPS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable supported_groups extension");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SupportedVersionsExtension.java b/src/java.base/share/classes/sun/security/ssl/SupportedVersionsExtension.java
index 6efdcef0d29..58597c3008c 100644
--- a/src/java.base/share/classes/sun/security/ssl/SupportedVersionsExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/SupportedVersionsExtension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2025, 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
@@ -168,7 +168,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(CH_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
CH_SUPPORTED_VERSIONS.name);
@@ -216,7 +216,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(CH_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
CH_SUPPORTED_VERSIONS.name);
@@ -308,7 +308,7 @@ public byte[] produce(ConnectionContext context,
shc.handshakeExtensions.get(CH_SUPPORTED_VERSIONS);
if (svs == null) {
// Unlikely, no key_share extension requested.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Ignore unavailable supported_versions extension");
}
@@ -317,7 +317,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(SH_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
SH_SUPPORTED_VERSIONS.name);
@@ -356,7 +356,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(SH_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
SH_SUPPORTED_VERSIONS.name);
@@ -399,7 +399,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(HRR_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
HRR_SUPPORTED_VERSIONS.name);
@@ -441,7 +441,7 @@ public void consume(ConnectionContext context,
// Is it a supported and enabled extension?
if (!chc.sslConfig.isAvailable(HRR_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"Ignore unavailable extension: " +
HRR_SUPPORTED_VERSIONS.name);
@@ -483,7 +483,7 @@ public byte[] produce(ConnectionContext context,
// Is it a supported and enabled extension?
if (!shc.sslConfig.isAvailable(HRR_SUPPORTED_VERSIONS)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.fine(
"[Reproduce] Ignore unavailable extension: " +
HRR_SUPPORTED_VERSIONS.name);
diff --git a/src/java.base/share/classes/sun/security/ssl/TransportContext.java b/src/java.base/share/classes/sun/security/ssl/TransportContext.java
index 9595dc8b3fd..980d9c4a6ce 100644
--- a/src/java.base/share/classes/sun/security/ssl/TransportContext.java
+++ b/src/java.base/share/classes/sun/security/ssl/TransportContext.java
@@ -270,7 +270,7 @@ void warning(Alert alert) {
try {
outputRecord.encodeAlert(Alert.Level.WARNING.level, alert.id);
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"Warning: failed to send warning alert " + alert, ioe);
}
@@ -330,7 +330,7 @@ SSLException fatal(Alert alert, String diagnostic,
// so we'll do it here.
if (closeReason != null) {
if (cause == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"Closed transport, general or untracked problem");
}
@@ -341,7 +341,7 @@ SSLException fatal(Alert alert, String diagnostic,
if (cause instanceof SSLException) {
throw (SSLException)cause;
} else { // unlikely, but just in case.
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"Closed transport, unexpected rethrowing", cause);
}
@@ -364,7 +364,7 @@ SSLException fatal(Alert alert, String diagnostic,
}
// shutdown the transport
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.severe("Fatal (" + alert + "): " + diagnostic, cause);
}
@@ -380,7 +380,7 @@ SSLException fatal(Alert alert, String diagnostic,
try {
inputRecord.close();
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Fatal: input record closure failed", ioe);
}
@@ -411,7 +411,7 @@ SSLException fatal(Alert alert, String diagnostic,
try {
outputRecord.encodeAlert(Alert.Level.FATAL.level, alert.id);
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"Fatal: failed to send fatal alert " + alert, ioe);
}
@@ -424,7 +424,7 @@ SSLException fatal(Alert alert, String diagnostic,
try {
outputRecord.close();
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Fatal: output record closure failed", ioe);
}
@@ -440,7 +440,7 @@ SSLException fatal(Alert alert, String diagnostic,
try {
transport.shutdown();
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("Fatal: transport closure failed", ioe);
}
@@ -526,7 +526,7 @@ void closeInbound() {
passiveInboundClose();
}
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("inbound closure failed", ioe);
}
}
@@ -583,7 +583,7 @@ void closeOutbound() {
try {
initiateOutboundClose();
} catch (IOException ioe) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning("outbound closure failed", ioe);
}
}
diff --git a/src/java.base/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java b/src/java.base/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
index bac7735de07..8b89fecefa8 100644
--- a/src/java.base/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2025, 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
@@ -48,24 +48,24 @@ protected void engineInit(KeyStore ks) throws KeyStoreException {
trustManager = getInstance(TrustStoreManager.getTrustedCerts());
} catch (SecurityException se) {
// eat security exceptions but report other throwables
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"SunX509: skip default keystore", se);
}
} catch (Error err) {
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"SunX509: skip default keystore", err);
}
throw err;
} catch (RuntimeException re) {
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"SunX509: skip default keystore", re);
}
throw re;
} catch (Exception e) {
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"SunX509: skip default keystore", e);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java
index e2c353847c7..a44f3a4e32d 100644
--- a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java
+++ b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java
@@ -108,7 +108,7 @@ private TrustStoreDescriptor(String storeName, String storeType,
this.storeFile = storeFile;
this.lastModified = lastModified;
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"trustStore is: " + storeName + "\n" +
"trustStore type is: " + storeType + "\n" +
@@ -151,7 +151,7 @@ static TrustStoreDescriptor createInstance() {
}
// Not break, the file is inaccessible.
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"Inaccessible trust store: " +
@@ -267,7 +267,7 @@ KeyStore getKeyStore(
}
// Reload a new key store.
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine("Reload the trust store");
}
@@ -321,7 +321,7 @@ Set getTrustedCerts(
// Reload the trust store if needed.
if (ks == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine("Reload the trust store");
}
ks = loadKeyStore(descriptor);
@@ -329,12 +329,12 @@ Set getTrustedCerts(
}
// Reload trust certs from the key store.
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine("Reload trust certs");
}
certs = loadTrustedCerts(ks);
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine("Reloaded " + certs.size() + " trust certs");
}
@@ -355,7 +355,7 @@ private static KeyStore loadKeyStore(
descriptor.storeFile == null) {
// No file available, no KeyStore available.
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine("No available key store");
}
@@ -382,7 +382,7 @@ private static KeyStore loadKeyStore(
ks.load(bis, password);
} catch (FileNotFoundException fnfe) {
// No file available, no KeyStore available.
- if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"Not available key store: " + descriptor.storeName);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/Utilities.java b/src/java.base/share/classes/sun/security/ssl/Utilities.java
index 50cd3bee751..458551b9d8a 100644
--- a/src/java.base/share/classes/sun/security/ssl/Utilities.java
+++ b/src/java.base/share/classes/sun/security/ssl/Utilities.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2025, 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
@@ -70,7 +70,7 @@ static List addToSNIServerNameList(
SNIServerName serverName = sniList.get(i);
if (serverName.getType() == StandardConstants.SNI_HOST_NAME) {
sniList.set(i, sniHostName);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
"the previous server name in SNI (" + serverName +
") was replaced with (" + sniHostName + ")");
@@ -116,7 +116,7 @@ private static SNIHostName rawToSNIHostName(String hostname) {
return new SNIHostName(hostname);
} catch (IllegalArgumentException iae) {
// don't bother to handle illegal host_name
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(hostname + "\" " +
"is not a legal HostName for server name indication");
}
diff --git a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java
index 5abc2cb1bf4..6aedff02c34 100644
--- a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java
+++ b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java
@@ -201,7 +201,7 @@ public static SSLPossession createPossession(
private static SSLPossession createClientPossession(
ClientHandshakeContext chc, String[] keyTypes) {
X509ExtendedKeyManager km = chc.sslContext.getX509KeyManager();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("X509KeyManager class: " +
km.getClass().getName());
}
@@ -243,7 +243,7 @@ private static SSLPossession createClientPossession(
}
if (clientAlias == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("No X.509 cert selected for "
+ Arrays.toString(keyTypes));
}
@@ -252,7 +252,7 @@ private static SSLPossession createClientPossession(
PrivateKey clientPrivateKey = km.getPrivateKey(clientAlias);
if (clientPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
clientAlias + " is not a private key entry");
}
@@ -261,7 +261,7 @@ private static SSLPossession createClientPossession(
X509Certificate[] clientCerts = km.getCertificateChain(clientAlias);
if ((clientCerts == null) || (clientCerts.length == 0)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(clientAlias +
" is a private key entry with no cert chain stored");
}
@@ -270,7 +270,7 @@ private static SSLPossession createClientPossession(
String privateKeyAlgorithm = clientPrivateKey.getAlgorithm();
if (!Arrays.asList(keyTypes).contains(privateKeyAlgorithm)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
clientAlias + " private key algorithm " +
privateKeyAlgorithm + " not in request list");
@@ -280,7 +280,7 @@ private static SSLPossession createClientPossession(
String publicKeyAlgorithm = clientCerts[0].getPublicKey().getAlgorithm();
if (!privateKeyAlgorithm.equals(publicKeyAlgorithm)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
clientAlias + " private or public key is not of " +
"same algorithm: " +
@@ -296,7 +296,7 @@ private static SSLPossession createClientPossession(
private static SSLPossession createServerPossession(
ServerHandshakeContext shc, String[] keyTypes) {
X509ExtendedKeyManager km = shc.sslContext.getX509KeyManager();
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("X509KeyManager class: " +
km.getClass().getName());
}
@@ -337,7 +337,7 @@ private static SSLPossession createServerPossession(
}
if (serverAlias == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest("No X.509 cert selected for " + keyType);
}
continue;
@@ -345,7 +345,7 @@ private static SSLPossession createServerPossession(
PrivateKey serverPrivateKey = km.getPrivateKey(serverAlias);
if (serverPrivateKey == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
serverAlias + " is not a private key entry");
}
@@ -354,7 +354,7 @@ private static SSLPossession createServerPossession(
X509Certificate[] serverCerts = km.getCertificateChain(serverAlias);
if ((serverCerts == null) || (serverCerts.length == 0)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
serverAlias + " is not a certificate entry");
}
@@ -364,7 +364,7 @@ private static SSLPossession createServerPossession(
PublicKey serverPublicKey = serverCerts[0].getPublicKey();
if ((!serverPrivateKey.getAlgorithm().equals(keyType))
|| (!serverPublicKey.getAlgorithm().equals(keyType))) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
serverAlias + " private or public key is not of " +
keyType + " algorithm");
@@ -379,7 +379,7 @@ private static SSLPossession createServerPossession(
if (!shc.negotiatedProtocol.useTLS13PlusSpec() &&
keyType.equals("EC")) {
if (!(serverPublicKey instanceof ECPublicKey)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(serverAlias +
" public key is not an instance of ECPublicKey");
}
@@ -398,7 +398,7 @@ private static SSLPossession createServerPossession(
((shc.clientRequestedNamedGroups != null) &&
!shc.clientRequestedNamedGroups.contains(namedGroup))) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.warning(
"Unsupported named group (" + namedGroup +
") used in the " + serverAlias + " certificate");
diff --git a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java
index 9484ab4f830..2a1f01273bd 100644
--- a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java
+++ b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerCertChecking.java
@@ -116,7 +116,7 @@ protected EntryStatus checkAlias(int keyStoreIndex, String alias,
}
if (keyIndex == -1) {
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine("Ignore alias " + alias
+ ": key algorithm does not match");
}
@@ -134,7 +134,7 @@ protected EntryStatus checkAlias(int keyStoreIndex, String alias,
}
}
if (!found) {
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine(
"Ignore alias " + alias
+ ": issuers do not match");
@@ -150,7 +150,7 @@ protected EntryStatus checkAlias(int keyStoreIndex, String alias,
!conformsToAlgorithmConstraints(constraints, chain,
checkType.getValidator())) {
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine("Ignore alias " + alias +
": certificate chain does not conform to " +
"algorithm constraints");
@@ -219,7 +219,7 @@ private boolean conformsToAlgorithmConstraints(
checker.init(false);
} catch (CertPathValidatorException cpve) {
// unlikely to happen
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine(
"Cannot initialize algorithm constraints checker",
cpve);
@@ -235,7 +235,7 @@ private boolean conformsToAlgorithmConstraints(
// We don't care about the unresolved critical extensions.
checker.check(cert, Collections.emptySet());
} catch (CertPathValidatorException cpve) {
- if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("keymanager")) {
SSLLogger.fine("Certificate does not conform to " +
"algorithm constraints", cert, cpve);
}
@@ -392,7 +392,7 @@ CheckResult check(X509Certificate cert, Date date,
serverName.getEncoded());
} catch (IllegalArgumentException iae) {
// unlikely to happen, just in case ...
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("keymanager")) {
SSLLogger.fine("Illegal server name: "
+ serverName);
@@ -408,7 +408,7 @@ CheckResult check(X509Certificate cert, Date date,
X509TrustManagerImpl.checkIdentity(hostname,
cert, idAlgorithm);
} catch (CertificateException e) {
- if (SSLLogger.isOn &&
+ if (SSLLogger.isOn() &&
SSLLogger.isOn("keymanager")) {
SSLLogger.fine(
"Certificate identity does not match "
diff --git a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java
index c607fe0f25d..72f079db175 100644
--- a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java
@@ -228,7 +228,7 @@ private PrivateKeyEntry getEntry(String alias) {
|| (secondDot - firstDot < 2)
|| (alias.length() - secondDot < 2)) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.warning("Invalid alias format: " + alias);
}
return null;
@@ -255,7 +255,7 @@ private PrivateKeyEntry getEntry(String alias) {
NoSuchAlgorithmException |
IndexOutOfBoundsException e) {
// ignore and only log exception
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.warning("Exception thrown while getting an alias " +
alias + ": " + e);
}
@@ -295,7 +295,7 @@ private String chooseAlias(List keyTypeList, Principal[] issuers,
if (results != null) {
for (EntryStatus status : results) {
if (status.checkResult == CheckResult.OK) {
- if (SSLLogger.isOn
+ if (SSLLogger.isOn()
&& SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.fine("Choosing key: " + status);
}
@@ -312,13 +312,13 @@ private String chooseAlias(List keyTypeList, Principal[] issuers,
}
}
if (allResults == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.fine("No matching key found");
}
return null;
}
Collections.sort(allResults);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.fine(
"No good matching key found, "
+ "returning best match out of", allResults);
@@ -358,13 +358,13 @@ private String[] getAliases(
}
}
if (allResults == null || allResults.isEmpty()) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.fine("No matching alias found");
}
return null;
}
Collections.sort(allResults);
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,keymanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,keymanager")) {
SSLLogger.fine("Getting aliases", allResults);
}
return toAliases(allResults);
diff --git a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java
index d82b94a1d7d..1bbe0bfb9c7 100644
--- a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java
@@ -81,7 +81,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
this.trustedCerts = trustedCerts;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,trustmanager")) {
SSLLogger.fine("adding as trusted certificates",
(Object[])trustedCerts.toArray(new X509Certificate[0]));
}
@@ -98,7 +98,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
trustedCerts = v.getTrustedCertificates();
serverValidator = v;
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,trustmanager")) {
SSLLogger.fine("adding as trusted certificates",
(Object[])trustedCerts.toArray(new X509Certificate[0]));
}
@@ -242,7 +242,7 @@ private void checkTrusted(X509Certificate[] chain,
null, checkClientTrusted ? null : authType);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,trustmanager")) {
SSLLogger.fine("Found trusted certificate",
trustedChain[trustedChain.length - 1]);
}
@@ -288,7 +288,7 @@ private void checkTrusted(X509Certificate[] chain,
null, checkClientTrusted ? null : authType);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,trustmanager")) {
SSLLogger.fine("Found trusted certificate",
trustedChain[trustedChain.length - 1]);
}
@@ -331,7 +331,7 @@ private void checkTrusted(X509Certificate[] chain,
null, checkClientTrusted ? null : authType);
}
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,trustmanager")) {
SSLLogger.fine("Found trusted certificate",
trustedChain[trustedChain.length - 1]);
}
@@ -365,7 +365,7 @@ private static String getHostNameInSNI(List sniNames) {
hostname = new SNIHostName(sniName.getEncoded());
} catch (IllegalArgumentException iae) {
// unlikely to happen, just in case ...
- if (SSLLogger.isOn && SSLLogger.isOn("ssl,trustmanager")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl,trustmanager")) {
SSLLogger.fine("Illegal server name: " + sniName);
}
}
diff --git a/src/java.base/share/classes/sun/security/tools/keytool/resources/keytool.properties b/src/java.base/share/classes/sun/security/tools/keytool/resources/keytool.properties
index fb03573a7d5..751e3af9c9c 100644
--- a/src/java.base/share/classes/sun/security/tools/keytool/resources/keytool.properties
+++ b/src/java.base/share/classes/sun/security/tools/keytool/resources/keytool.properties
@@ -321,7 +321,8 @@ Unable.to.parse.denyAfter.string.in.exception.message=Unable to parse denyAfter
whose.sigalg.weak=%1$s uses the %2$s signature algorithm which is considered a security risk.
whose.key.disabled=%1$s uses a %2$s which is considered a security risk and is disabled.
whose.key.weak=%1$s uses a %2$s which is considered a security risk. It will be disabled in a future update.
-jks.storetype.warning=The %1$s keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore %2$s -destkeystore %2$s -deststoretype pkcs12".
+jks.storetype.warning=%1$s uses outdated cryptographic algorithms and will be removed in a future release. Migrate to PKCS12 using:\n\
+keytool -importkeystore -srckeystore %2$s -destkeystore %2$s -deststoretype pkcs12
migrate.keystore.warning=Migrated "%1$s" to %4$s. The %2$s keystore is backed up as "%3$s".
backup.keystore.warning=The original keystore "%1$s" is backed up as "%3$s"...
importing.keystore.status=Importing keystore %1$s to %2$s...
diff --git a/src/java.base/share/classes/sun/security/util/DomainName.java b/src/java.base/share/classes/sun/security/util/DomainName.java
index 4f577f1114c..465c155ab87 100644
--- a/src/java.base/share/classes/sun/security/util/DomainName.java
+++ b/src/java.base/share/classes/sun/security/util/DomainName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2025, 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
@@ -45,7 +45,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
-import jdk.internal.util.StaticProperty;
import sun.security.ssl.SSLLogger;
/**
@@ -193,7 +192,7 @@ private static Rules createRules(String tld) {
}
return getRules(tld, new ZipInputStream(pubSuffixStream));
} catch (IOException e) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
"cannot parse public suffix data for " + tld +
": " + e.getMessage());
@@ -210,7 +209,7 @@ private static InputStream getPubSuffixStream() {
is = new FileInputStream(f);
} catch (FileNotFoundException e) { }
if (is == null) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl") &&
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl") &&
SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"lib/security/public_suffix_list.dat not found");
@@ -231,7 +230,7 @@ private static Rules getRules(String tld,
}
}
if (!found) {
- if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ if (SSLLogger.isOn() && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Domain " + tld + " not found");
}
return null;
diff --git a/src/java.base/share/classes/sun/security/util/HostnameChecker.java b/src/java.base/share/classes/sun/security/util/HostnameChecker.java
index 1374bc6d535..65115c9aeaf 100644
--- a/src/java.base/share/classes/sun/security/util/HostnameChecker.java
+++ b/src/java.base/share/classes/sun/security/util/HostnameChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2025, 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
@@ -271,7 +271,7 @@ private boolean isMatched(String name, String template,
name = IDN.toUnicode(IDN.toASCII(name));
template = IDN.toUnicode(IDN.toASCII(template));
} catch (RuntimeException re) {
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine("Failed to normalize to Unicode: " + re);
}
@@ -308,7 +308,7 @@ private static boolean hasIllegalWildcard(
String template, boolean chainsToPublicCA) {
// not ok if it is a single wildcard character or "*."
if (template.equals("*") || template.equals("*.")) {
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine(
"Certificate domain name has illegal single " +
"wildcard character: " + template);
@@ -328,7 +328,7 @@ private static boolean hasIllegalWildcard(
// not ok if there is no dot after wildcard (ex: "*com")
if (firstDotIndex == -1) {
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine(
"Certificate domain name has illegal wildcard, " +
"no dot after wildcard character: " + template);
@@ -353,7 +353,7 @@ private static boolean hasIllegalWildcard(
// Is it a top-level domain?
if (wildcardedDomain.equalsIgnoreCase(templateDomainSuffix)) {
- if (SSLLogger.isOn) {
+ if (SSLLogger.isOn()) {
SSLLogger.fine(
"Certificate domain name has illegal " +
"wildcard for top-level public suffix: " + template);
diff --git a/src/java.base/share/classes/sun/security/util/SliceableSecretKey.java b/src/java.base/share/classes/sun/security/util/SliceableSecretKey.java
new file mode 100644
index 00000000000..4dc3fe0a3e8
--- /dev/null
+++ b/src/java.base/share/classes/sun/security/util/SliceableSecretKey.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.security.util;
+
+import javax.crypto.SecretKey;
+
+/**
+ * An interface for SecretKeys that support using its slice as a new
+ * SecretKey.
+ *
+ * This is mainly used by PKCS #11 implementations that support the
+ * EXTRACT_KEY_FROM_KEY mechanism even if the key itself is sensitive
+ * and non-extractable.
+ */
+public interface SliceableSecretKey {
+
+ /**
+ * Returns a slice as a new SecretKey.
+ *
+ * @param alg the new algorithm name
+ * @param from the byte offset of the new key in the full key
+ * @param to the to offset (exclusive) of the new key in the full key
+ * @return the new key
+ * @throws ArrayIndexOutOfBoundsException for improper from
+ * and to values
+ * @throws UnsupportedOperationException if slicing is not supported
+ */
+ SecretKey slice(String alg, int from, int to);
+}
diff --git a/src/java.base/share/native/libjimage/jimage.cpp b/src/java.base/share/native/libjimage/jimage.cpp
index 10e85eb2520..91a86f992e6 100644
--- a/src/java.base/share/native/libjimage/jimage.cpp
+++ b/src/java.base/share/native/libjimage/jimage.cpp
@@ -110,7 +110,7 @@ JIMAGE_FindResource(JImageFile* image,
size_t nameLen = strlen(name);
size_t index;
- // TBD: assert(moduleNameLen > 0 && "module name must be non-empty");
+ assert(moduleNameLen > 0 && "module name must be non-empty");
assert(nameLen > 0 && "name must non-empty");
// If the concatenated string is too long for the buffer, return not found
diff --git a/src/java.base/unix/native/libjava/java_props_md.c b/src/java.base/unix/native/libjava/java_props_md.c
index 000eb4b953e..1cbc3665ebc 100644
--- a/src/java.base/unix/native/libjava/java_props_md.c
+++ b/src/java.base/unix/native/libjava/java_props_md.c
@@ -388,8 +388,12 @@ GetJavaProperties(JNIEnv *env)
/* supported instruction sets */
{
char list[258];
- sysinfo(SI_ISALIST, list, sizeof(list));
- sprops.cpu_isalist = strdup(list);
+ int ret = sysinfo(SI_ISALIST, list, sizeof(list));
+ if (ret == 0) {
+ sprops.cpu_isalist = strdup(list);
+ } else {
+ sprops.cpu_isalist = NULL;
+ }
}
#else
sprops.cpu_isalist = NULL;
@@ -438,7 +442,7 @@ GetJavaProperties(JNIEnv *env)
/* Determine the language, country, variant, and encoding from the host,
* and store these in the user.language, user.country, user.variant and
- * file.encoding system properties. */
+ * native.encoding system properties. */
setlocale(LC_ALL, "");
if (ParseLocale(env, LC_CTYPE,
&(sprops.format_language),
diff --git a/src/java.base/windows/native/libjava/java_props_md.c b/src/java.base/windows/native/libjava/java_props_md.c
index 75587a09d0b..e152dbe9bef 100644
--- a/src/java.base/windows/native/libjava/java_props_md.c
+++ b/src/java.base/windows/native/libjava/java_props_md.c
@@ -569,7 +569,7 @@ GetJavaProperties(JNIEnv* env)
/*
* user.language
* user.script, user.country, user.variant (if user's environment specifies them)
- * file.encoding
+ * native.encoding
*/
{
/*
diff --git a/src/java.desktop/share/classes/java/awt/image/Raster.java b/src/java.desktop/share/classes/java/awt/image/Raster.java
index 9f346cb304a..053e7c1eec5 100644
--- a/src/java.desktop/share/classes/java/awt/image/Raster.java
+++ b/src/java.desktop/share/classes/java/awt/image/Raster.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, 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
@@ -265,9 +265,15 @@ public static WritableRaster createInterleavedRaster(int dataType,
* {@code location.x + w} or
* {@code location.y + h} results in integer overflow
* @throws IllegalArgumentException if {@code scanlineStride}
- * is less than 0
- * @throws IllegalArgumentException if {@code pixelStride} is less than 0
+ * is less than or equal to 0
+ * @throws IllegalArgumentException if {@code pixelStride} is less than or equal to 0
+ * @throws IllegalArgumentException if {@code w * pixelStride} is greater
+ * than {@code scanlineStride}
+ * @throws IllegalArgumentException if the data size need to store all
+ * lines of the image is greater than {@code Integer.MAX_VALUE}
* @throws NullPointerException if {@code bandOffsets} is null
+ * @throws IllegalArgumentException if any element of {@code bandOffsets} is greater
+ * than {@code pixelStride} or the {@code scanlineStride}
*/
public static WritableRaster createInterleavedRaster(int dataType,
int w, int h,
@@ -285,14 +291,25 @@ public static WritableRaster createInterleavedRaster(int dataType,
throw new IllegalArgumentException("Dimensions (width="+w+
" height="+h+") are too large");
}
- if (pixelStride < 0) {
- throw new IllegalArgumentException("pixelStride is < 0");
+ if (pixelStride <= 0) {
+ throw new IllegalArgumentException("pixelStride is <= 0");
}
- if (scanlineStride < 0) {
- throw new IllegalArgumentException("scanlineStride is < 0");
+ if (scanlineStride <= 0) {
+ throw new IllegalArgumentException("scanlineStride is <= 0");
+ }
+ if (bandOffsets == null) {
+ throw new NullPointerException("bandOffsets is null");
}
- int size = scanlineStride * (h - 1) + // first (h - 1) scans
- pixelStride * w; // last scan
+ lsz = (long)w * pixelStride;
+ if (lsz > scanlineStride) {
+ throw new IllegalArgumentException("w * pixelStride is too large");
+ }
+ lsz = (long)scanlineStride * (long)(h - 1) + // first (h - 1) scans
+ (long)pixelStride * (long)w; // last scan
+ if (lsz > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("size too large to store image");
+ }
+ int size = (int)lsz;
if (location == null) {
location = new Point(0, 0);
@@ -415,6 +432,10 @@ public static WritableRaster createBandedRaster(int dataType,
* is less than 0
* @throws ArrayIndexOutOfBoundsException if {@code bankIndices}
* is {@code null}
+ * @throws IllegalArgumentException if the lengths of {@code bankIndices}
+ * and {@code bandOffsets} are different.
+ * @throws IllegalArgumentException if the data size need to store all
+ * lines of a bank of the image is greater than {@code Integer.MAX_VALUE}
* @throws NullPointerException if {@code bandOffsets} is {@code null}
*/
public static WritableRaster createBandedRaster(int dataType,
@@ -423,9 +444,6 @@ public static WritableRaster createBandedRaster(int dataType,
int[] bankIndices,
int[] bandOffsets,
Point location) {
- DataBuffer d;
- int bands = bandOffsets.length;
-
if (w <= 0 || h <= 0) {
throw new IllegalArgumentException("w and h must be positive");
}
@@ -440,7 +458,11 @@ public static WritableRaster createBandedRaster(int dataType,
}
if (bandOffsets == null) {
throw new
- ArrayIndexOutOfBoundsException("Band offsets array is null");
+ NullPointerException("Band offsets array is null");
+ }
+ if (bandOffsets.length != bankIndices.length) {
+ throw new IllegalArgumentException(
+ "bankIndices.length != bandOffsets.length");
}
if (location != null) {
if ((w + location.getX() > Integer.MAX_VALUE) ||
@@ -451,6 +473,9 @@ public static WritableRaster createBandedRaster(int dataType,
}
}
+ DataBuffer d;
+ int bands = bandOffsets.length;
+
// Figure out the #banks and the largest band offset
int maxBank = bankIndices[0];
int maxBandOff = bandOffsets[0];
@@ -463,9 +488,15 @@ public static WritableRaster createBandedRaster(int dataType,
}
}
int banks = maxBank + 1;
- int size = maxBandOff +
- scanlineStride * (h - 1) + // first (h - 1) scans
- w; // last scan
+
+ lsz = (long) maxBandOff +
+ (long)scanlineStride * (h - 1) + // first (h - 1) scans
+ w; // last scan
+ if (lsz > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("storage size is too large");
+ }
+
+ int size = (int)lsz;
switch(dataType) {
case DataBuffer.TYPE_BYTE:
@@ -508,11 +539,14 @@ public static WritableRaster createBandedRaster(int dataType,
* @param location the upper-left corner of the {@code Raster}
* @return a WritableRaster object with the specified data type,
* width, height, and band masks.
- * @throws RasterFormatException if {@code w} or {@code h}
- * is less than or equal to zero, or computing either
+ * @throws NullPointerException if {@code bandMasks} is null
+ * @throws IllegalArgumentException if {@code w} and {@code h}
+ * are not both greater than 0
+ * @throws IllegalArgumentException if the product of {@code w}
+ * and {@code h} is greater than {@code Integer.MAX_VALUE}
+ * @throws RasterFormatException if computing either
* {@code location.x + w} or
- * {@code location.y + h} results in integer
- * overflow
+ * {@code location.y + h} results in integer overflow
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types, which are
* {@code DataBuffer.TYPE_BYTE},
@@ -525,6 +559,24 @@ public static WritableRaster createPackedRaster(int dataType,
Point location) {
DataBuffer d;
+ if (w <= 0 || h <= 0) {
+ throw new IllegalArgumentException("w and h must be positive");
+ }
+ long lsz = (long)w * h;
+ if (lsz > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Dimensions (width="+w+
+ " height="+h+") are too large");
+ }
+
+ if (location != null) {
+ if ((w + location.getX() > Integer.MAX_VALUE) ||
+ (h + location.getY() > Integer.MAX_VALUE)) {
+ throw new RasterFormatException(
+ "location.x + w and location.y + h " +
+ " cannot exceed Integer.MAX_VALUE");
+ }
+ }
+
switch(dataType) {
case DataBuffer.TYPE_BYTE:
d = new DataBufferByte(w*h);
@@ -573,17 +625,19 @@ public static WritableRaster createPackedRaster(int dataType,
* @param location the upper-left corner of the {@code Raster}
* @return a WritableRaster object with the specified data type,
* width, height, number of bands, and bits per band.
- * @throws RasterFormatException if {@code w} or {@code h}
- * is less than or equal to zero, or computing either
- * {@code location.x + w} or
- * {@code location.y + h} results in integer
- * overflow
+ * @throws IllegalArgumentException if {@code bitsPerBand} or
+ * {@code bands} is not greater than zero
* @throws IllegalArgumentException if the product of
* {@code bitsPerBand} and {@code bands} is
* greater than the number of bits held by
* {@code dataType}
- * @throws IllegalArgumentException if {@code bitsPerBand} or
- * {@code bands} is not greater than zero
+ * @throws IllegalArgumentException if {@code w} and {@code h}
+ * are not both greater than 0
+ * @throws IllegalArgumentException if the product of {@code w}
+ * and {@code h} is greater than {@code Integer.MAX_VALUE}
+ * @throws RasterFormatException if computing either
+ * {@code location.x + w} or
+ * {@code location.y + h} results in integer overflow
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types, which are
* {@code DataBuffer.TYPE_BYTE},
@@ -607,18 +661,37 @@ public static WritableRaster createPackedRaster(int dataType,
") must be greater than 0");
}
+ if (w <= 0 || h <= 0) {
+ throw new IllegalArgumentException("w and h must be positive");
+ }
+ long lsz = (long)w * h;
+ if (lsz > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Dimensions (width="+w+
+ " height="+h+") are too large");
+ }
+
+ if (location != null) {
+ if ((w + location.getX() > Integer.MAX_VALUE) ||
+ (h + location.getY() > Integer.MAX_VALUE)) {
+ throw new RasterFormatException(
+ "location.x + w and location.y + h " +
+ " cannot exceed Integer.MAX_VALUE");
+ }
+ }
+
+ int shift = (bands-1)*bitsPerBand;
+
+ /* Make sure the total mask size will fit in the data type */
+ if (shift+bitsPerBand > DataBuffer.getDataTypeSize(dataType)) {
+ throw new IllegalArgumentException("bitsPerBand("+
+ bitsPerBand+") * bands is "+
+ " greater than data type "+
+ "size.");
+ }
if (bands != 1) {
int[] masks = new int[bands];
int mask = (1 << bitsPerBand) - 1;
- int shift = (bands-1)*bitsPerBand;
-
- /* Make sure the total mask size will fit in the data type */
- if (shift+bitsPerBand > DataBuffer.getDataTypeSize(dataType)) {
- throw new IllegalArgumentException("bitsPerBand("+
- bitsPerBand+") * bands is "+
- " greater than data type "+
- "size.");
- }
+
switch(dataType) {
case DataBuffer.TYPE_BYTE:
case DataBuffer.TYPE_USHORT:
@@ -693,6 +766,7 @@ public static WritableRaster createPackedRaster(int dataType,
* {@code DataBuffer.TYPE_USHORT}.
* @throws RasterFormatException if {@code dataBuffer} has more
* than one bank.
+ * @throws RasterFormatException if {@code dataBuffer} is too small.
* @throws IllegalArgumentException if {@code w} and {@code h} are not
* both > 0
* @throws IllegalArgumentException if the product of {@code w}
@@ -704,6 +778,8 @@ public static WritableRaster createPackedRaster(int dataType,
* is less than 0
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws NullPointerException if {@code bandOffsets} is null
+ * @throws IllegalArgumentException if any element of {@code bandOffsets} is greater
+ * than {@code pixelStride} or the {@code scanlineStride}
*/
public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
@@ -779,6 +855,10 @@ public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
* bank indices and band offsets.
* @throws NullPointerException if {@code dataBuffer} is null,
* or {@code bankIndices} is null, or {@code bandOffsets} is null
+ * @throws IllegalArgumentException if the lengths of {@code bankIndices}
+ * and {@code bandOffsets} are different.
+ * @throws ArrayIndexOutOfBoundsException if any element of {@code bankIndices}
+ * is greater or equal to the number of bands in {@code dataBuffer}
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types, which are
* {@code DataBuffer.TYPE_BYTE},
@@ -883,11 +963,14 @@ public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
* @return a WritableRaster object with the specified
* {@code DataBuffer}, width, height, scanline stride,
* and band masks.
- * @throws RasterFormatException if {@code w} or {@code h}
- * is less than or equal to zero, or computing either
+ * @throws NullPointerException if {@code bandMasks} is null
+ * @throws IllegalArgumentException if {@code w} and {@code h}
+ * are not both greater than 0
+ * @throws IllegalArgumentException if the product of {@code w}
+ * and {@code h} is greater than {@code Integer.MAX_VALUE}
+ * @throws RasterFormatException if computing either
* {@code location.x + w} or
- * {@code location.y + h} results in integer
- * overflow
+ * {@code location.y + h} results in integer overflow
* @throws IllegalArgumentException if {@code dataBuffer} is not
* one of the supported data types, which are
* {@code DataBuffer.TYPE_BYTE},
@@ -906,6 +989,25 @@ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
+
+ if (w <= 0 || h <= 0) {
+ throw new IllegalArgumentException("w and h must be positive");
+ }
+ long lsz = (long)w * h;
+ if (lsz > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Dimensions (width="+w+
+ " height="+h+") are too large");
+ }
+
+ if (location != null) {
+ if ((w + location.getX() > Integer.MAX_VALUE) ||
+ (h + location.getY() > Integer.MAX_VALUE)) {
+ throw new RasterFormatException(
+ "location.x + w and location.y + h " +
+ " cannot exceed Integer.MAX_VALUE");
+ }
+ }
+
if (location == null) {
location = new Point(0,0);
}
@@ -960,11 +1062,13 @@ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
* @return a WritableRaster object with the specified
* {@code DataBuffer}, width, height, and
* bits per pixel.
- * @throws RasterFormatException if {@code w} or {@code h}
- * is less than or equal to zero, or computing either
+ * @throws IllegalArgumentException if {@code w} and {@code h}
+ * are not both greater than 0
+ * @throws IllegalArgumentException if the product of {@code w}
+ * and {@code h} is greater than {@code Integer.MAX_VALUE}
+ * @throws RasterFormatException if computing either
* {@code location.x + w} or
- * {@code location.y + h} results in integer
- * overflow
+ * {@code location.y + h} results in integer overflow
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types, which are
* {@code DataBuffer.TYPE_BYTE},
@@ -972,6 +1076,8 @@ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
* or {@code DataBuffer.TYPE_INT}
* @throws RasterFormatException if {@code dataBuffer} has more
* than one bank.
+ * @throws RasterFormatException if {@code bitsPixel} is less than 1 or
+ * not a power of 2 or exceeds the {@code dataBuffer} element size.
* @throws NullPointerException if {@code dataBuffer} is null
*/
public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
@@ -982,6 +1088,25 @@ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
+ if (w <= 0 || h <= 0) {
+ throw new IllegalArgumentException("w and h must be positive");
+ }
+ long lsz = (long)w * h;
+
+ if (lsz > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("Dimensions (width="+w+
+ " height="+h+") are too large");
+ }
+
+ if (location != null) {
+ if ((w + location.getX() > Integer.MAX_VALUE) ||
+ (h + location.getY() > Integer.MAX_VALUE)) {
+ throw new RasterFormatException(
+ "location.x + w and location.y + h " +
+ " cannot exceed Integer.MAX_VALUE");
+ }
+ }
+
if (location == null) {
location = new Point(0,0);
}
@@ -1000,6 +1125,12 @@ public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
" must only have 1 bank.");
}
+ if ((bitsPerPixel < 1) || (bitsPerPixel > DataBuffer.getDataTypeSize(dataType))) {
+ // NB MPPSM checks power of 2 condition
+ throw new
+ RasterFormatException("bitsPerPixel must be > 0 and a power of 2 that " +
+ "does not exceed data buffer element size");
+ }
MultiPixelPackedSampleModel mppsm =
new MultiPixelPackedSampleModel(dataType, w, h, bitsPerPixel);
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java
index 0bbbab7b45f..c940b4dcead 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalButtonUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2025, 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
@@ -217,6 +217,13 @@ protected void paintFocus(Graphics g, AbstractButton b,
// If there is an icon and no text
else if ( isIcon ) {
focusRect.setBounds( iconRect );
+ } else {
+ Rectangle emptyRect = new Rectangle();
+ emptyRect.x = 5;
+ emptyRect.y = 5;
+ emptyRect.width = b.getWidth() - emptyRect.x * 2;
+ emptyRect.height = b.getHeight() - emptyRect.y * 2;
+ focusRect.setBounds(emptyRect);
}
g.setColor(getFocusColor());
diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java
index 63a1359323f..24b50003e3c 100644
--- a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java
+++ b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2025, 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
@@ -136,8 +136,7 @@ public ColorTransform createTransform(int renderingIntent,
static native void colorConvert(long trans, int width, int height,
int srcOffset, int srcNextRowOffset,
int dstOffset, int dstNextRowOffset,
- Object srcData, Object dstData,
- int srcType, int dstType);
+ Object srcData, Object dstData);
private LCMS() {}
diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
index 663e11ff172..c7bae875282 100644
--- a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
+++ b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
@@ -31,7 +31,6 @@
import java.awt.image.ComponentColorModel;
import java.awt.image.ComponentSampleModel;
import java.awt.image.Raster;
-import java.lang.annotation.Native;
import java.nio.ByteOrder;
import sun.awt.image.ByteComponentRaster;
@@ -69,14 +68,7 @@ private static int CHANNELS_SH(int x) {
// private static final int PT_BGRA_8 = PT_ABGR_8 | SWAPFIRST;
private static final int SWAP_ENDIAN =
ByteOrder.nativeOrder() == LITTLE_ENDIAN ? DOSWAP : 0;
- @Native
- private static final int DT_BYTE = 0;
- @Native
- private static final int DT_SHORT = 1;
- @Native
- private static final int DT_INT = 2;
int pixelType;
- int dataType;
int width;
int height;
int nextRowOffset;
@@ -93,12 +85,10 @@ private static int CHANNELS_SH(int x) {
* @param data the storage of pixels: {@code byte[], short[] or int[]}
* @param length the length of the data array
* @param nc the number of color components
- * @param dt the type of data array: DT_BYTE, DT_SHORT or DT_INT
* @param size the size of one color component in bytes
*/
- private LCMSImageLayout(Object data, int length, int nc, int dt, int size) {
+ private LCMSImageLayout(Object data, int length, int nc, int size) {
dataArray = data;
- dataType = dt;
dataArrayLength = length * size;
pixelType = CHANNELS_SH(nc) | BYTES_SH(size);
width = length / nc;
@@ -109,11 +99,11 @@ private LCMSImageLayout(Object data, int length, int nc, int dt, int size) {
}
LCMSImageLayout(byte[] data, int nc) {
- this(data, data.length, nc, DT_BYTE, Byte.BYTES);
+ this(data, data.length, nc, Byte.BYTES);
}
LCMSImageLayout(short[] data, int nc) {
- this(data, data.length, nc, DT_SHORT, Short.BYTES);
+ this(data, data.length, nc, Short.BYTES);
}
private LCMSImageLayout() {
@@ -186,7 +176,6 @@ static LCMSImageLayout createImageLayout(BufferedImage image) {
l.offset = safeMult(4, intRaster.getDataOffset(0));
l.dataArray = intRaster.getDataStorage();
l.dataArrayLength = 4 * intRaster.getDataStorage().length;
- l.dataType = DT_INT;
}
case BufferedImage.TYPE_BYTE_GRAY, BufferedImage.TYPE_3BYTE_BGR,
BufferedImage.TYPE_4BYTE_ABGR,
@@ -201,7 +190,6 @@ static LCMSImageLayout createImageLayout(BufferedImage image) {
l.offset = byteRaster.getDataOffset(firstBand);
l.dataArray = byteRaster.getDataStorage();
l.dataArrayLength = byteRaster.getDataStorage().length;
- l.dataType = DT_BYTE;
}
case BufferedImage.TYPE_USHORT_GRAY -> {
if (!(raster instanceof ShortComponentRaster shortRaster)) {
@@ -212,7 +200,6 @@ static LCMSImageLayout createImageLayout(BufferedImage image) {
l.offset = safeMult(2, shortRaster.getDataOffset(0));
l.dataArray = shortRaster.getDataStorage();
l.dataArrayLength = 2 * shortRaster.getDataStorage().length;
- l.dataType = DT_SHORT;
}
default -> {
return null;
@@ -319,7 +306,6 @@ static LCMSImageLayout createImageLayout(Raster r, ColorModel cm) {
l.nextPixelOffset = br.getPixelStride();
l.offset = br.getDataOffset(firstBand);
- l.dataType = DT_BYTE;
byte[] data = br.getDataStorage();
l.dataArray = data;
l.dataArrayLength = data.length;
diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java
index 881a6556ace..3f4f510cf94 100644
--- a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java
+++ b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSTransform.java
@@ -121,8 +121,7 @@ private void doTransform(LCMSImageLayout in, LCMSImageLayout out) {
}
LCMS.colorConvert(tfm.ID, in.width, in.height, in.offset,
in.nextRowOffset, out.offset, out.nextRowOffset,
- in.dataArray, out.dataArray,
- in.dataType, out.dataType);
+ in.dataArray, out.dataArray);
Reference.reachabilityFence(tfm); // prevent deallocation of "tfm.ID"
}
diff --git a/src/java.desktop/share/native/liblcms/LCMS.c b/src/java.desktop/share/native/liblcms/LCMS.c
index 5cf7ee6c436..5d4ace7a624 100644
--- a/src/java.desktop/share/native/liblcms/LCMS.c
+++ b/src/java.desktop/share/native/liblcms/LCMS.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2025, 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
@@ -27,7 +27,6 @@
#include
#include
#include "sun_java2d_cmm_lcms_LCMS.h"
-#include "sun_java2d_cmm_lcms_LCMSImageLayout.h"
#include "jni_util.h"
#include "Trace.h"
#include "Disposer.h"
@@ -46,10 +45,6 @@
#define SigHead TagIdConst('h','e','a','d')
-#define DT_BYTE sun_java2d_cmm_lcms_LCMSImageLayout_DT_BYTE
-#define DT_SHORT sun_java2d_cmm_lcms_LCMSImageLayout_DT_SHORT
-#define DT_INT sun_java2d_cmm_lcms_LCMSImageLayout_DT_INT
-
/* Default temp profile list size */
#define DF_ICC_BUF_SIZE 32
@@ -464,46 +459,17 @@ JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_setTagDataNative
}
}
-static void *getILData(JNIEnv *env, jobject data, jint type) {
- switch (type) {
- case DT_BYTE:
- return (*env)->GetByteArrayElements(env, data, 0);
- case DT_SHORT:
- return (*env)->GetShortArrayElements(env, data, 0);
- case DT_INT:
- return (*env)->GetIntArrayElements(env, data, 0);
- default:
- return NULL;
- }
-}
-
-static void releaseILData(JNIEnv *env, void *pData, jint type, jobject data,
- jint mode) {
- switch (type) {
- case DT_BYTE:
- (*env)->ReleaseByteArrayElements(env, data, (jbyte *) pData, mode);
- break;
- case DT_SHORT:
- (*env)->ReleaseShortArrayElements(env, data, (jshort *) pData, mode);
- break;
- case DT_INT:
- (*env)->ReleaseIntArrayElements(env, data, (jint *) pData, mode);
- break;
- }
-}
-
/*
* Class: sun_java2d_cmm_lcms_LCMS
* Method: colorConvert
- * Signature: (JIIIIIIZZLjava/lang/Object;Ljava/lang/Object;)V
+ * Signature: (JIIIIIILjava/lang/Object;Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_colorConvert
(JNIEnv *env, jclass cls, jlong ID, jint width, jint height, jint srcOffset,
jint srcNextRowOffset, jint dstOffset, jint dstNextRowOffset,
- jobject srcData, jobject dstData, jint srcDType, jint dstDType)
+ jobject srcData, jobject dstData)
{
cmsHTRANSFORM sTrans = jlong_to_ptr(ID);
-
if (sTrans == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_colorConvert: transform == NULL");
JNU_ThrowByName(env, "java/awt/color/CMMException",
@@ -511,28 +477,22 @@ JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_colorConvert
return;
}
- void *inputBuffer = getILData(env, srcData, srcDType);
+ void *inputBuffer = (*env)->GetPrimitiveArrayCritical(env, srcData, NULL);
if (inputBuffer == NULL) {
- J2dRlsTraceLn(J2D_TRACE_ERROR, "");
// An exception should have already been thrown.
return;
}
+ void *outputBuffer = (*env)->GetPrimitiveArrayCritical(env, dstData, NULL);
+ if (outputBuffer != NULL) {
+ char *input = (char *) inputBuffer + srcOffset;
+ char *output = (char *) outputBuffer + dstOffset;
- void *outputBuffer = getILData(env, dstData, dstDType);
- if (outputBuffer == NULL) {
- releaseILData(env, inputBuffer, srcDType, srcData, JNI_ABORT);
- // An exception should have already been thrown.
- return;
- }
+ cmsDoTransformLineStride(sTrans, input, output, width, height,
+ srcNextRowOffset, dstNextRowOffset, 0, 0);
- char *input = (char *) inputBuffer + srcOffset;
- char *output = (char *) outputBuffer + dstOffset;
-
- cmsDoTransformLineStride(sTrans, input, output, width, height,
- srcNextRowOffset, dstNextRowOffset, 0, 0);
-
- releaseILData(env, inputBuffer, srcDType, srcData, JNI_ABORT);
- releaseILData(env, outputBuffer, dstDType, dstData, 0);
+ (*env)->ReleasePrimitiveArrayCritical(env, dstData, outputBuffer, 0);
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, srcData, inputBuffer, JNI_ABORT);
}
static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java b/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java
index c50a4922e80..64ff093152f 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java
@@ -27,11 +27,9 @@
import java.io.IOException;
import java.net.ProtocolException;
-import java.net.http.HttpClient.Version;
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -708,12 +706,10 @@ HttpResponse.BodySubscriber ignoreBody(HttpResponse.ResponseInfo hdrs) {
if (s == null) {
// s can be null if an exception occurred
// asynchronously while sending the preface.
- Throwable t = c.getRecordedCause();
+ final Http2TerminationCause tc = c.getTerminationCause();
IOException ioe;
- if (t != null) {
- if (!cached)
- c.close();
- ioe = new IOException("Can't get stream 1: " + t, t);
+ if (tc != null) {
+ ioe = new IOException("Can't get stream 1", tc.getCloseCause());
} else {
ioe = new IOException("Can't get stream 1");
}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java
index cc8a2a7142b..6121a0c1673 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2025, 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
@@ -25,7 +25,6 @@
package jdk.internal.net.http;
-import java.io.EOFException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Base64;
@@ -234,11 +233,8 @@ void removeFromPool(Http2Connection c) {
}
}
- private EOFException STOPPED;
void stop() {
if (debug.on()) debug.log("stopping");
- STOPPED = new EOFException("HTTP/2 client stopped");
- STOPPED.setStackTrace(new StackTraceElement[0]);
connectionPoolLock.lock();
try {
stopping = true;
@@ -253,10 +249,7 @@ void stop() {
private boolean close(Http2Connection h2c) {
// close all streams
try { h2c.closeAllStreams(); } catch (Throwable t) {}
- // send GOAWAY
try { h2c.close(); } catch (Throwable t) {}
- // attempt graceful shutdown
- try { h2c.shutdown(STOPPED); } catch (Throwable t) {}
// double check and close any new streams
try { h2c.closeAllStreams(); } catch (Throwable t) {}
// Allows for use of removeIf in stop()
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
index 63889fa6af2..94b8505da47 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
@@ -25,21 +25,20 @@
package jdk.internal.net.http;
+import java.io.Closeable;
import java.io.EOFException;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.VarHandle;
import java.net.InetSocketAddress;
import java.net.ProtocolException;
import java.net.http.HttpClient;
import java.net.http.HttpClient.Version;
import java.net.http.HttpHeaders;
import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.net.http.HttpConnectTimeoutException;
import java.time.Duration;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -49,6 +48,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Flow;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@@ -56,6 +56,7 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function;
import java.util.function.Supplier;
+
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
@@ -130,7 +131,7 @@
* and incoming stream creation (Server push). Incoming frames destined for a
* stream are provided by calling Stream.incoming().
*/
-class Http2Connection {
+class Http2Connection implements Closeable {
final Logger debug = Utils.getDebugLogger(this::dbgString);
static final Logger DEBUG_LOGGER =
@@ -143,6 +144,8 @@ class Http2Connection {
private static final int MAX_SERVER_STREAM_ID = Integer.MAX_VALUE - 1; // 2147483646
// may be null; must be accessed/updated with the stateLock held
private IdleConnectionTimeoutEvent idleConnectionTimeoutEvent;
+ private final AtomicBoolean goAwaySent = new AtomicBoolean();
+ private final AtomicBoolean goAwayRecvd = new AtomicBoolean();
/**
* Flag set when no more streams to be opened on this connection.
@@ -215,7 +218,7 @@ final class IdleConnectionTimeoutEvent extends TimeoutEvent {
}
/**
- * {@link #shutdown(Throwable) Shuts down} the connection, unless this event is
+ * {@link #close(Http2TerminationCause) Closes} the connection, unless this event is
* {@link #cancelled}
*/
@Override
@@ -228,26 +231,20 @@ public void handle() {
try {
if (cancelled) {
if (debug.on()) {
- debug.log("Not initiating idle connection shutdown");
- }
- return;
- }
- if (!markIdleShutdownInitiated()) {
- if (debug.on()) {
- debug.log("Unexpected state %s, skipping idle connection shutdown",
- describeClosedState(closedState));
+ debug.log("Idle timeout event already cancelled, not initiating idle connection close");
}
return;
}
+ // the connection has been idle long enough, we now
+ // mark a state indicating that the connection is chosen
+ // for idle termination and should not be handed out (from the pool)
+ // for newer requests.
+ connTerminator.markForIdleTermination();
} finally {
stateLock.unlock();
}
- if (debug.on()) {
- debug.log("Initiating shutdown of HTTP connection which is idle for too long");
- }
- HttpConnectTimeoutException hte = new HttpConnectTimeoutException(
- "HTTP connection idle, no active streams. Shutting down.");
- shutdown(hte);
+ // terminate the connection due to being idle long enough
+ connTerminator.idleTimedOut();
}
/**
@@ -256,7 +253,7 @@ public void handle() {
void cancel() {
assert stateLock.isHeldByCurrentThread() : "Current thread doesn't hold " + stateLock;
// mark as cancelled to prevent potentially already triggered event from actually
- // doing the shutdown
+ // doing the close
this.cancelled = true;
// cancel the timer to prevent the event from being triggered (if it hasn't already)
client().cancelTimer(this);
@@ -376,16 +373,7 @@ public void onMaxHeaderListSizeReached(long size, int maxHeaderListSize) throws
}
- private static final int HALF_CLOSED_LOCAL = 1;
- private static final int HALF_CLOSED_REMOTE = 2;
- private static final int SHUTDOWN_REQUESTED = 4;
- // state when idle connection management initiates a shutdown of the connection, after
- // which the connection will go into SHUTDOWN_REQUESTED state
- private static final int IDLE_SHUTDOWN_INITIATED = 8;
private final ReentrantLock stateLock = new ReentrantLock();
- private volatile int closedState;
-
- //-------------------------------------
final HttpConnection connection;
private final Http2ClientImpl client2;
private final ConcurrentHashMap> streams = new ConcurrentHashMap<>();
@@ -403,7 +391,9 @@ public void onMaxHeaderListSizeReached(long size, int maxHeaderListSize) throws
private final Decoder hpackIn;
final SettingsFrame clientSettings;
private volatile SettingsFrame serverSettings;
+
private record PushContinuationState(PushPromiseDecoder pushContDecoder, PushPromiseFrame pushContFrame) {}
+
private volatile PushContinuationState pushContinuationState;
private final String key; // for HttpClientImpl.connections map
private final FramesDecoder framesDecoder;
@@ -418,7 +408,7 @@ private record PushContinuationState(PushPromiseDecoder pushContDecoder, PushPro
private final FramesController framesController = new FramesController();
private final Http2TubeSubscriber subscriber;
final ConnectionWindowUpdateSender windowUpdater;
- private final AtomicReference cause = new AtomicReference<>();
+ private final Terminator connTerminator = new Terminator();
private volatile Supplier initial;
private volatile Stream> initialStream;
@@ -640,35 +630,31 @@ private boolean reserveStream0(boolean clientInitiated, boolean pushEnabled) thr
}
void abandonStream() {
- boolean shouldClose = false;
stateLock.lock();
try {
long reserved = --numReservedClientStreams;
assert reserved >= 0;
- if (finalStream && reserved == 0 && streams.isEmpty()) {
- shouldClose = true;
- }
} catch (Throwable t) {
- shutdown(t); // in case the assert fires...
+ close(Http2TerminationCause.forException(t)); // in case the assert fires...
} finally {
stateLock.unlock();
}
- // We should close the connection here if
- // it's not pooled. If it's not pooled it will
- // be marked final stream, reserved will be 0
- // after decrementing it by one, and there should
- // be no active request-response streams.
- if (shouldClose) {
- shutdown(new IOException("HTTP/2 connection abandoned"));
+ // if the connection is eligible to be closed, we close it here
+ if (shouldClose()) {
+ close(Http2TerminationCause.noErrorTermination());
}
-
}
- boolean shouldClose() {
+ /*
+ * return true if the connection is marked as "final stream" and there
+ * are no active streams on that connection and the connection isn't
+ * reserved for a new stream.
+ */
+ final boolean shouldClose() {
stateLock.lock();
try {
- return finalStream() && streams.isEmpty();
+ return finalStream() && streams.isEmpty() && numReservedClientStreams == 0;
} finally {
stateLock.unlock();
}
@@ -840,22 +826,8 @@ final int maxConcurrentServerInitiatedStreams() {
return clientSettings.getParameter(MAX_CONCURRENT_STREAMS);
}
- void close() {
- if (markHalfClosedLocal()) {
- // we send a GOAWAY frame only if the remote side hasn't already indicated
- // the intention to close the connection by previously sending a GOAWAY of its own
- if (connection.channel().isOpen() && !isMarked(closedState, HALF_CLOSED_REMOTE)) {
- Log.logTrace("Closing HTTP/2 connection: to {0}", connection.address());
- GoAwayFrame f = new GoAwayFrame(0,
- ErrorFrame.NO_ERROR,
- "Requested by user".getBytes(UTF_8));
- // TODO: set last stream. For now zero ok.
- sendFrame(f);
- }
- }
- }
-
long count;
+
final void asyncReceive(ByteBuffer buffer) {
// We don't need to read anything and
// we don't want to send anything back to the server
@@ -904,44 +876,26 @@ final void asyncReceive(ByteBuffer buffer) {
} catch (Throwable e) {
String msg = Utils.stackTrace(e);
Log.logTrace(msg);
- shutdown(e);
+ close(Http2TerminationCause.forException(e));
}
}
- Throwable getRecordedCause() {
- return cause.get();
+ /**
+ * Closes the connection normally (with a NO_ERROR termination cause), if not already closed.
+ */
+ @Override
+ public final void close() {
+ close(Http2TerminationCause.noErrorTermination());
}
- void shutdown(Throwable t) {
- int state = closedState;
- if (debug.on()) debug.log(() -> "Shutting down h2c (state="+describeClosedState(state)+"): " + t);
- stateLock.lock();
- try {
- if (!markShutdownRequested()) return;
- cause.compareAndSet(null, t);
- } finally {
- stateLock.unlock();
- }
-
- if (Log.errors()) {
- if (t!= null && (!(t instanceof EOFException) || isActive())) {
- Log.logError(t);
- } else if (t != null) {
- Log.logError("Shutting down connection: {0}", t.getMessage());
- } else {
- Log.logError("Shutting down connection");
- }
- }
- client2.removeFromPool(this);
- subscriber.stop(cause.get());
- for (Stream> s : streams.values()) {
- try {
- s.connectionClosing(t);
- } catch (Throwable e) {
- Log.logError("Failed to close stream {0}: {1}", s.streamid, e);
- }
- }
- connection.close(cause.get());
+ /**
+ * Closes the connection with the given termination cause, if not already closed.
+ *
+ * @param tc the termination cause. cannot be null.
+ */
+ final void close(final Http2TerminationCause tc) {
+ Objects.requireNonNull(tc, "termination cause cannot be null");
+ this.connTerminator.terminate(tc);
}
/**
@@ -981,15 +935,14 @@ void processFrame(Http2Frame frame) throws IOException {
} else {
if (frame instanceof SettingsFrame) {
// The stream identifier for a SETTINGS frame MUST be zero
- framesDecoder.close(
+ protocolError(ErrorFrame.PROTOCOL_ERROR,
"The stream identifier for a SETTINGS frame MUST be zero");
- protocolError(GoAwayFrame.PROTOCOL_ERROR);
return;
}
if (frame instanceof PushPromiseFrame && !serverPushEnabled()) {
String protocolError = "received a PUSH_PROMISE when SETTINGS_ENABLE_PUSH is 0";
- protocolError(ResetFrame.PROTOCOL_ERROR, protocolError);
+ protocolError(ErrorFrame.PROTOCOL_ERROR, protocolError);
return;
}
@@ -1144,7 +1097,9 @@ final void releaseUnconsumed(DataFrame df) {
// Otherwise, if the frame is dropped after having been added to the
// inputQ, releaseUnconsumed above should be called.
final void dropDataFrame(DataFrame df) {
- if (isMarked(closedState, SHUTDOWN_REQUESTED)) return;
+ if (!isOpen()) {
+ return;
+ }
if (debug.on()) {
debug.log("Dropping data frame for stream %d (%d payload bytes)",
df.streamid(), df.payloadLength());
@@ -1154,7 +1109,9 @@ final void dropDataFrame(DataFrame df) {
final void ensureWindowUpdated(DataFrame df) {
try {
- if (isMarked(closedState, SHUTDOWN_REQUESTED)) return;
+ if (!isOpen()) {
+ return;
+ }
int length = df.payloadLength();
if (length > 0) {
windowUpdater.update(length);
@@ -1251,12 +1208,16 @@ private void handleConnectionFrame(Http2Frame frame)
case AltSvcFrame.TYPE -> processAltSvcFrame(0, (AltSvcFrame) frame,
connection, connection.client());
- default -> protocolError(ErrorFrame.PROTOCOL_ERROR);
+ default -> protocolError(ErrorFrame.PROTOCOL_ERROR, "unknown frame: " + frame);
}
}
- boolean isOpen() {
- return !isMarkedForShutdown() && connection.channel().isOpen();
+ /**
+ * Returns true if this connection hasn't been terminated and the underlying
+ * {@linkplain NetworkChannel#isOpen() channel is open}. false otherwise.
+ */
+ final boolean isOpen() {
+ return this.connTerminator.terminationCause.get() == null && connection.channel().isOpen();
}
void resetStream(int streamid, int code) {
@@ -1295,6 +1256,7 @@ void decrementStreamsCount(int streamid) {
}
}
+
private void decrementStreamsCount0(int streamid) {
Stream> s = streams.get(streamid);
if (s == null || !s.deRegister())
@@ -1346,8 +1308,7 @@ void closeStream(int streamid) {
// corresponding entry in the window controller.
windowController.removeStream(streamid);
}
- if (finalStream() && streams.isEmpty()) {
- // should be only 1 stream, but there might be more if server push
+ if (shouldClose()) {
close();
} else {
// Start timer if property present and not already created
@@ -1372,9 +1333,7 @@ void closeStream(int streamid) {
/**
* Increments this connection's send Window by the amount in the given frame.
*/
- private void handleWindowUpdate(WindowUpdateFrame f)
- throws IOException
- {
+ private void handleWindowUpdate(WindowUpdateFrame f) {
int amount = f.getUpdate();
if (amount <= 0) {
// ## temporarily disable to workaround a bug in Jetty where it
@@ -1383,37 +1342,19 @@ private void handleWindowUpdate(WindowUpdateFrame f)
} else {
boolean success = windowController.increaseConnectionWindow(amount);
if (!success) {
- protocolError(ErrorFrame.FLOW_CONTROL_ERROR); // overflow
+ protocolError(ErrorFrame.FLOW_CONTROL_ERROR, null); // overflow
}
}
}
- private void protocolError(int errorCode)
- throws IOException
- {
- protocolError(errorCode, null);
- }
-
- private void protocolError(int errorCode, String msg)
- throws IOException
- {
- String protocolError = "protocol error" + (msg == null?"":(": " + msg));
- ProtocolException protocolException =
- new ProtocolException(protocolError);
- this.cause.compareAndSet(null, protocolException);
- if (markHalfClosedLocal()) {
- framesDecoder.close(protocolError);
- subscriber.stop(protocolException);
- if (debug.on()) debug.log("Sending GOAWAY due to " + protocolException);
- GoAwayFrame frame = new GoAwayFrame(0, errorCode);
- sendFrame(frame);
- }
- shutdown(protocolException);
+ private void protocolError(final int errorCode, final String msg) {
+ final Http2TerminationCause terminationCause =
+ Http2TerminationCause.forH2Error(errorCode, msg);
+ framesDecoder.close(terminationCause.getLogMsg());
+ close(terminationCause);
}
- private void handleSettings(SettingsFrame frame)
- throws IOException
- {
+ private void handleSettings(SettingsFrame frame) {
assert frame.streamid() == 0;
if (!frame.getFlag(SettingsFrame.ACK)) {
int newWindowSize = frame.getParameter(INITIAL_WINDOW_SIZE);
@@ -1430,9 +1371,7 @@ private void handleSettings(SettingsFrame frame)
}
}
- private void handlePing(PingFrame frame)
- throws IOException
- {
+ private void handlePing(PingFrame frame) {
frame.setFlag(PingFrame.ACK);
sendUnorderedFrame(frame);
}
@@ -1442,7 +1381,7 @@ private void handleGoAway(final GoAwayFrame frame) {
assert lastProcessedStream >= 0 : "unexpected last stream id: "
+ lastProcessedStream + " in GOAWAY frame";
- markHalfClosedRemote();
+ goAwayRecvd.set(true);
setFinalStream(); // don't allow any new streams on this connection
if (debug.on()) {
debug.log("processing incoming GOAWAY with last processed stream id:%s in frame %s",
@@ -1599,20 +1538,20 @@ boolean tryReserveForPoolCheckout() {
// must be done with "stateLock" held to co-ordinate idle connection management
stateLock.lock();
try {
- cancelIdleShutdownEvent();
- // consider the reservation successful only if the connection's state hasn't moved
- // to "being closed"
- return isOpen();
+ cancelIdleCloseEvent();
+ // consider the reservation successful only if the connection is open and
+ // hasn't been chosen for idle termination
+ return !this.connTerminator.isMarkedForIdleTermination() && isOpen();
} finally {
stateLock.unlock();
}
}
/**
- * Cancels any event that might have been scheduled to shutdown this connection. Must be called
+ * Cancels any event that might have been scheduled to close this connection. Must be called
* with the stateLock held.
*/
- private void cancelIdleShutdownEvent() {
+ private void cancelIdleCloseEvent() {
assert stateLock.isHeldByCurrentThread() : "Current thread doesn't hold " + stateLock;
if (idleConnectionTimeoutEvent == null) {
return;
@@ -1627,20 +1566,23 @@ void putStream(Stream stream, int streamid) {
// the stream is closed.
stateLock.lock();
try {
- if (!isMarkedForShutdown()) {
+ if (isOpen() && !this.connTerminator.isMarkedForIdleTermination()) {
if (debug.on()) {
debug.log("Opened stream %d", streamid);
}
client().streamReference();
streams.put(streamid, stream);
- cancelIdleShutdownEvent();
+ // don't consider the connection idle anymore
+ cancelIdleCloseEvent();
return;
}
} finally {
stateLock.unlock();
}
if (debug.on()) debug.log("connection closed: closing stream %d", stream);
- stream.cancel(new IOException("Stream " + streamid + " cancelled", cause.get()));
+ final Http2TerminationCause terminationCause = getTerminationCause();
+ assert terminationCause != null : "termination cause is null";
+ stream.cancel(new IOException("Stream " + streamid + " cancelled", terminationCause.getCloseCause()));
}
/**
@@ -1743,11 +1685,10 @@ private Stream> registerNewStream(OutgoingHeaders> oh) {
int streamid = nextstreamid;
Throwable cause = null;
synchronized (this) {
- if (isMarked(closedState, SHUTDOWN_REQUESTED)) {
- cause = this.cause.get();
- if (cause == null) {
- cause = new IOException("Connection closed");
- }
+ if (!isOpen()) {
+ final Http2TerminationCause terminationCause = getTerminationCause();
+ assert terminationCause != null : "termination cause is null";
+ cause = terminationCause.getCloseCause();
}
}
if (cause != null) {
@@ -1762,7 +1703,7 @@ private Stream> registerNewStream(OutgoingHeaders> oh) {
return stream;
} else {
stream.cancelImpl(new IOException("Request cancelled"));
- if (finalStream() && streams.isEmpty()) {
+ if (shouldClose()) {
close();
}
return null;
@@ -1795,14 +1736,12 @@ void sendFrame(Http2Frame frame) {
}
publisher.signalEnqueued();
} catch (IOException e) {
- if (!isMarked(closedState, SHUTDOWN_REQUESTED)) {
- if (!client2.stopping()) {
- Log.logError(e);
- shutdown(e);
- } else if (debug.on()) {
- debug.log("Failed to send %s while stopping: %s", frame, e);
- }
+ if (!client2.stopping()) {
+ Log.logError(e);
+ } else if (debug.on()) {
+ debug.log("Failed to send %s while stopping: %s", frame, e);
}
+ close(Http2TerminationCause.forException(e));
}
}
@@ -1817,14 +1756,12 @@ void sendDataFrame(DataFrame frame) {
publisher.enqueue(encodeFrame(frame));
publisher.signalEnqueued();
} catch (IOException e) {
- if (!isMarked(closedState, SHUTDOWN_REQUESTED)) {
- if (!client2.stopping()) {
- Log.logError(e);
- shutdown(e);
- } else if (debug.on()) {
- debug.log("Failed to send %s while stopping: %s", frame, e);
- }
+ if (!client2.stopping()) {
+ Log.logError(e);
+ } else if (debug.on()) {
+ debug.log("Failed to send %s while stopping: %s", frame, e);
}
+ close(Http2TerminationCause.forException(e));
}
}
@@ -1839,10 +1776,12 @@ void sendUnorderedFrame(Http2Frame frame) {
publisher.enqueueUnordered(encodeFrame(frame));
publisher.signalEnqueued();
} catch (IOException e) {
- if (!isMarked(closedState, SHUTDOWN_REQUESTED)) {
+ if (!client2.stopping()) {
Log.logError(e);
- shutdown(e);
+ } else if (debug.on()) {
+ debug.log("Failed to send %s while stopping: %s", frame, e);
}
+ close(Http2TerminationCause.forException(e));
}
}
@@ -1868,6 +1807,7 @@ final void processQueue() {
try {
while (!queue.isEmpty() && !scheduler.isStopped()) {
ByteBuffer buffer = queue.poll();
+ assert buffer != null : "null buffer obtained from non-empty queue";
if (debug.on())
debug.log("sending %d to Http2Connection.asyncReceive",
buffer.remaining());
@@ -1877,7 +1817,12 @@ final void processQueue() {
errorRef.compareAndSet(null, t);
} finally {
Throwable x = errorRef.get();
- if (x != null) {
+ // if there was any error or if the TubeSubscriber completed normally,
+ // then close the connection
+ if (x != null || completed) {
+ // although the connection terminator stops the scheduler too,
+ // we don't want to wait that "long" and instead we should immediately
+ // stop the scheduler so that we don't enter "processQueue" anymore.
scheduler.stop();
if (client2.stopping()) {
if (debug.on()) {
@@ -1888,7 +1833,11 @@ final void processQueue() {
debug.log("Stopping scheduler", x);
}
}
- Http2Connection.this.shutdown(x);
+ // terminate the connection
+ final Http2TerminationCause tc = (x != null)
+ ? Http2TerminationCause.forException(x)
+ : Http2TerminationCause.noErrorTermination();
+ Http2Connection.this.close(tc);
}
}
}
@@ -1938,11 +1887,17 @@ public void onError(Throwable throwable) {
@Override
public void onComplete() {
if (completed) return;
- String msg = isActive()
- ? "EOF reached while reading"
- : "Idle connection closed by HTTP/2 peer";
- if (debug.on()) debug.log(msg);
- errorRef.compareAndSet(null, new EOFException(msg));
+ if (isActive()) {
+ final String msg = "EOF reached while reading";
+ errorRef.compareAndSet(null, new EOFException(msg));
+ if (debug.on()) {
+ debug.log(msg);
+ }
+ } else {
+ if (debug.on()) {
+ debug.log("HTTP/2 connection (with no active streams) closed by peer");
+ }
+ }
completed = true;
runOrSchedule();
}
@@ -1955,16 +1910,13 @@ public void dropSubscription() {
dropped = true;
}
- void stop(Throwable error) {
- if (errorRef.compareAndSet(null, error)) {
- completed = true;
- scheduler.stop();
- queue.clear();
- if (subscription != null) {
- subscription.cancel();
- }
- queue.clear();
+ private void close() {
+ scheduler.stop();
+ queue.clear();
+ if (subscription != null) {
+ subscription.cancel();
}
+ queue.clear();
}
}
@@ -1990,6 +1942,7 @@ final String dbgString() {
static final class ConnectionWindowUpdateSender extends WindowUpdateSender {
final int initialWindowSize;
+
public ConnectionWindowUpdateSender(Http2Connection connection,
int initialWindowSize) {
super(connection, initialWindowSize);
@@ -2004,13 +1957,9 @@ int getStreamId() {
@Override
protected boolean windowSizeExceeded(long received) {
if (connection.isOpen()) {
- try {
- connection.protocolError(ErrorFrame.FLOW_CONTROL_ERROR,
- "connection window exceeded (%s > %s)"
- .formatted(received, windowSize));
- } catch (IOException io) {
- connection.shutdown(io);
- }
+ connection.protocolError(ErrorFrame.FLOW_CONTROL_ERROR,
+ "connection window exceeded (%s > %s)"
+ .formatted(received, windowSize));
}
return true;
}
@@ -2033,72 +1982,144 @@ AbstractAsyncSSLConnection getConnection() {
}
}
- private boolean isMarked(int state, int mask) {
- return (state & mask) == mask;
- }
-
- private boolean isMarkedForShutdown() {
- final int closedSt = closedState;
- return isMarked(closedSt, IDLE_SHUTDOWN_INITIATED)
- || isMarked(closedSt, SHUTDOWN_REQUESTED);
- }
-
- private boolean markShutdownRequested() {
- return markClosedState(SHUTDOWN_REQUESTED);
- }
-
- private boolean markHalfClosedLocal() {
- return markClosedState(HALF_CLOSED_LOCAL);
- }
-
- private boolean markHalfClosedRemote() {
- return markClosedState(HALF_CLOSED_REMOTE);
- }
-
- private boolean markIdleShutdownInitiated() {
- return markClosedState(IDLE_SHUTDOWN_INITIATED);
- }
-
- private boolean markClosedState(int flag) {
- int state, desired;
- do {
- state = desired = closedState;
- if ((state & flag) == flag) return false;
- desired = state | flag;
- } while (!CLOSED_STATE.compareAndSet(this, state, desired));
- return true;
+ private void sendGoAway(final GoAwayFrame goAway) {
+ // currently we send a GOAWAY just once irrespective of what value the
+ // last stream id was in the GOAWAY frame
+ if (!goAwaySent.compareAndSet(false, true)) {
+ // already sent
+ return;
+ }
+ if (Log.trace()) {
+ Log.logTrace("{0} sending GOAWAY {1}", connection, goAway);
+ } else if (debug.on()) {
+ debug.log("sending GOAWAY " + goAway);
+ }
+ // this merely enqueues the frame
+ sendFrame(goAway);
}
- String describeClosedState(int state) {
- if (state == 0) return "active";
- String desc = null;
- if (isMarked(state, IDLE_SHUTDOWN_INITIATED)) {
- desc = "idle-shutdown-initiated";
+ /**
+ * Returns the termination cause if the connection is closed, else returns null.
+ */
+ final Http2TerminationCause getTerminationCause() {
+ return this.connTerminator.determineTerminationCause();
+ }
+
+ // Responsible for doing all the necessary work for closing a Http2Connection
+ private final class Terminator {
+ // the cause for closing the connection. Must only be set in the
+ // Terminator.terminate(Http2TerminationCause) method.
+ private final AtomicReference terminationCause = new AtomicReference<>();
+ // true if it has been decided to terminate the connection due to being idle,
+ // false otherwise. should be accessed only when holding the stateLock
+ private boolean chosenForIdleTermination;
+
+ private void terminate(final Http2TerminationCause terminationCause) {
+ Objects.requireNonNull(terminationCause, "termination cause cannot be null");
+ // allow to be terminated only once
+ stateLock.lock();
+ try {
+ final boolean success = this.terminationCause.compareAndSet(null, terminationCause);
+ if (!success) {
+ // already terminated or is being terminated by some other thread
+ return;
+ }
+ // disable the idle timeout event, since we are now going to terminate the
+ // connection
+ Http2Connection.this.cancelIdleCloseEvent();
+ } finally {
+ stateLock.unlock();
+ }
+ // do the actual termination
+ doTerminate();
}
- if (isMarked(state, SHUTDOWN_REQUESTED)) {
- desc = desc == null ? "shutdown" : desc + "+shutdown";
+
+ private void doTerminate() {
+ final Http2TerminationCause tc = terminationCause.get();
+ assert tc != null : "missing termination cause";
+ // we send a GOAWAY frame only if the remote side hasn't already indicated
+ // the intention to close the connection by previously sending a GOAWAY of its own
+ if (!Http2Connection.this.goAwayRecvd.get()) {
+ final int lastStream = 0; // TODO: set last stream. For now zero is ok.
+ final String peerVisibleReason = tc.getPeerVisibleReason();
+ final GoAwayFrame goAway;
+ if (peerVisibleReason == null) {
+ goAway = new GoAwayFrame(lastStream, tc.getCloseCode());
+ } else {
+ goAway = new GoAwayFrame(lastStream, tc.getCloseCode(),
+ peerVisibleReason.getBytes(UTF_8));
+ }
+ sendGoAway(goAway);
+ }
+ // now close the connection
+
+ if (Log.errors() || debug.on()) {
+ final String stateStr = "Abnormal close=" + tc.isAbnormalClose() +
+ ", has active streams=" + isActive() +
+ ", GOAWAY received=" + goAwayRecvd.get() +
+ ", GOAWAY sent=" + goAwaySent.get();
+ if (Log.errors()) {
+ Log.logError("Closing connection {0} ({1}) due to: {2}",
+ connection, stateStr, tc);
+ } else {
+ debug.log("Closing connection (" + stateStr + ") due to: " + tc);
+ }
+ }
+ // close the TubeSubscriber
+ subscriber.close();
+ client2.removeFromPool(Http2Connection.this);
+ // notify the HTTP/2 streams of the connection closure
+ for (final Stream> s : streams.values()) {
+ try {
+ s.connectionClosing(tc.getCloseCause());
+ } catch (Throwable e) {
+ Log.logError("Failed to close stream {0}: {1}", s.streamid, e);
+ }
+ }
+ // close the underlying connection
+ connection.close(tc.getCloseCause());
}
- if (isMarked(state, HALF_CLOSED_LOCAL | HALF_CLOSED_REMOTE)) {
- if (desc == null) return "closed";
- else return desc + "+closed";
+
+ private void markForIdleTermination() {
+ assert stateLock.isHeldByCurrentThread() : Thread.currentThread()
+ + " not holding stateLock";
+ this.chosenForIdleTermination = true;
}
- if (isMarked(state, HALF_CLOSED_LOCAL)) {
- if (desc == null) return "half-closed-local";
- else return desc + "+half-closed-local";
+
+ private boolean isMarkedForIdleTermination() {
+ assert stateLock.isHeldByCurrentThread() : Thread.currentThread()
+ + " not holding stateLock";
+ return this.chosenForIdleTermination;
}
- if (isMarked(state, HALF_CLOSED_REMOTE)) {
- if (desc == null) return "half-closed-remote";
- else return desc + "+half-closed-remote";
+
+ private void idleTimedOut() {
+ if (debug.on()) {
+ debug.log("closing connection due to being idle");
+ }
+ this.terminate(Http2TerminationCause.idleTimedOut());
}
- return "0x" + Integer.toString(state, 16);
- }
- private static final VarHandle CLOSED_STATE;
- static {
- try {
- CLOSED_STATE = MethodHandles.lookup().findVarHandle(Http2Connection.class, "closedState", int.class);
- } catch (Exception x) {
- throw new ExceptionInInitializerError(x);
+ /**
+ * Returns the termination cause for the connection. This method guarantees that if the
+ * {@linkplain Http2Connection#isOpen() connection is not open}, when this method is called,
+ * then it returns a non-null termination cause. Returns null if the connection is open.
+ */
+ private Http2TerminationCause determineTerminationCause() {
+ final Http2TerminationCause tc = this.terminationCause.get();
+ if (tc != null) {
+ // already terminated, return the cause
+ return tc;
+ }
+ if (!connection.channel().isOpen()) {
+ // if the underlying SocketChannel isn't open, then terminate the connection.
+ // that way when Http2Connection.isOpen() returns false in that situation, then this
+ // getTerminationCause() will return a termination cause.
+ terminate(Http2TerminationCause.forException(new ClosedChannelException()));
+ final Http2TerminationCause terminated = this.terminationCause.get();
+ assert terminated != null : "missing termination cause";
+ return terminated;
+ }
+ return null; // connection still open
}
}
}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2TerminationCause.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2TerminationCause.java
new file mode 100644
index 00000000000..89b08cf8888
--- /dev/null
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2TerminationCause.java
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.net.http;
+
+
+import java.io.IOException;
+import java.net.ProtocolException;
+import java.util.Objects;
+
+import jdk.internal.net.http.common.Utils;
+import jdk.internal.net.http.frame.ErrorFrame;
+
+/**
+ * Termination cause for an {@linkplain Http2Connection HTTP/2 connection}
+ */
+public abstract sealed class Http2TerminationCause {
+ private String logMsg;
+ private String peerVisibleReason;
+ private final int closeCode;
+ private final Throwable originalCause;
+ private final IOException reportedCause;
+
+ private Http2TerminationCause(final int closeCode, final Throwable closeCause) {
+ this.closeCode = closeCode;
+ this.originalCause = closeCause;
+ if (closeCause != null) {
+ this.logMsg = closeCause.toString();
+ }
+ this.reportedCause = toReportedCause(this.originalCause, this.logMsg);
+ }
+
+ private Http2TerminationCause(final int closeCode, final String loggedAs) {
+ this.closeCode = closeCode;
+ this.originalCause = null;
+ this.logMsg = loggedAs;
+ this.reportedCause = toReportedCause(null, this.logMsg);
+ }
+
+ /**
+ * Returns the error code (specified for HTTP/2 ErrorFrame) that caused the
+ * connection termination.
+ */
+ public final int getCloseCode() {
+ return this.closeCode;
+ }
+
+ /**
+ * Returns the {@link IOException} that is considered the cause of the connection termination.
+ * Even a {@linkplain #isAbnormalClose() normal} termination will have
+ * an {@code IOException} associated with it, so this method will always return a non-null instance.
+ */
+ public final IOException getCloseCause() {
+ return this.reportedCause;
+ }
+
+ /**
+ * Returns {@code true} if the connection was terminated due to some exception. {@code false}
+ * otherwise.
+ * A normal connection termination (for example, the connection idle timing out locally)
+ * is not considered as an abnormal termination and this method returns {@code false} for
+ * such cases.
+ */
+ public abstract boolean isAbnormalClose();
+
+ /**
+ * Returns the connection termination cause, represented as a string. Unlike the
+ * {@linkplain #getPeerVisibleReason() peer-visible reason}, this log message will not be
+ * sent across to the peer and it is thus allowed to include additional details that might
+ * help debugging a connection termination.
+ */
+ public final String getLogMsg() {
+ return logMsg;
+ }
+
+ /**
+ * Returns the connection termination cause, represented as a string. This represents the
+ * "debugData" that is sent to the peer in a
+ * {@linkplain jdk.internal.net.http.frame.GoAwayFrame GOAWAY frame}.
+ */
+ public final String getPeerVisibleReason() {
+ return this.peerVisibleReason;
+ }
+
+ /**
+ * Sets the connection termination cause, represented as a string, which will be sent
+ * to the peer in a {@linkplain jdk.internal.net.http.frame.GoAwayFrame GOAWAY frame}.
+ * Unlike the {@link #getLogMsg() log message},
+ * it is expected that this peer-visible reason will not contain anything that is not meant
+ * to be viewed by the peer.
+ */
+ protected final void setPeerVisibleReason(final String reasonPhrase) {
+ this.peerVisibleReason = reasonPhrase;
+ }
+
+ /**
+ * Returns a connection termination cause that represents an
+ * {@linkplain #isAbnormalClose() abnormal} termination due to the given {@code cause}.
+ *
+ * @param cause the termination cause, cannot be null.
+ */
+ public static Http2TerminationCause forException(final Throwable cause) {
+ Objects.requireNonNull(cause);
+ if (cause instanceof ProtocolException pe) {
+ return new ProtocolError(pe);
+ }
+ return new InternalError(cause);
+ }
+
+ /**
+ * Returns a connection termination cause that represents a
+ * {@linkplain #isAbnormalClose() normal} termination.
+ */
+ public static Http2TerminationCause noErrorTermination() {
+ return NoError.INSTANCE;
+ }
+
+ /**
+ * Returns a connection termination cause that represents a
+ * {@linkplain #isAbnormalClose() normal} termination due to the connection
+ * being idle.
+ */
+ public static Http2TerminationCause idleTimedOut() {
+ return NoError.IDLE_TIMED_OUT;
+ }
+
+ /**
+ * Returns a connection termination cause that represents an
+ * {@linkplain #isAbnormalClose() abnormal} termination due to the given {@code errorCode}.
+ * Although this method does no checks for the {@code errorCode}, it is expected to be one
+ * of the error codes specified by the HTTP/2 RFC for the ErrorFrame.
+ *
+ * @param errorCode the error code
+ * @param loggedAs optional log message to be associated with this termination cause
+ */
+ public static Http2TerminationCause forH2Error(final int errorCode, final String loggedAs) {
+ if (errorCode == ErrorFrame.PROTOCOL_ERROR) {
+ return new ProtocolError(loggedAs);
+ } else if (errorCode == ErrorFrame.FLOW_CONTROL_ERROR) {
+ // we treat flow control error as a protocol error currently
+ return new ProtocolError(loggedAs, true);
+ }
+ return new H2StandardError(errorCode, loggedAs);
+ }
+
+ private static IOException toReportedCause(final Throwable original,
+ final String fallbackExceptionMsg) {
+ if (original == null) {
+ return fallbackExceptionMsg == null
+ ? new IOException("connection terminated")
+ : new IOException(fallbackExceptionMsg);
+ } else if (original instanceof IOException ioe) {
+ return ioe;
+ } else {
+ return Utils.toIOException(original);
+ }
+ }
+
+ private static final class NoError extends Http2TerminationCause {
+ private static final IOException NO_ERROR_MARKER =
+ new IOException("HTTP/2 connection closed normally - no error");
+ private static final IOException NO_ERROR_IDLE_TIMED_OUT_MARKER =
+ new IOException("HTTP/2 connection idle timed out - no error");
+
+ static {
+ // remove the stacktrace from the marker exception instances
+ NO_ERROR_MARKER.setStackTrace(new StackTraceElement[0]);
+ NO_ERROR_IDLE_TIMED_OUT_MARKER.setStackTrace(new StackTraceElement[0]);
+ }
+
+ private static final NoError INSTANCE = new NoError(false);
+ private static final NoError IDLE_TIMED_OUT = new NoError(true);
+
+ private final boolean idleTimedOut;
+
+ private NoError(final boolean idleTimedOut) {
+ super(ErrorFrame.NO_ERROR,
+ idleTimedOut ? NO_ERROR_IDLE_TIMED_OUT_MARKER : NO_ERROR_MARKER);
+ this.idleTimedOut = idleTimedOut;
+ setPeerVisibleReason(idleTimedOut ? "idle timed out" : "no error");
+ }
+
+ @Override
+ public boolean isAbnormalClose() {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return this.idleTimedOut
+ ? "No error - idle timed out"
+ : "No error - normal termination";
+ }
+ }
+
+ private static sealed class H2StandardError extends Http2TerminationCause {
+ private H2StandardError(final int errCode, final String msg) {
+ super(errCode, msg);
+ setPeerVisibleReason(ErrorFrame.stringForCode(errCode));
+ }
+
+ private H2StandardError(final int errCode, final Throwable cause) {
+ super(errCode, cause);
+ setPeerVisibleReason(ErrorFrame.stringForCode(errCode));
+ }
+
+ @Override
+ public boolean isAbnormalClose() {
+ return getCloseCode() != ErrorFrame.NO_ERROR;
+ }
+
+ @Override
+ public String toString() {
+ return ErrorFrame.stringForCode(this.getCloseCode());
+ }
+ }
+
+ private static final class ProtocolError extends H2StandardError {
+ private ProtocolError(final String msg) {
+ this(msg, false);
+ }
+
+ private ProtocolError(final String msg, final boolean flowControlError) {
+ super(flowControlError
+ ? ErrorFrame.FLOW_CONTROL_ERROR
+ : ErrorFrame.PROTOCOL_ERROR,
+ new ProtocolException(msg));
+ }
+
+ private ProtocolError(final ProtocolException pe) {
+ super(ErrorFrame.PROTOCOL_ERROR, pe);
+ }
+
+ @Override
+ public boolean isAbnormalClose() {
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Protocol error - " + this.getLogMsg();
+ }
+ }
+
+ private static final class InternalError extends Http2TerminationCause {
+ private InternalError(final Throwable cause) {
+ super(ErrorFrame.INTERNAL_ERROR, cause);
+ }
+
+ @Override
+ public boolean isAbnormalClose() {
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Internal error - " + this.getLogMsg();
+ }
+ }
+}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java b/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java
index 6ea196a4d1c..af9fd3b96ba 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java
@@ -98,6 +98,7 @@
import jdk.internal.net.http.common.OperationTrackers.Tracker;
import jdk.internal.net.http.common.Utils.SafeExecutor;
import jdk.internal.net.http.common.Utils.SafeExecutorService;
+import jdk.internal.net.http.common.Utils.UseVTForSelector;
import jdk.internal.net.http.websocket.BuilderImpl;
import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY;
@@ -126,6 +127,16 @@ final class HttpClientImpl extends HttpClient implements Trackable {
static final long IDLE_CONNECTION_TIMEOUT_H2 = getTimeoutProp("jdk.httpclient.keepalive.timeout.h2", KEEP_ALIVE_TIMEOUT);
static final long IDLE_CONNECTION_TIMEOUT_H3 = getTimeoutProp("jdk.httpclient.keepalive.timeout.h3", IDLE_CONNECTION_TIMEOUT_H2);
+ static final UseVTForSelector USE_VT_FOR_SELECTOR =
+ Utils.useVTForSelector("jdk.internal.httpclient.tcp.selector.useVirtualThreads", "default");
+ private static boolean useVtForSelector() {
+ return switch (USE_VT_FOR_SELECTOR) {
+ case ALWAYS -> true;
+ case NEVER -> false;
+ default -> true;
+ };
+ }
+
// Define the default factory as a static inner class
// that embeds all the necessary logic to avoid
// the risk of using a lambda that might keep a reference on the
@@ -293,7 +304,6 @@ static CompletableFuture registerPending(PendingRequest pending, Completa
if (pending.cf.isDone()) return res;
var client = pending.client;
- var cf = pending.cf;
var id = pending.id;
boolean added = client.pendingRequests.add(pending);
// this may immediately remove `pending` from the set is the cf is already completed
@@ -342,6 +352,7 @@ static void abortPendingRequests(HttpClientImpl client, Throwable reason) {
private final boolean isDefaultExecutor;
private final SSLContext sslContext;
private final SSLParameters sslParams;
+ private final Thread selmgrThread;
private final SelectorManager selmgr;
private final FilterFactory filters;
private final Http2ClientImpl client2;
@@ -509,7 +520,11 @@ private HttpClientImpl(HttpClientBuilderImpl builder,
// unlikely
throw new UncheckedIOException(e);
}
- selmgr.setDaemon(true);
+ selmgrThread = useVtForSelector()
+ ? Thread.ofVirtual().name("HttpClient-" + id + "-SelectorManager")
+ .inheritInheritableThreadLocals(false).unstarted(selmgr)
+ : Thread.ofPlatform().name("HttpClient-" + id + "-SelectorManager")
+ .inheritInheritableThreadLocals(false).daemon().unstarted(selmgr);
filters = new FilterFactory();
initFilters();
assert facadeRef.get() != null;
@@ -528,7 +543,7 @@ void onSubmitFailure(Runnable command, Throwable failure) {
private void start() {
try {
- selmgr.start();
+ selmgrThread.start();
} catch (Throwable t) {
isStarted.set(true);
throw t;
@@ -635,7 +650,7 @@ public void shutdownNow() {
@Override
public boolean awaitTermination(Duration duration) throws InterruptedException {
// Implicit NPE will be thrown if duration is null
- return selmgr.join(duration);
+ return selmgrThread.join(duration);
}
@Override
@@ -927,7 +942,7 @@ void eventUpdated(AsyncEvent event) throws ClosedChannelException {
}
boolean isSelectorThread() {
- return Thread.currentThread() == selmgr;
+ return Thread.currentThread() == selmgrThread;
}
AltServicesRegistry registry() { return registry; }
@@ -1157,7 +1172,7 @@ private static CompletableFuture> translateSendAsyncExecFail
}
// Main loop for this client's selector
- private static final class SelectorManager extends Thread {
+ private static final class SelectorManager implements Runnable {
// For testing purposes we have an internal System property that
// can control the frequency at which the selector manager will wake
@@ -1196,9 +1211,6 @@ private static final class SelectorManager extends Thread {
private final ReentrantLock lock = new ReentrantLock();
SelectorManager(HttpClientImpl ref) throws IOException {
- super(null, null,
- "HttpClient-" + ref.id + "-SelectorManager",
- 0, false);
owner = ref;
debug = ref.debug;
debugtimeout = ref.debugtimeout;
@@ -1221,7 +1233,7 @@ IOException selectorClosedException() {
}
void eventUpdated(AsyncEvent e) throws ClosedChannelException {
- if (Thread.currentThread() == this) {
+ if (owner.isSelectorThread()) {
SelectionKey key = e.channel().keyFor(selector);
if (key != null && key.isValid()) {
SelectorAttachment sa = (SelectorAttachment) key.attachment();
@@ -1315,6 +1327,10 @@ void abort(Throwable t) {
if (!inSelectorThread) selector.wakeup();
}
+ String getName() {
+ return owner.selmgrThread.getName();
+ }
+
// Only called by the selector manager thread
private void shutdown() {
try {
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java
index 0219b0960d7..115bc56f804 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java
@@ -540,9 +540,7 @@ public List getSNIServerNames() {
* Closes this connection due to the given cause.
* @param cause the cause for which the connection is closed, may be null
*/
- void close(Throwable cause) {
- close();
- }
+ abstract void close(Throwable cause);
/**
* {@return the underlying connection flow, if applicable}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java
index a02506cff5c..20b0338215c 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java
@@ -242,6 +242,15 @@ private static Set getDisallowedRedirectHeaders() {
return true;
};
+ public enum UseVTForSelector { ALWAYS, NEVER, DEFAULT }
+
+ public static UseVTForSelector useVTForSelector(String property, String defval) {
+ String useVtForSelector = System.getProperty(property, defval);
+ return Stream.of(UseVTForSelector.values())
+ .filter((v) -> v.name().equalsIgnoreCase(useVtForSelector))
+ .findFirst().orElse(UseVTForSelector.DEFAULT);
+ }
+
public static T addSuppressed(T x, Throwable suppressed) {
if (x != suppressed && suppressed != null) {
var sup = x.getSuppressed();
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/ConnectionTerminatorImpl.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/ConnectionTerminatorImpl.java
index 150d6233953..0f5aa4cb7ac 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/ConnectionTerminatorImpl.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/ConnectionTerminatorImpl.java
@@ -143,8 +143,9 @@ void incomingStatelessReset() {
Log.logError("{0}: stateless reset from peer ({1})", connection.logTag(),
(peerIsServer ? "server" : "client"));
}
+ var label = "quic:" + connection.uniqueId();
final SilentTermination st = forSilentTermination("stateless reset from peer ("
- + (peerIsServer ? "server" : "client") + ")");
+ + (peerIsServer ? "server" : "client") + ") on " + label);
terminate(st);
}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/IdleTimeoutManager.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/IdleTimeoutManager.java
index a7469f18ed8..72ce0290038 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/IdleTimeoutManager.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/IdleTimeoutManager.java
@@ -346,8 +346,10 @@ private void idleTimedOut() {
}
}
// silently close the connection and discard all its state
- final TerminationCause cause = forSilentTermination("connection idle timed out ("
- + timeoutMillis + " milli seconds)");
+ var type = connection.isClientConnection() ? "client" : "server";
+ var label = "quic:" + connection.uniqueId();
+ final TerminationCause cause = forSilentTermination(type + " connection idle timed out ("
+ + timeoutMillis + " milli seconds) on " + label);
connection.terminator.terminate(cause);
}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/PacketSpaceManager.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/PacketSpaceManager.java
index 90031decdb4..487a8a186f6 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/PacketSpaceManager.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/PacketSpaceManager.java
@@ -385,10 +385,10 @@ private void handleLoop0() throws IOException, QuicTransportException {
}
packetEmitter.checkAbort(PacketSpaceManager.this.packetNumberSpace);
// Handle is called from within the executor
- var nextDeadline = this.nextDeadline;
+ Deadline newDeadline;
Deadline now = now();
- congestionController.updatePacer(now);
do {
+ congestionController.updatePacer(now);
transmitNow = false;
var closed = !isOpenForTransmission();
if (closed) {
@@ -534,16 +534,17 @@ private void handleLoop0() throws IOException, QuicTransportException {
packetEmitter.ptoBackoffIncreased(PacketSpaceManager.this, backoff);
}
- // if nextDeadline is not Deadline.MAX the task will be
+ // if newDeadline is not Deadline.MAX the task will be
// automatically rescheduled.
if (debug.on()) debug.log("handle: refreshing deadline");
- nextDeadline = computeNextDeadline();
- } while(!nextDeadline.isAfter(now));
+ newDeadline = computeNextDeadline();
+ now = now();
+ } while(!newDeadline.isAfter(now));
- logNoDeadline(nextDeadline, true);
- if (Deadline.MAX.equals(nextDeadline)) return;
+ logNoDeadline(newDeadline, true);
+ if (Deadline.MAX.equals(newDeadline)) return;
// we have a new deadline
- packetEmitter.reschedule(this, nextDeadline);
+ packetEmitter.reschedule(this, newDeadline);
}
/**
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicBaseCongestionController.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicBaseCongestionController.java
new file mode 100644
index 00000000000..7dd3276f0d3
--- /dev/null
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicBaseCongestionController.java
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2022, 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.net.http.quic;
+
+import jdk.internal.net.http.common.Deadline;
+import jdk.internal.net.http.common.Log;
+import jdk.internal.net.http.common.TimeLine;
+import jdk.internal.net.http.common.TimeSource;
+import jdk.internal.net.http.common.Utils;
+import jdk.internal.net.http.quic.frames.AckFrame;
+import jdk.internal.net.http.quic.packets.QuicPacket;
+
+import java.util.Collection;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Implementation of the common parts of a QUIC congestion controller based on RFC 9002.
+ *
+ * This class implements the common parts of a congestion controller:
+ * - slow start
+ * - loss recovery
+ * - cooperation with pacer
+ *
+ * Subclasses implement congestion window growth in congestion avoidance phase.
+ *
+ * @spec https://www.rfc-editor.org/info/rfc9002
+ * RFC 9002: QUIC Loss Detection and Congestion Control
+ */
+abstract class QuicBaseCongestionController implements QuicCongestionController {
+ // higher of 14720 and 2*maxDatagramSize; we use fixed maxDatagramSize
+ private static final int INITIAL_WINDOW = Math.max(14720, 2 * QuicConnectionImpl.DEFAULT_DATAGRAM_SIZE);
+ private static final int MAX_BYTES_IN_FLIGHT = Math.clamp(
+ Utils.getLongProperty("jdk.httpclient.quic.maxBytesInFlight", 1 << 24),
+ 1 << 14, 1 << 24);
+ final TimeLine timeSource;
+ final String dbgTag;
+ final Lock lock = new ReentrantLock();
+ long congestionWindow = INITIAL_WINDOW;
+ int maxDatagramSize = QuicConnectionImpl.DEFAULT_DATAGRAM_SIZE;
+ int minimumWindow = 2 * maxDatagramSize;
+ long bytesInFlight;
+ // maximum bytes in flight seen since the last congestion event
+ long maxBytesInFlight;
+ Deadline congestionRecoveryStartTime;
+ long ssThresh = Long.MAX_VALUE;
+
+ private final QuicPacer pacer;
+
+ QuicBaseCongestionController(String dbgTag, QuicRttEstimator rttEstimator) {
+ this(dbgTag, TimeSource.source(), rttEstimator);
+ }
+
+ // Allows to pass a custom timeline for testing
+ QuicBaseCongestionController(String dbgTag, TimeLine source, QuicRttEstimator rttEstimator) {
+ this.dbgTag = dbgTag;
+ this.timeSource = source;
+ this.pacer = new QuicPacer(rttEstimator, this);
+ }
+
+ boolean inCongestionRecovery(Deadline sentTime) {
+ return (congestionRecoveryStartTime != null &&
+ !sentTime.isAfter(congestionRecoveryStartTime));
+ }
+
+ abstract void onCongestionEvent(Deadline sentTime);
+
+ private static boolean inFlight(QuicPacket packet) {
+ // packet is in flight if it contains anything other than a single ACK frame
+ // specifically, a packet containing padding is considered to be in flight.
+ return packet.frames().size() != 1 ||
+ !(packet.frames().get(0) instanceof AckFrame);
+ }
+
+ @Override
+ public boolean canSendPacket() {
+ lock.lock();
+ try {
+ if (bytesInFlight >= MAX_BYTES_IN_FLIGHT) {
+ return false;
+ }
+ if (isCwndLimited() || isPacerLimited()) {
+ return false;
+ }
+ return true;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void updateMaxDatagramSize(int newSize) {
+ lock.lock();
+ try {
+ if (minimumWindow != newSize * 2) {
+ minimumWindow = newSize * 2;
+ maxDatagramSize = newSize;
+ congestionWindow = Math.max(congestionWindow, minimumWindow);
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void packetSent(int packetBytes) {
+ lock.lock();
+ try {
+ bytesInFlight += packetBytes;
+ if (bytesInFlight > maxBytesInFlight) {
+ maxBytesInFlight = bytesInFlight;
+ }
+ pacer.packetSent(packetBytes);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void packetAcked(int packetBytes, Deadline sentTime) {
+ lock.lock();
+ try {
+ long oldWindow = congestionWindow;
+ assert oldWindow >= minimumWindow :
+ "Congestion window lower than minimum: %s < %s".formatted(oldWindow, minimumWindow);
+ bytesInFlight -= packetBytes;
+ // RFC 9002 says we should not increase cwnd when application limited.
+ // The concept itself is poorly defined.
+ // Here we limit cwnd growth based on the maximum bytes in flight
+ // observed since the last congestion event
+ if (inCongestionRecovery(sentTime)) {
+ if (Log.quicCC() && Log.trace()) {
+ Log.logQuic(dbgTag + " Acked, in recovery: bytes: " + packetBytes +
+ ", in flight: " + bytesInFlight);
+ }
+ return;
+ }
+ boolean isAppLimited;
+ if (congestionWindow < ssThresh) {
+ isAppLimited = congestionWindow >= 2 * maxBytesInFlight;
+ if (!isAppLimited) {
+ congestionWindow += packetBytes;
+ }
+ } else {
+ isAppLimited = congestionAvoidanceAcked(packetBytes, sentTime);
+ }
+ if (Log.quicCC() && Log.trace()) {
+ if (isAppLimited) {
+ Log.logQuic(dbgTag + " Acked, not blocked: bytes: " + packetBytes +
+ ", in flight: " + bytesInFlight);
+ } else {
+ Log.logQuic(dbgTag + " Acked, increased: bytes: " + packetBytes +
+ ", in flight: " + bytesInFlight +
+ ", new cwnd:" + congestionWindow);
+ }
+ }
+ assert congestionWindow >= oldWindow :
+ "Window size decreased on ACK: %s to %s".formatted(oldWindow, congestionWindow);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ abstract boolean congestionAvoidanceAcked(int packetBytes, Deadline sentTime);
+
+ @Override
+ public void packetLost(Collection lostPackets, Deadline sentTime, boolean persistent) {
+ lock.lock();
+ try {
+ for (QuicPacket packet : lostPackets) {
+ if (inFlight(packet)) {
+ bytesInFlight -= packet.size();
+ }
+ }
+ onCongestionEvent(sentTime);
+ if (persistent) {
+ congestionWindow = minimumWindow;
+ congestionRecoveryStartTime = null;
+ if (Log.quicCC()) {
+ Log.logQuic(dbgTag + " Persistent congestion: ssThresh: " + ssThresh +
+ ", in flight: " + bytesInFlight +
+ ", cwnd:" + congestionWindow);
+ }
+ }
+ assert congestionWindow >= minimumWindow :
+ "Congestion window lower than minimum: %s < %s".formatted(congestionWindow, minimumWindow);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void packetDiscarded(Collection discardedPackets) {
+ lock.lock();
+ try {
+ for (QuicPacket packet : discardedPackets) {
+ if (inFlight(packet)) {
+ bytesInFlight -= packet.size();
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public long congestionWindow() {
+ lock.lock();
+ try {
+ return congestionWindow;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public long initialWindow() {
+ lock.lock();
+ try {
+ return Math.max(14720, 2 * maxDatagramSize);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public long maxDatagramSize() {
+ lock.lock();
+ try {
+ return maxDatagramSize;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public boolean isSlowStart() {
+ lock.lock();
+ try {
+ return congestionWindow < ssThresh;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void updatePacer(Deadline now) {
+ lock.lock();
+ try {
+ pacer.updateQuota(now);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public boolean isPacerLimited() {
+ lock.lock();
+ try {
+ return !pacer.canSend();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public boolean isCwndLimited() {
+ lock.lock();
+ try {
+ return congestionWindow - bytesInFlight < maxDatagramSize;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public Deadline pacerDeadline() {
+ lock.lock();
+ try {
+ return pacer.twoPacketDeadline();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void appLimited() {
+ lock.lock();
+ try {
+ pacer.appLimited();
+ } finally {
+ lock.unlock();
+ }
+ }
+}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java
index 7ebe09e008e..d90ad1b217e 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicConnectionImpl.java
@@ -334,7 +334,7 @@ protected QuicConnectionImpl(final QuicVersion firstFlightVersion,
this.connectionId = this.endpoint.idFactory().newConnectionId();
this.logTag = logTagFormat.formatted(labelId);
this.dbgTag = dbgTag(quicInstance, logTag);
- this.congestionController = new QuicRenoCongestionController(dbgTag, rttEstimator);
+ this.congestionController = createCongestionController(dbgTag, rttEstimator);
this.originalVersion = this.quicVersion = firstFlightVersion == null
? QuicVersion.firstFlightVersion(quicInstance.getAvailableVersions())
: firstFlightVersion;
@@ -366,6 +366,16 @@ protected QuicConnectionImpl(final QuicVersion firstFlightVersion,
if (debug.on()) debug.log("Quic Connection Created");
}
+ private static QuicCongestionController createCongestionController
+ (String dbgTag, QuicRttEstimator rttEstimator) {
+ String algo = System.getProperty("jdk.internal.httpclient.quic.congestionController", "cubic");
+ if (algo.equalsIgnoreCase("reno")) {
+ return new QuicRenoCongestionController(dbgTag, rttEstimator);
+ } else {
+ return new QuicCubicCongestionController(dbgTag, rttEstimator);
+ }
+ }
+
@Override
public final long uniqueId() {
return labelId;
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicCubicCongestionController.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicCubicCongestionController.java
new file mode 100644
index 00000000000..a7a1cd0c0bc
--- /dev/null
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicCubicCongestionController.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2022, 2025, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.net.http.quic;
+
+import jdk.internal.net.http.common.Deadline;
+import jdk.internal.net.http.common.Log;
+import jdk.internal.net.http.common.TimeLine;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Implementation of the CUBIC congestion controller
+ * based on RFC 9438.
+ *
+ * @spec https://www.rfc-editor.org/rfc/rfc9438.html
+ * RFC 9438: CUBIC for Fast and Long-Distance Networks
+ */
+public final class QuicCubicCongestionController extends QuicBaseCongestionController {
+
+ public static final double BETA = 0.7;
+ public static final double ALPHA = 3 * (1 - BETA) / (1 + BETA);
+ private static final double C = 0.4;
+ private final QuicRttEstimator rttEstimator;
+ // Cubic curve inflection point, in bytes
+ private long wMaxBytes;
+ // cwnd before the most recent congestion event
+ private long cwndPriorBytes;
+ // "t" from RFC 9438
+ private long timeNanos;
+ // "K" from RFC 9438
+ private long kNanos;
+ // estimate for the Reno-friendly congestion window
+ private long wEstBytes;
+ // the most recent time when the congestion window was filled
+ private Deadline lastFullWindow;
+
+ public QuicCubicCongestionController(String dbgTag, QuicRttEstimator rttEstimator) {
+ super(dbgTag, rttEstimator);
+ this.rttEstimator = rttEstimator;
+ }
+
+ // for testing
+ public QuicCubicCongestionController(TimeLine source, QuicRttEstimator rttEstimator) {
+ super("TEST", source, rttEstimator);
+ this.rttEstimator = rttEstimator;
+ }
+
+ @Override
+ public void packetSent(int packetBytes) {
+ lock.lock();
+ try {
+ super.packetSent(packetBytes);
+ if (isCwndLimited()) {
+ Deadline now = timeSource.instant();
+ if (lastFullWindow == null) {
+ lastFullWindow = now;
+ } else {
+ long timePassedNanos = Deadline.between(lastFullWindow, now).toNanos();
+ if (timePassedNanos > 0) {
+ /* "The elapsed time MUST NOT include periods during which cwnd
+ has not been updated due to application-limited behavior"
+ "A flow is application limited if it is currently sending less
+ than what is allowed by the congestion window."
+
+ We are sending asynchronously; one thread is sending data,
+ a separate thread is processing the acknowledgements.
+ We can't rely on cwnd being fully utilized when we process an ack, because
+ most of the time it won't be.
+
+ Instead, we assume that if we filled the cwnd, we were not application-limited
+ in the last RTT (which is a pretty good approximation because of pacing),
+ and acknowledgements for all packets sent prior to filling the cwnd
+ count towards cwnd increase.
+ */
+ long rttNanos = TimeUnit.MICROSECONDS.toNanos(rttEstimator.state().smoothedRttMicros());
+ timeNanos += Math.min(timePassedNanos, rttNanos);
+ lastFullWindow = now;
+ }
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+
+ boolean congestionAvoidanceAcked(int packetBytes, Deadline sentTime) {
+ boolean isAppLimited = sentTime.isAfter(lastFullWindow);
+ if (!isAppLimited) {
+ if (wEstBytes < cwndPriorBytes) {
+ wEstBytes += Math.max((long) (ALPHA * maxDatagramSize * packetBytes / congestionWindow), 1);
+ } else {
+ wEstBytes += Math.max((long)maxDatagramSize * packetBytes / congestionWindow, 1);
+ }
+ // target = Wcubic(t + RTT)
+ long rttNanos = TimeUnit.MICROSECONDS.toNanos(rttEstimator.state().smoothedRttMicros());
+ double dblTargetBytes = wCubicBytes(timeNanos + rttNanos);
+ assert dblTargetBytes > 0 : "Unexpected negative target bytes";
+ long targetBytes = (long) Math.min(dblTargetBytes, 1.5 * congestionWindow);
+ if (targetBytes > congestionWindow) {
+ long oldWindow = congestionWindow;
+ congestionWindow += Math.max((targetBytes - congestionWindow) * packetBytes / congestionWindow, 1L);
+ assert congestionWindow > oldWindow :
+ "Window size decreased: %s to %s".formatted(oldWindow, congestionWindow);
+ }
+ if (wEstBytes > congestionWindow) {
+ congestionWindow = wEstBytes;
+ }
+ }
+ return isAppLimited;
+ }
+
+ // Wcubic(t) = C * (t-K [seconds])^3 + Wmax (segments)
+ private double wCubicBytes(long timeNanos) {
+ return (C * maxDatagramSize * Math.pow((timeNanos - kNanos) / 1e9, 3)) + wMaxBytes;
+ }
+
+ void onCongestionEvent(Deadline sentTime) {
+ if (inCongestionRecovery(sentTime)) {
+ return;
+ }
+ if (congestionWindow < wMaxBytes) {
+ // fast convergence
+ wMaxBytes = (long) ((1 + BETA) * congestionWindow / 2);
+ } else {
+ wMaxBytes = congestionWindow;
+ }
+ cwndPriorBytes = congestionWindow;
+ congestionRecoveryStartTime = timeSource.instant();
+ ssThresh = (long)(congestionWindow * BETA);
+ wEstBytes = congestionWindow = Math.max(minimumWindow, ssThresh);
+ maxBytesInFlight = 0;
+ timeNanos = 0;
+ // set lastFullWindow to prevent rapid timeNanos growth
+ lastFullWindow = congestionRecoveryStartTime;
+ // ((wmax_segments - cwnd_segments) / C) ^ (1/3) seconds
+ kNanos = (long)(Math.cbrt((wMaxBytes - congestionWindow) / C / maxDatagramSize) * 1_000_000_000);
+ // kNanos may be negative if we reduced the window below minimum,
+ // and fast convergence was used. This is acceptable.
+ if (Log.quicCC()) {
+ Log.logQuic(dbgTag + " Congestion: ssThresh: " + ssThresh +
+ ", in flight: " + bytesInFlight +
+ ", cwnd:" + congestionWindow +
+ ", K: " + TimeUnit.NANOSECONDS.toMillis(kNanos) + " ms");
+ }
+ }
+}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicEndpoint.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicEndpoint.java
index d9bf5fe6dcf..b1de5ef4bfd 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicEndpoint.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicEndpoint.java
@@ -62,6 +62,7 @@
import jdk.internal.net.http.common.TimeLine;
import jdk.internal.net.http.common.TimeSource;
import jdk.internal.net.http.common.Utils;
+import jdk.internal.net.http.common.Utils.UseVTForSelector;
import jdk.internal.net.http.quic.QuicSelector.QuicNioSelector;
import jdk.internal.net.http.quic.QuicSelector.QuicVirtualThreadPoller;
import jdk.internal.net.http.quic.packets.QuicPacket.HeadersType;
@@ -116,7 +117,6 @@ public abstract sealed class QuicEndpoint implements AutoCloseable
static final boolean DGRAM_SEND_ASYNC;
static final int MAX_BUFFERED_HIGH;
static final int MAX_BUFFERED_LOW;
- enum UseVTForSelector { ALWAYS, NEVER, DEFAULT }
static final UseVTForSelector USE_VT_FOR_SELECTOR;
static {
// This default value is the maximum payload size of
@@ -144,11 +144,8 @@ enum UseVTForSelector { ALWAYS, NEVER, DEFAULT }
if (maxBufferLow >= maxBufferHigh) maxBufferLow = maxBufferHigh >> 1;
MAX_BUFFERED_HIGH = maxBufferHigh;
MAX_BUFFERED_LOW = maxBufferLow;
- String useVtForSelector =
- System.getProperty("jdk.internal.httpclient.quic.selector.useVirtualThreads", "default");
- USE_VT_FOR_SELECTOR = Stream.of(UseVTForSelector.values())
- .filter((v) -> v.name().equalsIgnoreCase(useVtForSelector))
- .findFirst().orElse(UseVTForSelector.DEFAULT);
+ var property = "jdk.internal.httpclient.quic.selector.useVirtualThreads";
+ USE_VT_FOR_SELECTOR = Utils.useVTForSelector(property, "default");
}
/**
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicPacer.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicPacer.java
index 0ba7d78038b..50d8485785f 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicPacer.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicPacer.java
@@ -30,10 +30,8 @@
import jdk.internal.net.http.common.Utils;
import jdk.internal.util.OperatingSystem;
-import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantLock;
/**
* Implementation of pacing.
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicRenoCongestionController.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicRenoCongestionController.java
index ff51aafc131..2594c00055f 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicRenoCongestionController.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicRenoCongestionController.java
@@ -27,15 +27,6 @@
import jdk.internal.net.http.common.Deadline;
import jdk.internal.net.http.common.Log;
-import jdk.internal.net.http.common.TimeLine;
-import jdk.internal.net.http.common.TimeSource;
-import jdk.internal.net.http.common.Utils;
-import jdk.internal.net.http.quic.frames.AckFrame;
-import jdk.internal.net.http.quic.packets.QuicPacket;
-
-import java.util.Collection;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
/**
* Implementation of QUIC congestion controller based on RFC 9002.
@@ -46,38 +37,20 @@
* @spec https://www.rfc-editor.org/info/rfc9002
* RFC 9002: QUIC Loss Detection and Congestion Control
*/
-class QuicRenoCongestionController implements QuicCongestionController {
- // higher of 14720 and 2*maxDatagramSize; we use fixed maxDatagramSize
- private static final int INITIAL_WINDOW = Math.max(14720, 2 * QuicConnectionImpl.DEFAULT_DATAGRAM_SIZE);
- private static final int MAX_BYTES_IN_FLIGHT = Math.clamp(
- Utils.getLongProperty("jdk.httpclient.quic.maxBytesInFlight", 1 << 24),
- 1 << 14, 1 << 24);
- private final TimeLine timeSource;
- private final String dbgTag;
- private final Lock lock = new ReentrantLock();
- private long congestionWindow = INITIAL_WINDOW;
- private int maxDatagramSize = QuicConnectionImpl.DEFAULT_DATAGRAM_SIZE;
- private int minimumWindow = 2 * maxDatagramSize;
- private long bytesInFlight;
- // maximum bytes in flight seen since the last congestion event
- private long maxBytesInFlight;
- private Deadline congestionRecoveryStartTime;
- private long ssThresh = Long.MAX_VALUE;
-
- private final QuicPacer pacer;
-
+final class QuicRenoCongestionController extends QuicBaseCongestionController {
public QuicRenoCongestionController(String dbgTag, QuicRttEstimator rttEstimator) {
- this.dbgTag = dbgTag;
- this.timeSource = TimeSource.source();
- this.pacer = new QuicPacer(rttEstimator, this);
+ super(dbgTag, rttEstimator);
}
- private boolean inCongestionRecovery(Deadline sentTime) {
- return (congestionRecoveryStartTime != null &&
- !sentTime.isAfter(congestionRecoveryStartTime));
+ boolean congestionAvoidanceAcked(int packetBytes, Deadline sentTime) {
+ boolean isAppLimited = congestionWindow > maxBytesInFlight + 2L * maxDatagramSize;
+ if (!isAppLimited) {
+ congestionWindow += Math.max((long) maxDatagramSize * packetBytes / congestionWindow, 1L);
+ }
+ return isAppLimited;
}
- private void onCongestionEvent(Deadline sentTime) {
+ void onCongestionEvent(Deadline sentTime) {
if (inCongestionRecovery(sentTime)) {
return;
}
@@ -91,226 +64,4 @@ private void onCongestionEvent(Deadline sentTime) {
", cwnd:" + congestionWindow);
}
}
-
- private static boolean inFlight(QuicPacket packet) {
- // packet is in flight if it contains anything other than a single ACK frame
- // specifically, a packet containing padding is considered to be in flight.
- return packet.frames().size() != 1 ||
- !(packet.frames().get(0) instanceof AckFrame);
- }
-
- @Override
- public boolean canSendPacket() {
- lock.lock();
- try {
- if (bytesInFlight >= MAX_BYTES_IN_FLIGHT) {
- return false;
- }
- if (isCwndLimited() || isPacerLimited()) {
- return false;
- }
- return true;
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void updateMaxDatagramSize(int newSize) {
- lock.lock();
- try {
- if (minimumWindow != newSize * 2) {
- minimumWindow = newSize * 2;
- maxDatagramSize = newSize;
- congestionWindow = Math.max(congestionWindow, minimumWindow);
- }
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void packetSent(int packetBytes) {
- lock.lock();
- try {
- bytesInFlight += packetBytes;
- if (bytesInFlight > maxBytesInFlight) {
- maxBytesInFlight = bytesInFlight;
- }
- pacer.packetSent(packetBytes);
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void packetAcked(int packetBytes, Deadline sentTime) {
- lock.lock();
- try {
- bytesInFlight -= packetBytes;
- // RFC 9002 says we should not increase cwnd when application limited.
- // The concept itself is poorly defined.
- // Here we limit cwnd growth based on the maximum bytes in flight
- // observed since the last congestion event
- if (inCongestionRecovery(sentTime)) {
- if (Log.quicCC() && Log.trace()) {
- Log.logQuic(dbgTag + " Acked, in recovery: bytes: " + packetBytes +
- ", in flight: " + bytesInFlight);
- }
- return;
- }
- boolean isAppLimited;
- if (congestionWindow < ssThresh) {
- isAppLimited = congestionWindow >= 2 * maxBytesInFlight;
- if (!isAppLimited) {
- congestionWindow += packetBytes;
- }
- } else {
- isAppLimited = congestionWindow > maxBytesInFlight + 2L * maxDatagramSize;
- if (!isAppLimited) {
- congestionWindow += Math.max((long) maxDatagramSize * packetBytes / congestionWindow, 1L);
- }
- }
- if (Log.quicCC() && Log.trace()) {
- if (isAppLimited) {
- Log.logQuic(dbgTag + " Acked, not blocked: bytes: " + packetBytes +
- ", in flight: " + bytesInFlight);
- } else {
- Log.logQuic(dbgTag + " Acked, increased: bytes: " + packetBytes +
- ", in flight: " + bytesInFlight +
- ", new cwnd:" + congestionWindow);
- }
- }
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void packetLost(Collection lostPackets, Deadline sentTime, boolean persistent) {
- lock.lock();
- try {
- for (QuicPacket packet : lostPackets) {
- if (inFlight(packet)) {
- bytesInFlight -= packet.size();
- }
- }
- onCongestionEvent(sentTime);
- if (persistent) {
- congestionWindow = minimumWindow;
- congestionRecoveryStartTime = null;
- if (Log.quicCC()) {
- Log.logQuic(dbgTag + " Persistent congestion: ssThresh: " + ssThresh +
- ", in flight: " + bytesInFlight +
- ", cwnd:" + congestionWindow);
- }
- }
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void packetDiscarded(Collection discardedPackets) {
- lock.lock();
- try {
- for (QuicPacket packet : discardedPackets) {
- if (inFlight(packet)) {
- bytesInFlight -= packet.size();
- }
- }
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public long congestionWindow() {
- lock.lock();
- try {
- return congestionWindow;
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public long initialWindow() {
- lock.lock();
- try {
- return Math.max(14720, 2 * maxDatagramSize);
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public long maxDatagramSize() {
- lock.lock();
- try {
- return maxDatagramSize;
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public boolean isSlowStart() {
- lock.lock();
- try {
- return congestionWindow < ssThresh;
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void updatePacer(Deadline now) {
- lock.lock();
- try {
- pacer.updateQuota(now);
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public boolean isPacerLimited() {
- lock.lock();
- try {
- return !pacer.canSend();
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public boolean isCwndLimited() {
- lock.lock();
- try {
- return congestionWindow - bytesInFlight < maxDatagramSize;
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public Deadline pacerDeadline() {
- lock.lock();
- try {
- return pacer.twoPacketDeadline();
- } finally {
- lock.unlock();
- }
- }
-
- @Override
- public void appLimited() {
- lock.lock();
- try {
- pacer.appLimited();
- } finally {
- lock.unlock();
- }
- }
}
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicSelector.java b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicSelector.java
index 9fa825459ff..02db895d27c 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicSelector.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/quic/QuicSelector.java
@@ -45,9 +45,9 @@
import jdk.internal.net.http.common.TimeLine;
import jdk.internal.net.http.common.TimeSource;
import jdk.internal.net.http.common.Utils;
+import jdk.internal.net.http.common.Utils.UseVTForSelector;
import jdk.internal.net.http.quic.QuicEndpoint.QuicVirtualThreadedEndpoint;
import jdk.internal.net.http.quic.QuicEndpoint.QuicSelectableEndpoint;
-import jdk.internal.net.http.quic.QuicEndpoint.UseVTForSelector;
import static jdk.internal.net.http.quic.QuicEndpoint.USE_VT_FOR_SELECTOR;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
index 2eca26de838..22ee2393a02 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
@@ -413,7 +413,18 @@ private Symbol attributeDocReference(TreePath path, DCReference ref) {
}
if (ref.qualifierExpression == null) {
- tsym = env.enclClass.sym;
+ // Resolve target for unqualified reference based on declaring element
+ tsym = switch (path.getLeaf().getKind()) {
+ case PACKAGE -> env.toplevel.packge;
+ case MODULE -> env.toplevel.modle;
+ case COMPILATION_UNIT ->
+ // Treat unqualified reference in legacy package.html as package reference.
+ // Unqualified references in doc-files only need to work locally, so null is fine.
+ path.getCompilationUnit().getSourceFile().isNameCompatible("package", JavaFileObject.Kind.HTML)
+ ? env.toplevel.packge
+ : null;
+ default -> env.enclClass.sym; // Class or class member reference
+ };
memberName = (Name) ref.memberName;
} else {
// Check if qualifierExpression is a type or package, using the methods javac provides.
@@ -470,8 +481,15 @@ private Symbol attributeDocReference(TreePath path, DCReference ref) {
}
}
- if (memberName == null)
+ if (memberName == null) {
return tsym;
+ } else if (tsym == null || tsym.getKind() == ElementKind.PACKAGE || tsym.getKind() == ElementKind.MODULE) {
+ return null; // Non-null member name in non-class context
+ }
+
+ if (tsym.type.isPrimitive()) {
+ return null;
+ }
final List paramTypes;
if (ref.paramTypes == null)
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
index ad41adcc135..3f72ada94e8 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -176,7 +176,7 @@ protected Attr(Context context) {
Feature.UNCONDITIONAL_PATTERN_IN_INSTANCEOF.allowedInSource(source);
sourceName = source.name;
useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
- captureMRefReturnType = Source.Feature.ERASE_POLY_SIG_RETURN_TYPE.allowedInSource(source);
+ captureMRefReturnType = Source.Feature.CAPTURE_MREF_RETURN_TYPE.allowedInSource(source);
statInfo = new ResultInfo(KindSelector.NIL, Type.noType);
varAssignmentInfo = new ResultInfo(KindSelector.ASG, Type.noType);
@@ -377,7 +377,7 @@ private class IdentAttributer extends SimpleTreeVisitor>
@Override @DefinedBy(Api.COMPILER_TREE)
public Symbol visitMemberSelect(MemberSelectTree node, Env env) {
Symbol site = visit(node.getExpression(), env);
- if (site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN)
+ if (site == null || site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN)
return site;
Name name = (Name)node.getIdentifier();
if (site.kind == PCK) {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
index eea766f57c1..07f2a742bcb 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -2810,7 +2810,12 @@ Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env env,
Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env env,
Symbol location, Type site, Name name, List