From 367c3041272d43b0474b433c555f22a3e15579f6 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Fri, 13 Dec 2024 08:34:10 +0000 Subject: [PATCH 01/12] 8346059: [ASAN] awt_LoadLibrary.c reported compile warning ignoring return value of function by clang17 Reviewed-by: ihse --- src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c index f24a4eb9a2c..d6ff51f8018 100644 --- a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c +++ b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c @@ -137,7 +137,9 @@ AWT_OnLoad(JavaVM *vm, void *reserved) } else { /* Get address of this library and the directory containing it. */ dladdr((void *)AWT_OnLoad, &dlinfo); - realpath((char *)dlinfo.dli_fname, buf); + if (realpath((char *)dlinfo.dli_fname, buf) == NULL) { + perror((char *)dlinfo.dli_fname); + } len = strlen(buf); p = strrchr(buf, '/'); From a9a5f7cb0a75b82d613ecd9018e13e5337e90363 Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Fri, 13 Dec 2024 11:43:32 +0000 Subject: [PATCH 02/12] 8345323: Parallel GC does not handle UseLargePages and UseNUMA gracefully Reviewed-by: sjohanss, tschatzl --- src/hotspot/share/gc/shared/genArguments.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shared/genArguments.cpp b/src/hotspot/share/gc/shared/genArguments.cpp index 76f9f6d4052..c94ca56722f 100644 --- a/src/hotspot/share/gc/shared/genArguments.cpp +++ b/src/hotspot/share/gc/shared/genArguments.cpp @@ -37,7 +37,11 @@ size_t MinNewSize = 0; size_t MinOldSize = 0; size_t MaxOldSize = 0; -size_t OldSize = 0; +// If InitialHeapSize or MinHeapSize is not set on cmdline, this variable, +// together with NewSize, is used to derive them. +// Using the same value when it was a configurable flag to avoid breakage. +// See more in JDK-8346005 +size_t OldSize = ScaleForWordSize(4*M); size_t GenAlignment = 0; From 1d2ccaeaa316029772b5de3dc5579ee7b1363b60 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 13 Dec 2024 12:14:07 +0000 Subject: [PATCH 03/12] 8345569: [ubsan] adjustments to filemap.cpp and virtualspace.cpp for macOS aarch64 Reviewed-by: mdoerr, lucy, dholmes --- src/hotspot/share/cds/filemap.cpp | 4 ++-- src/hotspot/share/memory/virtualspace.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 594d8817322..06298949e0a 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -2219,7 +2219,7 @@ address FileMapInfo::heap_region_dumptime_address() { assert(CDSConfig::is_using_archive(), "runtime only"); assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be"); if (UseCompressedOops) { - return /*dumptime*/ narrow_oop_base() + r->mapping_offset(); + return /*dumptime*/ (address)((uintptr_t)narrow_oop_base() + r->mapping_offset()); } else { return heap_region_requested_address(); } @@ -2245,7 +2245,7 @@ address FileMapInfo::heap_region_requested_address() { // Runtime base = 0x4000 and shift is also 0. If we map this region at 0x5000, then // the value P can remain 0x1200. The decoded address = (0x4000 + (0x1200 << 0)) = 0x5200, // which is the runtime location of the referenced object. - return /*runtime*/ CompressedOops::base() + r->mapping_offset(); + return /*runtime*/ (address)((uintptr_t)CompressedOops::base() + r->mapping_offset()); } else { // This was the hard-coded requested base address used at dump time. With uncompressed oops, // the heap range is assigned by the OS so we will most likely have to relocate anyway, no matter diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index 0e4e4a4660d..69b39fcbdeb 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -443,7 +443,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start, while (attach_point >= lowest_start && attach_point <= highest_start && // Avoid wrap around. ((_base == nullptr) || - (_base < aligned_heap_base_min_address || _base + size > upper_bound))) { + (_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) { try_reserve_heap(size, alignment, page_size, attach_point); attach_point -= stepsize; } From 266e3d0decc09b9c17c455e2c754cd39114fa31a Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 13 Dec 2024 12:18:49 +0000 Subject: [PATCH 04/12] 8345590: AIX 'make all' fails after JDK-8339480 Reviewed-by: clanger, jkern, mdoerr, lucy --- make/Main.gmk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/make/Main.gmk b/make/Main.gmk index ddcc0c7f674..7675fe6fcf7 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -1310,7 +1310,10 @@ endif ################################################################################ # all-images builds all our deliverables as images. -all-images: product-images static-jdk-image test-image all-docs-images +all-images: product-images test-image all-docs-images +ifeq ($(call isTargetOs, linux macosx windows), true) + all-images: static-jdk-image +endif # all-bundles packages all our deliverables as tar.gz bundles. all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles From 2ce53e88481659734bc5424c643c5e31c116bc5d Mon Sep 17 00:00:00 2001 From: William Kemper Date: Fri, 13 Dec 2024 17:41:26 +0000 Subject: [PATCH 05/12] 8345970: pthread_getcpuclockid related crashes in shenandoah tests Reviewed-by: ysr --- .../share/gc/shenandoah/shenandoahGenerationalHeap.cpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp | 6 +++++- src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp | 6 +++++- src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.hpp | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp index 5b8afc52b93..2ad35fcb288 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp @@ -180,8 +180,8 @@ void ShenandoahGenerationalHeap::gc_threads_do(ThreadClosure* tcl) const { } void ShenandoahGenerationalHeap::stop() { - regulator_thread()->stop(); ShenandoahHeap::stop(); + regulator_thread()->stop(); } void ShenandoahGenerationalHeap::evacuate_collection_set(bool concurrent) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index c1bc9dc6616..cdcc5dbd267 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -545,7 +545,6 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) : _pacer(nullptr), _verifier(nullptr), _phase_timings(nullptr), - _mmu_tracker(), _monitoring_support(nullptr), _memory_pool(nullptr), _stw_memory_manager("Shenandoah Pauses"), @@ -639,6 +638,8 @@ class ShenandoahInitWorkerGCLABClosure : public ThreadClosure { void ShenandoahHeap::post_initialize() { CollectedHeap::post_initialize(); + + // Schedule periodic task to report on gc thread CPU utilization _mmu_tracker.initialize(); MutexLocker ml(Threads_lock); @@ -2050,6 +2051,9 @@ void ShenandoahHeap::stop() { // Step 0. Notify policy to disable event recording and prevent visiting gc threads during shutdown _shenandoah_policy->record_shutdown(); + // Step 0a. Stop reporting on gc thread cpu utilization + mmu_tracker()->stop(); + // Step 1. Notify control thread that we are in shutdown. // Note that we cannot do that with stop(), because stop() is blocking and waits for the actual shutdown. // Doing stop() here would wait for the normal GC cycle to complete, never falling through to cancel below. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp index f4cbdbdd493..d9cec36e6c9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp @@ -48,6 +48,7 @@ class ThreadTimeAccumulator : public ThreadClosure { size_t total_time; ThreadTimeAccumulator() : total_time(0) {} void do_thread(Thread* thread) override { + assert(!thread->has_terminated(), "Cannot get cpu time for terminated thread: " UINTX_FORMAT, thread->osthread()->thread_id_for_printing()); total_time += os::thread_cpu_time(thread); } }; @@ -65,7 +66,6 @@ ShenandoahMmuTracker::ShenandoahMmuTracker() : } ShenandoahMmuTracker::~ShenandoahMmuTracker() { - _mmu_periodic_task->disenroll(); delete _mmu_periodic_task; } @@ -175,6 +175,10 @@ void ShenandoahMmuTracker::report() { log_debug(gc)("Periodic Sample: GCU = %.3f%%, MU = %.3f%% during most recent %.1fs", gcu * 100, mu * 100, time_delta); } +void ShenandoahMmuTracker::stop() const { + _mmu_periodic_task->disenroll(); +} + void ShenandoahMmuTracker::initialize() { // initialize static data _active_processors = os::initial_active_processor_count(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.hpp index 53b6fdada55..89dbf921cd4 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.hpp @@ -101,6 +101,10 @@ class ShenandoahMmuTracker { // GCPauseIntervalMillis and defaults to 5 seconds. This method computes // the MMU over the elapsed interval and records it in a running average. void report(); + + // Unenrolls the periodic task that collects CPU utilization for GC threads. This must happen _before_ the + // gc threads are stopped and terminated. + void stop() const; }; #endif //SHARE_GC_SHENANDOAH_SHENANDOAHMMUTRACKER_HPP From cfa04d31ddff49cbf5dfdfedd61264d5556a283c Mon Sep 17 00:00:00 2001 From: William Kemper Date: Fri, 13 Dec 2024 18:14:01 +0000 Subject: [PATCH 06/12] 8346051: MemoryTest fails when Shenandoah's generational mode is enabled Reviewed-by: lmesnik, ysr --- .../management/MemoryMXBean/MemoryTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java b/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java index 699be54ec89..72c4655b6d8 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java +++ b/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java @@ -46,17 +46,29 @@ */ /* - * @test + * @test id=Shenandoah * @bug 4530538 - * @summary Basic unit test of MemoryMXBean.getMemoryPools() and - * MemoryMXBean.getMemoryManager(). - * @requires vm.gc == "Shenandoah" + * @summary Shenandoah has a gc mgr bean for cycles and another + * for pauses, they both have one pool. + * @requires vm.gc == "Shenandoah" & vm.opt.ShenandoahGCMode != "generational" * @author Mandy Chung * * @modules jdk.management * @run main MemoryTest 2 1 */ +/* + * @test id=Genshen + * @bug 4530538 + * @summary Shenandoah's generational mode has a gc mgr bean for cycles + * and another for pauses. They both reference the young and old pools. + * @requires vm.gc == "Shenandoah" & vm.opt.ShenandoahGCMode == "generational" + * @author Mandy Chung + * + * @modules jdk.management + * @run main MemoryTest 2 2 + */ + /* * @test * @bug 4530538 From f647d4d908a6760c116a3a762c4dc09e3ed95796 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 13 Dec 2024 19:19:42 +0000 Subject: [PATCH 07/12] 8345936: Call ClassLoader.getResourceAsByteArray only for multi-release jar Reviewed-by: iklam, dholmes --- src/hotspot/share/cds/filemap.cpp | 5 +++-- src/hotspot/share/cds/filemap.hpp | 4 +++- src/hotspot/share/classfile/classLoader.cpp | 10 ++++++---- src/hotspot/share/classfile/classLoader.hpp | 10 ++++++++-- src/hotspot/share/classfile/classLoaderExt.cpp | 5 +++++ 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 06298949e0a..c87081d9d14 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -347,6 +347,7 @@ void SharedClassPathEntry::init(bool is_modules_image, _type = jar_entry; _timestamp = st.st_mtime; _from_class_path_attr = cpe->from_class_path_attr(); + _is_multi_release = cpe->is_multi_release_jar(); } _filesize = st.st_size; _is_module_path = is_module_path; @@ -2680,7 +2681,7 @@ ClassPathEntry* FileMapInfo::get_classpath_entry_for_jvmti(int i, TRAPS) { jio_snprintf(msg, strlen(path) + 127, "error in finding JAR file %s", path); THROW_MSG_(vmSymbols::java_io_IOException(), msg, nullptr); } else { - ent = ClassLoader::create_class_path_entry(THREAD, path, &st, false, false); + ent = ClassLoader::create_class_path_entry(THREAD, path, &st, false, false, scpe->is_multi_release()); if (ent == nullptr) { char *msg = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(path) + 128); jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path); @@ -2715,7 +2716,7 @@ ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle cl name->utf8_length()); ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); ClassFileStream* cfs; - if (class_loader() != nullptr && !cpe->is_modules_image()) { + if (class_loader() != nullptr && !cpe->is_modules_image() && cpe->is_multi_release_jar()) { cfs = get_stream_from_class_loader(class_loader, cpe, file_name, CHECK_NULL); } else { cfs = cpe->open_stream_for_loader(THREAD, file_name, loader_data); diff --git a/src/hotspot/share/cds/filemap.hpp b/src/hotspot/share/cds/filemap.hpp index cabb54769fe..6759b4a5020 100644 --- a/src/hotspot/share/cds/filemap.hpp +++ b/src/hotspot/share/cds/filemap.hpp @@ -64,6 +64,7 @@ class SharedClassPathEntry : public MetaspaceObj { u1 _type; bool _is_module_path; bool _from_class_path_attr; + bool _is_multi_release; time_t _timestamp; // jar timestamp, 0 if is directory, modules image or other int64_t _filesize; // jar/jimage file size, -1 if is directory, -2 if other Array* _name; @@ -71,7 +72,7 @@ class SharedClassPathEntry : public MetaspaceObj { public: SharedClassPathEntry() : _type(0), _is_module_path(false), - _from_class_path_attr(false), _timestamp(0), + _from_class_path_attr(false), _is_multi_release(false), _timestamp(0), _filesize(0), _name(nullptr), _manifest(nullptr) {} static int size() { static_assert(is_aligned(sizeof(SharedClassPathEntry), wordSize), "must be"); @@ -92,6 +93,7 @@ class SharedClassPathEntry : public MetaspaceObj { bool is_jar() const { return _type == jar_entry; } bool is_non_existent() const { return _type == non_existent_entry; } bool from_class_path_attr() { return _from_class_path_attr; } + bool is_multi_release() { return _is_multi_release; } time_t timestamp() const { return _timestamp; } const char* name() const; const char* manifest() const { diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index aac312c36a3..83d0e803ee1 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -303,10 +303,11 @@ ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char* } ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name, - bool is_boot_append, bool from_class_path_attr) : ClassPathEntry() { + bool is_boot_append, bool from_class_path_attr, bool multi_release) : ClassPathEntry() { _zip = zip; _zip_name = copy_path(zip_name); _from_class_path_attr = from_class_path_attr; + _multi_release = multi_release; } ClassPathZipEntry::~ClassPathZipEntry() { @@ -750,7 +751,8 @@ jzfile* ClassLoader::open_zip_file(const char* canonical_path, char** error_msg, ClassPathEntry* ClassLoader::create_class_path_entry(JavaThread* current, const char *path, const struct stat* st, bool is_boot_append, - bool from_class_path_attr) { + bool from_class_path_attr, + bool is_multi_release) { ClassPathEntry* new_entry = nullptr; if ((st->st_mode & S_IFMT) == S_IFREG) { ResourceMark rm(current); @@ -763,7 +765,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(JavaThread* current, char* error_msg = nullptr; jzfile* zip = open_zip_file(canonical_path, &error_msg, current); if (zip != nullptr && error_msg == nullptr) { - new_entry = new ClassPathZipEntry(zip, path, is_boot_append, from_class_path_attr); + new_entry = new ClassPathZipEntry(zip, path, is_boot_append, from_class_path_attr, is_multi_release); } else { #if INCLUDE_CDS ClassLoaderExt::set_has_non_jar_in_classpath(); @@ -796,7 +798,7 @@ ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bo jzfile* zip = open_zip_file(canonical_path, &error_msg, thread); if (zip != nullptr && error_msg == nullptr) { // create using canonical path - return new ClassPathZipEntry(zip, canonical_path, is_boot_append, false); + return new ClassPathZipEntry(zip, canonical_path, is_boot_append, false, false); } } } diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index d6780054904..8eb6593f07a 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -58,6 +58,8 @@ class ClassPathEntry : public CHeapObj { virtual bool is_modules_image() const { return false; } virtual bool is_jar_file() const { return false; } + virtual bool is_multi_release_jar() const { return false; } + virtual void set_multi_release_jar() {} // Is this entry created from the "Class-path" attribute from a JAR Manifest? virtual bool from_class_path_attr() const { return false; } virtual const char* name() const = 0; @@ -91,11 +93,14 @@ class ClassPathZipEntry: public ClassPathEntry { jzfile* _zip; // The zip archive const char* _zip_name; // Name of zip archive bool _from_class_path_attr; // From the "Class-path" attribute of a jar file + bool _multi_release; // multi-release jar public: bool is_jar_file() const { return true; } + bool is_multi_release_jar() const { return _multi_release; } + void set_multi_release_jar() { _multi_release = true; } bool from_class_path_attr() const { return _from_class_path_attr; } const char* name() const { return _zip_name; } - ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr); + ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr, bool multi_release); virtual ~ClassPathZipEntry(); u1* open_entry(JavaThread* current, const char* name, jint* filesize, bool nul_terminate); ClassFileStream* open_stream(JavaThread* current, const char* name); @@ -260,7 +265,8 @@ class ClassLoader: AllStatic { static ClassPathEntry* create_class_path_entry(JavaThread* current, const char *path, const struct stat* st, bool is_boot_append, - bool from_class_path_attr); + bool from_class_path_attr, + bool is_multi_release = false); // Canonicalizes path names, so strcmp will work properly. This is mainly // to avoid confusing the zip library diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index b9e420899c2..f7b2906394d 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -244,6 +244,10 @@ void ClassLoaderExt::process_jar_manifest(JavaThread* current, ClassPathEntry* e vm_exit_during_cds_dumping(err_msg("-Xshare:dump does not support Extension-List in JAR manifest: %s", entry->name())); } + if (strstr(manifest, "Multi-Release: true") != nullptr) { + entry->set_multi_release_jar(); + } + char* cp_attr = get_class_path_attr(entry->name(), manifest, manifest_size); if (cp_attr != nullptr && strlen(cp_attr) > 0) { @@ -299,6 +303,7 @@ void ClassLoaderExt::process_jar_manifest(JavaThread* current, ClassPathEntry* e file_start = file_end; } } + return; } void ClassLoaderExt::setup_search_paths(JavaThread* current) { From e7fc0eb522f14ee28ac40cf89268767cb7b6dfcf Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Fri, 13 Dec 2024 20:39:18 +0000 Subject: [PATCH 08/12] 8345987: java.management has two Util.newObjectName methods (remove one) Reviewed-by: cjplummer, amenkov, lmesnik --- .../jmx/interceptor/DefaultMBeanServerInterceptor.java | 3 ++- .../classes/com/sun/jmx/mbeanserver/Repository.java | 7 +++---- .../share/classes/com/sun/jmx/mbeanserver/Util.java | 9 +-------- .../classes/javax/management/MBeanServerDelegate.java | 2 +- .../share/classes/javax/management/ObjectName.java | 4 ++-- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java index 555dfdc918b..43606144cd0 100644 --- a/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java +++ b/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java @@ -35,7 +35,6 @@ import com.sun.jmx.mbeanserver.NamedObject; import com.sun.jmx.mbeanserver.Repository; import com.sun.jmx.mbeanserver.Repository.RegistrationContext; -import com.sun.jmx.mbeanserver.Util; import com.sun.jmx.remote.util.EnvHelp; import java.lang.ref.WeakReference; @@ -81,6 +80,8 @@ import javax.management.RuntimeOperationsException; import javax.management.loading.ClassLoaderRepository; +import sun.management.Util; + /** * This is the default class for MBean manipulation on the agent side. It * contains the methods necessary for the creation, registration, and diff --git a/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java b/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java index ffd4d758759..882fcaf809b 100644 --- a/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java +++ b/src/java.management/share/classes/com/sun/jmx/mbeanserver/Repository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, 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 @@ -281,7 +281,7 @@ public void addMBean(final DynamicMBean object, ObjectName name, // Set domain to default if domain is empty and not already set if (dom.length() == 0) - name = Util.newObjectName(domain + name.toString()); + name = sun.management.Util.newObjectName(domain + name.toString()); // Do we have default domain ? if (dom == domain) { // ES: OK (dom & domain are interned) @@ -438,10 +438,9 @@ public Set query(ObjectName pattern, QueryExp query) { if (allNames) result.addAll(moiTb.values()); else - addAllMatching(moiTb, result, Util.newObjectName(domain + name.getCanonicalName())); + addAllMatching(moiTb, result, sun.management.Util.newObjectName(domain + name.getCanonicalName())); return result; } - if (!name.isDomainPattern()) { final Map moiTb = domainTb.get(dom2Match); if (moiTb == null) return Collections.emptySet(); diff --git a/src/java.management/share/classes/com/sun/jmx/mbeanserver/Util.java b/src/java.management/share/classes/com/sun/jmx/mbeanserver/Util.java index 81f306e1dbb..8ef1c99052e 100644 --- a/src/java.management/share/classes/com/sun/jmx/mbeanserver/Util.java +++ b/src/java.management/share/classes/com/sun/jmx/mbeanserver/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -43,13 +43,6 @@ import javax.management.ObjectName; public class Util { - public static ObjectName newObjectName(String string) { - try { - return new ObjectName(string); - } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException(e); - } - } static Map newMap() { return new HashMap<>(); diff --git a/src/java.management/share/classes/javax/management/MBeanServerDelegate.java b/src/java.management/share/classes/javax/management/MBeanServerDelegate.java index f2346a04d5e..df75fdce9ef 100644 --- a/src/java.management/share/classes/javax/management/MBeanServerDelegate.java +++ b/src/java.management/share/classes/javax/management/MBeanServerDelegate.java @@ -28,7 +28,7 @@ import java.lang.System.Logger.Level; import com.sun.jmx.defaults.JmxProperties; import com.sun.jmx.defaults.ServiceName; -import com.sun.jmx.mbeanserver.Util; +import sun.management.Util; /** * Represents the MBean server from the management point of view. diff --git a/src/java.management/share/classes/javax/management/ObjectName.java b/src/java.management/share/classes/javax/management/ObjectName.java index 4bcda7f0252..f51037cbaf1 100644 --- a/src/java.management/share/classes/javax/management/ObjectName.java +++ b/src/java.management/share/classes/javax/management/ObjectName.java @@ -1222,7 +1222,7 @@ public static ObjectName getInstance(String domain, public static ObjectName getInstance(ObjectName name) { if (name.getClass().equals(ObjectName.class)) return name; - return Util.newObjectName(name.getSerializedNameString()); + return sun.management.Util.newObjectName(name.getSerializedNameString()); } /** @@ -1813,7 +1813,7 @@ public static String unquote(String q) { * * @since 1.6 */ - public static final ObjectName WILDCARD = Util.newObjectName("*:*"); + public static final ObjectName WILDCARD = sun.management.Util.newObjectName("*:*"); // Category : Utilities <=================================== From 4b21fb9df99918fe1adf84e80148a2076a52a276 Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Fri, 13 Dec 2024 22:40:42 +0000 Subject: [PATCH 09/12] 8343467: Remove unnecessary @SuppressWarnings annotations (security) Reviewed-by: mullan --- .../com/sun/crypto/provider/PBES2Parameters.java | 3 --- .../crypto/provider/SealedObjectForKeyProtector.java | 1 - src/java.base/share/classes/java/security/Key.java | 1 - .../share/classes/java/security/PrivateKey.java | 3 +-- .../share/classes/java/security/Provider.java | 10 +++++----- .../share/classes/java/security/PublicKey.java | 3 +-- .../java/security/interfaces/DSAPrivateKey.java | 1 - .../classes/java/security/interfaces/DSAPublicKey.java | 1 - .../classes/java/security/interfaces/ECPrivateKey.java | 1 - .../classes/java/security/interfaces/ECPublicKey.java | 1 - .../interfaces/RSAMultiPrimePrivateCrtKey.java | 1 - .../java/security/interfaces/RSAPrivateCrtKey.java | 1 - .../java/security/interfaces/RSAPrivateKey.java | 1 - .../classes/java/security/interfaces/RSAPublicKey.java | 1 - .../share/classes/javax/crypto/SecretKey.java | 3 +-- .../classes/javax/crypto/interfaces/DHPrivateKey.java | 1 - .../classes/javax/crypto/interfaces/DHPublicKey.java | 1 - .../share/classes/javax/crypto/interfaces/PBEKey.java | 3 +-- .../security/internal/interfaces/TlsMasterSecret.java | 3 +-- .../share/classes/sun/security/jca/ProviderConfig.java | 1 - .../classes/sun/security/jgss/krb5/SubjectComber.java | 3 +-- .../sun/security/pkcs11/P11TlsPrfGenerator.java | 3 +-- src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java | 2 +- 23 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java b/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java index d6b7d00d360..64b276a1c79 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java @@ -206,7 +206,6 @@ protected void engineInit(AlgorithmParameterSpec paramSpec) this.cipherParam = ((PBEParameterSpec)paramSpec).getParameterSpec(); } - @SuppressWarnings("deprecation") protected void engineInit(byte[] encoded) throws IOException { @@ -239,7 +238,6 @@ protected void engineInit(byte[] encoded) this.pbes2AlgorithmName = "PBEWith" + kdfAlgo + "And" + cipherAlgo; } - @SuppressWarnings("deprecation") private String parseKDF(DerValue keyDerivationFunc) throws IOException { if (!pkcs5PBKDF2_OID.equals(keyDerivationFunc.data.getOID())) { @@ -299,7 +297,6 @@ private String parseKDF(DerValue keyDerivationFunc) throws IOException { return kdfAlgo; } - @SuppressWarnings("deprecation") private String parseES(DerValue encryptionScheme) throws IOException { String cipherAlgo; diff --git a/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java b/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java index b5f5bc89f23..feaeee48836 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java @@ -81,7 +81,6 @@ final Key getKey(Cipher c, int maxLength) .getExtObjectInputStream(this, c)) { ois.setObjectInputFilter(new DeserializationChecker(maxLength)); try { - @SuppressWarnings("unchecked") Key t = (Key) ois.readObject(); return t; } catch (InvalidClassException ice) { diff --git a/src/java.base/share/classes/java/security/Key.java b/src/java.base/share/classes/java/security/Key.java index 28c0098c064..190a3db2999 100644 --- a/src/java.base/share/classes/java/security/Key.java +++ b/src/java.base/share/classes/java/security/Key.java @@ -115,7 +115,6 @@ public interface Key extends java.io.Serializable { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 6603384152749567654L; diff --git a/src/java.base/share/classes/java/security/PrivateKey.java b/src/java.base/share/classes/java/security/PrivateKey.java index 045670ca008..70b6f854592 100644 --- a/src/java.base/share/classes/java/security/PrivateKey.java +++ b/src/java.base/share/classes/java/security/PrivateKey.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 @@ -68,7 +68,6 @@ public interface PrivateKey extends AsymmetricKey, javax.security.auth.Destroyab * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 6034044314589513430L; } diff --git a/src/java.base/share/classes/java/security/Provider.java b/src/java.base/share/classes/java/security/Provider.java index da3f53b9632..203ffa82345 100644 --- a/src/java.base/share/classes/java/security/Provider.java +++ b/src/java.base/share/classes/java/security/Provider.java @@ -827,7 +827,7 @@ private Object implReplace(Object key, Object value) { return o; } - @SuppressWarnings("unchecked") // Function must actually operate over strings + // Function must actually operate over strings private void implReplaceAll(BiFunction function) { @@ -847,7 +847,7 @@ private void implReplaceAll(BiFunction remappingFunction) { @@ -864,7 +864,7 @@ private Object implMerge(Object key, Object value, return o; } - @SuppressWarnings("unchecked") // Function must actually operate over strings + // Function must actually operate over strings private Object implCompute(Object key, BiFunction remappingFunction) { @@ -881,7 +881,7 @@ private Object implCompute(Object key, BiFunction mappingFunction) { if (!checkLegacy(key)) return null; @@ -893,7 +893,7 @@ private Object implComputeIfAbsent(Object key, Function remappingFunction) { if (!checkLegacy(key)) return null; diff --git a/src/java.base/share/classes/java/security/PublicKey.java b/src/java.base/share/classes/java/security/PublicKey.java index e93efaf1c5b..9b79cd6908c 100644 --- a/src/java.base/share/classes/java/security/PublicKey.java +++ b/src/java.base/share/classes/java/security/PublicKey.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 @@ -54,7 +54,6 @@ public interface PublicKey extends AsymmetricKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 7187392471159151072L; } diff --git a/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java index efef7daca29..d3f042f2137 100644 --- a/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java @@ -52,7 +52,6 @@ public interface DSAPrivateKey extends DSAKey, java.security.PrivateKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 7776497482533790279L; diff --git a/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java b/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java index a58333b38ba..d7fa55a8c8f 100644 --- a/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java @@ -52,7 +52,6 @@ public interface DSAPublicKey extends DSAKey, java.security.PublicKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 1234526332779022332L; diff --git a/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java index 53c1f358d52..cdb31a90ba0 100644 --- a/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java @@ -48,7 +48,6 @@ public interface ECPrivateKey extends PrivateKey, ECKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -7896394956925609184L; diff --git a/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java b/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java index d78f863cc76..5cfdab999b1 100644 --- a/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java @@ -50,7 +50,6 @@ public interface ECPublicKey extends PublicKey, ECKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -3314988629879632826L; diff --git a/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java b/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java index a523d36ac70..a15d6db4133 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java @@ -57,7 +57,6 @@ public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 618058533534628008L; diff --git a/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java b/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java index 7a8bea29e7e..025145fa625 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java @@ -52,7 +52,6 @@ public interface RSAPrivateCrtKey extends RSAPrivateKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -5682214253527700368L; diff --git a/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java index 8f74b476f99..dad9b375e00 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java @@ -50,7 +50,6 @@ public interface RSAPrivateKey extends java.security.PrivateKey, RSAKey * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 5187144804936595022L; diff --git a/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java b/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java index a02b454abb2..03fe109db5d 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java @@ -47,7 +47,6 @@ public interface RSAPublicKey extends java.security.PublicKey, RSAKey * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -8727434096241101194L; diff --git a/src/java.base/share/classes/javax/crypto/SecretKey.java b/src/java.base/share/classes/javax/crypto/SecretKey.java index 6dd6a9be19a..5fa6f7fd44d 100644 --- a/src/java.base/share/classes/javax/crypto/SecretKey.java +++ b/src/java.base/share/classes/javax/crypto/SecretKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, 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 @@ -68,6 +68,5 @@ public interface SecretKey extends * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") long serialVersionUID = -4795878709595146952L; } diff --git a/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java b/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java index 49a93c02b42..8a252c7f82b 100644 --- a/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java +++ b/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java @@ -47,7 +47,6 @@ public interface DHPrivateKey extends DHKey, java.security.PrivateKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = 2211791113380396553L; diff --git a/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java b/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java index 631d8a20e66..f1a748cff24 100644 --- a/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java +++ b/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java @@ -47,7 +47,6 @@ public interface DHPublicKey extends DHKey, java.security.PublicKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -6628103563352519193L; diff --git a/src/java.base/share/classes/javax/crypto/interfaces/PBEKey.java b/src/java.base/share/classes/javax/crypto/interfaces/PBEKey.java index 20f1e64798f..162d4d85b45 100644 --- a/src/java.base/share/classes/javax/crypto/interfaces/PBEKey.java +++ b/src/java.base/share/classes/javax/crypto/interfaces/PBEKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -44,7 +44,6 @@ public interface PBEKey extends javax.crypto.SecretKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -1430015993304333921L; diff --git a/src/java.base/share/classes/sun/security/internal/interfaces/TlsMasterSecret.java b/src/java.base/share/classes/sun/security/internal/interfaces/TlsMasterSecret.java index 2f91a445ace..36306c26862 100644 --- a/src/java.base/share/classes/sun/security/internal/interfaces/TlsMasterSecret.java +++ b/src/java.base/share/classes/sun/security/internal/interfaces/TlsMasterSecret.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -49,7 +49,6 @@ public interface TlsMasterSecret extends SecretKey { * ineffectual. Do not use; no replacement. */ @Deprecated - @SuppressWarnings("serial") @java.io.Serial long serialVersionUID = -461748105810469773L; diff --git a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java index ce954b3b6a5..830b18e8fef 100644 --- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java +++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java @@ -149,7 +149,6 @@ public String toString() { /** * Get the provider object. Loads the provider if it is not already loaded. */ - @SuppressWarnings("deprecation") Provider getProvider() { // volatile variable load Provider p = provider; diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/krb5/SubjectComber.java b/src/java.security.jgss/share/classes/sun/security/jgss/krb5/SubjectComber.java index f6597bbfeec..26bfe936d0f 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/krb5/SubjectComber.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/krb5/SubjectComber.java @@ -151,8 +151,7 @@ private static Object findAux(Subject subject, String serverPrincipal, Iterator iterator = pcs.iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); - if (!(obj instanceof @SuppressWarnings("unchecked") - KerberosTicket ticket)) { + if (!(obj instanceof KerberosTicket ticket)) { continue; } if (DEBUG != null) { diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java index ed08978c0ea..32f99b3fd5a 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -107,7 +107,6 @@ protected void engineInit(AlgorithmParameterSpec params, // compatibility, it is nonsensical for an anonymous class to define a // serialVersionUID. Suppress warnings relative to missing serialVersionUID // field in the anonymous subclass of serializable SecretKey. - @SuppressWarnings("serial") private static final SecretKey NULL_KEY = new SecretKey() { public byte[] getEncoded() { return new byte[0]; diff --git a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java index a12049cbcf0..0be28f52625 100644 --- a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java +++ b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java @@ -304,7 +304,7 @@ static native void setInitMsgOption0(int fd, int arg1, int arg2) loadSctpLibrary(); } - @SuppressWarnings({"removal", "restricted"}) + @SuppressWarnings("restricted") private static void loadSctpLibrary() { IOUtil.load(); // loads nio & net native libraries System.loadLibrary("sctp"); From c2f0ef5f4822e7e558fe2b4077d57634d380aa11 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Sat, 14 Dec 2024 00:16:08 +0000 Subject: [PATCH 10/12] 8346159: Disable CDS AOTClassLinking tests for JVMCI due to JDK-8345635 Reviewed-by: dnsimon, dholmes --- .../runtime/cds/appcds/LambdaWithUseImplMethodHandle.java | 3 +++ .../runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java | 4 ++++ .../runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java | 3 +++ .../cds/appcds/resolvedConstants/AOTLinkedLambdas.java | 2 ++ .../cds/appcds/resolvedConstants/AOTLinkedVarHandles.java | 2 ++ 5 files changed, 14 insertions(+) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java index 360fce5879a..0c747168945 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithUseImplMethodHandle.java @@ -27,6 +27,9 @@ * @bug 8290417 * @summary CDS cannot archive lambda proxy with useImplMethodHandle * @requires vm.cds + * @requires vm.cds.supports.aot.class.linking + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes * @build pkg1.BaseWithProtectedMethod * @build pkg2.Child diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java index 6e7473c59c1..25361403481 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java @@ -29,6 +29,8 @@ /* * @test id=static * @requires vm.cds.supports.aot.class.linking + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled * @library /test/jdk/lib/testlibrary /test/lib * @build InitiatingLoaderTester * @build BulkLoaderTest @@ -39,6 +41,8 @@ /* * @test id=dynamic * @requires vm.cds.supports.aot.class.linking + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled * @library /test/jdk/lib/testlibrary /test/lib * @build InitiatingLoaderTester * @build jdk.test.whitebox.WhiteBox BulkLoaderTest diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java index 1603d8430b2..ca5a08d20af 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java @@ -27,6 +27,9 @@ * @bug 8214781 8293187 * @summary Test for the -XX:ArchiveHeapTestClass flag * @requires vm.debug == true & vm.cds.write.archived.java.heap + * @requires vm.cds.supports.aot.class.linking + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled * @modules java.logging * @library /test/jdk/lib/testlibrary /test/lib * /test/hotspot/jtreg/runtime/cds/appcds diff --git a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java index 5fb0a30cd61..d015498ed04 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java @@ -28,6 +28,8 @@ * @bug 8340836 * @requires vm.cds * @requires vm.cds.supports.aot.class.linking + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds/test-classes/ * @build AOTLinkedLambdas * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar diff --git a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java index 2098ebc2c71..886e0424c9a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java @@ -28,6 +28,8 @@ * @bug 8343245 * @requires vm.cds * @requires vm.cds.supports.aot.class.linking + * @comment work around JDK-8345635 + * @requires !vm.jvmci.enabled * @library /test/lib * @build AOTLinkedVarHandles * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar From ebb27c2e8f47d35d4f030cca4126c39e24d456bd Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Sat, 14 Dec 2024 01:48:05 +0000 Subject: [PATCH 11/12] 8346139: test_memset_with_concurrent_readers.cpp should not use Reviewed-by: stefank, tschatzl --- .../test_memset_with_concurrent_readers.cpp | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp index 875186b83d0..8033643b53b 100644 --- a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp +++ b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, 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 @@ -24,13 +24,7 @@ #include "precompiled.hpp" #include "gc/shared/memset_with_concurrent_readers.hpp" #include "utilities/globalDefinitions.hpp" - -#include "utilities/vmassert_uninstall.hpp" -#include -#include -#include -#include "utilities/vmassert_reinstall.hpp" - +#include "utilities/ostream.hpp" #include "unittest.hpp" static unsigned line_byte(const char* line, size_t i) { @@ -71,29 +65,31 @@ TEST(gc, memset_with_concurrent_readers) { bool middle_set = !memcmp(set_block, block + set_start, set_size); bool tail_clear = !memcmp(clear_block, block + set_end, block_size - set_end); if (!(head_clear && middle_set && tail_clear)) { - std::ostringstream err_stream; - err_stream << "*** memset_with_concurrent_readers failed: set start " - << set_start << ", set end " << set_end << std::endl; + stringStream err_stream{}; + err_stream.print_cr("*** memset_with_concurrent_readers failed: " + "set start %zu, set end %zu", + set_start, set_end); for (unsigned chunk = 0; chunk < (block_size / chunk_size); ++chunk) { for (unsigned line = 0; line < (chunk_size / BytesPerWord); ++line) { const char* lp = &block[chunk * chunk_size + line * BytesPerWord]; - err_stream << std::dec << chunk << "," << line << ": " << std::hex - << std::setw(2) << line_byte(lp, 0) << " " - << std::setw(2) << line_byte(lp, 1) << " " - << std::setw(2) << line_byte(lp, 2) << " " - << std::setw(2) << line_byte(lp, 3) << " " - << std::setw(2) << line_byte(lp, 4) << " " - << std::setw(2) << line_byte(lp, 5) << " " - << std::setw(2) << line_byte(lp, 6) << " " - << std::setw(2) << line_byte(lp, 7) << std::endl; + err_stream.print_cr("%u, %u: " + "%02x %02x " + "%02x %02x " + "%02x %02x " + "%02x %02x", + chunk, line, + line_byte(lp, 0), line_byte(lp, 1), + line_byte(lp, 2), line_byte(lp, 3), + line_byte(lp, 4), line_byte(lp, 5), + line_byte(lp, 6), line_byte(lp, 7)); } } EXPECT_TRUE(head_clear) << "leading byte not clear"; EXPECT_TRUE(middle_set) << "memset byte not set"; EXPECT_TRUE(tail_clear) << "trailing bye not clear"; - ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.str(); + ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.freeze(); } } } From 3b9de117e83a7875df7fd2ddcc9d896f027e2c92 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Sat, 14 Dec 2024 06:13:26 +0000 Subject: [PATCH 12/12] 8319875: Add macOS implementation for jcmd System.map Reviewed-by: stuefe, szaldana --- src/hotspot/os/bsd/memMapPrinter_macosx.cpp | 383 ++++++++++++++++++ .../os/windows/memMapPrinter_windows.cpp | 3 +- src/hotspot/share/nmt/memMapPrinter.cpp | 2 +- src/hotspot/share/nmt/memMapPrinter.hpp | 2 +- .../share/services/diagnosticCommand.cpp | 6 +- .../share/services/diagnosticCommand.hpp | 8 +- .../dcmd/vm/SystemDumpMapTest.java | 2 +- .../serviceability/dcmd/vm/SystemMapTest.java | 2 +- .../dcmd/vm/SystemMapTestBase.java | 213 +++++++--- 9 files changed, 543 insertions(+), 78 deletions(-) create mode 100644 src/hotspot/os/bsd/memMapPrinter_macosx.cpp diff --git a/src/hotspot/os/bsd/memMapPrinter_macosx.cpp b/src/hotspot/os/bsd/memMapPrinter_macosx.cpp new file mode 100644 index 00000000000..33c30ab6f70 --- /dev/null +++ b/src/hotspot/os/bsd/memMapPrinter_macosx.cpp @@ -0,0 +1,383 @@ +/* + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates. + * 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. + * + */ + +#if defined(__APPLE__) + +#include "precompiled.hpp" + +#include "nmt/memMapPrinter.hpp" +#include "runtime/os.hpp" +#include "utilities/align.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/powerOfTwo.hpp" + +#include +#include +#include +#include +#include + +#include +#include +#include + +// maximum number of mapping records returned +static const int MAX_REGIONS_RETURNED = 1000000; + +// ::mmap() on MacOS is a layer on top of Mach system calls, and will allocate in 128MB chunks. +// This code will coalesce a series of identical 128GB chunks (maybe followed by one smaller chunk +// with identical flags) into one. +// Unfortunately, two or more identically allocated contiguous sections will appear as one, if the +// first section is size 128MB. vmmap(1) has the same issue. +static const int MACOS_PARTIAL_ALLOCATION_SIZE = 128 * M; + +class MappingInfo { + proc_regioninfo _rinfo; +public: + const char* _address; + size_t _size; + stringStream _share_buffer; + stringStream _type_buffer; + stringStream _protect_buffer; + stringStream _file_name; + const char* _tag_text; + + MappingInfo() : _address(nullptr), _size(0), _tag_text(nullptr) {} + + void reset() { + _share_buffer.reset(); + _protect_buffer.reset(); + _type_buffer.reset(); + _file_name.reset(); + _tag_text = nullptr; + } + + bool canCombine(const proc_regionwithpathinfo& mem_info) { + const proc_regioninfo& n = mem_info.prp_prinfo; + bool cc = _rinfo.pri_size == MACOS_PARTIAL_ALLOCATION_SIZE + && n.pri_address == (_rinfo.pri_address + _size) + && n.pri_protection == _rinfo.pri_protection + && n.pri_max_protection == _rinfo.pri_max_protection + && n.pri_user_tag == _rinfo.pri_user_tag + && n.pri_share_mode == _rinfo.pri_share_mode + && n.pri_offset == 0; + return cc; + } + + void combineWithFollowing(const proc_regionwithpathinfo& mem_info) { + _size += mem_info.prp_prinfo.pri_size; + } + + void process(const proc_regionwithpathinfo& mem_info) { + reset(); + + _rinfo = mem_info.prp_prinfo; + + _address = (const char*) _rinfo.pri_address; + _size = _rinfo.pri_size; + + if (mem_info.prp_vip.vip_path[0] != '\0') { + _file_name.print_raw(mem_info.prp_vip.vip_path); + } + // proc_regionfilename() seems to give bad results, so we don't try to use it here. + + char prot[4]; + char maxprot[4]; + rwbits(_rinfo.pri_protection, prot); + rwbits(_rinfo.pri_max_protection, maxprot); + _protect_buffer.print("%s/%s", prot, maxprot); + + get_share_mode(_share_buffer, _rinfo); + _tag_text = tagToStr(_rinfo.pri_user_tag); + } + + static void get_share_mode(outputStream& out, const proc_regioninfo& rinfo) { + static const char* share_strings[] = { + "cow", "pvt", "---", "shr", "tsh", "p/a", "s/a", "lpg" + }; + assert(SM_COW == 1 && SM_LARGE_PAGE == (sizeof(share_strings)/sizeof(share_strings[0])), "share_mode contants are out of range"); // the +1 offset is intentional; see below + const bool valid_share_mode = rinfo.pri_share_mode >= SM_COW && rinfo.pri_share_mode <= SM_LARGE_PAGE; + if (valid_share_mode) { + int share_mode = rinfo.pri_share_mode; + out.print_raw(share_strings[share_mode - 1]); + } else { + out.print_cr("invalid pri_share_mode (%d)", rinfo.pri_share_mode); + assert(valid_share_mode, "invalid pri_share_mode (%d)", rinfo.pri_share_mode); + } + } + +#define X1(TAG, DESCR) X2(TAG, DESCR) +#define X2(TAG, DESCRIPTION) case VM_MEMORY_ ## TAG: return # DESCRIPTION; + static const char* tagToStr(uint32_t user_tag) { + switch (user_tag) { + case 0: + return 0; + X1(MALLOC, malloc); + X1(MALLOC_SMALL, malloc_small); + X1(MALLOC_LARGE, malloc_large); + X1(MALLOC_HUGE, malloc_huge); + X1(SBRK, sbrk); + X1(REALLOC, realloc); + X1(MALLOC_TINY, malloc_tiny); + X1(MALLOC_LARGE_REUSABLE, malloc_large_reusable); + X1(MALLOC_LARGE_REUSED, malloc_lage_reused); + X1(ANALYSIS_TOOL, analysis_tool); + X1(MALLOC_NANO, malloc_nano); + X1(MALLOC_MEDIUM, malloc_medium); + X1(MALLOC_PROB_GUARD, malloc_prob_guard); + X1(MACH_MSG, malloc_msg); + X1(IOKIT, IOKit); + X1(STACK, stack); + X1(GUARD, guard); + X1(SHARED_PMAP, shared_pmap); + X1(DYLIB, dylib); + X1(UNSHARED_PMAP, unshared_pmap); + X2(APPKIT, AppKit); + X2(FOUNDATION, Foundation); + X2(COREGRAPHICS, CoreGraphics); + X2(CORESERVICES, CoreServices); // is also VM_MEMORY_CARBON + X2(JAVA, Java); + X2(COREDATA, CoreData); + X1(COREDATA_OBJECTIDS, CodeData_objectids); + X1(ATS, ats); + X1(DYLD, dyld); + X1(DYLD_MALLOC, dyld_malloc); + X1(SQLITE, sqlite); + X1(JAVASCRIPT_CORE, javascript_core); + X1(JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR, javascript_jit_executable_allocator); + X1(JAVASCRIPT_JIT_REGISTER_FILE, javascript_jit_register_file); + X1(OPENCL, OpenCL); + X2(COREIMAGE, CoreImage); + X2(IMAGEIO, ImageIO); + X2(COREPROFILE, CoreProfile); + X1(APPLICATION_SPECIFIC_1, application_specific_1); + X1(APPLICATION_SPECIFIC_16, application_specific_16); + X1(OS_ALLOC_ONCE, os_alloc_once); + X1(GENEALOGY, genealogy); + default: + static char buffer[30]; + snprintf(buffer, sizeof(buffer), "user_tag=0x%x(%d)", user_tag, user_tag); + return buffer; + } + } + + static void rwbits(int rw, char bits[4]) { + bits[0] = rw & VM_PROT_READ ? 'r' : '-'; + bits[1] = rw & VM_PROT_WRITE ? 'w' : '-'; + bits[2] = rw & VM_PROT_EXECUTE ? 'x' : '-'; + bits[3] = 0; + } +}; + +class ProcSmapsSummary { + unsigned _num_mappings; + size_t _private; + size_t _committed; // combined committed size + size_t _reserved; // reserved but not committed + size_t _shared; // combined shared size + size_t _swapped_out; // combined amount of swapped-out memory +public: + ProcSmapsSummary() : _num_mappings(0), _private(0), + _committed(0), _shared(0), _swapped_out(0) {} + + void add_mapping(const proc_regioninfo& region_info) { + _num_mappings++; + + bool is_private = region_info.pri_share_mode == SM_PRIVATE + || region_info.pri_share_mode == SM_PRIVATE_ALIASED; + bool is_shared = region_info.pri_share_mode == SM_SHARED + || region_info.pri_share_mode == SM_SHARED_ALIASED + || region_info.pri_share_mode == SM_TRUESHARED + || region_info.pri_share_mode == SM_COW; + bool is_committed = region_info.pri_share_mode == SM_EMPTY + && region_info.pri_max_protection == VM_PROT_ALL + && ((region_info.pri_protection & VM_PROT_DEFAULT) == VM_PROT_DEFAULT); + bool is_reserved = region_info.pri_share_mode == SM_EMPTY + && region_info.pri_max_protection == VM_PROT_ALL + && region_info.pri_protection == VM_PROT_NONE; + + _private += is_private ? region_info.pri_size : 0; + _shared += is_shared ? region_info.pri_size : 0; + _swapped_out += region_info.pri_pages_swapped_out; + _committed += is_committed ? region_info.pri_size : 0; + _reserved += is_reserved ? region_info.pri_size : 0; + } + + void print_on(const MappingPrintSession& session) const { + outputStream* st = session.out(); + + st->print_cr("Number of mappings: %u", _num_mappings); + + task_vm_info vm_info; + mach_msg_type_number_t num_out = TASK_VM_INFO_COUNT; + kern_return_t err = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t)(&vm_info), &num_out); + if (err == KERN_SUCCESS) { + st->print_cr(" vsize: %llu (%llu%s)", vm_info.virtual_size, PROPERFMTARGS(vm_info.virtual_size)); + st->print_cr(" rss: %llu (%llu%s)", vm_info.resident_size, PROPERFMTARGS(vm_info.resident_size)); + st->print_cr(" peak rss: %llu (%llu%s)", vm_info.resident_size_peak, PROPERFMTARGS(vm_info.resident_size_peak)); + st->print_cr(" page size: %d (%ld%s)", vm_info.page_size, PROPERFMTARGS((size_t)vm_info.page_size)); + } else { + st->print_cr("error getting vm_info %d", err); + } + st->print_cr(" reserved: %zu (" PROPERFMT ")", _reserved, PROPERFMTARGS(_reserved)); + st->print_cr(" committed: %zu (" PROPERFMT ")", _committed, PROPERFMTARGS(_committed)); + st->print_cr(" private: %zu (" PROPERFMT ")", _private, PROPERFMTARGS(_private)); + st->print_cr(" shared: %zu (" PROPERFMT ")", _shared, PROPERFMTARGS(_shared)); + st->print_cr(" swapped out: %zu (" PROPERFMT ")", _swapped_out * vm_info.page_size, PROPERFMTARGS(_swapped_out * vm_info.page_size)); + } +}; + +class ProcSmapsPrinter { + const MappingPrintSession& _session; +public: + ProcSmapsPrinter(const MappingPrintSession& session) : + _session(session) + {} + + void print_single_mapping(const proc_regioninfo& region_info, const MappingInfo& mapping_info) const { + outputStream* st = _session.out(); +#define INDENT_BY(n) \ + if (st->fill_to(n) == 0) { \ + st->print(" "); \ + } + st->print("%#014.12llx-%#014.12llx", (uint64_t)(mapping_info._address), (uint64_t)(mapping_info._address + mapping_info._size)); + INDENT_BY(38); + st->print("%12ld", mapping_info._size); + INDENT_BY(51); + st->print("%s", mapping_info._protect_buffer.base()); + INDENT_BY(59); + st->print("%s", mapping_info._share_buffer.base()); + st->print("%s", mapping_info._type_buffer.base()); + INDENT_BY(64); + st->print("%#11llx", region_info.pri_offset); + INDENT_BY(77); + if (_session.print_nmt_info_for_region((const void*)mapping_info._address, (const void*)(mapping_info._address + mapping_info._size))) { + st->print(" "); + } else { + const char* tag = mapping_info._tag_text; + if (tag != nullptr) { + st->print("[%s] ", tag); + } + } + + st->print_raw(mapping_info._file_name.base()); + st->cr(); + +#undef INDENT_BY + } + + void print_legend() const { + outputStream* st = _session.out(); + st->print_cr("from, to, vsize: address range and size"); + st->print_cr("prot: protection:"); + st->print_cr(" rwx: read / write / execute"); + st->print_cr("share: share mode:"); + st->print_cr(" cow: copy on write"); + st->print_cr(" pvt: private"); + st->print_cr(" shr: shared"); + st->print_cr(" tsh: true shared"); + st->print_cr(" p/a: private aliased"); + st->print_cr(" s/a: shared aliased"); + st->print_cr(" lpg: large page"); + st->print_cr("offset: offset from start of allocation block"); + st->print_cr("vminfo: VM information (requires NMT)"); + st->print_cr("file: file mapped, if mapping is not anonymous"); + { + streamIndentor si(st, 16); + _session.print_nmt_flag_legend(); + } + st->print_cr("file: file mapped, if mapping is not anonymous"); + } + + void print_header() const { + outputStream* st = _session.out(); + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 + // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 0x000102890000-0x000102898000 32768 r--/r-- cow 0xc000 /Users/simont/dev/openjdk/jdk/build/macos-aarch64-fastdebug-shenandoah/images/jdk/bin/java + st->print_cr("from to vsize prot share offset vminfo/file"); + st->print_cr("=================================================================================================="); + } +}; + +static bool is_interesting(const proc_regionwithpathinfo& info) { + return info.prp_prinfo.pri_share_mode != SM_EMPTY + || info.prp_prinfo.pri_user_tag != 0 + || info.prp_vip.vip_path[0] != '\0' + || info.prp_prinfo.pri_protection != 0 + || info.prp_prinfo.pri_max_protection != 0; +} + +void MemMapPrinter::pd_print_all_mappings(const MappingPrintSession& session) { + + ProcSmapsPrinter printer(session); + ProcSmapsSummary summary; + outputStream* const st = session.out(); + const pid_t pid = getpid(); + + printer.print_legend(); + st->cr(); + printer.print_header(); + + proc_regionwithpathinfo region_info_with_path; + MappingInfo mapping_info; + uint64_t address = 0; + int region_count = 0; + while (true) { + if (++region_count > MAX_REGIONS_RETURNED) { + st->print_cr("limit of %d regions reached (results inaccurate)", region_count); + break; + } + ::bzero(®ion_info_with_path, sizeof(region_info_with_path)); + int retval = proc_pidinfo(pid, PROC_PIDREGIONPATHINFO, (uint64_t)address, ®ion_info_with_path, sizeof(region_info_with_path)); + if (retval <= 0) { + break; + } else if (retval < (int)sizeof(region_info_with_path)) { + st->print_cr("proc_pidinfo() returned %d", retval); + assert(false, "proc_pidinfo() returned %d", retval); + } + proc_regioninfo& region_info = region_info_with_path.prp_prinfo; + if (is_interesting(region_info_with_path)) { + if (mapping_info.canCombine(region_info_with_path)) { + mapping_info.combineWithFollowing(region_info_with_path); + } else { + // print previous mapping info + // avoid printing the empty info at the start + if (mapping_info._size != 0) { + printer.print_single_mapping(region_info, mapping_info); + } + summary.add_mapping(region_info); + mapping_info.process(region_info_with_path); + } + } + assert(region_info.pri_size > 0, "size of region is 0"); + address = region_info.pri_address + region_info.pri_size; + } + printer.print_single_mapping(region_info_with_path.prp_prinfo, mapping_info); + summary.add_mapping(region_info_with_path.prp_prinfo); + st->cr(); + summary.print_on(session); + st->cr(); +} +#endif // __APPLE__ \ No newline at end of file diff --git a/src/hotspot/os/windows/memMapPrinter_windows.cpp b/src/hotspot/os/windows/memMapPrinter_windows.cpp index eb6b24a9d13..ff27aea02c5 100644 --- a/src/hotspot/os/windows/memMapPrinter_windows.cpp +++ b/src/hotspot/os/windows/memMapPrinter_windows.cpp @@ -197,8 +197,9 @@ class MappingInfoPrinter { st->print_cr("state: region state and type:"); st->print_cr(" state: committed / reserved"); st->print_cr(" type: image / mapped / private"); + st->print_cr("offset: offset from start of allocation block"); + st->print_cr("vminfo: VM information (requires NMT)"); st->print_cr("file: file mapped, if mapping is not anonymous"); - st->print_cr("vm info: VM information (requires NMT)"); { streamIndentor si(st, 16); _session.print_nmt_flag_legend(); diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index 34ddb7a8713..5c164e19b57 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" -#if defined(LINUX) || defined(_WIN64) +#if defined(LINUX) || defined(_WIN64) || defined(__APPLE__) #include "gc/shared/collectedHeap.hpp" #include "logging/logAsyncWriter.hpp" diff --git a/src/hotspot/share/nmt/memMapPrinter.hpp b/src/hotspot/share/nmt/memMapPrinter.hpp index 7f3ef9abca8..34897a0c75c 100644 --- a/src/hotspot/share/nmt/memMapPrinter.hpp +++ b/src/hotspot/share/nmt/memMapPrinter.hpp @@ -30,7 +30,7 @@ #include "nmt/memTag.hpp" #include "utilities/globalDefinitions.hpp" -#if defined(LINUX) || defined(_WIN64) +#if defined(LINUX) || defined(_WIN64) || defined(__APPLE__) class outputStream; class CachedNMTInformation; diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index e4dff47c84f..3b52f0edc72 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -140,10 +140,10 @@ void DCmd::register_dcmds(){ DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); #endif // LINUX -#if defined(LINUX) || defined(_WIN64) +#if defined(LINUX) || defined(_WIN64) || defined(__APPLE__) DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true,false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true,false)); -#endif // LINUX or WINDOWS +#endif // LINUX or WINDOWS or MacOS DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); @@ -1158,7 +1158,7 @@ void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) { CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize); } -#if defined(LINUX) || defined(_WIN64) +#if defined(LINUX) || defined(_WIN64) || defined(__APPLE__) SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) : DCmd(output, heap) {} diff --git a/src/hotspot/share/services/diagnosticCommand.hpp b/src/hotspot/share/services/diagnosticCommand.hpp index 83e818e16d2..212a8996d0a 100644 --- a/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/hotspot/share/services/diagnosticCommand.hpp @@ -822,14 +822,14 @@ class CompilationMemoryStatisticDCmd: public DCmdWithParser { virtual void execute(DCmdSource source, TRAPS); }; -#if defined(LINUX) || defined(_WIN64) +#if defined(LINUX) || defined(_WIN64) || defined(__APPLE__) class SystemMapDCmd : public DCmd { public: SystemMapDCmd(outputStream* output, bool heap); static const char* name() { return "System.map"; } static const char* description() { - return "Prints an annotated process memory map of the VM process (linux and Windows only)."; + return "Prints an annotated process memory map of the VM process (linux, Windows and MacOS only)."; } static const char* impact() { return "Medium; can be high for very large java heaps."; } virtual void execute(DCmdSource source, TRAPS); @@ -842,12 +842,12 @@ class SystemDumpMapDCmd : public DCmdWithParser { SystemDumpMapDCmd(outputStream* output, bool heap); static const char* name() { return "System.dump_map"; } static const char* description() { - return "Dumps an annotated process memory map to an output file (linux and Windows only)."; + return "Dumps an annotated process memory map to an output file (linux, Windows and MacOS only)."; } static const char* impact() { return "Medium; can be high for very large java heaps."; } virtual void execute(DCmdSource source, TRAPS); }; -#endif // LINUX or WINDOWS +#endif // LINUX, WINDOWS or MACOS #endif // SHARE_SERVICES_DIAGNOSTICCOMMAND_HPP diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java index eab69de0a51..1bfec79e9df 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java @@ -35,7 +35,7 @@ * @test * @summary Test of diagnostic command System.map * @library /test/lib - * @requires (os.family == "linux" | os.family == "windows") + * @requires (os.family == "linux" | os.family == "windows" | os.family == "mac") * @modules java.base/jdk.internal.misc * java.compiler * java.management diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java index 6d589d17f8a..72283ca0120 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java @@ -31,7 +31,7 @@ * @test * @summary Test of diagnostic command System.map * @library /test/lib - * @requires (os.family == "linux" | os.family == "windows") + * @requires (os.family == "linux" | os.family == "windows" | os.family == "mac") * @modules java.base/jdk.internal.misc * java.compiler * java.management diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java index 6507117df35..dbd82f0f208 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java @@ -33,80 +33,161 @@ public class SystemMapTestBase { private static final String someSize = "\\d+"; private static final String someNumber = "(0x\\p{XDigit}+|\\d+)"; private static final String pagesize = "(4K|8K|16K|64K|2M|16M|64M)"; - private static final String prot = "[rwsxp-]+"; - - private static final String regexBase = range + space + - someSize + space + - prot + space + - someSize + space + - someSize + space + - pagesize + space; - - private static final String regexBase_committed = regexBase + "com.*"; - private static final String regexBase_shared_and_committed = regexBase + "shrd,com.*"; - - // java heap is either committed, non-shared, or - in case of ZGC - committed and shared. - private static final String regexBase_java_heap = regexBase + "(shrd,)?com.*"; - - private static final String shouldMatchUnconditionally_linux[] = { - // java launcher - regexBase_committed + "/bin/java", - // libjvm - regexBase_committed + "/lib/.*/libjvm.so", - // heap segment, should be part of all user space apps on all architectures OpenJDK supports. - regexBase_committed + "\\[heap\\]", - // we should see the hs-perf data file, and it should appear as shared as well as committed - regexBase_shared_and_committed + "hsperfdata_.*" - }; - private static final String shouldMatchIfNMTIsEnabled_linux[] = { - regexBase_java_heap + "JAVAHEAP.*", - // metaspace - regexBase_committed + "META.*", - // parts of metaspace should be uncommitted - regexBase + "-" + space + "META.*", - // code cache - regexBase_committed + "CODE.*", - // Main thread stack - regexBase_committed + "STACK.*main.*" + interface MapPatterns { + String[] shouldMatchUnconditionally(); + String[] shouldMatchIfNMTIsEnabled(); }; - // windows: - private static final String winprot = "[\\-rwxcin]*"; - private static final String wintype = "[rc]-(img|map|pvt)"; + private final MapPatterns patternProvider; - private static final String winbase = range + space + someSize + space + winprot + space; + private static final boolean isWindows = Platform.isWindows(); + private static final boolean isMacOS = Platform.isOSX(); - private static final String winimage = winbase + "c-img" + space + someNumber + space; - private static final String wincommitted = winbase + "(c-pvt|c-map)" + space + someNumber + space; - private static final String winreserved = winbase + "r-pvt" + space + someNumber + space; + protected String[] shouldMatchUnconditionally() { + return patternProvider.shouldMatchUnconditionally(); + } - private static final String shouldMatchUnconditionally_windows[] = { - // java launcher - winimage + ".*[\\/\\\\]bin[\\/\\\\]java[.]exe", - // libjvm - winimage + ".*[\\/\\\\]bin[\\/\\\\].*[\\/\\\\]jvm.dll" - }; + protected String[] shouldMatchIfNMTIsEnabled() { + return patternProvider.shouldMatchIfNMTIsEnabled(); + } - private static final String shouldMatchIfNMTIsEnabled_windows[] = { - wincommitted + "JAVAHEAP.*", - // metaspace - wincommitted + "META.*", - // parts of metaspace should be uncommitted - winreserved + "META.*", - // code cache - wincommitted + "CODE.*", - // Main thread stack - wincommitted + "STACK-\\d+-main.*" - }; + protected SystemMapTestBase() { + if (Platform.isWindows()) { + patternProvider = new WindowsPatterns(); + } else if (Platform.isOSX()) { + patternProvider = new MacOSPatterns(); + } else { + patternProvider = new LinuxPatterns(); + } + } - private static final boolean isWindows = Platform.isWindows(); + private static class LinuxPatterns implements MapPatterns { + + private static final String prot = "[rwsxp-]+"; + + static final String regexBase = range + space + + someSize + space + + prot + space + + someSize + space + + someSize + space + + pagesize + space; + + static final String regexBase_committed = regexBase + "com.*"; + static final String regexBase_shared_and_committed = regexBase + "shrd,com.*"; + + // java heap is either committed, non-shared, or - in case of ZGC - committed and shared. + static final String regexBase_java_heap = regexBase + "(shrd,)?com.*"; + + static final String shouldMatchUnconditionally_linux[] = { + // java launcher + regexBase_committed + "/bin/java", + // libjvm + regexBase_committed + "/lib/.*/libjvm.so", + // heap segment, should be part of all user space apps on all architectures OpenJDK supports. + regexBase_committed + "\\[heap\\]", + // we should see the hs-perf data file, and it should appear as shared as well as committed + regexBase_shared_and_committed + "hsperfdata_.*" + }; + + static final String shouldMatchIfNMTIsEnabled_linux[] = { + regexBase_java_heap + "JAVAHEAP.*", + // metaspace + regexBase_committed + "META.*", + // parts of metaspace should be uncommitted + regexBase + "-" + space + "META.*", + // code cache + regexBase_committed + "CODE.*", + // Main thread stack + regexBase_committed + "STACK.*main.*" + }; + + public String[] shouldMatchUnconditionally() { + return shouldMatchUnconditionally_linux; + } + + public String[] shouldMatchIfNMTIsEnabled() { + return shouldMatchIfNMTIsEnabled_linux; + } + }; - protected static String[] shouldMatchUnconditionally() { - return isWindows ? shouldMatchUnconditionally_windows : shouldMatchUnconditionally_linux; - } - protected static String[] shouldMatchIfNMTIsEnabled() { - return isWindows ? shouldMatchIfNMTIsEnabled_windows : shouldMatchIfNMTIsEnabled_linux; - } + private static class WindowsPatterns implements MapPatterns { + + static final String winprot = "[\\-rwxcin]*"; + static final String wintype = "[rc]-(img|map|pvt)"; + + static final String winbase = range + space + someSize + space + winprot + space; + + static final String winimage = winbase + "c-img" + space + someNumber + space; + static final String wincommitted = winbase + "(c-pvt|c-map)" + space + someNumber + space; + static final String winreserved = winbase + "r-pvt" + space + someNumber + space; + + static final String shouldMatchUnconditionally_windows[] = { + // java launcher + winimage + ".*[\\/\\\\]bin[\\/\\\\]java[.]exe", + // libjvm + winimage + ".*[\\/\\\\]bin[\\/\\\\].*[\\/\\\\]jvm.dll" + }; + + static final String shouldMatchIfNMTIsEnabled_windows[] = { + wincommitted + "JAVAHEAP.*", + // metaspace + wincommitted + "META.*", + // parts of metaspace should be uncommitted + winreserved + "META.*", + // code cache + wincommitted + "CODE.*", + // Main thread stack + wincommitted + "STACK-\\d+-main.*" + }; + + public String[] shouldMatchUnconditionally() { + return shouldMatchUnconditionally_windows; + } + + public String[] shouldMatchIfNMTIsEnabled() { + return shouldMatchIfNMTIsEnabled_windows; + } + }; + private static class MacOSPatterns implements MapPatterns { + + // macOS: + static final String macprot = "[\\-rwx]*/[\\-rwx]*"; + + static final String macow = "cow"; + static final String macprivate = "pvt"; + static final String macprivate_or_shared = "(pvt|tsh-shared)"; + static final String macprivatealiased = "p/a"; + + static final String macOSbase = range + space + someSize + space + macprot + space; + + static final String shouldMatchUnconditionally_macOS[] = { + // java launcher + macOSbase + macow + space + someNumber + space + "/.*/bin/java", + // libjvm + macOSbase + macow + space + someNumber + space + "/.*/lib/server/libjvm.dylib", + // we should see the hs-perf data file, and it should appear as shared as well as committed + macOSbase + macprivate + space + someNumber + space + ".*/.*/hsperfdata_.*" + }; + + static final String shouldMatchIfNMTIsEnabled_macOS[] = { + // heap is private with G1GC, shared with ZGC + macOSbase + macprivate_or_shared + space + someNumber + space + "JAVAHEAP.*", + // metaspace + macOSbase + macprivate + space + someNumber + space + "META.*", + // code cache + macOSbase + macprivate + space + someNumber + space + "CODE.*", + // Main thread stack + macOSbase + macprivatealiased + space + someNumber + space + "STACK-.*-main.*" + }; + + public String[] shouldMatchUnconditionally() { + return shouldMatchUnconditionally_macOS; + } + + public String[] shouldMatchIfNMTIsEnabled() { + return shouldMatchIfNMTIsEnabled_macOS; + } + }; }