!65 sync master to openEuler-24.03-LTS

From: @Autistic_boyya 
Reviewed-by: @kuenking111 
Signed-off-by: @kuenking111
This commit is contained in:
openeuler-ci-bot 2025-02-26 09:26:16 +00:00 committed by Gitee
commit 120f1075ee
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
51 changed files with 4469 additions and 763 deletions

View File

@ -0,0 +1,22 @@
Subject: 8300800: UB: Shift exponent 32 is too large for 32-bit type 'int'
---
src/hotspot/cpu/aarch64/immediate_aarch64.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hotspot/cpu/aarch64/immediate_aarch64.cpp b/src/hotspot/cpu/aarch64/immediate_aarch64.cpp
index 3d87fde2b..961f93ed7 100644
--- a/src/hotspot/cpu/aarch64/immediate_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/immediate_aarch64.cpp
@@ -295,7 +295,7 @@ int expandLogicalImmediate(uint32_t immN, uint32_t immr,
uint64_t and_bits_sub = replicate(and_bit, 1, nbits);
uint64_t or_bits_sub = replicate(or_bit, 1, nbits);
uint64_t and_bits_top = (and_bits_sub << nbits) | ones(nbits);
- uint64_t or_bits_top = (0 << nbits) | or_bits_sub;
+ uint64_t or_bits_top = (UCONST64(0) << nbits) | or_bits_sub;
tmask = ((tmask
& (replicate(and_bits_top, 2 * nbits, 32 / nbits)))
--
2.33.0

View File

@ -0,0 +1,25 @@
Subject: 8334780: Crash: assert(h_array_list.not_null()) failed: invariant
---
src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp b/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp
index 5388349c3..1f594a19e 100644
--- a/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp
+++ b/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp
@@ -136,8 +136,9 @@ jobject JdkJfrEvent::get_all_klasses(TRAPS) {
transform_klasses_to_local_jni_handles(event_subklasses, THREAD);
Handle h_array_list(THREAD, new_java_util_arraylist(THREAD));
- assert(h_array_list.not_null(), "invariant");
-
+ if (h_array_list.is_null()) {
+ return empty_java_util_arraylist;
+ }
static const char add_method_name[] = "add";
static const char add_method_signature[] = "(Ljava/lang/Object;)Z";
const Klass* const array_list_klass = JfrJavaSupport::klass(empty_java_util_arraylist);
--
2.33.0

View File

@ -0,0 +1,22 @@
Subject: 8335610: DiagnosticFramework: CmdLine::is_executable() correction
---
src/hotspot/share/services/diagnosticFramework.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hotspot/share/services/diagnosticFramework.hpp b/src/hotspot/share/services/diagnosticFramework.hpp
index 8313954aa..3f5087fd1 100644
--- a/src/hotspot/share/services/diagnosticFramework.hpp
+++ b/src/hotspot/share/services/diagnosticFramework.hpp
@@ -67,7 +67,7 @@ public:
const char* cmd_addr() const { return _cmd; }
size_t cmd_len() const { return _cmd_len; }
bool is_empty() const { return _cmd_len == 0; }
- bool is_executable() const { return is_empty() || _cmd[0] != '#'; }
+ bool is_executable() const { return !is_empty() && _cmd[0] != '#'; }
bool is_stop() const { return !is_empty() && strncmp("stop", _cmd, _cmd_len) == 0; }
};
--
2.33.0

View File

@ -0,0 +1,21 @@
Subject: 8337982: Remove dead undef assrt0n
---
src/hotspot/share/memory/metaspace/blockTree.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/hotspot/share/memory/metaspace/blockTree.cpp b/src/hotspot/share/memory/metaspace/blockTree.cpp
index 934f25d84..883f7792e 100644
--- a/src/hotspot/share/memory/metaspace/blockTree.cpp
+++ b/src/hotspot/share/memory/metaspace/blockTree.cpp
@@ -179,7 +179,6 @@ void BlockTree::verify() const {
// as many nodes as are in this tree)
_counter.check(counter);
- #undef assrt0n
}
void BlockTree::zap_range(MetaWord* p, size_t word_size) {
--
2.33.0

View File

@ -0,0 +1,22 @@
Subject: 8339149: jfr_flush_event_writer - return value type mismatch
---
src/hotspot/share/jfr/jni/jfrJniMethod.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp
index c7efe1c6a..90d74d59e 100644
--- a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp
+++ b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp
@@ -119,7 +119,7 @@ jobject JNICALL jfr_get_event_writer(JNIEnv* env, jclass cls);
jobject JNICALL jfr_new_event_writer(JNIEnv* env, jclass cls);
-jboolean JNICALL jfr_event_writer_flush(JNIEnv* env, jclass cls, jobject writer, jint used_size, jint requested_size);
+void JNICALL jfr_event_writer_flush(JNIEnv* env, jclass cls, jobject writer, jint used_size, jint requested_size);
jlong JNICALL jfr_commit(JNIEnv* env, jclass cls, jlong next_position);
--
2.33.0

View File

@ -0,0 +1,21 @@
Subject: 8339351: Remove duplicate line in FileMapHeader::print
---
src/hotspot/share/cds/filemap.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp
index 7d12e1aca..023c0762a 100644
--- a/src/hotspot/share/cds/filemap.cpp
+++ b/src/hotspot/share/cds/filemap.cpp
@@ -278,7 +278,6 @@ void FileMapHeader::print(outputStream* st) {
st->print_cr("- core_region_alignment: " SIZE_FORMAT, _core_region_alignment);
st->print_cr("- obj_alignment: %d", _obj_alignment);
st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
- st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
st->print_cr("- narrow_oop_shift %d", _narrow_oop_shift);
st->print_cr("- compact_strings: %d", _compact_strings);
st->print_cr("- max_heap_size: " UINTX_FORMAT, _max_heap_size);
--
2.33.0

View File

@ -0,0 +1,31 @@
Subject: BackPort of JDK-8336346: Fix -Wzero-as-null-pointer-constant warnings in jvmciJavaClasses.cpp
---
src/hotspot/share/jvmci/jvmciJavaClasses.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hotspot/share/jvmci/jvmciJavaClasses.cpp b/src/hotspot/share/jvmci/jvmciJavaClasses.cpp
index 4346c4050..94229dcb3 100644
--- a/src/hotspot/share/jvmci/jvmciJavaClasses.cpp
+++ b/src/hotspot/share/jvmci/jvmciJavaClasses.cpp
@@ -581,7 +581,7 @@ void JNIJVMCI::register_natives(JNIEnv* env) {
#define EMPTY2(x,y)
#define FIELD3(className, name, sig) FIELD2(className, name)
#define FIELD2(className, name) \
- jfieldID JNIJVMCI::className::_##name##_field_id = 0; \
+ jfieldID JNIJVMCI::className::_##name##_field_id = nullptr; \
int HotSpotJVMCI::className::_##name##_offset = 0;
#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args)
#define CONSTRUCTOR(className, signature)
@@ -623,7 +623,7 @@ JVMCI_CLASSES_DO(EMPTY2, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3,
void JNIJVMCI::className::check(JVMCIEnv* jvmciEnv, JVMCIObject obj, const char* field_name, jfieldID offset) { \
assert(obj.is_non_null(), "null field access of %s.%s", #className, field_name); \
assert(jvmciEnv->isa_##className(obj), "wrong class, " #className " expected, found %s", jvmciEnv->klass_name(obj)); \
- assert(offset != 0, "must be valid offset"); \
+ assert(offset != nullptr, "must be valid offset"); \
} \
jclass JNIJVMCI::className::_class = nullptr;
--
2.33.0

View File

@ -0,0 +1,22 @@
Subject: Backport JDK-8304484 CDS dynamic dumping incorrectly leads to "Error occurred during initialization of VM"
---
src/hotspot/share/classfile/classLoader.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp
index 5e89673a5..e4a14d560 100644
--- a/src/hotspot/share/classfile/classLoader.cpp
+++ b/src/hotspot/share/classfile/classLoader.cpp
@@ -445,7 +445,7 @@ bool ClassPathImageEntry::is_modules_image() const {
void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
Arguments::assert_is_dumping_archive();
tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure");
- vm_exit_during_initialization(error, message);
+ vm_exit_during_cds_dumping(error, message);
}
#endif
--
2.33.0

View File

@ -0,0 +1,24 @@
Subject: Backport JDK-8313909 [JVMCI] assert(cp->tag_at(index).is_unresolved_klass()) in lookupKlassInPool
---
src/hotspot/share/jvmci/jvmciCompilerToVM.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
index 5b45499f9..df9f866b9 100644
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
@@ -879,7 +879,9 @@ C2V_VMENTRY_NULL(jobject, lookupKlassInPool, (JNIEnv* env, jobject, ARGUMENT_PAI
} else if (tag.is_symbol()) {
symbol = cp->symbol_at(index);
} else {
- assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag");
+ if (!tag.is_unresolved_klass()) {
+ JVMCI_THROW_MSG_NULL(InternalError, err_msg("Expected %d at index %d, got %d", JVM_CONSTANT_UnresolvedClassInError, index, tag.value()));
+ }
symbol = cp->klass_name_at(index);
}
}
--
2.33.0

View File

@ -0,0 +1,161 @@
Subject: Backport JDK-8320308 C2 compilation crashes in LibraryCallKit::inline_unsafe_access
---
src/hotspot/share/opto/library_call.cpp | 7 +-
.../TestUnsafeArrayAccessWithNullBase.java | 113 ++++++++++++++++++
2 files changed, 117 insertions(+), 3 deletions(-)
create mode 100644 test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java
diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp
index af2ea6095..3ef0098c4 100644
--- a/src/hotspot/share/opto/library_call.cpp
+++ b/src/hotspot/share/opto/library_call.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, 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
@@ -2004,7 +2004,7 @@ LibraryCallKit::classify_unsafe_addr(Node* &base, Node* &offset, BasicType type)
if (base_type == nullptr) {
// Unknown type.
return Type::AnyPtr;
- } else if (base_type == TypePtr::NULL_PTR) {
+ } else if (_gvn.type(base->uncast()) == TypePtr::NULL_PTR) {
// Since this is a null+long form, we have to switch to a rawptr.
base = _gvn.transform(new CastX2PNode(offset));
offset = MakeConX(0);
@@ -2322,8 +2322,9 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c
SafePointNode* old_map = clone_map();
Node* adr = make_unsafe_address(base, offset, type, kind == Relaxed);
+ assert(!stopped(), "Inlining of unsafe access failed: address construction stopped unexpectedly");
- if (_gvn.type(base)->isa_ptr() == TypePtr::NULL_PTR) {
+ if (_gvn.type(base->uncast())->isa_ptr() == TypePtr::NULL_PTR) {
if (type != T_OBJECT) {
decorators |= IN_NATIVE; // off-heap primitive access
} else {
diff --git a/test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java b/test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java
new file mode 100644
index 000000000..28eb4f3c1
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2024, 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8320308
+ * @summary Unsafe::getShortUnaligned with base null hidden behind CheckCastPP nodes
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @run main/othervm -Xbatch -XX:CompileCommand=quiet -XX:TypeProfileLevel=222
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
+ * -XX:CompileCommand=compileonly,compiler.parsing.TestUnsafeArrayAccessWithNullBase::test*
+ * -XX:-TieredCompilation compiler.parsing.TestUnsafeArrayAccessWithNullBase
+ * @run main compiler.parsing.TestUnsafeArrayAccessWithNullBase
+ */
+
+package compiler.parsing;
+
+import java.lang.reflect.*;
+import jdk.internal.misc.Unsafe;
+
+public class TestUnsafeArrayAccessWithNullBase {
+
+ /*
+ Trigger bug when handling Unsafe.getShortUnaligned with null checks and inlined methods.
+ The bug appears when the method is incrementally inlined and optimized based on the argument profile information.
+
+ Warmup Phase: By warming up with non-null values, the argument profile for the helper methods records non-null types.
+ - insert CheckCastPP: speculative=byte[int:>=0] for return of getSmall/getLarge
+ - insert CheckCastPP: speculative=byte[int:>=0] for argument `Object array` in helperSmall/helperLarge
+ Trigger Phase: Calling test causes LibraryCallKit::inline_unsafe_access(..) for Unsafe::getShortUnaligned to fail:
+ Reason: UNSAFE.getShortUnaligned(array, offset) is called with array=null,
+ but ConP null is now hidden by two CheckCastPP with speculative=byte[int:>=0] in the graph
+ */
+
+ private static final Unsafe UNSAFE = Unsafe.getUnsafe();
+
+ private static final Object byteArray = new byte[1_050_000];
+
+ public static Object getLarge(boolean useNull) {
+ return useNull ? null : byteArray;
+ }
+
+ public static Object getSmall(boolean useNull) {
+ return useNull ? null : new byte[10];
+ }
+
+ // use a helper to delay inlining of UNSAFE.getShortUnaligned
+ public static int helperLarge(Object array, boolean run) {
+ // offset >= os::vm_page_size(): LibraryCallKit::classify_unsafe_addr returns Type::AnyPtr
+ return run ? UNSAFE.getShortUnaligned(array, 1_049_000) : 0; // after warmup CheckCastPP: speculative=byte[int:>=0]
+ }
+
+ public static int accessLargeArray(boolean useNull, boolean run) {
+ Object array = getLarge(useNull); // after warmup CheckCastPP: speculative=byte[int:>=0]
+ // getLarge() ensures null is only visible after helperLarge was (incrementally) inlined
+ return helperLarge(array, run);
+ }
+
+ // use a helper to delay inlining of UNSAFE.getShortUnaligned
+ // warmup adds argument profile information for array: CheckCastPP with type non null
+ public static int helperSmall(Object array, boolean run) {
+ // 0 <= offset < os::vm_page_size(): LibraryCallKit::classify_unsafe_addr returns Type::OopPtr
+ return run ? UNSAFE.getShortUnaligned(array, 1) : 0; // after warmup CheckCastPP: speculative=byte[int:>=0]
+ }
+
+ public static int accessSmallArray(boolean useNull, boolean run) {
+ Object array = getSmall(useNull); // after warmup CheckCastPP: speculative=byte[int:>=0]
+ return helperSmall(array, run);
+ }
+
+ public static int test1(boolean run) {
+ return accessLargeArray(true, run);
+ }
+
+ public static int test2(boolean run) {
+ return accessSmallArray(true, run);
+ }
+
+ public static void main(String[] args) {
+ // Warmup to collect speculative types
+ for (int i = 0; i < 10_000; i++) {
+ accessLargeArray(false, true);
+ accessSmallArray(false, true);
+ }
+
+ // Trigger Compilation
+ for (int i = 0; i < 10_000; ++i) {
+ test1(false);
+ test2(false);
+ }
+ }
+}
--
2.33.0

View File

@ -0,0 +1,84 @@
Subject: Backport JDK-8322812 Manpage for jcmd is missing JFR.view command
---
src/jdk.jcmd/share/man/jcmd.1 | 53 +++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/src/jdk.jcmd/share/man/jcmd.1 b/src/jdk.jcmd/share/man/jcmd.1
index 27f5ee5eb..f3e254be9 100644
--- a/src/jdk.jcmd/share/man/jcmd.1
+++ b/src/jdk.jcmd/share/man/jcmd.1
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
+.\" Copyright (c) 2012, 2024, 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
@@ -35,7 +35,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
-.TH "JCMD" "1" "2023" "JDK 21" "JDK Commands"
+.TH "JCMD" "1" "2025" "JDK 24-ea" "JDK Commands"
.hy
.SH NAME
.PP
@@ -625,6 +625,55 @@ If no path is provided, the data from the recording is discarded.
value)
.RE
.TP
+\f[V]JFR.view\f[R] [\f[I]options\f[R]]
+Display event data in predefined views.
+.RS
+.PP
+Impact: Medium
+.PP
+\f[B]Note:\f[R]
+.PP
+The \f[I]options\f[R] must be specified using either \f[I]key\f[R] or
+\f[I]key\f[R]\f[V]=\f[R]\f[I]value\f[R] syntax.
+If no parameters are entered, then a list of available views are
+displayed.
+.PP
+\f[I]options\f[R]:
+.IP \[bu] 2
+\f[V]cell-height\f[R]: (Optional) Maximum number of rows in a table
+cell.
+(INT, default value depends on the view)
+.IP \[bu] 2
+\f[V]maxage\f[R]: (Optional) Length of time for the view to span.
+(INT followed by \[aq]s\[aq] for seconds \[aq]m\[aq] for minutes or
+\[aq]h\[aq] for hours, default value is 10m)
+.IP \[bu] 2
+\f[V]maxsize\f[R]: (Optional) Maximum size for the view to span in bytes
+if one of the following suffixes is not used: \[aq]m\[aq] or \[aq]M\[aq]
+for megabytes OR \[aq]g\[aq] or \[aq]G\[aq] for gigabytes.
+(STRING, default value is 32MB)
+.IP \[bu] 2
+\f[V]truncate\f[R]: (Optional) Maximum number of rows in a table cell.
+(INT, default value depends on the view)
+.IP \[bu] 2
+\f[V]verbose\f[R]: (Optional) Displays the query that makes up the view.
+(BOOLEAN, default value is false)
+.IP \[bu] 2
+\f[V]width\f[R]: (Optional) The width of the view in characters.
+(INT, default value depends on the view)
+.PP
+\f[I]arguments\f[R]:
+.IP \[bu] 2
+\f[V]view\f[R]: Name of the view or event type to display.
+Use \f[V]help JFR.view\f[R] to see a list of available views.
+(STRING, no default value)
+.PP
+The view parameter can be an event type name.
+Use \f[V]JFR.view types\f[R] to see a list.
+To display all views, use \f[V]JFR.view all-views\f[R].
+To display all events, use \f[V]JFR.view all-events\f[R].
+.RE
+.TP
\f[V]JVMTI.agent_load\f[R] [\f[I]arguments\f[R]]
Loads JVMTI native agent.
.RS
--
2.33.0

View File

@ -0,0 +1,566 @@
Subject: Backport JDK-8323699: MessageFormat.toPattern() generates non-equivalent MessageFormat pattern
---
.../classes/java/text/MessageFormat.java | 76 +++-
.../MessageFormatToPatternTest.java | 364 ++++++++++++++++++
.../MessageFormatsByArgumentIndex.java | 8 +-
.../MessageFormat/MessageRegression.java | 6 +-
4 files changed, 442 insertions(+), 12 deletions(-)
create mode 100644 test/jdk/java/text/Format/MessageFormat/MessageFormatToPatternTest.java
diff --git a/src/java.base/share/classes/java/text/MessageFormat.java b/src/java.base/share/classes/java/text/MessageFormat.java
index 28d1474ad..659838c8a 100644
--- a/src/java.base/share/classes/java/text/MessageFormat.java
+++ b/src/java.base/share/classes/java/text/MessageFormat.java
@@ -548,6 +548,11 @@ public class MessageFormat extends Format {
* The string is constructed from internal information and therefore
* does not necessarily equal the previously applied pattern.
*
+ * @implSpec The implementation in {@link MessageFormat} returns a
+ * string that, when passed to a {@code MessageFormat()} constructor
+ * or {@link #applyPattern applyPattern()}, produces an instance that
+ * is semantically equivalent to this instance.
+ *
* @return a pattern representing the current state of the message format
*/
public String toPattern() {
@@ -559,6 +564,7 @@ public class MessageFormat extends Format {
lastOffset = offsets[i];
result.append('{').append(argumentNumbers[i]);
Format fmt = formats[i];
+ String subformatPattern = null;
if (fmt == null) {
// do nothing, string format
} else if (fmt instanceof NumberFormat) {
@@ -571,10 +577,12 @@ public class MessageFormat extends Format {
} else if (fmt.equals(NumberFormat.getIntegerInstance(locale))) {
result.append(",number,integer");
} else {
- if (fmt instanceof DecimalFormat) {
- result.append(",number,").append(((DecimalFormat)fmt).toPattern());
- } else if (fmt instanceof ChoiceFormat) {
- result.append(",choice,").append(((ChoiceFormat)fmt).toPattern());
+ if (fmt instanceof DecimalFormat dfmt) {
+ result.append(",number");
+ subformatPattern = dfmt.toPattern();
+ } else if (fmt instanceof ChoiceFormat cfmt) {
+ result.append(",choice");
+ subformatPattern = cfmt.toPattern();
} else {
// UNKNOWN
}
@@ -596,8 +604,9 @@ public class MessageFormat extends Format {
}
}
if (index >= DATE_TIME_MODIFIERS.length) {
- if (fmt instanceof SimpleDateFormat) {
- result.append(",date,").append(((SimpleDateFormat)fmt).toPattern());
+ if (fmt instanceof SimpleDateFormat sdfmt) {
+ result.append(",date");
+ subformatPattern = sdfmt.toPattern();
} else {
// UNKNOWN
}
@@ -607,6 +616,14 @@ public class MessageFormat extends Format {
} else {
//result.append(", unknown");
}
+ if (subformatPattern != null) {
+ result.append(',');
+
+ // The subformat pattern comes already quoted, but only for those characters that are
+ // special to the subformat. Therefore, we may need to quote additional characters.
+ // The ones we care about at the MessageFormat level are '{' and '}'.
+ copyAndQuoteBraces(subformatPattern, result);
+ }
result.append('}');
}
copyAndFixQuotes(pattern, lastOffset, pattern.length(), result);
@@ -1624,6 +1641,53 @@ public class MessageFormat extends Format {
}
}
+ // Copy the text, but add quotes around any quotables that aren't already quoted
+ private static void copyAndQuoteBraces(String source, StringBuilder target) {
+
+ // Analyze existing string for already quoted and newly quotable characters
+ record Qchar(char ch, boolean quoted) { };
+ ArrayList<Qchar> qchars = new ArrayList<>();
+ boolean quoted = false;
+ boolean anyChangeNeeded = false;
+ for (int i = 0; i < source.length(); i++) {
+ char ch = source.charAt(i);
+ if (ch == '\'') {
+ if (i + 1 < source.length() && source.charAt(i + 1) == '\'') {
+ qchars.add(new Qchar('\'', quoted));
+ i++;
+ } else {
+ quoted = !quoted;
+ }
+ } else {
+ boolean quotable = ch == '{' || ch == '}';
+ anyChangeNeeded |= quotable && !quoted;
+ qchars.add(new Qchar(ch, quoted || quotable));
+ }
+ }
+
+ // Was any change needed?
+ if (!anyChangeNeeded) {
+ target.append(source);
+ return;
+ }
+
+ // Build new string, automatically consolidating adjacent runs of quoted chars
+ quoted = false;
+ for (Qchar qchar : qchars) {
+ char ch = qchar.ch;
+ if (ch == '\'') {
+ target.append(ch); // doubling works whether quoted or not
+ } else if (qchar.quoted() != quoted) {
+ target.append('\'');
+ quoted = qchar.quoted();
+ }
+ target.append(ch);
+ }
+ if (quoted) {
+ target.append('\'');
+ }
+ }
+
/**
* After reading an object from the input stream, do a simple verification
* to maintain class invariants.
diff --git a/test/jdk/java/text/Format/MessageFormat/MessageFormatToPatternTest.java b/test/jdk/java/text/Format/MessageFormat/MessageFormatToPatternTest.java
new file mode 100644
index 000000000..020bc8033
--- /dev/null
+++ b/test/jdk/java/text/Format/MessageFormat/MessageFormatToPatternTest.java
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 2024, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @summary Verify that MessageFormat.toPattern() properly escapes special curly braces
+ * @bug 8323699
+ * @run junit MessageFormatToPatternTest
+ */
+
+import java.text.ChoiceFormat;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.text.MessageFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Random;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class MessageFormatToPatternTest {
+
+ private static final int NUM_RANDOM_TEST_CASES = 1000;
+
+ // Max levels of nesting of ChoiceFormats inside MessageFormats
+ private static final int MAX_FORMAT_NESTING = 3;
+
+ private static Locale savedLocale;
+ private static long randomSeed; // set this to a non-zero value for reproducibility
+ private static Random random;
+ private static boolean spitSeed;
+ private static int textCount;
+
+// Setup & Teardown
+
+ @BeforeAll
+ public static void setup() {
+ savedLocale = Locale.getDefault();
+ Locale.setDefault(Locale.US);
+ if (randomSeed == 0)
+ randomSeed = new Random().nextLong();
+ random = new Random(randomSeed);
+ }
+
+ @AfterAll
+ public static void teardown() {
+ Locale.setDefault(savedLocale);
+ }
+
+// Tests
+
+ // Test expected output when given a MessageFormat pattern string and value 1.23
+ @ParameterizedTest
+ @MethodSource("generateOutputTestCases")
+ public void testOutput(String pattern, String expected) {
+
+ // Test we get the expected output
+ MessageFormat format = new MessageFormat(pattern);
+ String actual = format.format(new Object[] { 1.23 });
+ assertEquals(expected, actual);
+
+ // Test round trip as well
+ testRoundTrip(format);
+ }
+
+ public static Stream<Arguments> generateOutputTestCases() {
+ return Stream.of(
+
+ // This is the test case from JDK-8323699
+ Arguments.of("{0,choice,0.0#option A: {0}|1.0#option B: {0}'}'}", "option B: 1.23}"),
+ Arguments.of("{0,choice,0.0#option A: {0}|2.0#option B: {0}'}'}", "option A: 1.23"),
+
+ // A few more test cases from the PR#17416 discussion
+ Arguments.of("Test: {0,number,foo'{'#.00}", "Test: foo{1.23"),
+ Arguments.of("Test: {0,number,foo'}'#.00}", "Test: foo}1.23"),
+ Arguments.of("{0,number,' abc }'' ' 0.00}", " abc }' 1.23"),
+ Arguments.of("Wayne ''The Great One'' Gretsky", "Wayne 'The Great One' Gretsky"),
+ Arguments.of("'Wayne ''The Great One'' Gretsky'", "Wayne 'The Great One' Gretsky"),
+ Arguments.of("{0,choice,0.0#'''{''curly''}'' braces'}", "{curly} braces"),
+ Arguments.of("{0,choice,0.0#''{''curly''}'' braces}", "{curly} braces"),
+ Arguments.of("{0,choice,0.0#'{0,choice,0.0#''{0,choice,0.0#''''{0,choice,0.0#foo}''''}''}'}", "foo"),
+
+ // Absurd double quote examples
+ Arguments.of("Foo '}''''''''}' {0,number,bar'}' '}' } baz ", "Foo }''''} bar} } 1 baz "),
+ Arguments.of("'''}''{'''}''''}'", "'}'{'}''}"),
+
+ // An absurdly complicated example
+ Arguments.of("{0,choice,0.0#text2887 [] '{'1,date,YYYY-MM-DD'}' text2888 [''*'']|1.0#found|2.0#'text2901 [oog'')!''] {2,choice,0.0#''text2897 ['''']''''wq1Q] {2,choice,0.0#''''text2891 [s''''''''&''''''''] {0,number,#0.##} text2892 [8''''''''|$'''''''''''''''''''''''']''''|1.0#''''text2893 [] {0,number,#0.##} text2894 [S'''''''']'''''''']''''|2.0#text2895 [''''''''.''''''''eB] {1,date,YYYY-MM-DD} text2896 [9Y]} text2898 []''|1.0#''text2899 [xk7] {0,number,#0.##} text2900 []''} text2902 [7'':$)''O]'}{0,choice,0.0#'text2903 [] {0,number,#0.##} text2904 [S'':'']'|1.0#'me'}", "foundme")
+ );
+ }
+
+ // Go roundrip from MessageFormat -> pattern string -> MessageFormat and verify equivalence
+ @ParameterizedTest
+ @MethodSource("generateRoundTripTestCases")
+ public void testRoundTrip(MessageFormat format1) {
+
+ // Prepare MessageFormat argument
+ Object[] args = new Object[] {
+ 8.5, // argument for DecimalFormat
+ new Date(1705502102677L), // argument for SimpleDateFormat
+ random.nextInt(6) // argument for ChoiceFormat
+ };
+
+ String pattern1 = null;
+ String result1 = null;
+ String pattern2 = null;
+ String result2 = null;
+ try {
+
+ // Format using the given MessageFormat
+ pattern1 = format1.toPattern();
+ result1 = format1.format(args);
+
+ // Round-trip via toPattern() and repeat
+ MessageFormat format2 = new MessageFormat(pattern1);
+ pattern2 = format2.toPattern();
+ result2 = format2.format(args);
+
+ // Check equivalence
+ assertEquals(result1, result2);
+ assertEquals(pattern1, pattern2);
+
+ // Debug
+ //showRoundTrip(format1, pattern1, result1, pattern2, result2);
+ } catch (RuntimeException | Error e) {
+ System.out.println(String.format("%n********** FAILURE **********%n"));
+ System.out.println(String.format("%s%n", e));
+ if (!spitSeed) {
+ System.out.println(String.format("*** Random seed was 0x%016xL%n", randomSeed));
+ spitSeed = true;
+ }
+ showRoundTrip(format1, pattern1, result1, pattern2, result2);
+ throw e;
+ }
+ }
+
+ public static Stream<Arguments> generateRoundTripTestCases() {
+ final ArrayList<Arguments> argList = new ArrayList<>();
+ for (int i = 0; i < NUM_RANDOM_TEST_CASES; i++)
+ argList.add(Arguments.of(randomFormat()));
+ return argList.stream();
+ }
+
+ // Generate a "random" MessageFormat. We do this by creating a MessageFormat with "{0}" placeholders
+ // and then substituting in random DecimalFormat, DateFormat, and ChoiceFormat subformats. The goal here
+ // is to avoid using pattern strings to construct formats, because they're what we're trying to check.
+ private static MessageFormat randomFormat() {
+
+ // Create a temporary MessageFormat containing "{0}" placeholders and random text
+ StringBuilder tempPattern = new StringBuilder();
+ int numParts = random.nextInt(3) + 1;
+ for (int i = 0; i < numParts; i++) {
+ if (random.nextBoolean())
+ tempPattern.append("{0}"); // temporary placeholder for a subformat
+ else
+ tempPattern.append(quoteText(randomText()));
+ }
+
+ // Replace all the "{0}" placeholders with random subformats
+ MessageFormat format = new MessageFormat(tempPattern.toString());
+ Format[] formats = format.getFormats();
+ for (int i = 0; i < formats.length; i++)
+ formats[i] = randomSubFormat(0);
+ format.setFormats(formats);
+
+ // Done
+ return format;
+ }
+
+ // Generate some random text
+ private static String randomText() {
+ StringBuilder buf = new StringBuilder();
+ int length = random.nextInt(6);
+ for (int i = 0; i < length; i++) {
+ char ch = (char)(0x20 + random.nextInt(0x5f));
+ buf.append(ch);
+ }
+ return buf.toString();
+ }
+
+ // Quote non-alphanumeric characters in the given plain text
+ private static String quoteText(String string) {
+ StringBuilder buf = new StringBuilder();
+ boolean quoted = false;
+ for (int i = 0; i < string.length(); i++) {
+ char ch = string.charAt(i);
+ if (ch == '\'')
+ buf.append("''");
+ else if (!(ch == ' ' || Character.isLetter(ch) || Character.isDigit(ch))) {
+ if (!quoted) {
+ buf.append('\'');
+ quoted = true;
+ }
+ buf.append(ch);
+ } else {
+ if (quoted) {
+ buf.append('\'');
+ quoted = false;
+ }
+ buf.append(ch);
+ }
+ }
+ if (quoted)
+ buf.append('\'');
+ return buf.toString();
+ }
+
+ // Create a random subformat for a MessageFormat
+ private static Format randomSubFormat(int nesting) {
+ int which;
+ if (nesting >= MAX_FORMAT_NESTING)
+ which = random.nextInt(2); // no more recursion
+ else
+ which = random.nextInt(3);
+ switch (which) {
+ case 0:
+ return new DecimalFormat("#.##");
+ case 1:
+ return new SimpleDateFormat("YYYY-MM-DD");
+ default:
+ int numChoices = random.nextInt(3) + 1;
+ assert numChoices > 0;
+ final double[] limits = new double[numChoices];
+ final String[] formats = new String[numChoices];
+ for (int i = 0; i < limits.length; i++) {
+ limits[i] = (double)i;
+ formats[i] = randomMessageFormatContaining(randomSubFormat(nesting + 1));
+ }
+ return new ChoiceFormat(limits, formats);
+ }
+ }
+
+ // Create a MessageFormat pattern string that includes the given Format as a subformat.
+ // The result will be one option in a ChoiceFormat which is nested in an outer MessageFormat.
+ // A ChoiceFormat option string is just a plain string; it's only when that plain string
+ // bubbles up to a containing MessageFormat that it gets interpreted as a MessageFormat string,
+ // and that only happens if the option string contains a '{' character. That will always
+ // be the case for the strings returned by this method of course.
+ private static String randomMessageFormatContaining(Format format) {
+ String beforeText = quoteText(randomText().replaceAll("\\{", "")); // avoid invalid MessageFormat syntax
+ String afterText = quoteText(randomText().replaceAll("\\{", "")); // avoid invalid MessageFormat syntax
+ String middleText;
+ if (format instanceof DecimalFormat dfmt)
+ middleText = String.format("{0,number,%s}", dfmt.toPattern());
+ else if (format instanceof SimpleDateFormat sdfmt)
+ middleText = String.format("{1,date,%s}", sdfmt.toPattern());
+ else if (format instanceof ChoiceFormat cfmt)
+ middleText = String.format("{2,choice,%s}", cfmt.toPattern());
+ else
+ throw new RuntimeException("internal error");
+ return String.format("text%d [%s] %s text%d [%s]", ++textCount, beforeText, middleText, ++textCount, afterText);
+ }
+
+// Debug printing
+
+ private void showRoundTrip(MessageFormat format1, String pattern1, String result1, String pattern2, String result2) {
+ print(0, format1);
+ System.out.println();
+ if (pattern1 != null)
+ System.out.println(String.format(" pattern1 = %s", javaLiteral(pattern1)));
+ if (result1 != null)
+ System.out.println(String.format(" result1 = %s", javaLiteral(result1)));
+ if (pattern2 != null)
+ System.out.println(String.format(" pattern2 = %s", javaLiteral(pattern2)));
+ if (result2 != null)
+ System.out.println(String.format(" result2 = %s", javaLiteral(result2)));
+ System.out.println();
+ }
+
+ private static void print(int depth, Object format) {
+ if (format == null)
+ return;
+ if (format instanceof String)
+ System.out.println(String.format("%s- %s", indent(depth), javaLiteral((String)format)));
+ else if (format instanceof MessageFormat)
+ print(depth, (MessageFormat)format);
+ else if (format instanceof DecimalFormat)
+ print(depth, (DecimalFormat)format);
+ else if (format instanceof SimpleDateFormat)
+ print(depth, (SimpleDateFormat)format);
+ else if (format instanceof ChoiceFormat)
+ print(depth, (ChoiceFormat)format);
+ else
+ throw new RuntimeException("internal error: " + format.getClass());
+ }
+
+ private static void print(int depth, MessageFormat format) {
+ System.out.println(String.format("%s- %s: %s", indent(depth), "MessageFormat", javaLiteral(format.toPattern())));
+ for (Format subformat : format.getFormats())
+ print(depth + 1, subformat);
+ }
+
+ private static void print(int depth, DecimalFormat format) {
+ System.out.println(String.format("%s- %s: %s", indent(depth), "DecimalFormat", javaLiteral(format.toPattern())));
+ }
+
+ private static void print(int depth, SimpleDateFormat format) {
+ System.out.println(String.format("%s- %s: %s", indent(depth), "SimpleDateFormat", javaLiteral(format.toPattern())));
+ }
+
+ private static void print(int depth, ChoiceFormat format) {
+ System.out.println(String.format("%s- %s: %s", indent(depth), "ChoiceFormat", javaLiteral(format.toPattern())));
+ for (Object subformat : format.getFormats())
+ print(depth + 1, subformat);
+ }
+
+ private static String indent(int depth) {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < depth; i++)
+ buf.append(" ");
+ return buf.toString();
+ }
+
+ // Print a Java string in double quotes so it looks like a String literal (for easy pasting into jshell)
+ private static String javaLiteral(String string) {
+ StringBuilder buf = new StringBuilder();
+ buf.append('"');
+ for (int i = 0; i < string.length(); i++) {
+ char ch = string.charAt(i);
+ switch (ch) {
+ case '"':
+ case '\\':
+ buf.append('\\');
+ // FALLTHROUGH
+ default:
+ buf.append(ch);
+ break;
+ }
+ }
+ return buf.append('"').toString();
+ }
+}
diff --git a/test/jdk/java/text/Format/MessageFormat/MessageFormatsByArgumentIndex.java b/test/jdk/java/text/Format/MessageFormat/MessageFormatsByArgumentIndex.java
index 1d69258f6..b82d566d3 100644
--- a/test/jdk/java/text/Format/MessageFormat/MessageFormatsByArgumentIndex.java
+++ b/test/jdk/java/text/Format/MessageFormat/MessageFormatsByArgumentIndex.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, 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
@@ -35,6 +35,7 @@ import java.text.NumberFormat;
public class MessageFormatsByArgumentIndex {
private static String choicePattern = "0.0#are no files|1.0#is one file|1.0<are {0,number,integer} files";
+ private static String quotedChoicePattern = choicePattern.replaceAll("([{}])", "'$1'");
public static void main(String[] args) {
Format[] subformats;
@@ -56,7 +57,7 @@ public class MessageFormatsByArgumentIndex {
format.setFormatByArgumentIndex(0, NumberFormat.getInstance());
- checkPattern(format.toPattern(), "{3,choice," + choicePattern + "}, {2}, {0,number}");
+ checkPattern(format.toPattern(), "{3,choice," + quotedChoicePattern + "}, {2}, {0,number}");
subformats = format.getFormatsByArgumentIndex();
checkSubformatLength(subformats, 4);
@@ -73,7 +74,8 @@ public class MessageFormatsByArgumentIndex {
format.setFormatsByArgumentIndex(subformats);
- checkPattern(format.toPattern(), "{3,choice," + choicePattern + "}, {2,number}, {0,choice," + choicePattern + "}");
+ checkPattern(format.toPattern(),
+ "{3,choice," + quotedChoicePattern + "}, {2,number}, {0,choice," + quotedChoicePattern + "}");
subformats = format.getFormatsByArgumentIndex();
checkSubformatLength(subformats, 4);
diff --git a/test/jdk/java/text/Format/MessageFormat/MessageRegression.java b/test/jdk/java/text/Format/MessageFormat/MessageRegression.java
index 344888f47..e10e48992 100644
--- a/test/jdk/java/text/Format/MessageFormat/MessageRegression.java
+++ b/test/jdk/java/text/Format/MessageFormat/MessageRegression.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -114,9 +114,9 @@ public class MessageRegression {
@Test
public void Test4058973() {
- MessageFormat fmt = new MessageFormat("{0,choice,0#no files|1#one file|1< {0,number,integer} files}");
+ MessageFormat fmt = new MessageFormat("{0,choice,0.0#no files|1.0#one file|1.0< '{'0,number,integer'}' files}");
String pat = fmt.toPattern();
- if (!pat.equals("{0,choice,0.0#no files|1.0#one file|1.0< {0,number,integer} files}")) {
+ if (!pat.equals("{0,choice,0.0#no files|1.0#one file|1.0< '{'0,number,integer'}' files}")) {
fail("MessageFormat.toPattern failed");
}
}
--
2.33.0

View File

@ -0,0 +1,119 @@
Subject: Backport JDK-8325730 StringBuilder.toString allocation for the empty String
---
.../share/classes/java/lang/StringBuffer.java | 5 ++++-
.../share/classes/java/lang/StringBuilder.java | 7 +++++--
.../org/openjdk/bench/java/lang/StringBuffers.java | 8 +++++++-
.../org/openjdk/bench/java/lang/StringBuilders.java | 10 +++++++++-
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/java.base/share/classes/java/lang/StringBuffer.java b/src/java.base/share/classes/java/lang/StringBuffer.java
index d77462f0c..1aeceb959 100644
--- a/src/java.base/share/classes/java/lang/StringBuffer.java
+++ b/src/java.base/share/classes/java/lang/StringBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2024, 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
@@ -735,6 +735,9 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
@Override
@IntrinsicCandidate
public synchronized String toString() {
+ if (length() == 0) {
+ return "";
+ }
if (toStringCache == null) {
return toStringCache = new String(this, null);
}
diff --git a/src/java.base/share/classes/java/lang/StringBuilder.java b/src/java.base/share/classes/java/lang/StringBuilder.java
index c42422e62..d7ff5ee35 100644
--- a/src/java.base/share/classes/java/lang/StringBuilder.java
+++ b/src/java.base/share/classes/java/lang/StringBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -471,8 +471,11 @@ public final class StringBuilder
@Override
@IntrinsicCandidate
public String toString() {
+ if (length() == 0) {
+ return "";
+ }
// Create a copy, don't share the array
- return new String(this);
+ return new String(this, null);
}
/**
diff --git a/test/micro/org/openjdk/bench/java/lang/StringBuffers.java b/test/micro/org/openjdk/bench/java/lang/StringBuffers.java
index b3d4d85c7..fea64c0d2 100644
--- a/test/micro/org/openjdk/bench/java/lang/StringBuffers.java
+++ b/test/micro/org/openjdk/bench/java/lang/StringBuffers.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2024, 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
@@ -80,4 +80,10 @@ public class StringBuffers {
return blaha.substring(30, 35);
}
+ StringBuffer sb = new StringBuffer();
+
+ @Benchmark
+ public String emptyToString() {
+ return sb.toString();
+ }
}
diff --git a/test/micro/org/openjdk/bench/java/lang/StringBuilders.java b/test/micro/org/openjdk/bench/java/lang/StringBuilders.java
index 40f41659e..29827b7f0 100644
--- a/test/micro/org/openjdk/bench/java/lang/StringBuilders.java
+++ b/test/micro/org/openjdk/bench/java/lang/StringBuilders.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2024, 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
@@ -364,6 +364,11 @@ public class StringBuilders {
return sbUtf16.charAt(charAt_index);
}
+ @Benchmark
+ public String emptyToString(Data data) {
+ return data.sbEmpty.toString();
+ }
+
@State(Scope.Thread)
public static class Data {
int i = 0;
@@ -380,6 +385,7 @@ public class StringBuilders {
}
}
+ StringBuilder sbEmpty;
String str;
String utf16Str;
CharSequence cs;
@@ -398,6 +404,8 @@ public class StringBuilders {
}
private void generateData() {
+ sbEmpty = new StringBuilder(length);
+
char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
StringBuilder sb = new StringBuilder(length);
--
2.33.0

View File

@ -0,0 +1,32 @@
Subject: Backport JDK-8325994 JFR: Examples in JFR.start help use incorrect separator
---
.../share/classes/jdk/jfr/internal/dcmd/DCmdStart.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
index 781ceff46..b40620e6d 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2024, 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
@@ -416,9 +416,9 @@ final class DCmdStart extends AbstractDCmd {
$ jcmd <pid> JFR.start filename=dump.jfr
$ jcmd <pid> JFR.start filename=%s
$ jcmd <pid> JFR.start dumponexit=true
- $ jcmd <pid> JFR.start maxage=1h,maxsize=1000M
+ $ jcmd <pid> JFR.start maxage=1h maxsize=1000M
$ jcmd <pid> JFR.start settings=profile
- $ jcmd <pid> JFR.start delay=5m,settings=my.jfc
+ $ jcmd <pid> JFR.start delay=5m settings=my.jfc
$ jcmd <pid> JFR.start gc=high method-profiling=high
$ jcmd <pid> JFR.start jdk.JavaMonitorEnter#threshold=1ms
$ jcmd <pid> JFR.start +HelloWorld#enabled=true +HelloWorld#stackTrace=true
--
2.33.0

View File

@ -0,0 +1,214 @@
Subject: Backport JDK-8326957 Implement JEP 474: ZGC: Generational Mode by Default
---
src/hotspot/share/gc/shared/gc_globals.hpp | 4 +-
src/hotspot/share/gc/x/xArguments.cpp | 2 +
src/hotspot/share/gc/x/xInitialize.cpp | 2 +-
src/hotspot/share/runtime/arguments.cpp | 3 +-
test/hotspot/jtreg/gc/x/TestDeprecated.java | 50 ++++++++++++++++++
test/hotspot/jtreg/gc/z/TestDefault.java | 51 +++++++++++++++++++
.../CommandLine/VMDeprecatedOptions.java | 3 +-
7 files changed, 110 insertions(+), 5 deletions(-)
create mode 100644 test/hotspot/jtreg/gc/x/TestDeprecated.java
create mode 100644 test/hotspot/jtreg/gc/z/TestDefault.java
diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp
index 5d7202685..8e51632bd 100644
--- a/src/hotspot/share/gc/shared/gc_globals.hpp
+++ b/src/hotspot/share/gc/shared/gc_globals.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -125,7 +125,7 @@
product(bool, UseZGC, false, \
"Use the Z garbage collector") \
\
- product(bool, ZGenerational, false, \
+ product(bool, ZGenerational, true, \
"Use the generational version of ZGC") \
\
product(bool, UseShenandoahGC, false, \
diff --git a/src/hotspot/share/gc/x/xArguments.cpp b/src/hotspot/share/gc/x/xArguments.cpp
index 60e78d2c7..13cb302d1 100644
--- a/src/hotspot/share/gc/x/xArguments.cpp
+++ b/src/hotspot/share/gc/x/xArguments.cpp
@@ -42,6 +42,8 @@ void XArguments::initialize_heap_flags_and_sizes() {
}
void XArguments::initialize() {
+ warning("Non-generational ZGC is deprecated.");
+
// Check mark stack size
const size_t mark_stack_space_limit = XAddressSpaceLimit::mark_stack();
if (ZMarkStackSpaceLimit > mark_stack_space_limit) {
diff --git a/src/hotspot/share/gc/x/xInitialize.cpp b/src/hotspot/share/gc/x/xInitialize.cpp
index 01b79f3ff..156be1797 100644
--- a/src/hotspot/share/gc/x/xInitialize.cpp
+++ b/src/hotspot/share/gc/x/xInitialize.cpp
@@ -41,7 +41,7 @@ XInitialize::XInitialize(XBarrierSet* barrier_set) {
log_info(gc, init)("Version: %s (%s)",
VM_Version::vm_release(),
VM_Version::jdk_debug_level());
- log_info(gc, init)("Using legacy single-generation mode");
+ log_info(gc, init)("Using deprecated non-generational mode");
// Early initialization
XAddress::initialize();
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
index 720a0e9ba..9b8e5aa87 100644
--- a/src/hotspot/share/runtime/arguments.cpp
+++ b/src/hotspot/share/runtime/arguments.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -500,6 +500,7 @@ static SpecialFlag const special_jvm_flags[] = {
{ "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
{ "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
{ "FlightRecorder", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() },
+ { "ZGenerational", JDK_Version::jdk(21), JDK_Version::undefined(), JDK_Version::undefined() },
{ "DumpSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
{ "DynamicDumpSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
{ "RequireSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
diff --git a/test/hotspot/jtreg/gc/x/TestDeprecated.java b/test/hotspot/jtreg/gc/x/TestDeprecated.java
new file mode 100644
index 000000000..17e2e70f4
--- /dev/null
+++ b/test/hotspot/jtreg/gc/x/TestDeprecated.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2024, 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.
+ *
+ * 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 gc.x;
+
+/*
+ * @test TestDeprecated
+ * @requires vm.gc.ZSinglegen
+ * @summary Test ZGenerational Deprecated
+ * @library /test/lib
+ * @run driver gc.x.TestDeprecated
+ */
+
+import java.util.LinkedList;
+import jdk.test.lib.process.ProcessTools;
+
+public class TestDeprecated {
+ static class Test {
+ public static void main(String[] args) throws Exception {}
+ }
+ public static void main(String[] args) throws Exception {
+ ProcessTools.executeLimitedTestJava("-XX:+UseZGC",
+ "-XX:-ZGenerational",
+ "-Xlog:gc+init",
+ Test.class.getName())
+ .shouldContain("Option ZGenerational was deprecated")
+ .shouldContain("Using deprecated non-generational mode")
+ .shouldHaveExitValue(0);
+ }
+}
diff --git a/test/hotspot/jtreg/gc/z/TestDefault.java b/test/hotspot/jtreg/gc/z/TestDefault.java
new file mode 100644
index 000000000..c693e8745
--- /dev/null
+++ b/test/hotspot/jtreg/gc/z/TestDefault.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2024, 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.
+ *
+ * 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 gc.z;
+
+/*
+ * @test TestDefault
+ * @requires vm.gc.ZGenerational
+ * @summary Test that ZGC Generational Mode is Default
+ * @library /test/lib
+ * @run driver gc.z.TestDefault
+ */
+
+import java.util.LinkedList;
+import jdk.test.lib.process.ProcessTools;
+
+public class TestDefault {
+ static class Test {
+ public static void main(String[] args) throws Exception {}
+ }
+ public static void main(String[] args) throws Exception {
+ ProcessTools.executeLimitedTestJava("-XX:+UseZGC",
+ "-Xlog:gc+init",
+ Test.class.getName())
+ .shouldNotContain("Option ZGenerational was deprecated")
+ .shouldNotContain("Using deprecated non-generational mode")
+ .shouldContain("GC Workers for Old Generation")
+ .shouldContain("GC Workers for Young Generation")
+ .shouldHaveExitValue(0);
+ }
+}
diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
index 95dd88c72..0c9c2d6ea 100644
--- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
+++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2024, 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,6 +62,7 @@ public class VMDeprecatedOptions {
{"InitialRAMFraction", "64"},
{"TLABStats", "false"},
{"AllowRedefinitionToAddDeleteMethods", "true"},
+ {"ZGenerational", "false"},
// deprecated alias flags (see also aliased_jvm_flags):
{"DefaultMaxRAMFraction", "4"},
--
2.33.0

View File

@ -0,0 +1,38 @@
Subject: Backport JDK-8327538 The SSLExtension class specifies incorrect values for heartbeat per RFC 6520 and post_handshake_auth per RFC 8446
---
.../share/classes/sun/security/ssl/SSLExtension.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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 2a9239fac..2cb74fb10 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLExtension.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLExtension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2024, 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
@@ -181,7 +181,7 @@ enum SSLExtension implements SSLStringizer {
USE_SRTP (0x000E, "use_srtp"),
// Extensions defined in RFC 6520 (TLS and DTLS Heartbeat Extension)
- HEARTBEAT (0x000E, "heartbeat"),
+ HEARTBEAT (0x000F, "heartbeat"),
// Extensions defined in RFC 7301 (TLS Application-Layer Protocol Negotiation Extension)
CH_ALPN (0x0010, "application_layer_protocol_negotiation",
@@ -406,7 +406,7 @@ enum SSLExtension implements SSLStringizer {
CertificateAuthoritiesExtension.ssStringizer),
OID_FILTERS (0x0030, "oid_filters"),
- POST_HANDSHAKE_AUTH (0x0030, "post_handshake_auth"),
+ POST_HANDSHAKE_AUTH (0x0031, "post_handshake_auth"),
CH_SIGNATURE_ALGORITHMS_CERT (0x0032, "signature_algorithms_cert",
SSLHandshake.CLIENT_HELLO,
--
2.33.0

View File

@ -0,0 +1,120 @@
Subject: Backport JDK-8328107 Shenandoah/C2: TestVerifyLoopOptimizations test failure
---
.../gc/shenandoah/c2/shenandoahSupport.cpp | 8 ++
.../compiler/TestBarrierOnLoopBackedge.java | 84 +++++++++++++++++++
2 files changed, 92 insertions(+)
create mode 100644 test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java
diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
index acf4b8f08..ce6403cb4 100644
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
@@ -1321,6 +1321,14 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
OuterStripMinedLoopNode* outer = head->as_OuterStripMinedLoop();
hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
}
+ if (head->is_BaseCountedLoop() && ctrl->is_IfProj() && ctrl->in(0)->is_BaseCountedLoopEnd() &&
+ head->as_BaseCountedLoop()->loopexit() == ctrl->in(0)) {
+ Node* entry = head->in(LoopNode::EntryControl);
+ Node* backedge = head->in(LoopNode::LoopBackControl);
+ Node* new_head = new LoopNode(entry, backedge);
+ phase->register_control(new_head, phase->get_loop(entry), entry);
+ phase->lazy_replace(head, new_head);
+ }
}
// Expand load-reference-barriers
diff --git a/test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java b/test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java
new file mode 100644
index 000000000..a72c7d69d
--- /dev/null
+++ b/test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2024, Red Hat, Inc. 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8328107
+ * @summary Barrier expanded on backedge break loop verification code
+ * @requires vm.gc.Shenandoah
+ *
+ * @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations TestBarrierOnLoopBackedge
+ * @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations -XX:-UseCountedLoopSafepoints TestBarrierOnLoopBackedge
+ */
+
+public class TestBarrierOnLoopBackedge {
+ private static A field = new A();
+ private static final A finalField = new A();
+ private static float floatField;
+
+ public static void main(String[] args) {
+ A[] array = new A[1];
+ array[0] = finalField;
+ for (int i = 0; i < 20_000; i++) {
+ test1();
+ test2();
+ }
+ }
+
+ private static void test1() {
+ floatField = field.f;
+ for (int i = 0; i < 1000; i++) {
+ notInlined(field); // load barrier split thru phi and ends up on back edge
+ if (i % 2 == 0) {
+ field = finalField;
+ }
+ }
+ }
+
+ private static void test2() {
+ A[] array = new A[1];
+ notInlined(array);
+ int i = 0;
+ A a = array[0];
+ for (;;) {
+ synchronized (new Object()) {
+ }
+ notInlined(a);
+ i++;
+ if (i >= 1000) {
+ break;
+ }
+ a = array[0]; // load barrier pinned on backedge
+ }
+ }
+
+ private static void notInlined(Object a) {
+
+ }
+
+ private static class A {
+ float f;
+ }
+}
--
2.33.0

View File

@ -0,0 +1,54 @@
Subject: Backport JDK-8328553 Get rid of JApplet in test/jdk/sanity/client/lib/SwingSet2/src/DemoModule.java
---
.../client/lib/SwingSet2/src/DemoModule.java | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/test/jdk/sanity/client/lib/SwingSet2/src/DemoModule.java b/test/jdk/sanity/client/lib/SwingSet2/src/DemoModule.java
index 3511583e9..0e7c71083 100644
--- a/test/jdk/sanity/client/lib/SwingSet2/src/DemoModule.java
+++ b/test/jdk/sanity/client/lib/SwingSet2/src/DemoModule.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2024, 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
@@ -31,7 +31,6 @@ import java.net.URL;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
-import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
@@ -42,10 +41,8 @@ import javax.swing.border.SoftBevelBorder;
/**
* A generic SwingSet2 demo module
- *
- * @author Jeff Dinkins
*/
-public class DemoModule extends JApplet {
+public class DemoModule extends JPanel {
// The preferred size of the demo
private int PREFERRED_WIDTH = 680;
@@ -214,10 +211,6 @@ public class DemoModule extends JApplet {
demo.mainImpl();
}
- public void init() {
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(getDemoPanel(), BorderLayout.CENTER);
- }
-
void updateDragEnabled(boolean dragEnabled) {}
-}
\ No newline at end of file
+}
+
--
2.33.0

View File

@ -0,0 +1,45 @@
Subject: Backport JDK-8329174 update CodeBuffer layout in comment after constants section moved
---
src/hotspot/share/asm/codeBuffer.cpp | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp
index ab8aed1cb..4bc33cc89 100644
--- a/src/hotspot/share/asm/codeBuffer.cpp
+++ b/src/hotspot/share/asm/codeBuffer.cpp
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "asm/codeBuffer.hpp"
+#include "code/compiledIC.hpp"
#include "code/oopRecorder.inline.hpp"
#include "compiler/disassembler.hpp"
#include "logging/log.hpp"
@@ -65,7 +66,11 @@
// The structure of the CodeBuffer while code is being accumulated:
//
// _total_start -> \
-// _insts._start -> +----------------+
+// _consts._start -> +----------------+
+// | |
+// | Constants |
+// | |
+// _insts._start -> |----------------|
// | |
// | Code |
// | |
@@ -73,10 +78,6 @@
// | |
// | Stubs | (also handlers for deopt/exception)
// | |
-// _consts._start -> |----------------|
-// | |
-// | Constants |
-// | |
// +----------------+
// + _total_size -> | |
//
--
2.33.0

View File

@ -0,0 +1,143 @@
Subject: Backport JDK-8329754 The ThreadSafe attribute is ignored for SecureRandom algorithm aliases
---
.../classes/java/security/SecureRandom.java | 6 +-
.../security/SecureRandom/ThreadSafe.java | 55 +++++++++++++------
2 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java
index 6a1683e99..36e71cf54 100644
--- a/src/java.base/share/classes/java/security/SecureRandom.java
+++ b/src/java.base/share/classes/java/security/SecureRandom.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2024, 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
@@ -230,8 +230,8 @@ public class SecureRandom extends java.util.Random {
if (provider == null || algorithm == null) {
return false;
} else {
- return Boolean.parseBoolean(provider.getProperty(
- "SecureRandom." + algorithm + " ThreadSafe", "false"));
+ Service service = provider.getService("SecureRandom", algorithm);
+ return Boolean.parseBoolean(service.getAttribute("ThreadSafe"));
}
}
diff --git a/test/jdk/java/security/SecureRandom/ThreadSafe.java b/test/jdk/java/security/SecureRandom/ThreadSafe.java
index 174f3253c..b0975678e 100644
--- a/test/jdk/java/security/SecureRandom/ThreadSafe.java
+++ b/test/jdk/java/security/SecureRandom/ThreadSafe.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2024, 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
@@ -21,33 +21,46 @@
* questions.
*/
+import static jdk.test.lib.Utils.runAndCheckException;
+
+import java.lang.Override;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.SecureRandomSpi;
+import java.util.List;
import java.util.Map;
/*
* @test
- * @bug 7004967
+ * @library /test/lib
+ * @bug 7004967 8329754
* @summary SecureRandom should be more explicit about threading
*/
+
public class ThreadSafe {
public static void main(String[] args) throws Exception {
Provider p = new P();
NoSync.test(SecureRandom.getInstance("S1", p), 5, 5);
- try {
- NoSync.test(SecureRandom.getInstance("S2", p), 5, 5);
- throw new Exception("Failed");
- } catch (RuntimeException re) {
- // Good
- }
+ NoSync.test(SecureRandom.getInstance("AliasS1", p), 5, 5);
+
+ runAndCheckException(
+ () -> NoSync.test(SecureRandom.getInstance("S2", p), 5, 5),
+ RuntimeException.class);
+
+ runAndCheckException(
+ () -> NoSync.test(SecureRandom.getInstance("AliasS2", p), 5, 5),
+ RuntimeException.class);
+
NoSync.test(SecureRandom.getInstance("S3", p), 5, 5);
- try {
- NoSync.test(SecureRandom.getInstance("S4", p), 5, 5);
- throw new Exception("Failed");
- } catch (RuntimeException re) {
- // Good
- }
+ NoSync.test(SecureRandom.getInstance("AliasS3", p), 5, 5);
+
+ runAndCheckException(
+ () -> NoSync.test(SecureRandom.getInstance("S4", p), 5, 5),
+ RuntimeException.class);
+
+ runAndCheckException(
+ () -> NoSync.test(SecureRandom.getInstance("AliasS4", p), 5, 5),
+ RuntimeException.class);
}
public static class P extends Provider {
@@ -58,28 +71,36 @@ public class ThreadSafe {
// Good. No attribute.
put("SecureRandom.S1", S.class.getName());
+ // Good. Alias of S1, should pass because S1 is not marked as ThreadSafe
+ put("Alg.alias.SecureRandom.AliasS1", "S1");
+
// Bad. Boasting ThreadSafe but isn't
put("SecureRandom.S2", S.class.getName());
put("SecureRandom.S2 ThreadSafe", "true");
+ //Bad. Alias of S2, should fail because S2 is marked as ThreadSafe
+ put("alg.Alias.SecureRandom.AliasS2", "S2");
+
// Good. No attribute.
putService(new Service(this, "SecureRandom", "S3",
- S.class.getName(), null, null));
+ S.class.getName(), List.of("AliasS3"), null));
// Bad. Boasting ThreadSafe but isn't
putService(new Service(this, "SecureRandom", "S4",
- S.class.getName(), null, Map.of("ThreadSafe", "true")));
+ S.class.getName(), List.of("AliasS4"), Map.of("ThreadSafe", "true")));
}
}
// This implementation is not itself thread safe.
public static class S extends SecureRandomSpi {
- @java.lang.Override
+
+ @Override
protected void engineSetSeed(byte[] seed) {
return;
}
private volatile boolean inCall = false;
+
@Override
protected void engineNextBytes(byte[] bytes) {
if (inCall) {
--
2.33.0

View File

@ -0,0 +1,183 @@
Subject: Backport JDK-8332297 annotation processor that generates records sometimes fails due to NPE in javac
---
.../com/sun/tools/javac/code/Symbol.java | 6 +-
.../processing/RecordGenerationTest.java | 148 ++++++++++++++++++
2 files changed, 152 insertions(+), 2 deletions(-)
create mode 100644 test/langtools/tools/javac/processing/RecordGenerationTest.java
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
index 7a939abb3..3438756be 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
@@ -1549,9 +1549,11 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
RecordComponent toRemove = null;
for (RecordComponent rc : recordComponents) {
/* it could be that a record erroneously declares two record components with the same name, in that
- * case we need to use the position to disambiguate
+ * case we need to use the position to disambiguate, but if we loaded the record from a class file
+ * all positions will be -1, in that case we have to ignore the position and match only based on the
+ * name
*/
- if (rc.name == var.name && var.pos == rc.pos) {
+ if (rc.name == var.name && (var.pos == rc.pos || rc.pos == -1)) {
toRemove = rc;
}
}
diff --git a/test/langtools/tools/javac/processing/RecordGenerationTest.java b/test/langtools/tools/javac/processing/RecordGenerationTest.java
new file mode 100644
index 000000000..9ee28d264
--- /dev/null
+++ b/test/langtools/tools/javac/processing/RecordGenerationTest.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2024, 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8332297
+ * @summary annotation processor that generates records sometimes fails due to NPE in javac
+ * @library /tools/lib /tools/javac/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.Task
+ * @build RecordGenerationTest JavacTestingAbstractProcessor
+ * @run main RecordGenerationTest
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Set;
+
+import javax.annotation.processing.FilerException;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedOptions;
+import javax.annotation.processing.SupportedAnnotationTypes;
+
+import javax.lang.model.element.TypeElement;
+import javax.tools.StandardLocation;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class RecordGenerationTest {
+ public static void main(String... args) throws Exception {
+ new RecordGenerationTest().run();
+ }
+
+ Path[] findJavaFiles(Path... paths) throws Exception {
+ return tb.findJavaFiles(paths);
+ }
+
+ ToolBox tb = new ToolBox();
+
+ void run() throws Exception {
+ Path allInOne = Paths.get("allInOne");
+ if (Files.isDirectory(allInOne)) {
+ tb.cleanDirectory(allInOne);
+ }
+ Files.deleteIfExists(allInOne);
+ tb.createDirectories(allInOne);
+
+ tb.writeJavaFiles(allInOne,
+ """
+ import java.io.IOException;
+ import java.io.OutputStream;
+ import java.io.Writer;
+ import java.nio.file.Files;
+ import java.nio.file.Path;
+ import java.nio.file.Paths;
+ import java.util.Set;
+
+ import javax.annotation.processing.AbstractProcessor;
+ import javax.annotation.processing.FilerException;
+ import javax.annotation.processing.RoundEnvironment;
+ import javax.annotation.processing.SupportedOptions;
+ import javax.annotation.processing.SupportedAnnotationTypes;
+
+ import javax.lang.model.element.TypeElement;
+ import javax.tools.StandardLocation;
+
+ @SupportedAnnotationTypes("*")
+ public class AP extends AbstractProcessor {
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (roundEnv.processingOver()) {
+ try (Writer w = processingEnv.getFiler().createSourceFile("ConfRecord").openWriter()) {
+ w.append("@RecordBuilder public record ConfRecord(int maxConcurrency) implements Conf {}");
+ } catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+ return true;
+ }
+ }
+ """
+ );
+
+ new JavacTask(tb).options("-d", allInOne.toString())
+ .files(findJavaFiles(allInOne))
+ .run()
+ .writeAll();
+
+ tb.writeJavaFiles(allInOne,
+ """
+ interface Conf {
+ int maxConcurrency( );
+ }
+ """,
+ """
+ import java.lang.annotation.*;
+ public @interface RecordBuilder {
+ }
+ """
+ );
+
+ Path confSource = Paths.get(allInOne.toString(), "Conf.java");
+ new JavacTask(tb).options("-processor", "AP",
+ "-cp", allInOne.toString(),
+ "-d", allInOne.toString())
+ .files(confSource)
+ .run()
+ .writeAll();
+
+ /* the bug reported at JDK-8332297 was reproducible only every other time this is why we reproduce
+ * the same compilation command as above basically the second time the compiler is completing the
+ * record symbol from the class file produced during the first compilation
+ */
+ new JavacTask(tb).options("-processor", "AP",
+ "-cp", allInOne.toString(),
+ "-d", allInOne.toString())
+ .files(confSource)
+ .run()
+ .writeAll();
+ }
+}
--
2.33.0

View File

@ -0,0 +1,41 @@
Subject: Backport JDK-8333599 Improve description of \b matcher in j.u.r.Pattern
---
src/java.base/share/classes/java/util/regex/Pattern.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java
index 45c48ddab..84e5a140d 100644
--- a/src/java.base/share/classes/java/util/regex/Pattern.java
+++ b/src/java.base/share/classes/java/util/regex/Pattern.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, 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
@@ -160,7 +160,7 @@ import jdk.internal.util.regex.Grapheme;
* <td headers="matches predef any">Any character (may or may not match <a href="#lt">line terminators</a>)</td></tr>
* <tr><th style="vertical-align:top; font-weight:normal" id="digit">{@code \d}</th>
* <td headers="matches predef digit">A digit: {@code [0-9]} if <a href="#UNICODE_CHARACTER_CLASS">
- * * UNICODE_CHARACTER_CLASS</a> is not set. See <a href="#unicodesupport">Unicode Support</a>.</td></tr>
+ * UNICODE_CHARACTER_CLASS</a> is not set. See <a href="#unicodesupport">Unicode Support</a>.</td></tr>
* <tr><th style="vertical-align:top; font-weight:normal" id="non_digit">{@code \D}</th>
* <td headers="matches predef non_digit">A non-digit: {@code [^0-9]}</td></tr>
* <tr><th style="vertical-align:top; font-weight:normal" id="horiz_white">{@code \h}</th>
@@ -251,8 +251,9 @@ import jdk.internal.util.regex.Grapheme;
* <tr><th style="vertical-align:top; font-weight:normal" id="end_line">{@code $}</th>
* <td headers="matches bounds end_line">The end of a line</td></tr>
* <tr><th style="vertical-align:top; font-weight:normal" id="word_boundary">{@code \b}</th>
- * <td headers="matches bounds word_boundary">A word boundary: {@code (?:(?<=\w)(?=\W)|(?<=\W)(?=\w))} (the location
- * where a non-word character abuts a word character)</td></tr>
+ * <td headers="matches bounds word_boundary">A word boundary:
+ * at the beginning or at the end of a line if a word character ({@code \w}) appears there;
+ * or between a word ({@code \w}) and a non-word character ({@code \W}), in either order.</td></tr>
* <tr><th style="vertical-align:top; font-weight:normal" id="grapheme_cluster_boundary">{@code \b{g}}</th>
* <td headers="matches bounds grapheme_cluster_boundary">A Unicode extended grapheme cluster boundary</td></tr>
* <tr><th style="vertical-align:top; font-weight:normal" id="non_word_boundary">{@code \B}</th>
--
2.33.0

View File

@ -0,0 +1,242 @@
Subject: Backport JDK-8333805 Replaying compilation with null static final fields results in a crash
---
src/hotspot/share/ci/ciInstanceKlass.cpp | 10 ++-
src/hotspot/share/ci/ciReplay.cpp | 89 ++++++++++---------
.../ciReplay/TestNullStaticField.java | 82 +++++++++++++++++
3 files changed, 136 insertions(+), 45 deletions(-)
create mode 100644 test/hotspot/jtreg/compiler/ciReplay/TestNullStaticField.java
diff --git a/src/hotspot/share/ci/ciInstanceKlass.cpp b/src/hotspot/share/ci/ciInstanceKlass.cpp
index fa084e228..240bb25ae 100644
--- a/src/hotspot/share/ci/ciInstanceKlass.cpp
+++ b/src/hotspot/share/ci/ciInstanceKlass.cpp
@@ -661,7 +661,8 @@ class StaticFinalFieldPrinter : public FieldClosure {
ResourceMark rm;
oop mirror = fd->field_holder()->java_mirror();
_out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii());
- switch (fd->field_type()) {
+ BasicType field_type = fd->field_type();
+ switch (field_type) {
case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break;
case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break;
case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break;
@@ -682,9 +683,12 @@ class StaticFinalFieldPrinter : public FieldClosure {
case T_OBJECT: {
oop value = mirror->obj_field_acquire(fd->offset());
if (value == nullptr) {
- _out->print_cr("null");
+ if (field_type == T_ARRAY) {
+ _out->print("%d", -1);
+ }
+ _out->cr();
} else if (value->is_instance()) {
- assert(fd->field_type() == T_OBJECT, "");
+ assert(field_type == T_OBJECT, "");
if (value->is_a(vmClasses::String_klass())) {
const char* ascii_value = java_lang_String::as_quoted_ascii(value);
_out->print_cr("\"%s\"", (ascii_value != nullptr) ? ascii_value : "");
diff --git a/src/hotspot/share/ci/ciReplay.cpp b/src/hotspot/share/ci/ciReplay.cpp
index 68d4308a2..3171a5d51 100644
--- a/src/hotspot/share/ci/ciReplay.cpp
+++ b/src/hotspot/share/ci/ciReplay.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2024, 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
@@ -1065,46 +1065,48 @@ class CompileReplay : public StackObj {
int length = parse_int("array length");
oop value = nullptr;
- if (field_signature[1] == JVM_SIGNATURE_ARRAY) {
- // multi dimensional array
- ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
- if (kelem == nullptr) {
- return;
- }
- int rank = 0;
- while (field_signature[rank] == JVM_SIGNATURE_ARRAY) {
- rank++;
- }
- jint* dims = NEW_RESOURCE_ARRAY(jint, rank);
- dims[0] = length;
- for (int i = 1; i < rank; i++) {
- dims[i] = 1; // These aren't relevant to the compiler
- }
- value = kelem->multi_allocate(rank, dims, CHECK);
- } else {
- if (strcmp(field_signature, "[B") == 0) {
- value = oopFactory::new_byteArray(length, CHECK);
- } else if (strcmp(field_signature, "[Z") == 0) {
- value = oopFactory::new_boolArray(length, CHECK);
- } else if (strcmp(field_signature, "[C") == 0) {
- value = oopFactory::new_charArray(length, CHECK);
- } else if (strcmp(field_signature, "[S") == 0) {
- value = oopFactory::new_shortArray(length, CHECK);
- } else if (strcmp(field_signature, "[F") == 0) {
- value = oopFactory::new_floatArray(length, CHECK);
- } else if (strcmp(field_signature, "[D") == 0) {
- value = oopFactory::new_doubleArray(length, CHECK);
- } else if (strcmp(field_signature, "[I") == 0) {
- value = oopFactory::new_intArray(length, CHECK);
- } else if (strcmp(field_signature, "[J") == 0) {
- value = oopFactory::new_longArray(length, CHECK);
- } else if (field_signature[0] == JVM_SIGNATURE_ARRAY &&
- field_signature[1] == JVM_SIGNATURE_CLASS) {
- parse_klass(CHECK); // eat up the array class name
- Klass* kelem = resolve_klass(field_signature + 1, CHECK);
- value = oopFactory::new_objArray(kelem, length, CHECK);
+ if (length != -1) {
+ if (field_signature[1] == JVM_SIGNATURE_ARRAY) {
+ // multi dimensional array
+ ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK);
+ if (kelem == nullptr) {
+ return;
+ }
+ int rank = 0;
+ while (field_signature[rank] == JVM_SIGNATURE_ARRAY) {
+ rank++;
+ }
+ jint* dims = NEW_RESOURCE_ARRAY(jint, rank);
+ dims[0] = length;
+ for (int i = 1; i < rank; i++) {
+ dims[i] = 1; // These aren't relevant to the compiler
+ }
+ value = kelem->multi_allocate(rank, dims, CHECK);
} else {
- report_error("unhandled array staticfield");
+ if (strcmp(field_signature, "[B") == 0) {
+ value = oopFactory::new_byteArray(length, CHECK);
+ } else if (strcmp(field_signature, "[Z") == 0) {
+ value = oopFactory::new_boolArray(length, CHECK);
+ } else if (strcmp(field_signature, "[C") == 0) {
+ value = oopFactory::new_charArray(length, CHECK);
+ } else if (strcmp(field_signature, "[S") == 0) {
+ value = oopFactory::new_shortArray(length, CHECK);
+ } else if (strcmp(field_signature, "[F") == 0) {
+ value = oopFactory::new_floatArray(length, CHECK);
+ } else if (strcmp(field_signature, "[D") == 0) {
+ value = oopFactory::new_doubleArray(length, CHECK);
+ } else if (strcmp(field_signature, "[I") == 0) {
+ value = oopFactory::new_intArray(length, CHECK);
+ } else if (strcmp(field_signature, "[J") == 0) {
+ value = oopFactory::new_longArray(length, CHECK);
+ } else if (field_signature[0] == JVM_SIGNATURE_ARRAY &&
+ field_signature[1] == JVM_SIGNATURE_CLASS) {
+ Klass* actual_array_klass = parse_klass(CHECK);
+ Klass* kelem = ObjArrayKlass::cast(actual_array_klass)->element_klass();
+ value = oopFactory::new_objArray(kelem, length, CHECK);
+ } else {
+ report_error("unhandled array staticfield");
+ }
}
}
java_mirror->obj_field_put(fd.offset(), value);
@@ -1142,8 +1144,11 @@ class CompileReplay : public StackObj {
Handle value = java_lang_String::create_from_str(string_value, CHECK);
java_mirror->obj_field_put(fd.offset(), value());
} else if (field_signature[0] == JVM_SIGNATURE_CLASS) {
- Klass* k = resolve_klass(string_value, CHECK);
- oop value = InstanceKlass::cast(k)->allocate_instance(CHECK);
+ oop value = nullptr;
+ if (string_value != nullptr) {
+ Klass* k = resolve_klass(string_value, CHECK);
+ value = InstanceKlass::cast(k)->allocate_instance(CHECK);
+ }
java_mirror->obj_field_put(fd.offset(), value);
} else {
report_error("unhandled staticfield");
diff --git a/test/hotspot/jtreg/compiler/ciReplay/TestNullStaticField.java b/test/hotspot/jtreg/compiler/ciReplay/TestNullStaticField.java
new file mode 100644
index 000000000..47a78ad5e
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/ciReplay/TestNullStaticField.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2024, Red Hat, Inc. 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8333805
+ * @library / /test/lib
+ * @summary Replaying compilation with null static final fields results in a crash
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.compMode != "Xcomp" & vm.debug == true & vm.compiler2.enabled
+ * @modules java.base/jdk.internal.misc
+ * @build jdk.test.whitebox.WhiteBox
+ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * compiler.ciReplay.TestNullStaticField
+ */
+
+package compiler.ciReplay;
+
+public class TestNullStaticField extends DumpReplayBase {
+
+ public static void main(String[] args) {
+ new TestNullStaticField().runTest(TIERED_DISABLED_VM_OPTION);
+ }
+
+ @Override
+ public void testAction() {
+ positiveTest(TIERED_DISABLED_VM_OPTION, "-XX:+ReplayIgnoreInitErrors");
+ }
+
+ @Override
+ public String getTestClass() {
+ return TestClassNullStaticField.class.getName();
+ }
+
+}
+
+class TestClassNullStaticField {
+
+ static final Object[] staticNullArrayField = null;
+ static final Object[][] staticNullMultiArrayField = null;
+ static final Object staticNullObjectField = null;
+ static final String staticNullStringField = null;
+ static final int[] staticNullIntArrayField = null;
+ static final Object[] staticNotNullArrayField = new A[10];
+ static final Object[][] staticNotNullMultiArrayField = new A[10][10];
+ static final Object staticNotNullObjectField = new A();
+ static final String staticNotNullStringField = "Not null";
+ static final int[] staticNotNullIntArrayField = new int[10];
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 20_000; i++) {
+ test();
+ }
+ }
+ public static void test() {
+
+ }
+
+ private static class A {
+ }
+}
+
--
2.33.0

View File

@ -0,0 +1,97 @@
Subject: Backport JDK-8334758: Incorrect note in Javadoc for a few RandomGenerator methods
---
.../java/util/random/RandomGenerator.java | 51 +++++++++----------
1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/src/java.base/share/classes/java/util/random/RandomGenerator.java b/src/java.base/share/classes/java/util/random/RandomGenerator.java
index a7c6bcec3..5c0d07fb1 100644
--- a/src/java.base/share/classes/java/util/random/RandomGenerator.java
+++ b/src/java.base/share/classes/java/util/random/RandomGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2024, 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
@@ -640,12 +640,11 @@ public interface RandomGenerator {
*
* @throws IllegalArgumentException if {@code bound} is not positive
*
- * @implSpec The default implementation checks that {@code bound} is a
- * positive {@code int}. Then invokes {@code nextInt()}, limiting the result
- * to be greater than or equal zero and less than {@code bound}. If {@code bound}
- * is a power of two then limiting is a simple masking operation. Otherwise,
- * the result is re-calculated by invoking {@code nextInt()} until the
- * result is greater than or equal zero and less than {@code bound}.
+ * @implSpec The default implementation checks that {@code bound} is positive.
+ * It then invokes {@link #nextInt()} one or more times to ensure a uniform
+ * distribution in the range 0 (inclusive)
+ * to {@code bound} (exclusive).
+ * It assumes the distribution of {@link #nextInt()} to be uniform.
*/
default int nextInt(int bound) {
RandomSupport.checkBound(bound);
@@ -666,13 +665,12 @@ public interface RandomGenerator {
* @throws IllegalArgumentException if {@code origin} is greater than
* or equal to {@code bound}
*
- * @implSpec The default implementation checks that {@code origin} and
- * {@code bound} are positive {@code ints}. Then invokes {@code nextInt()},
- * limiting the result to be greater that or equal {@code origin} and less
- * than {@code bound}. If {@code bound} is a power of two then limiting is a
- * simple masking operation. Otherwise, the result is re-calculated by
- * invoking {@code nextInt()} until the result is greater than or equal
- * {@code origin} and less than {@code bound}.
+ * @implSpec The default implementation checks that {@code origin}
+ * is less than {@code bound}.
+ * It then invokes {@link #nextInt()} one or more times to ensure a uniform
+ * distribution in the range {@code origin} (inclusive)
+ * to {@code bound} (exclusive).
+ * It assumes the distribution of {@link #nextInt()} to be uniform.
*/
default int nextInt(int origin, int bound) {
RandomSupport.checkRange(origin, bound);
@@ -699,13 +697,11 @@ public interface RandomGenerator {
*
* @throws IllegalArgumentException if {@code bound} is not positive
*
- * @implSpec The default implementation checks that {@code bound} is a
- * positive {@code long}. Then invokes {@code nextLong()}, limiting the
- * result to be greater than or equal zero and less than {@code bound}. If
- * {@code bound} is a power of two then limiting is a simple masking
- * operation. Otherwise, the result is re-calculated by invoking
- * {@code nextLong()} until the result is greater than or equal zero and
- * less than {@code bound}.
+ * @implSpec The default implementation checks that {@code bound} is positive.
+ * It then invokes {@link #nextLong()} one or more times to ensure a uniform
+ * distribution in the range 0 (inclusive)
+ * to {@code bound} (exclusive).
+ * It assumes the distribution of {@link #nextLong()} to be uniform.
*/
default long nextLong(long bound) {
RandomSupport.checkBound(bound);
@@ -726,13 +722,12 @@ public interface RandomGenerator {
* @throws IllegalArgumentException if {@code origin} is greater than
* or equal to {@code bound}
*
- * @implSpec The default implementation checks that {@code origin} and
- * {@code bound} are positive {@code longs}. Then invokes {@code nextLong()},
- * limiting the result to be greater than or equal {@code origin} and less
- * than {@code bound}. If {@code bound} is a power of two then limiting is a
- * simple masking operation. Otherwise, the result is re-calculated by
- * invoking {@code nextLong()} until the result is greater than or equal
- * {@code origin} and less than {@code bound}.
+ * @implSpec The default implementation checks that {@code origin}
+ * is less than {@code bound}.
+ * It then invokes {@link #nextLong()} one or more times to ensure a uniform
+ * distribution in the range {@code origin} (inclusive)
+ * to {@code bound} (exclusive).
+ * It assumes the distribution of {@link #nextLong()} to be uniform.
*/
default long nextLong(long origin, long bound) {
RandomSupport.checkRange(origin, bound);
--
2.33.0

View File

@ -0,0 +1,162 @@
Subject: Backport JDK-8335638 Calling VarHandle.{access-mode} methods reflectively throws wrong exception
---
src/hotspot/share/prims/methodHandles.cpp | 59 ++++++++++++++++++-
.../VarHandles/VarHandleTestReflection.java | 25 +++++++-
2 files changed, 78 insertions(+), 6 deletions(-)
diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp
index f6412504a..55a6b3286 100644
--- a/src/hotspot/share/prims/methodHandles.cpp
+++ b/src/hotspot/share/prims/methodHandles.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2024, 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
@@ -1362,6 +1362,18 @@ JVM_ENTRY(jobject, MH_invokeExact_UOE(JNIEnv* env, jobject mh, jobjectArray args
}
JVM_END
+/**
+ * Throws a java/lang/UnsupportedOperationException unconditionally.
+ * This is required by the specification of VarHandle.{access-mode} if
+ * invoked directly.
+ */
+JVM_ENTRY(jobject, VH_UOE(JNIEnv* env, jobject vh, jobjectArray args)) {
+ THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "VarHandle access mode methods cannot be invoked reflectively");
+ return nullptr;
+}
+JVM_END
+
+
/// JVM_RegisterMethodHandleMethods
#define LANG "Ljava/lang/"
@@ -1401,6 +1413,40 @@ static JNINativeMethod MH_methods[] = {
{CC "invoke", CC "([" OBJ ")" OBJ, FN_PTR(MH_invoke_UOE)},
{CC "invokeExact", CC "([" OBJ ")" OBJ, FN_PTR(MH_invokeExact_UOE)}
};
+static JNINativeMethod VH_methods[] = {
+ // UnsupportedOperationException throwers
+ {CC "get", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "set", CC "([" OBJ ")V", FN_PTR(VH_UOE)},
+ {CC "getVolatile", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "setVolatile", CC "([" OBJ ")V", FN_PTR(VH_UOE)},
+ {CC "getAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "setRelease", CC "([" OBJ ")V", FN_PTR(VH_UOE)},
+ {CC "getOpaque", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "setOpaque", CC "([" OBJ ")V", FN_PTR(VH_UOE)},
+ {CC "compareAndSet", CC "([" OBJ ")Z", FN_PTR(VH_UOE)},
+ {CC "compareAndExchange", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "compareAndExchangeAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "compareAndExchangeRelease", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "weakCompareAndSetPlain", CC "([" OBJ ")Z", FN_PTR(VH_UOE)},
+ {CC "weakCompareAndSet", CC "([" OBJ ")Z", FN_PTR(VH_UOE)},
+ {CC "weakCompareAndSetAcquire", CC "([" OBJ ")Z", FN_PTR(VH_UOE)},
+ {CC "weakCompareAndSetRelease", CC "([" OBJ ")Z", FN_PTR(VH_UOE)},
+ {CC "getAndSet", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndSetAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndSetRelease", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndAdd", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndAddAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndAddRelease", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseOr", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseOrAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseOrRelease", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseAnd", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseAndAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseAndRelease", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseXor", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseXorAcquire", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)},
+ {CC "getAndBitwiseXorRelease", CC "([" OBJ ")" OBJ, FN_PTR(VH_UOE)}
+};
/**
* This one function is exported, used by NativeLookup.
@@ -1408,9 +1454,12 @@ static JNINativeMethod MH_methods[] = {
JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) {
assert(!MethodHandles::enabled(), "must not be enabled");
assert(vmClasses::MethodHandle_klass() != nullptr, "should be present");
+ assert(vmClasses::VarHandle_klass() != nullptr, "should be present");
- oop mirror = vmClasses::MethodHandle_klass()->java_mirror();
- jclass MH_class = (jclass) JNIHandles::make_local(THREAD, mirror);
+ oop mh_mirror = vmClasses::MethodHandle_klass()->java_mirror();
+ oop vh_mirror = vmClasses::VarHandle_klass()->java_mirror();
+ jclass MH_class = (jclass) JNIHandles::make_local(THREAD, mh_mirror);
+ jclass VH_class = (jclass) JNIHandles::make_local(THREAD, vh_mirror);
{
ThreadToNativeFromVM ttnfv(thread);
@@ -1422,6 +1471,10 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class))
status = env->RegisterNatives(MH_class, MH_methods, sizeof(MH_methods)/sizeof(JNINativeMethod));
guarantee(status == JNI_OK && !env->ExceptionOccurred(),
"register java.lang.invoke.MethodHandle natives");
+
+ status = env->RegisterNatives(VH_class, VH_methods, sizeof(VH_methods)/sizeof(JNINativeMethod));
+ guarantee(status == JNI_OK && !env->ExceptionOccurred(),
+ "register java.lang.invoke.VarHandle natives");
}
log_debug(methodhandles, indy)("MethodHandle support loaded (using LambdaForms)");
diff --git a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestReflection.java b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestReflection.java
index 652272ca8..b20e18d26 100644
--- a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestReflection.java
+++ b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestReflection.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2024, 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
@@ -33,6 +33,7 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleInfo;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.stream.Stream;
@@ -52,15 +53,33 @@ public class VarHandleTestReflection extends VarHandleBaseTest {
}
@Test(dataProvider = "accessModesProvider", expectedExceptions = IllegalArgumentException.class)
- public void methodInvocation(VarHandle.AccessMode accessMode) throws Exception {
+ public void methodInvocationArgumentMismatch(VarHandle.AccessMode accessMode) throws Exception {
VarHandle v = handle();
- // Try a reflective invoke using a Method
+ // Try a reflective invoke using a Method, with no arguments
Method vhm = VarHandle.class.getMethod(accessMode.methodName(), Object[].class);
vhm.invoke(v, new Object[]{});
}
+ @Test(dataProvider = "accessModesProvider")
+ public void methodInvocationMatchingArguments(VarHandle.AccessMode accessMode) throws Exception {
+ VarHandle v = handle();
+
+ // Try a reflective invoke using a Method, with the minimal required arguments
+
+ Method vhm = VarHandle.class.getMethod(accessMode.methodName(), Object[].class);
+ Object arg = new Object[0];
+ try {
+ vhm.invoke(v, arg);
+ } catch (InvocationTargetException e) {
+ if (!(e.getCause() instanceof UnsupportedOperationException)) {
+ throw new RuntimeException("expected UnsupportedOperationException but got: "
+ + e.getCause().getClass().getName(), e);
+ }
+ }
+ }
+
@Test(dataProvider = "accessModesProvider", expectedExceptions = UnsupportedOperationException.class)
public void methodHandleInvoke(VarHandle.AccessMode accessMode) throws Throwable {
VarHandle v = handle();
--
2.33.0

View File

@ -0,0 +1,29 @@
Subject: Backport JDK-8336012 Fix usages of jtreg-reserved properties
---
test/jdk/java/lang/invoke/PrivateInvokeTest.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/test/jdk/java/lang/invoke/PrivateInvokeTest.java b/test/jdk/java/lang/invoke/PrivateInvokeTest.java
index 12edf8e32..8ae78d967 100644
--- a/test/jdk/java/lang/invoke/PrivateInvokeTest.java
+++ b/test/jdk/java/lang/invoke/PrivateInvokeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2024, 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
@@ -67,8 +67,6 @@ public class PrivateInvokeTest {
String vstr = System.getProperty(THIS_CLASS.getSimpleName()+".verbose");
if (vstr == null)
vstr = System.getProperty(THIS_CLASS.getName()+".verbose");
- if (vstr == null)
- vstr = System.getProperty("test.verbose");
if (vstr != null) verbose = Integer.parseInt(vstr);
}
private static int referenceKind(Method m) {
--
2.33.0

View File

@ -0,0 +1,33 @@
Subject: Backport of JDK-8336080 Fix -Wzero-as-null-pointer-constant warnings in ClassLoaderStats ctor
---
src/hotspot/share/classfile/classLoaderStats.hpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/hotspot/share/classfile/classLoaderStats.hpp b/src/hotspot/share/classfile/classLoaderStats.hpp
index 8296c6ee2..4818ddff6 100644
--- a/src/hotspot/share/classfile/classLoaderStats.hpp
+++ b/src/hotspot/share/classfile/classLoaderStats.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2024, 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
@@ -82,9 +82,9 @@ public:
uintx _hidden_classes_count;
ClassLoaderStats() :
- _cld(0),
- _class_loader(0),
- _parent(0),
+ _cld(nullptr),
+ _class_loader(),
+ _parent(),
_chunk_sz(0),
_block_sz(0),
_classes_count(0),
--
2.33.0

View File

@ -0,0 +1,29 @@
Subject: Backport of JDK-8336152 Remove unused forward declaration in classLoadInfo.hpp
---
src/hotspot/share/classfile/classLoadInfo.hpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/hotspot/share/classfile/classLoadInfo.hpp b/src/hotspot/share/classfile/classLoadInfo.hpp
index b1257dc99..ab665c6b3 100644
--- a/src/hotspot/share/classfile/classLoadInfo.hpp
+++ b/src/hotspot/share/classfile/classLoadInfo.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2024, 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,8 +29,6 @@
class InstanceKlass;
-template <typename T> class GrowableArray;
-
class ClassInstanceInfo : public StackObj {
private:
InstanceKlass* _dynamic_nest_host;
--
2.33.0

View File

@ -0,0 +1,40 @@
Subject: Backport JDK-8336855 Duplicate protected declaration and comment in interp_masm_aarch64.hpp
---
src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp
index 019eb2355..6dd8ea70d 100644
--- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp
@@ -35,8 +35,6 @@
typedef ByteSize (*OffsetFunction)(uint);
class InterpreterMacroAssembler: public MacroAssembler {
- protected:
-
protected:
// Interpreter specific version of call_VM_base
using MacroAssembler::call_VM_leaf_base;
@@ -110,8 +108,6 @@ class InterpreterMacroAssembler: public MacroAssembler {
void get_dispatch();
- // Helpers for runtime call arguments/results
-
// Helpers for runtime call arguments/results
void get_method(Register reg) {
ldr(reg, Address(rfp, frame::interpreter_frame_method_offset * wordSize));
@@ -183,7 +179,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
void load_ptr(int n, Register val);
void store_ptr(int n, Register val);
-// Load float value from 'address'. The value is loaded onto the FPU register v0.
+ // Load float value from 'address'. The value is loaded onto the FPU register v0.
void load_float(Address src);
void load_double(Address src);
--
2.33.0

View File

@ -0,0 +1,34 @@
Subject: Backport JDK-8336879 Always true condition 'img != null' in GTKPainter.paintPopupMenuBackground
---
.../classes/com/sun/java/swing/plaf/gtk/GTKPainter.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
index 1635ff66f..6231e11d6 100644
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
+++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2024, 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
@@ -610,10 +610,10 @@ class GTKPainter extends SynthPainter {
x + insets.left, y + insets.top, w - insets.left - insets.right,
h - insets.top - insets.bottom);
BufferedImage img = ENGINE.finishPainting();
- if(!isHW) {
+ if (!isHW && img != null) {
int border = img.getRGB(0, h / 2);
- if (img != null && border == img.getRGB(w / 2, h / 2)) {
- // fix no menu borders in Adwaita theme
+ if (border == img.getRGB(w / 2, h / 2)) {
+ // fix no menu borders
Graphics g2 = img.getGraphics();
Color c = new Color(border);
g2.setColor(new Color(Math.max((int) (c.getRed() * 0.8), 0),
--
2.33.0

View File

@ -0,0 +1,54 @@
Subject: Backport JDK-8337334 Test tools/javac/7142086/T7142086.java timeout with fastdebug binary
---
test/langtools/TEST.ROOT | 3 ++-
test/langtools/tools/javac/7142086/T7142086.java | 12 ++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT
index da884dee1..938c7674b 100644
--- a/test/langtools/TEST.ROOT
+++ b/test/langtools/TEST.ROOT
@@ -42,4 +42,5 @@ requires.extraPropDefns.vmOpts = \
-XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI \
--add-exports java.base/jdk.internal.foreign=ALL-UNNAMED
requires.properties= \
- vm.continuations
+ vm.continuations \
+ vm.debug
diff --git a/test/langtools/tools/javac/7142086/T7142086.java b/test/langtools/tools/javac/7142086/T7142086.java
index bc8260bd4..b6521b7ff 100644
--- a/test/langtools/tools/javac/7142086/T7142086.java
+++ b/test/langtools/tools/javac/7142086/T7142086.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2024, 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
@@ -23,12 +23,20 @@
/*
* @test
- * @bug 7142086
+ * @bug 7142086 8337334
+ * @requires vm.debug == false
* @summary performance problem in Check.checkOverrideClashes(...)
* @modules jdk.compiler
* @run main/timeout=10 T7142086
*/
+/*
+ * @test
+ * @requires vm.debug == true
+ * @modules jdk.compiler
+ * @run main/timeout=20 T7142086
+ */
+
import com.sun.source.util.JavacTask;
import java.net.URI;
import java.util.List;
--
2.33.0

View File

@ -0,0 +1,29 @@
Subject: Backport JDK-8337679 Memset warning in src/hotspot/share/adlc/adlArena.cpp
---
src/hotspot/share/adlc/adlArena.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/hotspot/share/adlc/adlArena.cpp b/src/hotspot/share/adlc/adlArena.cpp
index d29a255a9..f0f489d90 100644
--- a/src/hotspot/share/adlc/adlArena.cpp
+++ b/src/hotspot/share/adlc/adlArena.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2024, 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,8 +62,6 @@ void AdlChunk::chop() {
AdlChunk *k = this;
while( k ) {
AdlChunk *tmp = k->_next;
- // clear out this chunk (to detect allocation bugs)
- memset(k, 0xBE, k->_len);
free(k); // Free chunk (was malloc'd)
k = tmp;
}
--
2.33.0

View File

@ -0,0 +1,28 @@
Subject: Backport JDK-8338010 WB_IsFrameDeoptimized miss ResourceMark
---
src/hotspot/share/prims/whitebox.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
index 4a7e69ca8..f83e84e30 100644
--- a/src/hotspot/share/prims/whitebox.cpp
+++ b/src/hotspot/share/prims/whitebox.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2024, 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
@@ -771,6 +771,7 @@ WB_END
WB_ENTRY(jboolean, WB_IsFrameDeoptimized(JNIEnv* env, jobject o, jint depth))
bool result = false;
if (thread->has_last_Java_frame()) {
+ ResourceMark rm(THREAD);
RegisterMap reg_map(thread,
RegisterMap::UpdateMap::include,
RegisterMap::ProcessFrames::include,
--
2.33.0

View File

@ -0,0 +1,82 @@
Subject: Backport JDK-8338938 The result of the combine method of SettingsControl is not used
---
.../classes/jdk/jfr/internal/Control.java | 4 +--
.../jfr/api/settings/TestFilterEvents.java | 31 ++++++++++++++++++-
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java
index 339346bd6..fbc4d4c91 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Control.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2024, 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,7 +136,7 @@ final class Control {
@Override
public String run() {
try {
- delegate.combine(Collections.unmodifiableSet(values));
+ return delegate.combine(Collections.unmodifiableSet(values));
} catch (Throwable t) {
// Prevent malicious user to propagate exception callback in the wrong context
Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occurred when combining " + values + " for " + getClass());
diff --git a/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java b/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java
index 42bfc3176..67619fb10 100644
--- a/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java
+++ b/test/jdk/jdk/jfr/api/settings/TestFilterEvents.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2024, 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,6 +70,7 @@ public class TestFilterEvents {
continuous.enable(HTTPGetEvent.class).with("threadNames", "\"unused-threadname-1\"");
assertEquals(0, makeProfilingRecording("\"unused-threadname-2\""));
assertEquals(1, makeProfilingRecording("\"" + Thread.currentThread().getName() + "\""));
+ assertEquals(2, makeCombineControl());
continuous.close();
}
@@ -94,4 +95,32 @@ public class TestFilterEvents {
}
}
+ private static int makeCombineControl() throws Exception {
+ try (Recording r1 = new Recording()) {
+ r1.enable(HTTPPostEvent.class).with("uriFilter", "https://www.example.com/list");
+ r1.start();
+
+ try (Recording r2 = new Recording()) {
+ r2.enable(HTTPPostEvent.class).with("uriFilter", "https://www.example.com/get");
+ r2.start();
+
+ HTTPPostEvent e1 = new HTTPPostEvent();
+ e1.uri = "https://www.example.com/list";
+ e1.commit();
+
+ HTTPPostEvent e2 = new HTTPPostEvent();
+ e2.uri = "https://www.example.com/get";
+ e2.commit();
+
+ HTTPPostEvent e3 = new HTTPPostEvent();
+ e3.uri = "https://www.example.com/put";
+ e3.commit();
+ }
+
+ r1.stop();
+
+ return Events.fromRecording(r1).size();
+ }
+ }
+
}
--
2.33.0

View File

@ -0,0 +1,486 @@
Subject: Backport JDK-8339460 CDS error when module is located in a directory with space in the name
---
src/hotspot/share/cds/classListParser.cpp | 6 +-
src/hotspot/share/cds/classListWriter.cpp | 4 +-
src/hotspot/share/cds/filemap.cpp | 4 +-
src/hotspot/share/classfile/classLoader.cpp | 50 +++++-
src/hotspot/share/classfile/classLoader.hpp | 4 +-
.../share/classfile/classLoaderExt.cpp | 12 +-
test/hotspot/jtreg/TEST.groups | 3 +-
.../cds/appcds/complexURI/ComplexURITest.java | 167 ++++++++++++++++++
.../appcds/complexURI/mypackage/Another.java | 27 +++
.../cds/appcds/complexURI/mypackage/Main.java | 37 ++++
10 files changed, 296 insertions(+), 18 deletions(-)
create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java
create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java
create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java
diff --git a/src/hotspot/share/cds/classListParser.cpp b/src/hotspot/share/cds/classListParser.cpp
index a1e1a4131..0ba74ca4e 100644
--- a/src/hotspot/share/cds/classListParser.cpp
+++ b/src/hotspot/share/cds/classListParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2024, 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
@@ -472,7 +472,9 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
}
- InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL);
+ ResourceMark rm;
+ char * source_path = os::strdup_check_oom(ClassLoader::uri_to_path(_source));
+ InstanceKlass* k = UnregisteredClasses::load_class(class_name, source_path, CHECK_NULL);
if (k->local_interfaces()->length() != _interfaces->length()) {
print_specified_interfaces();
print_actual_interfaces(k);
diff --git a/src/hotspot/share/cds/classListWriter.cpp b/src/hotspot/share/cds/classListWriter.cpp
index 2a65ee51d..53637429a 100644
--- a/src/hotspot/share/cds/classListWriter.cpp
+++ b/src/hotspot/share/cds/classListWriter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2024, 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
@@ -171,6 +171,8 @@ void ClassListWriter::write_to_stream(const InstanceKlass* k, outputStream* stre
}
}
+ // NB: the string following "source: " is not really a proper file name, but rather
+ // a truncated URI referring to a file. It must be decoded after reading.
#ifdef _WINDOWS
// "file:/C:/dir/foo.jar" -> "C:/dir/foo.jar"
stream->print(" source: %s", cfs->source() + 6);
diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp
index 023c0762a..f56920c64 100644
--- a/src/hotspot/share/cds/filemap.cpp
+++ b/src/hotspot/share/cds/filemap.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2024, 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
@@ -583,7 +583,7 @@ int FileMapInfo::get_module_shared_path_index(Symbol* location) {
// skip_uri_protocol was also called during dump time -- see ClassLoaderExt::process_module_table()
ResourceMark rm;
- const char* file = ClassLoader::skip_uri_protocol(location->as_C_string());
+ const char* file = ClassLoader::uri_to_path(location->as_C_string());
for (int i = ClassLoaderExt::app_module_paths_start_index(); i < get_number_of_shared_paths(); i++) {
SharedClassPathEntry* ent = shared_path(i);
assert(ent->in_named_module(), "must be");
diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp
index 5e89673a5..74b9d9300 100644
--- a/src/hotspot/share/classfile/classLoader.cpp
+++ b/src/hotspot/share/classfile/classLoader.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -78,6 +78,9 @@
#include "utilities/macros.hpp"
#include "utilities/utf8.hpp"
+#include <stdlib.h>
+#include <ctype.h>
+
// Entry point in java.dll for path canonicalization
typedef int (*canonicalize_fn_t)(const char *orig, char *out, int len);
@@ -1223,7 +1226,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
}
#if INCLUDE_CDS
-char* ClassLoader::skip_uri_protocol(char* source) {
+static const char* skip_uri_protocol(const char* source) {
if (strncmp(source, "file:", 5) == 0) {
// file: protocol path could start with file:/ or file:///
// locate the char after all the forward slashes
@@ -1242,6 +1245,47 @@ char* ClassLoader::skip_uri_protocol(char* source) {
return source;
}
+static char decode_percent_encoded(const char *str, size_t& index) {
+ if (str[index] == '%'
+ && isxdigit(str[index + 1])
+ && isxdigit(str[index + 2])) {
+ char hex[3];
+ hex[0] = str[index + 1];
+ hex[1] = str[index + 2];
+ hex[2] = '\0';
+ index += 2;
+ return (char) strtol(hex, NULL, 16);
+ }
+ return str[index];
+}
+
+char* ClassLoader::uri_to_path(const char* uri) {
+ const size_t len = strlen(uri) + 1;
+ char* path = NEW_RESOURCE_ARRAY(char, len);
+
+ uri = skip_uri_protocol(uri);
+
+ if (strncmp(uri, "//", 2) == 0) {
+ // Skip the empty "authority" part
+ uri += 2;
+ }
+
+#ifdef _WINDOWS
+ if (uri[0] == '/') {
+ // Absolute path name on Windows does not begin with a slash
+ uri += 1;
+ }
+#endif
+
+ size_t path_index = 0;
+ for (size_t i = 0; i < strlen(uri); ++i) {
+ char decoded = decode_percent_encoded(uri, i);
+ path[path_index++] = decoded;
+ }
+ path[path_index] = '\0';
+ return path;
+}
+
// Record the shared classpath index and loader type for classes loaded
// by the builtin loaders at dump time.
void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
@@ -1275,7 +1319,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
// Save the path from the file: protocol or the module name from the jrt: protocol
// if no protocol prefix is found, path is the same as stream->source(). This path
// must be valid since the class has been successfully parsed.
- char* path = skip_uri_protocol(src);
+ const char* path = ClassLoader::uri_to_path(src);
assert(path != nullptr, "sanity");
for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) {
SharedClassPathEntry* ent = FileMapInfo::shared_path(i);
diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp
index 4cb196719..2f464063e 100644
--- a/src/hotspot/share/classfile/classLoader.hpp
+++ b/src/hotspot/share/classfile/classLoader.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -364,7 +364,7 @@ class ClassLoader: AllStatic {
// entries during shared classpath setup time.
static int num_module_path_entries();
static void exit_with_path_failure(const char* error, const char* message);
- static char* skip_uri_protocol(char* source);
+ static char* uri_to_path(const char* uri);
static void record_result(JavaThread* current, InstanceKlass* ik,
const ClassFileStream* stream, bool redefined);
#endif
diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp
index c9fd8173b..5334b118e 100644
--- a/src/hotspot/share/classfile/classLoaderExt.cpp
+++ b/src/hotspot/share/classfile/classLoaderExt.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2024, 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,12 +98,10 @@ void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable*
ModulePathsGatherer(JavaThread* current, GrowableArray<char*>* module_paths) :
_current(current), _module_paths(module_paths) {}
void do_module(ModuleEntry* m) {
- char* path = m->location()->as_C_string();
- if (strncmp(path, "file:", 5) == 0) {
- path = ClassLoader::skip_uri_protocol(path);
- char* path_copy = NEW_RESOURCE_ARRAY(char, strlen(path) + 1);
- strcpy(path_copy, path);
- _module_paths->append(path_copy);
+ char* uri = m->location()->as_C_string();
+ if (strncmp(uri, "file:", 5) == 0) {
+ char* path = ClassLoader::uri_to_path(uri);
+ _module_paths->append(path);
}
}
};
diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups
index 4923fbd5b..4c7352956 100644
--- a/test/hotspot/jtreg/TEST.groups
+++ b/test/hotspot/jtreg/TEST.groups
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2024, 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
@@ -430,6 +430,7 @@ hotspot_cds_only = \
hotspot_appcds_dynamic = \
runtime/cds/appcds/ \
-runtime/cds/appcds/cacheObject \
+ -runtime/cds/appcds/complexURI \
-runtime/cds/appcds/customLoader \
-runtime/cds/appcds/dynamicArchive \
-runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java \
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java
new file mode 100644
index 000000000..409e37e10
--- /dev/null
+++ b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java
@@ -0,0 +1,167 @@
+/* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2024 JetBrains s.r.o.
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies that CDS works with jar located in directories
+ * with names that need escaping
+ * @bug 8339460
+ * @requires vm.cds
+ * @requires vm.cds.custom.loaders
+ * @requires vm.flagless
+ * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
+ * @compile mypackage/Main.java mypackage/Another.java
+ * @run main/othervm ComplexURITest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.Platform;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class ComplexURITest {
+ final static String moduleName = "mymodule";
+
+ public static void main(String[] args) throws Exception {
+ System.setProperty("test.noclasspath", "true");
+ String jarFile = JarBuilder.build(moduleName, "mypackage/Main", "mypackage/Another");
+
+ Path subDir = Path.of(".", "dir with space");
+ Files.createDirectory(subDir);
+ Path newJarFilePath = subDir.resolve(moduleName + ".jar");
+ Files.move(Path.of(jarFile), newJarFilePath);
+ jarFile = newJarFilePath.toString();
+
+ final String listFileName = "test-classlist.txt";
+ final String staticArchiveName = "test-static.jsa";
+ final String dynamicArchiveName = "test-dynamic.jsa";
+
+ // Verify static archive creation and use
+ File fileList = new File(listFileName);
+ delete(fileList.toPath());
+ File staticArchive = new File(staticArchiveName);
+ delete(staticArchive.toPath());
+
+ createClassList(jarFile, listFileName);
+ if (!fileList.exists()) {
+ throw new RuntimeException("No class list created at " + fileList);
+ }
+
+ createArchive(jarFile, listFileName, staticArchiveName);
+ if (!staticArchive.exists()) {
+ throw new RuntimeException("No shared classes archive created at " + staticArchive);
+ }
+
+ useArchive(jarFile, staticArchiveName);
+
+ // Verify dynamic archive creation and use
+ File dynamicArchive = new File(dynamicArchiveName);
+ delete(dynamicArchive.toPath());
+
+ createDynamicArchive(jarFile, dynamicArchiveName);
+ if (!dynamicArchive.exists()) {
+ throw new RuntimeException("No dynamic archive created at " + dynamicArchive);
+ }
+
+ testDynamicArchive(jarFile, dynamicArchiveName);
+ }
+
+ private static void delete(Path path) throws Exception {
+ if (Files.exists(path)) {
+ if (Platform.isWindows()) {
+ Files.setAttribute(path, "dos:readonly", false);
+ }
+ Files.delete(path);
+ }
+ }
+
+ private static void createClassList(String jarFile, String list) throws Exception {
+ String[] launchArgs = {
+ "-XX:DumpLoadedClassList=" + list,
+ "--module-path",
+ jarFile,
+ "--module",
+ moduleName + "/mypackage.Main"};
+ ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs);
+ OutputAnalyzer output = TestCommon.executeAndLog(pb, "create-list");
+ output.shouldHaveExitValue(0);
+ }
+
+ private static void createArchive(String jarFile, String list, String archive) throws Exception {
+ String[] launchArgs = {
+ "-Xshare:dump",
+ "-XX:SharedClassListFile=" + list,
+ "-XX:SharedArchiveFile=" + archive,
+ "--module-path",
+ jarFile,
+ "--module",
+ moduleName + "/mypackage.Main"};
+ ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs);
+ OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive");
+ output.shouldHaveExitValue(0);
+ }
+
+ private static void useArchive(String jarFile, String archive) throws Exception {
+ String[] launchArgs = {
+ "-Xshare:on",
+ "-XX:SharedArchiveFile=" + archive,
+ "--module-path",
+ jarFile,
+ "--module",
+ moduleName + "/mypackage.Main"};
+ ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs);
+ OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive");
+ output.shouldHaveExitValue(0);
+ }
+
+ private static void createDynamicArchive(String jarFile, String archive) throws Exception {
+ String[] launchArgs = {
+ "-XX:ArchiveClassesAtExit=" + archive,
+ "--module-path",
+ jarFile,
+ "--module",
+ moduleName + "/mypackage.Main"};
+ ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs);
+ OutputAnalyzer output = TestCommon.executeAndLog(pb, "dynamic-archive");
+ output.shouldHaveExitValue(0);
+ }
+
+ private static void testDynamicArchive(String jarFile, String archive) throws Exception {
+ String[] launchArgs = {
+ "-XX:SharedArchiveFile=" + archive,
+ "-XX:+PrintSharedArchiveAndExit",
+ "--module-path",
+ jarFile,
+ "--module",
+ moduleName + "/mypackage.Main"};
+ ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs);
+ OutputAnalyzer output = TestCommon.executeAndLog(pb, "dynamic-archive");
+ output.shouldHaveExitValue(0);
+ output.shouldContain("archive is valid");
+ output.shouldContain(": mypackage.Main app_loader");
+ output.shouldContain(": mypackage.Another unregistered_loader");
+ }
+}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java
new file mode 100644
index 000000000..106dfd490
--- /dev/null
+++ b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java
@@ -0,0 +1,27 @@
+/* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2024 JetBrains s.r.o.
+ * 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.
+ *
+ * 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 mypackage;
+
+public class Another {
+}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java
new file mode 100644
index 000000000..fdb79e895
--- /dev/null
+++ b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java
@@ -0,0 +1,37 @@
+/* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2024 JetBrains s.r.o.
+ * 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.
+ *
+ * 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 mypackage;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class Main {
+ public static void main(String[] args) throws Exception {
+ URL url1 = Main.class.getProtectionDomain().getCodeSource().getLocation();
+ System.out.println("Will load Another from " + url1);
+ ClassLoader cl = URLClassLoader.newInstance(new URL[] { url1 }, null);
+ var anotherClass = cl.loadClass("mypackage.Another");
+ System.out.println("Class " + anotherClass + " loaded successfully");
+ }
+}
--
2.33.0

View File

@ -0,0 +1,30 @@
Subject: Backport JDK-8340186 Shenandoah: Missing load_reference_barrier_phantom_narrow match in is_shenandoah_lrb_call
---
.../share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
index ac3afa774..da9fd5466 100644
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2023, Red Hat, Inc. 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
@@ -306,7 +306,8 @@ bool ShenandoahBarrierSetC2::is_shenandoah_lrb_call(Node* call) {
(entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_strong_narrow)) ||
(entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak)) ||
(entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak_narrow)) ||
- (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom));
+ (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom)) ||
+ (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom_narrow));
}
bool ShenandoahBarrierSetC2::is_shenandoah_marking_if(PhaseValues* phase, Node* n) {
--
2.33.0

View File

@ -0,0 +1,23 @@
Subject: Backport JDK-8340273 Remove CounterHalfLifeTime
---
src/hotspot/share/runtime/globals.hpp | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
index a066d0d37..6f8b3e85e 100644
--- a/src/hotspot/share/runtime/globals.hpp
+++ b/src/hotspot/share/runtime/globals.hpp
@@ -1221,9 +1221,6 @@ const int ObjectAlignmentInBytes = 8;
product(bool, UseCounterDecay, true, \
"Adjust recompilation counters") \
\
- develop(intx, CounterHalfLifeTime, 30, \
- "Half-life time of invocation counters (in seconds)") \
- \
develop(intx, CounterDecayMinIntervalLength, 500, \
"The minimum interval (in milliseconds) between invocation of " \
"CounterDecay") \
--
2.33.0

View File

@ -0,0 +1,23 @@
Subject: Backport JDK-8340623 Remove outdated PROCESSOR_ARCHITECTURE_IA64 from Windows coding
---
src/java.base/windows/native/libjava/java_props_md.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
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 2ff4c9e88..280747d0d 100644
--- a/src/java.base/windows/native/libjava/java_props_md.c
+++ b/src/java.base/windows/native/libjava/java_props_md.c
@@ -263,9 +263,6 @@ cpu_isalist(void)
SYSTEM_INFO info;
GetSystemInfo(&info);
switch (info.wProcessorArchitecture) {
-#ifdef PROCESSOR_ARCHITECTURE_IA64
- case PROCESSOR_ARCHITECTURE_IA64: return "ia64";
-#endif
#ifdef PROCESSOR_ARCHITECTURE_AMD64
case PROCESSOR_ARCHITECTURE_AMD64: return "amd64";
#endif
--
2.33.0

View File

@ -0,0 +1,29 @@
Subject: Backport of 8330191: Fix typo in precompiled.hpp
---
src/hotspot/share/precompiled/precompiled.hpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hotspot/share/precompiled/precompiled.hpp b/src/hotspot/share/precompiled/precompiled.hpp
index c6b866801..e8dec0fc6 100644
--- a/src/hotspot/share/precompiled/precompiled.hpp
+++ b/src/hotspot/share/precompiled/precompiled.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2024, 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,7 +29,7 @@
// These header files are included in at least 130 C++ files, as of
// measurements made in November 2018. This list excludes files named
-// *.include.hpp, since including them decreased build performance.
+// *.incline.hpp, since including them decreased build performance.
#include "classfile/classLoaderData.hpp"
#include "classfile/javaClasses.hpp"
--
2.33.0

View File

@ -0,0 +1,49 @@
Subject: Backport of 8337245: Fix wrong comment of StringConcatHelper
---
.../share/classes/java/lang/StringConcatHelper.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/java.base/share/classes/java/lang/StringConcatHelper.java b/src/java.base/share/classes/java/lang/StringConcatHelper.java
index 139181af0..db4b2d690 100644
--- a/src/java.base/share/classes/java/lang/StringConcatHelper.java
+++ b/src/java.base/share/classes/java/lang/StringConcatHelper.java
@@ -228,7 +228,7 @@ final class StringConcatHelper {
* @param indexCoder final char index in the buffer, along with coder packed
* into higher bits.
* @param buf buffer to append to
- * @param value boolean value to encode
+ * @param value char value to encode
* @param prefix a constant to prepend before value
* @return updated index (coder value retained)
*/
@@ -263,7 +263,7 @@ final class StringConcatHelper {
* @param indexCoder final char index in the buffer, along with coder packed
* into higher bits.
* @param buf buffer to append to
- * @param value boolean value to encode
+ * @param value int value to encode
* @param prefix a constant to prepend before value
* @return updated index (coder value retained)
*/
@@ -298,7 +298,7 @@ final class StringConcatHelper {
* @param indexCoder final char index in the buffer, along with coder packed
* into higher bits.
* @param buf buffer to append to
- * @param value boolean value to encode
+ * @param value long value to encode
* @param prefix a constant to prepend before value
* @return updated index (coder value retained)
*/
@@ -335,7 +335,7 @@ final class StringConcatHelper {
* @param indexCoder final char index in the buffer, along with coder packed
* into higher bits.
* @param buf buffer to append to
- * @param value boolean value to encode
+ * @param value String value to encode
* @param prefix a constant to prepend before value
* @return updated index (coder value retained)
*/
--
2.33.0

View File

@ -0,0 +1,40 @@
Subject: Backport of 8337274: Remove repeated 'the'
---
.../share/classes/javax/swing/text/html/StyleSheet.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java b/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java
index fd3c75829..89e8b63d6 100644
--- a/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java
+++ b/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java
@@ -688,7 +688,7 @@ public class StyleSheet extends StyleContext {
* to return an AttributeSet that provides some sort of
* attribute conversion.
*
- * @param a The set of attributes to be represented in the
+ * @param a The set of attributes to be represented in
* the compact form.
*/
protected SmallAttributeSet createSmallAttributeSet(AttributeSet a) {
@@ -704,7 +704,7 @@ public class StyleSheet extends StyleContext {
* to return a MutableAttributeSet that provides some sort of
* attribute conversion.
*
- * @param a The set of attributes to be represented in the
+ * @param a The set of attributes to be represented in
* the larger form.
*/
protected MutableAttributeSet createLargeAttributeSet(AttributeSet a) {
@@ -2137,7 +2137,7 @@ public class StyleSheet extends StyleContext {
/**
* Returns a string that represents the value
* of the HTML.Attribute.TYPE attribute.
- * If this attributes is not defined, then
+ * If this attributes is not defined,
* then the type defaults to "disc" unless
* the tag is on Ordered list. In the case
* of the latter, the default type is "decimal".
--
2.33.0

View File

@ -0,0 +1,29 @@
Subject: Backport of 8337712: Wrong javadoc in java.util.Date#toString(): 61 and right parenthesis
---
src/java.base/share/classes/java/util/Date.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/java.base/share/classes/java/util/Date.java b/src/java.base/share/classes/java/util/Date.java
index 1850564d8..aa16f2a75 100644
--- a/src/java.base/share/classes/java/util/Date.java
+++ b/src/java.base/share/classes/java/util/Date.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2024, 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
@@ -1012,7 +1012,7 @@ public class Date
* <li>{@code mm} is the minute within the hour ({@code 00} through
* {@code 59}), as two decimal digits.
* <li>{@code ss} is the second within the minute ({@code 00} through
- * {@code 61}, as two decimal digits.
+ * {@code 61}), as two decimal digits.
* <li>{@code zzz} is the time zone (and may reflect daylight saving
* time). Standard time zone abbreviations include those
* recognized by the method {@code parse}. If time zone
--
2.33.0

View File

@ -0,0 +1,33 @@
Subject: Backport of 8337787: Fix -Wzero-as-null-pointer-constant warnings when JVMTI feature is disabled
---
src/hotspot/share/prims/jvmtiExport.hpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/hotspot/share/prims/jvmtiExport.hpp b/src/hotspot/share/prims/jvmtiExport.hpp
index 805c8c090..d8e20086b 100644
--- a/src/hotspot/share/prims/jvmtiExport.hpp
+++ b/src/hotspot/share/prims/jvmtiExport.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2024, 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
@@ -279,10 +279,10 @@ class JvmtiExport : public AllStatic {
}
// field access management
- static address get_field_access_count_addr() NOT_JVMTI_RETURN_(0);
+ static address get_field_access_count_addr() NOT_JVMTI_RETURN_(nullptr);
// field modification management
- static address get_field_modification_count_addr() NOT_JVMTI_RETURN_(0);
+ static address get_field_modification_count_addr() NOT_JVMTI_RETURN_(nullptr);
// -----------------
--
2.33.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
Subject: backport of 8339298: Remove unused function declaration poll_for_safepoint
---
src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp | 2 --
src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp | 2 --
2 files changed, 4 deletions(-)
diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp
index 43ec18925..fcb6d2943 100644
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp
@@ -60,8 +60,6 @@ friend class ArrayCopyStub;
void casw(Register addr, Register newval, Register cmpval);
void casl(Register addr, Register newval, Register cmpval);
- void poll_for_safepoint(relocInfo::relocType rtype, CodeEmitInfo* info = nullptr);
-
static const int max_tableswitches = 20;
struct tableswitch switches[max_tableswitches];
int tableswitch_count;
diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp
index 04e76796c..a74bf1611 100644
--- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp
+++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp
@@ -62,8 +62,6 @@ private:
void caswu(Register addr, Register newval, Register cmpval);
void casl(Register addr, Register newval, Register cmpval);
- void poll_for_safepoint(relocInfo::relocType rtype, CodeEmitInfo* info = nullptr);
-
void deoptimize_trap(CodeEmitInfo *info);
enum {
--
2.33.0

View File

@ -21,6 +21,8 @@
%bcond_without slowdebug %bcond_without slowdebug
# Enable release builds by default on relevant arches. # Enable release builds by default on relevant arches.
%bcond_without release %bcond_without release
# Disable global LTO
%define _lto_cflags %{nil}
# The -g flag says to use strip -g instead of full strip on DSOs or EXEs. # The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
# This fixes detailed NMT and other tools which need minimal debug info. # This fixes detailed NMT and other tools which need minimal debug info.
@ -158,7 +160,7 @@
# Used via new version scheme. JDK 19 was # Used via new version scheme. JDK 19 was
# GA'ed in March 2022 => 22.3 # GA'ed in March 2022 => 22.3
%global vendor_version_string BiSheng %global vendor_version_string BiSheng
%global securityver 4 %global securityver 6
# buildjdkver is usually same as %%{majorver}, # buildjdkver is usually same as %%{majorver},
# but in time of bootstrap of next jdk, it is majorver-1, # but in time of bootstrap of next jdk, it is majorver-1,
# and this it is better to change it here, on single place # and this it is better to change it here, on single place
@ -897,7 +899,7 @@ Name: java-21-%{origin}
Version: %{newjavaver}.%{buildver} Version: %{newjavaver}.%{buildver}
# This package needs `.rolling` as part of Release so as to not conflict on install with # This package needs `.rolling` as part of Release so as to not conflict on install with
# java-X-openjdk. I.e. when latest rolling release is also an LTS release packaged as # java-X-openjdk. I.e. when latest rolling release is also an LTS release packaged as
Release: 0 Release: 1
# java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons
# and this change was brought into RHEL-4. java-1.5.0-ibm packages # and this change was brought into RHEL-4. java-1.5.0-ibm packages
@ -926,15 +928,13 @@ Summary: %{origin_nice} Runtime Environment %{majorver}
# The test code includes copies of NSS under the Mozilla Public License v2.0 # The test code includes copies of NSS under the Mozilla Public License v2.0
# The PCSClite headers are under a BSD with advertising license # The PCSClite headers are under a BSD with advertising license
# The elliptic curve cryptography (ECC) source code is licensed under the LGPLv2.1 or any later version # The elliptic curve cryptography (ECC) source code is licensed under the LGPLv2.1 or any later version
License: ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib and ISC and FTL and RSA License: ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib and ISC and FTL and RSA-MD
URL: http://openjdk.java.net/ URL: http://openjdk.java.net/
# to regenerate source0 (jdk) and source8 (jdk's taspets) run update_package.sh # to regenerate source0 (jdk) and source8 (jdk's taspets) run update_package.sh
# update_package.sh contains hard-coded repos, revisions, tags, and projects to regenerate the source archives # update_package.sh contains hard-coded repos, revisions, tags, and projects to regenerate the source archives
Source0: jdk-updates-jdk%{majorver}u-jdk-%{filever}+%{buildver}.tar.gz Source0: jdk-updates-jdk%{majorver}u-jdk-%{filever}+%{buildver}.tar.gz
Source1: OpenJDK20U-jdk_aarch64_linux_hotspot_20.0.2_9.tar.xz
Source2: OpenJDK20U-jdk_x64_linux_hotspot_20.0.2_9.tar.xz
Source8: systemtap_3.2_tapsets_hg-icedtea8-9d464368e06d.tar.xz Source8: systemtap_3.2_tapsets_hg-icedtea8-9d464368e06d.tar.xz
# Desktop files. Adapted from IcedTea # Desktop files. Adapted from IcedTea
@ -958,10 +958,6 @@ Source14: TestECDSA.java
# #
############################################ ############################################
# NSS via SunPKCS11 Provider (disabled comment
# due to memory leak).
Patch1000: rh1648249-add_commented_out_nss_cfg_provider_to_java_security.patch
# Ignore AWTError when assistive technologies are loaded # Ignore AWTError when assistive technologies are loaded
Patch1: rh1648242-accessible_toolkit_crash_do_not_break_jvm.patch Patch1: rh1648242-accessible_toolkit_crash_do_not_break_jvm.patch
# Restrict access to java-atk-wrapper classes # Restrict access to java-atk-wrapper classes
@ -979,6 +975,51 @@ Patch7: add-downgrade-the-glibc-symver-of-log2f-posix_spawn.patch
Patch8: add-downgrade-the-glibc-symver-of-memcpy.patch Patch8: add-downgrade-the-glibc-symver-of-memcpy.patch
Patch9: add-downgrade-the-glibc-symbol-of-fcntl.patch Patch9: add-downgrade-the-glibc-symbol-of-fcntl.patch
# 21.0.4
Patch10: Backport-JDK-8336855-Duplicate-protected-declaration.patch
Patch11: Backport-JDK-8334758-Incorrect-note-in-Javadoc-for-a.patch
Patch12: Backport-JDK-8323699-MessageFormat.toPattern-generat.patch
Patch16: Backport-JDK-8333805-Replaying-compilation-with-null.patch
Patch19: 8339351-Remove-duplicate-line-in-FileMapHeader-print.patch
Patch21: 8339149-jfr_flush_event_writer-return-value-type-mis.patch
Patch22: 8300800-UB-Shift-exponent-32-is-too-large-for-32-bit.patch
Patch23: 8334780-Crash-assert-h_array_list.not_null-failed-in.patch
Patch24: 8337982-Remove-dead-undef-assrt0n.patch
Patch26: 8335610-DiagnosticFramework-CmdLine-is_executable-co.patch
Patch27: Backport-of-8337245-Fix-wrong-comment-of-StringConca.patch
Patch28: Backport-of-8337274-Remove-repeated-the.patch
Patch29: backport-of-8339298-Remove-unused-function-declarati.patch
Patch32: BackPort-JDK-8336346-Fix--Wzero-as-null-pointer-cons.patch
Patch37: Backport-JDK-8336080-Fix--Wzero-as-null-pointer-cons.patch
Patch38: Backport-JDK-8336152-Remove-unused-forward-declarati.patch
Patch39: Backport-of-8330191-Fix-typo-in-precompiled.hpp.patch
Patch40: Backport-of-8337787-Fix-Wzero-as-null-pointer-consta.patch
Patch41: Backport-of-8337712-Wrong-javadoc-in-java.util.Date-.patch
Patch49: Backport-JDK-8328107-Shenandoah-C2-TestVerifyLoopOpt.patch
Patch50: Backport-JDK-8328553-Get-rid-of-JApplet-in-test-jdk-.patch
Patch51: Backport-JDK-8329754-The-ThreadSafe-attribute-is-ign.patch
Patch53: Backport-JDK-8335638-Calling-VarHandle.-access-mode-.patch
Patch54: Backport-JDK-8338938-The-result-of-the-combine-metho.patch
Patch55: Backport-JDK-8313909-JVMCI-assert-cp-tag_at-index-.i.patch
Patch56: Backport-JDK-8304484-CDS-dynamic-dumping-incorrectly.patch
Patch57: Backport-JDK-8322812-Manpage-for-jcmd-is-missing-JFR.patch
Patch58: Backport-JDK-8327538-The-SSLExtension-class-specifie.patch
Patch60: Backport-JDK-8333599-Improve-description-of-b-matche.patch
Patch62: Backport-JDK-8336012-Fix-usages-of-jtreg-reserved-pr.patch
Patch63: Backport-JDK-8336879-Always-true-condition-img-null-.patch
Patch64: Backport-JDK-8337334-Test-tools-javac-7142086-T71420.patch
Patch65: Backport-JDK-8340623-Remove-outdated-PROCESSOR_ARCHI.patch
Patch66: Backport-JDK-8338010-WB_IsFrameDeoptimized-miss-Reso.patch
Patch67: Backport-JDK-8340186-Shenandoah-Missing-load_referen.patch
Patch68: Backport-JDK-8340273-Remove-CounterHalfLifeTime.patch
Patch69: Backport-JDK-8339460-CDS-error-when-module-is-locate.patch
Patch70: Backport-JDK-8332297-annotation-processor-that-gener.patch
Patch71: Backport-JDK-8329174-update-CodeBuffer-layout-in-com.patch
Patch72: Backport-JDK-8325994-JFR-Examples-in-JFR.start-help-.patch
Patch73: Backport-JDK-8325730-StringBuilder.toString-allocati.patch
Patch74: Backport-JDK-8337679-Memset-warning-in-src-hotspot-s.patch
Patch75: Backport-JDK-8326957-Implement-JEP-474-ZGC-Generatio.patch
Patch76: Backport-JDK-8320308-C2-compilation-crashes-in-Libra.patch
############################################ ############################################
# #
# LoongArch64 specific patches # LoongArch64 specific patches
@ -1207,7 +1248,7 @@ fi
# OpenJDK patches # OpenJDK patches
# Remove libraries that are linked # Remove libraries that are linked
sh %{SOURCE12} # sh %{SOURCE12}
%ifnarch loongarch64 %ifnarch loongarch64
pushd %{top_level_dir_name} pushd %{top_level_dir_name}
%patch1 -p1 %patch1 -p1
@ -1215,6 +1256,50 @@ pushd %{top_level_dir_name}
%patch7 -p1 %patch7 -p1
%patch8 -p1 %patch8 -p1
%patch9 -p1 %patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch16 -p1
%patch19 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch32 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%patch60 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch72 -p1
%patch73 -p1
%patch74 -p1
%patch75 -p1
%patch76 -p1
popd # openjdk popd # openjdk
%endif %endif
@ -1224,8 +1309,6 @@ pushd %{top_level_dir_name}
popd popd
%endif %endif
%patch1000
# Extract systemtap tapsets # Extract systemtap tapsets
%if %{with_systemtap} %if %{with_systemtap}
tar --strip-components=1 -x -I xz -f %{SOURCE8} tar --strip-components=1 -x -I xz -f %{SOURCE8}
@ -1330,22 +1413,6 @@ fi
ARCH=$(uname -m) ARCH=$(uname -m)
BOOTJDKPATH=/usr/lib/jvm/java-%{buildjdkver}-openjdk BOOTJDKPATH=/usr/lib/jvm/java-%{buildjdkver}-openjdk
if [ "$ARCH" = "x86_64" ]; then
tar -xf %{SOURCE2}
BOOTJDKPATH=$PWD/jdk-20.0.2+9
elif [ "$ARCH" = "aarch64" ]; then
tar -xf %{SOURCE1}
BOOTJDKPATH=$PWD/jdk-20.0.2+9
elif [ "$ARCH" = "riscv64" ]; then
:
elif [ "$ARCH" = "loongarch64" ]; then
:
elif [ "$ARCH" = "ppc64le" ]; then
:
else
echo " Failed to set BOOTJDKPATH "
exit 18
fi
echo $BOOTJDKPATH echo $BOOTJDKPATH
@ -1363,7 +1430,7 @@ bash ../configure \
--with-toolchain-type=clang \ --with-toolchain-type=clang \
%endif %endif
--with-version-build=%{buildver} \ --with-version-build=%{buildver} \
--with-version-pre=\"${EA_DESIGNATOR}\" \ --with-version-pre="${EA_DESIGNATOR}" \
--with-version-opt=%{lts_designator} \ --with-version-opt=%{lts_designator} \
--with-vendor-version-string="%{vendor_version_string}" \ --with-vendor-version-string="%{vendor_version_string}" \
--with-vendor-name="BiSheng" \ --with-vendor-name="BiSheng" \
@ -1665,9 +1732,10 @@ else
end end
end end
-- run content of included file with fake args -- run content of included file with fake args
arg = nil; -- it is better to null the arg up, no meter if they exists or not, and use cjc as module in unified way, instead of relaying on "main" method during require "copy_jdk_configs.lua"
cjc = require "copy_jdk_configs.lua" cjc = require "copy_jdk_configs.lua"
arg = {"--currentjvm", "%{uniquesuffix %{nil}}", "--jvmdir", "%{_jvmdir %{nil}}", "--origname", "%{name}", "--origjavaver", "%{javaver}", "--arch", "%{_arch}", "--temp", "%{rpm_state_dir}/%{name}.%{_arch}"} args = {"--currentjvm", "%{uniquesuffix %{nil}}", "--jvmdir", "%{_jvmdir %{nil}}", "--origname", "%{name}", "--origjavaver", "%{javaver}", "--arch", "%{_arch}", "--temp", "%{rpm_state_dir}/%{name}.%{_arch}"}
cjc.mainProgram(arg) cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect this 'main', so it should run under all circumstances, except fatal error
%post %post
%{post_script %{nil}} %{post_script %{nil}}
@ -1792,6 +1860,134 @@ cjc.mainProgram(arg)
%changelog %changelog
* Tue Feb 11 2025 Pan Xuefeng <panxuefeng@loongson.cn> - 1:21.0.6.7-1
- update LoongArch64 port to 21.0.6
* Thu Jan 23 2025 Benshuai5D <zhangyunbo7@huawei.com> - 1:21.0.6.7-0
- update to jdk21.0.6-ga
- delete Backport-JDK-8207908-JMXStatusTest.java-fails-assert.patch
- delete Backport-JDK-8320682-[AArch64]-C1-compilation-fails-.patch
- delete Backport-JDK-8331391-Enhance-the-keytool-code-by-inv.patch
- delete Backport-JDK-8332866-Crash-in-ImageIO-JPEG-decoding-.patch
- delete Backport-of-8337067-Test-runtime-classFileParserBug-.patch
- delete Backport-of-JDK-8316895-SeenThread-print_action_que.patch
- delete Backport-of-JDK-8328723-IP-Address-error-when-client.patch
- modify Backport-JDK-8329174-update-CodeBuffer-layout-in-com.patch
- modify Backport-JDK-8340623-Remove-outdated-PROCESSOR_ARCHI.patch
* Wed Dec 25 2024 Dingli Zhang <dingli@iscas.ac.cn> - 1:21.0.5.11-4
- Remove double colons from patch names
- Fix typo in chagelog
* Thu Dec 5 2024 kuenking111 <wangkun49@huawei.com> - 1:21.0.5.11-3
- disable LTO
* Mon Nov 11 2024 Dingli Zhang <dingli@iscas.ac.cn> - 1:21.0.5.11-2
- Remove redundant patch to fix ci check
* Wed Nov 6 2024 Pan Xuefeng <panxuefeng@loongson.cn> - 1:21.0.5.11-1
- update LoongArch64 port to 21.0.5
* Wed Oct 16 2024 huangjie <huangjie150@huawei.com> - 1:21.0.5.11-0
- update to jdk21.0.5-ga
- delete Backport-JDK-8333462-Performance-regression-of-new-D.patch
- delete Backport-JDK-8332818-ubsan-archiveHeapLoader.cpp:70:.patch
- detete Backport-JDK-8333887-ubsan-unsafe.cpp:247:13:-runtim.patch
- detete BackPort-JDK-8324580-SIGFPE-on-THP-initialization-on.patch
- delete Backport-JDK-8334239-Introduce-macro-for-ubsan-metho.patch
- delete Backport-of-8333088-ubsan-shenandoahAdaptiveHeuristi.patch
- detete Backport-JDK-8332524-Instead-of-printing-TLSv1.3,-.patch
- delete Backport-JDK-8333149-ubsan-memset-on-nullptr-target-.patch
- detete Backport-JDK-8333622-ubsan-relocInfo_x86.cpp:101:56:.patch
- detete Backport-JDK-8333354-ubsan-frame.inline.hpp:91:25:-a.patch
- delete Backport-JDK-8333639-ubsan-cppVtables.cpp:81:55-runt.patch
- delete Backport-of-JDK-8336343-Add-more-known-sysroot-libra.patch
- delete Backport-of-JDK-8332720-ubsan-instanceKlass.cpp:3550.patch
- delete Backport-JDK-8332920-C2-Partial-Peeling-is-wrongly-a.patch
- delete Backport-JDK-8334123-log-the-opening-of-Type-1-fonts.patch
- delete Backport-JDK-8325022-Incorrect-error-message-on-clie.patch
* Sat Oct 12 2024 Autistic_boyya <wangzhongyi7@huawei.com> - 1:21.0.4.7-5
- add 8300800-UB-Shift-exponent-32-is-too-large-for-32-bit.patch
- add 8334780-Crash-assert-h_array_list.not_null-failed-in.patch
- add 8335610-DiagnosticFramework-CmdLine-is_executable-co.patch
- add 8337982-Remove-dead-undef-assrt0n.patch
- add 8339149-jfr_flush_event_writer-return-value-type-mis.patch
- add 8339351-Remove-duplicate-line-in-FileMapHeader-print.patch
- add BackPort-JDK-8324580-SIGFPE-on-THP-initialization-on.patch
- add BackPort-JDK-8336346-Fix--Wzero-as-null-pointer-cons.patch
- add Backport-JDK-8207908-JMXStatusTest.java-fails-assert.patch
- add Backport-JDK-8304484-CDS-dynamic-dumping-incorrectly.patch
- add Backport-JDK-8313909-JVMCI-assert-cp-tag_at-index-.i.patch
- add Backport-JDK-8320308-C2-compilation-crashes-in-Libra.patch
- add Backport-JDK-8320682-[AArch64]-C1-compilation-fails-.patch
- add Backport-JDK-8322812-Manpage-for-jcmd-is-missing-JFR.patch
- add Backport-JDK-8323699-MessageFormat.toPattern-generat.patch
- add Backport-JDK-8325022-Incorrect-error-message-on-clie.patch
- add Backport-JDK-8325730-StringBuilder.toString-allocati.patch
- add Backport-JDK-8325994-JFR-Examples-in-JFR.start-help-.patch
- add Backport-JDK-8326957-Implement-JEP-474-ZGC-Generatio.patch
- add Backport-JDK-8327538-The-SSLExtension-class-specifie.patch
- add Backport-JDK-8328107-Shenandoah-C2-TestVerifyLoopOpt.patch
- add Backport-JDK-8328553-Get-rid-of-JApplet-in-test-jdk-.patch
- add Backport-JDK-8329174-update-CodeBuffer-layout-in-com.patch
- add Backport-JDK-8329754-The-ThreadSafe-attribute-is-ign.patch
- add Backport-JDK-8331391-Enhance-the-keytool-code-by-inv.patch
- add Backport-JDK-8332297-annotation-processor-that-gener.patch
- add Backport-JDK-8332524-Instead-of-printing-TLSv1.3,-.patch
- add Backport-JDK-8332818-ubsan-archiveHeapLoader.cpp:70:.patch
- add Backport-JDK-8332866-Crash-in-ImageIO-JPEG-decoding-.patch
- add Backport-JDK-8332920-C2-Partial-Peeling-is-wrongly-a.patch
- add Backport-JDK-8333149-ubsan-memset-on-nullptr-target-.patch
- add Backport-JDK-8333354-ubsan-frame.inline.hpp:91:25:-a.patch
- add Backport-JDK-8333462-Performance-regression-of-new-D.patch
- add Backport-JDK-8333599-Improve-description-of-b-matche.patch
- add Backport-JDK-8333622-ubsan-relocInfo_x86.cpp:101:56:.patch
- add Backport-JDK-8333639-ubsan-cppVtables.cpp:81:55-runt.patch
- add Backport-JDK-8333805-Replaying-compilation-with-null.patch
- add Backport-JDK-8333887-ubsan-unsafe.cpp:247:13:-runtim.patch
- add Backport-JDK-8334123-log-the-opening-of-Type-1-fonts.patch
- add Backport-JDK-8334239-Introduce-macro-for-ubsan-metho.patch
- add Backport-JDK-8334758-Incorrect-note-in-Javadoc-for-a.patch
- add Backport-JDK-8335638-Calling-VarHandle.-access-mode-.patch
- add Backport-JDK-8336012-Fix-usages-of-jtreg-reserved-pr.patch
- add Backport-JDK-8336080-Fix--Wzero-as-null-pointer-cons.patch
- add Backport-JDK-8336152-Remove-unused-forward-declarati.patch
- add Backport-JDK-8336855-Duplicate-protected-declaration.patch
- add Backport-JDK-8336879-Always-true-condition-img-null-.patch
- add Backport-JDK-8337334-Test-tools-javac-7142086-T71420.patch
- add Backport-JDK-8337679-Memset-warning-in-src-hotspot-s.patch
- add Backport-JDK-8338010-WB_IsFrameDeoptimized-miss-Reso.patch
- add Backport-JDK-8338938-The-result-of-the-combine-metho.patch
- add Backport-JDK-8339460-CDS-error-when-module-is-locate.patch
- add Backport-JDK-8340186-Shenandoah-Missing-load_referen.patch
- add Backport-JDK-8340273-Remove-CounterHalfLifeTime.patch
- add Backport-JDK-8340623-Remove-outdated-PROCESSOR_ARCHI.patch
- add Backport-of-8330191-Fix-typo-in-precompiled.hpp.patch
- add Backport-of-8333088-ubsan-shenandoahAdaptiveHeuristi.patch
- add Backport-of-8337067-Test-runtime-classFileParserBug-.patch
- add Backport-of-8337245-Fix-wrong-comment-of-StringConca.patch
- add Backport-of-8337274-Remove-repeated-the.patch
- add Backport-of-8337712-Wrong-javadoc-in-java.util.Date-.patch
- add Backport-of-8337787-Fix-Wzero-as-null-pointer-consta.patch
- add Backport-of-JDK-8316895-SeenThread::print_action_que.patch
- add Backport-of-JDK-8328723-IP-Address-error-when-client.patch
- add Backport-of-JDK-8332720-ubsan-instanceKlass.cpp:3550.patch
- add Backport-of-JDK-8336343-Add-more-known-sysroot-libra.patch
- add backport-of-8339298-Remove-unused-function-declarati.patch
* Wed Aug 14 2024 songliyang <songliyang@kylinos.cn> - 1:21.0.4.7-4
- delete redundant symbols while viewing spec file with vim that make it strange on highlight
* Wed Aug 7 2024 Autistic_boyya <wangzhongyi7@huawei.com> - 1:21.0.4.7-3
- delete rh1648249-add_commented_out_nss_cfg_provider_to_java_security.patch
* Mon Jul 29 2024 zhaosaisai <zhaosaisai@kylinos.cn> - 1:21.0.4.7-2
- change boot jdk to itself
* Thu Aug 1 2024 aoqi <aoqi@loongson.cn> - 1:21.0.4.7-1
- update LoongArch64 port to 21.0.4
* Thu Jul 18 2024 Autistic_boyya <wangzhongyi7@huawei.com> -1:21.0.4.7-rolling * Thu Jul 18 2024 Autistic_boyya <wangzhongyi7@huawei.com> -1:21.0.4.7-rolling
- update to jdk21.0.4-ga - update to jdk21.0.4-ga

View File

@ -1,87 +0,0 @@
# HG changeset patch
# User andrew
# Date 1478057514 0
# Node ID 1c4d5cb2096ae55106111da200b0bcad304f650c
# Parent 3d53f19b48384e5252f4ec8891f7a3a82d77af2a
diff -r 3d53f19b4838 -r 1c4d5cb2096a src/java.base/share/classes/java/security/Security.java
--- a/src/java.base/share/classes/java/security/Security.java Wed Oct 26 03:51:39 2016 +0100
+++ b/src/java.base/share/classes/java/security/Security.java Wed Nov 02 03:31:54 2016 +0000
@@ -43,6 +43,9 @@
* implementation-specific location, which is typically the properties file
* {@code conf/security/java.security} in the Java installation directory.
*
+ * <p>Additional default values of security properties are read from a
+ * system-specific location, if available.</p>
+ *
* @author Benjamin Renaud
* @since 1.1
*/
@@ -52,6 +55,10 @@
private static final Debug sdebug =
Debug.getInstance("properties");
+ /* System property file*/
+ private static final String SYSTEM_PROPERTIES =
+ "/etc/crypto-policies/back-ends/java.config";
+
/* The java.security properties */
private static Properties props;
@@ -93,6 +100,7 @@
if (sdebug != null) {
sdebug.println("reading security properties file: " +
propFile);
+ sdebug.println(props.toString());
}
} catch (IOException e) {
if (sdebug != null) {
@@ -114,6 +122,31 @@
}
if ("true".equalsIgnoreCase(props.getProperty
+ ("security.useSystemPropertiesFile"))) {
+
+ // now load the system file, if it exists, so its values
+ // will win if they conflict with the earlier values
+ try (BufferedInputStream bis =
+ new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
+ props.load(bis);
+ loadedProps = true;
+
+ if (sdebug != null) {
+ sdebug.println("reading system security properties file " +
+ SYSTEM_PROPERTIES);
+ sdebug.println(props.toString());
+ }
+ } catch (IOException e) {
+ if (sdebug != null) {
+ sdebug.println
+ ("unable to load security properties from " +
+ SYSTEM_PROPERTIES);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if ("true".equalsIgnoreCase(props.getProperty
("security.overridePropertiesFile"))) {
String extraPropFile = System.getProperty
diff -r 3d53f19b4838 -r 1c4d5cb2096a src/java.base/share/conf/security/java.security
--- a/src/java.base/share/conf/security/java.security Wed Oct 26 03:51:39 2016 +0100
+++ b/src/java.base/share/conf/security/java.security Wed Nov 02 03:31:54 2016 +0000
@@ -276,6 +276,13 @@
security.overridePropertiesFile=true
#
+# Determines whether this properties file will be appended to
+# using the system properties file stored at
+# /etc/crypto-policies/back-ends/java.config
+#
+security.useSystemPropertiesFile=true
+
+#
# Determines the default key and trust manager factory algorithms for
# the javax.net.ssl package.
#

View File

@ -1,12 +0,0 @@
diff -r e3f940bd3c8f src/java.base/share/conf/security/java.security
--- openjdk/src/java.base/share/conf/security/java.security Thu Jun 11 21:54:51 2020 +0530
+++ openjdk/src/java.base/share/conf/security/java.security Mon Aug 24 10:14:31 2020 +0200
@@ -77,7 +77,7 @@
#ifdef macosx
security.provider.tbd=Apple
#endif
-security.provider.tbd=SunPKCS11
+#security.provider.tbd=SunPKCS11 ${java.home}/lib/security/nss.cfg
#
# A list of preferred providers for specific algorithms. These providers will