diff --git a/.hgtags b/.hgtags index e0803eae99265867ea73726baeedeeaf769e1eff..8425efb288a5998af65d1c89962ed60d7ab5a5bd 100644 --- a/.hgtags +++ b/.hgtags @@ -1289,6 +1289,11 @@ ce42ae95d4d671f74246091f89bd101d5bcbfd91 jdk8u242-b01 775e2bf92114e41365cc6baf1480c818454256a4 jdk8u242-b02 ee19c358e3b8deeda2f64d660a0870df7b1abd49 jdk8u242-b03 20258ba5a788da55485c0648bcc073f8ad2c26ef jdk8u242-b04 +2c1e9fab6964647f4eeffe55fe5592da6399a3ce jdk8u242-b05 +81ddc1072b923330f84c0ace3124226f63877582 jdk8u242-b06 +8b80409d5840142a27e274d33948f483a6406a50 jdk8u242-b07 +7c9f6b5f8d119dc1ba3c5536595ce3ae7414599d jdk8u242-b08 +7c9f6b5f8d119dc1ba3c5536595ce3ae7414599d jdk8u242-ga 8c0733543544bbcd32c4404630d764d280299056 jdk8u252-b00 a67e9c6edcdd73cb860a16990f0905e102c282d7 jdk8u252-b01 5bd3b8c0555292a967ea3b4c39a220d0c2cf40ad jdk8u252-b02 diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README index 3f187565673839857a8fe8bdfb44d3c140cd56c6..a9adb432a31f43a999dd7b8ae83677affe512e1b 100644 --- a/THIRD_PARTY_README +++ b/THIRD_PARTY_README @@ -1334,11 +1334,13 @@ SUCH DAMAGE. -------------------------------------------------------------------------------- -%% This notice is provided with respect to Joni v1.1.9, which may be +%% This notice is provided with respect to Joni v2.1.16, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- +Copyright (c) 2017 JRuby Team + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/src/cpu/sparc/vm/vm_version_sparc.cpp b/src/cpu/sparc/vm/vm_version_sparc.cpp index 793dc184a8234e0f6aca55e37aef73cc0b40a990..d7240e87693f245551b01beeae76d3e74d365a30 100644 --- a/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -286,35 +286,35 @@ void VM_Version::initialize() { // SPARC T4 and above should have support for AES instructions if (has_aes()) { - if (UseVIS > 2) { // AES intrinsics use MOVxTOd/MOVdTOx which are VIS3 - if (FLAG_IS_DEFAULT(UseAES)) { - FLAG_SET_DEFAULT(UseAES, true); - } - if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { - FLAG_SET_DEFAULT(UseAESIntrinsics, true); - } - // we disable both the AES flags if either of them is disabled on the command line - if (!UseAES || !UseAESIntrinsics) { - FLAG_SET_DEFAULT(UseAES, false); - FLAG_SET_DEFAULT(UseAESIntrinsics, false); + if (FLAG_IS_DEFAULT(UseAES)) { + FLAG_SET_DEFAULT(UseAES, true); + } + if (!UseAES) { + if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { + warning("AES intrinsics require UseAES flag to be enabled. Intrinsics will be disabled."); } + FLAG_SET_DEFAULT(UseAESIntrinsics, false); } else { - if (UseAES || UseAESIntrinsics) { - warning("SPARC AES intrinsics require VIS3 instruction support. Intrinsics will be disabled."); - if (UseAES) { - FLAG_SET_DEFAULT(UseAES, false); - } - if (UseAESIntrinsics) { - FLAG_SET_DEFAULT(UseAESIntrinsics, false); - } + // The AES intrinsic stubs require AES instruction support (of course) + // but also require VIS3 mode or higher for instructions it use. + if (UseVIS > 2) { + if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { + FLAG_SET_DEFAULT(UseAESIntrinsics, true); + } + } else { + if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { + warning("SPARC AES intrinsics require VIS3 instructions. Intrinsics will be disabled."); } + FLAG_SET_DEFAULT(UseAESIntrinsics, false); + } } } else if (UseAES || UseAESIntrinsics) { - warning("AES instructions are not available on this CPU"); - if (UseAES) { + if (UseAES && !FLAG_IS_DEFAULT(UseAES)) { + warning("AES instructions are not available on this CPU"); FLAG_SET_DEFAULT(UseAES, false); } - if (UseAESIntrinsics) { + if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { + warning("AES intrinsics are not available on this CPU"); FLAG_SET_DEFAULT(UseAESIntrinsics, false); } } diff --git a/src/cpu/x86/vm/vm_version_x86.cpp b/src/cpu/x86/vm/vm_version_x86.cpp index 1f5ae757a3d4423387f78b02b236585547c3b1f8..3a4246c681633263f017fb97e87345d5ee29727c 100644 --- a/src/cpu/x86/vm/vm_version_x86.cpp +++ b/src/cpu/x86/vm/vm_version_x86.cpp @@ -553,12 +553,36 @@ void VM_Version::get_processor_features() { // Use AES instructions if available. if (supports_aes()) { if (FLAG_IS_DEFAULT(UseAES)) { - UseAES = true; + FLAG_SET_DEFAULT(UseAES, true); } - } else if (UseAES) { - if (!FLAG_IS_DEFAULT(UseAES)) + if (!UseAES) { + if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { + warning("AES intrinsics require UseAES flag to be enabled. Intrinsics will be disabled."); + } + FLAG_SET_DEFAULT(UseAESIntrinsics, false); + } else { + if (UseSSE > 2) { + if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { + FLAG_SET_DEFAULT(UseAESIntrinsics, true); + } + } else { + // The AES intrinsic stubs require AES instruction support (of course) + // but also require sse3 mode or higher for instructions it use. + if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { + warning("X86 AES intrinsics require SSE3 instructions or higher. Intrinsics will be disabled."); + } + FLAG_SET_DEFAULT(UseAESIntrinsics, false); + } + } + } else if (UseAES || UseAESIntrinsics) { + if (UseAES && !FLAG_IS_DEFAULT(UseAES)) { warning("AES instructions are not available on this CPU"); - FLAG_SET_DEFAULT(UseAES, false); + FLAG_SET_DEFAULT(UseAES, false); + } + if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { + warning("AES intrinsics are not available on this CPU"); + FLAG_SET_DEFAULT(UseAESIntrinsics, false); + } } // Use CLMUL instructions if available. @@ -582,18 +606,6 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseCRC32Intrinsics, false); } - // The AES intrinsic stubs require AES instruction support (of course) - // but also require sse3 mode for instructions it use. - if (UseAES && (UseSSE > 2)) { - if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { - UseAESIntrinsics = true; - } - } else if (UseAESIntrinsics) { - if (!FLAG_IS_DEFAULT(UseAESIntrinsics)) - warning("AES intrinsics are not available on this CPU"); - FLAG_SET_DEFAULT(UseAESIntrinsics, false); - } - // GHASH/GCM intrinsics if (UseCLMUL && (UseSSE > 2)) { if (FLAG_IS_DEFAULT(UseGHASHIntrinsics)) { diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp index e5a3a1106972077c3963156870d52f70601f3778..2a2faa69ae8cd870f5d366013ed9aa88eb41012f 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp @@ -161,6 +161,8 @@ CompactibleFreeListSpace::CompactibleFreeListSpace(BlockOffsetSharedArray* bs, } _dictionary->set_par_lock(&_parDictionaryAllocLock); } + + _used_stable = 0; } // Like CompactibleSpace forward() but always calls cross_threshold() to @@ -377,6 +379,14 @@ size_t CompactibleFreeListSpace::used() const { return capacity() - free(); } +size_t CompactibleFreeListSpace::used_stable() const { + return _used_stable; +} + +void CompactibleFreeListSpace::recalculate_used_stable() { + _used_stable = used(); +} + size_t CompactibleFreeListSpace::free() const { // "MT-safe, but not MT-precise"(TM), if you will: i.e. // if you do this while the structures are in flux you @@ -1218,6 +1228,13 @@ HeapWord* CompactibleFreeListSpace::allocate(size_t size) { debug_only(fc->mangleAllocated(size)); } + // During GC we do not need to recalculate the stable used value for + // every allocation in old gen. It is done once at the end of GC instead + // for performance reasons. + if (!Universe::heap()->is_gc_active()) { + recalculate_used_stable(); + } + return res; } diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp index 7269068f630ef6c7d52771caf158e27e7b19ff67..121299d4bcee118c3c36d7e8472c36fd2af165ca 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp @@ -148,6 +148,9 @@ class CompactibleFreeListSpace: public CompactibleSpace { // Used to keep track of limit of sweep for the space HeapWord* _sweep_limit; + // Stable value of used(). + size_t _used_stable; + // Support for compacting cms HeapWord* cross_threshold(HeapWord* start, HeapWord* end); HeapWord* forward(oop q, size_t size, CompactPoint* cp, HeapWord* compact_top); @@ -343,6 +346,17 @@ class CompactibleFreeListSpace: public CompactibleSpace { // which overestimates the region by returning the entire // committed region (this is safe, but inefficient). + // Returns monotonically increasing stable used space bytes for CMS. + // This is required for jstat and other memory monitoring tools + // that might otherwise see inconsistent used space values during a garbage + // collection, promotion or allocation into compactibleFreeListSpace. + // The value returned by this function might be smaller than the + // actual value. + size_t used_stable() const; + // Recalculate and cache the current stable used() value. Only to be called + // in places where we can be sure that the result is stable. + void recalculate_used_stable(); + // Returns a subregion of the space containing all the objects in // the space. MemRegion used_region() const { diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 1872e72e3631811d6bc0ac447018d09430921cd0..e7228d31305c61acd3504c33bd5cfb05a4311dd9 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -869,6 +869,10 @@ ConcurrentMarkSweepGeneration::unsafe_max_alloc_nogc() const { return _cmsSpace->max_alloc_in_words() * HeapWordSize; } +size_t ConcurrentMarkSweepGeneration::used_stable() const { + return cmsSpace()->used_stable(); +} + size_t ConcurrentMarkSweepGeneration::max_available() const { return free() + _virtual_space.uncommitted_size(); } @@ -1955,6 +1959,8 @@ void CMSCollector::compute_new_size() { FreelistLocker z(this); MetaspaceGC::compute_new_size(); _cmsGen->compute_new_size_free_list(); + // recalculate CMS used space after CMS collection + _cmsGen->cmsSpace()->recalculate_used_stable(); } // A work method used by foreground collection to determine @@ -2768,6 +2774,7 @@ void ConcurrentMarkSweepGeneration::gc_prologue(bool full) { _capacity_at_prologue = capacity(); _used_at_prologue = used(); + _cmsSpace->recalculate_used_stable(); // Delegate to CMScollector which knows how to coordinate between // this and any other CMS generations that it is responsible for @@ -2837,6 +2844,7 @@ void CMSCollector::gc_epilogue(bool full) { _eden_chunk_index = 0; size_t cms_used = _cmsGen->cmsSpace()->used(); + _cmsGen->cmsSpace()->recalculate_used_stable(); // update performance counters - this uses a special version of // update_counters() that allows the utilization to be passed as a @@ -3672,6 +3680,7 @@ void CMSCollector::checkpointRootsInitial(bool asynch) { _collectorState = Marking; } SpecializationStats::print(); + _cmsGen->cmsSpace()->recalculate_used_stable(); } void CMSCollector::checkpointRootsInitialWork(bool asynch) { @@ -5066,10 +5075,12 @@ void CMSCollector::checkpointRootsFinal(bool asynch, Mutex::_no_safepoint_check_flag); assert(!init_mark_was_synchronous, "but that's impossible!"); checkpointRootsFinalWork(asynch, clear_all_soft_refs, false); + _cmsGen->cmsSpace()->recalculate_used_stable(); } else { // already have all the locks checkpointRootsFinalWork(asynch, clear_all_soft_refs, init_mark_was_synchronous); + _cmsGen->cmsSpace()->recalculate_used_stable(); } verify_work_stacks_empty(); verify_overflow_empty(); @@ -6368,6 +6379,10 @@ void CMSCollector::sweep(bool asynch) { // Update heap occupancy information which is used as // input to soft ref clearing policy at the next gc. Universe::update_heap_info_at_gc(); + + // recalculate CMS used space after CMS collection + _cmsGen->cmsSpace()->recalculate_used_stable(); + _collectorState = Resizing; } } else { @@ -6467,6 +6482,7 @@ void ConcurrentMarkSweepGeneration::update_gc_stats(int current_level, // Gather statistics on the young generation collection. collector()->stats().record_gc0_end(used()); } + _cmsSpace->recalculate_used_stable(); } CMSAdaptiveSizePolicy* ConcurrentMarkSweepGeneration::size_policy() { diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index a6d06a5dc5a1c9bcff97798efc28910b9e09441d..a023b9fb9e720872236602a1a59ba4cbfe24c3f4 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -1190,6 +1190,7 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { double occupancy() const { return ((double)used())/((double)capacity()); } size_t contiguous_available() const; size_t unsafe_max_alloc_nogc() const; + size_t used_stable() const; // over-rides MemRegion used_region() const; diff --git a/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp b/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp index 7a5fdf9ee57614d32f15cf6d7c2deda0daba9da6..b03430e2700280ac4cfd82c522291388993a870b 100644 --- a/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp +++ b/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp @@ -63,7 +63,7 @@ class GSpaceCounters: public CHeapObj { } inline void update_used() { - _used->set_value(_gen->used()); + _used->set_value(_gen->used_stable()); } // special version of update_used() to allow the used value to be @@ -107,7 +107,7 @@ class GenerationUsedHelper : public PerfLongSampleHelper { GenerationUsedHelper(Generation* g) : _gen(g) { } inline jlong take_sample() { - return _gen->used(); + return _gen->used_stable(); } }; diff --git a/src/share/vm/memory/generation.cpp b/src/share/vm/memory/generation.cpp index 3c45a9192962f5ae0cb79bdf7660ae43b9ddd037..dc4ac0869c7690219b0ca11e0df9ecd0bc4382a3 100644 --- a/src/share/vm/memory/generation.cpp +++ b/src/share/vm/memory/generation.cpp @@ -68,6 +68,12 @@ GenerationSpec* Generation::spec() { return gch->_gen_specs[level()]; } +// This is for CMS. It returns stable monotonic used space size. +// Remove this when CMS is removed. +size_t Generation::used_stable() const { + return used(); +} + size_t Generation::max_capacity() const { return reserved().byte_size(); } diff --git a/src/share/vm/memory/generation.hpp b/src/share/vm/memory/generation.hpp index 63dccb70fb6823957de36eded6a30a2ef3652a87..ca3fe949d8e13f87a82d57bed619256a559fe750 100644 --- a/src/share/vm/memory/generation.hpp +++ b/src/share/vm/memory/generation.hpp @@ -168,6 +168,7 @@ class Generation: public CHeapObj { virtual size_t capacity() const = 0; // The maximum number of object bytes the // generation can currently hold. virtual size_t used() const = 0; // The number of used bytes in the gen. + virtual size_t used_stable() const; // The number of used bytes for memory monitoring tools. virtual size_t free() const = 0; // The number of free bytes in the gen. // Support for java.lang.Runtime.maxMemory(); see CollectedHeap. diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp index 0204188adc6e577658d32c9f61e8e322263be45b..4c973d38bb17d8c339d286bb5e716af0b6fd1609 100644 --- a/src/share/vm/oops/instanceKlass.cpp +++ b/src/share/vm/oops/instanceKlass.cpp @@ -294,6 +294,7 @@ InstanceKlass::InstanceKlass(int vtable_len, set_has_unloaded_dependent(false); set_init_state(InstanceKlass::allocated); set_init_thread(NULL); + set_init_state(allocated); set_reference_type(rt); set_oop_map_cache(NULL); set_jni_ids(NULL); @@ -978,11 +979,13 @@ void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle oop init_lock = this_oop->init_lock(); if (init_lock != NULL) { ObjectLocker ol(init_lock, THREAD); + this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state this_oop->set_init_state(state); this_oop->fence_and_clear_init_lock(); ol.notify_all(CHECK); } else { assert(init_lock != NULL, "The initialization state should never be set twice"); + this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state this_oop->set_init_state(state); } } @@ -3602,6 +3605,7 @@ void InstanceKlass::set_init_state(ClassState state) { bool good_state = is_shared() ? (_init_state <= state) : (_init_state < state); assert(good_state || state == allocated, "illegal state transition"); + assert(_init_thread == NULL, "should be cleared before state change"); _init_state = (u1)state; } #endif diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp index 444eadd38ada8f1958a339a06125b4ef5fdf6549..49d55282211332abe4f222af9591c19c3725437d 100644 --- a/src/share/vm/oops/instanceKlass.hpp +++ b/src/share/vm/oops/instanceKlass.hpp @@ -241,7 +241,7 @@ class InstanceKlass: public Klass { u2 _misc_flags; u2 _minor_version; // minor version number of class file u2 _major_version; // major version number of class file - Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) + Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization) int _vtable_len; // length of Java vtable (in words) int _itable_len; // length of Java itable (in words) OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily) diff --git a/src/share/vm/oops/klassVtable.cpp b/src/share/vm/oops/klassVtable.cpp index 61dd4c21db6530d2d1604a9158c067659c18ff71..b3f477cd07cf91d12a850b3b72daf47ffba7eac9 100644 --- a/src/share/vm/oops/klassVtable.cpp +++ b/src/share/vm/oops/klassVtable.cpp @@ -289,22 +289,25 @@ InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) { InstanceKlass* superk = initialsuper; while (superk != NULL && superk->super() != NULL) { - InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super()); - klassVtable* ssVtable = supersuperklass->vtable(); + klassVtable* ssVtable = (superk->super())->vtable(); if (vtable_index < ssVtable->length()) { Method* super_method = ssVtable->method_at(vtable_index); + // get the class holding the matching method + // make sure you use that class for is_override + InstanceKlass* supermethodholder = super_method->method_holder(); #ifndef PRODUCT Symbol* name= target_method()->name(); Symbol* signature = target_method()->signature(); assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch"); #endif - if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) { + + if (supermethodholder->is_override(super_method, target_loader, target_classname, THREAD)) { #ifndef PRODUCT if (PrintVtables && Verbose) { ResourceMark rm(THREAD); char* sig = target_method()->name_and_sig_as_C_string(); tty->print("transitive overriding superclass %s with %s::%s index %d, original flags: ", - supersuperklass->internal_name(), + supermethodholder->internal_name(), _klass->internal_name(), sig, vtable_index); super_method->access_flags().print_on(tty); if (super_method->is_default_method()) { @@ -656,7 +659,7 @@ bool klassVtable::needs_new_vtable_entry(methodHandle target_method, // search through the super class hierarchy to see if we need // a new entry - ResourceMark rm; + ResourceMark rm(THREAD); Symbol* name = target_method()->name(); Symbol* signature = target_method()->signature(); Klass* k = super; diff --git a/src/share/vm/services/memoryPool.hpp b/src/share/vm/services/memoryPool.hpp index 007366e0bd6c5644cb17a62c23a61c431b9244fd..157b54e73311d00068cad998cb45ad0cb1658004 100644 --- a/src/share/vm/services/memoryPool.hpp +++ b/src/share/vm/services/memoryPool.hpp @@ -198,7 +198,7 @@ public: bool support_usage_threshold); MemoryUsage get_memory_usage(); - size_t used_in_bytes() { return _space->used(); } + size_t used_in_bytes() { return _space->used_stable(); } }; #endif // INCLUDE_ALL_GCS diff --git a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java index 6fbaf9cef72e8f46269a9e56fecc922cac9490a6..9ff45492f468b0674619600fb99bbe4ba614d670 100644 --- a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java +++ b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java @@ -22,9 +22,10 @@ */ import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; import sun.misc.IOUtils; +import sun.misc.Unsafe; +import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; @@ -108,7 +109,13 @@ public class TestAnonymousClassUnloading { // (1) Load an anonymous version of this class using the corresponding Unsafe method URL classUrl = TestAnonymousClassUnloading.class.getResource("TestAnonymousClassUnloading.class"); URLConnection connection = classUrl.openConnection(); - byte[] classBytes = IOUtils.readFully(connection.getInputStream(), connection.getContentLength(), true); + + int length = connection.getContentLength(); + byte[] classBytes = IOUtils.readAllBytes(connection.getInputStream()); + if (length != -1 && classBytes.length != length) { + throw new IOException("Expected:" + length + ", actual: " + classBytes.length); + } + Class anonymousClass = UNSAFE.defineAnonymousClass(TestAnonymousClassUnloading.class, classBytes, null); // (2) Make sure all paths of doWork are profiled and compiled diff --git a/test/runtime/8003720/VictimClassLoader.java b/test/runtime/8003720/VictimClassLoader.java index 3505f7832f39b6dafa41354a630e43a674252ac7..e219fd60f9edb6fec7c97b76567e489c16f8a7e9 100644 --- a/test/runtime/8003720/VictimClassLoader.java +++ b/test/runtime/8003720/VictimClassLoader.java @@ -22,6 +22,8 @@ * */ +import sun.misc.IOUtils; + public class VictimClassLoader extends ClassLoader { public static long counter = 0; @@ -72,8 +74,10 @@ public class VictimClassLoader extends ClassLoader { } static byte[] readFully(java.io.InputStream in, int len) throws java.io.IOException { - // Warning here: - return sun.misc.IOUtils.readFully(in, len, true); + byte[] b = IOUtils.readAllBytes(in); + if (len != -1 && b.length != len) + throw new java.io.IOException("Expected:" + len + ", actual:" + b.length); + return b; } public void finalize() { diff --git a/test/runtime/RedefineTests/test8178870.sh b/test/runtime/RedefineTests/test8178870.sh deleted file mode 100644 index 4a90e2655931e4f4bb436200251983cf466e5797..0000000000000000000000000000000000000000 --- a/test/runtime/RedefineTests/test8178870.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2019, Red Hat, Inc. All rights reserved. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -## @test test.sh -## @bug 8178870 -## @summary test instrumentation.retransformClasses -## @run shell test.sh - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../test_env.sh - -LIB_SRC=${TESTSRC}/../../testlibrary/ - -# set platform-dependent variables -OS=`uname -s` -echo "Testing on " $OS -case "$OS" in - Linux) - cc_cmd=`which gcc` - if [ "x$cc_cmd" == "x" ]; then - echo "WARNING: gcc not found. Cannot execute test." 2>&1 - exit 0; - fi - ;; - Solaris) - cc_cmd=`which cc` - if [ "x$cc_cmd" == "x" ]; then - echo "WARNING: cc not found. Cannot execute test." 2>&1 - exit 0; - fi - ;; - *) - echo "Test passed. Only on Linux and Solaris" - exit 0; - ;; -esac - -THIS_DIR=. - -cp ${TESTSRC}/RedefineDoubleDelete.java ${THIS_DIR} -mkdir -p ${THIS_DIR}/classes -${TESTJAVA}/bin/javac -sourcepath ${LIB_SRC} -d ${THIS_DIR}/classes ${LIB_SRC}RedefineClassHelper.java -${TESTJAVA}/bin/javac -cp .:${THIS_DIR}/classes:${TESTJAVA}/lib/tools.jar -d ${THIS_DIR} RedefineDoubleDelete.java - -$cc_cmd -fPIC -shared -o ${THIS_DIR}${FS}libRedefineDoubleDelete.so \ - -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \ - ${TESTSRC}/libRedefineDoubleDelete.c - -LD_LIBRARY_PATH=${THIS_DIR} -echo LD_LIBRARY_PATH = ${LD_LIBRARY_PATH} -export LD_LIBRARY_PATH - -# Install redefineagent.jar -${TESTJAVA}/bin${FS}java -cp ${THIS_DIR}/classes RedefineClassHelper - -echo -echo ${TESTJAVA}/bin/java -agentlib:RedefineDoubleDelete RedefineDoubleDelete -${TESTJAVA}/bin/java -cp .:${THIS_DIR}${FS}classes -javaagent:redefineagent.jar -agentlib:RedefineDoubleDelete RedefineDoubleDelete -