--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -211,9 +211,14 @@
if (borrow_reg) {
// No free registers available. Make one useful.
tmp = rscratch1;
+ if (tmp == dst) {
+ tmp = rscratch2;
+ }
__ push(RegSet::of(tmp), sp);
}
+ assert_different_registers(tmp, dst);
+
Label done;
__ ldr(tmp, Address(dst, oopDesc::mark_offset_in_bytes()));
__ eon(tmp, tmp, zr);
--- a/src/hotspot/cpu/ppc/c2_globals_ppc.hpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/cpu/ppc/c2_globals_ppc.hpp Mon Sep 30 21:16:42 2019 +0200
@@ -82,9 +82,9 @@
define_pd_global(bool, IdealizeClearArrayNode, true);
define_pd_global(uintx, InitialCodeCacheSize, 2048*K); // Integral multiple of CodeCacheExpansionSize
-define_pd_global(uintx, ReservedCodeCacheSize, 256*M);
-define_pd_global(uintx, NonProfiledCodeHeapSize, 125*M);
-define_pd_global(uintx, ProfiledCodeHeapSize, 126*M);
+define_pd_global(uintx, ReservedCodeCacheSize, 48*M);
+define_pd_global(uintx, NonProfiledCodeHeapSize, 21*M);
+define_pd_global(uintx, ProfiledCodeHeapSize, 22*M);
define_pd_global(uintx, NonNMethodCodeHeapSize, 5*M );
define_pd_global(uintx, CodeCacheExpansionSize, 64*K);
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -271,9 +271,14 @@
if (borrow_reg) {
// No free registers available. Make one useful.
tmp = LP64_ONLY(rscratch1) NOT_LP64(rdx);
+ if (tmp == dst) {
+ tmp = LP64_ONLY(rscratch2) NOT_LP64(rcx);
+ }
__ push(tmp);
}
+ assert_different_registers(dst, tmp);
+
Label done;
__ movptr(tmp, Address(dst, oopDesc::mark_offset_in_bytes()));
__ notptr(tmp);
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -38,6 +38,7 @@
#include "opto/movenode.hpp"
#include "opto/narrowptrnode.hpp"
#include "opto/rootnode.hpp"
+#include "opto/runtime.hpp"
ShenandoahBarrierSetC2* ShenandoahBarrierSetC2::bsc2() {
return reinterpret_cast<ShenandoahBarrierSetC2*>(BarrierSet::barrier_set()->barrier_set_c2());
@@ -461,12 +462,9 @@
}
const TypeFunc* ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type() {
- const Type **fields = TypeTuple::fields(4);
- fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // src oop
- fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // src
- fields[TypeFunc::Parms+2] = TypeRawPtr::NOTNULL; // dst
- fields[TypeFunc::Parms+3] = TypeInt::INT; // length
- const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields);
+ const Type **fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = TypeOopPtr::NOTNULL; // src oop
+ const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
// create result type (range)
fields = TypeTuple::fields(0);
@@ -797,8 +795,6 @@
return false;
}
-#define XTOP LP64_ONLY(COMMA phase->top())
-
void ShenandoahBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
Node* ctrl = ac->in(TypeFunc::Control);
Node* mem = ac->in(TypeFunc::Memory);
@@ -812,13 +808,62 @@
assert (dest->is_AddP(), "for clone the dst should be the interior ptr");
if (ShenandoahCloneBarrier && clone_needs_barrier(src, phase->igvn())) {
- Node* call = phase->make_leaf_call(ctrl, mem,
+ // Check if heap is has forwarded objects. If it does, we need to call into the special
+ // routine that would fix up source references before we can continue.
+
+ enum { _heap_stable = 1, _heap_unstable, PATH_LIMIT };
+ Node* region = new RegionNode(PATH_LIMIT);
+ Node* mem_phi = new PhiNode(region, Type::MEMORY, TypeRawPtr::BOTTOM);
+
+ Node* thread = phase->transform_later(new ThreadLocalNode());
+ Node* offset = phase->igvn().MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
+ Node* gc_state_addr = phase->transform_later(new AddPNode(phase->C->top(), thread, offset));
+
+ uint gc_state_idx = Compile::AliasIdxRaw;
+ const TypePtr* gc_state_adr_type = NULL; // debug-mode-only argument
+ debug_only(gc_state_adr_type = phase->C->get_adr_type(gc_state_idx));
+
+ Node* gc_state = phase->transform_later(new LoadBNode(ctrl, mem, gc_state_addr, gc_state_adr_type, TypeInt::BYTE, MemNode::unordered));
+ Node* stable_and = phase->transform_later(new AndINode(gc_state, phase->igvn().intcon(ShenandoahHeap::HAS_FORWARDED)));
+ Node* stable_cmp = phase->transform_later(new CmpINode(stable_and, phase->igvn().zerocon(T_INT)));
+ Node* stable_test = phase->transform_later(new BoolNode(stable_cmp, BoolTest::ne));
+
+ IfNode* stable_iff = phase->transform_later(new IfNode(ctrl, stable_test, PROB_UNLIKELY(0.999), COUNT_UNKNOWN))->as_If();
+ Node* stable_ctrl = phase->transform_later(new IfFalseNode(stable_iff));
+ Node* unstable_ctrl = phase->transform_later(new IfTrueNode(stable_iff));
+
+ // Heap is stable, no need to do anything additional
+ region->init_req(_heap_stable, stable_ctrl);
+ mem_phi->init_req(_heap_stable, mem);
+
+ // Heap is unstable, call into clone barrier stub
+ Node* call = phase->make_leaf_call(unstable_ctrl, mem,
ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type(),
CAST_FROM_FN_PTR(address, ShenandoahRuntime::shenandoah_clone_barrier),
"shenandoah_clone",
TypeRawPtr::BOTTOM,
- src->in(AddPNode::Base), src, dest, length);
+ src->in(AddPNode::Base));
call = phase->transform_later(call);
+
+ ctrl = phase->transform_later(new ProjNode(call, TypeFunc::Control));
+ mem = phase->transform_later(new ProjNode(call, TypeFunc::Memory));
+ region->init_req(_heap_unstable, ctrl);
+ mem_phi->init_req(_heap_unstable, mem);
+
+ // Wire up the actual arraycopy stub now
+ ctrl = phase->transform_later(region);
+ mem = phase->transform_later(mem_phi);
+
+ const char* name = "arraycopy";
+ call = phase->make_leaf_call(ctrl, mem,
+ OptoRuntime::fast_arraycopy_Type(),
+ phase->basictype2arraycopy(T_LONG, NULL, NULL, true, name, true),
+ name, TypeRawPtr::BOTTOM,
+ src, dest, length
+ LP64_ONLY(COMMA phase->top()));
+ call = phase->transform_later(call);
+
+ // Hook up the whole thing into the graph
phase->igvn().replace_node(ac, call);
} else {
BarrierSetC2::clone_at_expansion(phase, ac);
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -286,6 +286,8 @@
}
void ShenandoahBarrierSet::clone_barrier_runtime(oop src) {
- clone_barrier(src);
+ if (_heap->has_forwarded_objects()) {
+ clone_barrier(src);
+ }
}
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp Mon Sep 30 21:16:42 2019 +0200
@@ -73,7 +73,7 @@
void ShenandoahBarrierSet::clone_barrier(oop obj) {
assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");
- if (!_heap->has_forwarded_objects()) return;
+ assert(_heap->has_forwarded_objects(), "only when heap is unstable");
// This is called for cloning an object (see jvm.cpp) after the clone
// has been made. We are not interested in any 'previous value' because
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -76,13 +76,10 @@
// Shenandoah clone barrier: makes sure that references point to to-space
// in cloned objects.
-JRT_LEAF(void, ShenandoahRuntime::shenandoah_clone_barrier(oopDesc* src, void* src_ptr, void* dst_ptr, size_t length))
+JRT_LEAF(void, ShenandoahRuntime::shenandoah_clone_barrier(oopDesc* src))
oop s = oop(src);
shenandoah_assert_correct(NULL, s);
ShenandoahBarrierSet::barrier_set()->clone_barrier(s);
- Copy::conjoint_jlongs_atomic(reinterpret_cast<jlong*>(src_ptr),
- reinterpret_cast<jlong*>(dst_ptr),
- length);
JRT_END
JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_native(oopDesc * src))
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp Mon Sep 30 21:16:42 2019 +0200
@@ -44,7 +44,7 @@
static oopDesc* load_reference_barrier_native(oopDesc* src);
- static void shenandoah_clone_barrier(oopDesc* src, void* src_ptr, void* dst_ptr, size_t length);
+ static void shenandoah_clone_barrier(oopDesc* src);
};
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHRUNTIME_HPP
--- a/src/hotspot/share/oops/instanceKlass.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/oops/instanceKlass.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -1101,7 +1101,7 @@
void InstanceKlass::set_implementor(Klass* k) {
- assert_lock_strong(Compile_lock);
+ assert_locked_or_safepoint(Compile_lock);
assert(is_interface(), "not interface");
Klass* volatile* addr = adr_implementor();
assert(addr != NULL, "null addr");
@@ -2333,8 +2333,8 @@
// being added to class hierarchy (see SystemDictionary:::add_to_hierarchy()).
_init_state = allocated;
- {
- MutexLocker ml(Compile_lock);
+ { // Otherwise this needs to take out the Compile_lock.
+ assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
init_implementor();
}
--- a/src/hotspot/share/prims/whitebox.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/prims/whitebox.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -1745,6 +1745,20 @@
sfpt_check_attempted);
WB_END
+WB_ENTRY(void, WB_AssertSpecialLock(JNIEnv* env, jobject o, jboolean allowVMBlock, jboolean safepointCheck))
+ // Create a special lock violating condition in value
+ Mutex::SafepointCheckRequired sfpt_check_required = safepointCheck ?
+ Mutex::_safepoint_check_always :
+ Mutex::_safepoint_check_never;
+ Mutex::SafepointCheckFlag safepoint_check = safepointCheck ?
+ Monitor::_safepoint_check_flag :
+ Monitor::_no_safepoint_check_flag;
+
+ MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", allowVMBlock, sfpt_check_required), safepoint_check);
+ // If the lock above succeeds, try to safepoint to test the NSV implied with this special lock.
+ ThreadBlockInVM tbivm(JavaThread::current());
+WB_END
+
WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj))
oop obj_oop = JNIHandles::resolve(obj);
return (jboolean) obj_oop->mark().has_monitor();
@@ -2322,6 +2336,7 @@
{CC"AddModuleExportsToAll", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
(void*)&WB_AddModuleExportsToAll },
{CC"assertMatchingSafepointCalls", CC"(ZZ)V", (void*)&WB_AssertMatchingSafepointCalls },
+ {CC"assertSpecialLock", CC"(ZZ)V", (void*)&WB_AssertSpecialLock },
{CC"isMonitorInflated0", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated },
{CC"forceSafepoint", CC"()V", (void*)&WB_ForceSafepoint },
{CC"getConstantPool0", CC"(Ljava/lang/Class;)J", (void*)&WB_GetConstantPool },
--- a/src/hotspot/share/runtime/mutex.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/runtime/mutex.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -282,6 +282,11 @@
assert(_safepoint_check_required != _safepoint_check_sometimes || is_sometimes_ok(name),
"Lock has _safepoint_check_sometimes %s", name);
+
+ assert(_rank > special || _allow_vm_block,
+ "Special locks or below should allow the vm to block");
+ assert(_rank > special || _safepoint_check_required == _safepoint_check_never,
+ "Special locks or below should never safepoint");
#endif
}
@@ -388,17 +393,13 @@
// NSV implied with locking allow_vm_block or !safepoint_check locks.
void Mutex::no_safepoint_verifier(Thread* thread, bool enable) {
- // Threads_lock is special, since the safepoint synchronization will not start before this is
- // acquired. Hence, a JavaThread cannot be holding it at a safepoint. So is VMOperationRequest_lock,
- // since it is used to transfer control between JavaThreads and the VMThread
- // Do not *exclude* any locks unless you are absolutely sure it is correct. Ask someone else first!
- if ((_allow_vm_block &&
- this != Threads_lock &&
- this != Compile_lock && // Temporary: should not be necessary when we get separate compilation
- this != tty_lock && // The tty_lock is released for the safepoint.
- this != VMOperationRequest_lock &&
- this != VMOperationQueue_lock) ||
- rank() == Mutex::special) {
+ // The tty_lock is special because it is released for the safepoint by
+ // the safepoint mechanism.
+ if (this == tty_lock) {
+ return;
+ }
+
+ if (_allow_vm_block) {
if (enable) {
thread->_no_safepoint_count++;
} else {
--- a/src/hotspot/share/runtime/mutexLocker.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/runtime/mutexLocker.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -288,7 +288,7 @@
def(JvmtiThreadState_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController
def(Management_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); // used for JVM management
- def(Compile_lock , PaddedMutex , nonleaf+3, true, _safepoint_check_always);
+ def(Compile_lock , PaddedMutex , nonleaf+3, false, _safepoint_check_always);
def(MethodData_lock , PaddedMutex , nonleaf+3, false, _safepoint_check_always);
def(TouchedMethodLog_lock , PaddedMutex , nonleaf+3, false, _safepoint_check_always);
--- a/src/hotspot/share/runtime/vmThread.cpp Mon Sep 30 20:52:58 2019 +0200
+++ b/src/hotspot/share/runtime/vmThread.cpp Mon Sep 30 21:16:42 2019 +0200
@@ -354,9 +354,9 @@
void VMThread::wait_for_vm_thread_exit() {
assert(Thread::current()->is_Java_thread(), "Should be a JavaThread");
assert(((JavaThread*)Thread::current())->is_terminated(), "Should be terminated");
- { MutexLocker mu(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
+ { MonitorLocker mu(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
_should_terminate = true;
- VMOperationQueue_lock->notify();
+ mu.notify();
}
// Note: VM thread leaves at Safepoint. We are not stopped by Safepoint
@@ -620,8 +620,8 @@
//
// Notify (potential) waiting Java thread(s)
- { MutexLocker mu(VMOperationRequest_lock, Mutex::_no_safepoint_check_flag);
- VMOperationRequest_lock->notify_all();
+ { MonitorLocker mu(VMOperationRequest_lock, Mutex::_no_safepoint_check_flag);
+ mu.notify_all();
}
// We want to make sure that we get to a safepoint regularly
@@ -695,12 +695,11 @@
// VMOperationQueue_lock, so we can block without a safepoint check. This allows vm operation requests
// to be queued up during a safepoint synchronization.
{
- VMOperationQueue_lock->lock_without_safepoint_check();
+ MonitorLocker ml(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag);
log_debug(vmthread)("Adding VM operation: %s", op->name());
_vm_queue->add(op);
op->set_timestamp(os::javaTimeMillis());
- VMOperationQueue_lock->notify();
- VMOperationQueue_lock->unlock();
+ ml.notify();
}
if (!concurrent) {
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java Mon Sep 30 20:52:58 2019 +0200
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java Mon Sep 30 21:16:42 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -83,7 +83,7 @@
* @author Andy Clark, IBM
* @author Ralf Pfeiffer, IBM
* @since PR-DOM-Level-1-19980818.
- * @LastModified: Nov 2018
+ * @LastModified: Sept 2019
*/
public class CoreDocumentImpl
extends ParentNode implements Document {
@@ -862,6 +862,9 @@
* the version number of this document.
*/
public void setXmlVersion(String value) {
+ if (value == null) {
+ return;
+ }
if(value.equals("1.0") || value.equals("1.1")){
//we need to change the flag value only --
// when the version set is different than already set.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Safepoint/NoSafepointVerifier.java Mon Sep 30 21:16:42 2019 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8184732
+ * @summary Ensure that special locks never safepoint check and are vm_block.
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.management
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main NoSafepointVerifier
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Platform;
+
+import sun.hotspot.WhiteBox;
+
+public class NoSafepointVerifier {
+
+ static void runTest(String test) throws Exception {
+ if (Platform.isDebugBuild()){
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-Xbootclasspath/a:.",
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+WhiteBoxAPI",
+ "-XX:-CreateCoredumpOnCrash",
+ "NoSafepointVerifier",
+ test);
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain(test);
+ }
+ }
+
+ static String test1 = "Special locks or below should never safepoint";
+ static String test2 = "Special locks or below should allow the vm to block";
+ static String test3 = "Possible safepoint reached by thread that does not allow it";
+
+ public static void main(String args[]) throws Exception {
+ if (args.length > 0) {
+ if (args[0].equals(test1)) {
+ WhiteBox.getWhiteBox().assertSpecialLock(/*vm_block*/true, /*safepoint_check_always*/true);
+ } else if (args[0].equals(test2)) {
+ WhiteBox.getWhiteBox().assertSpecialLock(/*vm_block*/false, /*safepoint_check_always*/false);
+ } else if (args[0].equals(test3)) {
+ WhiteBox.getWhiteBox().assertSpecialLock(/*vm_block*/true, /*safepoint_check_always*/false);
+ }
+ } else {
+ runTest(test1);
+ runTest(test2);
+ runTest(test3);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jaxp/javax/xml/jaxp/unittest/transform/StAX2DOMTest.java Mon Sep 30 21:16:42 2019 +0200
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package transform;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stax.StAXSource;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.w3c.dom.Node;
+
+/*
+ * @test
+ * @bug 8016914
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
+ * @run testng transform.StAX2DOMTest
+ * @summary Verifies transforming a StAXSource to a DOMResult.
+ */
+public class StAX2DOMTest {
+ /**
+ * Data files for test.
+ * Column(s): xml file
+ *
+ * @return data for test
+ */
+ @DataProvider(name = "datafiles")
+ public Object[][] getData() {
+ return new Object[][] {
+ { "StAX2DOMTest.xml"}, //without declaration
+ { "StAX2DOMTest1.xml"}, //with declaration
+ };
+ }
+
+ /**
+ * Verifies that transforming a StAX source to a DOM result passes with
+ * or without the XML declaration.
+ *
+ * @param file the XML file
+ * @throws Exception if the test fails
+ */
+ @Test(dataProvider = "datafiles")
+ public void test(String file) throws Exception {
+ final XMLInputFactory xif = XMLInputFactory.newInstance();
+ final XMLStreamReader xsr = xif.createXMLStreamReader(
+ this.getClass().getResourceAsStream(file));
+ xsr.nextTag(); // Advance to statements element
+
+ final TransformerFactory tf = TransformerFactory.newInstance();
+ final Transformer t = tf.newTransformer();
+ while(xsr.nextTag() == XMLStreamConstants.START_ELEMENT) {
+ final DOMResult result = new DOMResult();
+ t.transform(new StAXSource(xsr), result);
+ final Node domNode = result.getNode();
+ System.out.println(domNode);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jaxp/javax/xml/jaxp/unittest/transform/StAX2DOMTest.xml Mon Sep 30 21:16:42 2019 +0200
@@ -0,0 +1,119 @@
+<catalog>
+ <book id= " bk101 " >
+ <author>Gambardella, Matthew</author>
+ <title>XML Developer's Guide</title>
+ <genre>Computer</genre>
+ <price>44.95</price>
+ <publish_date>2000-10-01</publish_date>
+ <description>An in-depth look at creating applications
+ with XML.</description>
+ </book>
+ <book id= " bk102 " >
+ <author>Ralls, Kim</author>
+ <title>Midnight Rain</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2000-12-16</publish_date>
+ <description>A former architect battles corporate zombies,
+ an evil sorceress, and her own childhood to become queen
+ of the world.</description>
+ </book>
+ <book id= " bk103 " >
+ <author>Corets, Eva</author>
+ <title>Maeve Ascendant</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2000-11-17</publish_date>
+ <description>After the collapse of a nanotechnology
+ society in England, the young survivors lay the
+ foundation for a new society.</description>
+ </book>
+ <book id= " bk104 " >
+ <author>Corets, Eva</author>
+ <title>Oberon's Legacy</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2001-03-10</publish_date>
+ <description>In post-apocalypse England, the mysterious
+ agent known only as Oberon helps to create a new life
+ for the inhabitants of London. Sequel to Maeve
+ Ascendant.</description>
+ </book>
+ <book id= " bk105 " >
+ <author>Corets, Eva</author>
+ <title>The Sundered Grail</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2001-09-10</publish_date>
+ <description>The two daughters of Maeve, half-sisters,
+ battle one another for control of England. Sequel to
+ Oberon's Legacy.</description>
+ </book>
+ <book id= " bk106 " >
+ <author>Randall, Cynthia</author>
+ <title>Lover Birds</title>
+ <genre>Romance</genre>
+ <price>4.95</price>
+ <publish_date>2000-09-02</publish_date>
+ <description>When Carla meets Paul at an ornithology
+ conference, tempers fly as feathers get ruffled.</description>
+ </book>
+ <book id= " bk107 " >
+ <author>Thurman, Paula</author>
+ <title>Splish Splash</title>
+ <genre>Romance</genre>
+ <price>4.95</price>
+ <publish_date>2000-11-02</publish_date>
+ <description>A deep sea diver finds true love twenty
+ thousand leagues beneath the sea.</description>
+ </book>
+ <book id= " bk108 " >
+ <author>Knorr, Stefan</author>
+ <title>Creepy Crawlies</title>
+ <genre>Horror</genre>
+ <price>4.95</price>
+ <publish_date>2000-12-06</publish_date>
+ <description>An anthology of horror stories about roaches,
+ centipedes, scorpions and other insects.</description>
+ </book>
+ <book id= " bk109 " >
+ <author>Kress, Peter</author>
+ <title>Paradox Lost</title>
+ <genre>Science Fiction</genre>
+ <price>6.95</price>
+ <publish_date>2000-11-02</publish_date>
+ <description>After an inadvertant trip through a Heisenberg
+ Uncertainty Device, James Salway discovers the problems
+ of being quantum.</description>
+ </book>
+ <book id= " bk110 " >
+ <author>O'Brien, Tim</author>
+ <title>Microsoft .NET: The Programming Bible</title>
+ <genre>Computer</genre>
+ <price>36.95</price>
+ <publish_date>2000-12-09</publish_date>
+ <description>Microsoft's .NET initiative is explored in
+ detail in this deep programmer's reference.</description>
+ </book>
+ <book id= " bk111 " >
+ <author>O'Brien, Tim</author>
+ <title>MSXML3: A Comprehensive Guide</title>
+ <genre>Computer</genre>
+ <price>36.95</price>
+ <publish_date>2000-12-01</publish_date>
+ <description>The Microsoft MSXML3 parser is covered in
+ detail, with attention to XML DOM interfaces, XSLT processing,
+ SAX and more.</description>
+ </book>
+ <book id= " bk112 " >
+ <author>Galos, Mike</author>
+ <title>Visual Studio 7: A Comprehensive Guide</title>
+ <genre>Computer</genre>
+ <price>49.95</price>
+ <publish_date>2001-04-16</publish_date>
+ <description>Microsoft Visual Studio 7 is explored in depth,
+ looking at how Visual Basic, Visual C++, C#, and ASP+ are
+ integrated into a comprehensive development
+ environment.</description>
+ </book>
+</catalog>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jaxp/javax/xml/jaxp/unittest/transform/StAX2DOMTest1.xml Mon Sep 30 21:16:42 2019 +0200
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalog>
+ <book id= " bk101 " >
+ <author>Gambardella, Matthew</author>
+ <title>XML Developer's Guide</title>
+ <genre>Computer</genre>
+ <price>44.95</price>
+ <publish_date>2000-10-01</publish_date>
+ <description>An in-depth look at creating applications
+ with XML.</description>
+ </book>
+ <book id= " bk102 " >
+ <author>Ralls, Kim</author>
+ <title>Midnight Rain</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2000-12-16</publish_date>
+ <description>A former architect battles corporate zombies,
+ an evil sorceress, and her own childhood to become queen
+ of the world.</description>
+ </book>
+ <book id= " bk103 " >
+ <author>Corets, Eva</author>
+ <title>Maeve Ascendant</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2000-11-17</publish_date>
+ <description>After the collapse of a nanotechnology
+ society in England, the young survivors lay the
+ foundation for a new society.</description>
+ </book>
+ <book id= " bk104 " >
+ <author>Corets, Eva</author>
+ <title>Oberon's Legacy</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2001-03-10</publish_date>
+ <description>In post-apocalypse England, the mysterious
+ agent known only as Oberon helps to create a new life
+ for the inhabitants of London. Sequel to Maeve
+ Ascendant.</description>
+ </book>
+ <book id= " bk105 " >
+ <author>Corets, Eva</author>
+ <title>The Sundered Grail</title>
+ <genre>Fantasy</genre>
+ <price>5.95</price>
+ <publish_date>2001-09-10</publish_date>
+ <description>The two daughters of Maeve, half-sisters,
+ battle one another for control of England. Sequel to
+ Oberon's Legacy.</description>
+ </book>
+ <book id= " bk106 " >
+ <author>Randall, Cynthia</author>
+ <title>Lover Birds</title>
+ <genre>Romance</genre>
+ <price>4.95</price>
+ <publish_date>2000-09-02</publish_date>
+ <description>When Carla meets Paul at an ornithology
+ conference, tempers fly as feathers get ruffled.</description>
+ </book>
+ <book id= " bk107 " >
+ <author>Thurman, Paula</author>
+ <title>Splish Splash</title>
+ <genre>Romance</genre>
+ <price>4.95</price>
+ <publish_date>2000-11-02</publish_date>
+ <description>A deep sea diver finds true love twenty
+ thousand leagues beneath the sea.</description>
+ </book>
+ <book id= " bk108 " >
+ <author>Knorr, Stefan</author>
+ <title>Creepy Crawlies</title>
+ <genre>Horror</genre>
+ <price>4.95</price>
+ <publish_date>2000-12-06</publish_date>
+ <description>An anthology of horror stories about roaches,
+ centipedes, scorpions and other insects.</description>
+ </book>
+ <book id= " bk109 " >
+ <author>Kress, Peter</author>
+ <title>Paradox Lost</title>
+ <genre>Science Fiction</genre>
+ <price>6.95</price>
+ <publish_date>2000-11-02</publish_date>
+ <description>After an inadvertant trip through a Heisenberg
+ Uncertainty Device, James Salway discovers the problems
+ of being quantum.</description>
+ </book>
+ <book id= " bk110 " >
+ <author>O'Brien, Tim</author>
+ <title>Microsoft .NET: The Programming Bible</title>
+ <genre>Computer</genre>
+ <price>36.95</price>
+ <publish_date>2000-12-09</publish_date>
+ <description>Microsoft's .NET initiative is explored in
+ detail in this deep programmer's reference.</description>
+ </book>
+ <book id= " bk111 " >
+ <author>O'Brien, Tim</author>
+ <title>MSXML3: A Comprehensive Guide</title>
+ <genre>Computer</genre>
+ <price>36.95</price>
+ <publish_date>2000-12-01</publish_date>
+ <description>The Microsoft MSXML3 parser is covered in
+ detail, with attention to XML DOM interfaces, XSLT processing,
+ SAX and more.</description>
+ </book>
+ <book id= " bk112 " >
+ <author>Galos, Mike</author>
+ <title>Visual Studio 7: A Comprehensive Guide</title>
+ <genre>Computer</genre>
+ <price>49.95</price>
+ <publish_date>2001-04-16</publish_date>
+ <description>Microsoft Visual Studio 7 is explored in depth,
+ looking at how Visual Basic, Visual C++, C#, and ASP+ are
+ integrated into a comprehensive development
+ environment.</description>
+ </book>
+</catalog>
--- a/test/jdk/java/util/RandomAccess/Basic.java Mon Sep 30 20:52:58 2019 +0200
+++ b/test/jdk/java/util/RandomAccess/Basic.java Mon Sep 30 21:16:42 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,111 +21,148 @@
* questions.
*/
-/*
+/**
* @test
- * @bug 4327164
+ * @bug 4327164 8229338
* @summary Basic test for new RandomAccess interface
+ * @run testng Basic
*/
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-import java.util.RandomAccess;
-import java.util.Vector;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.*;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.function.Function;
+import java.util.function.Supplier;
public class Basic {
- public static void main(String[] args) throws Exception {
- List a0 = Arrays.asList(new String[] { "a", "b", "c" });
- List a[] = { a0, new ArrayList(a0), new LinkedList(a0),
- new Vector(a0) };
- if (!(a[0] instanceof RandomAccess))
- throw new Exception("Arrays.asList doesn't implement RandomAccess");
- if (!(a[1] instanceof RandomAccess))
- throw new Exception("ArrayList doesn't implement RandomAccess");
- if (a[2] instanceof RandomAccess)
- throw new Exception("LinkedList implements RandomAccess");
- if (!(a[3] instanceof RandomAccess))
- throw new Exception("Vector doesn't implement RandomAccess");
-
- for (int i = 0; i < a.length; i++) {
- List t = a[i];
- List ut = Collections.unmodifiableList(t);
- List st = Collections.synchronizedList(t);
+ /*
+ * Lists which implement Random Access interface
+ */
+ @DataProvider(name = "testLists")
+ public Object[][] testData() {
+ var intArray = new Integer[100];
+ var stack = new Stack<>();
+ var random = new Random();
+ for (int i = 0; i < 100; i++) {
+ var r = random.nextInt(100);
+ stack.push(r);
+ intArray[i] = r;
+ }
+ List<Integer> list = Arrays.asList(intArray);
+ return new Object[][]{
+ {list, true, "Arrays.asList"},
+ {stack, true, "Stack"},
+ {new ArrayList<>(list), true, "ArrayList"},
+ {new LinkedList<>(list), false, "LinkedList"},
+ {new Vector<>(list), true, "Vector"},
+ {new CopyOnWriteArrayList<>(list), true, "CopyOnWriteArrayList"}
+ };
+ }
- boolean random = t instanceof RandomAccess;
- if ((ut instanceof RandomAccess) != random)
- throw new Exception(
- "Unmodifiable fails to preserve RandomAccess: " + i);
- if ((st instanceof RandomAccess) != random)
- throw new Exception(
- "Synchronized fails to preserve RandomAccess: " + i);
+ @Test(dataProvider = "testLists")
+ public void testRandomAccess(List<Integer> list, boolean expectedRA, String failMsg) {
+
+ var actualRA = list instanceof RandomAccess;
+ assertEquals(actualRA, expectedRA, failMsg);
+
+ List<Integer> unmodList = Collections.unmodifiableList(list);
+ List<Integer> syncList = Collections.synchronizedList(list);
+ assertEquals((unmodList instanceof RandomAccess), actualRA,
+ "Unmodifiable fails to preserve RandomAccess");
+ assertEquals((syncList instanceof RandomAccess), actualRA,
+ "Synchronized fails to preserve RandomAccess");
- while (t.size() > 0) {
- t = t.subList(0, t.size() - 1);
- if ((t instanceof RandomAccess) != random)
- throw new Exception(
- "SubList fails to preserve RandomAccess: " + i
- + ", " + t.size());
+ while (list.size() > 0) {
+ list = list.subList(0, list.size() - 1);
+ assertEquals((list instanceof RandomAccess), actualRA,
+ "SubList fails to preserve RandomAccess: " + list.size());
- ut = ut.subList(0, ut.size() - 1);
- if ((ut instanceof RandomAccess) != random)
- throw new Exception(
- "SubList(unmodifiable) fails to preserve RandomAccess: "
- + i + ", " + ut.size());
+ unmodList = unmodList.subList(0, unmodList.size() - 1);
+ assertEquals((unmodList instanceof RandomAccess), actualRA,
+ "SubList(unmodifiable) fails to preserve RandomAccess: "
+ + unmodList.size());
+
+ syncList = syncList.subList(0, syncList.size() - 1);
+ assertEquals((syncList instanceof RandomAccess), actualRA,
+ "SubList(synchronized) fails to preserve RandomAccess: "
+ + syncList.size());
+ }
+ }
- st = st.subList(0, st.size() - 1);
- if ((st instanceof RandomAccess) != random)
- throw new Exception(
- "SubList(synchronized) fails to preserve RandomAccess: "
- + i + ", " + st.size());
- }
- }
+ @Test(dataProvider = "testLists")
+ public void testListCopy(List<Integer> list, boolean expectedRA, String failMsg) {
+ ArrayList testCollection = new ArrayList<>(Collections.nCopies(100, 0));
+ // Test that copy works on random & sequential access
+ Collections.copy(list, testCollection);
+ assertEquals(list, testCollection, "Copy failed: " + failMsg);
+ }
+
+ @Test(dataProvider = "testLists")
+ public void testListFill(List<Integer> list, boolean expectedRA, String failMsg) {
+ ArrayList testCollection = new ArrayList<>(Collections.nCopies(100, 0));
+ // Test that copy works on random & sequential access
+ Collections.fill(list, 0);
+ assertEquals(list, testCollection, "Fill failed: " + failMsg);
+ }
- // Test that shuffle works the same on random and sequential access
- List al = new ArrayList();
- for (int j = 0; j < 100; j++)
- al.add(Integer.valueOf(2 * j));
- List ll = new LinkedList(al);
- Random r1 = new Random(666), r2 = new Random(666);
- for (int i = 0; i < 100; i++) {
- Collections.shuffle(al, r1);
- Collections.shuffle(ll, r2);
- if (!al.equals(ll))
- throw new Exception("Shuffle failed: " + i);
- }
+ /*
+ * Test that shuffle and binarySearch work the same on random and sequential access lists.
+ */
+ @DataProvider(name = "testFactoryLists")
+ public Object[][] testDataFactory() {
+ return new Object[][]{
+ {"ArrayList -> LinkedList", supplier(ArrayList::new), copyCtor(LinkedList::new)},
+ {"CopyOnWriteArrayList -> Stack", supplier(CopyOnWriteArrayList::new),
+ copyCtor((list) -> { var s = new Stack();s.addAll(list);return s; })}
+ };
+ }
+
+ private Supplier<List<Integer>> supplier(Supplier<List<Integer>> supplier) {
+ return supplier;
+ }
- // Test that fill works on random & sequential access
- List gumbyParade = Collections.nCopies(100, "gumby");
- Collections.fill(al, "gumby");
- if (!al.equals(gumbyParade))
- throw new Exception("ArrayList fill failed");
- Collections.fill(ll, "gumby");
- if (!ll.equals(gumbyParade))
- throw new Exception("LinkedList fill failed");
+ private Function<List<Integer>, List<Integer>> copyCtor(Function<List<Integer>, List<Integer>> ctor) {
+ return ctor;
+ }
+
+ @Test(dataProvider = "testFactoryLists")
+ public void testListShuffle(String description, Supplier<List<Integer>> randomAccessListSupplier,
+ Function<List<Integer>, List<Integer>> otherListFactory) {
- // Test that copy works on random & sequential access
- List pokeyParade = Collections.nCopies(100, "pokey");
- Collections.copy(al, pokeyParade);
- if (!al.equals(pokeyParade))
- throw new Exception("ArrayList copy failed");
- Collections.copy(ll, pokeyParade);
- if (!ll.equals(pokeyParade))
- throw new Exception("LinkedList copy failed");
+ //e.g: ArrayList<Integer> al = new ArrayList<>();
+ List<Integer> l1 = randomAccessListSupplier.get();
+ for (int j = 0; j < 100; j++) {
+ l1.add(Integer.valueOf(2 * j));
+ }
+ // e.g: List<Integer> ll = new LinkedList<>(al);
+ List<Integer> l2 = otherListFactory.apply(l1);
+ for (int i = 0; i < 100; i++) {
+ Collections.shuffle(l1, new Random(666));
+ Collections.shuffle(l2, new Random(666));
+ assertEquals(l1, l2, "Shuffle failed: " + description);
+ }
+ }
- // Test that binarySearch works the same on random & sequential access
- al = new ArrayList();
- for (int i = 0; i < 10000; i++)
- al.add(Integer.valueOf(2 * i));
- ll = new LinkedList(al);
+ @Test(dataProvider = "testFactoryLists")
+ public void testListBinarySearch(String description, Supplier<List<Integer>> randomAccessListSupplier,
+ Function<List<Integer>, List<Integer>> otherListFactory) {
+
+ //e.g: ArrayList<Integer> al = new ArrayList<>();
+ List<Integer> l1 = randomAccessListSupplier.get();
+ for (int i = 0; i < 10000; i++) {
+ l1.add(Integer.valueOf(2 * i));
+ }
+ // e.g: List<Integer> ll = new LinkedList<>(al);
+ List<Integer> l2 = otherListFactory.apply(l1);
for (int i = 0; i < 500; i++) {
- Integer key = Integer.valueOf(r1.nextInt(20000));
- if (Collections.binarySearch(al, key) != Collections
- .binarySearch(ll, key))
- throw new Exception("Binary search failed: " + i);
+ Integer key = Integer.valueOf(new Random(666).nextInt(20000));
+ assertEquals(Collections.binarySearch(l1, key), Collections
+ .binarySearch(l2, key), "Binary search failed: " + description);
}
}
}
--- a/test/lib/sun/hotspot/WhiteBox.java Mon Sep 30 20:52:58 2019 +0200
+++ b/test/lib/sun/hotspot/WhiteBox.java Mon Sep 30 21:16:42 2019 +0200
@@ -511,6 +511,7 @@
// Safepoint Checking
public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
+ public native void assertSpecialLock(boolean allowVMBlock, boolean safepointCheck);
// Sharing & archiving
public native String getDefaultArchivePath();