Fri, 20 Jul 2018 05:44:33 -0700
Merge
1.1 --- a/make/linux/makefiles/defs.make Thu Jul 19 10:00:36 2018 +0100 1.2 +++ b/make/linux/makefiles/defs.make Fri Jul 20 05:44:33 2018 -0700 1.3 @@ -239,10 +239,12 @@ 1.4 # client and server subdirectories have symbolic links to ../libjsig.so 1.5 EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX) 1.6 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.7 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.8 - EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.diz 1.9 - else 1.10 - EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.debuginfo 1.11 + ifneq ($(STRIP_POLICY),no_strip) 1.12 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.13 + EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.diz 1.14 + else 1.15 + EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.debuginfo 1.16 + endif 1.17 endif 1.18 endif 1.19 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server 1.20 @@ -253,10 +255,12 @@ 1.21 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt 1.22 EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX) 1.23 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.24 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.25 - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz 1.26 - else 1.27 - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo 1.28 + ifneq ($(STRIP_POLICY),no_strip) 1.29 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.30 + EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz 1.31 + else 1.32 + EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo 1.33 + endif 1.34 endif 1.35 endif 1.36 endif 1.37 @@ -265,10 +269,12 @@ 1.38 EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt 1.39 EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) 1.40 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.41 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.42 - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz 1.43 - else 1.44 - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo 1.45 + ifneq ($(STRIP_POLICY),no_strip) 1.46 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.47 + EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz 1.48 + else 1.49 + EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo 1.50 + endif 1.51 endif 1.52 endif 1.53 endif 1.54 @@ -278,10 +284,12 @@ 1.55 EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX) 1.56 1.57 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.58 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.59 - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.diz 1.60 - else 1.61 - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo 1.62 + ifneq ($(STRIP_POLICY),no_strip) 1.63 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.64 + EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.diz 1.65 + else 1.66 + EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo 1.67 + endif 1.68 endif 1.69 endif 1.70 endif 1.71 @@ -293,12 +301,14 @@ 1.72 ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \ 1.73 $(EXPORT_LIB_DIR)/sa-jdi.jar 1.74 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 1.75 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.76 - ADD_SA_BINARIES/x86 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz 1.77 - ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz 1.78 - else 1.79 - ADD_SA_BINARIES/x86 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo 1.80 - ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo 1.81 + ifneq ($(STRIP_POLICY),no_strip) 1.82 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 1.83 + ADD_SA_BINARIES/x86 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz 1.84 + ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz 1.85 + else 1.86 + ADD_SA_BINARIES/x86 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo 1.87 + ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo 1.88 + endif 1.89 endif 1.90 endif 1.91 ADD_SA_BINARIES/ppc =
2.1 --- a/make/linux/makefiles/jsig.make Thu Jul 19 10:00:36 2018 +0100 2.2 +++ b/make/linux/makefiles/jsig.make Fri Jul 20 05:44:33 2018 -0700 2.3 @@ -56,20 +56,23 @@ 2.4 $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ 2.5 $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(EXTRA_CFLAGS) -o $@ $< -ldl 2.6 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 2.7 + ifneq ($(STRIP_POLICY),no_strip) 2.8 $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO) 2.9 + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ 2.10 + endif 2.11 ifeq ($(STRIP_POLICY),all_strip) 2.12 - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ 2.13 $(QUIETLY) $(STRIP) $@ 2.14 else 2.15 ifeq ($(STRIP_POLICY),min_strip) 2.16 - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ 2.17 $(QUIETLY) $(STRIP) -g $@ 2.18 endif 2.19 # implied else here is no stripping at all 2.20 endif 2.21 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 2.22 + ifneq ($(STRIP_POLICY),no_strip) 2.23 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 2.24 $(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO) 2.25 $(RM) $(LIBJSIG_DEBUGINFO) 2.26 + endif 2.27 endif 2.28 endif 2.29
3.1 --- a/make/linux/makefiles/saproc.make Thu Jul 19 10:00:36 2018 +0100 3.2 +++ b/make/linux/makefiles/saproc.make Fri Jul 20 05:44:33 2018 -0700 3.3 @@ -99,20 +99,23 @@ 3.4 -o $@ \ 3.5 -lthread_db 3.6 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 3.7 + ifneq ($(STRIP_POLICY),no_strip) 3.8 $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO) 3.9 + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@ 3.10 + endif 3.11 ifeq ($(STRIP_POLICY),all_strip) 3.12 - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@ 3.13 $(QUIETLY) $(STRIP) $@ 3.14 else 3.15 ifeq ($(STRIP_POLICY),min_strip) 3.16 - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@ 3.17 $(QUIETLY) $(STRIP) -g $@ 3.18 endif 3.19 # implied else here is no stripping at all 3.20 endif 3.21 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 3.22 + ifneq ($(STRIP_POLICY),no_strip) 3.23 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 3.24 $(ZIPEXE) -q -y $(LIBSAPROC_DIZ) $(LIBSAPROC_DEBUGINFO) 3.25 $(RM) $(LIBSAPROC_DEBUGINFO) 3.26 + endif 3.27 endif 3.28 endif 3.29
4.1 --- a/make/linux/makefiles/vm.make Thu Jul 19 10:00:36 2018 +0100 4.2 +++ b/make/linux/makefiles/vm.make Fri Jul 20 05:44:33 2018 -0700 4.3 @@ -357,20 +357,23 @@ 4.4 } 4.5 4.6 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) 4.7 + ifneq ($(STRIP_POLICY),no_strip) 4.8 $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) 4.9 + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ 4.10 + endif 4.11 ifeq ($(STRIP_POLICY),all_strip) 4.12 - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ 4.13 $(QUIETLY) $(STRIP) $@ 4.14 else 4.15 ifeq ($(STRIP_POLICY),min_strip) 4.16 - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ 4.17 $(QUIETLY) $(STRIP) -g $@ 4.18 endif 4.19 # implied else here is no stripping at all 4.20 endif 4.21 - ifeq ($(ZIP_DEBUGINFO_FILES),1) 4.22 + ifneq ($(STRIP_POLICY),no_strip) 4.23 + ifeq ($(ZIP_DEBUGINFO_FILES),1) 4.24 $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) 4.25 $(RM) $(LIBJVM_DEBUGINFO) 4.26 + endif 4.27 endif 4.28 endif 4.29
5.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Thu Jul 19 10:00:36 2018 +0100 5.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Fri Jul 20 05:44:33 2018 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -135,9 +135,16 @@ 5.11 MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations); 5.12 { 5.13 G1RootProcessor root_processor(g1h); 5.14 - root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, 5.15 - &GenMarkSweep::follow_cld_closure, 5.16 - &follow_code_closure); 5.17 + if (ClassUnloading) { 5.18 + root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, 5.19 + &GenMarkSweep::follow_cld_closure, 5.20 + &follow_code_closure); 5.21 + } else { 5.22 + root_processor.process_all_roots_no_string_table( 5.23 + &GenMarkSweep::follow_root_closure, 5.24 + &GenMarkSweep::follow_cld_closure, 5.25 + &follow_code_closure); 5.26 + } 5.27 } 5.28 5.29 // Process reference objects found during marking 5.30 @@ -158,15 +165,17 @@ 5.31 // This is the point where the entire marking should have completed. 5.32 assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed"); 5.33 5.34 - // Unload classes and purge the SystemDictionary. 5.35 - bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); 5.36 + if (ClassUnloading) { 5.37 5.38 - // Unload nmethods. 5.39 - CodeCache::do_unloading(&GenMarkSweep::is_alive, purged_class); 5.40 + // Unload classes and purge the SystemDictionary. 5.41 + bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); 5.42 5.43 - // Prune dead klasses from subklass/sibling/implementor lists. 5.44 - Klass::clean_weak_klass_links(&GenMarkSweep::is_alive); 5.45 + // Unload nmethods. 5.46 + CodeCache::do_unloading(&GenMarkSweep::is_alive, purged_class); 5.47 5.48 + // Prune dead klasses from subklass/sibling/implementor lists. 5.49 + Klass::clean_weak_klass_links(&GenMarkSweep::is_alive); 5.50 + } 5.51 // Delete entries for dead interned string and clean up unreferenced symbols in symbol table. 5.52 G1CollectedHeap::heap()->unlink_string_and_symbol_table(&GenMarkSweep::is_alive); 5.53
6.1 --- a/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp Thu Jul 19 10:00:36 2018 +0100 6.2 +++ b/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp Fri Jul 20 05:44:33 2018 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -156,7 +156,7 @@ 6.11 } 6.12 6.13 process_vm_roots(strong_roots, weak_roots, phase_times, worker_i); 6.14 - 6.15 + process_string_table_roots(weak_roots, phase_times, worker_i); 6.16 { 6.17 // Now the CM ref_processor roots. 6.18 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CMRefRoots, worker_i); 6.19 @@ -223,18 +223,34 @@ 6.20 6.21 void G1RootProcessor::process_all_roots(OopClosure* oops, 6.22 CLDClosure* clds, 6.23 - CodeBlobClosure* blobs) { 6.24 + CodeBlobClosure* blobs, 6.25 + bool process_string_table) { 6.26 6.27 process_java_roots(oops, NULL, clds, clds, NULL, NULL, 0); 6.28 process_vm_roots(oops, oops, NULL, 0); 6.29 6.30 - if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { 6.31 - CodeCache::blobs_do(blobs); 6.32 - } 6.33 + if (process_string_table) { 6.34 + process_string_table_roots(oops, NULL, 0); 6.35 + } 6.36 + process_code_cache_roots(blobs, NULL, 0); 6.37 6.38 _process_strong_tasks.all_tasks_completed(); 6.39 } 6.40 6.41 +void G1RootProcessor::process_all_roots(OopClosure* oops, 6.42 + CLDClosure* clds, 6.43 + CodeBlobClosure* blobs) { 6.44 + process_all_roots(oops, clds, blobs, true); 6.45 +} 6.46 + 6.47 +void G1RootProcessor::process_all_roots_no_string_table(OopClosure* oops, 6.48 + CLDClosure* clds, 6.49 + CodeBlobClosure* blobs) { 6.50 + assert(!ClassUnloading, "Should only be used when class unloading is disabled"); 6.51 + process_all_roots(oops, clds, blobs, false); 6.52 +} 6.53 + 6.54 + 6.55 void G1RootProcessor::process_java_roots(OopClosure* strong_roots, 6.56 CLDClosure* thread_stack_clds, 6.57 CLDClosure* strong_clds, 6.58 @@ -311,14 +327,23 @@ 6.59 SystemDictionary::roots_oops_do(strong_roots, weak_roots); 6.60 } 6.61 } 6.62 +} 6.63 6.64 - { 6.65 - G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); 6.66 - // All threads execute the following. A specific chunk of buckets 6.67 - // from the StringTable are the individual tasks. 6.68 - if (weak_roots != NULL) { 6.69 - StringTable::possibly_parallel_oops_do(weak_roots); 6.70 - } 6.71 +void G1RootProcessor::process_string_table_roots(OopClosure* weak_roots, G1GCPhaseTimes* phase_times, 6.72 + uint worker_i) { 6.73 + assert(weak_roots != NULL, "Should only be called when all roots are processed"); 6.74 + 6.75 + G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); 6.76 + // All threads execute the following. A specific chunk of buckets 6.77 + // from the StringTable are the individual tasks. 6.78 + StringTable::possibly_parallel_oops_do(weak_roots); 6.79 +} 6.80 + 6.81 +void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure, 6.82 + G1GCPhaseTimes* phase_times, 6.83 + uint worker_i) { 6.84 + if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { 6.85 + CodeCache::blobs_do(code_closure); 6.86 } 6.87 } 6.88
7.1 --- a/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp Thu Jul 19 10:00:36 2018 +0100 7.2 +++ b/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp Fri Jul 20 05:44:33 2018 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -34,6 +34,7 @@ 7.11 class G1CollectedHeap; 7.12 class G1GCPhaseTimes; 7.13 class G1ParPushHeapRSClosure; 7.14 +class G1RootClosures; 7.15 class Monitor; 7.16 class OopClosure; 7.17 class SubTasksDone; 7.18 @@ -71,6 +72,11 @@ 7.19 void worker_has_discovered_all_strong_classes(); 7.20 void wait_until_all_strong_classes_discovered(); 7.21 7.22 + void process_all_roots(OopClosure* oops, 7.23 + CLDClosure* clds, 7.24 + CodeBlobClosure* blobs, 7.25 + bool process_string_table); 7.26 + 7.27 void process_java_roots(OopClosure* scan_non_heap_roots, 7.28 CLDClosure* thread_stack_clds, 7.29 CLDClosure* scan_strong_clds, 7.30 @@ -84,6 +90,14 @@ 7.31 G1GCPhaseTimes* phase_times, 7.32 uint worker_i); 7.33 7.34 + void process_string_table_roots(OopClosure* scan_non_heap_weak_roots, 7.35 + G1GCPhaseTimes* phase_times, 7.36 + uint worker_i); 7.37 + 7.38 + void process_code_cache_roots(CodeBlobClosure* code_closure, 7.39 + G1GCPhaseTimes* phase_times, 7.40 + uint worker_i); 7.41 + 7.42 public: 7.43 G1RootProcessor(G1CollectedHeap* g1h); 7.44 7.45 @@ -114,6 +128,13 @@ 7.46 OopClosure* scan_non_heap_weak_roots, 7.47 uint worker_i); 7.48 7.49 + // Apply oops, clds and blobs to strongly and weakly reachable roots in the system, 7.50 + // the only thing different from process_all_roots is that we skip the string table 7.51 + // to avoid keeping every string live when doing class unloading. 7.52 + void process_all_roots_no_string_table(OopClosure* oops, 7.53 + CLDClosure* clds, 7.54 + CodeBlobClosure* blobs); 7.55 + 7.56 // Inform the root processor about the number of worker threads 7.57 void set_num_workers(int active_workers); 7.58 };
8.1 --- a/src/share/vm/runtime/arguments.cpp Thu Jul 19 10:00:36 2018 +0100 8.2 +++ b/src/share/vm/runtime/arguments.cpp Fri Jul 20 05:44:33 2018 -0700 8.3 @@ -1377,11 +1377,6 @@ 8.4 CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight); 8.5 } 8.6 8.7 - if (!ClassUnloading) { 8.8 - FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); 8.9 - FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false); 8.10 - } 8.11 - 8.12 if (PrintGCDetails && Verbose) { 8.13 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk", 8.14 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); 8.15 @@ -1748,6 +1743,13 @@ 8.16 // Keeping the heap 100% free is hard ;-) so limit it to 99%. 8.17 FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); 8.18 } 8.19 + 8.20 + // If class unloading is disabled, also disable concurrent class unloading. 8.21 + if (!ClassUnloading) { 8.22 + FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); 8.23 + FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); 8.24 + FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false); 8.25 + } 8.26 #else // INCLUDE_ALL_GCS 8.27 assert(verify_serial_gc_flags(), "SerialGC unset"); 8.28 #endif // INCLUDE_ALL_GCS
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/gc/class_unloading/TestClassUnloadingDisabled.java Fri Jul 20 05:44:33 2018 -0700 9.3 @@ -0,0 +1,116 @@ 9.4 +/* 9.5 + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 +/* 9.28 + * @test 9.29 + * @key gc 9.30 + * @bug 8114823 9.31 + * @requires vm.gc == null 9.32 + * @requires vm.opt.ExplicitGCInvokesConcurrent != true 9.33 + * @requires vm.opt.ClassUnloading != true 9.34 + * @library /testlibrary /testlibrary/whitebox 9.35 + * @build sun.hotspot.WhiteBox 9.36 + * @run main ClassFileInstaller sun.hotspot.WhiteBox 9.37 + * sun.hotspot.WhiteBox$WhiteBoxPermission 9.38 + * 9.39 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 9.40 + * -XX:-ClassUnloading -XX:+UseG1GC TestClassUnloadingDisabled 9.41 + * 9.42 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 9.43 + * -XX:-ClassUnloading -XX:+UseSerialGC TestClassUnloadingDisabled 9.44 + * 9.45 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 9.46 + * -XX:-ClassUnloading -XX:+UseParallelGC TestClassUnloadingDisabled 9.47 + * 9.48 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 9.49 + * -XX:-ClassUnloading -XX:+UseConcMarkSweepGC TestClassUnloadingDisabled 9.50 + */ 9.51 + 9.52 +import java.io.File; 9.53 +import java.io.IOException; 9.54 +import java.nio.file.Files; 9.55 +import java.nio.file.Path; 9.56 +import java.nio.file.Paths; 9.57 + 9.58 +import sun.hotspot.WhiteBox; 9.59 + 9.60 +import com.oracle.java.testlibrary.Asserts; 9.61 + 9.62 +public class TestClassUnloadingDisabled { 9.63 + public static void main(String args[]) throws Exception { 9.64 + final WhiteBox wb = WhiteBox.getWhiteBox(); 9.65 + // Fetch the dir where the test class and the class 9.66 + // to be loaded resides. 9.67 + String classDir = TestClassUnloadingDisabled.class.getProtectionDomain().getCodeSource().getLocation().getPath(); 9.68 + String className = "ClassToLoadUnload"; 9.69 + 9.70 + Asserts.assertFalse(wb.isClassAlive(className), "Should not be loaded yet"); 9.71 + 9.72 + // The NoPDClassLoader handles loading classes in the test directory 9.73 + // and loads them without a protection domain, which in some cases 9.74 + // keeps the class live regardless of marking state. 9.75 + NoPDClassLoader nopd = new NoPDClassLoader(classDir); 9.76 + nopd.loadClass(className); 9.77 + 9.78 + Asserts.assertTrue(wb.isClassAlive(className), "Class should be loaded"); 9.79 + 9.80 + // Clear the class-loader, class and object references to make 9.81 + // class unloading possible. 9.82 + nopd = null; 9.83 + 9.84 + System.gc(); 9.85 + Asserts.assertTrue(wb.isClassAlive(className), "Class should not have ben unloaded"); 9.86 + } 9.87 +} 9.88 + 9.89 +class NoPDClassLoader extends ClassLoader { 9.90 + String path; 9.91 + 9.92 + NoPDClassLoader(String path) { 9.93 + this.path = path; 9.94 + } 9.95 + 9.96 + public Class<?> loadClass(String name) throws ClassNotFoundException { 9.97 + byte[] cls = null; 9.98 + File f = new File(path,name + ".class"); 9.99 + 9.100 + // Delegate class loading if class not present in the given 9.101 + // directory. 9.102 + if (!f.exists()) { 9.103 + return super.loadClass(name); 9.104 + } 9.105 + 9.106 + try { 9.107 + Path path = Paths.get(f.getAbsolutePath()); 9.108 + cls = Files.readAllBytes(path); 9.109 + } catch (IOException e) { 9.110 + throw new ClassNotFoundException(name); 9.111 + } 9.112 + 9.113 + // Define class with no protection domain and resolve it. 9.114 + return defineClass(name, cls, 0, cls.length, null); 9.115 + } 9.116 +} 9.117 + 9.118 +class ClassToLoadUnload { 9.119 +}