diff --git a/.hgtags b/.hgtags index 28f9ad5279c..555f758c163 100644 --- a/.hgtags +++ b/.hgtags @@ -376,3 +376,5 @@ e613affb88d178dc7c589f1679db113d589bddb4 jdk-9+130 4d2a15091124488080d65848b704e25599b2aaeb jdk-9+131 2e83d21d78cd9c1d52e6cd2599e9c8aa36ea1f52 jdk-9+132 e17429a7e843c4a4ed3651458d0f950970edcbcc jdk-9+133 +a71210c0d9800eb6925b61ecd6198abd554f90ee jdk-9+134 +e384420383a5b79fa0012ebcb25d8f83cff7f777 jdk-9+135 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 9b00c6661fd..c9694066072 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -376,3 +376,5 @@ d94d54a3192fea79234c3ac55cd0b4052d45e954 jdk-9+130 8728756c2f70a79a90188f4019cfd6b9a275765c jdk-9+131 a24702d4d5ab0015a5c553ed57f66fce7d85155e jdk-9+132 be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133 +065724348690eda41fc69112278d8da6dcde548c jdk-9+134 +82b94cb5f342319d2cda77f9fa59703ad7fde576 jdk-9+135 diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 92e055d9a12..b233cdcd433 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5095,7 +5095,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1470863189 +DATE_WHEN_GENERATED=1472718471 ############################################################################### # @@ -15944,6 +15944,8 @@ $as_echo "$COMPILE_TYPE" >&6; } HOTSPOT_TARGET_CPU_DEFINE=S390 elif test "x$OPENJDK_TARGET_CPU" = xs390x; then HOTSPOT_TARGET_CPU_DEFINE=S390 + elif test "x$OPENJDK_TARGET_CPU" != x; then + HOTSPOT_TARGET_CPU_DEFINE=$(echo $OPENJDK_TARGET_CPU | tr a-z A-Z) fi @@ -16117,6 +16119,8 @@ $as_echo "$COMPILE_TYPE" >&6; } HOTSPOT_BUILD_CPU_DEFINE=S390 elif test "x$OPENJDK_BUILD_CPU" = xs390x; then HOTSPOT_BUILD_CPU_DEFINE=S390 + elif test "x$OPENJDK_BUILD_CPU" != x; then + HOTSPOT_BUILD_CPU_DEFINE=$(echo $OPENJDK_BUILD_CPU | tr a-z A-Z) fi diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 2fbac1d0dd3..e7ffe4a2fa5 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -454,6 +454,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER], HOTSPOT_$1_CPU_DEFINE=S390 elif test "x$OPENJDK_$1_CPU" = xs390x; then HOTSPOT_$1_CPU_DEFINE=S390 + elif test "x$OPENJDK_$1_CPU" != x; then + HOTSPOT_$1_CPU_DEFINE=$(echo $OPENJDK_$1_CPU | tr a-z A-Z) fi AC_SUBST(HOTSPOT_$1_CPU_DEFINE) diff --git a/corba/.hgtags b/corba/.hgtags index a959d0d2240..3b09618de85 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -376,3 +376,5 @@ c3e83ccab3bb1733ae903d681879a33f85ed465c jdk-9+129 f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131 1ab4b9399c4cba584f66c1c088188f2f565fbf9c jdk-9+132 2021bfedf1c478a4808a7711a6090682a12f4c0e jdk-9+133 +1a497f5ca0cfd88115cc7daa8af8a62b8741caf2 jdk-9+134 +094d0db606db976045f594dba47d4593b715cc81 jdk-9+135 diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 8d8a2e6cf99..a52c2a2a2da 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -536,3 +536,5 @@ e96b34b76d863ed1fa04e0eeb3f297ac17b490fd jdk-9+129 943bf73b49c33c2d7cbd796f6a4ae3c7a00ae932 jdk-9+131 713951c08aa26813375175c2ab6cc99ff2a56903 jdk-9+132 a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133 +b8b694c6b4d2ab0939aed7adaf0eec1ac321a085 jdk-9+134 +3b1c4562953db47e36b237a500f368d5c9746d47 jdk-9+135 diff --git a/hotspot/make/test/JtregNative.gmk b/hotspot/make/test/JtregNative.gmk index 9ed952f36c0..8c818122765 100644 --- a/hotspot/make/test/JtregNative.gmk +++ b/hotspot/make/test/JtregNative.gmk @@ -44,6 +44,7 @@ BUILD_HOTSPOT_JTREG_NATIVE_SRC := \ $(HOTSPOT_TOPDIR)/test/native_sanity \ $(HOTSPOT_TOPDIR)/test/runtime/jni/8025979 \ $(HOTSPOT_TOPDIR)/test/runtime/jni/8033445 \ + $(HOTSPOT_TOPDIR)/test/runtime/jni/checked \ $(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \ $(HOTSPOT_TOPDIR)/test/runtime/modules/getModuleJNI \ $(HOTSPOT_TOPDIR)/test/runtime/SameObject \ diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp index bc8699e4a6b..91e32e94afa 100644 --- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp @@ -326,7 +326,8 @@ void InterpreterMacroAssembler::push_i(Register r) { } void InterpreterMacroAssembler::push_l(Register r) { - str(r, pre(esp, 2 * -wordSize)); + str(zr, pre(esp, -wordSize)); + str(r, pre(esp, -wordsize)); } void InterpreterMacroAssembler::pop_f(FloatRegister r) { diff --git a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp index 771dc099b9f..d1c4dbb68a2 100644 --- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp @@ -2041,6 +2041,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(r0); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ str(zr, Address(rthread, JavaThread::pending_jni_exception_check_fn_offset())); + } + if (!is_critical_native) { // reset handle block __ ldr(r2, Address(rthread, JavaThread::active_handles_offset())); diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp index 5ac01c904fc..122cac33cef 100644 --- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp @@ -1355,6 +1355,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // reset_last_Java_frame __ reset_last_Java_frame(true); + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ str(zr, Address(rthread, JavaThread::pending_jni_exception_check_fn_offset())); + } + // reset handle block __ ldr(t, Address(rthread, JavaThread::active_handles_offset())); __ str(zr, Address(t, JNIHandleBlock::top_offset_in_bytes())); diff --git a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp index d1ae77b5df0..fe26b39d736 100644 --- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp @@ -57,10 +57,12 @@ define_pd_global(intx, InlineSmallCode, 1500); #ifdef _LP64 // Stack slots are 2X larger in LP64 than in the 32 bit VM. +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); define_pd_global(intx, VMThreadStackSize, 1024); #define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+2)) #else +define_pd_global(intx, CompilerThreadStackSize, 512); define_pd_global(intx, ThreadStackSize, 512); define_pd_global(intx, VMThreadStackSize, 512); #define DEFAULT_STACK_SHADOW_PAGES (6 DEBUG_ONLY(+2)) diff --git a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp index ba25825ca5a..ef2362897f7 100644 --- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp @@ -359,7 +359,7 @@ void InterpreterMacroAssembler::store_unaligned_long(Register l, Register r1, in #ifdef _LP64 stx(l, r1, offset); // store something more useful here - debug_only(stx(G0, r1, offset+Interpreter::stackElementSize);) + stx(G0, r1, offset+Interpreter::stackElementSize); #else st(l, r1, offset); st(l->successor(), r1, offset + Interpreter::stackElementSize); diff --git a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp index aa54e3b91f9..06ca12698c4 100644 --- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp @@ -2765,6 +2765,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(I0); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset()); + } + if (!is_critical_native) { // reset handle block __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), L5); diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp index d8973ed0281..1f9fba2370b 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp @@ -1487,6 +1487,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { __ set(_thread_in_Java, G3_scratch); __ st(G3_scratch, thread_state); + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset()); + } + // reset handle block __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch); __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes()); diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp index f3ae96f05a1..331ac5d3405 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp @@ -611,7 +611,8 @@ void InterpreterMacroAssembler::pop_l(Register r) { void InterpreterMacroAssembler::push_l(Register r) { subptr(rsp, 2 * wordSize); - movq(Address(rsp, 0), r); + movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r ); + movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD ); } void InterpreterMacroAssembler::pop(TosState state) { diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index 96961a8b9b0..c69ef9a26e6 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -2236,6 +2236,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(rax); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); + } + if (!is_critical_native) { // reset handle block __ movptr(rcx, Address(thread, JavaThread::active_handles_offset())); diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index 76b7bb46e34..180a3abed4a 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -2589,6 +2589,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(rax); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ movptr(Address(r15_thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); + } + if (!is_critical_native) { // reset handle block __ movptr(rcx, Address(r15_thread, JavaThread::active_handles_offset())); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp index 845959fe4e4..6441d19cf5f 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp @@ -1169,6 +1169,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // reset_last_Java_frame __ reset_last_Java_frame(thread, true); + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); + } + // reset handle block __ movptr(t, Address(thread, JavaThread::active_handles_offset())); __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java index e66586e4b4f..ca757cac7be 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java @@ -65,4 +65,7 @@ public class GrowableArray extends GenericGrowableArray { super(addr); virtualConstructor = v; } + public Address getData() { + return dataField.getValue(getAddress()); + } } diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index 6c668c16870..47788262bdc 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -847,7 +847,8 @@ static void *thread_native_entry(Thread *thread) { return 0; } -bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { +bool os::create_thread(Thread* thread, ThreadType thr_type, + size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); @@ -880,37 +881,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???"); // calculate stack size if it's not specified by caller - if (stack_size == 0) { - stack_size = os::Aix::default_stack_size(thr_type); - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize whose default value can be changed with the flag -Xss. - assert(JavaThread::stack_size_at_create() > 0, "this should be set"); - stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - - stack_size = MAX2(stack_size, os::Aix::min_stack_allowed); + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); - char buf[64]; if (ret == 0) { log_info(os, thread)("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ", @@ -3593,32 +3569,11 @@ jint os::init_2(void) { Aix::signal_sets_init(); Aix::install_signal_handlers(); - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Aix::min_stack_allowed = MAX2(os::Aix::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Aix::min_stack_allowed = align_size_up(os::Aix::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Aix::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " - "Specify at least %dk", - os::Aix::min_stack_allowed / K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - // Note that this can be 0, if no default stacksize was set. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, vm_page_size())); - if (UseNUMA) { UseNUMA = false; warning("NUMA optimizations are not available on this OS."); diff --git a/hotspot/src/os/aix/vm/os_aix.hpp b/hotspot/src/os/aix/vm/os_aix.hpp index c17cd686c1c..83858048cbb 100644 --- a/hotspot/src/os/aix/vm/os_aix.hpp +++ b/hotspot/src/os/aix/vm/os_aix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2016 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -140,14 +140,6 @@ class Aix { // libpthread version string static void libpthread_init(); - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - static size_t min_stack_allowed; - - // Return default stack size or guard size for the specified thread type - static size_t default_stack_size(os::ThreadType thr_type); - static size_t default_guard_size(os::ThreadType thr_type); - // Function returns true if we run on OS/400 (pase), false if we run // on AIX. static bool on_pase() { diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 39cfd207cc6..926144074f9 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -734,7 +734,8 @@ static void *thread_native_entry(Thread *thread) { return 0; } -bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { +bool os::create_thread(Thread* thread, ThreadType thr_type, + size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); // Allocate the OSThread object @@ -757,32 +758,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // calculate stack size if it's not specified by caller - if (stack_size == 0) { - stack_size = os::Bsd::default_stack_size(thr_type); - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize which default value can be - // changed with the flag -Xss - assert(JavaThread::stack_size_at_create() > 0, "this should be set"); - stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - - stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed); + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); ThreadState state; @@ -3502,32 +3478,11 @@ jint os::init_2(void) { Bsd::signal_sets_init(); Bsd::install_signal_handlers(); - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Bsd::min_stack_allowed = MAX2(os::Bsd::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Bsd::min_stack_allowed = align_size_up(os::Bsd::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Bsd::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " - "Specify at least %dk", - os::Bsd::min_stack_allowed/ K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, - vm_page_size())); - if (MaxFDLimit) { // set the number of file descriptors to max. print out error // if getrlimit/setrlimit fails but continue regardless. diff --git a/hotspot/src/os/bsd/vm/os_bsd.hpp b/hotspot/src/os/bsd/vm/os_bsd.hpp index 52b88e6d865..5bc6092214c 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.hpp +++ b/hotspot/src/os/bsd/vm/os_bsd.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -120,14 +120,6 @@ class Bsd { static struct sigaction *get_chained_signal_action(int sig); static bool chained_handler(int sig, siginfo_t* siginfo, void* context); - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - static size_t min_stack_allowed; - - // Return default stack size or guard size for the specified thread type - static size_t default_stack_size(os::ThreadType thr_type); - static size_t default_guard_size(os::ThreadType thr_type); - // Real-time clock functions static void clock_init(void); diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 5aafe4b8474..e03ac29102e 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -701,7 +701,7 @@ static void *thread_native_entry(Thread *thread) { } bool os::create_thread(Thread* thread, ThreadType thr_type, - size_t stack_size) { + size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); // Allocate the OSThread object @@ -723,34 +723,8 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - // stack size // calculate stack size if it's not specified by caller - if (stack_size == 0) { - stack_size = os::Linux::default_stack_size(thr_type); - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize which default value can be - // changed with the flag -Xss - assert(JavaThread::stack_size_at_create() > 0, "this should be set"); - stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - - stack_size = MAX2(stack_size, os::Linux::min_stack_allowed); + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); // glibc guard page @@ -956,10 +930,9 @@ static bool find_vma(address addr, address* vma_low, address* vma_high) { // bogus value for initial thread. void os::Linux::capture_initial_stack(size_t max_size) { // stack size is the easy part, get it from RLIMIT_STACK - size_t stack_size; struct rlimit rlim; getrlimit(RLIMIT_STACK, &rlim); - stack_size = rlim.rlim_cur; + size_t stack_size = rlim.rlim_cur; // 6308388: a bug in ld.so will relocate its own .data section to the // lower end of primordial stack; reduce ulimit -s value a little bit @@ -4793,32 +4766,10 @@ jint os::init_2(void) { Linux::signal_sets_init(); Linux::install_signal_handlers(); - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Linux::min_stack_allowed = align_size_up(os::Linux::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Linux::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " - "Specify at least " SIZE_FORMAT "k", - os::Linux::min_stack_allowed/ K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, - vm_page_size())); - Linux::capture_initial_stack(JavaThread::stack_size_at_create()); #if defined(IA32) diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 2b6ae922e3f..3cada1b07be 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -170,12 +170,8 @@ class Linux { static void libpthread_init(); static bool libnuma_init(); static void* libnuma_dlsym(void* handle, const char* name); - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - static size_t min_stack_allowed; - // Return default stack size or guard size for the specified thread type - static size_t default_stack_size(os::ThreadType thr_type); + // Return default guard size for the specified thread type static size_t default_guard_size(os::ThreadType thr_type); static void capture_initial_stack(size_t max_size); diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index 2b7407dc985..8ff039e8644 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -1099,6 +1099,123 @@ char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_a return buf; } +// Check minimum allowable stack sizes for thread creation and to initialize +// the java system classes, including StackOverflowError - depends on page +// size. Add two 4K pages for compiler2 recursion in main thread. +// Add in 4*BytesPerWord 4K pages to account for VM stack during +// class initialization depending on 32 or 64 bit VM. +jint os::Posix::set_minimum_stack_sizes() { + _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed, + JavaThread::stack_guard_zone_size() + + JavaThread::stack_shadow_zone_size() + + (4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K); + + _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size()); + + size_t stack_size_in_bytes = ThreadStackSize * K; + if (stack_size_in_bytes != 0 && + stack_size_in_bytes < _java_thread_min_stack_allowed) { + // The '-Xss' and '-XX:ThreadStackSize=N' options both set + // ThreadStackSize so we go with "Java thread stack size" instead + // of "ThreadStackSize" to be more friendly. + tty->print_cr("\nThe Java thread stack size specified is too small. " + "Specify at least " SIZE_FORMAT "k", + _java_thread_min_stack_allowed / K); + return JNI_ERR; + } + +#ifdef SOLARIS + // For 64kbps there will be a 64kb page size, which makes + // the usable default stack size quite a bit less. Increase the + // stack for 64kb (or any > than 8kb) pages, this increases + // virtual memory fragmentation (since we're not creating the + // stack on a power of 2 boundary. The real fix for this + // should be to fix the guard page mechanism. + + if (vm_page_size() > 8*K) { + stack_size_in_bytes = (stack_size_in_bytes != 0) + ? stack_size_in_bytes + + JavaThread::stack_red_zone_size() + + JavaThread::stack_yellow_zone_size() + : 0; + ThreadStackSize = stack_size_in_bytes/K; + } +#endif // SOLARIS + + // Make the stack size a multiple of the page size so that + // the yellow/red zones can be guarded. + JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, + vm_page_size())); + + _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size()); + + stack_size_in_bytes = CompilerThreadStackSize * K; + if (stack_size_in_bytes != 0 && + stack_size_in_bytes < _compiler_thread_min_stack_allowed) { + tty->print_cr("\nThe CompilerThreadStackSize specified is too small. " + "Specify at least " SIZE_FORMAT "k", + _compiler_thread_min_stack_allowed / K); + return JNI_ERR; + } + + _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size()); + + stack_size_in_bytes = VMThreadStackSize * K; + if (stack_size_in_bytes != 0 && + stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) { + tty->print_cr("\nThe VMThreadStackSize specified is too small. " + "Specify at least " SIZE_FORMAT "k", + _vm_internal_thread_min_stack_allowed / K); + return JNI_ERR; + } + return JNI_OK; +} + +// Called when creating the thread. The minimum stack sizes have already been calculated +size_t os::Posix::get_initial_stack_size(ThreadType thr_type, size_t req_stack_size) { + size_t stack_size; + if (req_stack_size == 0) { + stack_size = default_stack_size(thr_type); + } else { + stack_size = req_stack_size; + } + + switch (thr_type) { + case os::java_thread: + // Java threads use ThreadStackSize which default value can be + // changed with the flag -Xss + if (req_stack_size == 0 && JavaThread::stack_size_at_create() > 0) { + // no requested size and we have a more specific default value + stack_size = JavaThread::stack_size_at_create(); + } + stack_size = MAX2(stack_size, + _java_thread_min_stack_allowed); + break; + case os::compiler_thread: + if (req_stack_size == 0 && CompilerThreadStackSize > 0) { + // no requested size and we have a more specific default value + stack_size = (size_t)(CompilerThreadStackSize * K); + } + stack_size = MAX2(stack_size, + _compiler_thread_min_stack_allowed); + break; + case os::vm_thread: + case os::pgc_thread: + case os::cgc_thread: + case os::watcher_thread: + default: // presume the unknown thr_type is a VM internal + if (req_stack_size == 0 && VMThreadStackSize > 0) { + // no requested size and we have a more specific default value + stack_size = (size_t)(VMThreadStackSize * K); + } + + stack_size = MAX2(stack_size, + _vm_internal_thread_min_stack_allowed); + break; + } + + return stack_size; +} os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() { assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread"); diff --git a/hotspot/src/os/posix/vm/os_posix.hpp b/hotspot/src/os/posix/vm/os_posix.hpp index 0196e989456..8120bde9e02 100644 --- a/hotspot/src/os/posix/vm/os_posix.hpp +++ b/hotspot/src/os/posix/vm/os_posix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -42,7 +42,18 @@ protected: static void print_libversion_info(outputStream* st); static void print_load_average(outputStream* st); + // Minimum stack size a thread can be created with (allowing + // the VM to completely create the thread and enter user code) + static size_t _compiler_thread_min_stack_allowed; + static size_t _java_thread_min_stack_allowed; + static size_t _vm_internal_thread_min_stack_allowed; + public: + // Return default stack size for the specified thread type + static size_t default_stack_size(os::ThreadType thr_type); + // Check and sets minimum stack sizes + static jint set_minimum_stack_sizes(); + static size_t get_initial_stack_size(ThreadType thr_type, size_t req_stack_size); // Returns true if signal is valid. static bool is_valid_signal(int sig); diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 825a679dc19..4c4268486b1 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -917,8 +917,15 @@ static char* describe_thr_create_attributes(char* buf, size_t buflen, return buf; } +// return default stack size for thr_type +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { + // default stack size when not specified by caller is 1M (2M for LP64) + size_t s = (BytesPerWord >> 2) * K * K; + return s; +} + bool os::create_thread(Thread* thread, ThreadType thr_type, - size_t stack_size) { + size_t req_stack_size) { // Allocate the OSThread object OSThread* osthread = new OSThread(NULL, NULL); if (osthread == NULL) { @@ -953,31 +960,8 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, tty->print_cr("In create_thread, creating a %s thread\n", thrtyp); } - // Calculate stack size if it's not specified by caller. - if (stack_size == 0) { - // The default stack size 1M (2M for LP64). - stack_size = (BytesPerWord >> 2) * K * K; - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize which default value can be changed with the flag -Xss - if (JavaThread::stack_size_at_create() > 0) stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - stack_size = MAX2(stack_size, os::Solaris::min_stack_allowed); + // calculate stack size if it's not specified by caller + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); // Initial state is ALLOCATED but not INITIALIZED osthread->set_state(ALLOCATED); @@ -4400,7 +4384,12 @@ void os::init(void) { // Constant minimum stack size allowed. It must be at least // the minimum of what the OS supports (thr_min_stack()), and // enough to allow the thread to get to user bytecode execution. - Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed); + Posix::_compiler_thread_min_stack_allowed = MAX2(thr_min_stack(), + Posix::_compiler_thread_min_stack_allowed); + Posix::_java_thread_min_stack_allowed = MAX2(thr_min_stack(), + Posix::_java_thread_min_stack_allowed); + Posix::_vm_internal_thread_min_stack_allowed = MAX2(thr_min_stack(), + Posix::_vm_internal_thread_min_stack_allowed); // dynamic lookup of functions that may not be available in our lowest // supported Solaris release @@ -4445,47 +4434,11 @@ jint os::init_2(void) { log_info(os)("Memory Serialize Page address: " INTPTR_FORMAT, p2i(mem_serialize_page)); } - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Solaris::min_stack_allowed = MAX2(os::Solaris::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Solaris::min_stack_allowed = align_size_up(os::Solaris::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Solaris::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, Specify at least %dk", - os::Solaris::min_stack_allowed/K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - // For 64kbps there will be a 64kb page size, which makes - // the usable default stack size quite a bit less. Increase the - // stack for 64kb (or any > than 8kb) pages, this increases - // virtual memory fragmentation (since we're not creating the - // stack on a power of 2 boundary. The real fix for this - // should be to fix the guard page mechanism. - - if (vm_page_size() > 8*K) { - threadStackSizeInBytes = (threadStackSizeInBytes != 0) - ? threadStackSizeInBytes + - JavaThread::stack_red_zone_size() + - JavaThread::stack_yellow_zone_size() - : 0; - ThreadStackSize = threadStackSizeInBytes/K; - } - - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, - vm_page_size())); - Solaris::libthread_init(); if (UseNUMA) { diff --git a/hotspot/src/os/solaris/vm/os_solaris.hpp b/hotspot/src/os/solaris/vm/os_solaris.hpp index 12f72247168..150abcb6486 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.hpp +++ b/hotspot/src/os/solaris/vm/os_solaris.hpp @@ -292,10 +292,6 @@ class Solaris { static jint _os_thread_limit; static volatile jint _os_thread_count; - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - - static size_t min_stack_allowed; // Stack overflow handling diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index d8034537e2d..3b075455d92 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -4215,7 +4215,7 @@ jint os::init_2(void) { min_stack_allowed = align_size_up(min_stack_allowed, os::vm_page_size()); if (actual_reserve_size < min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " + tty->print_cr("\nThe Java thread stack size specified is too small. " "Specify at least %dk", min_stack_allowed / K); return JNI_ERR; diff --git a/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp b/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp index c730ed269f8..50096a18c53 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,10 +33,6 @@ define_pd_global(bool, DontYieldALot, false); define_pd_global(intx, ThreadStackSize, 2048); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 2048); -// if we set CompilerThreadStackSize to a value different than 0, it will -// be used in os::create_thread(). Otherwise, due the strange logic in os::create_thread(), -// the stack size for compiler threads will default to VMThreadStackSize, although it -// is defined to 4M in os::Aix::default_stack_size()! define_pd_global(intx, CompilerThreadStackSize, 4096); // Allow extra space in DEBUG builds for asserts. diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index e5c986743ff..7a40c0df126 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -533,23 +533,17 @@ void os::Aix::init_thread_fpu_state(void) { //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Aix::min_stack_allowed = 128*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type -size_t os::Aix::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) - // Notice that the setting for compiler threads here have no impact - // because of the strange 'fallback logic' in os::create_thread(). - // Better set CompilerThreadStackSize in globals_.hpp if you want to - // specify a different stack size for compiler threads! size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); return s; } -size_t os::Aix::default_guard_size(os::ThreadType thr_type) { - return 2 * page_size(); -} - ///////////////////////////////////////////////////////////////////////////// // helper functions for fatal error handler diff --git a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp index 3711f37f6d0..b17ee1c2f86 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,11 @@ // define_pd_global(bool, DontYieldALot, false); #ifdef AMD64 +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 1024); #else +define_pd_global(intx, CompilerThreadStackSize, 512); // ThreadStackSize 320 allows a couple of test cases to run while // keeping the number of threads that can be created high. System // default ThreadStackSize appears to be 512 which is too big. @@ -41,7 +43,6 @@ define_pd_global(intx, ThreadStackSize, 320); define_pd_global(intx, VMThreadStackSize, 512); #endif // AMD64 -define_pd_global(intx, CompilerThreadStackSize, 0); define_pd_global(size_t, JVMInvokeMethodSlack, 8192); diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index 0bdbc7c3aaa..6e3de2d6f9e 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -838,9 +838,13 @@ bool os::is_allocatable(size_t bytes) { // thread stack #ifdef AMD64 -size_t os::Bsd::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #else -size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; #ifdef __GNUC__ #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) @@ -849,7 +853,7 @@ size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; #endif // AMD64 // return default stack size for thr_type -size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) #ifdef AMD64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); @@ -859,11 +863,6 @@ size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { return s; } -size_t os::Bsd::default_guard_size(os::ThreadType thr_type) { - // Creating guard page is very expensive. Java thread has HotSpot - // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); -} // Java thread: // diff --git a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp index f7ff3e51b96..9a6b38bc0fc 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp @@ -282,9 +282,11 @@ bool os::is_allocatable(size_t bytes) { /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Bsd::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; -size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { #ifdef _LP64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); #else @@ -293,12 +295,6 @@ size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { return s; } -size_t os::Bsd::default_guard_size(os::ThreadType thr_type) { - // Only enable glibc guard pages for non-Java threads - // (Java threads have HotSpot guard pages) - return (thr_type == java_thread ? 0 : page_size()); -} - static void current_stack_region(address *bottom, size_t *size) { address stack_bottom; address stack_top; diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp b/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp index 420453ba864..360be743ddc 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,7 +33,7 @@ define_pd_global(bool, DontYieldALot, false); define_pd_global(intx, ThreadStackSize, 2048); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 2048); -define_pd_global(intx, CompilerThreadStackSize, 0); +define_pd_global(intx, CompilerThreadStackSize, 2048); define_pd_global(uintx,JVMInvokeMethodSlack, 8192); diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp index b4bc43a81c6..21d185d5d70 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp @@ -473,10 +473,12 @@ bool os::is_allocatable(size_t bytes) { //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); return s; diff --git a/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp b/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp index 1d995a9ee4c..3787aeb1168 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,10 +33,6 @@ define_pd_global(bool, DontYieldALot, false); define_pd_global(intx, ThreadStackSize, 2048); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 2048); -// if we set CompilerThreadStackSize to a value different than 0, it will -// be used in os::create_thread(). Otherwise, due the strange logic in os::create_thread(), -// the stack size for compiler threads will default to VMThreadStackSize, although it -// is defined to 4M in os::Linux::default_stack_size()! define_pd_global(intx, CompilerThreadStackSize, 4096); // Allow extra space in DEBUG builds for asserts. diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 554dfa42286..3dce4275405 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -533,15 +533,13 @@ void os::Linux::set_fpu_control_word(int fpu_control) { //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 128*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) - // Notice that the setting for compiler threads here have no impact - // because of the strange 'fallback logic' in os::create_thread(). - // Better set CompilerThreadStackSize in globals_.hpp if you want to - // specify a different stack size for compiler threads! size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K); return s; } diff --git a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp index bc3c7f0ec7d..df6cad419fb 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ // define_pd_global(size_t, JVMInvokeMethodSlack, 12288); -define_pd_global(intx, CompilerThreadStackSize, 0); // Used on 64 bit platforms for UseCompressedOops base address define_pd_global(size_t, HeapBaseMinAddress, CONST64(4)*G); diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index 7cf5edb70b0..a5d435cae75 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -726,10 +726,12 @@ bool os::is_allocatable(size_t bytes) { /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 128 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); return s; diff --git a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp index b123d90c994..4d5069e5a8c 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp +++ b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -30,9 +30,11 @@ define_pd_global(bool, DontYieldALot, false); #ifdef AMD64 +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 1024); #else +define_pd_global(intx, CompilerThreadStackSize, 512); // ThreadStackSize 320 allows a couple of test cases to run while // keeping the number of threads that can be created high. System // default ThreadStackSize appears to be 512 which is too big. @@ -40,8 +42,6 @@ define_pd_global(intx, ThreadStackSize, 320); define_pd_global(intx, VMThreadStackSize, 512); #endif // AMD64 -define_pd_global(intx, CompilerThreadStackSize, 0); - define_pd_global(size_t, JVMInvokeMethodSlack, 8192); // Used on 64 bit platforms for UseCompressedOops base address diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 6eeb1280c82..e7566c7d4af 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -676,13 +676,17 @@ bool os::is_allocatable(size_t bytes) { // thread stack #ifdef AMD64 -size_t os::Linux::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #else -size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; #endif // AMD64 // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) #ifdef AMD64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); diff --git a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp index b43499ec772..b5d7401282c 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp +++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp @@ -307,9 +307,11 @@ bool os::is_allocatable(size_t bytes) { /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { #ifdef _LP64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); #else diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp index fa63ce0fc12..049d214a677 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ // define_pd_global(size_t, JVMInvokeMethodSlack, 12288); -define_pd_global(intx, CompilerThreadStackSize, 0); // Used on 64 bit platforms for UseCompressedOops base address #ifdef _LP64 diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index cf782a2f75f..864080d2073 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -84,9 +84,13 @@ // Minimum stack size for the VM. It's easier to document a constant // but it's different for x86 and sparc because the page sizes are different. #ifdef _LP64 -size_t os::Solaris::min_stack_allowed = 128*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; #else -size_t os::Solaris::min_stack_allowed = 96*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 96 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 96 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 96 * K; #endif int os::Solaris::max_register_window_saves_before_flushing() { diff --git a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp index 0c3016edffe..632dc1e0c85 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -30,10 +30,12 @@ define_pd_global(bool, DontYieldALot, true); // Determined in the design center #ifdef AMD64 +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 1024); define_pd_global(size_t, JVMInvokeMethodSlack, 8*K); #else +define_pd_global(intx, CompilerThreadStackSize, 512); // ThreadStackSize 320 allows a couple of test cases to run while // keeping the number of threads that can be created high. define_pd_global(intx, ThreadStackSize, 320); @@ -41,7 +43,6 @@ define_pd_global(intx, VMThreadStackSize, 512); define_pd_global(size_t, JVMInvokeMethodSlack, 10*K); #endif // AMD64 -define_pd_global(intx, CompilerThreadStackSize, 0); // Used on 64 bit platforms for UseCompressedOops base address define_pd_global(size_t, HeapBaseMinAddress, 2*G); diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index ef64ff751d0..bc79053f81d 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -86,15 +86,19 @@ #define MAX_PATH (2 * K) -// Minimum stack size for the VM. It's easier to document a constant value +// Minimum stack sizes for the VM. It's easier to document a constant value // but it's different for x86 and sparc because the page sizes are different. #ifdef AMD64 -size_t os::Solaris::min_stack_allowed = 224*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 394 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 224 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 224 * K; #define REG_SP REG_RSP #define REG_PC REG_RIP #define REG_FP REG_RBP #else -size_t os::Solaris::min_stack_allowed = 64*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #define REG_SP UESP #define REG_PC EIP #define REG_FP EBP diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp index d6797b306d5..fb4286becd3 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp @@ -32,6 +32,7 @@ #include "gc/g1/heapRegionSet.hpp" #include "logging/logStream.hpp" #include "utilities/debug.hpp" +#include "utilities/quickSort.hpp" G1CollectorState* G1CollectionSet::collector_state() { return _g1->collector_state(); @@ -396,6 +397,16 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi return time_remaining_ms; } +static int compare_region_idx(const uint a, const uint b) { + if (a > b) { + return 1; + } else if (a == b) { + return 0; + } else { + return -1; + } +} + void G1CollectionSet::finalize_old_part(double time_remaining_ms) { double non_young_start_time_sec = os::elapsedTime(); double predicted_old_time_ms = 0.0; @@ -493,6 +504,8 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { double non_young_end_time_sec = os::elapsedTime(); phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0); + + QuickSort::sort(_collection_set_regions, (int)_collection_set_cur_length, compare_region_idx, true); } #ifdef ASSERT diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 2f14e088f3f..9084f46c3be 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -1904,7 +1904,8 @@ G1ConcurrentMark::claim_region(uint worker_id) { assert(_g1h->is_in_g1_reserved(finger), "invariant"); HeapRegion* curr_region = _g1h->heap_region_containing(finger); - + // Make sure that the reads below do not float before loading curr_region. + OrderAccess::loadload(); // Above heap_region_containing may return NULL as we always scan claim // until the end of the heap. In this case, just jump to the next region. HeapWord* end = curr_region != NULL ? curr_region->end() : finger + HeapRegion::GrainWords; diff --git a/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp index 4eed0960dca..9834fbd8c7f 100644 --- a/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp @@ -132,9 +132,16 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations); { G1RootProcessor root_processor(g1h, 1); - root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, - &GenMarkSweep::follow_cld_closure, - &follow_code_closure); + if (ClassUnloading) { + root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); + } else { + root_processor.process_all_roots_no_string_table( + &GenMarkSweep::follow_root_closure, + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); + } } { @@ -157,7 +164,7 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, // This is the point where the entire marking should have completed. assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed"); - { + if (ClassUnloading) { GCTraceTime(Debug, gc, phases) trace("Class Unloading", gc_timer()); // Unload classes and purge the SystemDictionary. diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp index f8526e778e9..8c4642d0ccb 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp @@ -83,6 +83,7 @@ void G1RootProcessor::evacuate_roots(G1EvacuationRootClosures* closures, uint wo } process_vm_roots(closures, phase_times, worker_i); + process_string_table_roots(closures, phase_times, worker_i); { // Now the CM ref_processor roots. @@ -191,19 +192,34 @@ public: void G1RootProcessor::process_all_roots(OopClosure* oops, CLDClosure* clds, - CodeBlobClosure* blobs) { + CodeBlobClosure* blobs, + bool process_string_table) { AllRootsClosures closures(oops, clds); process_java_roots(&closures, NULL, 0); process_vm_roots(&closures, NULL, 0); - if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { - CodeCache::blobs_do(blobs); + if (process_string_table) { + process_string_table_roots(&closures, NULL, 0); } + process_code_cache_roots(blobs, NULL, 0); _process_strong_tasks.all_tasks_completed(n_workers()); } +void G1RootProcessor::process_all_roots(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs) { + process_all_roots(oops, clds, blobs, true); +} + +void G1RootProcessor::process_all_roots_no_string_table(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs) { + assert(!ClassUnloading, "Should only be used when class unloading is disabled"); + process_all_roots(oops, clds, blobs, false); +} + void G1RootProcessor::process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i) { @@ -280,14 +296,23 @@ void G1RootProcessor::process_vm_roots(G1RootClosures* closures, SystemDictionary::roots_oops_do(strong_roots, weak_roots); } } +} - { - G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); - // All threads execute the following. A specific chunk of buckets - // from the StringTable are the individual tasks. - if (weak_roots != NULL) { - StringTable::possibly_parallel_oops_do(weak_roots); - } +void G1RootProcessor::process_string_table_roots(G1RootClosures* closures, + G1GCPhaseTimes* phase_times, + uint worker_i) { + assert(closures->weak_oops() != NULL, "Should only be called when all roots are processed"); + G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); + // All threads execute the following. A specific chunk of buckets + // from the StringTable are the individual tasks. + StringTable::possibly_parallel_oops_do(closures->weak_oops()); +} + +void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure, + G1GCPhaseTimes* phase_times, + uint worker_i) { + if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { + CodeCache::blobs_do(code_closure); } } diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp index ad0f0479810..11cb6723559 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp @@ -73,6 +73,11 @@ class G1RootProcessor : public StackObj { void worker_has_discovered_all_strong_classes(); void wait_until_all_strong_classes_discovered(); + void process_all_roots(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs, + bool process_string_table); + void process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i); @@ -81,6 +86,14 @@ class G1RootProcessor : public StackObj { G1GCPhaseTimes* phase_times, uint worker_i); + void process_string_table_roots(G1RootClosures* closures, + G1GCPhaseTimes* phase_times, + uint worker_i); + + void process_code_cache_roots(CodeBlobClosure* code_closure, + G1GCPhaseTimes* phase_times, + uint worker_i); + public: G1RootProcessor(G1CollectedHeap* g1h, uint n_workers); @@ -99,6 +112,13 @@ public: CLDClosure* clds, CodeBlobClosure* blobs); + // Apply oops, clds and blobs to strongly and weakly reachable roots in the system, + // the only thing different from process_all_roots is that we skip the string table + // to avoid keeping every string live when doing class unloading. + void process_all_roots_no_string_table(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs); + // Number of worker threads used by the root processor. uint n_workers() const; }; diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp index 06b04eeefea..1f6bc95b1ad 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp @@ -123,6 +123,7 @@ void HeapRegionManager::make_regions_available(uint start, uint num_regions) { for (uint i = start; i < start + num_regions; i++) { if (_regions.get_by_index(i) == NULL) { HeapRegion* new_hr = new_heap_region(i); + OrderAccess::storestore(); _regions.set_by_index(i, new_hr); _allocated_heapregions_length = MAX2(_allocated_heapregions_length, i + 1); } diff --git a/hotspot/src/share/vm/gc/shared/gcTrace.cpp b/hotspot/src/share/vm/gc/shared/gcTrace.cpp index b275feed4b9..f3a1a873da5 100644 --- a/hotspot/src/share/vm/gc/shared/gcTrace.cpp +++ b/hotspot/src/share/vm/gc/shared/gcTrace.cpp @@ -185,8 +185,10 @@ void OldGCTracer::report_concurrent_mode_failure() { } #if INCLUDE_ALL_GCS -void G1MMUTracer::report_mmu(double timeSlice, double gcTime, double maxTime) { - send_g1_mmu_event(timeSlice, gcTime, maxTime); +void G1MMUTracer::report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec) { + send_g1_mmu_event(time_slice_sec * MILLIUNITS, + gc_time_sec * MILLIUNITS, + max_time_sec * MILLIUNITS); } void G1NewTracer::report_yc_type(G1YCType type) { diff --git a/hotspot/src/share/vm/gc/shared/gcTrace.hpp b/hotspot/src/share/vm/gc/shared/gcTrace.hpp index d45526e87d3..20cc55ecd49 100644 --- a/hotspot/src/share/vm/gc/shared/gcTrace.hpp +++ b/hotspot/src/share/vm/gc/shared/gcTrace.hpp @@ -235,10 +235,10 @@ class ParNewTracer : public YoungGCTracer { #if INCLUDE_ALL_GCS class G1MMUTracer : public AllStatic { - static void send_g1_mmu_event(double timeSlice, double gcTime, double maxTime); + static void send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms); public: - static void report_mmu(double timeSlice, double gcTime, double maxTime); + static void report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec); }; class G1NewTracer : public YoungGCTracer { diff --git a/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp b/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp index 046db77d4d5..2a2711d3e34 100644 --- a/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp +++ b/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp @@ -200,13 +200,13 @@ void G1NewTracer::send_g1_young_gc_event() { } } -void G1MMUTracer::send_g1_mmu_event(double timeSlice, double gcTime, double maxTime) { +void G1MMUTracer::send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms) { EventG1MMU e; if (e.should_commit()) { e.set_gcId(GCId::current()); - e.set_timeSlice(timeSlice); - e.set_gcTime(gcTime); - e.set_maxGcTime(maxTime); + e.set_timeSlice(time_slice_ms); + e.set_gcTime(gc_time_ms); + e.set_pauseTarget(max_time_ms); e.commit(); } } @@ -281,10 +281,10 @@ void G1NewTracer::send_basic_ihop_statistics(size_t threshold, evt.set_targetOccupancy(target_occupancy); evt.set_thresholdPercentage(target_occupancy > 0 ? ((double)threshold / target_occupancy) : 0.0); evt.set_currentOccupancy(current_occupancy); - evt.set_lastAllocationSize(last_allocation_size); - evt.set_lastAllocationDuration(last_allocation_duration); - evt.set_lastAllocationRate(last_allocation_duration != 0.0 ? last_allocation_size / last_allocation_duration : 0.0); - evt.set_lastMarkingLength(last_marking_length); + evt.set_recentMutatorAllocationSize(last_allocation_size); + evt.set_recentMutatorDuration(last_allocation_duration * MILLIUNITS); + evt.set_recentAllocationRate(last_allocation_duration != 0.0 ? last_allocation_size / last_allocation_duration : 0.0); + evt.set_lastMarkingDuration(last_marking_length * MILLIUNITS); evt.commit(); } } @@ -301,11 +301,11 @@ void G1NewTracer::send_adaptive_ihop_statistics(size_t threshold, evt.set_gcId(GCId::current()); evt.set_threshold(threshold); evt.set_thresholdPercentage(internal_target_occupancy > 0 ? ((double)threshold / internal_target_occupancy) : 0.0); - evt.set_internalTargetOccupancy(internal_target_occupancy); + evt.set_ihopTargetOccupancy(internal_target_occupancy); evt.set_currentOccupancy(current_occupancy); evt.set_additionalBufferSize(additional_buffer_size); evt.set_predictedAllocationRate(predicted_allocation_rate); - evt.set_predictedMarkingLength(predicted_marking_length); + evt.set_predictedMarkingDuration(predicted_marking_length * MILLIUNITS); evt.set_predictionActive(prediction_active); evt.commit(); } diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 6228453f6cc..6ef4f96ed08 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -894,6 +894,7 @@ static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, F } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, false); Flag::Error result = (*TAt)(flag_name, value, true, true); env->ReleaseStringUTFChars(name, flag_name); return (result == Flag::SUCCESS); @@ -906,6 +907,7 @@ static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, F } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, false); Flag::Error result = (*TAtPut)(flag_name, value, Flag::INTERNAL); env->ReleaseStringUTFChars(name, flag_name); return (result == Flag::SUCCESS); @@ -944,6 +946,7 @@ static jobject doubleBox(JavaThread* thread, JNIEnv* env, jdouble value) { static Flag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, NULL); Flag* result = Flag::find_flag(flag_name, strlen(flag_name), true, true); env->ReleaseStringUTFChars(name, flag_name); return result; @@ -1084,7 +1087,14 @@ WB_END WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value)) ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI - const char* ccstrValue = (value == NULL) ? NULL : env->GetStringUTFChars(value, NULL); + const char* ccstrValue; + if (value == NULL) { + ccstrValue = NULL; + } + else { + ccstrValue = env->GetStringUTFChars(value, NULL); + CHECK_JNI_EXCEPTION(env); + } ccstr ccstrResult = ccstrValue; bool needFree; { @@ -1308,6 +1318,7 @@ WB_ENTRY(jobjectArray, WB_GetCodeHeapEntries(JNIEnv* env, jobject o, jint blob_t jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); CHECK_JNI_EXCEPTION_(env, NULL); result = env->NewObjectArray(blobs.length(), clazz, NULL); + CHECK_JNI_EXCEPTION_(env, NULL); if (result == NULL) { return result; } @@ -1317,6 +1328,7 @@ WB_ENTRY(jobjectArray, WB_GetCodeHeapEntries(JNIEnv* env, jobject o, jint blob_t jobjectArray obj = codeBlob2objectArray(thread, env, *it); CHECK_JNI_EXCEPTION_(env, NULL); env->SetObjectArrayElement(result, i, obj); + CHECK_JNI_EXCEPTION_(env, NULL); ++i; } return result; @@ -1523,6 +1535,7 @@ static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jst // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, false); bool result = CompilerOracle::has_option_value(mh, flag_name, *value); env->ReleaseStringUTFChars(name, flag_name); return result; @@ -1678,6 +1691,7 @@ WB_ENTRY(jint, WB_AddCompilerDirective(JNIEnv* env, jobject o, jstring compDirec // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); const char* dir = env->GetStringUTFChars(compDirect, NULL); + CHECK_JNI_EXCEPTION_(env, 0); int ret; { ThreadInVMfromNative ttvfn(thread); // back to VM diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp index 6398b4ca0d9..8402195fcaf 100644 --- a/hotspot/src/share/vm/prims/whitebox.hpp +++ b/hotspot/src/share/vm/prims/whitebox.hpp @@ -33,9 +33,22 @@ #include "oops/symbol.hpp" #include "runtime/interfaceSupport.hpp" +// Unconditionally clear pedantic pending JNI checks +class ClearPendingJniExcCheck : public StackObj { +private: + JavaThread* _thread; +public: + ClearPendingJniExcCheck(JNIEnv* env) : _thread(JavaThread::thread_from_jni_environment(env)) {} + ~ClearPendingJniExcCheck() { + _thread->clear_pending_jni_exception_check(); + } +}; + // Entry macro to transition from JNI to VM state. -#define WB_ENTRY(result_type, header) JNI_ENTRY(result_type, header) +#define WB_ENTRY(result_type, header) JNI_ENTRY(result_type, header) \ + ClearPendingJniExcCheck _clearCheck(env); + #define WB_END JNI_END #define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index e897e9cdf50..e7e45e9fcd1 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1308,35 +1308,13 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop return true; } -// sets or adds a module name to the jdk.module.addmods property -bool Arguments::append_to_addmods_property(const char* module_name) { - const char* key = "jdk.module.addmods"; - const char* old_value = Arguments::get_property(key); - size_t buf_len = strlen(key) + strlen(module_name) + 2; - if (old_value != NULL) { - buf_len += strlen(old_value) + 1; - } - char* new_value = AllocateHeap(buf_len, mtArguments); - if (new_value == NULL) { - return false; - } - if (old_value == NULL) { - jio_snprintf(new_value, buf_len, "%s=%s", key, module_name); - } else { - jio_snprintf(new_value, buf_len, "%s=%s,%s", key, old_value, module_name); - } - bool added = add_property(new_value, UnwriteableProperty, InternalProperty); - FreeHeap(new_value); - return added; -} - #if INCLUDE_CDS void Arguments::check_unsupported_dumping_properties() { assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); const char* unsupported_properties[5] = { "jdk.module.main", "jdk.module.path", "jdk.module.upgrade.path", - "jdk.module.addmods", + "jdk.module.addmods.0", "jdk.module.limitmods" }; const char* unsupported_options[5] = { "-m", "--module-path", @@ -1687,11 +1665,6 @@ void Arguments::set_cms_and_parnew_gc_flags() { CompactibleFreeListSpaceLAB::modify_initialization(OldPLABSize, OldPLABWeight); } - if (!ClassUnloading) { - FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); - FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false); - } - log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); } #endif // INCLUDE_ALL_GCS @@ -2019,6 +1992,13 @@ void Arguments::set_gc_specific_flags() { // Keeping the heap 100% free is hard ;-) so limit it to 99%. FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); } + + // If class unloading is disabled, also disable concurrent class unloading. + if (!ClassUnloading) { + FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); + FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); + FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false); + } #endif // INCLUDE_ALL_GCS } @@ -2566,8 +2546,8 @@ bool Arguments::parse_uintx(const char* value, unsigned int addreads_count = 0; unsigned int addexports_count = 0; +unsigned int addmods_count = 0; unsigned int patch_mod_count = 0; -const char* add_modules_value = NULL; bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) { size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2; @@ -2821,7 +2801,9 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m return JNI_ENOMEM; } } else if (match_option(option, "--add-modules=", &tail)) { - add_modules_value = tail; + if (!create_numbered_property("jdk.module.addmods", tail, addmods_count++)) { + return JNI_ENOMEM; + } } else if (match_option(option, "--limit-modules=", &tail)) { if (!create_property("jdk.module.limitmods", tail, InternalProperty)) { return JNI_ENOMEM; @@ -2873,7 +2855,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail); add_init_agent("instrument", options, false); // java agents need module java.instrument - if (!Arguments::append_to_addmods_property("java.instrument")) { + if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) { return JNI_ENOMEM; } } @@ -3149,7 +3131,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m return JNI_EINVAL; } // management agent in module java.management - if (!Arguments::append_to_addmods_property("java.management")) { + if (!create_numbered_property("jdk.module.addmods", "java.management", addmods_count++)) { return JNI_ENOMEM; } #else @@ -3560,15 +3542,6 @@ jint Arguments::finalize_vm_init_args() { return JNI_ERR; } - // Append the value of the last --add-modules option specified on the command line. - // This needs to be done here, to prevent overwriting possible values written - // to the jdk.module.addmods property by -javaagent and other options. - if (add_modules_value != NULL) { - if (!append_to_addmods_property(add_modules_value)) { - return JNI_ENOMEM; - } - } - // This must be done after all arguments have been processed. // java_compiler() true means set to "NONE" or empty. if (java_compiler() && !xdebug_mode()) { @@ -3617,7 +3590,8 @@ jint Arguments::finalize_vm_init_args() { #endif #if INCLUDE_JVMCI - if (EnableJVMCI && !append_to_addmods_property("jdk.vm.ci")) { + if (EnableJVMCI && + !create_numbered_property("jdk.module.addmods", "jdk.vm.ci", addmods_count++)) { return JNI_ENOMEM; } #endif diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index dbac4f710b0..c989e61fe07 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -489,9 +489,6 @@ class Arguments : AllStatic { static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase); - // Miscellaneous system property setter - static bool append_to_addmods_property(const char* module_name); - // Aggressive optimization flags. static jint set_aggressive_opts_flags(); diff --git a/hotspot/src/share/vm/runtime/interfaceSupport.hpp b/hotspot/src/share/vm/runtime/interfaceSupport.hpp index 840d68e2444..7b7d01fa9d3 100644 --- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp +++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp @@ -280,6 +280,7 @@ class ThreadToNativeFromVM : public ThreadStateTransition { ~ThreadToNativeFromVM() { trans_from_native(_thread_in_vm); + assert(!_thread->is_pending_jni_exception_check(), "Pending JNI Exception Check"); // We don't need to clear_walkable because it will happen automagically when we return to java } }; diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 431e7b2a985..4f714e3cec2 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -443,7 +443,7 @@ class os: AllStatic { static bool create_thread(Thread* thread, ThreadType thr_type, - size_t stack_size = 0); + size_t req_stack_size = 0); static bool create_main_thread(JavaThread* thread); static bool create_attached_thread(JavaThread* thread); static void pd_start_thread(Thread* thread); diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 37e6ed310c0..2925dee0b50 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -1542,6 +1542,9 @@ class JavaThread: public Thread { static ByteSize jmp_ring_offset() { return byte_offset_of(JavaThread, _jmp_ring); } #endif // PRODUCT static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment); } + static ByteSize pending_jni_exception_check_fn_offset() { + return byte_offset_of(JavaThread, _pending_jni_exception_check_fn); + } static ByteSize last_Java_sp_offset() { return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset(); } @@ -1615,7 +1618,11 @@ class JavaThread: public Thread { assert(_jni_active_critical >= 0, "JNI critical nesting problem?"); } - // Checked JNI, is the programmer required to check for exceptions, specify which function name + // Checked JNI: is the programmer required to check for exceptions, if so specify + // which function name. Returning to a Java frame should implicitly clear the + // pending check, this is done for Native->Java transitions (i.e. user JNI code). + // VM->Java transistions are not cleared, it is expected that JNI code enclosed + // within ThreadToNativeFromVM makes proper exception checks (i.e. VM internal). bool is_pending_jni_exception_check() const { return _pending_jni_exception_check_fn != NULL; } void clear_pending_jni_exception_check() { _pending_jni_exception_check_fn = NULL; } const char* get_pending_jni_exception_check() const { return _pending_jni_exception_check_fn; } diff --git a/hotspot/src/share/vm/trace/traceevents.xml b/hotspot/src/share/vm/trace/traceevents.xml index f3b6447127a..c2a5fe7a61d 100644 --- a/hotspot/src/share/vm/trace/traceevents.xml +++ b/hotspot/src/share/vm/trace/traceevents.xml @@ -315,9 +315,9 @@ Declares a structure type that can be used in other events. - - - + + + @@ -377,29 +377,29 @@ Declares a structure type that can be used in other events. - - - - - - - - - + + + + + + + + - - - - - - + + + + + - + diff --git a/hotspot/src/share/vm/utilities/exceptions.cpp b/hotspot/src/share/vm/utilities/exceptions.cpp index fa4981986ef..2bb3d77e6a5 100644 --- a/hotspot/src/share/vm/utilities/exceptions.cpp +++ b/hotspot/src/share/vm/utilities/exceptions.cpp @@ -80,7 +80,7 @@ bool Exceptions::special_exception(Thread* thread, const char* file, int line, H if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) { InstanceKlass* ik = InstanceKlass::cast(h_exception->klass()); assert(ik->is_initialized(), - "need to increase min_stack_allowed calculation"); + "need to increase java_thread_min_stack_allowed calculation"); } #endif // ASSERT @@ -227,7 +227,7 @@ void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file Klass* k = SystemDictionary::StackOverflowError_klass(); oop e = InstanceKlass::cast(k)->allocate_instance(CHECK); exception = Handle(THREAD, e); // fill_in_stack trace does gc - assert(InstanceKlass::cast(k)->is_initialized(), "need to increase min_stack_allowed calculation"); + assert(InstanceKlass::cast(k)->is_initialized(), "need to increase java_thread_min_stack_allowed calculation"); if (StackTraceInThrowable) { java_lang_Throwable::fill_in_stack_trace(exception, method()); } diff --git a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java index 0aa9dc3bb35..476b52d09d0 100644 --- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java +++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java @@ -48,8 +48,8 @@ public abstract class AESIntrinsicsBase extends CommandLineOptionTest { = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintIntrinsics"}; public static final String[] TEST_AES_CMD = {"-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintFlagsFinal", - "-Xbatch", "-DcheckOutput=true", "-Dmode=CBC", - TestAESMain.class.getName()}; + "-Xbatch", "-XX:CompileThresholdScaling=0.01", "-DcheckOutput=true", "-Dmode=CBC", + TestAESMain.class.getName(), "100", "1000"}; protected AESIntrinsicsBase(BooleanSupplier predicate) { super(predicate); diff --git a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java index 5f3b533c39d..a649e045bed 100644 --- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java +++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java @@ -27,11 +27,11 @@ * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management - * @ignore 8146128 * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * @run main/othervm/timeout=600 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions * -XX:+WhiteBoxAPI -Xbatch * compiler.cpuflags.TestAESIntrinsicsOnSupportedConfig */ diff --git a/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java b/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java new file mode 100644 index 00000000000..96f10bbcd60 --- /dev/null +++ b/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reqserved. + * 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 + * @key gc + * @bug 8114823 + * @requires vm.gc == null + * @requires vm.opt.ExplicitGCInvokesConcurrent != true + * @requires vm.opt.ClassUnloading != true + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseG1GC TestClassUnloadingDisabled + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseSerialGC TestClassUnloadingDisabled + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseParallelGC TestClassUnloadingDisabled + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseConcMarkSweepGC TestClassUnloadingDisabled + */ + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import sun.hotspot.WhiteBox; + +import static jdk.test.lib.Asserts.*; + +public class TestClassUnloadingDisabled { + public static void main(String args[]) throws Exception { + final WhiteBox wb = WhiteBox.getWhiteBox(); + // Fetch the dir where the test class and the class + // to be loaded resides. + String classDir = TestClassUnloadingDisabled.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + String className = "ClassToLoadUnload"; + + assertFalse(wb.isClassAlive(className), "Should not be loaded yet"); + + // The NoPDClassLoader handles loading classes in the test directory + // and loads them without a protection domain, which in some cases + // keeps the class live regardless of marking state. + NoPDClassLoader nopd = new NoPDClassLoader(classDir); + nopd.loadClass(className); + + assertTrue(wb.isClassAlive(className), "Class should be loaded"); + + // Clear the class-loader, class and object references to make + // class unloading possible. + nopd = null; + + System.gc(); + assertTrue(wb.isClassAlive(className), "Class should not have ben unloaded"); + } +} + +class NoPDClassLoader extends ClassLoader { + String path; + + NoPDClassLoader(String path) { + this.path = path; + } + + public Class loadClass(String name) throws ClassNotFoundException { + byte[] cls = null; + File f = new File(path,name + ".class"); + + // Delegate class loading if class not present in the given + // directory. + if (!f.exists()) { + return super.loadClass(name); + } + + try { + Path path = Paths.get(f.getAbsolutePath()); + cls = Files.readAllBytes(path); + } catch (IOException e) { + throw new ClassNotFoundException(name); + } + + // Define class with no protection domain and resolve it. + return defineClass(name, cls, 0, cls.length, null); + } +} + +class ClassToLoadUnload { +} diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index 303912d4e20..bd188d6cec8 100644 --- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -88,20 +88,6 @@ public class TestOptionsWithRanges { */ excludeTestMaxRange("CICompilerCount"); - /* - * JDK-8136766 - * Temporarily remove ThreadStackSize from testing because Windows can set it to 0 - * (for default OS size) but other platforms insist it must be greater than 0 - */ - excludeTestRange("ThreadStackSize"); - - /* - * Remove the flag controlling the size of the stack because the - * flag has direct influence on the physical memory usage of - * the VM. - */ - allOptionsAsMap.remove("CompilerThreadStackSize"); - /* * Exclude MallocMaxTestWords as it is expected to exit VM at small values (>=0) */ @@ -124,6 +110,8 @@ public class TestOptionsWithRanges { excludeTestMaxRange("OldSize"); excludeTestMaxRange("ParallelGCThreads"); + excludeTestMaxRange("CompilerThreadStackSize"); + excludeTestMaxRange("ThreadStackSize"); excludeTestMaxRange("VMThreadStackSize"); /* diff --git a/hotspot/test/runtime/LocalLong/LocalLongHelper.java b/hotspot/test/runtime/LocalLong/LocalLongHelper.java new file mode 100644 index 00000000000..2134aee069e --- /dev/null +++ b/hotspot/test/runtime/LocalLong/LocalLongHelper.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.lang.StackWalker.StackFrame; + +public class LocalLongHelper { + static StackWalker sw; + static Method intValue; + static Method getLocals; + static Class primitiveValueClass; + static Method primitiveType; + static Method getMethodType; + static Field memberName; + static Field offset; + + public static void main(String[] args) throws Throwable { + setupReflectionStatics(); + new LocalLongHelper().longArg(0xC0FFEE, 0x1234567890ABCDEFL); + } + + // locals[2] contains the high byte of the long argument. + public long longArg(int i, long l) throws Throwable { + List frames = sw.walk(s -> s.collect(Collectors.toList())); + Object[] locals = (Object[]) getLocals.invoke(frames.get(0)); + + int locals_2 = (int) intValue.invoke(locals[2]); + if (locals_2 != 0){ + throw new RuntimeException("Expected locals_2 == 0"); + } + return l; // Don't want l to become a dead var + } + + private static void setupReflectionStatics() throws Throwable { + Class liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); + primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue"); + + getLocals = liveStackFrameClass.getDeclaredMethod("getLocals"); + getLocals.setAccessible(true); + + intValue = primitiveValueClass.getDeclaredMethod("intValue"); + intValue.setAccessible(true); + + Class stackFrameInfoClass = Class.forName("java.lang.StackFrameInfo"); + memberName = stackFrameInfoClass.getDeclaredField("memberName"); + memberName.setAccessible(true); + offset = stackFrameInfoClass.getDeclaredField("bci"); + offset.setAccessible(true); + getMethodType = Class.forName("java.lang.invoke.MemberName").getDeclaredMethod("getMethodType"); + getMethodType.setAccessible(true); + + Class extendedOptionClass = Class.forName("java.lang.StackWalker$ExtendedOption"); + Method ewsNI = StackWalker.class.getDeclaredMethod("newInstance", Set.class, extendedOptionClass); + ewsNI.setAccessible(true); + Field f = extendedOptionClass.getDeclaredField("LOCALS_AND_OPERANDS"); + f.setAccessible(true); + Object localsAndOperandsOption = f.get(null); + + primitiveType = primitiveValueClass.getDeclaredMethod("type"); + primitiveType.setAccessible(true); + + sw = (StackWalker) ewsNI.invoke(null, java.util.Collections.emptySet(), localsAndOperandsOption); + } + + private static String type(Object o) throws Throwable { + if (primitiveValueClass.isInstance(o)) { + final char c = (char) primitiveType.invoke(o); + return String.valueOf(c); + } else if (o != null) { + return o.getClass().getName(); + } else { + return "null"; + } + } +} diff --git a/hotspot/test/runtime/LocalLong/LocalLongTest.java b/hotspot/test/runtime/LocalLong/LocalLongTest.java new file mode 100644 index 00000000000..2c6d8bf2035 --- /dev/null +++ b/hotspot/test/runtime/LocalLong/LocalLongTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, 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 LocalLongTest + * @bug 8163014 + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @compile LocalLongHelper.java + * @run driver LocalLongTest + */ + +import jdk.test.lib.Platform; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class LocalLongTest { + public static void main(String... args) throws Exception { + if (Platform.is64bit()) { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint", + "LocalLongHelper"); + OutputAnalyzer o = new OutputAnalyzer(pb.start()); + o.shouldHaveExitValue(0); + } + }; +} diff --git a/hotspot/test/runtime/Thread/TooSmallStackSize.java b/hotspot/test/runtime/Thread/TooSmallStackSize.java new file mode 100644 index 00000000000..383390503eb --- /dev/null +++ b/hotspot/test/runtime/Thread/TooSmallStackSize.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2016, 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 8140520 + * @summary Setting small CompilerThreadStackSize, ThreadStackSize, and + * VMThreadStackSize values should result in an error message that shows + * the minimum stack size value for each thread type. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run main TooSmallStackSize + */ + +/* + * The primary purpose of this test is to make sure we can run with a + * stack smaller than the minimum without crashing. Also this test will + * determine the minimum allowed stack size for the platform (as + * provided by the JVM error message when a very small stack is used), + * and then verify that the JVM can be launched with that stack size + * without a crash or any error messages. + * + * Note: The '-Xss' and '-XX:ThreadStackSize=' options + * both control Java thread stack size. This repo's version of the test + * exercises the '-XX:ThreadStackSize' VM option. The jdk repo's version + * of the test exercises the '-Xss' option. + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TooSmallStackSize { + /* for debugging. Normally false. */ + static final boolean verbose = false; + static final String CompilerThreadStackSizeString = "CompilerThreadStackSize"; + static final String ThreadStackSizeString = "Java thread stack size"; + static final String VMThreadStackSizeString = "VMThreadStackSize"; + + /* + * Returns the minimum stack size this platform will allowed based on the + * contents of the error message the JVM outputs when too small of a + * stack size was used. + * + * The testOutput argument must contain the result of having already run + * the JVM with too small of a stack size. + */ + static String getMinStackAllowed(String testOutput) { + /* + * The JVM output will contain in one of the lines: + * "The CompilerThreadStackSize specified is too small. Specify at least 100k" + * "The Java thread stack size specified is too small. Specify at least 100k" + * "The VMThreadStackSize specified is too small. Specify at least 100k" + * Although the actual size will vary. We need to extract this size + * string from the output and return it. + */ + String matchStr = "Specify at least "; + int match_idx = testOutput.indexOf(matchStr); + if (match_idx >= 0) { + int size_start_idx = match_idx + matchStr.length(); + int k_start_idx = testOutput.indexOf("k", size_start_idx); + // don't include the 'k'; the caller will have to + // add it back as needed. + return testOutput.substring(size_start_idx, k_start_idx); + } + + System.out.println("Expect='" + matchStr + "'"); + System.out.println("Actual: " + testOutput); + System.out.println("FAILED: Could not get the stack size from the output"); + throw new RuntimeException("test fails"); + } + + /* + * Run the JVM with the specified stack size. + * + * Returns the minimum allowed stack size gleaned from the error message, + * if there is an error message. Otherwise returns the stack size passed in. + */ + static String checkStack(String stackOption, String optionMesg, String stackSize) throws Exception { + String min_stack_allowed; + + System.out.println("*** Testing " + stackOption + stackSize); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + stackOption + stackSize, + // Uncomment the following to get log output + // that shows actual thread creation sizes. + // "-Xlog:os+thread", + "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + if (verbose) { + System.out.println("stdout: " + output.getStdout()); + } + + if (output.getExitValue() == 0) { + // checkMinStackAllowed() is called with stackSize values + // that should be the minimum that works. This method, + // checkStack(), is called with stackSize values that + // should be too small and result in error messages. + // However, some platforms fix up a stackSize value that is + // too small into something that works so we have to allow + // for checkStack() calls that work. + System.out.println("PASSED: got exit_code == 0 with " + stackOption + stackSize); + min_stack_allowed = stackSize; + } else { + String expect = "The " + optionMesg + " specified is too small"; + if (verbose) { + System.out.println("Expect='" + expect + "'"); + } + output.shouldContain(expect); + min_stack_allowed = getMinStackAllowed(output.getStdout()); + + System.out.println("PASSED: got expected error message with " + stackOption + stackSize); + } + + return min_stack_allowed; + } + + /* + * Run the JVM with the minimum allowed stack size. This should always succeed. + */ + static void checkMinStackAllowed(String stackOption, String optionMesg, String stackSize) throws Exception { + System.out.println("*** Testing " + stackOption + stackSize); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + stackOption + stackSize, + // Uncomment the following to get log output + // that shows actual thread creation sizes. + // "-Xlog:os+thread", + "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + + System.out.println("PASSED: VM launched with " + stackOption + stackSize); + } + + public static void main(String... args) throws Exception { + /* + * The result of a 16k stack size should be a quick exit with a complaint + * that the stack size is too small. However, for some win32 builds, the + * stack is always at least 64k, and this also sometimes is the minimum + * allowed size, so we won't see an error in this case. + * + * This test case will also produce a crash on some platforms if the fix + * for 6762191 is not yet in place. + */ + checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "16"); + + /* + * Try with a 32k stack size, which is the size that the launcher will + * set to if you try setting to anything smaller. This should produce the same + * result as setting to 16k if the fix for 6762191 is in place. + */ + String min_stack_allowed = checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "32"); + + /* + * Try again with a the minimum stack size that was given in the error message + */ + checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, min_stack_allowed); + + /* + * Now redo the same tests with the compiler thread stack size: + */ + checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "16"); + min_stack_allowed = checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "32"); + checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, min_stack_allowed); + + /* + * Now redo the same tests with the VM thread stack size: + */ + checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "16"); + min_stack_allowed = checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "32"); + checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, min_stack_allowed); + } +} diff --git a/hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java b/hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java new file mode 100644 index 00000000000..e5e8f9e7ad6 --- /dev/null +++ b/hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2016, 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 8164086 + * @summary regression tests for 8164086, verify correct warning from checked JNI + * @library /test/lib + * @modules java.management + * @run main/native TestCheckedJniExceptionCheck launch + */ + +import java.util.List; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestCheckedJniExceptionCheck { + + static { + System.loadLibrary("TestCheckedJniExceptionCheck"); + } + + int callableMethodInvokeCount = 0; + + static final String TEST_START = "TEST STARTED"; + static final String EXPECT_WARNING_START = "EXPECT_WARNING_START"; + static final String EXPECT_WARNING_END = "EXPECT_WARNING_END"; + + static final String JNI_CHECK_EXCEPTION = "WARNING in native method: JNI call made without checking exceptions when required to from"; + + static void printExpectWarningStart(int count) { + System.out.println(EXPECT_WARNING_START + " " + count); + } + + static void printExpectWarningEnd() { + System.out.println(EXPECT_WARNING_END); + } + + public TestCheckedJniExceptionCheck() { + initMethodIds("callableMethod", "()V", + "callableNestedMethod", "(IZ)V"); + System.out.println(TEST_START); + } + + public void test() { + testSingleCallNoCheck(); + testSingleCallCheck(); + testSingleCallNoCheckMultipleTimes(); + + testMultipleCallsNoCheck(); + testMultipleCallsCheck(); + + testNestedSingleCallsNoCheck(); + testNestedSingleCallsCheck(); + testNestedMultipleCallsNoCheck(); + testNestedMultipleCallsCheck(); + } + + public void testSingleCallNoCheck() { + System.out.println("testSingleCallNoCheck start"); + callJavaFromNative(1, false); + System.out.println("testSingleCallNoCheck end"); + } + + public void testSingleCallCheck() { + System.out.println("testSingleCallCheck start"); + callJavaFromNative(1, true); + System.out.println("testSingleCallCheck end"); + } + + public void testSingleCallNoCheckMultipleTimes() { + System.out.println("testSingleCallNoCheckMultipleTimes start"); + callJavaFromNative(1, false); + callJavaFromNative(1, false); + System.out.println("testSingleCallNoCheckMultipleTimes end"); + } + + public void testMultipleCallsNoCheck() { + System.out.println("testMultipleCallsNoCheck start"); + printExpectWarningStart(1); + callJavaFromNative(2, false); + printExpectWarningEnd(); + System.out.println("testMultipleCallsNoCheck end"); + } + + public void testMultipleCallsCheck() { + System.out.println("testMultipleCallsCheck start"); + callJavaFromNative(2, true); + System.out.println("testMultipleCallsCheck end"); + } + + public void testNestedSingleCallsNoCheck() { + System.out.println("testNestedSingleCallsNoCheck start"); + callNestedJavaFromNative(1, false); + System.out.println("testNestedSingleCallsNoCheck end"); + } + + public void testNestedSingleCallsCheck() { + System.out.println("testNestedSingleCallsCheck start"); + callNestedJavaFromNative(1, true); + System.out.println("testNestedSingleCallsCheck end"); + } + + public void testNestedMultipleCallsNoCheck() { + System.out.println("testNestedMultipleCallsNoCheck start"); + printExpectWarningStart(3); + callNestedJavaFromNative(2, false); + printExpectWarningEnd(); + System.out.println("testNestedMultipleCallsNoCheck end"); + } + + public void testNestedMultipleCallsCheck() { + System.out.println("testNestedMultipleCallsCheck start"); + callNestedJavaFromNative(2, true); + System.out.println("testNestedMultipleCallsCheck end"); + } + + public void callableMethod() { + callableMethodInvokeCount++; + } + + public void callableNestedMethod(int nofCalls, boolean withExceptionChecks) { + callJavaFromNative(nofCalls, withExceptionChecks); + } + + public native void callJavaFromNative(int nofCalls, boolean withExceptionChecks); + + public native void callNestedJavaFromNative(int nofCalls, boolean withExceptionChecks); + + private native void initMethodIds(String callableMethodName, + String callableMethodSig, + String callableNestedMethodName, + String callableNestedMethodSig); + + + // Check warnings appear where they should, with start/end statements in output... + static void checkOuputForCorrectWarnings(OutputAnalyzer oa) throws RuntimeException { + List lines = oa.asLines(); + int expectedWarnings = 0; + int warningCount = 0; + int lineNo = 0; + boolean testStartLine = false; + for (String line : lines) { + lineNo++; + if (!testStartLine) { // Skip any warning before the actual test itself + testStartLine = line.startsWith(TEST_START); + continue; + } + if (line.startsWith(JNI_CHECK_EXCEPTION)) { + if (expectedWarnings == 0) { + oa.reportDiagnosticSummary(); + throw new RuntimeException("Unexpected warning at line " + lineNo); + } + warningCount++; + if (warningCount > expectedWarnings) { + oa.reportDiagnosticSummary(); + throw new RuntimeException("Unexpected warning at line " + lineNo); + } + } + else if (line.startsWith(EXPECT_WARNING_START)) { + String countStr = line.substring(EXPECT_WARNING_START.length() + 1); + expectedWarnings = Integer.parseInt(countStr); + } + else if (line.startsWith(EXPECT_WARNING_END)) { + if (warningCount != expectedWarnings) { + oa.reportDiagnosticSummary(); + throw new RuntimeException("Missing warning at line " + lineNo); + } + warningCount = 0; + expectedWarnings = 0; + } + } + /* + System.out.println("Output looks good..."); + oa.reportDiagnosticSummary(); + */ + } + + public static void main(String[] args) throws Throwable { + if (args == null || args.length == 0) { + new TestCheckedJniExceptionCheck().test(); + return; + } + + // launch and check output + checkOuputForCorrectWarnings(ProcessTools.executeTestJvm("-Xcheck:jni", + "TestCheckedJniExceptionCheck")); + } + +} diff --git a/hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c b/hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c new file mode 100644 index 00000000000..fc4a9344838 --- /dev/null +++ b/hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016, 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. + */ + +#include + +static jmethodID _callable_method_id; +static jmethodID _callable_nested_method_id; + +static void check_exceptions(JNIEnv *env) { + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "Unexpected Exception"); + } +} + +static jmethodID get_method_id(JNIEnv *env, jclass clz, jstring jname, jstring jsig) { + jmethodID mid; + const char *name, *sig; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + check_exceptions(env); + + sig = (*env)->GetStringUTFChars(env, jsig, NULL); + check_exceptions(env); + + mid = (*env)->GetMethodID(env, clz, name, sig); + check_exceptions(env); + + (*env)->ReleaseStringUTFChars(env, jname, name); + (*env)->ReleaseStringUTFChars(env, jsig, sig); + return mid; +} + +JNIEXPORT void JNICALL +Java_TestCheckedJniExceptionCheck_initMethodIds(JNIEnv *env, + jobject obj, + jstring callable_method_name, + jstring callable_method_sig, + jstring callable_nested_method_name, + jstring callable_nested_method_sig) { + jclass clz = (*env)->GetObjectClass(env, obj); + + _callable_method_id = get_method_id(env, clz, + callable_method_name, + callable_method_sig); + + _callable_nested_method_id = get_method_id(env, clz, + callable_nested_method_name, + callable_nested_method_sig); +} + +JNIEXPORT void JNICALL +Java_TestCheckedJniExceptionCheck_callJavaFromNative(JNIEnv *env, + jobject obj, + jint nofCalls, + jboolean checkExceptions) { + int i; + for (i = 0; i < nofCalls; i++) { + (*env)->CallVoidMethod(env, obj, _callable_method_id); + if (checkExceptions == JNI_TRUE) { + check_exceptions(env); + } + } +} + +JNIEXPORT void JNICALL +Java_TestCheckedJniExceptionCheck_callNestedJavaFromNative(JNIEnv *env, + jobject obj, + jint nofCalls, + jboolean checkExceptions) { + int i; + for (i = 0; i < nofCalls; i++) { + (*env)->CallVoidMethod(env, obj, _callable_nested_method_id, nofCalls, checkExceptions); + if (checkExceptions == JNI_TRUE) { + check_exceptions(env); + } + } +} diff --git a/hotspot/test/runtime/modules/ModuleOptionsTest.java b/hotspot/test/runtime/modules/ModuleOptionsTest.java index a1dec0141d4..28064bddc27 100644 --- a/hotspot/test/runtime/modules/ModuleOptionsTest.java +++ b/hotspot/test/runtime/modules/ModuleOptionsTest.java @@ -24,8 +24,8 @@ /* * @test * @bug 8136930 - * @summary Test that the VM only recognizes the last specified --add-modules - * and --list-modules options + * @summary Test that the VM only recognizes the last specified --list-modules + * options but accumulates --add-module values. * @modules java.base/jdk.internal.misc * @library /test/lib */ @@ -38,14 +38,16 @@ public class ModuleOptionsTest { public static void main(String[] args) throws Exception { - // Test that last --add-modules is the only one recognized. No exception - // should be thrown. + // Test that multiple --add-modules options are cumulative, not last one wins. + // An exception should be thrown because module i_dont_exist doesn't exist. ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "--add-modules=i_dont_exist", "--add-modules=java.base", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldHaveExitValue(0); + output.shouldContain("ResolutionException"); + output.shouldContain("i_dont_exist"); + output.shouldHaveExitValue(1); - // Test that last --limit-modules is the only one recognized. No exception + // Test that the last --limit-modules is the only one recognized. No exception // should be thrown. pb = ProcessTools.createJavaProcessBuilder( "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version"); diff --git a/jaxp/.hgtags b/jaxp/.hgtags index e81f2084cef..19adf3a8769 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -376,3 +376,5 @@ e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130 874082a9b565a7092a40bfa934a6e3e3c3455a60 jdk-9+131 907445d85e680ea410fe2c83c0ec64b5508e4f3e jdk-9+132 9490ba2e5e41685c858a0ca2a6ec87611eb011c6 jdk-9+133 +1c6c21d87aa459d82425e1fddc9ce8647aebde34 jdk-9+134 +f695240370c77a25fed88225a392e7d530cb4d78 jdk-9+135 diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TransletOutput.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TransletOutput.java index 99911f99628..4ca60383ea3 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TransletOutput.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/TransletOutput.java @@ -1,13 +1,14 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. */ + /* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -17,9 +18,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * $Id: TransletOutput.java,v 1.2.4.1 2005/09/05 09:19:44 pvedula Exp $ - */ package com.sun.org.apache.xalan.internal.xsltc.compiler; @@ -35,6 +33,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util; +import jdk.xml.internal.JdkXmlFeatures; /** * @author Morten Jorgensen @@ -103,8 +102,10 @@ final class TransletOutput extends Instruction { final InstructionList il = methodGen.getInstructionList(); final boolean isSecureProcessing = classGen.getParser().getXSLTC() .isSecureProcessing(); + final boolean isExtensionFunctionEnabled = classGen.getParser().getXSLTC() + .getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION); - if (isSecureProcessing) { + if (isSecureProcessing && !isExtensionFunctionEnabled) { int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unallowed_extension_elementF", "(Ljava/lang/String;)V"); diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java index 98db772821e..f47a3eb2305 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet.java @@ -111,6 +111,9 @@ public abstract class AbstractTranslet implements Translet { private boolean _useServicesMechanism; + // The OutputStream for redirect function + private FileOutputStream output = null; + /** * protocols allowed for external references set by the stylesheet processing instruction, Document() function, Import and Include element. */ @@ -567,9 +570,10 @@ public abstract class AbstractTranslet implements Translet { dir.mkdirs(); } + output = new FileOutputStream(filename, append); factory.setEncoding(_encoding); factory.setOutputMethod(_method); - factory.setOutputStream(new BufferedOutputStream(new FileOutputStream(filename, append))); + factory.setOutputStream(new BufferedOutputStream(output)); factory.setOutputType(TransletOutputHandlerFactory.STREAM); final SerializationHandler handler @@ -594,6 +598,9 @@ public abstract class AbstractTranslet implements Translet { try { handler.endDocument(); handler.close(); + if (output != null) { + output.close(); + } } catch (Exception e) { // what can you do? diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java index 5336a8cb8e1..6630424c15a 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java @@ -31,6 +31,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -72,9 +73,6 @@ class CatalogImpl extends GroupEntry implements Catalog { //System Id for this catalog String systemId; - //The parent - CatalogImpl parent = null; - /* A list of catalog entry files from the input, excluding the current catalog. Paths in the List are normalized. @@ -107,7 +105,7 @@ class CatalogImpl extends GroupEntry implements Catalog { * catalog file. */ public CatalogImpl(CatalogImpl parent, CatalogFeatures f, String... file) throws CatalogException { - super(CatalogEntryType.CATALOG); + super(CatalogEntryType.CATALOG, parent); if (f == null) { throw new NullPointerException( formatMessage(CatalogMessages.ERR_NULL_ARGUMENT, new Object[]{"CatalogFeatures"})); @@ -117,7 +115,7 @@ class CatalogImpl extends GroupEntry implements Catalog { CatalogMessages.reportNPEOnNull("The path to the catalog file", file[0]); } - init(parent, f); + init(f); //Path of catalog files String[] catalogFile = file; @@ -159,19 +157,34 @@ class CatalogImpl extends GroupEntry implements Catalog { } } } - - if (systemId != null) { - parse(systemId); - } } } - private void init(CatalogImpl parent, CatalogFeatures f) { - this.parent = parent; + /** + * Loads the catalog + */ + void load() { + if (systemId != null) { + parse(systemId); + } + + //save this catalog before loading the next + loadedCatalogs.put(systemId, this); + + //Load delegate and alternative catalogs if defer is false. + if (!isDeferred()) { + loadDelegateCatalogs(); + loadNextCatalogs(); + } + } + + private void init(CatalogFeatures f) { if (parent == null) { level = 0; } else { level = parent.level + 1; + this.loadedCatalogs = parent.loadedCatalogs; + this.catalogsSearched = parent.catalogsSearched; } if (f == null) { this.features = CatalogFeatures.defaults(); @@ -196,11 +209,6 @@ class CatalogImpl extends GroupEntry implements Catalog { entries.stream().filter((entry) -> (entry.type == CatalogEntryType.GROUP)).forEach((entry) -> { ((GroupEntry) entry).reset(); }); - - if (parent != null) { - this.loadedCatalogs = parent.loadedCatalogs; - this.catalogsSearched = parent.catalogsSearched; - } } /** @@ -421,16 +429,16 @@ class CatalogImpl extends GroupEntry implements Catalog { void loadNextCatalogs() { //loads catalogs specified in nextCatalogs if (nextCatalogs != null) { - for (NextCatalog next : nextCatalogs) { + nextCatalogs.stream().forEach((next) -> { getCatalog(next.getCatalogURI()); - } + }); } //loads catalogs from the input list if (inputFiles != null) { - for (String file : inputFiles) { + inputFiles.stream().forEach((file) -> { getCatalog(getSystemId(file)); - } + }); } } @@ -445,14 +453,14 @@ class CatalogImpl extends GroupEntry implements Catalog { return null; } - Catalog c = null; + CatalogImpl c = null; String path = uri.toASCIIString(); if (verifyCatalogFile(uri)) { c = getLoadedCatalog(path); if (c == null) { c = new CatalogImpl(this, features, path); - saveLoadedCatalog(path, c); + c.load(); } } return c; @@ -464,7 +472,7 @@ class CatalogImpl extends GroupEntry implements Catalog { * @param catalogId the catalogId associated with the Catalog object * @param c the Catalog to be saved */ - void saveLoadedCatalog(String catalogId, Catalog c) { + void saveLoadedCatalog(String catalogId, CatalogImpl c) { loadedCatalogs.put(catalogId, c); } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java index bc8518685f7..7dd1e9cf873 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java @@ -62,7 +62,9 @@ public final class CatalogManager { * @throws CatalogException If an error occurs while parsing the catalog */ public static Catalog catalog(CatalogFeatures features, String... paths) { - return new CatalogImpl(features, paths); + CatalogImpl catalog = new CatalogImpl(features, paths); + catalog.load(); + return catalog; } /** diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java index bf4e95b963f..5f08c54cc12 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java @@ -259,15 +259,6 @@ class CatalogReader extends DefaultHandler implements EntityResolver, URIResolve CatalogEntryType type = CatalogEntryType.getType(localName); if (type == CatalogEntryType.GROUP) { inGroup = false; - } else if (type == CatalogEntryType.CATALOGENTRY) { - /* - Done reading the catalog file. - Load delegate and alternative catalogs if defer is false. - */ - if (!catalog.isDeferred()) { - catalog.loadDelegateCatalogs(); - catalog.loadNextCatalogs(); - } } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java index 9bf8b357adc..fe6223d9324 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java @@ -119,6 +119,10 @@ final class CatalogResolverImpl implements CatalogResolver { String result = null; CatalogImpl c = (CatalogImpl)catalog; String uri = Normalizer.normalizeURI(href); + if (uri == null) { + return null; + } + //check whether uri is an urn if (uri != null && uri.startsWith(Util.URN)) { String publicId = Normalizer.decodeURN(uri); diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java index 2c1a59c360c..e04f8cdb363 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java @@ -48,6 +48,9 @@ class GroupEntry extends BaseEntry { //Value of the prefer attribute boolean isPreferPublic = true; + //The parent of the catalog instance + CatalogImpl parent = null; + //The catalog instance this group belongs to CatalogImpl catalog; @@ -55,10 +58,10 @@ class GroupEntry extends BaseEntry { List entries = new ArrayList<>(); //loaded delegated catalog by system id - Map delegateCatalogs = new HashMap<>(); + Map delegateCatalogs = new HashMap<>(); //A list of all loaded Catalogs, including this, and next catalogs - Map loadedCatalogs = new HashMap<>(); + Map loadedCatalogs = new HashMap<>(); /* A list of Catalog Ids that have already been searched in a matching @@ -136,8 +139,9 @@ class GroupEntry extends BaseEntry { * * @param type The type of the entry */ - public GroupEntry(CatalogEntryType type) { + public GroupEntry(CatalogEntryType type, CatalogImpl parent) { super(type); + this.parent = parent; } /** @@ -163,7 +167,7 @@ class GroupEntry extends BaseEntry { } /** * Constructs a group entry. - * @param catalog The parent catalog + * @param catalog The catalog this GroupEntry belongs * @param base The baseURI attribute * @param attributes The attributes */ @@ -445,13 +449,14 @@ class GroupEntry extends BaseEntry { * @param catalogId the catalog Id */ Catalog loadCatalog(URI catalogURI) { - Catalog delegateCatalog = null; + CatalogImpl delegateCatalog = null; if (catalogURI != null) { String catalogId = catalogURI.toASCIIString(); delegateCatalog = getLoadedCatalog(catalogId); if (delegateCatalog == null) { if (verifyCatalogFile(catalogURI)) { delegateCatalog = new CatalogImpl(catalog, features, catalogId); + delegateCatalog.load(); delegateCatalogs.put(catalogId, delegateCatalog); } } @@ -467,8 +472,8 @@ class GroupEntry extends BaseEntry { * @return a Catalog object previously loaded, or null if none in the saved * list */ - Catalog getLoadedCatalog(String catalogId) { - Catalog c = null; + CatalogImpl getLoadedCatalog(String catalogId) { + CatalogImpl c = null; //checl delegate Catalogs c = delegateCatalogs.get(catalogId); @@ -504,7 +509,7 @@ class GroupEntry extends BaseEntry { } String catalogId = catalogURI.toASCIIString(); - if (catalogsSearched.contains(catalogId)) { + if (catalogsSearched.contains(catalogId) || isCircular(catalogId)) { CatalogMessages.reportRunTimeError(CatalogMessages.ERR_CIRCULAR_REFERENCE, new Object[]{CatalogMessages.sanitize(catalogId)}); } @@ -512,4 +517,20 @@ class GroupEntry extends BaseEntry { return true; } + /** + * Checks whether the catalog is circularly referenced + * @param systemId the system identifier of the catalog to be loaded + * @return true if is circular, false otherwise + */ + boolean isCircular(String systemId) { + if (parent == null) { + return false; + } + + if (parent.systemId.equals(systemId)) { + return true; + } + + return parent.isCircular(systemId); + } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java b/jaxp/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java index bc98084c55b..82ea2e17329 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java @@ -1072,4 +1072,3 @@ public abstract class XMLGregorianCalendar @Override public abstract Object clone(); } - diff --git a/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java b/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java index 868ad21535c..240c386bf56 100644 --- a/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java +++ b/jaxp/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java @@ -42,6 +42,9 @@ public class JdkXmlFeatures { ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; public static final String SP_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; + // This is the correct name by the spec + public static final String SP_ENABLE_EXTENSION_FUNCTION_SPEC = + "jdk.xml.enableExtensionFunctions"; public static final String CATALOG_FEATURES = "javax.xml.catalog.catalogFeatures"; public final static String PROPERTY_USE_CATALOG = XMLConstants.USE_CATALOG; @@ -49,11 +52,11 @@ public class JdkXmlFeatures { public static enum XmlFeature { /** * Feature enableExtensionFunctions - * FSP: extension function is enforced by FSP. When FSP is on, entension + * FSP: extension function is enforced by FSP. When FSP is on, extension * function is disabled. */ ENABLE_EXTENSION_FUNCTION(ORACLE_ENABLE_EXTENSION_FUNCTION, - SP_ENABLE_EXTENSION_FUNCTION, true, false, true, true), + SP_ENABLE_EXTENSION_FUNCTION_SPEC, true, false, true, true), /** * The {@link javax.xml.XMLConstants.USE_CATALOG} feature. * FSP: USE_CATALOG is not enforced by FSP. @@ -148,6 +151,30 @@ public class JdkXmlFeatures { } + /** + * Maps old property names with the new ones. This map is used to keep track of + * name changes so that old or incorrect names continue to be supported for compatibility. + */ + public static enum NameMap { + + ENABLE_EXTENSION_FUNCTION(SP_ENABLE_EXTENSION_FUNCTION_SPEC, SP_ENABLE_EXTENSION_FUNCTION); + + final String newName; + final String oldName; + + NameMap(String newName, String oldName) { + this.newName = newName; + this.oldName = oldName; + } + + String getOldName(String newName) { + if (newName.equals(this.newName)) { + return oldName; + } + return null; + } + } + /** * States of the settings of a property, in the order: default value, value * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system @@ -316,6 +343,15 @@ public class JdkXmlFeatures { private void readSystemProperties() { for (XmlFeature feature : XmlFeature.values()) { getSystemProperty(feature, feature.systemProperty()); + if (!getSystemProperty(feature, feature.systemProperty())) { + //if system property is not found, try the older form if any + for (NameMap nameMap : NameMap.values()) { + String oldName = nameMap.getOldName(feature.systemProperty()); + if (oldName != null) { + getSystemProperty(feature, oldName); + } + } + } } } diff --git a/jaxp/src/java.xml/share/classes/module-info.java b/jaxp/src/java.xml/share/classes/module-info.java index 40ca6421302..2e21ed692cf 100644 --- a/jaxp/src/java.xml/share/classes/module-info.java +++ b/jaxp/src/java.xml/share/classes/module-info.java @@ -92,4 +92,3 @@ module java.xml { uses javax.xml.xpath.XPathFactory; uses org.xml.sax.XMLReader; } - diff --git a/jaxp/src/jdk.xml.dom/share/classes/module-info.java b/jaxp/src/jdk.xml.dom/share/classes/module-info.java index a75c8f36b78..af8529c3f80 100644 --- a/jaxp/src/jdk.xml.dom/share/classes/module-info.java +++ b/jaxp/src/jdk.xml.dom/share/classes/module-info.java @@ -30,4 +30,3 @@ module jdk.xml.dom { exports org.w3c.dom.stylesheets; exports org.w3c.dom.xpath; } - diff --git a/jaxp/test/ProblemList.txt b/jaxp/test/ProblemList.txt index 27337ae935c..ce63d06ff47 100644 --- a/jaxp/test/ProblemList.txt +++ b/jaxp/test/ProblemList.txt @@ -24,7 +24,3 @@ ########################################################################### javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh 8147431 generic-all - -javax/xml/jaxp/unittest/common/TransformationWarningsTest.java 8150145 generic-all - -javax/xml/jaxp/unittest/common/ValidationWarningsTest.java 8150145 generic-all diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java index 626943a335b..b5368158ab1 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java @@ -64,12 +64,12 @@ public class DeferFeatureTest { public Object[][] data() { return new Object[][]{ // By default, alternative catalogs are not loaded. - {createCatalog(CatalogFeatures.defaults()), 0}, + {createCatalog(CatalogFeatures.defaults()), 1}, // Alternative catalogs are not loaded when DEFER is set to true. - {createCatalog(createDeferFeature(DEFER_TRUE)), 0}, - // The 3 alternative catalogs are not pre-loaded + {createCatalog(createDeferFeature(DEFER_TRUE)), 1}, + // The 3 alternative catalogs are pre-loaded along with the parent //when DEFER is set to false. - {createCatalog(createDeferFeature(DEFER_FALSE)), 3}}; + {createCatalog(createDeferFeature(DEFER_FALSE)), 4}}; } private CatalogFeatures createDeferFeature(String defer) { diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java index 2a27b942859..057414557a0 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java @@ -587,4 +587,3 @@ public class DurationTest { private final BigInteger one = BigInteger.ONE; } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java index 8f21a2b23a1..26aada36bcf 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java @@ -77,4 +77,3 @@ public class FactoryNewInstanceTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java index bd98ec9690d..2f0281013fa 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java @@ -358,4 +358,3 @@ public class XMLGregorianCalendarTest { private final int undef = DatatypeConstants.FIELD_UNDEFINED; } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java index 9eec7901ffd..be2dcba2f4e 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DBFNamespaceTest.java @@ -105,5 +105,3 @@ public class DBFNamespaceTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java index 2419a23241e..bc5cc4c9fcc 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java @@ -531,5 +531,3 @@ public class DocumentBuilderFactoryTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java index e805094f887..65028a582fc 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderImpl01.java @@ -157,5 +157,3 @@ public class DocumentBuilderImpl01 implements EntityResolver { return null; } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java index 32c25b30c0b..43527cf721a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/FactoryConfErrorTest.java @@ -86,5 +86,3 @@ public class FactoryConfErrorTest { DocumentBuilderFactory.newInstance(); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java index e4db5b4e3a2..aa8ba1337bb 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java @@ -78,5 +78,3 @@ public class SAXFactoryNewInstanceTest { } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java index 6b8245a43cc..c294abe51fb 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java @@ -229,5 +229,3 @@ public class SAXParserFactTest { assertFalse(spf.getFeature(EXTERNAL_P_ENTITIES)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java index adc1b657c23..ed702b24ec9 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest.java @@ -502,5 +502,3 @@ public class SAXParserTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java index d7efae1b51a..1c7f410615f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest02.java @@ -269,5 +269,3 @@ public class SAXParserTest02 { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java index e16a070bc2a..94273e722ee 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserTest03.java @@ -116,5 +116,3 @@ public class SAXParserTest03 { } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java index 9d588c3dea0..b272cd10cac 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java @@ -82,4 +82,3 @@ public class XMLEventFactoryNewInstanceTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java index b983d76a7d8..9b77ac4b1af 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java @@ -82,4 +82,3 @@ public class XMLInputFactoryNewInstanceTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java index 8fce6a80440..e3e46791768 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java @@ -67,5 +67,3 @@ public class Bug6384418Test { } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java index b1a86f73e64..b1a65ec6e9e 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/DOMResultTest.java @@ -118,5 +118,3 @@ public class DOMResultTest { writeNodes(kids.item(i), bWriter); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java index 7d01e52de9a..eb9de80edc4 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/ErrorListenerTest.java @@ -104,5 +104,3 @@ public class ErrorListenerTest implements ErrorListener { this.status = ListenerStatus.FATAL; } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java index 81f97cd909e..843b5571dbb 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXSourceTest.java @@ -105,5 +105,3 @@ public class SAXSourceTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java index 4721e7c9a61..16f2ba1b0e5 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/SAXTFactoryTest.java @@ -431,5 +431,3 @@ public class SAXTFactoryTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java index 832c5383e29..cfa6d59a587 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/StreamResultTest.java @@ -106,5 +106,3 @@ public class StreamResultTest { }); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java index b30cd90e4fc..10867c9f0d2 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TfClearParamTest.java @@ -239,5 +239,3 @@ public class TfClearParamTest { assertNull(transformer.getParameter(LONG_PARAM_NAME)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java index 038bb168407..b98272896cf 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java @@ -384,5 +384,3 @@ public class TransformTest { private Document xmlDoc; } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java index 58d60763db5..cf70fdee7b3 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerExcpTest.java @@ -105,5 +105,3 @@ public class TransformerExcpTest { assertNotNull(te.initCause(null)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java index ae8a2bc6b8f..5f1fbb29500 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java @@ -141,5 +141,3 @@ public class TransformerFactoryTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java index a8d7e4705a7..14d463e4dae 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest.java @@ -207,5 +207,3 @@ class MyErrorListener implements ErrorListener { System.out.println(" In fatal"); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java index 3a9a058abcb..57d47c2c72a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest02.java @@ -85,5 +85,3 @@ public class TransformerTest02 { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java index d0330a783ec..3ea3b1b8639 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerTest03.java @@ -94,5 +94,3 @@ public class TransformerTest03 { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java index d595b485115..c7c7fc3ee13 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/URIResolverTest.java @@ -262,5 +262,3 @@ public class URIResolverTest implements URIResolver { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java index f86d4b90fdc..e0471aeb160 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/othervm/TFCErrorTest.java @@ -54,5 +54,3 @@ public class TFCErrorTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java index f18588acbaa..c3a12612a05 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java @@ -404,4 +404,3 @@ public class SchemaFactoryTest { private Document xsdDoc2; private byte[] xml; } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java index 782981a49be..bc2b818fba7 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/TypeInfoProviderTest.java @@ -95,4 +95,3 @@ public class TypeInfoProviderTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java index b80a9f5047e..686abe494c3 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorHandlerTest.java @@ -148,4 +148,3 @@ public class ValidatorHandlerTest { private Schema schema; } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java index 17015bf9cc7..ec50dd50bb5 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/ValidatorTest.java @@ -209,4 +209,3 @@ public class ValidatorTest { private Document xmlDoc; } - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java index 585804cf995..4a7dca37be0 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathExpressionTest.java @@ -491,5 +491,3 @@ public class XPathExpressionTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java index 517fecc020c..8a9c51aa284 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java @@ -218,5 +218,3 @@ public class XPathFactoryTest { assertNotNull(XPathFactory.newInstance(DOM_OBJECT_MODEL)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java index 8f19976cdb9..6f5e80abb7a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFunctionResolverTest.java @@ -82,5 +82,3 @@ public class XPathFunctionResolverTest { assertEquals(xpath.evaluate(null, "5"), "2"); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java index f3f4a0d0563..86808d6b035 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathTest.java @@ -757,5 +757,3 @@ public class XPathTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java index e17afe6b80a..5c5405e63f0 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AttrTest.java @@ -151,4 +151,3 @@ public class AttrTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java index eda658bb960..8ded2ce6b51 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/CommentTest.java @@ -48,4 +48,3 @@ public class CommentTest extends AbstractCharacterDataTest { return document.createComment(text); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java index fe309a81aaa..aa4f6ee4759 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTest.java @@ -175,4 +175,3 @@ public class DocumentTest { doc.createElement("!nc$%^*(!"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java index 63d23966131..9ac72f5c337 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DocumentTypeTest.java @@ -92,4 +92,3 @@ public class DocumentTypeTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java index 9e8c0247144..ebfe9295ddd 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/DomImplementationTest.java @@ -129,4 +129,3 @@ public class DomImplementationTest { assertEquals(documentType.getName(), name); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java index 6726eb0ab8b..c67f32a840f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/ElementTest.java @@ -255,4 +255,3 @@ public class ElementTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java index ffac684287d..78473f793bc 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/EntityChildTest.java @@ -61,4 +61,3 @@ public class EntityChildTest { assertEquals(nl.getLength(), 3); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java index 405934b3c3d..b83bcf75f0d 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NamedNodeMapTest.java @@ -121,4 +121,3 @@ public class NamedNodeMapTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java index 8d2d1556616..9d9cb491f2a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeListTest.java @@ -64,4 +64,3 @@ public class NodeListTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java index 25c047bdfd5..bb4d6b3574a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NodeTest.java @@ -211,4 +211,3 @@ public class NodeTest { transformer.transform(domSource, streamResult); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java index 0b698f37bc5..46bb3d25ca6 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/NotationTest.java @@ -74,4 +74,3 @@ public class NotationTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java index 3ddf96e86a0..3b942942132 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/PITest.java @@ -54,4 +54,3 @@ public class PITest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java index 223853ebd05..3131e8d3de1 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TextTest.java @@ -74,4 +74,3 @@ public class TextTest extends AbstractCharacterDataTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java index c407ff58a64..ca3f174ce39 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/w3c/dom/ptests/TypeInfoTest.java @@ -140,4 +140,3 @@ public class TypeInfoTest { } - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java index 2337dcec586..9c4910bc904 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttrImplTest.java @@ -202,5 +202,3 @@ public class AttrImplTest { attr.removeAttribute(1); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java index f42dc9c50e2..f3115757e0f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesNSTest.java @@ -74,5 +74,3 @@ public class AttributesNSTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java index e56e9458532..e6259be3a76 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/AttributesTest.java @@ -76,5 +76,3 @@ public class AttributesTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java index bbcb4b40a4c..5ca0b94924a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ContentHandlerTest.java @@ -264,5 +264,3 @@ class MyContentHandler extends XMLFilterImpl implements AutoCloseable { bWriter.close(); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java index f8cce65cd30..6418fa264bd 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/DefaultHandlerTest.java @@ -272,5 +272,3 @@ class MyDefaultHandler extends DefaultHandler { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java index 9d4621a4dbf..173a5ca659f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/EHFatalTest.java @@ -135,5 +135,3 @@ class MyErrorHandler extends XMLFilterImpl implements AutoCloseable { bWriter.close(); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java index 148f46a3950..695a3ec806a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSSupportTest.java @@ -131,5 +131,3 @@ public class NSSupportTest { assertNull(support.getURI(DC_PREFIX)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java index 615554f1d4e..7fd27ffbbf5 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/NSTableTest.java @@ -168,5 +168,3 @@ public class NSTableTest { assertFalse(spf.getFeature(NAMESPACE_PREFIXES)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java index 4fb4de21bba..627134b5eaf 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ParserAdapterTest.java @@ -265,5 +265,3 @@ public class ParserAdapterTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java index 49796f21845..6822a88034c 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/ResolverTest.java @@ -143,5 +143,3 @@ class MyEntityResolver extends XMLFilterImpl implements AutoCloseable { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java index 84d534ba4d4..71cad03dc9f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/SAXParserNSTableTest.java @@ -107,5 +107,3 @@ public class SAXParserNSTableTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java index 9abea366b01..91dd02f8fb9 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterCBTest.java @@ -285,5 +285,3 @@ class MyXMLFilter extends XMLFilterImpl implements AutoCloseable { bWriter.close(); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java index df6bce21461..4483942699f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLFilterTest.java @@ -246,5 +246,3 @@ public class XMLFilterTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java index 9ea1a1a39bb..350074fbf2c 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderAdapterTest.java @@ -112,5 +112,3 @@ public class XMLReaderAdapterTest { } } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java index 221244b96de..7ee49f39076 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderFactoryTest.java @@ -76,5 +76,3 @@ public class XMLReaderFactoryTest { XMLReaderFactory.createXMLReader("org.apache.crimson.parser.ABCD"); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java index 9f91ddee5f2..518dbc0f8bb 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderNSTableTest.java @@ -131,5 +131,3 @@ public class XMLReaderNSTableTest { assertTrue(compareWithGold(goldFile, outputFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java index 0ba1ae55e76..568548d919c 100644 --- a/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/org/xml/sax/ptests/XMLReaderTest.java @@ -671,5 +671,3 @@ class MyDeclHandler implements DeclHandler { public void internalEntityDecl(String name, String value) { } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java b/jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java index 8671a12242e..b605137f48f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/AstroTest.java @@ -145,4 +145,3 @@ public class AstroTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java b/jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java index 20179d5f46b..acfe988c13a 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/DocumentLSTest.java @@ -182,4 +182,3 @@ public class DocumentLSTest { return dbf.newDocumentBuilder(); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java b/jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java index e9584a99579..70771bfeacf 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/NamespaceContextTest.java @@ -89,4 +89,3 @@ public class NamespaceContextTest { assertEquals(QName.valueOf(qname.toString()), qname); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java b/jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java index d1bb70a3b8f..822140baccc 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/SAX201Test.java @@ -48,4 +48,3 @@ public class SAX201Test { reader.setDTDHandler(null); // SAX 2.0.1 allows } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java b/jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java index 6c557fb032b..6ba78e9d817 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java @@ -76,4 +76,3 @@ public class SchemaValidationTest { return spf.newSAXParser(); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java b/jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java index ba3aae0fa2b..69ada828241 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/astro/XPathAPITest.java @@ -171,4 +171,3 @@ public class XPathAPITest { return new InputSource(filenameToURL(ASTROCAT)); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java index 1238fb88967..5d3ea0317c5 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java @@ -366,5 +366,3 @@ public class AuctionController { assertTrue(roletypeInfo.getTypeNamespace().equals(PORTAL_ACCOUNT_NS)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java index 4ab09cf71c7..2bab94a41aa 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java @@ -371,5 +371,3 @@ public class AuctionItemRepository { assertTrue(compareDocumentWithGold(goldFile, resultFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java index 4ee18c423c4..5c4ac7c9bc6 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java @@ -304,5 +304,3 @@ public class UserController { assertTrue(compareDocumentWithGold(goldFile, resultFile)); } } - - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java index 65e38a75e25..5c6c1b3e0be 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4511326.java @@ -64,4 +64,3 @@ public class Bug4511326 { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java index cfc74fd26f2..1778a20a031 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4512806.java @@ -90,4 +90,3 @@ public class Bug4512806 { } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java index a833c117a8f..7af1eb4235c 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515047.java @@ -62,4 +62,3 @@ public class Bug4515047 { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java index bff0d401d25..15626ab1e71 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java @@ -128,4 +128,3 @@ public class Bug4515660 { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java index 8db96ac91a6..f76670bd22e 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4693341.java @@ -81,4 +81,3 @@ public class Bug4693341 { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java index 4fa09ccc2dc..1ca0bcb77f3 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4848653.java @@ -81,4 +81,3 @@ public class Bug4848653 { } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java index 7bb8ea574ad..f5deceb04f1 100644 --- a/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java +++ b/jaxp/test/javax/xml/jaxp/functional/test/gaptest/Bug4858685.java @@ -247,4 +247,3 @@ public class Bug4858685 { } } - diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java index c2bf928ba1f..72fd20c1d74 100644 --- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java +++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java @@ -93,7 +93,7 @@ public class BasicModularXMLParserTest { */ public void testWithOneProvider() throws Exception { int exitValue - = executeTestJava("-mp", MOD_DIR1.toString(), + = executeTestJava("--module-path", MOD_DIR1.toString(), "-cp", CLASSES_DIR.toString(), "Main", "xmlprovider1") .outputTo(System.out) @@ -108,7 +108,7 @@ public class BasicModularXMLParserTest { */ public void testWithTwoProvider() throws Exception { int exitValue - = executeTestJava("-mp", MOD_DIR1.toString() + File.pathSeparator + MOD_DIR2.toString(), + = executeTestJava("--module-path", MOD_DIR1.toString() + File.pathSeparator + MOD_DIR2.toString(), "-cp", CLASSES_DIR.toString(), "Main", "xmlprovider1", "xmlprovider2") .outputTo(System.out) diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/test/module-info.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/test/module-info.java index 9a1caa4e1f9..3cc31a4056f 100644 --- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/test/module-info.java +++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/test/module-info.java @@ -24,4 +24,4 @@ module test { requires java.xml; exports test; -} \ No newline at end of file +} diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider1/module-info.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider1/module-info.java index 5a5b1b01447..a4681d42a0a 100644 --- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider1/module-info.java +++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider1/module-info.java @@ -31,4 +31,4 @@ module xmlprovider1 { provides javax.xml.transform.TransformerFactory with xp1.TransformerFactoryImpl; provides javax.xml.validation.SchemaFactory with xp1.SchemaFactoryImpl; provides javax.xml.xpath.XPathFactory with xp1.XPathFactoryImpl; -} \ No newline at end of file +} diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider2/module-info.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider2/module-info.java index c8bc623aa7a..511c25b019d 100644 --- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider2/module-info.java +++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/xmlprovider2/module-info.java @@ -27,4 +27,4 @@ module xmlprovider2 { provides javax.xml.datatype.DatatypeFactory with xp2.DatatypeFactoryImpl; provides javax.xml.stream.XMLEventFactory with xp2.XMLEventFactoryImpl; provides org.xml.sax.XMLReader with xp2.XMLReaderImpl; -} \ No newline at end of file +} diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java index 6f622f9ab25..4b9ea77826d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java @@ -92,6 +92,34 @@ public class CatalogTest extends CatalogSupportBase { super.setUp(); } + /* + * @bug 8162431 + * Verifies that circular references are caught and + * CatalogException is thrown. + */ + @Test(dataProvider = "getFeatures", expectedExceptions = CatalogException.class) + public void testCircularRef(CatalogFeatures cf, String xml) { + CatalogResolver catalogResolver = CatalogManager.catalogResolver( + cf, + getClass().getResource(xml).getFile()); + catalogResolver.resolve("anyuri", ""); + } + + /* + DataProvider: used to verify circular reference + Data columns: CatalogFeatures, catalog + */ + @DataProvider(name = "getFeatures") + public Object[][] getFeatures() { + + return new Object[][]{ + {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), + "catalogReferCircle-itself.xml"}, + {CatalogFeatures.defaults(), "catalogReferCircle-itself.xml"}, + {CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "false").build(), + "catalogReferCircle-left.xml"}, + {CatalogFeatures.defaults(), "catalogReferCircle-left.xml"},}; + } /* * @bug 8163232 diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml new file mode 100644 index 00000000000..c3cfaa66443 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-itself.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml new file mode 100644 index 00000000000..852b1a56ac3 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-left.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml new file mode 100644 index 00000000000..0c556a4b123 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalogReferCircle-right.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java index 210db35bfb2..aca1dcfe11a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6350682.java @@ -75,4 +75,3 @@ public class Bug6350682 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java index 8763290fe4e..f254c28ee49 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6723276Test.java @@ -68,4 +68,3 @@ public class Bug6723276Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java index 8bf9ea43c93..b372470990c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug6941169Test.java @@ -486,4 +486,3 @@ public class Bug6941169Test { return document; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java b/jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java index 2414288b218..771d26a4677 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/Bug7143711Test.java @@ -114,4 +114,3 @@ public class Bug7143711Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java b/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java index ec09062a626..ad5f815cbad 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/Sources.java @@ -213,4 +213,3 @@ public class Sources { return r; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java b/jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java index 1745e460a6d..033bbdefd6e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/TestSAXDriver.java @@ -56,4 +56,3 @@ public class TestSAXDriver extends SAXParserImpl.JAXPSAXParser { private static final String ENT_EXP_LIMIT_PROP = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit"; } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java b/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java index 310d1a4b4de..1dbe4188330 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/TransformationWarningsTest.java @@ -42,12 +42,13 @@ import org.testng.annotations.Test; * @test * @bug 8144593 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @compile -XDignore.symbol.file TestSAXDriver.java * @run testng/othervm -DrunSecMngr=true common.TransformationWarningsTest * @run testng/othervm common.TransformationWarningsTest * @summary Check that warnings about unsupported properties from parsers * are suppressed during the transformation process. */ -@Listeners({jaxp.library.BasePolicy.class}) +@Listeners({jaxp.library.BasePolicy.class, jaxp.library.InternalAPIPolicy.class}) public class TransformationWarningsTest extends WarningsTestBase { @BeforeClass @@ -80,7 +81,12 @@ public class TransformationWarningsTest extends WarningsTestBase { Source xslsrc = new StreamSource(new StringReader(xsl)); // Create factory and transformer - TransformerFactory tf = TransformerFactory.newInstance(); + TransformerFactory tf; + // newTransformer() method doc states that different transformer + // factories can be used concurrently by different Threads. + synchronized (TransformerFactory.class) { + tf = TransformerFactory.newInstance(); + } Transformer t = tf.newTransformer(xslsrc); // Set URI Resolver to return the newly constructed xml @@ -99,4 +105,3 @@ public class TransformationWarningsTest extends WarningsTestBase { + ""; private static final String xml = ""; } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java b/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java index 3b4a945a254..1e09a762f61 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java @@ -46,6 +46,7 @@ import org.xml.sax.InputSource; * @bug 8144593 * @key intermittent * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @compile -XDignore.symbol.file TestSAXDriver.java * @run testng/othervm -DrunSecMngr=true common.ValidationWarningsTest * @run testng/othervm common.ValidationWarningsTest * @summary Check that warnings about unsupported properties from SAX @@ -84,4 +85,3 @@ public class ValidationWarningsTest extends WarningsTestBase { private static final String xml = "Element"; } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java b/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java index 9a7ce2d8f7b..3fde8d1f725 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java +++ b/jaxp/test/javax/xml/jaxp/unittest/common/WarningsTestBase.java @@ -23,11 +23,15 @@ package common; +import static jaxp.library.JAXPTestUtilities.runWithAllPerm; + import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.lang.Thread.UncaughtExceptionHandler; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -58,25 +62,27 @@ public abstract class WarningsTestBase { PrintStream defStdErr = System.err; //Set new byte array stream as standard error stream ByteArrayOutputStream byteStream = new ByteArrayOutputStream(5000); - System.setErr(new PrintStream(byteStream)); + runWithAllPerm(() -> System.setErr(new PrintStream(byteStream))); //Execute multiple TestWorker tasks for (int id = 0; id < THREADS_COUNT; id++) { EXECUTOR.execute(new TestWorker(id)); } //Initiate shutdown of previously submitted task - EXECUTOR.shutdown(); + runWithAllPerm(EXECUTOR::shutdown); //Wait for termination of submitted tasks if (!EXECUTOR.awaitTermination(THREADS_COUNT, TimeUnit.SECONDS)) { //If not all tasks terminates during the time out force them to shutdown - EXECUTOR.shutdownNow(); + runWithAllPerm(EXECUTOR::shutdownNow); } //Restore default standard error stream - System.setErr(defStdErr); + runWithAllPerm(() -> System.setErr(defStdErr)); //Print tasks stderr output String errContent = byteStream.toString(); System.out.println("Standard error output content:"); System.out.println(errContent); - //Check tasks stderr output for quatity of warning messages + //Check if uncaught exceptions were observed by one or more threads + Assert.assertFalse(uncaughtExceptions); + //Check tasks stderr output for quantity of warning messages Assert.assertTrue(warningPrintedOnce(XMLConstants.ACCESS_EXTERNAL_DTD, errContent)); Assert.assertTrue(warningPrintedOnce(ENT_EXP_PROPERTY, errContent)); Assert.assertTrue(warningPrintedOnce(XMLConstants.FEATURE_SECURE_PROCESSING, errContent)); @@ -123,6 +129,25 @@ public abstract class WarningsTestBase { } } + // Thread factory that handles uncaughtExceptions and prints them + // to stdout instead of stderr. + private static class TestThreadFactory implements ThreadFactory { + + public Thread newThread(final Runnable r) { + Thread t = Executors.defaultThreadFactory().newThread(r); + t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable thr) { + thr.printStackTrace(System.out); + uncaughtExceptions = true; + } + }); + return t; + } + } + + //Flag that indicates if one or more threads from thread pool caught unhandled exception + private static boolean uncaughtExceptions = false; //Entity expansion limit property name private static final String ENT_EXP_PROPERTY = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit"; //Number of simultaneous test threads @@ -130,7 +155,7 @@ public abstract class WarningsTestBase { //Number of iterations per one thread private static final int ITERATIONS_PER_THREAD = 4; //Test thread pool - private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool(); - //Cyclic barrier for threads startup synchronisation + private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool(new TestThreadFactory()); + //Cyclic barrier for threads startup synchronization private static final CyclicBarrier BARRIER = new CyclicBarrier(THREADS_COUNT); } diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java index 5f92bd0a587..e9609155807 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6320118.java @@ -108,4 +108,3 @@ public class Bug6320118 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java index 1c86badd13c..36de6637e6d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937951Test.java @@ -57,4 +57,3 @@ public class Bug6937951Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java index 9caf929ccf9..3e1129d2acc 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug6937964Test.java @@ -270,4 +270,3 @@ public class Bug6937964Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java index f680336edc2..5e6e34b6af6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/Bug7042647Test.java @@ -60,4 +60,3 @@ public class Bug7042647Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java index 6ca2985348e..4029e2b21ae 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/DatatypeFactoryTest.java @@ -640,4 +640,3 @@ public class DatatypeFactoryTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java index 76023529624..6b2204ef1e1 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/DurationTest.java @@ -484,4 +484,3 @@ public class DurationTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java index 915a63c71ee..2a1e2d6ea7f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/FactoryFindTest.java @@ -76,4 +76,3 @@ public class FactoryFindTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java index dd0720ded6e..03412b59edb 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/JDK8068839Test.java @@ -51,4 +51,3 @@ public class JDK8068839Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java b/jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java index 89c5fc63556..415d949c05d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/datatype/XMLGregorianCalendarTest.java @@ -228,4 +228,3 @@ public class XMLGregorianCalendarTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java index 791146e6564..5ce2d195acd 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915524.java @@ -81,4 +81,3 @@ public class Bug4915524 { return docBuilder.parse(source); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java index e2186da9107..50a5ced37f4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4915748.java @@ -74,4 +74,3 @@ public class Bug4915748 { Assert.assertTrue(hadError[0]); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java index b24e9d5818b..30e1740f11c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966082.java @@ -53,4 +53,3 @@ public class Bug4966082 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java index 43f1e1aa410..cdc96d140b9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966138.java @@ -69,4 +69,3 @@ public class Bug4966138 { Assert.assertTrue(typeNs.length() != 0, "returned typeNamespace shouldn't be empty"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java index 5bd158e7723..ebd66a0a02b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966142.java @@ -61,4 +61,3 @@ public class Bug4966142 { Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION)); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java index 1cdbb466c14..4e42cb06b8c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug4966143.java @@ -66,4 +66,3 @@ public class Bug4966143 { Assert.assertTrue(type.isDerivedFrom("testNS", "Test", 0)); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java index df2eaf3f955..d389516117e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6339023.java @@ -139,4 +139,3 @@ public class Bug6339023 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java index d2656690847..f0b557a24a7 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6355326.java @@ -118,4 +118,3 @@ public class Bug6355326 { return p; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java index b1ce0a16db9..21284ee3902 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6367542.java @@ -52,4 +52,3 @@ public class Bug6367542 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java index b1381c0b8aa..22940e07b14 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6520131.java @@ -83,4 +83,3 @@ public class Bug6520131 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java index 300bde2159a..e051748fe7a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6521260.java @@ -77,4 +77,3 @@ public class Bug6521260 { Assert.assertEquals(systemId, systemId2); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java index 9108af3d7f6..23c872e8553 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6582545Test.java @@ -123,4 +123,3 @@ public class Bug6582545Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java index ff5cf2cda6a..1e0f9da9f24 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/Bug6879614Test.java @@ -78,4 +78,3 @@ public class Bug6879614Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java index f407e2612e8..a706ae2bb31 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6333993Test.java @@ -88,4 +88,3 @@ public class CR6333993Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java index c8ee54a3acc..90102a0afd2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517707Test.java @@ -128,4 +128,3 @@ public class CR6517707Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java index 0b5d2e65b2f..0d73cd4fee7 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6517717Test.java @@ -86,4 +86,3 @@ public class CR6517717Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java index 4b46cf9fb60..ea91169b203 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/CR6909336Test.java @@ -72,4 +72,3 @@ public class CR6909336Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java index b4341558e8e..528736f11e8 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/DOMConfigurationTest.java @@ -1628,4 +1628,3 @@ public class DOMConfigurationTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java index 672c38e5fda..b43e694a575 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/DOMXPathTest.java @@ -54,4 +54,3 @@ public class DOMXPathTest { Assert.assertEquals(domImpl.getFeature("+XPath", "3.0"), null); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java index ef87815d166..4319a0ad5a1 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ElementTraversal.java @@ -135,4 +135,3 @@ public class ElementTraversal { return doc; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java index 19523434cf2..f07ac57c7b2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/JdkXmlDomTest.java @@ -46,4 +46,3 @@ public class JdkXmlDomTest { Assert.assertTrue(runWithAllPerm(() -> cls.getClassLoader()) != null); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java index 6dc3a24b68d..6f71906ee9d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/TCKEncodingTest.java @@ -102,4 +102,3 @@ public class TCKEncodingTest { System.out.println("OK"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java index 42d8d2457d0..b6bdd0f606c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug4973153.java @@ -204,4 +204,3 @@ class DOMErrorHandlerImpl implements DOMErrorHandler { return true; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java index f874107cf52..745c31c8d2b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6290947.java @@ -147,4 +147,3 @@ public class Bug6290947 { return src; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java index f693e33765a..91507e97700 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6354955.java @@ -142,4 +142,3 @@ public class Bug6354955 { return documentBuilder.newDocument(); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java index afd0458ab22..07541e8fee3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6376823.java @@ -121,4 +121,3 @@ public class Bug6376823 { return src; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java index 73584b3f16d..3f4f1ffb0c4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/Bug6710741Test.java @@ -80,4 +80,3 @@ public class Bug6710741Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java index 3e4f8762b44..8c39f248400 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTCKTest.java @@ -584,4 +584,3 @@ public class LSParserTCKTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java index 1a3c5914942..18b50f2daed 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSParserTest.java @@ -109,4 +109,3 @@ public class LSParserTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java index d30baa8945f..f1019369c4b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/dom/ls/LSSerializerTest.java @@ -319,4 +319,3 @@ public class LSSerializerTest { Assert.assertEquals(XML11_DOCUMENT_OUTPUT, defaultSerialization, "Invalid serialization of XML 1.1 document: "); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java index c0e833e318d..1713fff6d62 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4674384_MAX_OCCURS_Test.java @@ -70,4 +70,3 @@ public class Bug4674384_MAX_OCCURS_Test { System.out.println("Success: File " + XML_FILE_NAME + " was parsed with a large value of maxOccurs."); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java index 65943390953..743f236302b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4934208.java @@ -74,4 +74,3 @@ public class Bug4934208 { r.parse(is); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java index 308b5b11bf0..d0797a2f669 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4967002.java @@ -101,4 +101,3 @@ public class Bug4967002 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java index 7cc3313fad9..3fb179751e6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4985486.java @@ -68,4 +68,3 @@ public class Bug4985486 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java index 189f5efebee..c0be7b47a04 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991020.java @@ -56,4 +56,3 @@ public class Bug4991020 { parser.parse(Bug4991020.class.getResource("Bug4991020.xml").toExternalForm(), new util.DraconianErrorHandler()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java index a30cbd8fbc9..9213a59508d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug4991946.java @@ -56,4 +56,3 @@ public class Bug4991946 { parser.parse(Bug4991946.class.getResource("Bug4991946.xml").toExternalForm(), new util.DraconianErrorHandler()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java index 786a2225731..04346c89fea 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5010072.java @@ -77,4 +77,3 @@ public class Bug5010072 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java index 86d766b282e..9f8cbcb4111 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug5025825.java @@ -89,4 +89,3 @@ public class Bug5025825 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java index 20e49c8a501..75fc8adfdd4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6309988.java @@ -370,4 +370,3 @@ public class Bug6309988 { return System.getSecurityManager() != null; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java index 5a93c1a515e..3bdff2a15ae 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java @@ -83,4 +83,3 @@ public class Bug6341770 { System.out.println("OK."); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java index 1e0e25a3bc0..5a76ae9992e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6361283.java @@ -56,4 +56,3 @@ public class Bug6361283 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java index eab6d6dbdb8..98f2e96418d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6506304Test.java @@ -71,4 +71,3 @@ public class Bug6506304Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java index ab23e378732..37ee4cc57f4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6518733.java @@ -67,4 +67,3 @@ public class Bug6518733 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java index 1ae8c810fd9..e427478c427 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6564400.java @@ -180,4 +180,3 @@ public class Bug6564400 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java index dd12ea5e254..87953ae836b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786.java @@ -73,4 +73,3 @@ public class Bug6573786 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java index f4595896db7..b938eb6eb6f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6573786ErrorHandler.java @@ -45,4 +45,3 @@ public class Bug6573786ErrorHandler extends DefaultHandler { System.out.println(e.getMessage()); } // warning () } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java index 411bdf7c422..7e168d90cd4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6594813.java @@ -175,4 +175,3 @@ public class Bug6594813 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java index 67f596b284f..9c638368cc6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6608841.java @@ -59,4 +59,3 @@ public class Bug6608841 { public class MyHandler extends DefaultHandler { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java index 5d4359ae368..a866ee56a81 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6690015.java @@ -87,4 +87,3 @@ public class Bug6690015 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java index 9e6514aded4..a1cdcac7054 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6760982.java @@ -168,4 +168,3 @@ public class Bug6760982 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java index 4c9f3c0e11f..f2266d24e1c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6849942Test.java @@ -81,4 +81,3 @@ public class Bug6849942Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java index 26f3f8a595a..6fb819bf9ec 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7157608Test.java @@ -218,4 +218,3 @@ public class Bug7157608Test { boolean validating = false; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java index ed727064128..ec25ae28d80 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug7166896Test.java @@ -80,4 +80,3 @@ public class Bug7166896Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147Test.java index efa75ed9838..4522fec1658 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147Test.java @@ -93,4 +93,3 @@ public class Bug8003147Test { }, new FilePermission(getSystemProperty("test.classes") + "/-", "read,write")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147TestClass.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147TestClass.java index f9da51202e1..3088a8d4f8c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147TestClass.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8003147TestClass.java @@ -32,4 +32,3 @@ public class Bug8003147TestClass { public void doSomething(double d, ArrayList list) { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java index eae5319f34d..aef8e65f838 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug8073385.java @@ -100,4 +100,3 @@ public class Bug8073385 { assertTrue(exceptionText.contains("Unicode: " + hexString)); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java index 2a4d7c17514..d45e6702fc0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/FactoryFindTest.java @@ -75,4 +75,3 @@ public class FactoryFindTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java index 52874b90362..c690163eb86 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/MyDefaultHandler.java @@ -45,4 +45,3 @@ public class MyDefaultHandler extends DefaultHandler { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java index fb01c19171a..695c932f603 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/MyErrorHandler.java @@ -53,4 +53,3 @@ public class MyErrorHandler extends DefaultHandler { errorOccured = true; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java index 079f25304c9..c3159cf50cd 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/ParseEmptyStream.java @@ -92,4 +92,3 @@ public class ParseEmptyStream { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java index 63e2371d75e..5b4e018e757 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/SupplementaryChars.java @@ -71,4 +71,3 @@ public class SupplementaryChars { return parser; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java index a1c83eb9c00..8385d40c47f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/xinclude/Bug6794483Test.java @@ -107,4 +107,3 @@ public class Bug6794483Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java b/jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java index a792405cce5..982bc8e595b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Attributes2ImplTest.java @@ -153,4 +153,3 @@ public class Attributes2ImplTest { Assert.assertTrue(impl1.getQName(2).equals(impl3.getQName(2))); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java index 651e804a89d..7eb7a59fe8f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6889654Test.java @@ -87,4 +87,3 @@ public class Bug6889654Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java index 96303049be7..df006578c0c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6925410Test.java @@ -60,4 +60,3 @@ public class Bug6925410Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java index 7a6c8618110..1ba064fa56b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6949607Test.java @@ -81,4 +81,3 @@ public class Bug6949607Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java index 47f076553ff..7d05dd7f0a9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug6992561Test.java @@ -86,4 +86,3 @@ public class Bug6992561Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java index 198ade37101..4bd69f09765 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/Bug7057778Test.java @@ -199,4 +199,3 @@ public class Bug7057778Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java index 7d3ff8c0e2e..a7bd3f59d0c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/DefaultHandler2Test.java @@ -251,4 +251,3 @@ public class DefaultHandler2Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java b/jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java index 6c52f6d69bd..fbfef8f705b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/IssueTracker56Test.java @@ -142,4 +142,3 @@ public class IssueTracker56Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java b/jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java index b36ae9aa88a..44ac9fde73d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/MyDefaultHandler2.java @@ -198,4 +198,3 @@ public class MyDefaultHandler2 extends DefaultHandler2 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java b/jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java index 4ade4a8d76a..32c4c5c05dc 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/NSSupportTest.java @@ -232,4 +232,3 @@ public class NSSupportTest { Assert.assertNull(nssupport.getURI("")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java b/jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java index a4c0e184458..9b9800d27fa 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/SAXExceptionExt.java @@ -38,4 +38,3 @@ public class SAXExceptionExt extends SAXException { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java b/jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java index 73c92da706a..cc234531a27 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/sax/XMLReaderTest.java @@ -70,4 +70,3 @@ public class XMLReaderTest { XMLReaderAdapter adapter = new XMLReaderAdapter(); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java index f9dbc0d4591..7aece9698f9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/AttributeLocalNameTest/AttributeLocalNameTest.java @@ -66,4 +66,3 @@ public class AttributeLocalNameTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java index 97cf8292b5e..ba8c7adee57 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6370703.java @@ -69,4 +69,3 @@ public class Bug6370703 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java index 8848cb4f76f..4fa70e2b73b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6378422.java @@ -51,4 +51,3 @@ public class Bug6378422 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java index 6ad9bfc092a..0c584d0fe35 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6380870.java @@ -58,4 +58,3 @@ public class Bug6380870 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java index 39cdcb0f9db..832f74de959 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6489502.java @@ -83,4 +83,3 @@ public class Bug6489502 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java index 54eeb8b60e4..5c6a4106104 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6509774.java @@ -174,4 +174,3 @@ public class Bug6509774 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java index dca27beec11..1c4ac758575 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6688002Test.java @@ -113,4 +113,3 @@ public class Bug6688002Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java index a3f09aa7334..f4a40ef28e8 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/Bug6976938Test.java @@ -100,4 +100,3 @@ public class Bug6976938Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java index 0b00c3c654c..09a12ca7476 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/CoalesceTest/CoalesceTest.java @@ -110,4 +110,3 @@ public class CoalesceTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java index b7947fd2f44..24526e0dd9f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EntitiesTest/EntityTest.java @@ -179,4 +179,3 @@ public class EntityTest { return true; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java index 87246ebd13b..db93e02f55b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventReaderDelegateTest.java @@ -231,4 +231,3 @@ public class EventReaderDelegateTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java index 56f97c54b48..13f25d5adc0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue41Test.java @@ -178,4 +178,3 @@ public class Issue41Test { System.out.println(sw.toString()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java index 4d3b144aca6..d4fa45bb789 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue48Test.java @@ -115,4 +115,3 @@ public class Issue48Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java index 1e30efb2ca4..1490e28269c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue53Test.java @@ -71,4 +71,3 @@ public class Issue53Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java index 8e00999acb4..6453fae9e06 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/Issue58Test.java @@ -84,4 +84,3 @@ public class Issue58Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java index 8e908b0e37e..a0a538f2369 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/FactoryFindTest.java @@ -151,4 +151,3 @@ public class FactoryFindTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java index 44708b22e3e..4610aff758e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/IgnoreExternalDTDTest.java @@ -77,4 +77,3 @@ public class IgnoreExternalDTDTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java index 44a7dea91c3..43e785f81e4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/ProcessingInstructionTest/ProcessingInstructionTest.java @@ -67,4 +67,3 @@ public class ProcessingInstructionTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java index 0568bca28bf..44c602e72d4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/StreamReaderDelegateTest.java @@ -383,4 +383,3 @@ public class StreamReaderDelegateTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java index 75bb79566f2..0472899ebb2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventLocationTest.java @@ -82,4 +82,3 @@ public class XMLEventLocationTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java index 5ac6f1a221a..d98aec1caf8 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6489890.java @@ -77,4 +77,3 @@ public class Bug6489890 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java index 79533441e96..ebb7cf87942 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6555001.java @@ -116,4 +116,3 @@ public class Bug6555001 { }, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java index 86f2437fc85..437dd9e602a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6586466Test.java @@ -66,4 +66,3 @@ public class Bug6586466Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java index 43e8a6165f1..23531b463ec 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6613059Test.java @@ -89,4 +89,3 @@ public class Bug6613059Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java index 07309465f99..f2b8ebe7e2f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6668115Test.java @@ -100,4 +100,3 @@ public class Bug6668115Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java index a89b976b618..416c3e960bb 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug6846133Test.java @@ -83,4 +83,3 @@ public class Bug6846133Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java index 2ac01596c50..7c3b529afcf 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Bug8153781.java @@ -94,4 +94,3 @@ public class Bug8153781 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java index 4c6e0c0ffb7..9ed53c57833 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/Issue40Test.java @@ -100,4 +100,3 @@ public class Issue40Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java index d96eea1a1b4..3bd3ca25296 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/ReaderToWriterTest.java @@ -214,4 +214,3 @@ public class ReaderToWriterTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java index e04a349d92e..3dd7e25de3c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLEventWriterTest/XMLEventWriterTest.java @@ -156,4 +156,3 @@ public class XMLEventWriterTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java index 3ba9ca7776b..2e4b41dce2d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6756677Test.java @@ -113,4 +113,3 @@ public class Bug6756677Test { Assert.assertTrue(xif instanceof XMLInputFactory, "xif should be an instance of XMLInputFactory"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java index d2e29713e2b..562b7a3d559 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/Bug6909759Test.java @@ -66,4 +66,3 @@ public class Bug6909759Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java index dea8f732b46..a70288a9346 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/IssueTracker38.java @@ -92,4 +92,3 @@ public class IssueTracker38 { } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java index d9db7a08344..551d3f0f8d2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLInputFactoryTest/MyInputFactory.java @@ -158,4 +158,3 @@ public class MyInputFactory extends javax.xml.stream.XMLInputFactory { throw new UnsupportedOperationException("Not supported yet."); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java index fa764c154a5..aabfa430581 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/Bug6846132Test.java @@ -89,4 +89,3 @@ public class Bug6846132Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java index 8fec5b107da..99c12487cf7 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/DuplicateNSDeclarationTest.java @@ -83,4 +83,3 @@ public class DuplicateNSDeclarationTest { Assert.assertEquals(EXPECTED_OUTPUT, buffer.toString()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java index e44a20c3138..47b089ae55f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLOutputFactoryTest/StreamResultTest.java @@ -162,4 +162,3 @@ public class StreamResultTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java index 12e7e9a74d9..628977e2656 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLResolverTest/XMLResolverTest.java @@ -96,4 +96,3 @@ public class XMLResolverTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java index 403c609db91..05f9aaecd0e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionTest.java @@ -53,4 +53,3 @@ public class ExceptionTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java index 5ab83c987f8..87e70ab9cd9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481615.java @@ -68,4 +68,3 @@ public class Bug6481615 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java index ea79d530b11..daec8fb9cd2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/Bug6481678.java @@ -225,4 +225,3 @@ public class Bug6481678 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java index c573a8dfb6b..ad4c50dce75 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTest.java @@ -145,4 +145,3 @@ public class HasNextTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java index 19748b3afdb..1fd6e20fe08 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamFilterTest/HasNextTypeFilter.java @@ -47,4 +47,3 @@ public class HasNextTypeFilter implements EventFilter, StreamFilter { return types[r.getEventType()]; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java index 3fa5bec18e7..93e934c7fe3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BOMTest.java @@ -67,4 +67,3 @@ public class BOMTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java index a981ba10c77..5c8096b45af 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6388460.java @@ -76,4 +76,3 @@ public class Bug6388460 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java index cd083359e1d..a4bec110fe9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6472982Test.java @@ -79,4 +79,3 @@ public class Bug6472982Test { return sbuffer.toString(); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java index 5a4c0be28a7..49f03ca4ba0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6767322Test.java @@ -76,4 +76,3 @@ public class Bug6767322Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java index cfe1ade63ad..cdf353ecafe 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Bug6847819Test.java @@ -69,4 +69,3 @@ public class Bug6847819Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java index a2cf3c2ae9b..ca30f426d68 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/BugTest.java @@ -51,4 +51,3 @@ public class BugTest { Assert.assertEquals(XMLStreamConstants.START_DOCUMENT, r.getEventType()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java index 10db94b8203..898bf3e3332 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DefaultAttributeTest.java @@ -108,4 +108,3 @@ public class DefaultAttributeTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java index 493d6b31545..1b47db5f4b3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/DoubleXmlnsTest.java @@ -118,4 +118,3 @@ public class DoubleXmlnsTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java index 1f447928aa7..44c0c1fcd2c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IsValidatingTest.java @@ -165,4 +165,3 @@ public class IsValidatingTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java index 9ef51e64d02..f4f8f5dbdc0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue44Test.java @@ -59,4 +59,3 @@ public class Issue44Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java index ad2d8dc0293..7d456463a4b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Issue47Test.java @@ -89,4 +89,3 @@ public class Issue47Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java index b259576202c..1d7041d58b2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker24.java @@ -61,4 +61,3 @@ public class IssueTracker24 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java index d98e249c48e..2cc0a483ae6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker35.java @@ -59,4 +59,3 @@ public class IssueTracker35 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java index 33cc4b87574..c107c18110f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/IssueTracker70.java @@ -76,4 +76,3 @@ public class IssueTracker70 { Assert.assertNotNull(value, "should have attribute value"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java index 3505fd59f50..0c753ac3be4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req5Test.java @@ -91,4 +91,3 @@ public class Jsr173MR1Req5Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java index b6e703e93f8..49908781cd1 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/Jsr173MR1Req8Test.java @@ -69,4 +69,3 @@ public class Jsr173MR1Req8Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java index 2ea93e90950..334011befc7 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/NamespaceTest.java @@ -153,4 +153,3 @@ public class NamespaceTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java index cc01f89ebda..39a1c85bafb 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/StreamReaderTest.java @@ -62,4 +62,3 @@ public class StreamReaderTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java index ca51c6e1094..bfdfb76e06f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/SupportDTDTest.java @@ -288,4 +288,3 @@ public class SupportDTDTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java index 216bf0d6536..a31b445880c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/VoiceXMLDTDTest.java @@ -58,4 +58,3 @@ public class VoiceXMLDTDTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java index f69166a2be8..95a88e5eb4b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamReaderTest/XML11Test.java @@ -54,4 +54,3 @@ public class XML11Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java index 811f0bf1173..e7378e11170 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/AttributeEscapeTest.java @@ -103,4 +103,3 @@ public class AttributeEscapeTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java index 595c58d44a2..35472f0713d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6452107.java @@ -64,4 +64,3 @@ public class Bug6452107 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java index f8cb256404c..e17b04da265 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6600882Test.java @@ -59,4 +59,3 @@ public class Bug6600882Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java index 25cd9327513..0e4f0aa22f5 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug6675332Test.java @@ -164,4 +164,3 @@ public class Bug6675332Test extends BaseStAXUT { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java index a157d7c84a1..8729d9f2711 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/Bug7037352Test.java @@ -65,4 +65,3 @@ public class Bug7037352Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java index 929cbda273f..f59ef011018 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DOMUtil.java @@ -221,4 +221,3 @@ public class DOMUtil { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java index 466a51ce506..bef8db02e6e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java @@ -124,4 +124,3 @@ public class DomUtilTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java index be4cc62d4a3..d40bcae712c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EmptyElementTest.java @@ -85,4 +85,3 @@ public class EmptyElementTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java index deff9cc9d1e..ced54992790 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/EncodingTest.java @@ -110,4 +110,3 @@ public class EncodingTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java index 04ad1d7b12e..7e574bc879f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NamespaceTest.java @@ -1434,4 +1434,3 @@ public class NamespaceTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java index e4d0bfc9c92..00f7a62dada 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/NullUriDetectionTest.java @@ -54,4 +54,3 @@ public class NullUriDetectionTest { w.writeCharacters("---"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java index a5d76495376..ea71a065817 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SqeLinuxTest.java @@ -88,4 +88,3 @@ public class SqeLinuxTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java index 4208cc9b24d..97953d3993a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/SurrogatesTest.java @@ -175,4 +175,3 @@ public class SurrogatesTest { }; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java index 95bb8965ab7..68fab1bdb5b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/UnprefixedNameTest.java @@ -125,4 +125,3 @@ public class UnprefixedNameTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java index c7148edb187..7e681e343c4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/WriterTest.java @@ -784,4 +784,3 @@ public class WriterTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java index 0d063043ba0..5b5893c8eb2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/XMLStreamWriterTest.java @@ -73,4 +73,3 @@ public class XMLStreamWriterTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java index 63869afc6ec..2b2a1e94506 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4693341Test.java @@ -94,4 +94,3 @@ public class Bug4693341Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java index ed348885b33..cb92eb762ed 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug4892774.java @@ -377,4 +377,3 @@ public class Bug4892774 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java index 750f38c811c..eb8853da891 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug5073477.java @@ -55,4 +55,3 @@ public class Bug5073477 { r.setNextSibling(r.getNode().getFirstChild()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java index 0cfcfa0e05e..dede016d4ff 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6175602.java @@ -54,4 +54,3 @@ public class Bug6175602 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java index 1947d7e7f93..2c60db3cc3d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6206491.java @@ -134,4 +134,3 @@ public class Bug6206491 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java index 291eb372eeb..7031585a864 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6216226Test.java @@ -69,4 +69,3 @@ public class Bug6216226Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java index adc49f1ed3d..9cfec4471f3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6311448.java @@ -85,4 +85,3 @@ public class Bug6311448 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java index 3e7bc97d12f..b32d1d83524 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6384805.java @@ -94,4 +94,3 @@ public class Bug6384805 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java index 881bd808038..ecf248b8523 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6465722.java @@ -72,4 +72,3 @@ public class Bug6465722 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java index 86f9436c9f6..61c6692b755 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6467808.java @@ -76,4 +76,3 @@ public class Bug6467808 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java index 7301108e272..255dd878c4e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490380.java @@ -61,4 +61,3 @@ public class Bug6490380 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java index 759467caffc..f9bea6978a1 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6490921.java @@ -145,4 +145,3 @@ public class Bug6490921 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java index 26a51f339e5..acb81122327 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6513892.java @@ -77,4 +77,3 @@ public class Bug6513892 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java index b77ec5d5900..6c1938e4afd 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6537167.java @@ -85,4 +85,3 @@ public class Bug6537167 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java index 90cbfccd0f4..22182435206 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6540545.java @@ -64,4 +64,3 @@ public class Bug6540545 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6551616.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6551616.java index 3bd1e7adbc9..27c6ddf008c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6551616.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6551616.java @@ -68,4 +68,3 @@ public class Bug6551616 { // if it doesn't blow up, it succeeded. } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java index 05a5e1c9e83..f1d4c3d8cfe 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6559595.java @@ -70,4 +70,3 @@ public class Bug6559595 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java index 6a56d55518b..df14bc37603 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6565260.java @@ -64,4 +64,3 @@ public class Bug6565260 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java index 628310c0d33..e00da88993c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Bug6940416.java @@ -115,4 +115,3 @@ public class Bug6940416 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java index e41107089d5..ecd61f603ec 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/BugDB12665704Test.java @@ -157,4 +157,3 @@ public class BugDB12665704Test { return sb.toString(); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CLITest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CLITest.java index e72fc26d4f6..57f3009b682 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CLITest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CLITest.java @@ -50,4 +50,3 @@ public class CLITest { }, new PropertyPermission("*", "read,write")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java index b7af4a5841f..b17df311824 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6401137Test.java @@ -94,4 +94,3 @@ public class CR6401137Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java index d08dddffca0..d168ecb2e48 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6551600Test.java @@ -94,4 +94,3 @@ public class CR6551600Test { : new FilePermission("///tmp/test.xml", "read,write,delete")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java index 3602f80b809..fec10a1be1b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6577667Test.java @@ -59,4 +59,3 @@ public class CR6577667Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java index 057238513d2..2bfe0631a71 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6652519Test.java @@ -79,4 +79,3 @@ public class CR6652519Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java index cdfcae7d550..5ad290060ac 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6689809Test.java @@ -64,4 +64,3 @@ public class CR6689809Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java index 33f9957bc85..78006b5c8f4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6905829Test.java @@ -65,4 +65,3 @@ public class CR6905829Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java index 3db8bc3af6e..db8d8721d2e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6935697Test.java @@ -77,4 +77,3 @@ public class CR6935697Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java index 8fd89254737..13331ce4cc1 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6941869Test.java @@ -76,4 +76,3 @@ public class CR6941869Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java index 4e4e7ddb05c..24c3bfd4318 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR6957215Test.java @@ -99,4 +99,3 @@ public class CR6957215Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java index c84a512e1ec..04ec9fd8ea3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/CR7098746Test.java @@ -90,4 +90,3 @@ public class CR7098746Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java index bf46190ee35..cbfaf0f924a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/DOMResultTest.java @@ -215,4 +215,3 @@ public class DOMResultTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java b/jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java index f9a93513112..81227c7d691 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/DocumentExtFunc.java @@ -33,4 +33,3 @@ public class DocumentExtFunc { return "["+node.getNodeName() + ":" + node.getTextContent()+"]"; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java index 56eff4001df..f1267ce4622 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/FactoryFindTest.java @@ -75,4 +75,3 @@ public class FactoryFindTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java index 52f41c46715..dbba31b46dc 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2204Test.java @@ -67,4 +67,3 @@ public class Issue2204Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java index 10ba8615c44..8047d83fec1 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/Issue2290Test.java @@ -96,4 +96,3 @@ public class Issue2290Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java b/jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java index 4fceeaacbc4..8aff9628bba 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/OpenJDK100017Test.java @@ -66,4 +66,3 @@ public class OpenJDK100017Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java index 1dc5cfbab7e..34e092101bc 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/SAX2DOMTest.java @@ -198,4 +198,3 @@ public class SAX2DOMTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java index 27a03bf4e44..a6ecfdee907 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java @@ -135,4 +135,3 @@ public class SecureProcessingTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java index 76507bfca1f..dd92c26065a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/SourceTest.java @@ -148,4 +148,3 @@ public class SourceTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java index cfa20d1b47a..09df03442e5 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java @@ -129,4 +129,3 @@ public class StAXSourceTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java index e2a4fc2ca08..f0cd1441661 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TemplatesTest.java @@ -83,4 +83,3 @@ public class TemplatesTest { + " contains($validAffectsRelClasses, @Class)]/@OBID)\"/>" + ""; } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java index 2d6dfbf8aae..550da2bc8d2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerFactoryTest.java @@ -153,4 +153,3 @@ public class TransformerFactoryTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java index 199a4bac62a..59d195e3d8b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerTest.java @@ -439,4 +439,3 @@ public class TransformerTest { Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(), "unexpected namespace for test6"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java index dade0b6b56f..793dd7ad6ac 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/TransformerUtilFactory.java @@ -56,4 +56,3 @@ public class TransformerUtilFactory { return null; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java b/jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java index f79ecd6bdde..ff8fbfe189b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/VersionDefaultHandler.java @@ -62,4 +62,3 @@ public class VersionDefaultHandler extends DefaultHandler { return encoding; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java b/jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java index e7fe77b039f..51ff18c421d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/VersionEventWriter.java @@ -82,4 +82,3 @@ public class VersionEventWriter implements XMLEventWriter { return encoding; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java index 51df5915037..87360daf486 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java @@ -23,9 +23,12 @@ package transform; +import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; - +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; @@ -34,11 +37,16 @@ import javax.xml.transform.URIResolver; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; +import static jaxp.library.JAXPTestUtilities.runWithAllPerm; +import static jaxp.library.JAXPTestUtilities.clearSystemProperty; +import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import static jaxp.library.JAXPTestUtilities.getSystemProperty; /* * @test @@ -49,8 +57,95 @@ import static org.testng.Assert.assertEquals; * @summary This class contains tests for XSLT functions. */ -//@Listeners({jaxp.library.BasePolicy.class}) //uncomment this line after 8161454 is resolved +@Listeners({jaxp.library.FilePolicy.class}) public class XSLTFunctionsTest { + /** + * @bug 8165116 + * Verifies that redirect works properly when extension function is enabled + * + * @param xml the XML source + * @param xsl the stylesheet that redirect output to a file + * @param output the output file + * @param redirect the redirect file + * @throws Exception if the test fails + **/ + @Test(dataProvider = "redirect") + public void testRedirect(String xml, String xsl, String output, String redirect) throws Exception { + + TransformerFactory tf = TransformerFactory.newInstance(); + tf.setFeature(ORACLE_ENABLE_EXTENSION_FUNCTION, true); + Transformer t = tf.newTransformer(new StreamSource(new StringReader(xsl))); + + //Transform the xml + t.transform(new StreamSource(new StringReader(xml)), new StreamResult(new StringWriter())); + + // Verifies that the output is redirected successfully + String userDir = getSystemProperty("user.dir"); + Path pathOutput = Paths.get(userDir, output); + Path pathRedirect = Paths.get(userDir, redirect); + Assert.assertTrue(Files.exists(pathOutput)); + Assert.assertTrue(Files.exists(pathRedirect)); + System.out.println("Output to " + pathOutput + " successful."); + System.out.println("Redirect to " + pathRedirect + " successful."); + Files.deleteIfExists(pathOutput); + Files.deleteIfExists(pathRedirect); + } + + /** + * @bug 8161454 + * Verifies that the new / correct name is supported, as is the old / incorrect + * one for compatibility + */ + @Test + public void testNameChange() { + + boolean feature; + TransformerFactory tf = TransformerFactory.newInstance(); + feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); + System.out.println("Default setting: " + feature); + // The default: true if no SecurityManager, false otherwise + Assert.assertTrue(feature == getDefault()); + + setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION, getDefaultOpposite()); + tf = TransformerFactory.newInstance(); + feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); + System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION + ": " + feature); + clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION); + // old/incorrect name is still supported + Assert.assertTrue(feature != getDefault()); + + setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC, getDefaultOpposite()); + tf = TransformerFactory.newInstance(); + feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); + System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION_SPEC + ": " + feature); + clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC); + // new/correct name is effective + Assert.assertTrue(feature != getDefault()); + } + + final boolean isSecure; + { + String runSecMngr = getSystemProperty("runSecMngr"); + isSecure = runSecMngr != null && runSecMngr.equals("true"); + } + + // The default: true if no SecurityManager, false otherwise + private boolean getDefault() { + if (isSecure) { + return false; + } else { + return true; + } + } + + // Gets a String value that is opposite to the default value + private String getDefaultOpposite() { + if (isSecure) { + return "true"; + } else { + return "false"; + } + } /** * @bug 8062518 8153082 @@ -72,7 +167,9 @@ public class XSLTFunctionsTest { // Create factory and transformer TransformerFactory tf = TransformerFactory.newInstance(); - tf.setFeature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", true); + tf.setFeature(ORACLE_ENABLE_EXTENSION_FUNCTION, true); + tf.setAttribute(EXTENSION_CLASS_LOADER, + runWithAllPerm(() -> Thread.currentThread().getContextClassLoader())); Transformer t = tf.newTransformer( xslsrc ); t.setErrorListener(tf.getErrorListener()); @@ -114,6 +211,13 @@ public class XSLTFunctionsTest { }; } + @DataProvider(name = "redirect") + public static Object[][] getData() { + return new Object[][] { + {documentTestXml, xslRedirect, "testoutput.xml", "testredirect.xml"}, + }; + } + static final String documentTestXml = "Doc"; static final String documentTestExternalDoc = "External Doc"; @@ -133,5 +237,33 @@ public class XSLTFunctionsTest { static final String documentTesteExpectedResult = "" + "[Test:Doc][Test:External Doc]"; -} + static String xslRedirect = " \n" + + " \n" + + " This goes to standard output\n" + + " \n" + + " This ends up in the file 'testoutput.xml'\n" + + " \n" + + " \n" + + " This ends up in the file 'testredirect.xml'\n" + + " \n" + + " \n" + + ""; + + public static final String ORACLE_JAXP_PROPERTY_PREFIX = + "http://www.oracle.com/xml/jaxp/properties/"; + /** + * Feature enableExtensionFunctions + */ + public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = + ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; + static final String SP_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; + // This is the correct name by the spec + static final String SP_ENABLE_EXTENSION_FUNCTION_SPEC = "jdk.xml.enableExtensionFunctions"; + private static final String EXTENSION_CLASS_LOADER = "jdk.xml.transform.extensionClassLoader"; +} diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java b/jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java index 662c20b13aa..77bc7b4a7e2 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/sax/Bug6451633.java @@ -62,4 +62,3 @@ public class Bug6451633 { Assert.assertEquals(0, ((Document) result.getNode()).getDocumentElement().getChildNodes().getLength()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java b/jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java index 832c10f062e..988da74f834 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/DOMUtil.java @@ -68,4 +68,3 @@ public class DOMUtil extends TransformerUtil { Assert.assertTrue(version.equals(resultVersion), "Expected XML Version is 1.1, but actual version " + resultVersion); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java b/jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java index 5bee6019cbb..9e257ebf9a6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/SAXUtil.java @@ -70,4 +70,3 @@ public class SAXUtil extends TransformerUtil { Assert.assertTrue(encoding.equals(resultEncoding), "Expected XML Version is " + encoding + " , but actual encoding " + resultEncoding); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java b/jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java index 91423dae161..26374d76ab0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/StAXUtil.java @@ -92,4 +92,3 @@ public class StAXUtil extends TransformerUtil { ((StreamUtil) TransformerUtilFactory.getUtil(TransformerUtilFactory.STREAM)).checkStream(new FileInputStream(TEMP_FILE), version); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java b/jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java index 91a37a909cb..8a1630088b6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/util/StreamUtil.java @@ -94,4 +94,3 @@ public class StreamUtil extends TransformerUtil { Assert.assertTrue(dh.getEncoding().equals(encoding), "Expected version is " + encoding + " actual version " + dh.getEncoding()); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java b/jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java index d142b7ad331..2088452af58 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java +++ b/jaxp/test/javax/xml/jaxp/unittest/util/BOMInputStream.java @@ -78,4 +78,3 @@ public class BOMInputStream { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java b/jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java index c3211c50e5b..86a54335249 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java +++ b/jaxp/test/javax/xml/jaxp/unittest/util/BaseStAXUT.java @@ -557,4 +557,3 @@ public class BaseStAXUT implements XMLStreamConstants { System.err.println("Skipping " + clsName + "#" + method + ": entity expansion does not seem to be functioning properly" + msg + "."); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java index 8c615c5d3a0..c12a1515245 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/AnyElementTest.java @@ -85,4 +85,3 @@ public class AnyElementTest { private Validator validator; } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java index 3c0c6db7b46..05300cc6964 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966232.java @@ -75,4 +75,3 @@ public class Bug4966232 { Assert.assertNotNull(s); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java index 4eafe25cac9..46e9fd23034 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4966254.java @@ -78,4 +78,3 @@ public class Bug4966254 { return s; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java index 31770d19436..e7b22fec08b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969042.java @@ -111,4 +111,3 @@ public class Bug4969042 { Assert.assertTrue(invoked[1], "Method characters() was not invoked."); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java index 1f7e75f7f74..74a75f75433 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969089.java @@ -76,4 +76,3 @@ public class Bug4969089 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java index 637aefd2e42..5c7bac6dbc9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969110.java @@ -79,4 +79,3 @@ public class Bug4969110 { validatorHandler.setProperty(name, "123"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java index a3973ba4cd5..c0554c2478e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969689.java @@ -66,4 +66,3 @@ public class Bug4969689 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java index cafb7dc502e..d78fe660b5f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969692.java @@ -67,4 +67,3 @@ public class Bug4969692 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java index 8cfe3f8e748..fd203f3c734 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969693.java @@ -67,4 +67,3 @@ public class Bug4969693 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java index dbc33468438..01d47b627e4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969695.java @@ -65,4 +65,3 @@ public class Bug4969695 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java index b633c960e61..cfec3964c19 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4969732.java @@ -112,4 +112,3 @@ public class Bug4969732 { parse(xmlReader, XML); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java index 8046b8d4df8..4954f41948a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970380.java @@ -62,4 +62,3 @@ public class Bug4970380 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java index 354a3c1222a..28809222c12 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970383.java @@ -53,4 +53,3 @@ public class Bug4970383 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java index d6de9217452..a8c761f23da 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970400.java @@ -48,4 +48,3 @@ public class Bug4970400 { validatorHandler.setFeature("http://xml.org/sax/features/namespace-prefixes", true); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java index c31fc8d440e..c75604b4b5e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970402.java @@ -123,4 +123,3 @@ public class Bug4970402 { parse(xmlReader, XML); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java index 2c4dfe9aa63..91b2891fdbf 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4970951.java @@ -126,4 +126,3 @@ public class Bug4970951 { parse(xmlReader, XML); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java index 8ca323f0022..8654f283a04 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971605.java @@ -66,4 +66,3 @@ public class Bug4971605 { Assert.assertNotNull(schema, "Failed: newSchema returned null."); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java index 6ee9bcacbb4..385bef46b58 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4971607.java @@ -56,4 +56,3 @@ public class Bug4971607 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java index 8c84351ffff..cf585a2df69 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4972882.java @@ -67,4 +67,3 @@ public class Bug4972882 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java index a4dfc4ca0a8..fb6dcdd4210 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4986844.java @@ -56,4 +56,3 @@ public class Bug4986844 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java index a5f0c528535..75a7ee51fa6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4987574.java @@ -60,4 +60,3 @@ public class Bug4987574 { schemaFactory.newSchema(tmpFile); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java index 51f735c5792..2da7618ed7c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988267.java @@ -56,4 +56,3 @@ public class Bug4988267 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java index 85129933490..8de45e95ff3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988268.java @@ -46,4 +46,3 @@ public class Bug4988268 { schemaFactory.newSchema(Bug4988268.class.getResource("Bug4988268.xsd")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java index c5c24343906..e9db60429ad 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4988387.java @@ -53,4 +53,3 @@ public class Bug4988387 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java index e27b80a56e8..ba546220580 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4996446.java @@ -90,4 +90,3 @@ class ErrorHandler extends DefaultHandler { errorCounter++; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java index d39c239211b..8c8d677c520 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug4997818.java @@ -81,4 +81,3 @@ public class Bug4997818 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java index f8444a597aa..b3a85cadc68 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5011500.java @@ -108,4 +108,3 @@ public class Bug5011500 { validator.validate(xmlSource); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java index ff58fd76658..3d6b490f2c3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug5072946.java @@ -125,4 +125,3 @@ public class Bug5072946 { Assert.assertSame(r.getNode(), n); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java index 344ff0f52e4..4bbc7560b19 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6378043.java @@ -53,4 +53,3 @@ public class Bug6378043 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java index 4ae313def37..8a96e05ae5f 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6449797.java @@ -46,4 +46,3 @@ public class Bug6449797 { SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(getClass().getResource("Bug6449797.xsd")); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java index 60181d68ae6..f6c54b14b64 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java @@ -86,4 +86,3 @@ public class Bug6457662 { return rtn; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java index b5ebcb6dd31..5fa073eb2d5 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java @@ -205,4 +205,3 @@ public class Bug6467424Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java index ceebedf2212..b9b0812c8e7 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6483188.java @@ -88,4 +88,3 @@ public class Bug6483188 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java index ed790064c7f..71a1afee3f9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6493687.java @@ -48,4 +48,3 @@ public class Bug6493687 { System.out.println("Got here3"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java index 8e32d70ab19..f397677ce73 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6509668.java @@ -141,4 +141,3 @@ public class Bug6509668 { parse(xmlReader, XML); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java index 0ee1219b3b0..47d8d624c21 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6526547.java @@ -82,4 +82,3 @@ public class Bug6526547 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java index 01b5e861672..54e1e05ea90 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6531160.java @@ -70,4 +70,3 @@ public class Bug6531160 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java index c0f85a31e0e..88d37eec67e 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6695843Test.java @@ -82,4 +82,3 @@ public class Bug6695843Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java index b50fa08e529..21479c6a6e3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java @@ -160,4 +160,3 @@ public class Bug6773084Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java index aafc2974ec1..c695aded8d7 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6859210.java @@ -100,4 +100,3 @@ public class Bug6859210 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java index cc36b1e541d..8059723d700 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6925531Test.java @@ -210,4 +210,3 @@ public class Bug6925531Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java index e5dda822b03..e134d8b6b5c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6946312Test.java @@ -128,4 +128,3 @@ public class Bug6946312Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java index 38eebc162bc..510298c865d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6954738_Test.java @@ -83,4 +83,3 @@ public class Bug6954738_Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java index 8221278929b..d3a0f1ef40c 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/CR6708840Test.java @@ -140,4 +140,3 @@ public class CR6708840Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java b/jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java index 31af92f26fc..bccef3d37b8 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/CR6740048.java @@ -131,4 +131,3 @@ public class CR6740048 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java b/jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java index 775fdd07c6a..95806ed3f21 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ErrorHandlerImpl.java @@ -45,4 +45,3 @@ public class ErrorHandlerImpl implements ErrorHandler { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java index 943f23d1b8c..459fa8c149a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Issue682Test.java @@ -78,4 +78,3 @@ public class Issue682Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java b/jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java index 68ba8c10152..6f0fb1b5a25 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/IssueTracker30.java @@ -132,4 +132,3 @@ public class IssueTracker30 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java index 4b506680016..b42f5272893 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue43Test.java @@ -84,4 +84,3 @@ public class JaxpIssue43Test { return list.toArray(new Source[list.size()]); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java b/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java index b53a10ee86e..7cf58257847 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/JaxpIssue49.java @@ -94,4 +94,3 @@ public class JaxpIssue49 { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java index 6681ab76918..78ac556e80a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/LargeMaxOccursTest.java @@ -109,4 +109,3 @@ public class LargeMaxOccursTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java index 33340dd6a29..457cf697228 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursTest.java @@ -147,4 +147,3 @@ public class MultiOccursTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java index 8330ac5de52..58062410c43 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/MultiOccursUnboundedTest.java @@ -115,4 +115,3 @@ public class MultiOccursUnboundedTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java index bce2b0d2d42..8e3613739d3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursTest.java @@ -147,4 +147,3 @@ public class OccursTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java index a986cc1f669..6e8213e0e8b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursUnboundedTest.java @@ -115,4 +115,3 @@ public class OccursUnboundedTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java index 649dcd27d73..f29da26225d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardTest.java @@ -147,4 +147,3 @@ public class OccursWildcardTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java index ee82f528855..002c9983716 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/OccursWildcardUnbounded.java @@ -115,4 +115,3 @@ public class OccursWildcardUnbounded { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java index aa9540d911c..ac1450d05d3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesId005Test.java @@ -99,4 +99,3 @@ public class ParticlesId005Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java index f08dbad1e54..424d4f35c86 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesIg004Test.java @@ -57,4 +57,3 @@ public class ParticlesIg004Test { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java index 05d727f536a..77da3675b83 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ParticlesQ013Test.java @@ -98,4 +98,3 @@ public class ParticlesQ013Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java index ef2bf3741c4..e9cd6473d3b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/SchemaTest.java @@ -54,4 +54,3 @@ public class SchemaTest { factory.newSchema(new File(getClass().getResource("Bug8149915.xsd").getFile())); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java index 79fecdcf9f5..0f5e9dc5de5 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/TCKGroupA008Test.java @@ -60,4 +60,3 @@ public class TCKGroupA008Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java index 720164f09cd..40ca0cc8d3a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/ValidatorTest.java @@ -208,4 +208,3 @@ public class ValidatorTest { return xmlr; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java b/jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java index bdd8107daba..de9b0d935e4 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/XMLDocBuilder.java @@ -141,4 +141,3 @@ public class XMLDocBuilder { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java b/jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java index b09a6b77674..beb05e56afb 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/XMLSchemaValidator.java @@ -59,4 +59,3 @@ public class XMLSchemaValidator { validator.validate(new DOMSource(node)); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java index 286094eb69f..663c7d87fd3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6943252Test.java @@ -69,4 +69,3 @@ public class Bug6943252Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java index 969c66d27ce..f2ff60839d9 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963124Test.java @@ -61,4 +61,3 @@ public class Bug6963124Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java index ea2f0894e37..e2e12b62067 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6963468Test.java @@ -148,4 +148,3 @@ public class Bug6963468Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java index 0536cbe3514..96d68ff4874 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6964720Test.java @@ -58,4 +58,3 @@ public class Bug6964720Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java index 06e4ce81c92..9ff29807e61 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6967214Test.java @@ -70,4 +70,3 @@ public class Bug6967214Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java index 3e3afac5889..4e885d190e3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6970890Test.java @@ -72,4 +72,3 @@ public class Bug6970890Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java index ca733947c0e..b717ff184a3 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6971190Test.java @@ -102,4 +102,3 @@ public class Bug6971190Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java index f4d3581f00c..210ca81ff05 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java @@ -122,4 +122,3 @@ public class Bug6974551Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java index 12ed8261b60..55f9903e470 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6975265Test.java @@ -71,4 +71,3 @@ public class Bug6975265Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java index df77551338b..e41bf4aea92 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6977201Test.java @@ -71,4 +71,3 @@ public class Bug6977201Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java index d1be119584b..3fe2676fa62 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug6989956Test.java @@ -148,4 +148,3 @@ public class Bug6989956Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java index 025c972c288..1f398cc71fb 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/Bug7014246Test.java @@ -59,4 +59,3 @@ public class Bug7014246Test { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java index 19a9eb77d68..50225cc7117 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java @@ -63,4 +63,3 @@ public class ParticleTest { validator.validate(new StreamSource(ParticleTest.class.getResourceAsStream("upa01.xml"))); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java index a46c7c720b2..3a127367be6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java +++ b/jaxp/test/javax/xml/jaxp/unittest/validation/tck/RegexWord.java @@ -63,4 +63,3 @@ public class RegexWord { validator.validate(new StreamSource(RegexWord.class.getResourceAsStream("reZ003vExc23082309.xml"))); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java index a8f65a22b48..7422497f030 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991857.java @@ -92,4 +92,3 @@ public class Bug4991857 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java index d201f489461..58f7e1ce33a 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4991939.java @@ -61,4 +61,3 @@ public class Bug4991939 { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java index 4da3e2de999..dd5ace27633 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992788.java @@ -82,4 +82,3 @@ public class Bug4992788 { return xpath; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java index 2e4a4128ff9..2aad726f9fd 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992793.java @@ -83,4 +83,3 @@ public class Bug4992793 { return xpath; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java index 97a9abfcca4..45449364017 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/Bug4992805.java @@ -70,4 +70,3 @@ public class Bug4992805 { return xpath; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java index d5a52bda8a2..15411a0e25d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/ClassLoaderTest.java @@ -54,4 +54,3 @@ public class ClassLoaderTest { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java index 39a0d72815c..d333e7053a6 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/MyClassLoader.java @@ -47,4 +47,3 @@ public class MyClassLoader extends ClassLoader { return isCalled; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java index a78c1e1439b..d0e100d6f0d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/SecureProcessingTest.java @@ -196,4 +196,3 @@ public class SecureProcessingTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java index 6ba9ceb48bd..efe1fa2a61b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathAnyTypeTest.java @@ -200,4 +200,3 @@ public class XPathAnyTypeTest extends XPathTestBase { verifyResult(result, "Customer"); } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java index f661fe9a035..1717f5d74d5 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/xpath/XPathExpAnyTypeTest.java @@ -187,4 +187,3 @@ public class XPathExpAnyTypeTest extends XPathTestBase { } } - diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 136f72fe00d..0217f716612 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -379,3 +379,5 @@ fe4e11bd2423635dc0f5f5cb9a64eb2f2cce7f4c jdk-9+128 783e7e2c587f2c7e1b9998a46d90ec196ab2a195 jdk-9+131 9fff2477a4cadf2a9618a76f1f4fe0f20bb5ff3b jdk-9+132 05e99eefda2b58d1ed176e411302d9d6b35dca16 jdk-9+133 +ab1d78d395d4cb8be426ff181211da1a4085cf01 jdk-9+134 +22631824f55128a7ab6605493b3001a37af6a168 jdk-9+135 diff --git a/jdk/.hgtags b/jdk/.hgtags index 4639f93e55b..ff5e6944eca 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -376,3 +376,5 @@ c40c8739bcdc88892ff58ebee3fd8a3f287be94d jdk-9+123 8c57f4c293bbc5609928308a6d91ba765760b5f9 jdk-9+131 d5c70818cd8a82e76632c8c815bdb4f75f53aeaf jdk-9+132 3cdae27c90b5e41afe75eab904fda19fac076330 jdk-9+133 +803adcd526d74ae0b64948d1f8260c2dbe514779 jdk-9+134 +021369229cfd0b5feb76834b2ea498f47f43c0f3 jdk-9+135 diff --git a/jdk/make/GenerateClasslist.gmk b/jdk/make/GenerateClasslist.gmk index 279cf9da012..3863a57d670 100644 --- a/jdk/make/GenerateClasslist.gmk +++ b/jdk/make/GenerateClasslist.gmk @@ -50,6 +50,8 @@ TARGETS += $(CLASSLIST_JAR) CLASSLIST_FILE := $(SUPPORT_OUTPUTDIR)/classlist/classlist +JLI_TRACE_FILE := $(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out + # If an external buildjdk has been supplied, we don't build a separate interim # image, so just use the external build jdk instead. ifeq ($(EXTERNAL_BUILDJDK), true) @@ -59,13 +61,11 @@ endif $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR) $(call MakeDir, $(@D)) $(call LogInfo, Generating lib/classlist) - $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.tmp \ - -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ - build.tools.classlist.HelloClasslist $(LOG_DEBUG) 2>&1 - # Filter out generated classes, remove after JDK-8149977 $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \ - -Xshare:dump -XX:SharedClassListFile=$@.tmp $(LOG_DEBUG) 2>&1 - $(RM) $@.tmp + -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \ + -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ + build.tools.classlist.HelloClasslist \ + $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE) TARGETS += $(CLASSLIST_FILE) diff --git a/jdk/make/gendata/GendataBreakIterator.gmk b/jdk/make/gendata/GendataBreakIterator.gmk index a68786a413b..2f7f5dff981 100644 --- a/jdk/make/gendata/GendataBreakIterator.gmk +++ b/jdk/make/gendata/GendataBreakIterator.gmk @@ -81,7 +81,7 @@ UNICODEDATA := $(JDK_TOPDIR)/make/data/unicodedata/UnicodeData.txt # output BASE_DATA_PKG_DIR := $(JDK_OUTPUTDIR)/modules/java.base/sun/text/resources -LD_DATA_PKG_DIR := $(JDK_OUTPUTDIR)/modules/jdk.localedata/sun/text/resources +LD_DATA_PKG_DIR := $(JDK_OUTPUTDIR)/modules/jdk.localedata/sun/text/resources/ext BIFILES := $(BASE_DATA_PKG_DIR)/CharacterBreakIteratorData \ $(BASE_DATA_PKG_DIR)/WordBreakIteratorData \ $(BASE_DATA_PKG_DIR)/LineBreakIteratorData \ diff --git a/jdk/make/gensrc/GensrcVarHandles.gmk b/jdk/make/gensrc/GensrcVarHandles.gmk index 3ad7e630e9c..b4a2bab9873 100644 --- a/jdk/make/gensrc/GensrcVarHandles.gmk +++ b/jdk/make/gensrc/GensrcVarHandles.gmk @@ -44,6 +44,10 @@ define GenerateVarHandle $1_ARGS += -KAtomicAdd endif + ifneq ($$(findstring $$($1_Type), Boolean Byte Short Char Int Long), ) + $1_ARGS += -KBitwise + endif + ifneq ($$(findstring $$($1_Type), Byte Short Char), ) $1_ARGS += -KShorterThanInt endif @@ -101,6 +105,7 @@ define GenerateVarHandleByteArray $1_ARGS += -KCAS $1_ARGS += -KAtomicAdd + $1_ARGS += -KBitwise endif ifeq ($$($1_Type), Long) @@ -113,6 +118,7 @@ define GenerateVarHandleByteArray $1_ARGS += -KCAS $1_ARGS += -KAtomicAdd + $1_ARGS += -KBitwise endif ifeq ($$($1_Type), Float) diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index 247e29698e2..0200c499f79 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2001, 2016, 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 @@ -22,259 +22,261 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# Java_java_awt_KeyboardFocusManager_getGlobalHeavyweightFocusOwner; # Define public interface. # These are the libmawt exports. See mapfile-vers for the libawt exports SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; - Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; - Java_java_awt_AWTEvent_nativeSetSource; - Java_java_awt_Checkbox_initIDs; - Java_java_awt_Component_initIDs; - Java_java_awt_Dialog_initIDs; - Java_java_awt_Font_initIDs; - Java_java_awt_KeyboardFocusManager_initIDs; - Java_java_awt_Menu_initIDs; - Java_java_awt_MenuComponent_initIDs; - Java_java_awt_MenuItem_initIDs; - Java_java_awt_Scrollbar_initIDs; - Java_java_awt_ScrollPane_initIDs; - Java_java_awt_TextArea_initIDs; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; - Java_sun_awt_UNIXToolkit_check_1gtk; - Java_sun_awt_UNIXToolkit_load_1gtk; - Java_sun_awt_UNIXToolkit_unload_1gtk; - Java_sun_awt_UNIXToolkit_load_1stock_1icon; - Java_sun_awt_UNIXToolkit_load_1gtk_1icon; - Java_sun_awt_UNIXToolkit_nativeSync; - Java_sun_awt_X11InputMethod_disposeXIC; - Java_sun_awt_X11InputMethod_isCompositionEnabledNative; - Java_sun_awt_X11InputMethod_resetXIC; - Java_sun_awt_X11InputMethod_setCompositionEnabledNative; - Java_sun_awt_X11InputMethod_turnoffStatusWindow; - Java_sun_awt_SunToolkit_closeSplashScreen; - Java_sun_awt_PlatformFont_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_dispose; - Java_sun_awt_X11GraphicsConfig_pGetBounds; - Java_sun_awt_X11GraphicsConfig_getNumColors; - Java_sun_awt_X11GraphicsConfig_getXResolution; - Java_sun_awt_X11GraphicsConfig_getYResolution; - Java_sun_awt_X11GraphicsConfig_createBackBuffer; - Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; - Java_sun_awt_X11GraphicsConfig_swapBuffers; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; - Java_sun_awt_X11GraphicsDevice_isDBESupported; - Java_sun_awt_X11GraphicsDevice_getDisplay; - Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; - Java_sun_awt_X11GraphicsDevice_getNumConfigs; - Java_sun_awt_X11GraphicsDevice_initIDs; - Java_sun_awt_X11GraphicsDevice_initXrandrExtension; - Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; - Java_sun_awt_X11GraphicsDevice_enumDisplayModes; - Java_sun_awt_X11GraphicsDevice_configDisplayMode; - Java_sun_awt_X11GraphicsDevice_resetNativeData; - Java_sun_awt_X11GraphicsEnvironment_checkShmExt; - Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; - Java_sun_awt_X11GraphicsEnvironment_getDisplayString; - Java_sun_awt_X11GraphicsEnvironment_getNumScreens; - Java_sun_awt_X11GraphicsEnvironment_initDisplay; - Java_sun_awt_X11GraphicsEnvironment_initGLX; - Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; - Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; - Java_sun_awt_X11GraphicsEnvironment_initXRender; - Java_java_awt_AWTEvent_initIDs; - Java_java_awt_Button_initIDs; - Java_java_awt_Container_initIDs; - Java_java_awt_Cursor_finalizeImpl; - Java_java_awt_Cursor_initIDs; - Java_java_awt_Event_initIDs; - Java_java_awt_event_InputEvent_initIDs; - Java_java_awt_event_KeyEvent_initIDs; - Java_java_awt_FileDialog_initIDs; - Java_java_awt_Frame_initIDs; - Java_java_awt_Insets_initIDs; - Java_java_awt_TextField_initIDs; - Java_java_awt_Window_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_initIDs; - Java_sun_awt_X11GraphicsConfig_makeColorModel; - Java_sun_awt_X11GraphicsDevice_getConfigVisualId; - Java_sun_awt_X11GraphicsDevice_getConfigColormap; - Java_sun_awt_X11GraphicsDevice_getConfigDepth; + Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; + Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; + Java_java_awt_AWTEvent_nativeSetSource; + Java_java_awt_Checkbox_initIDs; + Java_java_awt_Component_initIDs; + Java_java_awt_Dialog_initIDs; + Java_java_awt_Font_initIDs; + Java_java_awt_KeyboardFocusManager_initIDs; + Java_java_awt_Menu_initIDs; + Java_java_awt_MenuComponent_initIDs; + Java_java_awt_MenuItem_initIDs; + Java_java_awt_Scrollbar_initIDs; + Java_java_awt_ScrollPane_initIDs; + Java_java_awt_TextArea_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; + Java_sun_awt_UNIXToolkit_check_1gtk; + Java_sun_awt_UNIXToolkit_load_1gtk; + Java_sun_awt_UNIXToolkit_unload_1gtk; + Java_sun_awt_UNIXToolkit_load_1stock_1icon; + Java_sun_awt_UNIXToolkit_load_1gtk_1icon; + Java_sun_awt_UNIXToolkit_nativeSync; + Java_sun_awt_X11InputMethod_disposeXIC; + Java_sun_awt_X11InputMethod_isCompositionEnabledNative; + Java_sun_awt_X11InputMethod_resetXIC; + Java_sun_awt_X11InputMethod_setCompositionEnabledNative; + Java_sun_awt_X11InputMethod_turnoffStatusWindow; + Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_dispose; + Java_sun_awt_X11GraphicsConfig_pGetBounds; + Java_sun_awt_X11GraphicsConfig_getNumColors; + Java_sun_awt_X11GraphicsConfig_getXResolution; + Java_sun_awt_X11GraphicsConfig_getYResolution; + Java_sun_awt_X11GraphicsConfig_createBackBuffer; + Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; + Java_sun_awt_X11GraphicsConfig_swapBuffers; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsDevice_isDBESupported; + Java_sun_awt_X11GraphicsDevice_getDisplay; + Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; + Java_sun_awt_X11GraphicsDevice_getNumConfigs; + Java_sun_awt_X11GraphicsDevice_initIDs; + Java_sun_awt_X11GraphicsDevice_initXrandrExtension; + Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; + Java_sun_awt_X11GraphicsDevice_enumDisplayModes; + Java_sun_awt_X11GraphicsDevice_configDisplayMode; + Java_sun_awt_X11GraphicsDevice_resetNativeData; + Java_sun_awt_X11GraphicsEnvironment_checkShmExt; + Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; + Java_sun_awt_X11GraphicsEnvironment_getDisplayString; + Java_sun_awt_X11GraphicsEnvironment_getNumScreens; + Java_sun_awt_X11GraphicsEnvironment_initDisplay; + Java_sun_awt_X11GraphicsEnvironment_initGLX; + Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; + Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; + Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_java_awt_AWTEvent_initIDs; + Java_java_awt_Button_initIDs; + Java_java_awt_Container_initIDs; + Java_java_awt_Cursor_finalizeImpl; + Java_java_awt_Cursor_initIDs; + Java_java_awt_Event_initIDs; + Java_java_awt_event_InputEvent_initIDs; + Java_java_awt_event_KeyEvent_initIDs; + Java_java_awt_FileDialog_initIDs; + Java_java_awt_Frame_initIDs; + Java_java_awt_Insets_initIDs; + Java_java_awt_TextField_initIDs; + Java_java_awt_Window_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_initIDs; + Java_sun_awt_X11GraphicsConfig_makeColorModel; + Java_sun_awt_X11GraphicsDevice_getConfigVisualId; + Java_sun_awt_X11GraphicsDevice_getConfigColormap; + Java_sun_awt_X11GraphicsDevice_getConfigDepth; - Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; - Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; - Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; - Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; - Java_sun_java2d_x11_X11Renderer_devCopyArea; - Java_sun_java2d_x11_X11SurfaceData_initIDs; - Java_sun_java2d_x11_X11SurfaceData_initOps; - Java_sun_java2d_x11_X11SurfaceData_initSurface; - Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; - Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; - Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; - Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; - Java_sun_java2d_x11_X11SurfaceData_XSetForeground; + Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; + Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; + Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XDoPath; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_devCopyArea; + Java_sun_java2d_x11_X11SurfaceData_initIDs; + Java_sun_java2d_x11_X11SurfaceData_initOps; + Java_sun_java2d_x11_X11SurfaceData_initSurface; + Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; + Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; + Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; + Java_sun_java2d_x11_X11SurfaceData_XSetForeground; - Java_sun_java2d_x11_XSurfaceData_initOps; - Java_sun_java2d_x11_XSurfaceData_XCreateGC; - Java_sun_java2d_x11_XSurfaceData_XResetClip; - Java_sun_java2d_x11_XSurfaceData_XSetClip; - Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; - Java_sun_java2d_x11_XSurfaceData_setInvalid; - Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; - Java_sun_java2d_xr_XRSurfaceData_initXRPicture; - Java_sun_java2d_xr_XRSurfaceData_initIDs; - Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; - Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; - Java_sun_java2d_xr_XRBackendNative_initIDs; - Java_sun_java2d_xr_XIDGenerator_bufferXIDs; - Java_sun_java2d_xr_XRBackendNative_freeGC; - Java_sun_java2d_xr_XRBackendNative_createGC; - Java_sun_java2d_xr_XRBackendNative_createPixmap; - Java_sun_java2d_xr_XRBackendNative_createPictureNative; - Java_sun_java2d_xr_XRBackendNative_freePicture; - Java_sun_java2d_xr_XRBackendNative_freePixmap; - Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; - Java_sun_java2d_xr_XRBackendNative_setGCExposures; - Java_sun_java2d_xr_XRBackendNative_setGCForeground; - Java_sun_java2d_xr_XRBackendNative_copyArea; - Java_sun_java2d_xr_XRBackendNative_renderComposite; - Java_sun_java2d_xr_XRBackendNative_renderRectangle; - Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_setFilter; - Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; - Java_sun_java2d_xr_XRBackendNative_putMaskNative; - Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; - Java_sun_java2d_xr_XRBackendNative_setGCMode; - Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; - Java_sun_java2d_xr_XRUtils_initFormatPtrs; - Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; - XRT_DrawGlyphList; + Java_sun_java2d_x11_XSurfaceData_initOps; + Java_sun_java2d_x11_XSurfaceData_XCreateGC; + Java_sun_java2d_x11_XSurfaceData_XResetClip; + Java_sun_java2d_x11_XSurfaceData_XSetClip; + Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_setInvalid; + Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; + Java_sun_java2d_xr_XRSurfaceData_initXRPicture; + Java_sun_java2d_xr_XRSurfaceData_initIDs; + Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; + Java_sun_java2d_xr_XRBackendNative_initIDs; + Java_sun_java2d_xr_XIDGenerator_bufferXIDs; + Java_sun_java2d_xr_XRBackendNative_freeGC; + Java_sun_java2d_xr_XRBackendNative_createGC; + Java_sun_java2d_xr_XRBackendNative_createPixmap; + Java_sun_java2d_xr_XRBackendNative_createPictureNative; + Java_sun_java2d_xr_XRBackendNative_freePicture; + Java_sun_java2d_xr_XRBackendNative_freePixmap; + Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; + Java_sun_java2d_xr_XRBackendNative_setGCExposures; + Java_sun_java2d_xr_XRBackendNative_setGCForeground; + Java_sun_java2d_xr_XRBackendNative_copyArea; + Java_sun_java2d_xr_XRBackendNative_renderComposite; + Java_sun_java2d_xr_XRBackendNative_renderRectangle; + Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_setFilter; + Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; + Java_sun_java2d_xr_XRBackendNative_putMaskNative; + Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; + Java_sun_java2d_xr_XRBackendNative_setGCMode; + Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; + Java_sun_java2d_xr_XRUtils_initFormatPtrs; + Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; + XRT_DrawGlyphList; - Java_sun_java2d_opengl_OGLContext_getOGLIdString; - Java_sun_java2d_opengl_OGLMaskFill_maskFill; - Java_sun_java2d_opengl_OGLRenderer_drawPoly; - Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer; - Java_sun_java2d_opengl_OGLSurfaceData_initTexture; - Java_sun_java2d_opengl_OGLSurfaceData_initFBObject; - Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer; - Java_sun_java2d_opengl_OGLSurfaceData_getTextureID; - Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget; - Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList; - Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo; - Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig; - Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities; - Java_sun_java2d_opengl_GLXSurfaceData_initOps; + Java_sun_java2d_opengl_OGLContext_getOGLIdString; + Java_sun_java2d_opengl_OGLMaskFill_maskFill; + Java_sun_java2d_opengl_OGLRenderer_drawPoly; + Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer; + Java_sun_java2d_opengl_OGLSurfaceData_initTexture; + Java_sun_java2d_opengl_OGLSurfaceData_initFBObject; + Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer; + Java_sun_java2d_opengl_OGLSurfaceData_getTextureID; + Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget; + Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList; + Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo; + Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig; + Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities; + Java_sun_java2d_opengl_GLXSurfaceData_initOps; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName; - awt_display; - awt_Lock; - awt_Unlock; - awt_GetDrawingSurface; - awt_FreeDrawingSurface; - awt_GetComponent; + awt_display; + awt_Lock; + awt_Unlock; + awt_GetDrawingSurface; + awt_FreeDrawingSurface; + awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; - X11SurfaceData_GetOps; - getDefaultConfig; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_font_SunFontManager_populateFontFileNameMap; + X11SurfaceData_GetOps; + getDefaultConfig; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_font_SunFontManager_populateFontFileNameMap; - # CDE private entry point - Java_sun_awt_motif_XsessionWMcommand; - Java_sun_awt_motif_XsessionWMcommand_New; + # CDE private entry point + Java_sun_awt_motif_XsessionWMcommand; + Java_sun_awt_motif_XsessionWMcommand_New; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontAscent; - AWTFontDescent; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontAscent; + AWTFontDescent; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers b/jdk/make/mapfiles/libawt/mapfile-vers index 4624977e75c..9d8a34d3f37 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt/mapfile-vers @@ -27,163 +27,163 @@ # These are the libawt exports, mapfile-mawt-vers contains the libmawt exports. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_java_awt_CheckboxMenuItem_initIDs; - Java_java_awt_Color_initIDs; - Java_java_awt_FontMetrics_initIDs; - Java_java_awt_image_BufferedImage_initIDs; - Java_sun_awt_image_DataBufferNative_getElem; - Java_sun_awt_image_DataBufferNative_setElem; - Java_java_awt_image_ColorModel_initIDs; - Java_java_awt_image_IndexColorModel_initIDs; - Java_java_awt_image_Kernel_initIDs; - Java_java_awt_image_Raster_initIDs; - Java_java_awt_image_SampleModel_initIDs; - Java_java_awt_Label_initIDs; - Java_java_awt_MenuBar_initIDs; - Java_java_awt_ScrollPaneAdjustable_initIDs; - Java_java_awt_Toolkit_initIDs; - Java_sun_awt_DebugSettings_setCTracingOn__Z; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; - Java_sun_awt_image_ByteComponentRaster_initIDs; - Java_sun_awt_image_GifImageDecoder_initIDs; - Java_sun_awt_image_GifImageDecoder_parseImage; - Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setDiffICM; - Java_sun_awt_image_ImageRepresentation_setICMpixels; - Java_sun_awt_image_ImagingLib_convolveBI; - Java_sun_awt_image_ImagingLib_convolveRaster; - Java_sun_awt_image_ImagingLib_init; - Java_sun_awt_image_ImagingLib_transformBI; - Java_sun_awt_image_ImagingLib_transformRaster; - Java_sun_awt_image_IntegerComponentRaster_initIDs; - Java_sun_awt_image_ShortComponentRaster_initIDs; - Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile; - Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; - Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; - Java_sun_java2d_pipe_SpanClipRenderer_fillTile; - Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; - Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; - Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; - Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_closePath; - Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; - Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; - Java_sun_java2d_pipe_ShapeSpanIterator_dispose; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; - Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; - Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; - Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; - Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; - Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; - Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; - Java_sun_java2d_pipe_ShapeSpanIterator_setRule; - Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_CheckboxMenuItem_initIDs; + Java_java_awt_Color_initIDs; + Java_java_awt_FontMetrics_initIDs; + Java_java_awt_image_BufferedImage_initIDs; + Java_sun_awt_image_DataBufferNative_getElem; + Java_sun_awt_image_DataBufferNative_setElem; + Java_java_awt_image_ColorModel_initIDs; + Java_java_awt_image_IndexColorModel_initIDs; + Java_java_awt_image_Kernel_initIDs; + Java_java_awt_image_Raster_initIDs; + Java_java_awt_image_SampleModel_initIDs; + Java_java_awt_Label_initIDs; + Java_java_awt_MenuBar_initIDs; + Java_java_awt_ScrollPaneAdjustable_initIDs; + Java_java_awt_Toolkit_initIDs; + Java_sun_awt_DebugSettings_setCTracingOn__Z; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; + Java_sun_awt_image_ByteComponentRaster_initIDs; + Java_sun_awt_image_GifImageDecoder_initIDs; + Java_sun_awt_image_GifImageDecoder_parseImage; + Java_sun_awt_image_ImageRepresentation_initIDs; + Java_sun_awt_image_ImageRepresentation_setDiffICM; + Java_sun_awt_image_ImageRepresentation_setICMpixels; + Java_sun_awt_image_ImagingLib_convolveBI; + Java_sun_awt_image_ImagingLib_convolveRaster; + Java_sun_awt_image_ImagingLib_init; + Java_sun_awt_image_ImagingLib_transformBI; + Java_sun_awt_image_ImagingLib_transformRaster; + Java_sun_awt_image_IntegerComponentRaster_initIDs; + Java_sun_awt_image_ShortComponentRaster_initIDs; + Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile; + Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; + Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; + Java_sun_java2d_pipe_SpanClipRenderer_fillTile; + Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; + Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; + Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; + Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_closePath; + Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; + Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; + Java_sun_java2d_pipe_ShapeSpanIterator_dispose; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; + Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; + Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; + Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; + Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; + Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; + Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; + Java_sun_java2d_pipe_ShapeSpanIterator_setRule; + Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; - Java_java_awt_Choice_initIDs; - Java_java_awt_Dimension_initIDs; - Java_java_awt_event_MouseEvent_initIDs; - Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; - Java_java_awt_Rectangle_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; - Java_sun_awt_image_BytePackedRaster_initIDs; - Java_sun_awt_image_ImagingLib_lookupByteBI; - Java_sun_awt_image_ImagingLib_lookupByteRaster; - Java_sun_java2d_SurfaceData_initIDs; - Java_sun_java2d_SurfaceData_isOpaqueGray; - Java_sun_java2d_Disposer_initIDs; - Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; - Java_sun_java2d_loops_BlitBg_BlitBg; - Java_sun_java2d_loops_Blit_Blit; - Java_sun_java2d_loops_ScaledBlit_Scale; - Java_sun_java2d_loops_DrawLine_DrawLine; - Java_sun_java2d_loops_DrawPolygons_DrawPolygons; - Java_sun_java2d_loops_DrawPath_DrawPath; - Java_sun_java2d_loops_FillPath_FillPath; + Java_java_awt_Choice_initIDs; + Java_java_awt_Dimension_initIDs; + Java_java_awt_event_MouseEvent_initIDs; + Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; + Java_java_awt_Rectangle_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initRaster; + Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; + Java_sun_awt_image_BytePackedRaster_initIDs; + Java_sun_awt_image_ImagingLib_lookupByteBI; + Java_sun_awt_image_ImagingLib_lookupByteRaster; + Java_sun_java2d_SurfaceData_initIDs; + Java_sun_java2d_SurfaceData_isOpaqueGray; + Java_sun_java2d_Disposer_initIDs; + Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; + Java_sun_java2d_loops_BlitBg_BlitBg; + Java_sun_java2d_loops_Blit_Blit; + Java_sun_java2d_loops_ScaledBlit_Scale; + Java_sun_java2d_loops_DrawLine_DrawLine; + Java_sun_java2d_loops_DrawPolygons_DrawPolygons; + Java_sun_java2d_loops_DrawPath_DrawPath; + Java_sun_java2d_loops_FillPath_FillPath; - Java_sun_java2d_loops_DrawRect_DrawRect; - Java_sun_java2d_loops_FillRect_FillRect; - Java_sun_java2d_loops_FillSpans_FillSpans; - Java_sun_java2d_loops_FillParallelogram_FillParallelogram; - Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; - Java_sun_java2d_loops_MaskBlit_MaskBlit; - Java_sun_java2d_loops_MaskFill_MaskFill; - Java_sun_java2d_loops_MaskFill_FillAAPgram; - Java_sun_java2d_loops_MaskFill_DrawAAPgram; - Java_sun_java2d_loops_TransformHelper_Transform; - Java_sun_java2d_pipe_Region_initIDs; - Java_sun_java2d_pipe_SpanClipRenderer_initIDs; - sun_awt_image_GifImageDecoder_initIDs; + Java_sun_java2d_loops_DrawRect_DrawRect; + Java_sun_java2d_loops_FillRect_FillRect; + Java_sun_java2d_loops_FillSpans_FillSpans; + Java_sun_java2d_loops_FillParallelogram_FillParallelogram; + Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; + Java_sun_java2d_loops_MaskBlit_MaskBlit; + Java_sun_java2d_loops_MaskFill_MaskFill; + Java_sun_java2d_loops_MaskFill_FillAAPgram; + Java_sun_java2d_loops_MaskFill_DrawAAPgram; + Java_sun_java2d_loops_TransformHelper_Transform; + Java_sun_java2d_pipe_Region_initIDs; + Java_sun_java2d_pipe_SpanClipRenderer_initIDs; + sun_awt_image_GifImageDecoder_initIDs; - # libmawt entry points - SurfaceData_InitOps; - SurfaceData_ThrowInvalidPipeException; - SurfaceData_IntersectBlitBounds; - SurfaceData_IntersectBoundsXYXY; - Region_GetBounds; - Region_GetInfo; - Region_StartIteration; - Region_CountIterationRects; - Region_NextIteration; - Region_EndIteration; - RegionToYXBandedRectangles; - GrPrim_CompGetXorInfo; - GrPrim_CompGetAlphaInfo; - J2dTraceImpl; - J2dTraceInit; - img_makePalette; - initInverseGrayLut; - make_dither_arrays; - make_uns_ordered_dither_array; + # libmawt entry points + SurfaceData_InitOps; + SurfaceData_ThrowInvalidPipeException; + SurfaceData_IntersectBlitBounds; + SurfaceData_IntersectBoundsXYXY; + Region_GetBounds; + Region_GetInfo; + Region_StartIteration; + Region_CountIterationRects; + Region_NextIteration; + Region_EndIteration; + RegionToYXBandedRectangles; + GrPrim_CompGetXorInfo; + GrPrim_CompGetAlphaInfo; + J2dTraceImpl; + J2dTraceInit; + img_makePalette; + initInverseGrayLut; + make_dither_arrays; + make_uns_ordered_dither_array; - # variables exported to libmawt - std_img_oda_red; - std_img_oda_blue; - std_img_oda_green; - std_odas_computed; - g_CMpDataID; - colorValueID; - mul8table; - div8table; - jvm; + # variables exported to libmawt + std_img_oda_red; + std_img_oda_blue; + std_img_oda_green; + std_odas_computed; + g_CMpDataID; + colorValueID; + mul8table; + div8table; + jvm; - # ProcessPath entry points and data - doDrawPath; - doFillPath; - path2DNumTypesID; - path2DTypesID; - path2DWindingRuleID; - path2DFloatCoordsID; - sg2dStrokeHintID; - sunHints_INTVAL_STROKE_PURE; + # ProcessPath entry points and data + doDrawPath; + doFillPath; + path2DNumTypesID; + path2DTypesID; + path2DWindingRuleID; + path2DFloatCoordsID; + sg2dStrokeHintID; + sunHints_INTVAL_STROKE_PURE; - # CDE private entry points - # These are in awt_LoadLibrary.c and falls through to libmawt. - # Evidently CDE needs this for backward compatability. - Java_sun_awt_motif_XsessionWMcommand; - Java_sun_awt_motif_XsessionWMcommand_New; + # CDE private entry points + # These are in awt_LoadLibrary.c and falls through to libmawt. + # Evidently CDE needs this for backward compatability. + Java_sun_awt_motif_XsessionWMcommand; + Java_sun_awt_motif_XsessionWMcommand_New; - # libfontmanager entry points - AWTIsHeadless; - GrPrim_Sg2dGetCompInfo; - GrPrim_Sg2dGetClip; - GetNativePrim; - SurfaceData_IntersectBounds; - SurfaceData_GetOps; - Disposer_AddRecord; - GrPrim_Sg2dGetEaRGB; - GrPrim_Sg2dGetPixel; - GrPrim_Sg2dGetLCDTextContrast; + # libfontmanager entry points + AWTIsHeadless; + GrPrim_Sg2dGetCompInfo; + GrPrim_Sg2dGetClip; + GetNativePrim; + SurfaceData_IntersectBounds; + SurfaceData_GetOps; + Disposer_AddRecord; + GrPrim_Sg2dGetEaRGB; + GrPrim_Sg2dGetPixel; + GrPrim_Sg2dGetLCDTextContrast; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers-linux b/jdk/make/mapfiles/libawt/mapfile-vers-linux index 5645cbd18d9..90e12f075b1 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers-linux +++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2016, 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 @@ -27,277 +27,278 @@ # Linux port does not use mawt, all public symbols are in libawt.so SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_java_awt_CheckboxMenuItem_initIDs; - Java_java_awt_Color_initIDs; - Java_java_awt_FontMetrics_initIDs; - Java_java_awt_image_BufferedImage_initIDs; - Java_sun_awt_image_DataBufferNative_getElem; - Java_sun_awt_image_DataBufferNative_setElem; - Java_java_awt_image_ColorModel_initIDs; - Java_java_awt_image_IndexColorModel_initIDs; - Java_java_awt_image_Kernel_initIDs; - Java_java_awt_image_Raster_initIDs; - Java_java_awt_image_SampleModel_initIDs; - Java_java_awt_Label_initIDs; - Java_java_awt_MenuBar_initIDs; - Java_java_awt_ScrollPaneAdjustable_initIDs; - Java_java_awt_Toolkit_initIDs; - Java_java_awt_TrayIcon_initIDs; - Java_sun_awt_DebugSettings_setCTracingOn__Z; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; - Java_sun_awt_image_ByteComponentRaster_initIDs; - Java_sun_awt_image_GifImageDecoder_initIDs; - Java_sun_awt_image_GifImageDecoder_parseImage; - Java_sun_awt_image_Image_initIDs; - Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setDiffICM; - Java_sun_awt_image_ImageRepresentation_setICMpixels; - Java_sun_awt_image_ImagingLib_convolveBI; - Java_sun_awt_image_ImagingLib_convolveRaster; - Java_sun_awt_image_ImagingLib_init; - Java_sun_awt_image_ImagingLib_transformBI; - Java_sun_awt_image_ImagingLib_transformRaster; - Java_sun_awt_image_IntegerComponentRaster_initIDs; - Java_sun_awt_image_ShortComponentRaster_initIDs; - Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; - Java_sun_java2d_pipe_SpanClipRenderer_fillTile; - Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; - Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; - Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; - Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_closePath; - Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; - Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; - Java_sun_java2d_pipe_ShapeSpanIterator_dispose; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; - Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; - Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; - Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; - Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; - Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; - Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; - Java_sun_java2d_pipe_ShapeSpanIterator_setRule; - Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_CheckboxMenuItem_initIDs; + Java_java_awt_Color_initIDs; + Java_java_awt_FontMetrics_initIDs; + Java_java_awt_image_BufferedImage_initIDs; + Java_sun_awt_image_DataBufferNative_getElem; + Java_sun_awt_image_DataBufferNative_setElem; + Java_java_awt_image_ColorModel_initIDs; + Java_java_awt_image_IndexColorModel_initIDs; + Java_java_awt_image_Kernel_initIDs; + Java_java_awt_image_Raster_initIDs; + Java_java_awt_image_SampleModel_initIDs; + Java_java_awt_Label_initIDs; + Java_java_awt_MenuBar_initIDs; + Java_java_awt_ScrollPaneAdjustable_initIDs; + Java_java_awt_Toolkit_initIDs; + Java_java_awt_TrayIcon_initIDs; + Java_sun_awt_DebugSettings_setCTracingOn__Z; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; + Java_sun_awt_image_ByteComponentRaster_initIDs; + Java_sun_awt_image_GifImageDecoder_initIDs; + Java_sun_awt_image_GifImageDecoder_parseImage; + Java_sun_awt_image_Image_initIDs; + Java_sun_awt_image_ImageRepresentation_initIDs; + Java_sun_awt_image_ImageRepresentation_setDiffICM; + Java_sun_awt_image_ImageRepresentation_setICMpixels; + Java_sun_awt_image_ImagingLib_convolveBI; + Java_sun_awt_image_ImagingLib_convolveRaster; + Java_sun_awt_image_ImagingLib_init; + Java_sun_awt_image_ImagingLib_transformBI; + Java_sun_awt_image_ImagingLib_transformRaster; + Java_sun_awt_image_IntegerComponentRaster_initIDs; + Java_sun_awt_image_ShortComponentRaster_initIDs; + Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; + Java_sun_java2d_pipe_SpanClipRenderer_fillTile; + Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; + Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; + Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; + Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_closePath; + Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; + Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; + Java_sun_java2d_pipe_ShapeSpanIterator_dispose; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; + Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; + Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; + Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; + Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; + Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; + Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; + Java_sun_java2d_pipe_ShapeSpanIterator_setRule; + Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; - Java_java_awt_Choice_initIDs; - Java_java_awt_Dimension_initIDs; - Java_java_awt_event_MouseEvent_initIDs; - Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; - Java_java_awt_Rectangle_initIDs; - Java_sun_awt_image_BufImgSurfaceData_getSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; - Java_sun_awt_image_BytePackedRaster_initIDs; - Java_sun_awt_image_ImagingLib_lookupByteBI; - Java_sun_awt_image_ImagingLib_lookupByteRaster; - Java_sun_java2d_SurfaceData_initIDs; - Java_sun_java2d_SurfaceData_isOpaqueGray; - Java_sun_java2d_Disposer_initIDs; - Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; - Java_sun_java2d_loops_BlitBg_BlitBg; - Java_sun_java2d_loops_Blit_Blit; - Java_sun_java2d_loops_ScaledBlit_Scale; - Java_sun_java2d_loops_DrawLine_DrawLine; - Java_sun_java2d_loops_DrawPolygons_DrawPolygons; - Java_sun_java2d_loops_DrawRect_DrawRect; - Java_sun_java2d_loops_FillRect_FillRect; - Java_sun_java2d_loops_FillSpans_FillSpans; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; - Java_sun_java2d_loops_MaskBlit_MaskBlit; - Java_sun_java2d_loops_MaskFill_MaskFill; - Java_sun_java2d_loops_MaskFill_FillAAPgram; - Java_sun_java2d_loops_MaskFill_DrawAAPgram; - Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; - Java_sun_java2d_pipe_SpanClipRenderer_initIDs; - sun_awt_image_GifImageDecoder_initIDs; + Java_java_awt_Choice_initIDs; + Java_java_awt_Dimension_initIDs; + Java_java_awt_event_MouseEvent_initIDs; + Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; + Java_java_awt_Rectangle_initIDs; + Java_sun_awt_image_BufImgSurfaceData_getSurfaceData; + Java_sun_awt_image_BufImgSurfaceData_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initRaster; + Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; + Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; + Java_sun_awt_image_BytePackedRaster_initIDs; + Java_sun_awt_image_ImagingLib_lookupByteBI; + Java_sun_awt_image_ImagingLib_lookupByteRaster; + Java_sun_java2d_SurfaceData_initIDs; + Java_sun_java2d_SurfaceData_isOpaqueGray; + Java_sun_java2d_Disposer_initIDs; + Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; + Java_sun_java2d_loops_BlitBg_BlitBg; + Java_sun_java2d_loops_Blit_Blit; + Java_sun_java2d_loops_ScaledBlit_Scale; + Java_sun_java2d_loops_DrawLine_DrawLine; + Java_sun_java2d_loops_DrawPolygons_DrawPolygons; + Java_sun_java2d_loops_DrawRect_DrawRect; + Java_sun_java2d_loops_FillRect_FillRect; + Java_sun_java2d_loops_FillSpans_FillSpans; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; + Java_sun_java2d_loops_MaskBlit_MaskBlit; + Java_sun_java2d_loops_MaskFill_MaskFill; + Java_sun_java2d_loops_MaskFill_FillAAPgram; + Java_sun_java2d_loops_MaskFill_DrawAAPgram; + Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; + Java_sun_java2d_pipe_SpanClipRenderer_initIDs; + sun_awt_image_GifImageDecoder_initIDs; - # libmawt entry points - SurfaceData_InitOps; - SurfaceData_ThrowInvalidPipeException; - Region_GetBounds; - Region_GetInfo; - Region_StartIteration; - Region_CountIterationRects; - Region_NextIteration; - Region_EndIteration; - GrPrim_CompGetXorInfo; - GrPrim_CompGetAlphaInfo; - img_makePalette; - initInverseGrayLut; - make_dither_arrays; - make_uns_ordered_dither_array; + # libmawt entry points + SurfaceData_InitOps; + SurfaceData_ThrowInvalidPipeException; + Region_GetBounds; + Region_GetInfo; + Region_StartIteration; + Region_CountIterationRects; + Region_NextIteration; + Region_EndIteration; + GrPrim_CompGetXorInfo; + GrPrim_CompGetAlphaInfo; + img_makePalette; + initInverseGrayLut; + make_dither_arrays; + make_uns_ordered_dither_array; - # variables exported to libmawt - std_img_oda_red; - std_img_oda_blue; - std_img_oda_green; - std_odas_computed; - g_CMpDataID; - colorValueID; - jvm; + # variables exported to libmawt + std_img_oda_red; + std_img_oda_blue; + std_img_oda_green; + std_odas_computed; + g_CMpDataID; + colorValueID; + jvm; - # CDE private entry point - # This is in awt_LoadLibrary.c and falls through to libmawt. - # Evidently CDE needs this for backward compatability. - Java_sun_awt_motif_XsessionWMcommand; + # CDE private entry point + # This is in awt_LoadLibrary.c and falls through to libmawt. + # Evidently CDE needs this for backward compatability. + Java_sun_awt_motif_XsessionWMcommand; - # libfontmanager entry points - AWTIsHeadless; - GrPrim_Sg2dGetCompInfo; - GrPrim_Sg2dGetClip; - GetNativePrim; - SurfaceData_IntersectBounds; - SurfaceData_GetOps; - Disposer_AddRecord; - GrPrim_Sg2dGetEaRGB; - GrPrim_Sg2dGetPixel; - GrPrim_Sg2dGetLCDTextContrast; + # libfontmanager entry points + AWTIsHeadless; + GrPrim_Sg2dGetCompInfo; + GrPrim_Sg2dGetClip; + GetNativePrim; + SurfaceData_IntersectBounds; + SurfaceData_GetOps; + Disposer_AddRecord; + GrPrim_Sg2dGetEaRGB; + GrPrim_Sg2dGetPixel; + GrPrim_Sg2dGetLCDTextContrast; - Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; - Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; - Java_java_awt_AWTEvent_nativeSetSource; - Java_java_awt_Checkbox_initIDs; - Java_java_awt_Component_initIDs; - Java_java_awt_Dialog_initIDs; - Java_java_awt_Font_initIDs; - Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; - Java_java_awt_KeyboardFocusManager_initIDs; - Java_java_awt_Menu_initIDs; - Java_java_awt_MenuComponent_initIDs; - Java_java_awt_MenuItem_initIDs; - Java_java_awt_Scrollbar_initIDs; - Java_java_awt_ScrollPane_initIDs; - Java_java_awt_TextArea_initIDs; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_X11InputMethod_disposeXIC; - Java_sun_awt_X11InputMethod_isCompositionEnabledNative; - Java_sun_awt_X11InputMethod_resetXIC; - Java_sun_awt_X11InputMethod_setCompositionEnabledNative; - Java_sun_awt_X11InputMethod_turnoffStatusWindow; - Java_sun_awt_SunToolkit_closeSplashScreen; - Java_sun_awt_PlatformFont_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_dispose; - Java_sun_awt_X11GraphicsConfig_pGetBounds; - Java_sun_awt_X11GraphicsConfig_getNumColors; - Java_sun_awt_X11GraphicsConfig_getXResolution; - Java_sun_awt_X11GraphicsConfig_getYResolution; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; - Java_sun_awt_X11GraphicsDevice_isDBESupported; - Java_sun_awt_X11GraphicsDevice_getDisplay; - Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; - Java_sun_awt_X11GraphicsDevice_getNumConfigs; - Java_sun_awt_X11GraphicsDevice_initIDs; - Java_sun_awt_X11GraphicsDevice_initXrandrExtension; - Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; - Java_sun_awt_X11GraphicsDevice_enumDisplayModes; - Java_sun_awt_X11GraphicsDevice_configDisplayMode; - Java_sun_awt_X11GraphicsDevice_resetNativeData; - Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor; - Java_sun_awt_X11GraphicsEnvironment_checkShmExt; - Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; - Java_sun_awt_X11GraphicsEnvironment_getDisplayString; - Java_sun_awt_X11GraphicsEnvironment_getNumScreens; - Java_sun_awt_X11GraphicsEnvironment_initDisplay; - Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; - Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; - Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; + Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; + Java_java_awt_AWTEvent_nativeSetSource; + Java_java_awt_Checkbox_initIDs; + Java_java_awt_Component_initIDs; + Java_java_awt_Dialog_initIDs; + Java_java_awt_Font_initIDs; + Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; + Java_java_awt_KeyboardFocusManager_initIDs; + Java_java_awt_Menu_initIDs; + Java_java_awt_MenuComponent_initIDs; + Java_java_awt_MenuItem_initIDs; + Java_java_awt_Scrollbar_initIDs; + Java_java_awt_ScrollPane_initIDs; + Java_java_awt_TextArea_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_X11InputMethod_disposeXIC; + Java_sun_awt_X11InputMethod_isCompositionEnabledNative; + Java_sun_awt_X11InputMethod_resetXIC; + Java_sun_awt_X11InputMethod_setCompositionEnabledNative; + Java_sun_awt_X11InputMethod_turnoffStatusWindow; + Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_dispose; + Java_sun_awt_X11GraphicsConfig_pGetBounds; + Java_sun_awt_X11GraphicsConfig_getNumColors; + Java_sun_awt_X11GraphicsConfig_getXResolution; + Java_sun_awt_X11GraphicsConfig_getYResolution; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsDevice_isDBESupported; + Java_sun_awt_X11GraphicsDevice_getDisplay; + Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; + Java_sun_awt_X11GraphicsDevice_getNumConfigs; + Java_sun_awt_X11GraphicsDevice_initIDs; + Java_sun_awt_X11GraphicsDevice_initXrandrExtension; + Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; + Java_sun_awt_X11GraphicsDevice_enumDisplayModes; + Java_sun_awt_X11GraphicsDevice_configDisplayMode; + Java_sun_awt_X11GraphicsDevice_resetNativeData; + Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor; + Java_sun_awt_X11GraphicsEnvironment_checkShmExt; + Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; + Java_sun_awt_X11GraphicsEnvironment_getDisplayString; + Java_sun_awt_X11GraphicsEnvironment_getNumScreens; + Java_sun_awt_X11GraphicsEnvironment_initDisplay; + Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; + Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; + Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_java_awt_AWTEvent_initIDs; + Java_java_awt_Button_initIDs; + Java_java_awt_Container_initIDs; + Java_java_awt_Cursor_finalizeImpl; + Java_java_awt_Cursor_initIDs; + Java_java_awt_Event_initIDs; + Java_java_awt_event_InputEvent_initIDs; + Java_java_awt_event_KeyEvent_initIDs; + Java_java_awt_FileDialog_initIDs; + Java_java_awt_Frame_initIDs; + Java_java_awt_Insets_initIDs; + Java_java_awt_TextField_initIDs; + Java_java_awt_Window_initIDs; + Java_sun_awt_motif_X11OffScreenImage_updateBitmask; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_initIDs; + Java_sun_awt_X11GraphicsConfig_makeColorModel; + Java_sun_awt_X11GraphicsDevice_getConfigVisualId; + Java_sun_awt_X11PMBlitLoops_Blit; + Java_sun_awt_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_awt_X11Renderer_devFillSpans; + Java_sun_awt_X11Renderer_doDrawArc; + Java_sun_awt_X11Renderer_doDrawLine; + Java_sun_awt_X11Renderer_doDrawOval; + Java_sun_awt_X11Renderer_doDrawPoly; + Java_sun_awt_X11Renderer_doDrawRect; + Java_sun_awt_X11Renderer_doDrawRoundRect; + Java_sun_awt_X11Renderer_doFillArc; + Java_sun_awt_X11Renderer_doFillOval; + Java_sun_awt_X11Renderer_doFillPoly; + Java_sun_awt_X11Renderer_doFillRect; + Java_sun_awt_X11Renderer_doFillRoundRect; + Java_sun_awt_X11Renderer_devCopyArea; + Java_sun_awt_X11SurfaceData_initIDs; + Java_sun_awt_X11SurfaceData_initOps; + Java_sun_awt_X11SurfaceData_initSurface; + Java_sun_awt_X11SurfaceData_isDgaAvailable; + Java_sun_awt_X11SurfaceData_setInvalid; + Java_sun_awt_X11SurfaceData_flushNativeSurface; + awt_display; + awt_lock; + awt_Lock; + awt_Unlock; + awt_GetDrawingSurface; + awt_FreeDrawingSurface; + awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; + getDefaultConfig; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_font_SunFontManager_populateFontFileNameMap; - Java_java_awt_AWTEvent_initIDs; - Java_java_awt_Button_initIDs; - Java_java_awt_Container_initIDs; - Java_java_awt_Cursor_finalizeImpl; - Java_java_awt_Cursor_initIDs; - Java_java_awt_Event_initIDs; - Java_java_awt_event_InputEvent_initIDs; - Java_java_awt_event_KeyEvent_initIDs; - Java_java_awt_FileDialog_initIDs; - Java_java_awt_Frame_initIDs; - Java_java_awt_Insets_initIDs; - Java_java_awt_TextField_initIDs; - Java_java_awt_Window_initIDs; - Java_sun_awt_motif_X11OffScreenImage_updateBitmask; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_initIDs; - Java_sun_awt_X11GraphicsConfig_makeColorModel; - Java_sun_awt_X11GraphicsDevice_getConfigVisualId; - Java_sun_awt_X11PMBlitLoops_Blit; - Java_sun_awt_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_awt_X11Renderer_devFillSpans; - Java_sun_awt_X11Renderer_doDrawArc; - Java_sun_awt_X11Renderer_doDrawLine; - Java_sun_awt_X11Renderer_doDrawOval; - Java_sun_awt_X11Renderer_doDrawPoly; - Java_sun_awt_X11Renderer_doDrawRect; - Java_sun_awt_X11Renderer_doDrawRoundRect; - Java_sun_awt_X11Renderer_doFillArc; - Java_sun_awt_X11Renderer_doFillOval; - Java_sun_awt_X11Renderer_doFillPoly; - Java_sun_awt_X11Renderer_doFillRect; - Java_sun_awt_X11Renderer_doFillRoundRect; - Java_sun_awt_X11Renderer_devCopyArea; - Java_sun_awt_X11SurfaceData_initIDs; - Java_sun_awt_X11SurfaceData_initOps; - Java_sun_awt_X11SurfaceData_initSurface; - Java_sun_awt_X11SurfaceData_isDgaAvailable; - Java_sun_awt_X11SurfaceData_setInvalid; - Java_sun_awt_X11SurfaceData_flushNativeSurface; - awt_display; - awt_lock; - awt_Lock; - awt_Unlock; - awt_GetDrawingSurface; - awt_FreeDrawingSurface; - awt_GetComponent; + # CDE private entry point + Java_sun_awt_motif_XsessionWMcommand; - X11SurfaceData_GetOps; - getDefaultConfig; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_font_SunFontManager_populateFontFileNameMap; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - # CDE private entry point - Java_sun_awt_motif_XsessionWMcommand; - - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt_headless/mapfile-vers b/jdk/make/mapfiles/libawt_headless/mapfile-vers index ac5101042a2..4ec723ffe0a 100644 --- a/jdk/make/mapfiles/libawt_headless/mapfile-vers +++ b/jdk/make/mapfiles/libawt_headless/mapfile-vers @@ -26,85 +26,84 @@ # Define public interface. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; - Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; - Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; - Java_sun_java2d_x11_X11Renderer_devCopyArea; - Java_sun_java2d_x11_X11SurfaceData_initIDs; - Java_sun_java2d_x11_X11SurfaceData_initSurface; - Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; - Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; - Java_sun_java2d_x11_X11SurfaceData_XSetForeground; + Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; + Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XDoPath; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_devCopyArea; + Java_sun_java2d_x11_X11SurfaceData_initIDs; + Java_sun_java2d_x11_X11SurfaceData_initSurface; + Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; + Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; + Java_sun_java2d_x11_X11SurfaceData_XSetForeground; - Java_sun_java2d_x11_XSurfaceData_initOps; - Java_sun_java2d_x11_XSurfaceData_XCreateGC; - Java_sun_java2d_x11_XSurfaceData_XResetClip; - Java_sun_java2d_x11_XSurfaceData_XSetClip; - Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; - Java_sun_java2d_x11_XSurfaceData_setInvalid; - Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; + Java_sun_java2d_x11_XSurfaceData_initOps; + Java_sun_java2d_x11_XSurfaceData_XCreateGC; + Java_sun_java2d_x11_XSurfaceData_XResetClip; + Java_sun_java2d_x11_XSurfaceData_XSetClip; + Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_setInvalid; + Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; - X11SurfaceData_GetOps; - Java_java_awt_Font_initIDs; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_FcFontManager_getFontPathNative; + X11SurfaceData_GetOps; + Java_java_awt_Font_initIDs; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_font_FontConfigManager_getFontConfigVersion; + Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_PlatformFont_initIDs; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontAscent; - AWTFontDescent; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontAscent; + AWTFontDescent; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 461c1ba9f48..b56b47b8ce8 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -26,7 +26,7 @@ # Define public interface. SUNWprivate_1.1 { - global: + global: JNI_OnLoad; Java_sun_awt_X11_XlibWrapper_copyIntArray; Java_sun_awt_X11_XlibWrapper_copyLongArray; @@ -58,8 +58,8 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XSetLocaleModifiers; Java_sun_awt_X11_XlibWrapper_XPeekEvent; Java_sun_awt_X11_XlibWrapper_DefaultScreen; - Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay; - Java_sun_awt_X11_XlibWrapper_DoesBackingStore; + Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay; + Java_sun_awt_X11_XlibWrapper_DoesBackingStore; Java_sun_awt_X11_XlibWrapper_RootWindow; Java_sun_awt_X11_XlibWrapper_DisplayHeight; Java_sun_awt_X11_XlibWrapper_DisplayWidthMM; @@ -172,7 +172,7 @@ SUNWprivate_1.1 { Java_java_awt_Scrollbar_initIDs; Java_java_awt_Window_initIDs; Java_java_awt_Frame_initIDs; - Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_SunToolkit_closeSplashScreen; Java_sun_awt_UNIXToolkit_check_1gtk; Java_sun_awt_UNIXToolkit_load_1gtk; Java_sun_awt_UNIXToolkit_unload_1gtk; @@ -196,17 +196,16 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initGLX; - Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_sun_awt_X11GraphicsEnvironment_initXRender; Java_sun_awt_X11GraphicsEnvironment_checkShmExt; Java_sun_awt_X11GraphicsEnvironment_getNumScreens; Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; Java_sun_awt_X11GraphicsEnvironment_getDisplayString; -# Java_sun_awt_X11GraphicsEnvironment_getNativeFonts; Java_sun_awt_X11GraphicsDevice_initIDs; Java_sun_awt_X11GraphicsDevice_getConfigVisualId; Java_sun_awt_X11GraphicsDevice_getConfigDepth; @@ -231,16 +230,16 @@ SUNWprivate_1.1 { Java_sun_awt_X11GraphicsConfig_makeColorModel; Java_sun_awt_X11GraphicsConfig_pGetBounds; Java_sun_awt_X11GraphicsConfig_createBackBuffer; - Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; - Java_sun_awt_X11GraphicsConfig_swapBuffers; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; + Java_sun_awt_X11GraphicsConfig_swapBuffers; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout; Java_java_awt_Insets_initIDs; Java_java_awt_KeyboardFocusManager_initIDs; Java_java_awt_Font_initIDs; # libfontmanager entry points AWTIsHeadless; - AWTCountFonts; + AWTCountFonts; AWTLoadFont; AWTFreeFont; AWTFontAscent; @@ -303,7 +302,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XGetIconSizes; Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym; Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode; - Java_sun_awt_X11_XlibWrapper_XQueryKeymap; + Java_sun_awt_X11_XlibWrapper_XQueryKeymap; Java_sun_awt_X11_XlibWrapper_XkbGetEffectiveGroup; Java_sun_awt_X11_XlibWrapper_XkbSelectEvents; Java_sun_awt_X11_XlibWrapper_XkbSelectEventDetails; @@ -350,23 +349,23 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; Java_sun_java2d_x11_X11Renderer_devCopyArea; Java_sun_java2d_x11_X11SurfaceData_initIDs; Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; - Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; Java_sun_java2d_x11_X11SurfaceData_initSurface; Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; @@ -377,40 +376,40 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_XSurfaceData_XResetClip; Java_sun_java2d_x11_XSurfaceData_XSetClip; Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; Java_sun_java2d_x11_XSurfaceData_setInvalid; Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; Java_sun_java2d_xr_XRSurfaceData_initXRPicture; Java_sun_java2d_xr_XRSurfaceData_initIDs; Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; - Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; - Java_sun_java2d_xr_XRBackendNative_initIDs; - Java_sun_java2d_xr_XRBackendNative_freeGC; - Java_sun_java2d_xr_XRBackendNative_createGC; - Java_sun_java2d_xr_XRBackendNative_createPixmap; - Java_sun_java2d_xr_XRBackendNative_createPictureNative; - Java_sun_java2d_xr_XRBackendNative_freePicture; - Java_sun_java2d_xr_XRBackendNative_freePixmap; - Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; - Java_sun_java2d_xr_XRBackendNative_setGCExposures; - Java_sun_java2d_xr_XRBackendNative_setGCForeground; - Java_sun_java2d_xr_XRBackendNative_copyArea; - Java_sun_java2d_xr_XRBackendNative_renderComposite; - Java_sun_java2d_xr_XRBackendNative_renderRectangle; - Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_setFilter; - Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; - Java_sun_java2d_xr_XRBackendNative_putMaskNative; - Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; - Java_sun_java2d_xr_XRBackendNative_setGCMode; - Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; + Java_sun_java2d_xr_XRBackendNative_initIDs; + Java_sun_java2d_xr_XRBackendNative_freeGC; + Java_sun_java2d_xr_XRBackendNative_createGC; + Java_sun_java2d_xr_XRBackendNative_createPixmap; + Java_sun_java2d_xr_XRBackendNative_createPictureNative; + Java_sun_java2d_xr_XRBackendNative_freePicture; + Java_sun_java2d_xr_XRBackendNative_freePixmap; + Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; + Java_sun_java2d_xr_XRBackendNative_setGCExposures; + Java_sun_java2d_xr_XRBackendNative_setGCForeground; + Java_sun_java2d_xr_XRBackendNative_copyArea; + Java_sun_java2d_xr_XRBackendNative_renderComposite; + Java_sun_java2d_xr_XRBackendNative_renderRectangle; + Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_setFilter; + Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; + Java_sun_java2d_xr_XRBackendNative_putMaskNative; + Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; + Java_sun_java2d_xr_XRBackendNative_setGCMode; + Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; @@ -444,25 +443,28 @@ SUNWprivate_1.1 { Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_awt_X11_GtkFileDialogPeer_setBounds; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; awt_GetDrawingSurface; awt_FreeDrawingSurface; awt_Unlock; awt_Lock; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; #XAWT entry point for CDE Java_sun_awt_motif_XsessionWMcommand; Java_sun_awt_motif_XsessionWMcommand_New; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libjawt/mapfile-vers b/jdk/make/mapfiles/libjawt/mapfile-vers index 1a79df0c34d..ee0ef4202cc 100644 --- a/jdk/make/mapfiles/libjawt/mapfile-vers +++ b/jdk/make/mapfiles/libjawt/mapfile-vers @@ -26,8 +26,8 @@ # Define library interface. SUNWprivate_1.1 { - global: - JAWT_GetAWT; - local: - *; + global: + JAWT_GetAWT; + local: + *; }; diff --git a/jdk/make/mapfiles/libjpeg/mapfile-vers b/jdk/make/mapfiles/libjpeg/mapfile-vers index 4534fa0944b..b82e7574598 100644 --- a/jdk/make/mapfiles/libjpeg/mapfile-vers +++ b/jdk/make/mapfiles/libjpeg/mapfile-vers @@ -26,30 +26,30 @@ # Define public interface. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_awt_image_JPEGImageDecoder_initIDs; - Java_sun_awt_image_JPEGImageDecoder_readImage; + Java_sun_awt_image_JPEGImageDecoder_initIDs; + Java_sun_awt_image_JPEGImageDecoder_readImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter; - local: - *; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter; + local: + *; }; diff --git a/jdk/make/mapfiles/libjsound/mapfile-vers b/jdk/make/mapfiles/libjsound/mapfile-vers index b8ebf0d8af3..4cd03a758b1 100644 --- a/jdk/make/mapfiles/libjsound/mapfile-vers +++ b/jdk/make/mapfiles/libjsound/mapfile-vers @@ -26,60 +26,60 @@ # Define library interface. SUNWprivate_1.1 { - global: - Java_com_sun_media_sound_DirectAudioDevice_nAvailable; - Java_com_sun_media_sound_DirectAudioDevice_nClose; - Java_com_sun_media_sound_DirectAudioDevice_nFlush; - Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; - Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; - Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; - Java_com_sun_media_sound_DirectAudioDevice_nOpen; - Java_com_sun_media_sound_DirectAudioDevice_nRead; - Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; - Java_com_sun_media_sound_DirectAudioDevice_nService; - Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nStart; - Java_com_sun_media_sound_DirectAudioDevice_nStop; - Java_com_sun_media_sound_DirectAudioDevice_nWrite; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; - Java_com_sun_media_sound_MidiInDevice_nClose; - Java_com_sun_media_sound_MidiInDevice_nGetMessages; - Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiInDevice_nOpen; - Java_com_sun_media_sound_MidiInDevice_nStart; - Java_com_sun_media_sound_MidiInDevice_nStop; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiOutDevice_nClose; - Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiOutDevice_nOpen; - Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; - Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; - Java_com_sun_media_sound_Platform_nGetExtraLibraries; - Java_com_sun_media_sound_Platform_nGetLibraryForFeature; - Java_com_sun_media_sound_Platform_nIsBigEndian; - Java_com_sun_media_sound_PortMixer_nClose; - Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlGetIntValue; - Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlSetIntValue; - Java_com_sun_media_sound_PortMixer_nGetControls; - Java_com_sun_media_sound_PortMixer_nGetPortCount; - Java_com_sun_media_sound_PortMixer_nGetPortName; - Java_com_sun_media_sound_PortMixer_nGetPortType; - Java_com_sun_media_sound_PortMixer_nOpen; - Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; - Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; - local: - *; + global: + Java_com_sun_media_sound_DirectAudioDevice_nAvailable; + Java_com_sun_media_sound_DirectAudioDevice_nClose; + Java_com_sun_media_sound_DirectAudioDevice_nFlush; + Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; + Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; + Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; + Java_com_sun_media_sound_DirectAudioDevice_nOpen; + Java_com_sun_media_sound_DirectAudioDevice_nRead; + Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; + Java_com_sun_media_sound_DirectAudioDevice_nService; + Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nStart; + Java_com_sun_media_sound_DirectAudioDevice_nStop; + Java_com_sun_media_sound_DirectAudioDevice_nWrite; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; + Java_com_sun_media_sound_MidiInDevice_nClose; + Java_com_sun_media_sound_MidiInDevice_nGetMessages; + Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiInDevice_nOpen; + Java_com_sun_media_sound_MidiInDevice_nStart; + Java_com_sun_media_sound_MidiInDevice_nStop; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiOutDevice_nClose; + Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiOutDevice_nOpen; + Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; + Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; + Java_com_sun_media_sound_Platform_nGetExtraLibraries; + Java_com_sun_media_sound_Platform_nGetLibraryForFeature; + Java_com_sun_media_sound_Platform_nIsBigEndian; + Java_com_sun_media_sound_PortMixer_nClose; + Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlGetIntValue; + Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlSetIntValue; + Java_com_sun_media_sound_PortMixer_nGetControls; + Java_com_sun_media_sound_PortMixer_nGetPortCount; + Java_com_sun_media_sound_PortMixer_nGetPortName; + Java_com_sun_media_sound_PortMixer_nGetPortType; + Java_com_sun_media_sound_PortMixer_nOpen; + Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; + Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; + local: + *; }; diff --git a/jdk/make/mapfiles/libjsoundalsa/mapfile-vers b/jdk/make/mapfiles/libjsoundalsa/mapfile-vers index 1b1c8f75be6..6228f8ad23e 100644 --- a/jdk/make/mapfiles/libjsoundalsa/mapfile-vers +++ b/jdk/make/mapfiles/libjsoundalsa/mapfile-vers @@ -26,57 +26,57 @@ # Define library interface. SUNWprivate_1.1 { - global: - Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; - Java_com_sun_media_sound_DirectAudioDevice_nAvailable; - Java_com_sun_media_sound_DirectAudioDevice_nClose; - Java_com_sun_media_sound_DirectAudioDevice_nFlush; - Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; - Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; - Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; - Java_com_sun_media_sound_DirectAudioDevice_nOpen; - Java_com_sun_media_sound_DirectAudioDevice_nRead; - Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; - Java_com_sun_media_sound_DirectAudioDevice_nService; - Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nStart; - Java_com_sun_media_sound_DirectAudioDevice_nStop; - Java_com_sun_media_sound_DirectAudioDevice_nWrite; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiInDevice_nClose; - Java_com_sun_media_sound_MidiInDevice_nGetMessages; - Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiInDevice_nOpen; - Java_com_sun_media_sound_MidiInDevice_nStart; - Java_com_sun_media_sound_MidiInDevice_nStop; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiOutDevice_nClose; - Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiOutDevice_nOpen; - Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; - Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; - Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; - Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; - Java_com_sun_media_sound_PortMixer_nClose; - Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlGetIntValue; - Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlSetIntValue; - Java_com_sun_media_sound_PortMixer_nGetControls; - Java_com_sun_media_sound_PortMixer_nGetPortCount; - Java_com_sun_media_sound_PortMixer_nGetPortName; - Java_com_sun_media_sound_PortMixer_nGetPortType; - Java_com_sun_media_sound_PortMixer_nOpen; - local: - *; + global: + Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; + Java_com_sun_media_sound_DirectAudioDevice_nAvailable; + Java_com_sun_media_sound_DirectAudioDevice_nClose; + Java_com_sun_media_sound_DirectAudioDevice_nFlush; + Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; + Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; + Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; + Java_com_sun_media_sound_DirectAudioDevice_nOpen; + Java_com_sun_media_sound_DirectAudioDevice_nRead; + Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; + Java_com_sun_media_sound_DirectAudioDevice_nService; + Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nStart; + Java_com_sun_media_sound_DirectAudioDevice_nStop; + Java_com_sun_media_sound_DirectAudioDevice_nWrite; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiInDevice_nClose; + Java_com_sun_media_sound_MidiInDevice_nGetMessages; + Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiInDevice_nOpen; + Java_com_sun_media_sound_MidiInDevice_nStart; + Java_com_sun_media_sound_MidiInDevice_nStop; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiOutDevice_nClose; + Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiOutDevice_nOpen; + Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; + Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; + Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; + Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; + Java_com_sun_media_sound_PortMixer_nClose; + Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlGetIntValue; + Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlSetIntValue; + Java_com_sun_media_sound_PortMixer_nGetControls; + Java_com_sun_media_sound_PortMixer_nGetPortCount; + Java_com_sun_media_sound_PortMixer_nGetPortName; + Java_com_sun_media_sound_PortMixer_nGetPortType; + Java_com_sun_media_sound_PortMixer_nOpen; + local: + *; }; diff --git a/jdk/make/mapfiles/libsplashscreen/mapfile-vers b/jdk/make/mapfiles/libsplashscreen/mapfile-vers index fec7b037f0d..b948ef474a6 100644 --- a/jdk/make/mapfiles/libsplashscreen/mapfile-vers +++ b/jdk/make/mapfiles/libsplashscreen/mapfile-vers @@ -26,24 +26,24 @@ # Define public interface. SUNWprivate_1.1 { - global: - Java_java_awt_SplashScreen__1update; - Java_java_awt_SplashScreen__1isVisible; - Java_java_awt_SplashScreen__1getBounds; - Java_java_awt_SplashScreen__1getInstance; - Java_java_awt_SplashScreen__1close; - Java_java_awt_SplashScreen__1getImageFileName; - Java_java_awt_SplashScreen__1getImageJarName; - Java_java_awt_SplashScreen__1setImageData; - Java_java_awt_SplashScreen__1getScaleFactor; + global: + Java_java_awt_SplashScreen__1update; + Java_java_awt_SplashScreen__1isVisible; + Java_java_awt_SplashScreen__1getBounds; + Java_java_awt_SplashScreen__1getInstance; + Java_java_awt_SplashScreen__1close; + Java_java_awt_SplashScreen__1getImageFileName; + Java_java_awt_SplashScreen__1getImageJarName; + Java_java_awt_SplashScreen__1setImageData; + Java_java_awt_SplashScreen__1getScaleFactor; - SplashLoadMemory; - SplashLoadFile; - SplashInit; - SplashClose; - SplashSetFileJarName; - SplashSetScaleFactor; - SplashGetScaledImageName; - local: - *; + SplashLoadMemory; + SplashLoadFile; + SplashInit; + SplashClose; + SplashSetFileJarName; + SplashSetScaleFactor; + SplashGetScaledImageName; + local: + *; }; diff --git a/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c b/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c index 8fd84347da1..059d9a7badb 100644 --- a/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c +++ b/jdk/src/java.base/macosx/native/libnio/ch/KQueueArrayWrapper.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -123,7 +123,6 @@ Java_sun_nio_ch_KQueueArrayWrapper_register0(JNIEnv *env, jobject this, kevent(kq, changes, 2, errors, 2, &dontBlock); } - JNIEXPORT jint JNICALL Java_sun_nio_ch_KQueueArrayWrapper_kevent0(JNIEnv *env, jobject this, jint kq, jlong kevAddr, jint kevCount, @@ -138,6 +137,15 @@ Java_sun_nio_ch_KQueueArrayWrapper_kevent0(JNIEnv *env, jobject this, jint kq, // Java timeout == -1 : wait forever : timespec timeout of NULL // Java timeout == 0 : return immediately : timespec timeout of zero if (timeout >= 0) { + // For some indeterminate reason kevent(2) has been found to fail with + // an EINVAL error for timeout values greater than or equal to + // 100000001000L. To avoid this problem, clamp the timeout arbitrarily + // to the maximum value of a 32-bit signed integer which is + // approximately 25 days in milliseconds. + const jlong timeoutMax = 0x7fffffff; // java.lang.Integer.MAX_VALUE + if (timeout > timeoutMax) { + timeout = timeoutMax; + } ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000000; //nanosec = 1 million millisec tsp = &ts; diff --git a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java index 12baf44fe58..1d1a273ef7d 100644 --- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Package.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -476,7 +476,8 @@ class Package { } else if (localICs.isEmpty()) { // It was a non-empty diff, but the local ICs were absent. actualICs = null; - changed = 0; // [] => null, no tuple change + // [] => null, no tuple change, but attribute deletion. + changed = -1; } else { // Non-trivial diff was transmitted. actualICs = computeICdiff(); diff --git a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java index 1a60f9e1047..bcb6cb1eb4d 100644 --- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -1193,18 +1193,21 @@ class PackageReader extends BandStructure { cls.visitRefs(VRM_CLASSIC, cpRefs); ArrayList bsms = new ArrayList<>(); - /* - * BootstrapMethod(BSMs) are added here before InnerClasses(ICs), - * so as to ensure the order. Noting that the BSMs may be - * removed if they are not found in the CP, after the ICs expansion. - */ - cls.addAttribute(Package.attrBootstrapMethodsEmpty.canonicalInstance()); - // flesh out the local constant pool ConstantPool.completeReferencesIn(cpRefs, true, bsms); + // add the bsm and references as required + if (!bsms.isEmpty()) { + cls.addAttribute(Package.attrBootstrapMethodsEmpty.canonicalInstance()); + cpRefs.add(Package.getRefString("BootstrapMethods")); + Collections.sort(bsms); + cls.setBootstrapMethods(bsms); + } + // Now that we know all our local class references, // compute the InnerClasses attribute. + // An InnerClasses attribute usually gets added here, + // although it might already have been present. int changed = cls.expandLocalICs(); if (changed != 0) { @@ -1221,16 +1224,6 @@ class PackageReader extends BandStructure { ConstantPool.completeReferencesIn(cpRefs, true, bsms); } - // remove the attr previously set, otherwise add the bsm and - // references as required - if (bsms.isEmpty()) { - cls.attributes.remove(Package.attrBootstrapMethodsEmpty.canonicalInstance()); - } else { - cpRefs.add(Package.getRefString("BootstrapMethods")); - Collections.sort(bsms); - cls.setBootstrapMethods(bsms); - } - // construct a local constant pool int numDoubles = 0; for (Entry e : cpRefs) { diff --git a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/intrinsic.properties b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/intrinsic.properties index be1687076cc..fa9ba74f047 100644 --- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/intrinsic.properties +++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/intrinsic.properties @@ -18,7 +18,7 @@ pack.class.attribute.CompilationID = RUH pack.class.attribute.Module = NH[RUHFH]NH[RUHNH[RUH]]NH[RCH]NH[RCHRCH] pack.class.attribute.ConcealedPackages = NH[RUH] pack.class.attribute.Version = RUH -pack.class.attribute.MainClass = RUH +pack.class.attribute.MainClass = RCH pack.class.attribute.TargetPlatform = RUHRUHRUH pack.class.attribute.Hashes = RUHNH[RUHRUH] diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index d8b2dee337d..f011aa8b47e 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -27,6 +27,7 @@ package java.lang; import java.io.InputStream; import java.io.IOException; +import java.io.UncheckedIOException; import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -46,12 +47,16 @@ import java.util.Hashtable; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.Spliterator; +import java.util.Spliterators; import java.util.Stack; import java.util.NoSuchElementException; import java.util.Vector; import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import jdk.internal.perf.PerfCounter; import jdk.internal.module.ServicesCatalog; @@ -1167,17 +1172,7 @@ public abstract class ClassLoader { protected final Class findSystemClass(String name) throws ClassNotFoundException { - ClassLoader system = getSystemClassLoader(); - if (system == null) { - if (!checkName(name)) - throw new ClassNotFoundException(name); - Class cls = findBootstrapClass(name); - if (cls == null) { - throw new ClassNotFoundException(name); - } - return cls; - } - return system.loadClass(name); + return getSystemClassLoader().loadClass(name); } /** @@ -1353,6 +1348,57 @@ public abstract class ClassLoader { return new CompoundEnumeration<>(tmp); } + /** + * Returns a stream whose elements are the URLs of all the resources with + * the given name. A resource is some data (images, audio, text, etc) that + * can be accessed by class code in a way that is independent of the + * location of the code. + * + * Resources in a named module are private to that module. This method does + * not find resources in named modules. + * + *

The name of a resource is a {@code /}-separated path name that + * identifies the resource. + * + *

The search order is described in the documentation for {@link + * #getResource(String)}. + * + *

The resources will be located when the returned stream is evaluated. + * If the evaluation results in an {@code IOException} then the I/O + * exception is wrapped in an {@link UncheckedIOException} that is then + * thrown. + * + * @apiNote When overriding this method it is recommended that an + * implementation ensures that any delegation is consistent with the {@link + * #getResource(java.lang.String) getResource(String)} method. This should + * ensure that the first element returned by the stream is the same + * resource that the {@code getResource(String)} method would return. + * + * @param name + * The resource name + * + * @return A stream of resource {@link java.net.URL URL} objects. If no + * resources could be found, the stream will be empty. Resources + * that the class loader doesn't have access to will not be in the + * stream. + * + * @see #findResources(String) + * + * @since 9 + */ + public Stream resources(String name) { + int characteristics = Spliterator.NONNULL | Spliterator.IMMUTABLE; + Supplier> si = () -> { + try { + return Spliterators.spliteratorUnknownSize( + getResources(name).asIterator(), characteristics); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }; + return StreamSupport.stream(si, characteristics, false); + } + /** * Finds the resource with the given name. Class loader implementations * should override this method to specify where to find resources. @@ -1437,11 +1483,7 @@ public abstract class ClassLoader { * @since 1.1 */ public static URL getSystemResource(String name) { - ClassLoader system = getSystemClassLoader(); - if (system == null) { - return BootLoader.findResource(name); - } - return system.getResource(name); + return getSystemClassLoader().getResource(name); } /** @@ -1464,17 +1506,13 @@ public abstract class ClassLoader { * * @throws IOException * If I/O errors occur - + * * @since 1.2 */ public static Enumeration getSystemResources(String name) throws IOException { - ClassLoader system = getSystemClassLoader(); - if (system == null) { - return BootLoader.findResources(name); - } - return system.getResources(name); + return getSystemClassLoader().getResources(name); } /** @@ -1631,8 +1669,7 @@ public abstract class ClassLoader { * this method during startup should take care not to cache the return * value until the system is fully initialized. * - * @return The system ClassLoader for delegation, or - * null if none + * @return The system ClassLoader for delegation * * @throws SecurityException * If a security manager is present, and the caller's class loader @@ -1941,9 +1978,14 @@ public abstract class ClassLoader { * @return The {@code Package} of the given name defined by this class loader, * or {@code null} if not found * + * @throws NullPointerException + * if {@code name} is {@code null}. + * * @since 9 */ public final Package getDefinedPackage(String name) { + Objects.requireNonNull(name, "name cannot be null"); + NamedPackage p = packages.get(name); if (p == null) return null; @@ -1981,6 +2023,9 @@ public abstract class ClassLoader { * @return The {@code Package} corresponding to the given name defined by * this class loader or its ancestors, or {@code null} if not found. * + * @throws NullPointerException + * if {@code name} is {@code null}. + * * @deprecated * If multiple class loaders delegate to each other and define classes * with the same package name, and one such loader relies on the lookup diff --git a/jdk/src/java.base/share/classes/java/lang/Compiler.java b/jdk/src/java.base/share/classes/java/lang/Compiler.java index fd4f3045d48..1726b693219 100644 --- a/jdk/src/java.base/share/classes/java/lang/Compiler.java +++ b/jdk/src/java.base/share/classes/java/lang/Compiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,21 +29,18 @@ package java.lang; * The {@code Compiler} class is provided to support Java-to-native-code * compilers and related services. By design, the {@code Compiler} class does * nothing; it serves as a placeholder for a JIT compiler implementation. + * If no compiler is available, these methods do nothing. * - *

When the Java Virtual Machine first starts, it determines if the system - * property {@code java.compiler} exists. (System properties are accessible - * through {@link System#getProperty(String)} and {@link - * System#getProperty(String, String)}. If so, it is assumed to be the name of - * a library (with a platform-dependent exact location and type); {@link - * System#loadLibrary} is called to load that library. If this loading - * succeeds, the function named {@code java_lang_Compiler_start()} in that - * library is called. - * - *

If no compiler is available, these methods do nothing. + * @deprecated JIT compilers and their technologies vary too widely to + * be controlled effectively by a standardized interface. As such, many + * JIT compiler implementations ignore this interface, and are instead + * controllable by implementation-specific mechanisms such as command-line + * options. This class is subject to removal in a future version of Java SE. * * @author Frank Yellin * @since 1.0 */ +@Deprecated(since="9", forRemoval=true) public final class Compiler { private Compiler() {} // don't make instances diff --git a/jdk/src/java.base/share/classes/java/lang/Package.java b/jdk/src/java.base/share/classes/java/lang/Package.java index 1aa9e98fbf2..b4ba45b8f35 100644 --- a/jdk/src/java.base/share/classes/java/lang/Package.java +++ b/jdk/src/java.base/share/classes/java/lang/Package.java @@ -317,6 +317,9 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated * @return The {@code Package} of the given name defined by the caller's * class loader or its ancestors, or {@code null} if not found. * + * @throws NullPointerException + * if {@code name} is {@code null}. + * * @deprecated * If multiple class loaders delegate to each other and define classes * with the same package name, and one such loader relies on the lookup diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java index 43d4ef6aae0..84a599a4285 100644 --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java @@ -733,6 +733,7 @@ public class Runtime { * @deprecated * This method was intended to control instruction tracing. * It has been superseded by JVM-specific tracing mechanisms. + * This method is subject to removal in a future version of Java SE. * * @param on ignored */ @@ -745,6 +746,7 @@ public class Runtime { * @deprecated * This method was intended to control method call tracing. * It has been superseded by JVM-specific tracing mechanisms. + * This method is subject to removal in a future version of Java SE. * * @param on ignored */ diff --git a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java index d014ddb3378..46d8ef23c08 100644 --- a/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java +++ b/jdk/src/java.base/share/classes/java/lang/RuntimePermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -323,11 +323,9 @@ import java.util.StringTokenizer; * usePolicy * Granting this permission disables the Java Plug-In's default * security prompting behavior. - * For more information, refer to Java Plug-In's guides, - * Applet Security Basics and - * usePolicy Permission. + * For more information, refer to the deployment guide. + * * * * manageProcess diff --git a/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java b/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java index 1504e6ff37d..f3f16088f7a 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java +++ b/jdk/src/java.base/share/classes/java/lang/StringConcatHelper.java @@ -334,11 +334,15 @@ final class StringConcatHelper { /** * Instantiates the String with given buffer and coder * @param buf buffer to use + * @param index remaining index * @param coder coder to use * @return String resulting string */ - static String newString(byte[] buf, byte coder) { + static String newString(byte[] buf, int index, byte coder) { // Use the private, non-copying constructor (unsafe!) + if (index != 0) { + throw new InternalError("Storage is not completely initialized, " + index + " bytes left"); + } return new String(buf, coder); } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java index cec4ff1ea54..ddd60ca082f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java @@ -83,7 +83,9 @@ class LambdaFormEditor { FOLD_ARGS = 11, FOLD_ARGS_TO_VOID = 12, PERMUTE_ARGS = 13, - LOCAL_TYPES = 14; + LOCAL_TYPES = 14, + FOLD_SELECT_ARGS = 15, + FOLD_SELECT_ARGS_TO_VOID = 16; private static final boolean STRESS_TEST = false; // turn on to disable most packing private static final int @@ -695,6 +697,72 @@ class LambdaFormEditor { return buf.endEdit(); } + private LambdaForm makeArgumentCombinationForm(int pos, + MethodType combinerType, + int[] argPositions, + boolean keepArguments, + boolean dropResult) { + LambdaFormBuffer buf = buffer(); + buf.startEdit(); + int combinerArity = combinerType.parameterCount(); + assert(combinerArity == argPositions.length); + + int resultArity = (dropResult ? 0 : 1); + + assert(pos <= lambdaForm.arity); + assert(pos > 0); // cannot filter the MH arg itself + assert(combinerType == combinerType.basicType()); + assert(combinerType.returnType() != void.class || dropResult); + + BoundMethodHandle.SpeciesData oldData = oldSpeciesData(); + BoundMethodHandle.SpeciesData newData = newSpeciesData(L_TYPE); + + // The newly created LF will run with a different BMH. + // Switch over any pre-existing BMH field references to the new BMH class. + Name oldBaseAddress = lambdaForm.parameter(0); // BMH holding the values + buf.replaceFunctions(oldData.getterFunctions(), newData.getterFunctions(), oldBaseAddress); + Name newBaseAddress = oldBaseAddress.withConstraint(newData); + buf.renameParameter(0, newBaseAddress); + + Name getCombiner = new Name(newData.getterFunction(oldData.fieldCount()), newBaseAddress); + Object[] combinerArgs = new Object[1 + combinerArity]; + combinerArgs[0] = getCombiner; + Name[] newParams; + if (keepArguments) { + newParams = new Name[0]; + for (int i = 0; i < combinerArity; i++) { + combinerArgs[i + 1] = lambdaForm.parameter(1 + argPositions[i]); + assert (basicType(combinerType.parameterType(i)) == lambdaForm.parameterType(1 + argPositions[i])); + } + } else { + newParams = new Name[combinerArity]; + for (int i = 0; i < newParams.length; i++) { + newParams[i] = lambdaForm.parameter(1 + argPositions[i]); + assert (basicType(combinerType.parameterType(i)) == lambdaForm.parameterType(1 + argPositions[i])); + } + System.arraycopy(newParams, 0, + combinerArgs, 1, combinerArity); + } + Name callCombiner = new Name(combinerType, combinerArgs); + + // insert the two new expressions + int exprPos = lambdaForm.arity(); + buf.insertExpression(exprPos+0, getCombiner); + buf.insertExpression(exprPos+1, callCombiner); + + // insert new arguments, if needed + int argPos = pos + resultArity; // skip result parameter + for (Name newParam : newParams) { + buf.insertParameter(argPos++, newParam); + } + assert(buf.lastIndexOf(callCombiner) == exprPos+1+newParams.length); + if (!dropResult) { + buf.replaceParameterByCopy(pos, exprPos+1+newParams.length); + } + + return buf.endEdit(); + } + LambdaForm filterReturnForm(BasicType newType, boolean constantZero) { byte kind = (constantZero ? Transform.FILTER_RETURN_TO_ZERO : Transform.FILTER_RETURN); Transform key = Transform.of(kind, newType.ordinal()); @@ -759,6 +827,21 @@ class LambdaFormEditor { return putInCache(key, form); } + LambdaForm foldArgumentsForm(int foldPos, boolean dropResult, MethodType combinerType, int ... argPositions) { + byte kind = (dropResult ? Transform.FOLD_SELECT_ARGS_TO_VOID + : Transform.FOLD_SELECT_ARGS); + int[] keyArgs = Arrays.copyOf(argPositions, argPositions.length + 1); + keyArgs[argPositions.length] = foldPos; + Transform key = Transform.of(kind, keyArgs); + LambdaForm form = getInCache(key); + if (form != null) { + assert(form.arity == lambdaForm.arity - (kind == Transform.FOLD_SELECT_ARGS ? 1 : 0)); + return form; + } + form = makeArgumentCombinationForm(foldPos, combinerType, argPositions, true, dropResult); + return putInCache(key, form); + } + LambdaForm permuteArgumentsForm(int skip, int[] reorder) { assert(skip == 1); // skip only the leading MH argument, names[0] int length = lambdaForm.names.length; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index a02e2f18b23..86685b605de 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -1207,11 +1207,16 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method * the following conditions: *

    *
  • if the field is declared {@code final}, then the write, atomic - * update, and numeric atomic update access modes are unsupported. + * update, numeric atomic update, and bitwise atomic update access + * modes are unsupported. *
  • if the field type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double} then numeric atomic update * access modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the field is declared {@code volatile} then the returned VarHandle @@ -1326,11 +1331,16 @@ assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method * the following conditions: *

    *
  • if the field is declared {@code final}, then the write, atomic - * update, and numeric atomic update access modes are unsupported. + * update, numeric atomic update, and bitwise atomic update access + * modes are unsupported. *
  • if the field type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double}, then numeric atomic update * access modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the field is declared {@code volatile} then the returned VarHandle @@ -1631,11 +1641,16 @@ return mh1; * the following conditions: *

    *
  • if the field is declared {@code final}, then the write, atomic - * update, and numeric atomic update access modes are unsupported. + * update, numeric atomic update, and bitwise atomic update access + * modes are unsupported. *
  • if the field type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double} then numeric atomic update * access modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the field is declared {@code volatile} then the returned VarHandle @@ -2353,9 +2368,13 @@ return mh1; * the following conditions: *

    *
  • if the component type is anything other than {@code byte}, - * {@code short}, {@code char}, {@code int} or {@code long}, + * {@code short}, {@code char}, {@code int}, {@code long}, * {@code float}, or {@code double} then numeric atomic update access * modes are unsupported. + *
  • if the field type is anything other than {@code boolean}, + * {@code byte}, {@code short}, {@code char}, {@code int} or + * {@code long} then bitwise atomic update access modes are + * unsupported. *
*

* If the component type is {@code float} or {@code double} then numeric @@ -2426,7 +2445,9 @@ return mh1; * If access is aligned then following access modes are supported and are * guaranteed to support atomic access: *

    - *
  • read write access modes for all {@code T}; + *
  • read write access modes for all {@code T}, with the exception of + * access modes {@code get} and {@code set} for {@code long} and + * {@code double} on 32-bit platforms. *
  • atomic update access modes for {@code int}, {@code long}, * {@code float} or {@code double}. * (Future major platform releases of the JDK may support additional @@ -2434,6 +2455,9 @@ return mh1; *
  • numeric atomic update access modes for {@code int} and {@code long}. * (Future major platform releases of the JDK may support additional * numeric types for certain currently unsupported access modes.) + *
  • bitwise atomic update access modes for {@code int} and {@code long}. + * (Future major platform releases of the JDK may support additional + * numeric types for certain currently unsupported access modes.) *
*

* Misaligned access, and therefore atomicity guarantees, may be determined @@ -2508,7 +2532,9 @@ return mh1; * If access is aligned then following access modes are supported and are * guaranteed to support atomic access: *

    - *
  • read write access modes for all {@code T}; + *
  • read write access modes for all {@code T}, with the exception of + * access modes {@code get} and {@code set} for {@code long} and + * {@code double} on 32-bit platforms. *
  • atomic update access modes for {@code int}, {@code long}, * {@code float} or {@code double}. * (Future major platform releases of the JDK may support additional @@ -2516,6 +2542,9 @@ return mh1; *
  • numeric atomic update access modes for {@code int} and {@code long}. * (Future major platform releases of the JDK may support additional * numeric types for certain currently unsupported access modes.) + *
  • bitwise atomic update access modes for {@code int} and {@code long}. + * (Future major platform releases of the JDK may support additional + * numeric types for certain currently unsupported access modes.) *
*

* Misaligned access, and therefore atomicity guarantees, may be determined @@ -3914,6 +3943,33 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); return rtype; } + private static Class foldArgumentChecks(int foldPos, MethodType targetType, MethodType combinerType, int ... argPos) { + int foldArgs = combinerType.parameterCount(); + if (argPos.length != foldArgs) { + throw newIllegalArgumentException("combiner and argument map must be equal size", combinerType, argPos.length); + } + Class rtype = combinerType.returnType(); + int foldVals = rtype == void.class ? 0 : 1; + boolean ok = true; + for (int i = 0; i < foldArgs; i++) { + int arg = argPos[i]; + if (arg < 0 || arg > targetType.parameterCount()) { + throw newIllegalArgumentException("arg outside of target parameterRange", targetType, arg); + } + if (combinerType.parameterType(i) != targetType.parameterType(arg)) { + throw newIllegalArgumentException("target argument type at position " + arg + + " must match combiner argument type at index " + i + ": " + targetType + + " -> " + combinerType + ", map: " + Arrays.toString(argPos)); + } + } + if (ok && foldVals != 0 && combinerType.returnType() != targetType.parameterType(foldPos)) { + ok = false; + } + if (!ok) + throw misMatchedTypes("target and combiner types", targetType, combinerType); + return rtype; + } + /** * Makes a method handle which adapts a target method handle, * by guarding it with a test, a boolean-valued method handle. @@ -4920,6 +4976,27 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); return result; } + /** + * As {@see foldArguments(MethodHandle, int, MethodHandle)}, but with the + * added capability of selecting the arguments from the targets parameters + * to call the combiner with. This allows us to avoid some simple cases of + * permutations and padding the combiner with dropArguments to select the + * right argument, which may ultimately produce fewer intermediaries. + */ + static MethodHandle foldArguments(MethodHandle target, int pos, MethodHandle combiner, int ... argPositions) { + MethodType targetType = target.type(); + MethodType combinerType = combiner.type(); + Class rtype = foldArgumentChecks(pos, targetType, combinerType, argPositions); + BoundMethodHandle result = target.rebind(); + boolean dropResult = rtype == void.class; + LambdaForm lform = result.editor().foldArgumentsForm(1 + pos, dropResult, combinerType.basicType(), argPositions); + MethodType newType = targetType; + if (!dropResult) { + newType = newType.dropParameterTypes(pos, pos + 1); + } + result = result.copyWithExtendL(newType, lform, combiner); + return result; + } private static void checkLoop0(MethodHandle[][] clauses) { if (clauses == null || clauses.length == 0) { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java index ed56faae579..4b336f4c6b1 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java @@ -563,9 +563,8 @@ public final class StringConcatFactory { } if ((lookup.lookupModes() & MethodHandles.Lookup.PRIVATE) == 0) { - throw new StringConcatException(String.format( - "Invalid caller: %s", - lookup.lookupClass().getName())); + throw new StringConcatException("Invalid caller: " + + lookup.lookupClass().getName()); } int cCount = 0; @@ -1494,51 +1493,41 @@ public final class StringConcatFactory { // Drop all remaining parameter types, leave only helper arguments: MethodHandle mh; - mh = MethodHandles.dropArguments(NEW_STRING, 2, ptypes); - mh = MethodHandles.dropArguments(mh, 0, int.class); + mh = MethodHandles.dropArguments(NEW_STRING, 3, ptypes); - // Safety: check that remaining index is zero -- that would mean the storage is completely - // overwritten, and no leakage of uninitialized data occurred. - mh = MethodHandles.filterArgument(mh, 0, CHECK_INDEX); - - // Mix in prependers. This happens when (int, byte[], byte) = (index, storage, coder) is already + // Mix in prependers. This happens when (byte[], int, byte) = (storage, index, coder) is already // known from the combinators below. We are assembling the string backwards, so "index" is the // *ending* index. for (RecipeElement el : recipe.getElements()) { - MethodHandle prepender; + // Do the prepend, and put "new" index at index 1 + mh = MethodHandles.dropArguments(mh, 2, int.class); switch (el.getTag()) { - case TAG_CONST: + case TAG_CONST: { Object cnst = el.getValue(); - prepender = MethodHandles.insertArguments(prepender(cnst.getClass()), 3, cnst); + MethodHandle prepender = MethodHandles.insertArguments(prepender(cnst.getClass()), 3, cnst); + mh = MethodHandles.foldArguments(mh, 1, prepender, + 2, 0, 3 // index, storage, coder + ); break; - case TAG_ARG: + } + case TAG_ARG: { int pos = el.getArgPos(); - prepender = selectArgument(prepender(ptypes[pos]), 3, ptypes, pos); + MethodHandle prepender = prepender(ptypes[pos]); + mh = MethodHandles.foldArguments(mh, 1, prepender, + 2, 0, 3, // index, storage, coder + 4 + pos // selected argument + ); break; + } default: throw new StringConcatException("Unhandled tag: " + el.getTag()); } - - // Remove "old" index from arguments - mh = MethodHandles.dropArguments(mh, 1, int.class); - - // Do the prepend, and put "new" index at index 0 - mh = MethodHandles.foldArguments(mh, prepender); } - // Prepare the argument list for prepending. The tree below would instantiate - // the storage byte[] into argument 0, so we need to swap "storage" and "index". - // The index at this point equals to "size", and resides at argument 1. - { - MethodType nmt = mh.type() - .changeParameterType(0, byte[].class) - .changeParameterType(1, int.class); - mh = MethodHandles.permuteArguments(mh, nmt, swap10(nmt.parameterCount())); - } - - // Fold in byte[] instantiation at argument 0. - MethodHandle combiner = MethodHandles.dropArguments(NEW_ARRAY, 2, ptypes); - mh = MethodHandles.foldArguments(mh, combiner); + // Fold in byte[] instantiation at argument 0 + mh = MethodHandles.foldArguments(mh, 0, NEW_ARRAY, + 1, 2 // index, coder + ); // Start combining length and coder mixers. // @@ -1567,12 +1556,8 @@ public final class StringConcatFactory { int ac = el.getArgPos(); Class argClass = ptypes[ac]; - MethodHandle lm = selectArgument(lengthMixer(argClass), 1, ptypes, ac); - lm = MethodHandles.dropArguments(lm, 0, byte.class); // (*) - lm = MethodHandles.dropArguments(lm, 2, byte.class); - - MethodHandle cm = selectArgument(coderMixer(argClass), 1, ptypes, ac); - cm = MethodHandles.dropArguments(cm, 0, int.class); // (**) + MethodHandle lm = lengthMixer(argClass); + MethodHandle cm = coderMixer(argClass); // Read this bottom up: @@ -1580,12 +1565,18 @@ public final class StringConcatFactory { mh = MethodHandles.dropArguments(mh, 2, int.class, byte.class); // 3. Compute "new-index", producing ("new-index", "new-coder", "old-index", "old-coder", ) - // Length mixer ignores both "new-coder" and "old-coder" due to dropArguments above (*) - mh = MethodHandles.foldArguments(mh, lm); + // Length mixer needs old index, plus the appropriate argument + mh = MethodHandles.foldArguments(mh, 0, lm, + 2, // old-index + 4 + ac // selected argument + ); // 2. Compute "new-coder", producing ("new-coder", "old-index", "old-coder", ) - // Coder mixer ignores the "old-index" arg due to dropArguments above (**) - mh = MethodHandles.foldArguments(mh, cm); + // Coder mixer needs old coder, plus the appropriate argument. + mh = MethodHandles.foldArguments(mh, 0, cm, + 2, // old-coder + 3 + ac // selected argument + ); // 1. The mh shape here is ("old-index", "old-coder", ) break; @@ -1606,41 +1597,11 @@ public final class StringConcatFactory { return mh; } - private static int[] swap10(int count) { - int[] perm = new int[count]; - perm[0] = 1; - perm[1] = 0; - for (int i = 2; i < count; i++) { - perm[i] = i; - } - return perm; - } - - // Adapts: (...prefix..., parameter[pos])R -> (...prefix..., ...parameters...)R - private static MethodHandle selectArgument(MethodHandle mh, int prefix, Class[] ptypes, int pos) { - if (pos == 0) { - return MethodHandles.dropArguments(mh, prefix + 1, Arrays.copyOfRange(ptypes, 1, ptypes.length)); - } else if (pos == ptypes.length - 1) { - return MethodHandles.dropArguments(mh, prefix, Arrays.copyOf(ptypes, ptypes.length - 1)); - } else { // 0 < pos < ptypes.size() - 1 - MethodHandle t = MethodHandles.dropArguments(mh, prefix, Arrays.copyOf(ptypes, pos)); - return MethodHandles.dropArguments(t, prefix + 1 + pos, Arrays.copyOfRange(ptypes, pos + 1, ptypes.length)); - } - } - @ForceInline private static byte[] newArray(int length, byte coder) { return (byte[]) UNSAFE.allocateUninitializedArray(byte.class, length << coder); } - @ForceInline - private static int checkIndex(int index) { - if (index != 0) { - throw new IllegalStateException("Storage is not completely initialized, " + index + " bytes left"); - } - return index; - } - private static MethodHandle prepender(Class cl) { return PREPENDERS.computeIfAbsent(cl, PREPEND); } @@ -1678,7 +1639,6 @@ public final class StringConcatFactory { }; private static final MethodHandle NEW_STRING; - private static final MethodHandle CHECK_INDEX; private static final MethodHandle NEW_ARRAY; private static final ConcurrentMap, MethodHandle> PREPENDERS; private static final ConcurrentMap, MethodHandle> LENGTH_MIXERS; @@ -1699,9 +1659,8 @@ public final class StringConcatFactory { LENGTH_MIXERS = new ConcurrentHashMap<>(); CODER_MIXERS = new ConcurrentHashMap<>(); - NEW_STRING = lookupStatic(Lookup.IMPL_LOOKUP, STRING_HELPER, "newString", String.class, byte[].class, byte.class); + NEW_STRING = lookupStatic(Lookup.IMPL_LOOKUP, STRING_HELPER, "newString", String.class, byte[].class, int.class, byte.class); NEW_ARRAY = lookupStatic(Lookup.IMPL_LOOKUP, MethodHandleInlineCopyStrategy.class, "newArray", byte[].class, int.class, byte.class); - CHECK_INDEX = lookupStatic(Lookup.IMPL_LOOKUP, MethodHandleInlineCopyStrategy.class, "checkIndex", int.class, int.class); } } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index 5e71204b6d0..167de41e98b 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -134,21 +134,38 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * The set of corresponding access mode methods belonging to this group * consists of the methods * {@link #compareAndSet compareAndSet}, + * {@link #weakCompareAndSetPlain weakCompareAndSetPlain}, * {@link #weakCompareAndSet weakCompareAndSet}, - * {@link #weakCompareAndSetVolatile weakCompareAndSetVolatile}, * {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire}, * {@link #weakCompareAndSetRelease weakCompareAndSetRelease}, * {@link #compareAndExchangeAcquire compareAndExchangeAcquire}, * {@link #compareAndExchange compareAndExchange}, * {@link #compareAndExchangeRelease compareAndExchangeRelease}, - * {@link #getAndSet getAndSet}. + * {@link #getAndSet getAndSet}, + * {@link #getAndSetAcquire getAndSetAcquire}, + * {@link #getAndSetRelease getAndSetRelease}. *

  • numeric atomic update access modes that, for example, atomically get and * set with addition the value of a variable under specified memory ordering * effects. * The set of corresponding access mode methods belonging to this group * consists of the methods * {@link #getAndAdd getAndAdd}, - * {@link #addAndGet addAndGet}. + * {@link #getAndAddAcquire getAndAddAcquire}, + * {@link #getAndAddRelease getAndAddRelease}, + *
  • bitwise atomic update access modes that, for example, atomically get and + * bitwise OR the value of a variable under specified memory ordering + * effects. + * The set of corresponding access mode methods belonging to this group + * consists of the methods + * {@link #getAndBitwiseOr getAndBitwiseOr}, + * {@link #getAndBitwiseOrAcquire getAndBitwiseOrAcquire}, + * {@link #getAndBitwiseOrRelease getAndBitwiseOrRelease}, + * {@link #getAndBitwiseAnd getAndBitwiseAnd}, + * {@link #getAndBitwiseAndAcquire getAndBitwiseAndAcquire}, + * {@link #getAndBitwiseAndRelease getAndBitwiseAndRelease}, + * {@link #getAndBitwiseXor getAndBitwiseXor}, + * {@link #getAndBitwiseXorAcquire getAndBitwiseXorAcquire}, + * {@link #getAndBitwiseXorRelease getAndBitwiseXorRelease}. * * *

    Factory methods that produce or {@link java.lang.invoke.MethodHandles.Lookup @@ -163,8 +180,8 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; * VarHandle instances and the corresponding method never throws * {@code UnsupportedOperationException}. * If a VarHandle references a read-only variable (for example a {@code final} - * field) then write, atomic update and numeric atomic update access modes are - * not supported and corresponding methods throw + * field) then write, atomic update, numeric atomic update, and bitwise atomic + * update access modes are not supported and corresponding methods throw * {@code UnsupportedOperationException}. * Read/write access modes (if supported), with the exception of * {@code get} and {@code set}, provide atomic access for @@ -816,8 +833,8 @@ public abstract class VarHandle { *

    The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. * *

    The symbolic type descriptor at the call site of {@code - * weakCompareAndSet} must match the access mode type that is the result of - * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)} + * weakCompareAndSetPlain} must match the access mode type that is the result of + * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)} * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form @@ -838,7 +855,7 @@ public abstract class VarHandle { public final native @MethodHandle.PolymorphicSignature @HotSpotIntrinsicCandidate - boolean weakCompareAndSet(Object... args); + boolean weakCompareAndSetPlain(Object... args); /** * Possibly atomically sets the value of a variable to the {@code newValue} @@ -853,8 +870,8 @@ public abstract class VarHandle { *

    The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}. * *

    The symbolic type descriptor at the call site of {@code - * weakCompareAndSetVolatile} must match the access mode type that is the - * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)} + * weakCompareAndSet} must match the access mode type that is the + * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)} * on this VarHandle. * * @param args the signature-polymorphic parameter list of the form @@ -875,7 +892,7 @@ public abstract class VarHandle { public final native @MethodHandle.PolymorphicSignature @HotSpotIntrinsicCandidate - boolean weakCompareAndSetVolatile(Object... args); + boolean weakCompareAndSet(Object... args); /** * Possibly atomically sets the value of a variable to the {@code newValue} @@ -986,6 +1003,71 @@ public abstract class VarHandle { @HotSpotIntrinsicCandidate Object getAndSet(Object... args); + /** + * Atomically sets the value of a variable to the {@code newValue} with the + * memory semantics of {@link #set} and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    The method signature is of the form {@code (CT, T newValue)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndSetAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T newValue)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndSetAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the {@code newValue} with the + * memory semantics of {@link #setRelease} and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    The method signature is of the form {@code (CT, T newValue)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndSetRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T newValue)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndSetRelease(Object... args); // Primitive adders // Throw UnsupportedOperationException for refs @@ -1025,21 +1107,21 @@ public abstract class VarHandle { /** * Atomically adds the {@code value} to the current value of a variable with - * the memory semantics of {@link #setVolatile}, and returns the variable's - * current (updated) value, as accessed with the memory semantics of - * {@link #getVolatile}. + * the memory semantics of {@link #set}, and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #getAcquire}. * *

    The method signature is of the form {@code (CT, T value)T}. * - *

    The symbolic type descriptor at the call site of {@code addAndGet} + *

    The symbolic type descriptor at the call site of {@code getAndAddAcquire} * must match the access mode type that is the result of calling - * {@code accessModeType(VarHandle.AccessMode.ADD_AND_GET)} on this + * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)} on this * VarHandle. * * @param args the signature-polymorphic parameter list of the form * {@code (CT, T value)} * , statically represented using varargs. - * @return the signature-polymorphic result that is the current value of + * @return the signature-polymorphic result that is the previous value of * the variable * , statically represented using {@code Object}. * @throws UnsupportedOperationException if the access mode is unsupported @@ -1054,7 +1136,378 @@ public abstract class VarHandle { public final native @MethodHandle.PolymorphicSignature @HotSpotIntrinsicCandidate - Object addAndGet(Object... args); + Object getAndAddAcquire(Object... args); + + /** + * Atomically adds the {@code value} to the current value of a variable with + * the memory semantics of {@link #setRelease}, and returns the variable's + * previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    The method signature is of the form {@code (CT, T value)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndAddRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T value)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndAddRelease(Object... args); + + + // Bitwise operations + // Throw UnsupportedOperationException for refs + + /** + * Atomically sets the value of a variable to the result of + * bitwise OR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setVolatile} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getVolatile}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical OR is performed instead of a bitwise OR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseOr} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseOr(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise OR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #set} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical OR is performed instead of a bitwise OR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseOrAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #set(Object...) + * @see #getAcquire(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseOrAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise OR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setRelease} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical OR is performed instead of a bitwise OR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseOrRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setRelease(Object...) + * @see #get(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseOrRelease(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise AND between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setVolatile} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getVolatile}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical AND is performed instead of a bitwise AND. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseAnd} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseAnd(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise AND between the variable's current value and the {@code mask} + * with the memory semantics of {@link #set} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical AND is performed instead of a bitwise AND. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseAndAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #set(Object...) + * @see #getAcquire(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseAndAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise AND between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setRelease} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical AND is performed instead of a bitwise AND. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseAndRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setRelease(Object...) + * @see #get(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseAndRelease(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise XOR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setVolatile} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getVolatile}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical XOR is performed instead of a bitwise XOR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseXor} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setVolatile(Object...) + * @see #getVolatile(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseXor(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise XOR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #set} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #getAcquire}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical XOR is performed instead of a bitwise XOR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseXorAcquire} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #set(Object...) + * @see #getAcquire(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseXorAcquire(Object... args); + + /** + * Atomically sets the value of a variable to the result of + * bitwise XOR between the variable's current value and the {@code mask} + * with the memory semantics of {@link #setRelease} and returns the + * variable's previous value, as accessed with the memory semantics of + * {@link #get}. + * + *

    If the variable type is the non-integral {@code boolean} type then a + * logical XOR is performed instead of a bitwise XOR. + * + *

    The method signature is of the form {@code (CT, T mask)T}. + * + *

    The symbolic type descriptor at the call site of {@code getAndBitwiseXorRelease} + * must match the access mode type that is the result of calling + * {@code accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)} on this + * VarHandle. + * + * @param args the signature-polymorphic parameter list of the form + * {@code (CT, T mask)} + * , statically represented using varargs. + * @return the signature-polymorphic result that is the previous value of + * the variable + * , statically represented using {@code Object}. + * @throws UnsupportedOperationException if the access mode is unsupported + * for this VarHandle. + * @throws WrongMethodTypeException if the access mode type is not + * compatible with the caller's symbolic type descriptor. + * @throws ClassCastException if the access mode type is compatible with the + * caller's symbolic type descriptor, but a reference cast fails. + * @see #setRelease(Object...) + * @see #get(Object...) + */ + public final native + @MethodHandle.PolymorphicSignature + @HotSpotIntrinsicCandidate + Object getAndBitwiseXorRelease(Object... args); + enum AccessType { GET(Object.class), @@ -1204,15 +1657,15 @@ public abstract class VarHandle { /** * The access mode whose access is specified by the corresponding * method - * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet} + * {@link VarHandle#weakCompareAndSetPlain VarHandle.weakCompareAndSetPlain} */ - WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP), + WEAK_COMPARE_AND_SET_PLAIN("weakCompareAndSetPlain", AccessType.COMPARE_AND_SWAP), /** * The access mode whose access is specified by the corresponding * method - * {@link VarHandle#weakCompareAndSetVolatile VarHandle.weakCompareAndSetVolatile} + * {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet} */ - WEAK_COMPARE_AND_SET_VOLATILE("weakCompareAndSetVolatile", AccessType.COMPARE_AND_SWAP), + WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP), /** * The access mode whose access is specified by the corresponding * method @@ -1231,6 +1684,18 @@ public abstract class VarHandle { * {@link VarHandle#getAndSet VarHandle.getAndSet} */ GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndSetAcquire VarHandle.getAndSetAcquire} + */ + GET_AND_SET_ACQUIRE("getAndSetAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndSetRelease VarHandle.getAndSetRelease} + */ + GET_AND_SET_RELEASE("getAndSetRelease", AccessType.GET_AND_UPDATE), /** * The access mode whose access is specified by the corresponding * method @@ -1240,9 +1705,69 @@ public abstract class VarHandle { /** * The access mode whose access is specified by the corresponding * method - * {@link VarHandle#addAndGet VarHandle.addAndGet} + * {@link VarHandle#getAndAddAcquire VarHandle.getAndAddAcquire} */ - ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE), + GET_AND_ADD_ACQUIRE("getAndAddAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndAddRelease VarHandle.getAndAddRelease} + */ + GET_AND_ADD_RELEASE("getAndAddRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseOr VarHandle.getAndBitwiseOr} + */ + GET_AND_BITWISE_OR("getAndBitwiseOr", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseOrRelease VarHandle.getAndBitwiseOrRelease} + */ + GET_AND_BITWISE_OR_RELEASE("getAndBitwiseOrRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseOrAcquire VarHandle.getAndBitwiseOrAcquire} + */ + GET_AND_BITWISE_OR_ACQUIRE("getAndBitwiseOrAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseAnd VarHandle.getAndBitwiseAnd} + */ + GET_AND_BITWISE_AND("getAndBitwiseAnd", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseAndRelease VarHandle.getAndBitwiseAndRelease} + */ + GET_AND_BITWISE_AND_RELEASE("getAndBitwiseAndRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseAndAcquire VarHandle.getAndBitwiseAndAcquire} + */ + GET_AND_BITWISE_AND_ACQUIRE("getAndBitwiseAndAcquire", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseXor VarHandle.getAndBitwiseXor} + */ + GET_AND_BITWISE_XOR("getAndBitwiseXor", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseXorRelease VarHandle.getAndBitwiseXorRelease} + */ + GET_AND_BITWISE_XOR_RELEASE("getAndBitwiseXorRelease", AccessType.GET_AND_UPDATE), + /** + * The access mode whose access is specified by the corresponding + * method + * {@link VarHandle#getAndBitwiseXorAcquire VarHandle.getAndBitwiseXorAcquire} + */ + GET_AND_BITWISE_XOR_ACQUIRE("getAndBitwiseXorAcquire", AccessType.GET_AND_UPDATE), ; static final Map methodNameToAccessMode; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index d6f5aaa380c..634d64d8327 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -156,7 +156,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -164,7 +164,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -193,6 +193,20 @@ final class VarHandle$Type$s { handle.fieldOffset, {#if[Object]?handle.fieldType.cast(value):value}); } + + @ForceInline + static $type$ getAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } + + @ForceInline + static $type$ getAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } #end[CAS] #if[AtomicAdd] @@ -204,12 +218,85 @@ final class VarHandle$Type$s { } @ForceInline - static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) { - return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + static $type$ getAndAddAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndAdd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, - value) + value); + value); } + + @ForceInline + static $type$ getAndAddRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndAdd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAnd(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(FieldInstanceReadWrite handle, Object holder, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + handle.fieldOffset, + value); + } +#end[Bitwise] static final VarForm FORM = new VarForm(FieldInstanceReadWrite.class, Object.class, $type$.class); } @@ -337,7 +424,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -345,7 +432,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, @@ -374,6 +461,20 @@ final class VarHandle$Type$s { handle.fieldOffset, {#if[Object]?handle.fieldType.cast(value):value}); } + + @ForceInline + static $type$ getAndSetAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndSet$Type$Acquire(handle.base, + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } + + @ForceInline + static $type$ getAndSetRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndSet$Type$Release(handle.base, + handle.fieldOffset, + {#if[Object]?handle.fieldType.cast(value):value}); + } #end[CAS] #if[AtomicAdd] @@ -385,12 +486,84 @@ final class VarHandle$Type$s { } @ForceInline - static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) { - return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(handle.base, + static $type$ getAndAddAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndAdd$Type$Acquire(handle.base, handle.fieldOffset, - value) + value); + value); + } + + @ForceInline + static $type$ getAndAddRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndAdd$Type$Release(handle.base, + handle.fieldOffset, + value); } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Release(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseOr$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAnd(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Release(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseAnd$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXor(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Release(handle.base, + handle.fieldOffset, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(FieldStaticReadWrite handle, $type$ value) { + return UNSAFE.getAndBitwiseXor$Type$Acquire(handle.base, + handle.fieldOffset, + value); + } +#end[Bitwise] static final VarForm FORM = new VarForm(FieldStaticReadWrite.class, null, $type$.class); } @@ -562,7 +735,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] @@ -575,7 +748,7 @@ final class VarHandle$Type$s { } @ForceInline - static boolean weakCompareAndSetVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(Array handle, Object oarray, int index, $type$ expected, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] @@ -624,33 +797,131 @@ final class VarHandle$Type$s { (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(value):value}); } -#end[CAS] -#if[AtomicAdd] @ForceInline - static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) { + static $type$ getAndSetAcquire(Array handle, Object oarray, int index, $type$ value) { #if[Object] Object[] array = (Object[]) handle.arrayType.cast(oarray); #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] + return UNSAFE.getAndSet$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + {#if[Object]?handle.componentType.cast(value):value}); + } + + @ForceInline + static $type$ getAndSetRelease(Array handle, Object oarray, int index, $type$ value) { +#if[Object] + Object[] array = (Object[]) handle.arrayType.cast(oarray); +#else[Object] + $type$[] array = ($type$[]) oarray; +#end[Object] + return UNSAFE.getAndSet$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + {#if[Object]?handle.componentType.cast(value):value}); + } +#end[CAS] +#if[AtomicAdd] + + @ForceInline + static $type$ getAndAdd(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; return UNSAFE.getAndAdd$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @ForceInline - static $type$ addAndGet(Array handle, Object oarray, int index, $type$ value) { -#if[Object] - Object[] array = (Object[]) handle.arrayType.cast(oarray); -#else[Object] + static $type$ getAndAddAcquire(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; -#end[Object] - return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(array, + return UNSAFE.getAndAdd$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, - value) + value); + value); + } + + @ForceInline + static $type$ getAndAddRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndAdd$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); } #end[AtomicAdd] +#if[Bitwise] + + @ForceInline + static $type$ getAndBitwiseOr(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseOr$Type$(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseOr$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseOr$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseAnd(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseAnd$Type$(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseAnd$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseAnd$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseXor$Type$(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseXor$Type$Release(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(Array handle, Object oarray, int index, $type$ value) { + $type$[] array = ($type$[]) oarray; + return UNSAFE.getAndBitwiseXor$Type$Acquire(array, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + value); + } +#end[Bitwise] static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index bb2f7f0ae10..da57311e39d 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -223,7 +223,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; return UNSAFE.weakCompareAndSwap$RawType$( ba, @@ -232,7 +232,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; return UNSAFE.weakCompareAndSwap$RawType$Volatile( ba, @@ -267,6 +267,26 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { address(ba, index(ba, index)), convEndian(handle.be, value))); } + + @ForceInline + static $type$ getAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Acquire( + ba, + address(ba, index(ba, index)), + convEndian(handle.be, value))); + } + + @ForceInline + static $type$ getAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Release( + ba, + address(ba, index(ba, index)), + convEndian(handle.be, value))); + } #end[CAS] #if[AtomicAdd] @@ -283,6 +303,32 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } } + @ForceInline + static $type$ getAndAddAcquire(ArrayHandle handle, Object oba, int index, $type$ delta) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Acquire( + ba, + address(ba, index(ba, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(ba, index, delta); + } + } + + @ForceInline + static $type$ getAndAddRelease(ArrayHandle handle, Object oba, int index, $type$ delta) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Release( + ba, + address(ba, index(ba, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(ba, index, delta); + } + } + @ForceInline static $type$ getAndAddConvEndianWithCAS(byte[] ba, int index, $type$ delta) { $type$ nativeExpectedValue, expectedValue; @@ -294,12 +340,162 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } +#end[AtomicAdd] +#if[Bitwise] @ForceInline - static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) { - return getAndAdd(handle, oba, index, delta) + delta; + static $type$ getAndBitwiseOr(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(ba, index, value); + } } -#end[AtomicAdd] + + @ForceInline + static $type$ getAndBitwiseOrRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Release( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Acquire( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrConvEndianWithCAS(byte[] ba, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); + return expectedValue; + } + + @ForceInline + static $type$ getAndBitwiseAnd(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Release( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Acquire( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndConvEndianWithCAS(byte[] ba, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); + return expectedValue; + } + + @ForceInline + static $type$ getAndBitwiseXor(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Release( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(ArrayHandle handle, Object oba, int index, $type$ value) { + byte[] ba = (byte[]) oba; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Acquire( + ba, + address(ba, index(ba, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(ba, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorConvEndianWithCAS(byte[] ba, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); + return expectedValue; + } +#end[Bitwise] static final VarForm FORM = new VarForm(ArrayHandle.class, byte[].class, $type$.class, int.class); } @@ -466,7 +662,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; return UNSAFE.weakCompareAndSwap$RawType$( UNSAFE.getObject(bb, BYTE_BUFFER_HB), @@ -475,7 +671,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } @ForceInline - static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { + static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; return UNSAFE.weakCompareAndSwap$RawType$Volatile( UNSAFE.getObject(bb, BYTE_BUFFER_HB), @@ -510,6 +706,26 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { address(bb, indexRO(bb, index)), convEndian(handle.be, value))); } + + @ForceInline + static $type$ getAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + convEndian(handle.be, value))); + } + + @ForceInline + static $type$ getAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + return convEndian(handle.be, + UNSAFE.getAndSet$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + convEndian(handle.be, value))); + } #end[CAS] #if[AtomicAdd] @@ -526,6 +742,32 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { } } + @ForceInline + static $type$ getAndAddAcquire(ByteBufferHandle handle, Object obb, int index, $type$ delta) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(bb, index, delta); + } + } + + @ForceInline + static $type$ getAndAddRelease(ByteBufferHandle handle, Object obb, int index, $type$ delta) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(bb, index, delta); + } + } + @ForceInline static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) { $type$ nativeExpectedValue, expectedValue; @@ -538,12 +780,166 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } +#end[AtomicAdd] +#if[Bitwise] @ForceInline - static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) { - return getAndAdd(handle, obb, index, delta) + delta; + static $type$ getAndBitwiseOr(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(bb, index, value); + } } -#end[AtomicAdd] + + @ForceInline + static $type$ getAndBitwiseOrRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseOr$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseOrConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseOrConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); + return expectedValue; + } + + @ForceInline + static $type$ getAndBitwiseAnd(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseAnd$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseAndConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseAndConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); + return expectedValue; + } + + + @ForceInline + static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorRelease(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Release( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorAcquire(ByteBufferHandle handle, Object obb, int index, $type$ value) { + ByteBuffer bb = (ByteBuffer) obb; + if (handle.be == BE) { + return UNSAFE.getAndBitwiseXor$RawType$Acquire( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + value); + } else { + return getAndBitwiseXorConvEndianWithCAS(bb, index, value); + } + } + + @ForceInline + static $type$ getAndBitwiseXorConvEndianWithCAS(ByteBuffer bb, int index, $type$ value) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); + return expectedValue; + } +#end[Bitwise] static final VarForm FORM = new VarForm(ByteBufferHandle.class, ByteBuffer.class, $type$.class, int.class); } diff --git a/jdk/src/java.base/share/classes/java/lang/ref/package-info.java b/jdk/src/java.base/share/classes/java/lang/ref/package-info.java index 1ee769d16cc..58600cba1b8 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/package-info.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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,8 +43,7 @@ * implementing memory-sensitive caches, weak references are for * implementing canonicalizing mappings that do not prevent their keys * (or values) from being reclaimed, and phantom references are for - * scheduling pre-mortem cleanup actions in a more flexible way than - * is possible with the Java finalization mechanism. + * scheduling post-mortem cleanup actions. * Post-mortem cleanup actions can be registered and managed by a * {@link java.lang.ref.Cleaner}. * diff --git a/jdk/src/java.base/share/classes/java/net/ServerSocket.java b/jdk/src/java.base/share/classes/java/net/ServerSocket.java index a86fca6af3c..256c9a6e2ee 100644 --- a/jdk/src/java.base/share/classes/java/net/ServerSocket.java +++ b/jdk/src/java.base/share/classes/java/net/ServerSocket.java @@ -25,8 +25,13 @@ package java.net; +import jdk.internal.misc.JavaNetSocketAccess; +import jdk.internal.misc.SharedSecrets; + import java.io.FileDescriptor; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.nio.channels.ServerSocketChannel; import java.security.AccessController; import java.security.PrivilegedExceptionAction; @@ -1011,4 +1016,27 @@ class ServerSocket implements java.io.Closeable { return options; } } + + static { + SharedSecrets.setJavaNetSocketAccess( + new JavaNetSocketAccess() { + @Override + public ServerSocket newServerSocket(SocketImpl impl) { + return new ServerSocket(impl); + } + + @Override + public SocketImpl newSocketImpl(Class implClass) { + try { + Constructor ctor = + implClass.getDeclaredConstructor(); + return ctor.newInstance(); + } catch (NoSuchMethodException | InstantiationException | + IllegalAccessException | InvocationTargetException e) { + throw new AssertionError(e); + } + } + } + ); + } } diff --git a/jdk/src/java.base/share/classes/java/security/DigestInputStream.java b/jdk/src/java.base/share/classes/java/security/DigestInputStream.java index a1bf55ac9e7..747537df253 100644 --- a/jdk/src/java.base/share/classes/java/security/DigestInputStream.java +++ b/jdk/src/java.base/share/classes/java/security/DigestInputStream.java @@ -52,7 +52,7 @@ import java.io.ByteArrayInputStream; * {@link MessageDigest}), * so that in order to compute intermediate digests, a caller should * retain a handle onto the digest object, and clone it for each - * digest to be computed, leaving the orginal digest untouched. + * digest to be computed, leaving the original digest untouched. * * @see MessageDigest * diff --git a/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java index 46686b522a1..3a241787329 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java +++ b/jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java @@ -76,7 +76,7 @@ import sun.security.util.Debug; * {@code g} parameters. If the modulus size is not one of the above * values, the Sun provider creates a new set of parameters. Other * providers might have precomputed parameter sets for more than just the - * three modulus sizes mentioned above. Still others might not have a list of + * modulus sizes mentioned above. Still others might not have a list of * precomputed parameters at all and instead always create new parameter sets. * *

  • Algorithm-Specific Initialization @@ -393,7 +393,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi { * of randomness. * (If none of the installed providers supply an implementation of * {@code SecureRandom}, a system-provided source of randomness is - * used.). + * used.) * *

    This concrete method has been added to this previously-defined * abstract class. diff --git a/jdk/src/java.base/share/classes/java/security/SignatureSpi.java b/jdk/src/java.base/share/classes/java/security/SignatureSpi.java index 7e78726f3b8..9be7701a2fa 100644 --- a/jdk/src/java.base/share/classes/java/security/SignatureSpi.java +++ b/jdk/src/java.base/share/classes/java/security/SignatureSpi.java @@ -38,7 +38,7 @@ import sun.security.jca.JCAUtil; * for the {@code Signature} class, which is used to provide the * functionality of a digital signature algorithm. Digital signatures are used * for authentication and integrity assurance of digital data. - *. + * *

    All the abstract methods in this class must be implemented by each * cryptographic service provider who wishes to supply the implementation * of a particular signature algorithm. diff --git a/jdk/src/java.base/share/classes/java/util/ArrayDeque.java b/jdk/src/java.base/share/classes/java/util/ArrayDeque.java index ca3c66b6249..5a9b8312e30 100644 --- a/jdk/src/java.base/share/classes/java/util/ArrayDeque.java +++ b/jdk/src/java.base/share/classes/java/util/ArrayDeque.java @@ -81,8 +81,8 @@ import java.util.function.Consumer; * Java Collections Framework. * * @author Josh Bloch and Doug Lea - * @since 1.6 * @param the type of elements held in this deque + * @since 1.6 */ public class ArrayDeque extends AbstractCollection implements Deque, Cloneable, Serializable diff --git a/jdk/src/java.base/share/classes/java/util/Base64.java b/jdk/src/java.base/share/classes/java/util/Base64.java index 9a34f279ab3..99f5dc0d993 100644 --- a/jdk/src/java.base/share/classes/java/util/Base64.java +++ b/jdk/src/java.base/share/classes/java/util/Base64.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -788,7 +788,7 @@ public class Base64 { public void write(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("Stream is closed"); - if (off < 0 || len < 0 || off + len > b.length) + if (off < 0 || len < 0 || len > b.length - off) throw new ArrayIndexOutOfBoundsException(); if (len == 0) return; diff --git a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java index 8414311e425..494dce83a89 100644 --- a/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java +++ b/jdk/src/java.base/share/classes/java/util/ImmutableCollections.java @@ -31,6 +31,10 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamException; import java.io.Serializable; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; /** * Container class for immutable collections. Not part of the public API. @@ -61,9 +65,25 @@ class ImmutableCollections { */ static final double EXPAND_FACTOR = 2.0; + static UnsupportedOperationException uoe() { return new UnsupportedOperationException(); } + // ---------- List Implementations ---------- - static final class List0 extends AbstractList implements RandomAccess, Serializable { + abstract static class AbstractImmutableList extends AbstractList + implements RandomAccess, Serializable { + @Override public boolean add(E e) { throw uoe(); } + @Override public boolean addAll(Collection c) { throw uoe(); } + @Override public boolean addAll(int index, Collection c) { throw uoe(); } + @Override public void clear() { throw uoe(); } + @Override public boolean remove(Object o) { throw uoe(); } + @Override public boolean removeAll(Collection c) { throw uoe(); } + @Override public boolean removeIf(Predicate filter) { throw uoe(); } + @Override public void replaceAll(UnaryOperator operator) { throw uoe(); } + @Override public boolean retainAll(Collection c) { throw uoe(); } + @Override public void sort(Comparator c) { throw uoe(); } + } + + static final class List0 extends AbstractImmutableList { List0() { } @Override @@ -86,7 +106,7 @@ class ImmutableCollections { } } - static final class List1 extends AbstractList implements RandomAccess, Serializable { + static final class List1 extends AbstractImmutableList { private final E e0; List1(E e0) { @@ -114,7 +134,7 @@ class ImmutableCollections { } } - static final class List2 extends AbstractList implements RandomAccess, Serializable { + static final class List2 extends AbstractImmutableList { private final E e0; private final E e1; @@ -147,7 +167,7 @@ class ImmutableCollections { } } - static final class ListN extends AbstractList implements RandomAccess, Serializable { + static final class ListN extends AbstractImmutableList { private final E[] elements; @SafeVarargs @@ -183,7 +203,17 @@ class ImmutableCollections { // ---------- Set Implementations ---------- - static final class Set0 extends AbstractSet implements Serializable { + abstract static class AbstractImmutableSet extends AbstractSet implements Serializable { + @Override public boolean add(E e) { throw uoe(); } + @Override public boolean addAll(Collection c) { throw uoe(); } + @Override public void clear() { throw uoe(); } + @Override public boolean remove(Object o) { throw uoe(); } + @Override public boolean removeAll(Collection c) { throw uoe(); } + @Override public boolean removeIf(Predicate filter) { throw uoe(); } + @Override public boolean retainAll(Collection c) { throw uoe(); } + } + + static final class Set0 extends AbstractImmutableSet { Set0() { } @Override @@ -210,7 +240,7 @@ class ImmutableCollections { } } - static final class Set1 extends AbstractSet implements Serializable { + static final class Set1 extends AbstractImmutableSet { private final E e0; Set1(E e0) { @@ -241,7 +271,7 @@ class ImmutableCollections { } } - static final class Set2 extends AbstractSet implements Serializable { + static final class Set2 extends AbstractImmutableSet { private final E e0; private final E e1; @@ -312,7 +342,7 @@ class ImmutableCollections { * least one null is always present. * @param the element type */ - static final class SetN extends AbstractSet implements Serializable { + static final class SetN extends AbstractImmutableSet { private final E[] elements; private final int size; @@ -403,7 +433,23 @@ class ImmutableCollections { // ---------- Map Implementations ---------- - static final class Map0 extends AbstractMap implements Serializable { + abstract static class AbstractImmutableMap extends AbstractMap implements Serializable { + @Override public void clear() { throw uoe(); } + @Override public V compute(K key, BiFunction rf) { throw uoe(); } + @Override public V computeIfAbsent(K key, Function mf) { throw uoe(); } + @Override public V computeIfPresent(K key, BiFunction rf) { throw uoe(); } + @Override public V merge(K key, V value, BiFunction rf) { throw uoe(); } + @Override public V put(K key, V value) { throw uoe(); } + @Override public void putAll(Map m) { throw uoe(); } + @Override public V putIfAbsent(K key, V value) { throw uoe(); } + @Override public V remove(Object key) { throw uoe(); } + @Override public boolean remove(Object key, Object value) { throw uoe(); } + @Override public V replace(K key, V value) { throw uoe(); } + @Override public boolean replace(K key, V oldValue, V newValue) { throw uoe(); } + @Override public void replaceAll(BiFunction f) { throw uoe(); } + } + + static final class Map0 extends AbstractImmutableMap { Map0() { } @Override @@ -430,7 +476,7 @@ class ImmutableCollections { } } - static final class Map1 extends AbstractMap implements Serializable { + static final class Map1 extends AbstractImmutableMap { private final K k0; private final V v0; @@ -472,7 +518,7 @@ class ImmutableCollections { * @param the key type * @param the value type */ - static final class MapN extends AbstractMap implements Serializable { + static final class MapN extends AbstractImmutableMap { private final Object[] table; // pairs of key, value private final int size; // number of pairs diff --git a/jdk/src/java.base/share/classes/java/util/List.java b/jdk/src/java.base/share/classes/java/util/List.java index 3819d94e831..8e97c2ea259 100644 --- a/jdk/src/java.base/share/classes/java/util/List.java +++ b/jdk/src/java.base/share/classes/java/util/List.java @@ -94,7 +94,8 @@ import java.util.function.UnaryOperator; * *

      *
    • They are structurally immutable. Elements cannot be added, removed, - * or replaced. Attempts to do so result in {@code UnsupportedOperationException}. + * or replaced. Calling any mutator method will always cause + * {@code UnsupportedOperationException} to be thrown. * However, if the contained elements are themselves mutable, * this may cause the List's contents to appear to change. *
    • They disallow {@code null} elements. Attempts to create them with diff --git a/jdk/src/java.base/share/classes/java/util/Map.java b/jdk/src/java.base/share/classes/java/util/Map.java index 9b71b0552b6..d4ea203edee 100644 --- a/jdk/src/java.base/share/classes/java/util/Map.java +++ b/jdk/src/java.base/share/classes/java/util/Map.java @@ -119,7 +119,8 @@ import java.io.Serializable; * *
        *
      • They are structurally immutable. Keys and values cannot be added, - * removed, or updated. Attempts to do so result in {@code UnsupportedOperationException}. + * removed, or updated. Calling any mutator method will always cause + * {@code UnsupportedOperationException} to be thrown. * However, if the contained keys or values are themselves mutable, this may cause the * Map to behave inconsistently or its contents to appear to change. *
      • They disallow {@code null} keys and values. Attempts to create them with diff --git a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java index 440cbbe2c67..89bc2141e3d 100644 --- a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java +++ b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java @@ -749,11 +749,11 @@ public class PriorityQueue extends AbstractQueue /** * Saves this queue to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData The length of the array backing the instance is * emitted (int), followed by all of its elements * (each an {@code Object}) in the proper order. - * @param s the stream - * @throws java.io.IOException if an I/O error occurs */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { diff --git a/jdk/src/java.base/share/classes/java/util/Set.java b/jdk/src/java.base/share/classes/java/util/Set.java index 15a594a5e28..a1911c13e1b 100644 --- a/jdk/src/java.base/share/classes/java/util/Set.java +++ b/jdk/src/java.base/share/classes/java/util/Set.java @@ -70,7 +70,8 @@ package java.util; * *
          *
        • They are structurally immutable. Elements cannot be added or - * removed. Attempts to do so result in {@code UnsupportedOperationException}. + * removed. Calling any mutator method will always cause + * {@code UnsupportedOperationException} to be thrown. * However, if the contained elements are themselves mutable, this may cause the * Set to behave inconsistently or its contents to appear to change. *
        • They disallow {@code null} elements. Attempts to create them with diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index fd116b5343a..5708af2653c 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -136,9 +136,9 @@ import java.util.function.Supplier; * }} * * @author Doug Lea - * @since 1.8 * @param The result type returned by this future's {@code join} * and {@code get} methods + * @since 1.8 */ public class CompletableFuture implements Future, CompletionStage { @@ -521,7 +521,7 @@ public class CompletableFuture implements Future, CompletionStage { else break; } - else if (STACK.weakCompareAndSetVolatile(this, p, (p = p.next))) + else if (STACK.weakCompareAndSet(this, p, (p = p.next))) unlinked = true; else p = stack; @@ -532,7 +532,7 @@ public class CompletableFuture implements Future, CompletionStage { if (q.isLive()) { p = q; q = s; - } else if (NEXT.weakCompareAndSetVolatile(p, q, s)) + } else if (NEXT.weakCompareAndSet(p, q, s)) break; else q = p.next; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index e8193a00256..5c1c7069da7 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -330,7 +330,7 @@ public class ConcurrentLinkedDeque // for e to become an element of this deque, // and for newNode to become "live". if (p != h) // hop two nodes at a time; failure is OK - HEAD.weakCompareAndSetVolatile(this, h, newNode); + HEAD.weakCompareAndSet(this, h, newNode); return; } // Lost CAS race to another thread; re-read prev @@ -362,7 +362,7 @@ public class ConcurrentLinkedDeque // for e to become an element of this deque, // and for newNode to become "live". if (p != t) // hop two nodes at a time; failure is OK - TAIL.weakCompareAndSetVolatile(this, t, newNode); + TAIL.weakCompareAndSet(this, t, newNode); return; } // Lost CAS race to another thread; re-read next @@ -1153,12 +1153,12 @@ public class ConcurrentLinkedDeque if (NEXT.compareAndSet(p, null, beginningOfTheEnd)) { // Successful CAS is the linearization point // for all elements to be added to this deque. - if (!TAIL.weakCompareAndSetVolatile(this, t, last)) { + if (!TAIL.weakCompareAndSet(this, t, last)) { // Try a little harder to update tail, // since we may be adding many elements. t = tail; if (last.next == null) - TAIL.weakCompareAndSetVolatile(this, t, last); + TAIL.weakCompareAndSet(this, t, last); } return true; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index 1e3f1aad4f6..56ccb3317fa 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -308,7 +308,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue // for e to become an element of this queue, // and for newNode to become "live". if (p != t) // hop two nodes at a time; failure is OK - TAIL.weakCompareAndSetVolatile(this, t, newNode); + TAIL.weakCompareAndSet(this, t, newNode); return true; } // Lost CAS race to another thread; re-read next @@ -477,7 +477,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue next = succ(p); if (pred != null && next != null) // unlink - NEXT.weakCompareAndSetVolatile(pred, p, next); + NEXT.weakCompareAndSet(pred, p, next); if (removed) return true; } @@ -524,12 +524,12 @@ public class ConcurrentLinkedQueue extends AbstractQueue if (NEXT.compareAndSet(p, null, beginningOfTheEnd)) { // Successful CAS is the linearization point // for all elements to be added to this queue. - if (!TAIL.weakCompareAndSetVolatile(this, t, last)) { + if (!TAIL.weakCompareAndSet(this, t, last)) { // Try a little harder to update tail, // since we may be adding many elements. t = tail; if (last.next == null) - TAIL.weakCompareAndSetVolatile(this, t, last); + TAIL.weakCompareAndSet(this, t, last); } return true; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java b/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java index a61762b5669..0c809df9cf6 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java @@ -120,102 +120,114 @@ import java.lang.invoke.VarHandle; * to complete for some elements than others, either because of * intrinsic variation (for example I/O) or auxiliary effects such as * garbage collection. Because CountedCompleters provide their own - * continuations, other threads need not block waiting to perform - * them. + * continuations, other tasks need not block waiting to perform them. * - *

          For example, here is an initial version of a class that uses - * divide-by-two recursive decomposition to divide work into single - * pieces (leaf tasks). Even when work is split into individual calls, - * tree-based techniques are usually preferable to directly forking - * leaf tasks, because they reduce inter-thread communication and - * improve load balancing. In the recursive case, the second of each - * pair of subtasks to finish triggers completion of its parent + *

          For example, here is an initial version of a utility method that + * uses divide-by-two recursive decomposition to divide work into + * single pieces (leaf tasks). Even when work is split into individual + * calls, tree-based techniques are usually preferable to directly + * forking leaf tasks, because they reduce inter-thread communication + * and improve load balancing. In the recursive case, the second of + * each pair of subtasks to finish triggers completion of their parent * (because no result combination is performed, the default no-op * implementation of method {@code onCompletion} is not overridden). - * A static utility method sets up the base task and invokes it - * (here, implicitly using the {@link ForkJoinPool#commonPool()}). + * The utility method sets up the root task and invokes it (here, + * implicitly using the {@link ForkJoinPool#commonPool()}). It is + * straightforward and reliable (but not optimal) to always set the + * pending count to the number of child tasks and call {@code + * tryComplete()} immediately before returning. * *

           {@code
          - * class MyOperation { void apply(E e) { ... }  }
          - *
          - * class ForEach extends CountedCompleter {
          - *
          - *   public static  void forEach(E[] array, MyOperation op) {
          - *     new ForEach(null, array, op, 0, array.length).invoke();
          - *   }
          - *
          - *   final E[] array; final MyOperation op; final int lo, hi;
          - *   ForEach(CountedCompleter p, E[] array, MyOperation op, int lo, int hi) {
          - *     super(p);
          - *     this.array = array; this.op = op; this.lo = lo; this.hi = hi;
          - *   }
          - *
          - *   public void compute() { // version 1
          - *     if (hi - lo >= 2) {
          - *       int mid = (lo + hi) >>> 1;
          - *       setPendingCount(2); // must set pending count before fork
          - *       new ForEach(this, array, op, mid, hi).fork(); // right child
          - *       new ForEach(this, array, op, lo, mid).fork(); // left child
          + * public static  void forEach(E[] array, Consumer action) {
          + *   class Task extends CountedCompleter {
          + *     final int lo, hi;
          + *     Task(Task parent, int lo, int hi) {
          + *       super(parent); this.lo = lo; this.hi = hi;
          + *     }
          + *
          + *     public void compute() {
          + *       if (hi - lo >= 2) {
          + *         int mid = (lo + hi) >>> 1;
          + *         // must set pending count before fork
          + *         setPendingCount(2);
          + *         new Task(this, mid, hi).fork(); // right child
          + *         new Task(this, lo, mid).fork(); // left child
          + *       }
          + *       else if (hi > lo)
          + *         action.accept(array[lo]);
          + *       tryComplete();
            *     }
          - *     else if (hi > lo)
          - *       op.apply(array[lo]);
          - *     tryComplete();
            *   }
          + *   new Task(null, 0, array.length).invoke();
            * }}
          * * This design can be improved by noticing that in the recursive case, * the task has nothing to do after forking its right task, so can * directly invoke its left task before returning. (This is an analog - * of tail recursion removal.) Also, because the task returns upon - * executing its left task (rather than falling through to invoke - * {@code tryComplete}) the pending count is set to one: + * of tail recursion removal.) Also, when the last action in a task + * is to fork or invoke a subtask (a "tail call"), the call to {@code + * tryComplete()} can be optimized away, at the cost of making the + * pending count look "off by one". * *
           {@code
          - * class ForEach ... {
          - *   ...
          - *   public void compute() { // version 2
          - *     if (hi - lo >= 2) {
          - *       int mid = (lo + hi) >>> 1;
          - *       setPendingCount(1); // only one pending
          - *       new ForEach(this, array, op, mid, hi).fork(); // right child
          - *       new ForEach(this, array, op, lo, mid).compute(); // direct invoke
          - *     }
          - *     else {
          - *       if (hi > lo)
          - *         op.apply(array[lo]);
          - *       tryComplete();
          - *     }
          - *   }
          - * }}
          + * public void compute() { + * if (hi - lo >= 2) { + * int mid = (lo + hi) >>> 1; + * setPendingCount(1); // looks off by one, but correct! + * new Task(this, mid, hi).fork(); // right child + * new Task(this, lo, mid).compute(); // direct invoke + * } else { + * if (hi > lo) + * action.accept(array[lo]); + * tryComplete(); + * } + * }} * * As a further optimization, notice that the left task need not even exist. - * Instead of creating a new one, we can iterate using the original task, + * Instead of creating a new one, we can continue using the original task, * and add a pending count for each fork. Additionally, because no task * in this tree implements an {@link #onCompletion(CountedCompleter)} method, - * {@code tryComplete()} can be replaced with {@link #propagateCompletion}. + * {@code tryComplete} can be replaced with {@link #propagateCompletion}. * *
           {@code
          - * class ForEach ... {
          - *   ...
          - *   public void compute() { // version 3
          - *     int l = lo, h = hi;
          - *     while (h - l >= 2) {
          - *       int mid = (l + h) >>> 1;
          - *       addToPendingCount(1);
          - *       new ForEach(this, array, op, mid, h).fork(); // right child
          - *       h = mid;
          + *     public void compute() {
          + *       int n = hi - lo;
          + *       for (; n >= 2; n /= 2) {
          + *         addToPendingCount(1);
          + *         new Task(this, lo + n/2, lo + n).fork();
          + *       }
          + *       if (n > 0)
          + *         action.accept(array[lo]);
          + *       propagateCompletion();
          + *     }}
          + * + * When pending counts can be precomputed, they can be established in + * the constructor: + * + *
           {@code
          + * public static  void forEach(E[] array, Consumer action) {
          + *   class Task extends CountedCompleter {
          + *     final int lo, hi;
          + *     Task(Task parent, int lo, int hi) {
          + *       super(parent, 31 - Integer.numberOfLeadingZeros(hi - lo));
          + *       this.lo = lo; this.hi = hi;
          + *     }
          + *
          + *     public void compute() {
          + *       for (int n = hi - lo; n >= 2; n /= 2)
          + *         new Task(this, lo + n/2, lo + n).fork();
          + *       action.accept(array[lo]);
          + *       propagateCompletion();
            *     }
          - *     if (h > l)
          - *       op.apply(array[l]);
          - *     propagateCompletion();
            *   }
          + *   if (array.length > 0)
          + *     new Task(null, 0, array.length).invoke();
            * }}
          * - * Additional optimizations of such classes might entail precomputing - * pending counts so that they can be established in constructors, - * specializing classes for leaf steps, subdividing by say, four, - * instead of two per iteration, and using an adaptive threshold - * instead of always subdividing down to single elements. + * Additional optimizations of such classes might entail specializing + * classes for leaf steps, subdividing by say, four, instead of two + * per iteration, and using an adaptive threshold instead of always + * subdividing down to single elements. * *

          Searching. A tree of CountedCompleters can search for a * value or property in different parts of a data structure, and @@ -551,7 +563,7 @@ public abstract class CountedCompleter extends ForkJoinTask { public final int decrementPendingCountUnlessZero() { int c; do {} while ((c = pending) != 0 && - !PENDING.weakCompareAndSetVolatile(this, c, c - 1)); + !PENDING.weakCompareAndSet(this, c, c - 1)); return c; } @@ -584,7 +596,7 @@ public abstract class CountedCompleter extends ForkJoinTask { return; } } - else if (PENDING.weakCompareAndSetVolatile(a, c, c - 1)) + else if (PENDING.weakCompareAndSet(a, c, c - 1)) return; } } @@ -607,7 +619,7 @@ public abstract class CountedCompleter extends ForkJoinTask { return; } } - else if (PENDING.weakCompareAndSetVolatile(a, c, c - 1)) + else if (PENDING.weakCompareAndSet(a, c, c - 1)) return; } } @@ -652,7 +664,7 @@ public abstract class CountedCompleter extends ForkJoinTask { for (int c;;) { if ((c = pending) == 0) return this; - else if (PENDING.weakCompareAndSetVolatile(this, c, c - 1)) + else if (PENDING.weakCompareAndSet(this, c, c - 1)) return null; } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java b/jdk/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java index 5e018f1c327..beae1cabb90 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java @@ -132,10 +132,10 @@ import java.util.concurrent.locks.ReentrantLock; * happen-before actions following a successful return from the * corresponding {@code await()} in other threads. * - * @since 1.5 * @see CountDownLatch * * @author Doug Lea + * @since 1.5 */ public class CyclicBarrier { /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java index fe137386d45..9b53a8a54f9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java @@ -68,7 +68,7 @@ package java.util.concurrent; * private boolean subscribed; // true after first subscribe * public synchronized void subscribe(Subscriber subscriber) { * if (subscribed) - * subscriber.onError(new IllegalStateException()); // only one allowed + * subscriber.onError(new IllegalStateException()); // only one allowed * else { * subscribed = true; * subscriber.onSubscribe(new OneShotSubscription(subscriber, executor)); diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 9cc3aef305b..e8f7ac614df 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -42,15 +42,10 @@ import java.security.AccessControlContext; import java.security.Permissions; import java.security.ProtectionDomain; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.function.Predicate; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.CountedCompleter; -import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.ForkJoinWorkerThread; import java.util.concurrent.locks.LockSupport; /** @@ -135,7 +130,7 @@ import java.util.concurrent.locks.LockSupport; * * *

          The common pool is by default constructed with default - * parameters, but these may be controlled by setting three + * parameters, but these may be controlled by setting the following * {@linkplain System#getProperty system properties}: *

            *
          • {@code java.util.concurrent.ForkJoinPool.common.parallelism} @@ -1413,7 +1408,7 @@ public class ForkJoinPool extends AbstractExecutorService { } if (phase != QUIET) { // else pre-adjusted long c; // decrement counts - do {} while (!CTL.weakCompareAndSetVolatile + do {} while (!CTL.weakCompareAndSet (this, c = ctl, ((RC_MASK & (c - RC_UNIT)) | (TC_MASK & (c - TC_UNIT)) | (SP_MASK & c)))); @@ -1608,7 +1603,7 @@ public class ForkJoinPool extends AbstractExecutorService { do { w.stackPred = (int)(c = ctl); nc = ((c - RC_UNIT) & UC_MASK) | (SP_MASK & np); - } while (!CTL.weakCompareAndSetVolatile(this, c, nc)); + } while (!CTL.weakCompareAndSet(this, c, nc)); } else { // already queued int pred = w.stackPred; @@ -3246,7 +3241,7 @@ public class ForkJoinPool extends AbstractExecutorService { * An ACC to restrict permissions for the factory itself. * The constructed workers have no permissions set. */ - private static final AccessControlContext innocuousAcc; + private static final AccessControlContext INNOCUOUS_ACC; static { Permissions innocuousPerms = new Permissions(); innocuousPerms.add(modifyThreadPermission); @@ -3254,7 +3249,7 @@ public class ForkJoinPool extends AbstractExecutorService { "enableContextClassLoaderOverride")); innocuousPerms.add(new RuntimePermission( "modifyThreadGroup")); - innocuousAcc = new AccessControlContext(new ProtectionDomain[] { + INNOCUOUS_ACC = new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, innocuousPerms) }); } @@ -3265,7 +3260,7 @@ public class ForkJoinPool extends AbstractExecutorService { public ForkJoinWorkerThread run() { return new ForkJoinWorkerThread. InnocuousForkJoinWorkerThread(pool); - }}, innocuousAcc); + }}, INNOCUOUS_ACC); } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java index 82e773c7630..ec90f2334c9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java @@ -361,7 +361,7 @@ public class FutureTask implements RunnableFuture { private void finishCompletion() { // assert state > COMPLETING; for (WaitNode q; (q = waiters) != null;) { - if (WAITERS.weakCompareAndSetVolatile(this, q, null)) { + if (WAITERS.weakCompareAndSet(this, q, null)) { for (;;) { Thread t = q.thread; if (t != null) { @@ -423,7 +423,7 @@ public class FutureTask implements RunnableFuture { q = new WaitNode(); } else if (!queued) - queued = WAITERS.weakCompareAndSetVolatile(this, q.next = waiters, q); + queued = WAITERS.weakCompareAndSet(this, q.next = waiters, q); else if (timed) { final long parkNanos; if (startTime == 0L) { // first time diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java b/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java index c0e6fbadb01..043c0b2b2c8 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java @@ -456,7 +456,7 @@ public class Phaser { // finish registration whenever parent registration // succeeded, even when racing with termination, // since these are part of the same "transaction". - while (!STATE.weakCompareAndSetVolatile + while (!STATE.weakCompareAndSet (this, s, ((long)phase << PHASE_SHIFT) | adjust)) { s = state; @@ -488,7 +488,7 @@ public class Phaser { // CAS to root phase with current parties, tripping unarrived while ((phase = (int)(root.state >>> PHASE_SHIFT)) != (int)(s >>> PHASE_SHIFT) && - !STATE.weakCompareAndSetVolatile + !STATE.weakCompareAndSet (this, s, s = (((long)phase << PHASE_SHIFT) | ((phase < 0) ? (s & COUNTS_MASK) : diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java b/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java index 1298a6ee30d..f73c7fe2d5a 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java @@ -72,8 +72,8 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer; * protected synchronized Object getNextAvailableItem() { * for (int i = 0; i < MAX_AVAILABLE; ++i) { * if (!used[i]) { - * used[i] = true; - * return items[i]; + * used[i] = true; + * return items[i]; * } * } * return null; // not reached @@ -82,11 +82,11 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer; * protected synchronized boolean markAsUnused(Object item) { * for (int i = 0; i < MAX_AVAILABLE; ++i) { * if (item == items[i]) { - * if (used[i]) { - * used[i] = false; - * return true; - * } else - * return false; + * if (used[i]) { + * used[i] = false; + * return true; + * } else + * return false; * } * } * return false; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index 8ba78b3aeb8..5d96cae3f82 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -554,8 +554,9 @@ public class SubmissionPublisher implements Flow.Publisher, while (r != null) { BufferedSubscription nextRetry = r.nextRetry; r.nextRetry = null; - int stat = (nanos > 0L) ? r.timedOffer(item, nanos) : - r.offer(item); + int stat = (nanos > 0L) + ? r.timedOffer(item, nanos) + : r.offer(item); if (stat == 0 && onDrop != null && onDrop.test(r.subscriber, item)) stat = r.offer(item); @@ -1203,7 +1204,7 @@ public class SubmissionPublisher implements Flow.Publisher, } catch (RuntimeException | Error ex) { // back out do {} while (((c = ctl) & DISABLED) == 0 && (c & ACTIVE) != 0 && - !CTL.weakCompareAndSetVolatile + !CTL.weakCompareAndSet (this, c, c & ~ACTIVE)); throw ex; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java index d947a87cbd5..0016bfffe87 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java @@ -617,6 +617,9 @@ public class ThreadPoolExecutor extends AbstractExecutorService { /** Per-thread task counter */ volatile long completedTasks; + // TODO: switch to AbstractQueuedLongSynchronizer and move + // completedTasks into the lock word. + /** * Creates with given first task and thread from ThreadFactory. * @param firstTask the first task (null if none) diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java index 44b9e5aea68..9410db99bc4 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java @@ -106,16 +106,16 @@ public class AtomicBoolean implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value * @return {@code true} if successful */ public boolean weakCompareAndSet(boolean expectedValue, boolean newValue) { - return VALUE.weakCompareAndSet(this, - (expectedValue ? 1 : 0), - (newValue ? 1 : 0)); + return VALUE.weakCompareAndSetPlain(this, + (expectedValue ? 1 : 0), + (newValue ? 1 : 0)); } /** @@ -285,7 +285,7 @@ public class AtomicBoolean implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} if the current * value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value @@ -293,9 +293,9 @@ public class AtomicBoolean implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(boolean expectedValue, boolean newValue) { - return VALUE.weakCompareAndSetVolatile(this, - (expectedValue ? 1 : 0), - (newValue ? 1 : 0)); + return VALUE.weakCompareAndSet(this, + (expectedValue ? 1 : 0), + (newValue ? 1 : 0)); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java index fa7af454788..4e4c51eb53a 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java @@ -146,7 +146,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value @@ -193,7 +193,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { /** * Atomically increments the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(1)}. * @@ -205,7 +205,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { /** * Atomically decrements the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(-1)}. * @@ -217,7 +217,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { /** * Atomically adds the given value to the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param delta the value to add * @return the updated value @@ -490,7 +490,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} if * the current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java index 301aa4a5844..8bce29b6f95 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java @@ -149,7 +149,7 @@ public class AtomicIntegerArray implements java.io.Serializable { /** * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param i the index * @param expectedValue the expected value @@ -157,7 +157,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * @return {@code true} if successful */ public final boolean weakCompareAndSet(int i, int expectedValue, int newValue) { - return AA.weakCompareAndSet(array, i, expectedValue, newValue); + return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue); } /** @@ -200,7 +200,7 @@ public class AtomicIntegerArray implements java.io.Serializable { /** * Atomically increments the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(i, 1)}. * @@ -208,12 +208,12 @@ public class AtomicIntegerArray implements java.io.Serializable { * @return the updated value */ public final int incrementAndGet(int i) { - return (int)AA.addAndGet(array, i, 1); + return (int)AA.getAndAdd(array, i, 1) + 1; } /** * Atomically decrements the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(i, -1)}. * @@ -221,19 +221,19 @@ public class AtomicIntegerArray implements java.io.Serializable { * @return the updated value */ public final int decrementAndGet(int i) { - return (int)AA.addAndGet(array, i, -1); + return (int)AA.getAndAdd(array, i, -1) - 1; } /** * Atomically adds the given value to the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param i the index * @param delta the value to add * @return the updated value */ public final int addAndGet(int i, int delta) { - return (int)AA.addAndGet(array, i, delta); + return (int)AA.getAndAdd(array, i, delta) + delta; } /** @@ -489,7 +489,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param i the index * @param expectedValue the expected value @@ -498,7 +498,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int i, int expectedValue, int newValue) { - return AA.weakCompareAndSetVolatile(array, i, expectedValue, newValue); + return AA.weakCompareAndSet(array, i, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java index 726e7a3b7e3..5ee7104fdb8 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java @@ -162,7 +162,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value @@ -209,7 +209,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Atomically increments the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(1)}. * @@ -221,7 +221,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Atomically decrements the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(-1)}. * @@ -233,7 +233,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Atomically adds the given value to the current value, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param delta the value to add * @return the updated value @@ -504,7 +504,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java index 3d584cf44e0..84182c44f74 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java @@ -149,7 +149,7 @@ public class AtomicLongArray implements java.io.Serializable { /** * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param i the index * @param expectedValue the expected value @@ -157,7 +157,7 @@ public class AtomicLongArray implements java.io.Serializable { * @return {@code true} if successful */ public final boolean weakCompareAndSet(int i, long expectedValue, long newValue) { - return AA.weakCompareAndSet(array, i, expectedValue, newValue); + return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue); } /** @@ -200,7 +200,7 @@ public class AtomicLongArray implements java.io.Serializable { /** * Atomically increments the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(i, 1)}. * @@ -208,12 +208,12 @@ public class AtomicLongArray implements java.io.Serializable { * @return the updated value */ public final long incrementAndGet(int i) { - return (long)AA.addAndGet(array, i, 1L); + return (long)AA.getAndAdd(array, i, 1L) + 1L; } /** * Atomically decrements the value of the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * *

            Equivalent to {@code addAndGet(i, -1)}. * @@ -221,19 +221,19 @@ public class AtomicLongArray implements java.io.Serializable { * @return the updated value */ public final long decrementAndGet(int i) { - return (long)AA.addAndGet(array, i, -1L); + return (long)AA.getAndAdd(array, i, -1L) - 1L; } /** * Atomically adds the given value to the element at index {@code i}, - * with memory effects as specified by {@link VarHandle#addAndGet}. + * with memory effects as specified by {@link VarHandle#getAndAdd}. * * @param i the index * @param delta the value to add * @return the updated value */ public long addAndGet(int i, long delta) { - return (long)AA.addAndGet(array, i, delta); + return (long)AA.getAndAdd(array, i, delta) + delta; } /** @@ -489,7 +489,7 @@ public class AtomicLongArray implements java.io.Serializable { * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param i the index * @param expectedValue the expected value @@ -498,7 +498,7 @@ public class AtomicLongArray implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int i, long expectedValue, long newValue) { - return AA.weakCompareAndSetVolatile(array, i, expectedValue, newValue); + return AA.weakCompareAndSet(array, i, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java index d8bd6e4a7bc..0098d31bf2e 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java @@ -125,14 +125,14 @@ public class AtomicReference implements java.io.Serializable { /** * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param expectedValue the expected value * @param newValue the new value * @return {@code true} if successful */ public final boolean weakCompareAndSet(V expectedValue, V newValue) { - return VALUE.weakCompareAndSet(this, expectedValue, newValue); + return VALUE.weakCompareAndSetPlain(this, expectedValue, newValue); } /** @@ -370,7 +370,7 @@ public class AtomicReference implements java.io.Serializable { * Possibly atomically sets the value to {@code newValue} * if the current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param expectedValue the expected value * @param newValue the new value @@ -378,7 +378,7 @@ public class AtomicReference implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(V expectedValue, V newValue) { - return VALUE.weakCompareAndSetVolatile(this, expectedValue, newValue); + return VALUE.weakCompareAndSet(this, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java index 34bb0f135da..998f167d5cc 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java @@ -155,7 +155,7 @@ public class AtomicReferenceArray implements java.io.Serializable { /** * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, - * with memory effects as specified by {@link VarHandle#weakCompareAndSet}. + * with memory effects as specified by {@link VarHandle#weakCompareAndSetPlain}. * * @param i the index * @param expectedValue the expected value @@ -163,7 +163,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * @return {@code true} if successful */ public final boolean weakCompareAndSet(int i, E expectedValue, E newValue) { - return AA.weakCompareAndSet(array, i, expectedValue, newValue); + return AA.weakCompareAndSetPlain(array, i, expectedValue, newValue); } /** @@ -451,7 +451,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * Possibly atomically sets the element at index {@code i} to * {@code newValue} if the element's current value {@code == expectedValue}, * with memory effects as specified by - * {@link VarHandle#weakCompareAndSetVolatile}. + * {@link VarHandle#weakCompareAndSet}. * * @param i the index * @param expectedValue the expected value @@ -460,7 +460,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int i, E expectedValue, E newValue) { - return AA.weakCompareAndSetVolatile(array, i, expectedValue, newValue); + return AA.weakCompareAndSet(array, i, expectedValue, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java index 24be8fbe580..18fac82b111 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java @@ -154,13 +154,13 @@ import jdk.internal.vm.annotation.ReservedStackAccess; * long stamp = sl.tryOptimisticRead(); * double currentX = x, currentY = y; * if (!sl.validate(stamp)) { - * stamp = sl.readLock(); - * try { - * currentX = x; - * currentY = y; - * } finally { - * sl.unlockRead(stamp); - * } + * stamp = sl.readLock(); + * try { + * currentX = x; + * currentY = y; + * } finally { + * sl.unlockRead(stamp); + * } * } * return Math.sqrt(currentX * currentX + currentY * currentY); * } @@ -1123,14 +1123,14 @@ public class StampedLock implements java.io.Serializable { } else if ((p = wtail) == null) { // initialize queue WNode hd = new WNode(WMODE, null); - if (WHEAD.weakCompareAndSetVolatile(this, null, hd)) + if (WHEAD.weakCompareAndSet(this, null, hd)) wtail = hd; } else if (node == null) node = new WNode(WMODE, p); else if (node.prev != p) node.prev = p; - else if (WTAIL.weakCompareAndSetVolatile(this, p, node)) { + else if (WTAIL.weakCompareAndSet(this, p, node)) { p.next = node; break; } @@ -1162,7 +1162,7 @@ public class StampedLock implements java.io.Serializable { else if (h != null) { // help release stale waiters WNode c; Thread w; while ((c = h.cowait) != null) { - if (WCOWAIT.weakCompareAndSetVolatile(h, c, c.cowait) && + if (WCOWAIT.weakCompareAndSet(h, c, c.cowait) && (w = c.thread) != null) LockSupport.unpark(w); } @@ -1247,7 +1247,7 @@ public class StampedLock implements java.io.Serializable { } if (p == null) { // initialize queue WNode hd = new WNode(WMODE, null); - if (WHEAD.weakCompareAndSetVolatile(this, null, hd)) + if (WHEAD.weakCompareAndSet(this, null, hd)) wtail = hd; } else if (node == null) @@ -1255,7 +1255,7 @@ public class StampedLock implements java.io.Serializable { else if (h == p || p.mode != RMODE) { if (node.prev != p) node.prev = p; - else if (WTAIL.weakCompareAndSetVolatile(this, p, node)) { + else if (WTAIL.weakCompareAndSet(this, p, node)) { p.next = node; break; } diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java index 2c4500d169b..081fefd58ab 100644 --- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java @@ -836,18 +836,25 @@ class JarFile extends ZipFile { private static final byte[] CLASSPATH_CHARS = {'C','L','A','S','S','-','P','A','T','H', ':', ' '}; - // The bad character shift for "class-path:" + // The bad character shift for "class-path: " private static final byte[] CLASSPATH_LASTOCC; + // The good suffix shift for "class-path: " + private static final byte[] CLASSPATH_OPTOSFT; + private static final byte[] MULTIRELEASE_CHARS = {'M','U','L','T','I','-','R','E','L','E', 'A', 'S', 'E', ':', ' ', 'T', 'R', 'U', 'E'}; - // The bad character shift for "multi-release: " + // The bad character shift for "multi-release: true" private static final byte[] MULTIRELEASE_LASTOCC; + // The good suffix shift for "multi-release: true" + private static final byte[] MULTIRELEASE_OPTOSFT; + static { CLASSPATH_LASTOCC = new byte[64]; + CLASSPATH_OPTOSFT = new byte[12]; CLASSPATH_LASTOCC[(int)'C' - 32] = 1; CLASSPATH_LASTOCC[(int)'L' - 32] = 2; CLASSPATH_LASTOCC[(int)'S' - 32] = 5; @@ -858,8 +865,13 @@ class JarFile extends ZipFile { CLASSPATH_LASTOCC[(int)'H' - 32] = 10; CLASSPATH_LASTOCC[(int)':' - 32] = 11; CLASSPATH_LASTOCC[(int)' ' - 32] = 12; + for (int i = 0; i < 11; i++) { + CLASSPATH_OPTOSFT[i] = 12; + } + CLASSPATH_OPTOSFT[11] = 1; MULTIRELEASE_LASTOCC = new byte[64]; + MULTIRELEASE_OPTOSFT = new byte[19]; MULTIRELEASE_LASTOCC[(int)'M' - 32] = 1; MULTIRELEASE_LASTOCC[(int)'I' - 32] = 5; MULTIRELEASE_LASTOCC[(int)'-' - 32] = 6; @@ -872,6 +884,11 @@ class JarFile extends ZipFile { MULTIRELEASE_LASTOCC[(int)'R' - 32] = 17; MULTIRELEASE_LASTOCC[(int)'U' - 32] = 18; MULTIRELEASE_LASTOCC[(int)'E' - 32] = 19; + for (int i = 0; i < 17; i++) { + MULTIRELEASE_OPTOSFT[i] = 19; + } + MULTIRELEASE_OPTOSFT[17] = 6; + MULTIRELEASE_OPTOSFT[18] = 1; } private JarEntry getManEntry() { @@ -913,7 +930,7 @@ class JarFile extends ZipFile { * Since there are no repeated substring in our search strings, * the good suffix shifts can be replaced with a comparison. */ - private int match(byte[] src, byte[] b, byte[] lastOcc) { + private int match(byte[] src, byte[] b, byte[] lastOcc, byte[] optoSft) { int len = src.length; int last = b.length - len; int i = 0; @@ -926,9 +943,8 @@ class JarFile extends ZipFile { if (c != src[j]) { // no match - int goodShift = (j < len - 1) ? len : 1; int badShift = lastOcc[c - 32]; - i += Math.max(j + 1 - badShift, goodShift); + i += Math.max(j + 1 - badShift, optoSft[j]); continue next; } } else { @@ -958,10 +974,11 @@ class JarFile extends ZipFile { if (manEntry != null) { byte[] b = getBytes(manEntry); hasClassPathAttribute = match(CLASSPATH_CHARS, b, - CLASSPATH_LASTOCC) != -1; + CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT) != -1; // is this a multi-release jar file if (MULTI_RELEASE_ENABLED) { - int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC); + int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC, + MULTIRELEASE_OPTOSFT); if (i != -1) { i += MULTIRELEASE_CHARS.length; if (i < b.length) { diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java index 59f669baf67..2bc146c8d5f 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java @@ -567,19 +567,23 @@ public interface DoubleStream extends BaseStream { *

            This is a terminal * operation. * - * @param type of the result - * @param supplier a function that creates a new result container. For a - * parallel execution, this function may be called + * @param the type of the mutable result container + * @param supplier a function that creates a new mutable result container. + * For a parallel execution, this function may be called * multiple times and must return a fresh value each time. * @param accumulator an associative, * non-interfering, * stateless - * function for incorporating an additional element into a result + * function that must fold an element into a result + * container. * @param combiner an associative, * non-interfering, * stateless - * function for combining two values, which must be - * compatible with the accumulator function + * function that accepts two partial result containers + * and merges them, which must be compatible with the + * accumulator function. The combiner function must fold + * the elements from the second result container into the + * first result container. * @return the result of the reduction * @see Stream#collect(Supplier, BiConsumer, BiConsumer) */ @@ -947,6 +951,12 @@ public interface DoubleStream extends BaseStream { * position {@code n}, will be the result of applying the function {@code f} * to the element at position {@code n - 1}. * + *

            The action of applying {@code f} for one element + * happens-before + * the action of applying {@code f} for subsequent elements. For any given + * element the action may be performed in whatever thread the library + * chooses. + * * @param seed the initial element * @param f a function to be applied to the previous element to produce * a new element @@ -978,37 +988,44 @@ public interface DoubleStream extends BaseStream { /** * Returns a sequential ordered {@code DoubleStream} produced by iterative - * application of a function to an initial element, conditioned on - * satisfying the supplied predicate. The stream terminates as soon as - * the predicate returns false. + * application of the given {@code next} function to an initial element, + * conditioned on satisfying the given {@code hasNext} predicate. The + * stream terminates as soon as the {@code hasNext} predicate returns false. * - *

            - * {@code DoubleStream.iterate} should produce the same sequence of - * elements as produced by the corresponding for-loop: + *

            {@code DoubleStream.iterate} should produce the same sequence of elements as + * produced by the corresponding for-loop: *

            {@code
            -     *     for (double index=seed; predicate.test(index); index = f.applyAsDouble(index)) {
            +     *     for (double index=seed; hasNext.test(index); index = next.applyAsDouble(index)) {
                  *         ...
                  *     }
                  * }
            * - *

            - * The resulting sequence may be empty if the predicate does not hold on - * the seed value. Otherwise the first element will be the supplied seed - * value, the next element (if present) will be the result of applying the - * function f to the seed value, and so on iteratively until the predicate - * indicates that the stream should terminate. + *

            The resulting sequence may be empty if the {@code hasNext} predicate + * does not hold on the seed value. Otherwise the first element will be the + * supplied {@code seed} value, the next element (if present) will be the + * result of applying the {@code next} function to the {@code seed} value, + * and so on iteratively until the {@code hasNext} predicate indicates that + * the stream should terminate. + * + *

            The action of applying the {@code hasNext} predicate to an element + * happens-before + * the action of applying the {@code next} function to that element. The + * action of applying the {@code next} function for one element + * happens-before the action of applying the {@code hasNext} + * predicate for subsequent elements. For any given element an action may + * be performed in whatever thread the library chooses. * * @param seed the initial element - * @param predicate a predicate to apply to elements to determine when the - * stream must terminate. - * @param f a function to be applied to the previous element to produce - * a new element + * @param hasNext a predicate to apply to elements to determine when the + * stream must terminate. + * @param next a function to be applied to the previous element to produce + * a new element * @return a new sequential {@code DoubleStream} * @since 9 */ - public static DoubleStream iterate(double seed, DoublePredicate predicate, DoubleUnaryOperator f) { - Objects.requireNonNull(f); - Objects.requireNonNull(predicate); + public static DoubleStream iterate(double seed, DoublePredicate hasNext, DoubleUnaryOperator next) { + Objects.requireNonNull(next); + Objects.requireNonNull(hasNext); Spliterator.OfDouble spliterator = new Spliterators.AbstractDoubleSpliterator(Long.MAX_VALUE, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) { double prev; @@ -1021,12 +1038,12 @@ public interface DoubleStream extends BaseStream { return false; double t; if (started) - t = f.applyAsDouble(prev); + t = next.applyAsDouble(prev); else { t = seed; started = true; } - if (!predicate.test(t)) { + if (!hasNext.test(t)) { finished = true; return false; } @@ -1040,10 +1057,10 @@ public interface DoubleStream extends BaseStream { if (finished) return; finished = true; - double t = started ? f.applyAsDouble(prev) : seed; - while (predicate.test(t)) { + double t = started ? next.applyAsDouble(prev) : seed; + while (hasNext.test(t)) { action.accept(t); - t = f.applyAsDouble(t); + t = next.applyAsDouble(t); } } }; diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java index daeac3ab140..c051a12bec7 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java @@ -562,19 +562,23 @@ public interface IntStream extends BaseStream { *

            This is a terminal * operation. * - * @param type of the result - * @param supplier a function that creates a new result container. For a - * parallel execution, this function may be called + * @param the type of the mutable result container + * @param supplier a function that creates a new mutable result container. + * For a parallel execution, this function may be called * multiple times and must return a fresh value each time. * @param accumulator an associative, * non-interfering, * stateless - * function for incorporating an additional element into a result + * function that must fold an element into a result + * container. * @param combiner an associative, * non-interfering, * stateless - * function for combining two values, which must be - * compatible with the accumulator function + * function that accepts two partial result containers + * and merges them, which must be compatible with the + * accumulator function. The combiner function must fold + * the elements from the second result container into the + * first result container. * @return the result of the reduction * @see Stream#collect(Supplier, BiConsumer, BiConsumer) */ @@ -887,6 +891,12 @@ public interface IntStream extends BaseStream { * {@code n}, will be the result of applying the function {@code f} to the * element at position {@code n - 1}. * + *

            The action of applying {@code f} for one element + * happens-before + * the action of applying {@code f} for subsequent elements. For any given + * element the action may be performed in whatever thread the library + * chooses. + * * @param seed the initial element * @param f a function to be applied to the previous element to produce * a new element @@ -918,37 +928,44 @@ public interface IntStream extends BaseStream { /** * Returns a sequential ordered {@code IntStream} produced by iterative - * application of a function to an initial element, conditioned on - * satisfying the supplied predicate. The stream terminates as soon as - * the predicate returns false. + * application of the given {@code next} function to an initial element, + * conditioned on satisfying the given {@code hasNext} predicate. The + * stream terminates as soon as the {@code hasNext} predicate returns false. * - *

            - * {@code IntStream.iterate} should produce the same sequence of elements - * as produced by the corresponding for-loop: + *

            {@code IntStream.iterate} should produce the same sequence of elements as + * produced by the corresponding for-loop: *

            {@code
            -     *     for (int index=seed; predicate.test(index); index = f.applyAsInt(index)) {
            +     *     for (int index=seed; hasNext.test(index); index = next.applyAsInt(index)) {
                  *         ...
                  *     }
                  * }
            * - *

            - * The resulting sequence may be empty if the predicate does not hold on - * the seed value. Otherwise the first element will be the supplied seed - * value, the next element (if present) will be the result of applying the - * function f to the seed value, and so on iteratively until the predicate - * indicates that the stream should terminate. + *

            The resulting sequence may be empty if the {@code hasNext} predicate + * does not hold on the seed value. Otherwise the first element will be the + * supplied {@code seed} value, the next element (if present) will be the + * result of applying the {@code next} function to the {@code seed} value, + * and so on iteratively until the {@code hasNext} predicate indicates that + * the stream should terminate. + * + *

            The action of applying the {@code hasNext} predicate to an element + * happens-before + * the action of applying the {@code next} function to that element. The + * action of applying the {@code next} function for one element + * happens-before the action of applying the {@code hasNext} + * predicate for subsequent elements. For any given element an action may + * be performed in whatever thread the library chooses. * * @param seed the initial element - * @param predicate a predicate to apply to elements to determine when the - * stream must terminate. - * @param f a function to be applied to the previous element to produce - * a new element + * @param hasNext a predicate to apply to elements to determine when the + * stream must terminate. + * @param next a function to be applied to the previous element to produce + * a new element * @return a new sequential {@code IntStream} * @since 9 */ - public static IntStream iterate(int seed, IntPredicate predicate, IntUnaryOperator f) { - Objects.requireNonNull(f); - Objects.requireNonNull(predicate); + public static IntStream iterate(int seed, IntPredicate hasNext, IntUnaryOperator next) { + Objects.requireNonNull(next); + Objects.requireNonNull(hasNext); Spliterator.OfInt spliterator = new Spliterators.AbstractIntSpliterator(Long.MAX_VALUE, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) { int prev; @@ -961,12 +978,12 @@ public interface IntStream extends BaseStream { return false; int t; if (started) - t = f.applyAsInt(prev); + t = next.applyAsInt(prev); else { t = seed; started = true; } - if (!predicate.test(t)) { + if (!hasNext.test(t)) { finished = true; return false; } @@ -980,10 +997,10 @@ public interface IntStream extends BaseStream { if (finished) return; finished = true; - int t = started ? f.applyAsInt(prev) : seed; - while (predicate.test(t)) { + int t = started ? next.applyAsInt(prev) : seed; + while (hasNext.test(t)) { action.accept(t); - t = f.applyAsInt(t); + t = next.applyAsInt(t); } } }; diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java index d6428d55df5..bbdc1d00e0c 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java @@ -564,19 +564,23 @@ public interface LongStream extends BaseStream { *

            This is a terminal * operation. * - * @param type of the result - * @param supplier a function that creates a new result container. For a - * parallel execution, this function may be called + * @param the type of the mutable result container + * @param supplier a function that creates a new mutable result container. + * For a parallel execution, this function may be called * multiple times and must return a fresh value each time. * @param accumulator an associative, * non-interfering, * stateless - * function for incorporating an additional element into a result + * function that must fold an element into a result + * container. * @param combiner an associative, * non-interfering, * stateless - * function for combining two values, which must be - * compatible with the accumulator function + * function that accepts two partial result containers + * and merges them, which must be compatible with the + * accumulator function. The combiner function must fold + * the elements from the second result container into the + * first result container. * @return the result of the reduction * @see Stream#collect(Supplier, BiConsumer, BiConsumer) */ @@ -877,6 +881,12 @@ public interface LongStream extends BaseStream { * {@code n}, will be the result of applying the function {@code f} to the * element at position {@code n - 1}. * + *

            The action of applying {@code f} for one element + * happens-before + * the action of applying {@code f} for subsequent elements. For any given + * element the action may be performed in whatever thread the library + * chooses. + * * @param seed the initial element * @param f a function to be applied to the previous element to produce * a new element @@ -908,37 +918,44 @@ public interface LongStream extends BaseStream { /** * Returns a sequential ordered {@code LongStream} produced by iterative - * application of a function to an initial element, conditioned on - * satisfying the supplied predicate. The stream terminates as soon as - * the predicate returns false. + * application of the given {@code next} function to an initial element, + * conditioned on satisfying the given {@code hasNext} predicate. The + * stream terminates as soon as the {@code hasNext} predicate returns false. * - *

            - * {@code LongStream.iterate} should produce the same sequence of elements - * as produced by the corresponding for-loop: + *

            {@code LongStream.iterate} should produce the same sequence of elements as + * produced by the corresponding for-loop: *

            {@code
            -     *     for (long index=seed; predicate.test(index); index = f.applyAsLong(index)) {
            +     *     for (long index=seed; hasNext.test(index); index = next.applyAsLong(index)) {
                  *         ...
                  *     }
                  * }
            * - *

            - * The resulting sequence may be empty if the predicate does not hold on - * the seed value. Otherwise the first element will be the supplied seed - * value, the next element (if present) will be the result of applying the - * function f to the seed value, and so on iteratively until the predicate - * indicates that the stream should terminate. + *

            The resulting sequence may be empty if the {@code hasNext} predicate + * does not hold on the seed value. Otherwise the first element will be the + * supplied {@code seed} value, the next element (if present) will be the + * result of applying the {@code next} function to the {@code seed} value, + * and so on iteratively until the {@code hasNext} predicate indicates that + * the stream should terminate. + * + *

            The action of applying the {@code hasNext} predicate to an element + * happens-before + * the action of applying the {@code next} function to that element. The + * action of applying the {@code next} function for one element + * happens-before the action of applying the {@code hasNext} + * predicate for subsequent elements. For any given element an action may + * be performed in whatever thread the library chooses. * * @param seed the initial element - * @param predicate a predicate to apply to elements to determine when the - * stream must terminate. - * @param f a function to be applied to the previous element to produce - * a new element + * @param hasNext a predicate to apply to elements to determine when the + * stream must terminate. + * @param next a function to be applied to the previous element to produce + * a new element * @return a new sequential {@code LongStream} * @since 9 */ - public static LongStream iterate(long seed, LongPredicate predicate, LongUnaryOperator f) { - Objects.requireNonNull(f); - Objects.requireNonNull(predicate); + public static LongStream iterate(long seed, LongPredicate hasNext, LongUnaryOperator next) { + Objects.requireNonNull(next); + Objects.requireNonNull(hasNext); Spliterator.OfLong spliterator = new Spliterators.AbstractLongSpliterator(Long.MAX_VALUE, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) { long prev; @@ -951,12 +968,12 @@ public interface LongStream extends BaseStream { return false; long t; if (started) - t = f.applyAsLong(prev); + t = next.applyAsLong(prev); else { t = seed; started = true; } - if (!predicate.test(t)) { + if (!hasNext.test(t)) { finished = true; return false; } @@ -970,10 +987,10 @@ public interface LongStream extends BaseStream { if (finished) return; finished = true; - long t = started ? f.applyAsLong(prev) : seed; - while (predicate.test(t)) { + long t = started ? next.applyAsLong(prev) : seed; + while (hasNext.test(t)) { action.accept(t); - t = f.applyAsLong(t); + t = next.applyAsLong(t); } } }; diff --git a/jdk/src/java.base/share/classes/java/util/stream/Stream.java b/jdk/src/java.base/share/classes/java/util/stream/Stream.java index 7ab71a50aee..1ec21ed2b57 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java @@ -882,19 +882,23 @@ public interface Stream extends BaseStream> { * .toString(); * } * - * @param type of the result - * @param supplier a function that creates a new result container. For a - * parallel execution, this function may be called + * @param the type of the mutable result container + * @param supplier a function that creates a new mutable result container. + * For a parallel execution, this function may be called * multiple times and must return a fresh value each time. * @param accumulator an associative, * non-interfering, * stateless - * function for incorporating an additional element into a result + * function that must fold an element into a result + * container. * @param combiner an associative, * non-interfering, * stateless - * function for combining two values, which must be - * compatible with the accumulator function + * function that accepts two partial result containers + * and merges them, which must be compatible with the + * accumulator function. The combiner function must fold + * the elements from the second result container into the + * first result container. * @return the result of the reduction */ R collect(Supplier supplier, @@ -1194,6 +1198,12 @@ public interface Stream extends BaseStream> { * {@code n}, will be the result of applying the function {@code f} to the * element at position {@code n - 1}. * + *

            The action of applying {@code f} for one element + * happens-before + * the action of applying {@code f} for subsequent elements. For any given + * element the action may be performed in whatever thread the library + * chooses. + * * @param the type of stream elements * @param seed the initial element * @param f a function to be applied to the previous element to produce @@ -1226,38 +1236,45 @@ public interface Stream extends BaseStream> { /** * Returns a sequential ordered {@code Stream} produced by iterative - * application of a function to an initial element, conditioned on - * satisfying the supplied predicate. The stream terminates as soon as - * the predicate returns false. + * application of the given {@code next} function to an initial element, + * conditioned on satisfying the given {@code hasNext} predicate. The + * stream terminates as soon as the {@code hasNext} predicate returns false. * - *

            - * {@code Stream.iterate} should produce the same sequence of elements as + *

            {@code Stream.iterate} should produce the same sequence of elements as * produced by the corresponding for-loop: *

            {@code
            -     *     for (T index=seed; predicate.test(index); index = f.apply(index)) {
            +     *     for (T index=seed; hasNext.test(index); index = next.apply(index)) {
                  *         ...
                  *     }
                  * }
            * - *

            - * The resulting sequence may be empty if the predicate does not hold on - * the seed value. Otherwise the first element will be the supplied seed - * value, the next element (if present) will be the result of applying the - * function f to the seed value, and so on iteratively until the predicate - * indicates that the stream should terminate. + *

            The resulting sequence may be empty if the {@code hasNext} predicate + * does not hold on the seed value. Otherwise the first element will be the + * supplied {@code seed} value, the next element (if present) will be the + * result of applying the {@code next} function to the {@code seed} value, + * and so on iteratively until the {@code hasNext} predicate indicates that + * the stream should terminate. + * + *

            The action of applying the {@code hasNext} predicate to an element + * happens-before + * the action of applying the {@code next} function to that element. The + * action of applying the {@code next} function for one element + * happens-before the action of applying the {@code hasNext} + * predicate for subsequent elements. For any given element an action may + * be performed in whatever thread the library chooses. * * @param the type of stream elements * @param seed the initial element - * @param predicate a predicate to apply to elements to determine when the - * stream must terminate. - * @param f a function to be applied to the previous element to produce - * a new element + * @param hasNext a predicate to apply to elements to determine when the + * stream must terminate. + * @param next a function to be applied to the previous element to produce + * a new element * @return a new sequential {@code Stream} * @since 9 */ - public static Stream iterate(T seed, Predicate predicate, UnaryOperator f) { - Objects.requireNonNull(f); - Objects.requireNonNull(predicate); + public static Stream iterate(T seed, Predicate hasNext, UnaryOperator next) { + Objects.requireNonNull(next); + Objects.requireNonNull(hasNext); Spliterator spliterator = new Spliterators.AbstractSpliterator<>(Long.MAX_VALUE, Spliterator.ORDERED | Spliterator.IMMUTABLE) { T prev; @@ -1270,12 +1287,12 @@ public interface Stream extends BaseStream> { return false; T t; if (started) - t = f.apply(prev); + t = next.apply(prev); else { t = seed; started = true; } - if (!predicate.test(t)) { + if (!hasNext.test(t)) { prev = null; finished = true; return false; @@ -1290,11 +1307,11 @@ public interface Stream extends BaseStream> { if (finished) return; finished = true; - T t = started ? f.apply(prev) : seed; + T t = started ? next.apply(prev) : seed; prev = null; - while (predicate.test(t)) { + while (hasNext.test(t)) { action.accept(t); - t = f.apply(t); + t = next.apply(t); } } }; diff --git a/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorRulesProvider.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java similarity index 71% rename from jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorRulesProvider.java rename to jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java index 4bbb1cec212..39dd153731e 100644 --- a/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorRulesProvider.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,19 @@ * questions. */ -package sun.text.resources; +package jdk.internal.misc; -import java.util.spi.ResourceBundleProvider; +import java.net.ServerSocket; +import java.net.SocketImpl; -/** - * An interface for the internal locale data provider for which {@code ResourceBundle} - * searches. - */ -public interface BreakIteratorRulesProvider extends ResourceBundleProvider { +public interface JavaNetSocketAccess { + /** + * Creates a ServerSocket associated with the given SocketImpl. + */ + ServerSocket newServerSocket(SocketImpl impl); + + /* + * Constructs a SocketImpl instance of the given class. + */ + SocketImpl newSocketImpl(Class implClass); } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java index fed1b694548..052d1119f09 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java @@ -55,6 +55,7 @@ public class SharedSecrets { private static JavaNetAccess javaNetAccess; private static JavaNetInetAddressAccess javaNetInetAddressAccess; private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; + private static JavaNetSocketAccess javaNetSocketAccess; private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; @@ -161,6 +162,16 @@ public class SharedSecrets { return javaNetHttpCookieAccess; } + public static void setJavaNetSocketAccess(JavaNetSocketAccess jnsa) { + javaNetSocketAccess = jnsa; + } + + public static JavaNetSocketAccess getJavaNetSocketAccess() { + if (javaNetSocketAccess == null) + unsafe.ensureClassInitialized(java.net.ServerSocket.class); + return javaNetSocketAccess; + } + public static void setJavaNioAccess(JavaNioAccess jna) { javaNioAccess = jna; } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index d37b3e7de5b..f86f5ab69d3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -2278,6 +2278,24 @@ public final class Unsafe { return v; } + @ForceInline + public final int getAndAddIntRelease(Object o, long offset, int delta) { + int v; + do { + v = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, v, v + delta)); + return v; + } + + @ForceInline + public final int getAndAddIntAcquire(Object o, long offset, int delta) { + int v; + do { + v = getIntAcquire(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, v, v + delta)); + return v; + } + /** * Atomically adds the given value to the current value of a field * or array element within the given object {@code o} @@ -2298,6 +2316,24 @@ public final class Unsafe { return v; } + @ForceInline + public final long getAndAddLongRelease(Object o, long offset, long delta) { + long v; + do { + v = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, v, v + delta)); + return v; + } + + @ForceInline + public final long getAndAddLongAcquire(Object o, long offset, long delta) { + long v; + do { + v = getLongAcquire(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, v, v + delta)); + return v; + } + @HotSpotIntrinsicCandidate public final byte getAndAddByte(Object o, long offset, byte delta) { byte v; @@ -2307,6 +2343,24 @@ public final class Unsafe { return v; } + @ForceInline + public final byte getAndAddByteRelease(Object o, long offset, byte delta) { + byte v; + do { + v = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, v, (byte) (v + delta))); + return v; + } + + @ForceInline + public final byte getAndAddByteAcquire(Object o, long offset, byte delta) { + byte v; + do { + v = getByteAcquire(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, v, (byte) (v + delta))); + return v; + } + @HotSpotIntrinsicCandidate public final short getAndAddShort(Object o, long offset, short delta) { short v; @@ -2316,11 +2370,39 @@ public final class Unsafe { return v; } + @ForceInline + public final short getAndAddShortRelease(Object o, long offset, short delta) { + short v; + do { + v = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, v, (short) (v + delta))); + return v; + } + + @ForceInline + public final short getAndAddShortAcquire(Object o, long offset, short delta) { + short v; + do { + v = getShortAcquire(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, v, (short) (v + delta))); + return v; + } + @ForceInline public final char getAndAddChar(Object o, long offset, char delta) { return (char) getAndAddShort(o, offset, (short) delta); } + @ForceInline + public final char getAndAddCharRelease(Object o, long offset, char delta) { + return (char) getAndAddShortRelease(o, offset, (short) delta); + } + + @ForceInline + public final char getAndAddCharAcquire(Object o, long offset, char delta) { + return (char) getAndAddShortAcquire(o, offset, (short) delta); + } + @ForceInline public final float getAndAddFloat(Object o, long offset, float delta) { int expectedBits; @@ -2336,6 +2418,36 @@ public final class Unsafe { return v; } + @ForceInline + public final float getAndAddFloatRelease(Object o, long offset, float delta) { + int expectedBits; + float v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getInt(o, offset); + v = Float.intBitsToFloat(expectedBits); + } while (!weakCompareAndSwapIntRelease(o, offset, + expectedBits, Float.floatToRawIntBits(v + delta))); + return v; + } + + @ForceInline + public final float getAndAddFloatAcquire(Object o, long offset, float delta) { + int expectedBits; + float v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getIntAcquire(o, offset); + v = Float.intBitsToFloat(expectedBits); + } while (!weakCompareAndSwapIntAcquire(o, offset, + expectedBits, Float.floatToRawIntBits(v + delta))); + return v; + } + @ForceInline public final double getAndAddDouble(Object o, long offset, double delta) { long expectedBits; @@ -2351,6 +2463,36 @@ public final class Unsafe { return v; } + @ForceInline + public final double getAndAddDoubleRelease(Object o, long offset, double delta) { + long expectedBits; + double v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getLong(o, offset); + v = Double.longBitsToDouble(expectedBits); + } while (!weakCompareAndSwapLongRelease(o, offset, + expectedBits, Double.doubleToRawLongBits(v + delta))); + return v; + } + + @ForceInline + public final double getAndAddDoubleAcquire(Object o, long offset, double delta) { + long expectedBits; + double v; + do { + // Load and CAS with the raw bits to avoid issues with NaNs and + // possible bit conversion from signaling NaNs to quiet NaNs that + // may result in the loop not terminating. + expectedBits = getLongAcquire(o, offset); + v = Double.longBitsToDouble(expectedBits); + } while (!weakCompareAndSwapLongAcquire(o, offset, + expectedBits, Double.doubleToRawLongBits(v + delta))); + return v; + } + /** * Atomically exchanges the given value with the current value of * a field or array element within the given object {@code o} @@ -2371,6 +2513,24 @@ public final class Unsafe { return v; } + @ForceInline + public final int getAndSetIntRelease(Object o, long offset, int newValue) { + int v; + do { + v = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final int getAndSetIntAcquire(Object o, long offset, int newValue) { + int v; + do { + v = getIntAcquire(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, v, newValue)); + return v; + } + /** * Atomically exchanges the given value with the current value of * a field or array element within the given object {@code o} @@ -2391,6 +2551,24 @@ public final class Unsafe { return v; } + @ForceInline + public final long getAndSetLongRelease(Object o, long offset, long newValue) { + long v; + do { + v = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final long getAndSetLongAcquire(Object o, long offset, long newValue) { + long v; + do { + v = getLongAcquire(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, v, newValue)); + return v; + } + /** * Atomically exchanges the given reference value with the current * reference value of a field or array element within the given @@ -2411,6 +2589,24 @@ public final class Unsafe { return v; } + @ForceInline + public final Object getAndSetObjectRelease(Object o, long offset, Object newValue) { + Object v; + do { + v = getObject(o, offset); + } while (!weakCompareAndSwapObjectRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final Object getAndSetObjectAcquire(Object o, long offset, Object newValue) { + Object v; + do { + v = getObjectAcquire(o, offset); + } while (!weakCompareAndSwapObjectAcquire(o, offset, v, newValue)); + return v; + } + @HotSpotIntrinsicCandidate public final byte getAndSetByte(Object o, long offset, byte newValue) { byte v; @@ -2420,11 +2616,39 @@ public final class Unsafe { return v; } + @ForceInline + public final byte getAndSetByteRelease(Object o, long offset, byte newValue) { + byte v; + do { + v = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final byte getAndSetByteAcquire(Object o, long offset, byte newValue) { + byte v; + do { + v = getByteAcquire(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, v, newValue)); + return v; + } + @ForceInline public final boolean getAndSetBoolean(Object o, long offset, boolean newValue) { return byte2bool(getAndSetByte(o, offset, bool2byte(newValue))); } + @ForceInline + public final boolean getAndSetBooleanRelease(Object o, long offset, boolean newValue) { + return byte2bool(getAndSetByteRelease(o, offset, bool2byte(newValue))); + } + + @ForceInline + public final boolean getAndSetBooleanAcquire(Object o, long offset, boolean newValue) { + return byte2bool(getAndSetByteAcquire(o, offset, bool2byte(newValue))); + } + @HotSpotIntrinsicCandidate public final short getAndSetShort(Object o, long offset, short newValue) { short v; @@ -2434,23 +2658,559 @@ public final class Unsafe { return v; } + @ForceInline + public final short getAndSetShortRelease(Object o, long offset, short newValue) { + short v; + do { + v = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, v, newValue)); + return v; + } + + @ForceInline + public final short getAndSetShortAcquire(Object o, long offset, short newValue) { + short v; + do { + v = getShortAcquire(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, v, newValue)); + return v; + } + @ForceInline public final char getAndSetChar(Object o, long offset, char newValue) { return s2c(getAndSetShort(o, offset, c2s(newValue))); } + @ForceInline + public final char getAndSetCharRelease(Object o, long offset, char newValue) { + return s2c(getAndSetShortRelease(o, offset, c2s(newValue))); + } + + @ForceInline + public final char getAndSetCharAcquire(Object o, long offset, char newValue) { + return s2c(getAndSetShortAcquire(o, offset, c2s(newValue))); + } + @ForceInline public final float getAndSetFloat(Object o, long offset, float newValue) { int v = getAndSetInt(o, offset, Float.floatToRawIntBits(newValue)); return Float.intBitsToFloat(v); } + @ForceInline + public final float getAndSetFloatRelease(Object o, long offset, float newValue) { + int v = getAndSetIntRelease(o, offset, Float.floatToRawIntBits(newValue)); + return Float.intBitsToFloat(v); + } + + @ForceInline + public final float getAndSetFloatAcquire(Object o, long offset, float newValue) { + int v = getAndSetIntAcquire(o, offset, Float.floatToRawIntBits(newValue)); + return Float.intBitsToFloat(v); + } + @ForceInline public final double getAndSetDouble(Object o, long offset, double newValue) { long v = getAndSetLong(o, offset, Double.doubleToRawLongBits(newValue)); return Double.longBitsToDouble(v); } + @ForceInline + public final double getAndSetDoubleRelease(Object o, long offset, double newValue) { + long v = getAndSetLongRelease(o, offset, Double.doubleToRawLongBits(newValue)); + return Double.longBitsToDouble(v); + } + + @ForceInline + public final double getAndSetDoubleAcquire(Object o, long offset, double newValue) { + long v = getAndSetLongAcquire(o, offset, Double.doubleToRawLongBits(newValue)); + return Double.longBitsToDouble(v); + } + + + // The following contain CAS-based Java implementations used on + // platforms not supporting native instructions + + @ForceInline + public final boolean getAndBitwiseOrBoolean(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseOrByte(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseOrBooleanRelease(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseOrByteRelease(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseOrBooleanAcquire(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseOrByteAcquire(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseAndBoolean(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseAndByte(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseAndBooleanRelease(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseAndByteRelease(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseAndBooleanAcquire(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseAndByteAcquire(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseXorBoolean(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseXorByte(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseXorBooleanRelease(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseXorByteRelease(o, offset, bool2byte(mask))); + } + + @ForceInline + public final boolean getAndBitwiseXorBooleanAcquire(Object o, long offset, boolean mask) { + return byte2bool(getAndBitwiseXorByteAcquire(o, offset, bool2byte(mask))); + } + + + @ForceInline + public final byte getAndBitwiseOrByte(Object o, long offset, byte mask) { + byte current; + do { + current = getByteVolatile(o, offset); + } while (!weakCompareAndSwapByteVolatile(o, offset, + current, (byte) (current | mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseOrByteRelease(Object o, long offset, byte mask) { + byte current; + do { + current = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, + current, (byte) (current | mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseOrByteAcquire(Object o, long offset, byte mask) { + byte current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getByte(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, + current, (byte) (current | mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseAndByte(Object o, long offset, byte mask) { + byte current; + do { + current = getByteVolatile(o, offset); + } while (!weakCompareAndSwapByteVolatile(o, offset, + current, (byte) (current & mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseAndByteRelease(Object o, long offset, byte mask) { + byte current; + do { + current = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, + current, (byte) (current & mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseAndByteAcquire(Object o, long offset, byte mask) { + byte current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getByte(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, + current, (byte) (current & mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseXorByte(Object o, long offset, byte mask) { + byte current; + do { + current = getByteVolatile(o, offset); + } while (!weakCompareAndSwapByteVolatile(o, offset, + current, (byte) (current ^ mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseXorByteRelease(Object o, long offset, byte mask) { + byte current; + do { + current = getByte(o, offset); + } while (!weakCompareAndSwapByteRelease(o, offset, + current, (byte) (current ^ mask))); + return current; + } + + @ForceInline + public final byte getAndBitwiseXorByteAcquire(Object o, long offset, byte mask) { + byte current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getByte(o, offset); + } while (!weakCompareAndSwapByteAcquire(o, offset, + current, (byte) (current ^ mask))); + return current; + } + + + @ForceInline + public final char getAndBitwiseOrChar(Object o, long offset, char mask) { + return s2c(getAndBitwiseOrShort(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseOrCharRelease(Object o, long offset, char mask) { + return s2c(getAndBitwiseOrShortRelease(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseOrCharAcquire(Object o, long offset, char mask) { + return s2c(getAndBitwiseOrShortAcquire(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseAndChar(Object o, long offset, char mask) { + return s2c(getAndBitwiseAndShort(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseAndCharRelease(Object o, long offset, char mask) { + return s2c(getAndBitwiseAndShortRelease(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseAndCharAcquire(Object o, long offset, char mask) { + return s2c(getAndBitwiseAndShortAcquire(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseXorChar(Object o, long offset, char mask) { + return s2c(getAndBitwiseXorShort(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseXorCharRelease(Object o, long offset, char mask) { + return s2c(getAndBitwiseXorShortRelease(o, offset, c2s(mask))); + } + + @ForceInline + public final char getAndBitwiseXorCharAcquire(Object o, long offset, char mask) { + return s2c(getAndBitwiseXorShortAcquire(o, offset, c2s(mask))); + } + + + @ForceInline + public final short getAndBitwiseOrShort(Object o, long offset, short mask) { + short current; + do { + current = getShortVolatile(o, offset); + } while (!weakCompareAndSwapShortVolatile(o, offset, + current, (short) (current | mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseOrShortRelease(Object o, long offset, short mask) { + short current; + do { + current = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, + current, (short) (current | mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseOrShortAcquire(Object o, long offset, short mask) { + short current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getShort(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, + current, (short) (current | mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseAndShort(Object o, long offset, short mask) { + short current; + do { + current = getShortVolatile(o, offset); + } while (!weakCompareAndSwapShortVolatile(o, offset, + current, (short) (current & mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseAndShortRelease(Object o, long offset, short mask) { + short current; + do { + current = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, + current, (short) (current & mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseAndShortAcquire(Object o, long offset, short mask) { + short current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getShort(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, + current, (short) (current & mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseXorShort(Object o, long offset, short mask) { + short current; + do { + current = getShortVolatile(o, offset); + } while (!weakCompareAndSwapShortVolatile(o, offset, + current, (short) (current ^ mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseXorShortRelease(Object o, long offset, short mask) { + short current; + do { + current = getShort(o, offset); + } while (!weakCompareAndSwapShortRelease(o, offset, + current, (short) (current ^ mask))); + return current; + } + + @ForceInline + public final short getAndBitwiseXorShortAcquire(Object o, long offset, short mask) { + short current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getShort(o, offset); + } while (!weakCompareAndSwapShortAcquire(o, offset, + current, (short) (current ^ mask))); + return current; + } + + + @ForceInline + public final int getAndBitwiseOrInt(Object o, long offset, int mask) { + int current; + do { + current = getIntVolatile(o, offset); + } while (!weakCompareAndSwapIntVolatile(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseOrIntRelease(Object o, long offset, int mask) { + int current; + do { + current = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseOrIntAcquire(Object o, long offset, int mask) { + int current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getInt(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, + current, current | mask)); + return current; + } + + /** + * Atomically replaces the current value of a field or array element within + * the given object with the result of bitwise AND between the current value + * and mask. + * + * @param o object/array to update the field/element in + * @param offset field/element offset + * @param mask the mask value + * @return the previous value + * @since 1.9 + */ + @ForceInline + public final int getAndBitwiseAndInt(Object o, long offset, int mask) { + int current; + do { + current = getIntVolatile(o, offset); + } while (!weakCompareAndSwapIntVolatile(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseAndIntRelease(Object o, long offset, int mask) { + int current; + do { + current = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseAndIntAcquire(Object o, long offset, int mask) { + int current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getInt(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseXorInt(Object o, long offset, int mask) { + int current; + do { + current = getIntVolatile(o, offset); + } while (!weakCompareAndSwapIntVolatile(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseXorIntRelease(Object o, long offset, int mask) { + int current; + do { + current = getInt(o, offset); + } while (!weakCompareAndSwapIntRelease(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final int getAndBitwiseXorIntAcquire(Object o, long offset, int mask) { + int current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getInt(o, offset); + } while (!weakCompareAndSwapIntAcquire(o, offset, + current, current ^ mask)); + return current; + } + + + @ForceInline + public final long getAndBitwiseOrLong(Object o, long offset, long mask) { + long current; + do { + current = getLongVolatile(o, offset); + } while (!weakCompareAndSwapLongVolatile(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseOrLongRelease(Object o, long offset, long mask) { + long current; + do { + current = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseOrLongAcquire(Object o, long offset, long mask) { + long current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getLong(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, + current, current | mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseAndLong(Object o, long offset, long mask) { + long current; + do { + current = getLongVolatile(o, offset); + } while (!weakCompareAndSwapLongVolatile(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseAndLongRelease(Object o, long offset, long mask) { + long current; + do { + current = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseAndLongAcquire(Object o, long offset, long mask) { + long current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getLong(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, + current, current & mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseXorLong(Object o, long offset, long mask) { + long current; + do { + current = getLongVolatile(o, offset); + } while (!weakCompareAndSwapLongVolatile(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseXorLongRelease(Object o, long offset, long mask) { + long current; + do { + current = getLong(o, offset); + } while (!weakCompareAndSwapLongRelease(o, offset, + current, current ^ mask)); + return current; + } + + @ForceInline + public final long getAndBitwiseXorLongAcquire(Object o, long offset, long mask) { + long current; + do { + // Plain read, the value is a hint, the acquire CAS does the work + current = getLong(o, offset); + } while (!weakCompareAndSwapLongAcquire(o, offset, + current, current ^ mask)); + return current; + } + + + /** * Ensures that loads before the fence will not be reordered with loads and * stores after the fence; a "LoadLoad plus LoadStore barrier". diff --git a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java index 0486710dd47..e70bb1de5d5 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java +++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java @@ -80,7 +80,7 @@ import jdk.internal.org.objectweb.asm.Opcodes; * ClassWriter cw = new ClassWriter(...); * ClassVisitor sv = new SerialVersionUIDAdder(cw); * ClassVisitor ca = new MyClassAdapter(sv); - * new ClassReader(orginalClass).accept(ca, false); + * new ClassReader(originalClass).accept(ca, false); * * * The SVUID algorithm can be found pa = () -> { - InputStream is = module.getResourceAsStream("sun/text/resources/" + dictionaryName); + String pathName = "jdk.localedata".equals(module.getName()) ? + "sun/text/resources/ext/" : + "sun/text/resources/"; + InputStream is = module.getResourceAsStream(pathName + dictionaryName); if (is == null) { // Try to load the file with "java.base" module instance. Assumption // here is that the fall back data files to be read should reside in diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java index 7c00ee052f1..ebf6ba1956e 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java @@ -444,7 +444,10 @@ class RuleBasedBreakIterator extends BreakIterator { BufferedInputStream is; try { PrivilegedExceptionAction pa = () -> { - InputStream in = module.getResourceAsStream("sun/text/resources/" + datafile); + String pathName = "jdk.localedata".equals(module.getName()) ? + "sun/text/resources/ext/" : + "sun/text/resources/"; + InputStream in = module.getResourceAsStream(pathName + datafile); if (in == null) { // Try to load the file with "java.base" module instance. Assumption // here is that the fall back data files to be read should reside in diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 12ca2b2c656..6dc9674a6ed 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -556,20 +556,6 @@ IsLauncherOption(const char* name) { JLI_StrCmp(name, "--list-modules") == 0; } -#ifndef OLD_MODULE_OPTIONS -/* - * Old module options for transition - */ -static jboolean -IsOldModuleOption(const char* name) { - return JLI_StrCmp(name, "-modulepath") == 0 || - JLI_StrCmp(name, "-mp") == 0 || - JLI_StrCmp(name, "-upgrademodulepath") == 0 || - JLI_StrCmp(name, "-addmods") == 0 || - JLI_StrCmp(name, "-limitmods") == 0; -} -#endif - /* * Test if the given name is a module-system white-space option that * will be passed to the VM with its corresponding long-form option @@ -584,8 +570,7 @@ IsModuleOption(const char* name) { JLI_StrCmp(name, "--limit-modules") == 0 || JLI_StrCmp(name, "--add-exports") == 0 || JLI_StrCmp(name, "--add-reads") == 0 || - JLI_StrCmp(name, "--patch-module") == 0 || - IsOldModuleOption(name); + JLI_StrCmp(name, "--patch-module") == 0; } /* @@ -1224,32 +1209,6 @@ GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) { } } -#ifndef OLD_MODULE_OPTIONS - // for transition to support both old and new syntax - if (JLI_StrCmp(arg, "-modulepath") == 0 || - JLI_StrCmp(arg, "-mp") == 0) { - option = "--module-path"; - } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - option = "--upgrade-module-path"; - } else if (JLI_StrCmp(arg, "-addmods") == 0) { - option = "--add-modules"; - } else if (JLI_StrCmp(arg, "-limitmods") == 0) { - option = "--limit-modules"; - } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) { - option = "--add-exports"; - value = arg + 13; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) { - option = "--add-reads"; - value = arg + 11; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) { - option = "--patch-module"; - value = arg + 8; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } -#endif - *pargc = argc; *pargv = argv; *poption = option; @@ -1340,16 +1299,6 @@ ParseArguments(int *pargc, char ***pargv, JLI_StrCmp(arg, "--patch-module") == 0) { REPORT_ERROR (has_arg, ARG_ERROR6, arg); } -#ifndef OLD_MODULE_OPTIONS - else if (JLI_StrCmp(arg, "-modulepath") == 0 || - JLI_StrCmp(arg, "-mp") == 0 || - JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - REPORT_ERROR (has_arg, ARG_ERROR4, arg); - } else if (JLI_StrCmp(arg, "-addmods") == 0 || - JLI_StrCmp(arg, "-limitmods") == 0) { - REPORT_ERROR (has_arg, ARG_ERROR6, arg); - } -#endif /* * The following cases will cause the argument parsing to stop */ @@ -1548,6 +1497,7 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc) NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String")); NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0)); + CHECK_EXCEPTION_RETURN_VALUE(0); for (i = 0; i < strc; i++) { jstring str = NewPlatformString(env, *strv++); NULL_CHECK0(str); diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h index c18c66e5b51..41a232714c8 100644 --- a/jdk/src/java.base/share/native/libjli/java.h +++ b/jdk/src/java.base/share/native/libjli/java.h @@ -253,6 +253,13 @@ typedef struct { #define NULL_CHECK(NC_check_pointer) \ NULL_CHECK_RETURN_VALUE(NC_check_pointer, ) +#define CHECK_EXCEPTION_RETURN_VALUE(CER_value) \ + do { \ + if ((*env)->ExceptionOccurred(env)) { \ + return CER_value; \ + } \ + } while (JNI_FALSE) + #define CHECK_EXCEPTION_RETURN() \ do { \ if ((*env)->ExceptionOccurred(env)) { \ diff --git a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java index 4b4441a7700..f26b0108fed 100644 --- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java +++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java @@ -630,6 +630,19 @@ final class ProcessImpl extends Process { return !hasExited; } + /** + * The {@code toString} method returns a string consisting of + * the native process ID of the process and the exit value of the process. + * + * @return a string representation of the object. + */ + @Override + public String toString() { + return new StringBuilder("Process[pid=").append(pid) + .append(", exitValue=").append(hasExited ? exitcode : "\"not exited\"") + .append("]").toString(); + } + private static native void init(); static { diff --git a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c index 3408bdd9762..27230858253 100644 --- a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -349,6 +349,8 @@ static int copystrings(char *buf, int offset, const char * const *arg) { __attribute_noinline__ #endif +/* vfork(2) is deprecated on Solaris */ +#ifndef __solaris__ static pid_t vforkChild(ChildStuff *c) { volatile pid_t resultPid; @@ -367,6 +369,7 @@ vforkChild(ChildStuff *c) { assert(resultPid != 0); /* childProcess never returns */ return resultPid; } +#endif static pid_t forkChild(ChildStuff *c) { @@ -479,8 +482,11 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) static pid_t startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) { switch (c->mode) { +/* vfork(2) is deprecated on Solaris */ +#ifndef __solaris__ case MODE_VFORK: return vforkChild(c); +#endif case MODE_FORK: return forkChild(c); #if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX) diff --git a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c index 3efde95813a..d5b1824b314 100644 --- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c +++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c @@ -80,6 +80,12 @@ #define DEV_PREFIX "/dev/" #endif +#ifdef LIFNAMSIZ + #define IFNAMESIZE LIFNAMSIZ +#else + #define IFNAMESIZE IFNAMSIZ +#endif + #define CHECKED_MALLOC3(_pointer, _type, _size) \ do { \ _pointer = (_type)malloc(_size); \ @@ -158,7 +164,7 @@ static short translateIPv6AddressToPrefix(struct sockaddr_in6 *addr); static int getIndex(int sock, const char *ifname); static int getFlags(int sock, const char *ifname, int *flags); -static int getMacAddress(JNIEnv *env, int sock, const char *ifname, +static int getMacAddress(JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf); static int getMTU(JNIEnv *env, int sock, const char *ifname); @@ -237,20 +243,25 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0 const char* name_utf; jobject obj = NULL; + if (name != NULL) { + name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); + } else { + JNU_ThrowNullPointerException(env, "network interface name is NULL"); + return NULL; + } + + if (name_utf == NULL) { + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return NULL; + } + ifs = enumInterfaces(env); if (ifs == NULL) { return NULL; } - name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); - if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - freeif(ifs); - return NULL; - } - - // Search the list of interface based on name + // search the list of interfaces based on name curr = ifs; while (curr != NULL) { if (strcmp(name_utf, curr->name) == 0) { @@ -285,12 +296,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0 if (index <= 0) { return NULL; } + ifs = enumInterfaces(env); if (ifs == NULL) { return NULL; } - // Search the list of interface based on index + // search the list of interfaces based on index curr = ifs; while (curr != NULL) { if (index == curr->index) { @@ -304,7 +316,9 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0 obj = createNetworkInterface(env, curr); } + // release the interface list freeif(ifs); + return obj; } @@ -317,13 +331,11 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 (JNIEnv *env, jclass cls, jobject iaObj) { netif *ifs, *curr; - #if defined(AF_INET6) int family = (getInetAddress_family(env, iaObj) == IPv4) ? AF_INET : AF_INET6; #else int family = AF_INET; #endif - jobject obj = NULL; jboolean match = JNI_FALSE; @@ -342,7 +354,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 if (family == addrP->family) { if (family == AF_INET) { int address1 = htonl( - ((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr); + ((struct sockaddr_in *)addrP->addr)->sin_addr.s_addr); int address2 = getInetAddress_addr(env, iaObj); if (address1 == address2) { @@ -350,7 +362,6 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 break; } } - #if defined(AF_INET6) if (family == AF_INET6) { jbyte *bytes = (jbyte *)&( @@ -390,7 +401,9 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 obj = createNetworkInterface(env, curr); } + // release the interface list freeif(ifs); + return obj; } @@ -411,7 +424,7 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll return NULL; } - // count the interface + // count the interfaces ifCount = 0; curr = ifs; while (curr != NULL) { @@ -426,8 +439,8 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll return NULL; } - // Iterate through the interfaces, create a NetworkInterface instance - // for each array element and populate the object. + // iterate through the interfaces, create a NetworkInterface instance + // for each array element and populate the object curr = ifs; arr_index = 0; while (curr != NULL) { @@ -445,7 +458,9 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll curr = curr->next; } + // release the interface list freeif(ifs); + return netIFArr; } @@ -511,46 +526,45 @@ JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0 jbyteArray ret = NULL; unsigned char mac[16]; int len; - int sock; jboolean isCopy; - const char* name_utf; + const char *name_utf; - name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); - if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - return NULL; + if (name != NULL) { + name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); + } else { + JNU_ThrowNullPointerException(env, "network interface name is NULL"); + return NULL; } - if ((sock = openSocketWithFallback(env, name_utf)) < 0) { - (*env)->ReleaseStringUTFChars(env, name, name_utf); - return NULL; + + if (name_utf == NULL) { + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return NULL; } if (!IS_NULL(addrArray)) { - (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr); - addr = ((caddr[0]<<24) & 0xff000000); - addr |= ((caddr[1] <<16) & 0xff0000); - addr |= ((caddr[2] <<8) & 0xff00); - addr |= (caddr[3] & 0xff); - iaddr.s_addr = htonl(addr); - len = getMacAddress(env, sock, name_utf, &iaddr, mac); + (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr); + addr = ((caddr[0]<<24) & 0xff000000); + addr |= ((caddr[1] <<16) & 0xff0000); + addr |= ((caddr[2] <<8) & 0xff00); + addr |= (caddr[3] & 0xff); + iaddr.s_addr = htonl(addr); + len = getMacAddress(env, name_utf, &iaddr, mac); } else { - len = getMacAddress(env, sock, name_utf, NULL, mac); + len = getMacAddress(env, name_utf, NULL, mac); } - if (len > 0) { - ret = (*env)->NewByteArray(env, len); - if (IS_NULL(ret)) { - /* we may have memory to free at the end of this */ - goto fexit; - } - (*env)->SetByteArrayRegion(env, ret, 0, len, (jbyte *)(mac)); - } - fexit: - // release the UTF string and interface list - (*env)->ReleaseStringUTFChars(env, name, name_utf); - close(sock); - return ret; + if (len > 0) { + ret = (*env)->NewByteArray(env, len); + if (!IS_NULL(ret)) { + (*env)->SetByteArrayRegion(env, ret, 0, len, (jbyte *)(mac)); + } + } + + // release the UTF string and interface list + (*env)->ReleaseStringUTFChars(env, name, name_utf); + + return ret; } /* @@ -562,8 +576,7 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0 (JNIEnv *env, jclass cls, jstring name, jint index) { jboolean isCopy; - int ret = -1; - int sock; + int sock, ret = -1; const char* name_utf = NULL; if (name != NULL) { @@ -572,15 +585,16 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0 JNU_ThrowNullPointerException(env, "network interface name is NULL"); return ret; } + if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - return ret; + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return ret; } if ((sock = openSocketWithFallback(env, name_utf)) < 0) { - (*env)->ReleaseStringUTFChars(env, name, name_utf); - return JNI_FALSE; + (*env)->ReleaseStringUTFChars(env, name, name_utf); + return JNI_FALSE; } ret = getMTU(env, sock, name_utf); @@ -595,9 +609,8 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0 static int getFlags0(JNIEnv *env, jstring name) { jboolean isCopy; - int ret, sock; - const char* name_utf; - int flags = 0; + int ret, sock, flags = 0; + const char *name_utf; if (name != NULL) { name_utf = (*env)->GetStringUTFChars(env, name, &isCopy); @@ -607,9 +620,9 @@ static int getFlags0(JNIEnv *env, jstring name) { } if (name_utf == NULL) { - if (!(*env)->ExceptionCheck(env)) - JNU_ThrowOutOfMemoryError(env, NULL); - return -1; + if (!(*env)->ExceptionCheck(env)) + JNU_ThrowOutOfMemoryError(env, NULL); + return -1; } if ((sock = openSocketWithFallback(env, name_utf)) < 0) { (*env)->ReleaseStringUTFChars(env, name, name_utf); @@ -648,7 +661,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { netif *childP; jobject tmp; - // Create a NetworkInterface object and populate it + // create a NetworkInterface object and populate it netifObj = (*env)->NewObject(env, ni_class, ni_ctrID); CHECK_NULL_RETURN(netifObj, NULL); name = (*env)->NewStringUTF(env, ifs->name); @@ -659,7 +672,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { (*env)->SetBooleanField(env, netifObj, ni_virutalID, ifs->virtual ? JNI_TRUE : JNI_FALSE); - //Count the number of address on this interface + // count the number of addresses on this interface addr_count = 0; addrP = ifs->addr; while (addrP != NULL) { @@ -667,7 +680,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { addrP = addrP->next; } - // Create the array of InetAddresses + // create the array of InetAddresses addrArr = (*env)->NewObjectArray(env, addr_count, ia_class, NULL); if (addrArr == NULL) { return NULL; @@ -687,32 +700,31 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { if (addrP->family == AF_INET) { iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (iaObj) { - setInetAddress_addr(env, iaObj, htonl( - ((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); + setInetAddress_addr(env, iaObj, htonl( + ((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); } else { return NULL; } ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID); if (ibObj) { - (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); - if (addrP->brdcast) { + (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); + if (addrP->brdcast) { jobject ia2Obj = NULL; ia2Obj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (ia2Obj) { - setInetAddress_addr(env, ia2Obj, htonl( - ((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); - (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); + setInetAddress_addr(env, ia2Obj, htonl( + ((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); + (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); } else { return NULL; } - } - (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); - (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); + } + (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask); + (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj); } else { return NULL; } } - #if defined(AF_INET6) if (addrP->family == AF_INET6) { int scope=0; @@ -748,7 +760,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { addrP = addrP->next; } - // See if there is any virtual interface attached to this one. + // see if there is any virtual interface attached to this one. child_count = 0; childP = ifs->childs; while (childP) { @@ -761,17 +773,17 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { return NULL; } - // Create the NetworkInterface instances for the sub-interfaces as well. + // create the NetworkInterface instances for the sub-interfaces as well child_index = 0; childP = ifs->childs; while(childP) { - tmp = createNetworkInterface(env, childP); - if (tmp == NULL) { - return NULL; - } - (*env)->SetObjectField(env, tmp, ni_parentID, netifObj); - (*env)->SetObjectArrayElement(env, childArr, child_index++, tmp); - childP = childP->next; + tmp = createNetworkInterface(env, childP); + if (tmp == NULL) { + return NULL; + } + (*env)->SetObjectField(env, tmp, ni_parentID, netifObj); + (*env)->SetObjectArrayElement(env, childArr, child_index++, tmp); + childP = childP->next; } (*env)->SetObjectField(env, netifObj, ni_addrsID, addrArr); (*env)->SetObjectField(env, netifObj, ni_bindsID, bindArr); @@ -785,46 +797,42 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) { * Enumerates all interfaces */ static netif *enumInterfaces(JNIEnv *env) { - netif *ifs; + netif *ifs = NULL; int sock; - // Enumerate IPv4 addresses sock = openSocket(env, AF_INET); if (sock < 0 && (*env)->ExceptionOccurred(env)) { return NULL; } + // enumerate IPv4 addresses ifs = enumIPv4Interfaces(env, sock, NULL); close(sock); + // return partial list if an exception occurs in the middle of process ??? if (ifs == NULL && (*env)->ExceptionOccurred(env)) { return NULL; } - // return partial list if an exception occurs in the middle of process ??? - // If IPv6 is available then enumerate IPv6 addresses. #if defined(AF_INET6) - // User can disable ipv6 explicitly by -Djava.net.preferIPv4Stack=true, // so we have to call ipv6_available() if (ipv6_available()) { + sock = openSocket(env, AF_INET6); + if (sock < 0 && (*env)->ExceptionOccurred(env)) { + freeif(ifs); + return NULL; + } - sock = openSocket(env, AF_INET6); - if (sock < 0 && (*env)->ExceptionOccurred(env)) { - freeif(ifs); - return NULL; - } + ifs = enumIPv6Interfaces(env, sock, ifs); + close(sock); - ifs = enumIPv6Interfaces(env, sock, ifs); - close(sock); - - if ((*env)->ExceptionOccurred(env)) { - freeif(ifs); - return NULL; - } - - } + if ((*env)->ExceptionOccurred(env)) { + freeif(ifs); + return NULL; + } + } #endif return ifs; @@ -845,7 +853,7 @@ static void freeif(netif *ifs) { addrP = next; } - // Don't forget to free the sub-interfaces. + // don't forget to free the sub-interfaces if (currif->childs != NULL) { freeif(currif->childs); } @@ -863,26 +871,17 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, { netif *currif = ifs, *parent; netaddr *addrP; - -#ifdef LIFNAMSIZ - int ifnam_size = LIFNAMSIZ; - char name[LIFNAMSIZ], vname[LIFNAMSIZ]; -#else - int ifnam_size = IFNAMSIZ; - char name[IFNAMSIZ], vname[IFNAMSIZ]; -#endif - + char name[IFNAMESIZE], vname[IFNAMESIZE]; char *name_colonP; int isVirtual = 0; int addr_size; - int flags = 0; // If the interface name is a logical interface then we remove the unit // number so that we have the physical interface (eg: hme0:1 -> hme0). // NetworkInterface currently doesn't have any concept of physical vs. // logical interfaces. - strncpy(name, if_name, ifnam_size); - name[ifnam_size - 1] = '\0'; + strncpy(name, if_name, IFNAMESIZE); + name[IFNAMESIZE - 1] = '\0'; *vname = 0; // Create and populate the netaddr node. If allocation fails @@ -917,20 +916,21 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, // Deal with virtual interface with colon notation e.g. eth0:1 name_colonP = strchr(name, ':'); if (name_colonP != NULL) { + int flags = 0; // This is a virtual interface. If we are able to access the parent // we need to create a new entry if it doesn't exist yet *and* update // the 'parent' interface with the new records. *name_colonP = 0; if (getFlags(sock, name, &flags) < 0 || flags < 0) { - // failed to access parent interface do not create parent. - // We are a virtual interface with no parent. - isVirtual = 1; - *name_colonP = ':'; + // failed to access parent interface do not create parent. + // We are a virtual interface with no parent. + isVirtual = 1; + *name_colonP = ':'; } else { - // Got access to parent, so create it if necessary. - // Save original name to vname and truncate name by ':' - memcpy(vname, name, sizeof(vname) ); - vname[name_colonP - name] = ':'; + // Got access to parent, so create it if necessary. + // Save original name to vname and truncate name by ':' + memcpy(vname, name, sizeof(vname)); + vname[name_colonP - name] = ':'; } } @@ -943,12 +943,12 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, currif = currif->next; } - // If "new" then create an netif structure and insert it into the list. + // If "new" then create a netif structure and insert it into the list. if (currif == NULL) { - CHECKED_MALLOC3(currif, netif *, sizeof(netif) + ifnam_size); + CHECKED_MALLOC3(currif, netif *, sizeof(netif) + IFNAMESIZE); currif->name = (char *)currif + sizeof(netif); - strncpy(currif->name, name, ifnam_size); - currif->name[ifnam_size - 1] = '\0'; + strncpy(currif->name, name, IFNAMESIZE); + currif->name[IFNAMESIZE - 1] = '\0'; currif->index = getIndex(sock, name); currif->addr = NULL; currif->childs = NULL; @@ -977,13 +977,12 @@ static netif *addif(JNIEnv *env, int sock, const char *if_name, netif *ifs, } if (currif == NULL) { - CHECKED_MALLOC3(currif, netif *, sizeof(netif) + ifnam_size); + CHECKED_MALLOC3(currif, netif *, sizeof(netif) + IFNAMESIZE); currif->name = (char *)currif + sizeof(netif); - strncpy(currif->name, vname, ifnam_size); - currif->name[ifnam_size - 1] = '\0'; + strncpy(currif->name, vname, IFNAMESIZE); + currif->name[IFNAMESIZE - 1] = '\0'; currif->index = getIndex(sock, vname); - currif->addr = NULL; - // Need to duplicate the addr entry? + currif->addr = NULL; // Need to duplicate the addr entry? currif->virtual = 1; currif->childs = NULL; currif->next = parent->childs; @@ -1150,7 +1149,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { struct sockaddr addr, broadaddr, *broadaddrP = NULL; short prefix = 0; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifreqP->ifr_addr.sa_family != AF_INET) { continue; } @@ -1264,19 +1263,26 @@ static int getIndex(int sock, const char *name) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { static struct ifreq ifr; - int i; + int i, sock; + + if ((sock = openSocketWithFallback(env, ifname)) < 0) { + return -1; + } + memset((char *)&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFHWADDR) failed"); + close(sock); return -1; } + close(sock); memcpy(buf, &ifr.ifr_hwaddr.sa_data, IFHWADDRLEN); // all bytes to 0 means no hardware address @@ -1388,7 +1394,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { struct sockaddr addr, broadaddr, *broadaddrP = NULL; short prefix = 0; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifreqP->ifr_addr.sa_family != AF_INET) { continue; } @@ -1444,7 +1450,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { struct ifconf ifc; struct ifreq *ifreqP; - char *buf; + char *buf, *cp, *cplimit; // call SIOCGSIZIFCONF to get size for SIOCGIFCONF buffer if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) { @@ -1464,8 +1470,9 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { } // iterate through each interface - char *cp = (char *)ifc.ifc_req; - char *cplimit = cp + ifc.ifc_len; + ifreqP = ifc.ifc_req; + cp = (char *)ifc.ifc_req; + cplimit = cp + ifc.ifc_len; for (; cp < cplimit; cp += (sizeof(ifreqP->ifr_name) + @@ -1474,7 +1481,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { ifreqP = (struct ifreq *)cp; short prefix = 0; - // ignore non IPv6 interfaces + // ignore non IPv6 addresses if (ifreqP->ifr_addr.sa_family != AF_INET6) { continue; } @@ -1527,7 +1534,7 @@ static int getIndex(int sock, const char *name) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { int size; @@ -1586,20 +1593,20 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) { } static int getFlags(int sock, const char *ifname, int *flags) { - struct ifreq if2; - memset((char *)&if2, 0, sizeof(if2)); - strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1); + struct ifreq if2; + memset((char *)&if2, 0, sizeof(if2)); + strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1); - if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) { - return -1; - } + if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) { + return -1; + } - if (sizeof(if2.ifr_flags) == sizeof(short)) { - *flags = (if2.ifr_flags & 0xffff); - } else { - *flags = if2.ifr_flags; - } - return 0; + if (sizeof(if2.ifr_flags) == sizeof(short)) { + *flags = (if2.ifr_flags & 0xffff); + } else { + *flags = if2.ifr_flags; + } + return 0; } #endif /* _AIX */ @@ -1668,7 +1675,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { char *buf = NULL; unsigned i; - // call SIOCGLIFNUM to get the size of SIOCGIFCONF buffer + // call SIOCGLIFNUM to get the interface count numifs.lifn_family = AF_INET; numifs.lifn_flags = 0; if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) { @@ -1695,7 +1702,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { for (i = 0; i < numifs.lifn_count; i++, ifreqP++) { struct sockaddr addr, *broadaddrP = NULL; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifreqP->lifr_addr.ss_family != AF_INET) { continue; } @@ -1744,7 +1751,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { char *buf = NULL; unsigned i; - // call SIOCGLIFNUM to get the size of SIOCGLIFCONF buffer + // call SIOCGLIFNUM to get the interface count numifs.lifn_family = AF_INET6; numifs.lifn_flags = 0; if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) { @@ -1770,7 +1777,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { ifreqP = ifc.lifc_req; for (i = 0; i < numifs.lifn_count; i++, ifreqP++) { - // ignore non IPv6 interfaces + // ignore non IPv6 addresses if (ifreqP->lifr_addr.ss_family != AF_INET6) { continue; } @@ -1789,7 +1796,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { free(buf); return ifs; } - } + } // free buffer free(buf); @@ -1834,9 +1841,9 @@ static int getMacFromDevice strcpy(style1dev, DEV_PREFIX); strcat(style1dev, ifname); if ((fd = open(style1dev, O_RDWR)) < 0) { - // Can't open it. We probably are missing the privilege. - // We'll have to try something else - return 0; + // Can't open it. We probably are missing the privilege. + // We'll have to try something else + return 0; } dlpareq.dl_primitive = DL_PHYS_ADDR_REQ; @@ -1878,11 +1885,15 @@ static int getMacFromDevice * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { struct lifreq if2; - int len, i; + int len, i, sock; + + if ((sock = openSocketWithFallback(env, ifname)) < 0) { + return -1; + } // First, try the new (S11) SIOCGLIFHWADDR ioctl(). If that fails // try the old way. @@ -1893,40 +1904,36 @@ static int getMacAddress struct sockaddr_dl *sp; sp = (struct sockaddr_dl *)&if2.lifr_addr; memcpy(buf, &sp->sdl_data[0], sp->sdl_alen); + close(sock); return sp->sdl_alen; } // On Solaris we have to use DLPI, but it will only work if we have // privileged access (i.e. root). If that fails, we try a lookup // in the ARP table, which requires an IPv4 address. - if ((len = getMacFromDevice(env, ifname, buf)) == 0) { - // DLPI failed - trying to do arp lookup - + if (((len = getMacFromDevice(env, ifname, buf)) == 0) && (addr != NULL)) { struct arpreq arpreq; struct sockaddr_in *sin; struct sockaddr_in ipAddr; - if (addr == NULL) { - // No IPv4 address for that interface, so can't do an ARP lookup. - return -1; - } + len = 6; //??? - len = 6; //??? + sin = (struct sockaddr_in *)&arpreq.arp_pa; + memset((char *)&arpreq, 0, sizeof(struct arpreq)); + ipAddr.sin_port = 0; + ipAddr.sin_family = AF_INET; + memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr)); + memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in)); + arpreq.arp_flags= ATF_PUBL; - sin = (struct sockaddr_in *)&arpreq.arp_pa; - memset((char *)&arpreq, 0, sizeof(struct arpreq)); - ipAddr.sin_port = 0; - ipAddr.sin_family = AF_INET; - memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr)); - memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in)); - arpreq.arp_flags= ATF_PUBL; + if (ioctl(sock, SIOCGARP, &arpreq) < 0) { + close(sock); + return -1; + } - if (ioctl(sock, SIOCGARP, &arpreq) < 0) { - return -1; - } - - memcpy(buf, &arpreq.arp_ha.sa_data[0], len); + memcpy(buf, &arpreq.arp_ha.sa_data[0], len); } + close(sock); // all bytes to 0 means no hardware address for (i = 0; i < len; i++) { @@ -2014,7 +2021,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { for (ifa = origifa; ifa != NULL; ifa = ifa->ifa_next) { struct sockaddr *broadaddrP = NULL; - // ignore non IPv4 interfaces + // ignore non IPv4 addresses if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET) continue; @@ -2058,7 +2065,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { } for (ifa = origifa; ifa != NULL; ifa = ifa->ifa_next) { - // ignore non IPv6 interfaces + // ignore non IPv6 addresses if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -2113,22 +2120,22 @@ static int getIndex(int sock, const char *name) { * MAC address. Returns -1 if there is no hardware address on that interface. */ static int getMacAddress - (JNIEnv *env, int sock, const char *ifname, const struct in_addr *addr, + (JNIEnv *env, const char *ifname, const struct in_addr *addr, unsigned char *buf) { struct ifaddrs *ifa0, *ifa; struct sockaddr *saddr; int i; - // Grab the interface list + // grab the interface list if (!getifaddrs(&ifa0)) { - // Cycle through the interfaces + // cycle through the interfaces for (i = 0, ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next, i++) { saddr = ifa->ifa_addr; - // Link layer contains the MAC address + // link layer contains the MAC address if (saddr->sa_family == AF_LINK && !strcmp(ifname, ifa->ifa_name)) { struct sockaddr_dl *sadl = (struct sockaddr_dl *) saddr; - // Check the address is the correct length + // check the address has the correct length if (sadl->sdl_alen == ETHER_ADDR_LEN) { memcpy(buf, (sadl->sdl_data + sadl->sdl_nlen), ETHER_ADDR_LEN); freeifaddrs(ifa0); diff --git a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c index 81b37db572f..16166a5f83b 100644 --- a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c +++ b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c @@ -52,6 +52,10 @@ #include #endif +#ifdef __linux__ +#include +#endif + #if defined(__linux__) || defined(_AIX) #include #endif @@ -157,14 +161,11 @@ static int fstatat64_wrapper(int dfd, const char *path, } #endif -#if defined(__linux__) && defined(__x86_64__) +#if defined(__linux__) && defined(_LP64) && defined(__NR_newfstatat) #define FSTATAT64_SYSCALL_AVAILABLE static int fstatat64_wrapper(int dfd, const char *path, struct stat64 *statbuf, int flag) { - #ifndef __NR_newfstatat - #define __NR_newfstatat 262 - #endif return syscall(__NR_newfstatat, dfd, path, statbuf, flag); } #endif diff --git a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java index a59eba9dd3d..988234daf51 100644 --- a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java +++ b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java @@ -563,6 +563,20 @@ final class ProcessImpl extends Process { private static native boolean isProcessAlive(long handle); + /** + * The {@code toString} method returns a string consisting of + * the native process ID of the process and the exit value of the process. + * + * @return a string representation of the object. + */ + @Override + public String toString() { + int exitCode = getExitCodeProcess(handle); + return new StringBuilder("Process[pid=").append(getPid()) + .append(", exitValue=").append(exitCode == STILL_ACTIVE ? "\"not exited\"" : exitCode) + .append("]").toString(); + } + /** * Create a process using the win32 function CreateProcess. * The method is synchronized due to MS kb315939 problem. diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java index 272b1f1f25b..8e105132eaa 100644 --- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java +++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java @@ -25,7 +25,6 @@ package apple.laf; -import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.lang.annotation.Native; @@ -70,6 +69,21 @@ public final class JRSUIConstants { throw new RuntimeException("Constant not implemented in native: " + this); } + private String getConstantName(Key hit) { + if (hit == VALUE) { + return "VALUE"; + } else if (hit == THUMB_PROPORTION) { + return "THUMB_PROPORTION"; + } else if (hit == THUMB_START) { + return "THUMB_START"; + } else if (hit == WINDOW_TITLE_BAR_HEIGHT) { + return "WINDOW_TITLE_BAR_HEIGHT"; + } else if (hit == THUMB_START) { + return "ANIMATION_FRAME"; + } + return getClass().getSimpleName(); + } + public String toString() { return getConstantName(this) + (ptr == 0 ? "(unlinked)" : ""); } @@ -138,7 +152,7 @@ public final class JRSUIConstants { } public String toString() { - return getConstantName(this); + return getClass().getSimpleName(); } } @@ -779,6 +793,17 @@ public final class JRSUIConstants { return hit > 0; } + private String getConstantName(Hit hit) { + if (hit == UNKNOWN) { + return "UNKNOWN"; + } else if (hit == NONE) { + return "NONE"; + } else if (hit == HIT) { + return "HIT"; + } + return getClass().getSimpleName(); + } + public String toString() { return getConstantName(this); } @@ -829,16 +854,4 @@ public final class JRSUIConstants { } return Hit.UNKNOWN; } - - static String getConstantName(final Object object) { - final Class clazz = object.getClass(); - try { - for (final Field field : clazz.getFields()) { - if (field.get(null) == object) { - return field.getName(); - } - } - } catch (final Exception e) {} - return clazz.getSimpleName(); - } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java index eab1efb3447..c9c0c9bcf4d 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java @@ -72,7 +72,7 @@ class _AppDockIconHandler { public void setDockIconImage(final Image image) { try { - final CImage cImage = getCImageCreator().createFromImage(image); + final CImage cImage = CImage.createFromImage(image); final long nsImagePtr = getNSImagePtrFrom(cImage); nativeSetDockIconImage(nsImagePtr); } catch (final Throwable e) { @@ -84,7 +84,11 @@ class _AppDockIconHandler { try { final long dockNSImage = nativeGetDockIconImage(); if (dockNSImage == 0) return null; - return getCImageCreator().createImageUsingNativeSize(dockNSImage); + final Method getCreatorMethod = CImage.class.getDeclaredMethod( + "getCreator", new Class[]{}); + getCreatorMethod.setAccessible(true); + Creator imageCreator = (Creator) getCreatorMethod.invoke(null, new Object[]{}); + return imageCreator.createImageUsingNativeSize(dockNSImage); } catch (final Throwable e) { throw new RuntimeException(e); } @@ -98,16 +102,6 @@ class _AppDockIconHandler { nativeSetDockIconProgress(value); } - static Creator getCImageCreator() { - try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {}); - getCreatorMethod.setAccessible(true); - return (Creator)getCreatorMethod.invoke(null, new Object[] {}); - } catch (final Throwable e) { - throw new RuntimeException(e); - } - } - static long getNSImagePtrFrom(final CImage cImage) { if (cImage == null) return 0; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java index a417f692ab8..e64e9b158b5 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java @@ -171,7 +171,8 @@ class _AppEventHandler { currentQuitResponse = null; try { - if (defaultQuitAction == QuitStrategy.NORMAL_EXIT) System.exit(0); + if (defaultQuitAction == QuitStrategy.NORMAL_EXIT + || _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0); if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) { throw new RuntimeException("Unknown quit action"); @@ -422,6 +423,10 @@ class _AppEventHandler { } void performUsing(final QuitHandler handler, final _NativeEvent event) { + if (_AppMiscHandlers.isSuddenTerminationEnbaled()) { + performDefaultAction(event); + return; + } final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response handler.handleQuitRequestWith(new QuitEvent(), response); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java index 6f892caaa91..1851e2aa90c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java @@ -26,6 +26,8 @@ package com.apple.eawt; class _AppMiscHandlers { + private static boolean isSuddenTerminationEnabled; + private static native void nativeOpenHelpViewer(); private static native void nativeRequestActivation(final boolean allWindows); @@ -47,10 +49,16 @@ class _AppMiscHandlers { } static void enableSuddenTermination() { + isSuddenTerminationEnabled = true; nativeEnableSuddenTermination(); } static void disableSuddenTermination() { + isSuddenTerminationEnabled = false; nativeDisableSuddenTermination(); } + + public static boolean isSuddenTerminationEnbaled() { + return isSuddenTerminationEnabled; + } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java index b4bc1e69d58..936fe567c66 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java @@ -37,6 +37,7 @@ import apple.laf.*; import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.RecyclableSingleton; +import sun.lwawt.macosx.CImage; public class AquaIcon { interface InvertableIcon extends Icon { @@ -226,7 +227,7 @@ public class AquaIcon { } Image createImage() { - return AquaUtils.getCImageCreator().createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight()); + return CImage.createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight()); } } @@ -299,7 +300,7 @@ public class AquaIcon { } Image createImage() { - return AquaUtils.getCImageCreator().createSystemImageFromSelector( + return CImage.createSystemImageFromSelector( selector, getIconWidth(), getIconHeight()); } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java index c26bcae3d06..5d43a41e502 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java @@ -46,8 +46,8 @@ import com.apple.laf.AquaIcon.JRSUIControlSpec; import com.apple.laf.AquaIcon.SystemIcon; import com.apple.laf.AquaUtils.RecyclableObject; import com.apple.laf.AquaUtils.RecyclableSingleton; -import java.awt.image.MultiResolutionImage; import sun.awt.image.MultiResolutionCachedImage; +import sun.lwawt.macosx.CImage; public class AquaImageFactory { public static IconUIResource getConfirmImageIcon() { @@ -73,7 +73,7 @@ public class AquaImageFactory { public static IconUIResource getLockImageIcon() { // public, because UIDefaults.ProxyLazyValue uses reflection to get this value if (JRSUIUtils.Images.shouldUseLegacySecurityUIPath()) { - final Image lockIcon = AquaUtils.getCImageCreator().createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize); + final Image lockIcon = CImage.createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize); return getAppIconCompositedOn(lockIcon); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index 67520fcc30b..5e7d160943c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -41,8 +41,6 @@ import jdk.internal.loader.ClassLoaders; import sun.awt.AppContext; -import sun.lwawt.macosx.CImage; -import sun.lwawt.macosx.CImage.Creator; import sun.lwawt.macosx.CPlatformWindow; import sun.reflect.misc.ReflectUtil; import sun.security.action.GetPropertyAction; @@ -50,6 +48,7 @@ import sun.swing.SwingUtilities2; import com.apple.laf.AquaImageFactory.SlicedImageControl; import sun.awt.image.MultiResolutionCachedImage; +import sun.swing.SwingAccessor; final class AquaUtils { @@ -78,65 +77,45 @@ final class AquaUtils { } } - private static Creator getCImageCreatorInternal() { - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Creator run() { - try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod( - "getCreator", new Class[] {}); - getCreatorMethod.setAccessible(true); - return (Creator)getCreatorMethod.invoke(null, new Object[] {}); - } catch (final Exception ignored) { - return null; - } - } - }); - } - - private static final RecyclableSingleton cImageCreator = new RecyclableSingleton() { - @Override - protected Creator getInstance() { - return getCImageCreatorInternal(); - } - }; - static Creator getCImageCreator() { - return cImageCreator.get(); - } - static Image generateSelectedDarkImage(final Image image) { - final ImageProducer prod = new FilteredImageSource(image.getSource(), new IconImageFilter() { + final ImageFilter filter = new IconImageFilter() { @Override int getGreyFor(final int gray) { return gray * 75 / 100; } - }); - return Toolkit.getDefaultToolkit().createImage(prod); + }; + return map(image, filter); } static Image generateDisabledImage(final Image image) { - final ImageProducer prod = new FilteredImageSource(image.getSource(), new IconImageFilter() { + final ImageFilter filter = new IconImageFilter() { @Override int getGreyFor(final int gray) { return 255 - ((255 - gray) * 65 / 100); } - }); - return Toolkit.getDefaultToolkit().createImage(prod); + }; + return map(image, filter); } static Image generateLightenedImage(final Image image, final int percent) { final GrayFilter filter = new GrayFilter(true, percent); - return (image instanceof MultiResolutionCachedImage) - ? ((MultiResolutionCachedImage) image).map( - rv -> generateLightenedImage(rv, filter)) - : generateLightenedImage(image, filter); + return map(image, filter); } - static Image generateLightenedImage(Image image, ImageFilter filter) { + static Image generateFilteredImage(Image image, ImageFilter filter) { final ImageProducer prod = new FilteredImageSource(image.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(prod); } + private static Image map(Image image, ImageFilter filter) { + if (image instanceof MultiResolutionImage) { + return MultiResolutionCachedImage + .map((MultiResolutionImage) image, + (img) -> generateFilteredImage(img, filter)); + } + return generateFilteredImage(image, filter); + } + private abstract static class IconImageFilter extends RGBImageFilter { IconImageFilter() { super(); @@ -399,15 +378,9 @@ final class AquaUtils { } }; - private static final Integer OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET + private static final int OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET static boolean hasOpaqueBeenExplicitlySet(final JComponent c) { - final Method method = getJComponentGetFlagMethod.get(); - if (method == null) return false; - try { - return Boolean.TRUE.equals(method.invoke(c, OPAQUE_SET_FLAG)); - } catch (final Throwable ignored) { - return false; - } + return SwingAccessor.getJComponentAccessor().getFlag(c, OPAQUE_SET_FLAG); } private static boolean isWindowTextured(final Component c) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java index dcc4b5793eb..049dbb58619 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java @@ -278,6 +278,18 @@ public final class CFont extends PhysicalFont implements FontSubstitution { return getStrike(font, DEFAULT_FRC); } + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + + return ((Font2D)o).getStyle() == this.getStyle(); + } + + public int hashCode() { + return super.hashCode() ^ this.getStyle(); + } + public String toString() { return "CFont { fullName: " + fullName + ", familyName: " + familyName + ", style: " + style + diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java index 00cb5274be2..3307e5b0e86 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java @@ -37,6 +37,7 @@ import sun.awt.AWTAccessor; import javax.accessibility.*; import javax.swing.*; +import sun.awt.AWTAccessor; class CAccessibility implements PropertyChangeListener { private static Set ignoredRoles; @@ -205,33 +206,12 @@ class CAccessibility implements PropertyChangeListener { }, c); } - static Field getAccessibleBundleKeyFieldWithReflection() { - try { - final Field fieldKey = AccessibleBundle.class.getDeclaredField("key"); - fieldKey.setAccessible(true); - return fieldKey; - } catch (final SecurityException e) { - e.printStackTrace(); - } catch (final NoSuchFieldException e) { - e.printStackTrace(); - } - return null; - } - private static final Field FIELD_KEY = getAccessibleBundleKeyFieldWithReflection(); - static String getAccessibleRoleFor(final Accessible a) { final AccessibleContext ac = a.getAccessibleContext(); if (ac == null) return null; final AccessibleRole role = ac.getAccessibleRole(); - try { - return (String)FIELD_KEY.get(role); - } catch (final IllegalArgumentException e) { - e.printStackTrace(); - } catch (final IllegalAccessException e) { - e.printStackTrace(); - } - return null; + return AWTAccessor.getAccessibleBundleAccessor().getKey(role); } public static String getAccessibleRole(final Accessible a, final Component c) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java index 6ac0a07ca0f..d3d3dca9538 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java @@ -28,7 +28,6 @@ package sun.lwawt.macosx; import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.lang.reflect.Field; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; @@ -41,36 +40,23 @@ import static javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT import static javax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY; import static javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY; import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY; +import sun.awt.AWTAccessor; class CAccessible extends CFRetainedResource implements Accessible { - static Field getNativeAXResourceField() { - try { - final Field field = AccessibleContext.class.getDeclaredField("nativeAXResource"); - field.setAccessible(true); - return field; - } catch (final Exception e) { - e.printStackTrace(); - return null; - } - } - - private static Field nativeAXResourceField = getNativeAXResourceField(); public static CAccessible getCAccessible(final Accessible a) { if (a == null) return null; AccessibleContext context = a.getAccessibleContext(); - try { - final CAccessible cachedCAX = (CAccessible) nativeAXResourceField.get(context); - if (cachedCAX != null) return cachedCAX; - - final CAccessible newCAX = new CAccessible(a); - nativeAXResourceField.set(context, newCAX); - return newCAX; - } catch (final Exception e) { - e.printStackTrace(); - return null; + AWTAccessor.AccessibleContextAccessor accessor + = AWTAccessor.getAccessibleContextAccessor(); + final CAccessible cachedCAX = (CAccessible) accessor.getNativeAXResource(context); + if (cachedCAX != null) { + return cachedCAX; } + final CAccessible newCAX = new CAccessible(a); + accessor.setNativeAXResource(context, newCAX); + return newCAX; } private static native void unregisterFromCocoaAXSystem(long ptr); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 3f05185c091..150c6e92ad1 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -36,7 +36,7 @@ import java.nio.charset.Charset; import java.text.Normalizer; import java.text.Normalizer.Form; import java.util.*; - +import java.util.regex.*; import java.awt.datatransfer.*; import sun.awt.datatransfer.*; @@ -129,12 +129,21 @@ public class CDataTransferer extends DataTransferer { long format, Transferable transferable) throws IOException { if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) { - String[] strings = dragQueryFile(bytes); - if(strings == null || strings.length == 0) { - return null; + String charset = Charset.defaultCharset().name(); + if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) { + try { + charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), "UTF-8"); + } catch (UnsupportedFlavorException cannotHappen) { + } } - return new URL(strings[0]); - } else if(isUriListFlavor(flavor)) { + + String xml = new String(bytes, charset); + // macosx pasteboard returns a property list that consists of one URL + // let's extract it. + return new URL(extractURL(xml)); + } + + if(isUriListFlavor(flavor) && format == CF_FILE) { // dragQueryFile works fine with files and url, // it parses and extracts values from property list. // maxosx always returns property list for @@ -156,6 +165,16 @@ public class CDataTransferer extends DataTransferer { return super.translateBytes(bytes, flavor, format, transferable); } + private String extractURL(String xml) { + Pattern urlExtractorPattern = Pattern.compile("(.*)"); + Matcher matcher = urlExtractorPattern.matcher(xml); + if (matcher.find()) { + return matcher.group(1); + } else { + return null; + } + } + @Override protected synchronized Long getFormatForNativeAsLong(String str) { Long format = predefinedClipboardNameMap.get(str); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java index a5504cbee25..61f41a2c70f 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java @@ -56,6 +56,25 @@ public class CImage extends CFRetainedResource { return creator; } + // This is used to create a CImage that represents the icon of the given file. + public static Image createImageOfFile(String file, int width, int height) { + return getCreator().createImageOfFile(file, width, height); + } + + public static Image createSystemImageFromSelector(String iconSelector, + int width, int height) { + return getCreator().createSystemImageFromSelector(iconSelector, width, height); + } + + public static Image createImageFromFile(String file, double width, double height) { + return getCreator().createImageFromFile(file, width, height); + } + + // This is used to create a CImage from a Image + public static CImage createFromImage(final Image image) { + return getCreator().createFromImage(image); + } + public static class Creator { Creator() { } diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m index f444bc9b693..fb2cb86a617 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -27,6 +27,8 @@ #import "AWTSurfaceLayers.h" +#import "jni_util.h" + JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo (JAWT_DrawingSurface* ds) { @@ -130,3 +132,47 @@ JNIEXPORT jobject JNICALL awt_GetComponent // TODO: implement return NULL; } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = (*env)->GetMethodID(env, cls, "", "(J)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return (*env)->NewObject(env, cls, mid, platformInfo); +} + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/macosx/native/libjawt/jawt.m b/jdk/src/java.desktop/macosx/native/libjawt/jawt.m index cd9f52a8e5e..773c6482caa 100644 --- a/jdk/src/java.desktop/macosx/native/libjawt/jawt.m +++ b/jdk/src/java.desktop/macosx/native/libjawt/jawt.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -46,8 +46,9 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT return JNI_FALSE; } - if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) && - awt->version != JAWT_VERSION_1_7) + if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -58,6 +59,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT awt->Lock = awt_Lock; awt->Unlock = awt_Unlock; awt->GetComponent = awt_GetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DLSInfo.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DLSInfo.java index c25be39d290..e1d8cb78c0b 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DLSInfo.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DLSInfo.java @@ -95,7 +95,7 @@ public final class DLSInfo { public String subject = null; /** * (ISRC) Name of person or orginization who supplied - * orginal material for the file. + * original material for the file. */ public String source = null; /** diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java index 028efffbd12..ead39be2867 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -200,11 +200,13 @@ public final class ModelByteBuffer { public void writeTo(OutputStream out) throws IOException { if (root.file != null && root.buffer == null) { - InputStream is = getInputStream(); - byte[] buff = new byte[1024]; - int ret; - while ((ret = is.read(buff)) != -1) - out.write(buff, 0, ret); + try (InputStream is = getInputStream()) { + byte[] buff = new byte[1024]; + int ret; + while ((ret = is.read(buff)) != -1) { + out.write(buff, 0, ret); + } + } } else out.write(array(), (int) arrayOffset(), (int) capacity()); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java index 1c723aeb133..9250597ac81 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java @@ -284,35 +284,6 @@ public abstract class AWTEvent extends EventObject { }); } - private static synchronized Field get_InputEvent_CanAccessSystemClipboard() { - if (inputEvent_CanAccessSystemClipboard_Field == null) { - inputEvent_CanAccessSystemClipboard_Field = - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Field run() { - Field field = null; - try { - field = InputEvent.class. - getDeclaredField("canAccessSystemClipboard"); - field.setAccessible(true); - return field; - } catch (SecurityException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got SecurityException ", e); - } - } catch (NoSuchFieldException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got NoSuchFieldException ", e); - } - } - return null; - } - }); - } - - return inputEvent_CanAccessSystemClipboard_Field; - } - /** * Initialize JNI field and method IDs for fields that may be * accessed from C. @@ -593,33 +564,20 @@ public abstract class AWTEvent extends EventObject { that.bdata = this.bdata; // Copy canAccessSystemClipboard value from this into that. if (this instanceof InputEvent && that instanceof InputEvent) { - Field field = get_InputEvent_CanAccessSystemClipboard(); - if (field != null) { - try { - boolean b = field.getBoolean(this); - field.setBoolean(that, b); - } catch(IllegalAccessException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); - } - } - } + + AWTAccessor.InputEventAccessor accessor + = AWTAccessor.getInputEventAccessor(); + + boolean b = accessor.canAccessSystemClipboard((InputEvent) this); + accessor.setCanAccessSystemClipboard((InputEvent) that, b); } that.isSystemGenerated = this.isSystemGenerated; } void dispatched() { if (this instanceof InputEvent) { - Field field = get_InputEvent_CanAccessSystemClipboard(); - if (field != null) { - try { - field.setBoolean(this, false); - } catch(IllegalAccessException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.dispatched() got IllegalAccessException ", e); - } - } - } + AWTAccessor.getInputEventAccessor(). + setCanAccessSystemClipboard((InputEvent) this, false); } } } // class AWTEvent diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java index c2a021fd595..25c6ee2b1aa 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Component.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java @@ -53,13 +53,11 @@ import java.beans.Transient; import java.awt.im.InputContext; import java.awt.im.InputMethodRequests; import java.awt.dnd.DropTarget; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.AccessControlContext; import javax.accessibility.*; import java.applet.Applet; +import javax.swing.JComponent; import sun.awt.ComponentFactory; import sun.security.action.GetPropertyAction; @@ -81,6 +79,7 @@ import sun.java2d.pipe.hw.ExtendedBufferCapabilities; import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; import sun.awt.RequestFocusController; import sun.java2d.SunGraphicsEnvironment; +import sun.swing.SwingAccessor; import sun.util.logging.PlatformLogger; /** @@ -8695,6 +8694,9 @@ public abstract class Component implements ImageObserver, MenuContainer, * the Swing package private method {@code compWriteObjectNotify}. */ private void doSwingSerialization() { + if (!(this instanceof JComponent)) { + return; + } @SuppressWarnings("deprecation") Package swingPackage = Package.getPackage("javax.swing"); // For Swing serialization to correctly work Swing needs to @@ -8707,36 +8709,10 @@ public abstract class Component implements ImageObserver, MenuContainer, klass = klass.getSuperclass()) { if (klass.getPackage() == swingPackage && klass.getClassLoader() == null) { - final Class swingClass = klass; - // Find the first override of the compWriteObjectNotify method - Method[] methods = AccessController.doPrivileged( - new PrivilegedAction() { - public Method[] run() { - return swingClass.getDeclaredMethods(); - } - }); - for (int counter = methods.length - 1; counter >= 0; - counter--) { - final Method method = methods[counter]; - if (method.getName().equals("compWriteObjectNotify")){ - // We found it, use doPrivileged to make it accessible - // to use. - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - method.setAccessible(true); - return null; - } - }); - // Invoke the method - try { - method.invoke(this, (Object[]) null); - } catch (IllegalAccessException iae) { - } catch (InvocationTargetException ite) { - } - // We're done, bail. - return; - } - } + + SwingAccessor.getJComponentAccessor() + .compWriteObjectNotify((JComponent) this); + return; } } } diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index aa9d64367a4..1e9e2f4bfd0 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -40,8 +40,6 @@ import java.beans.VetoableChangeSupport; import java.lang.ref.WeakReference; -import java.lang.reflect.Field; - import java.security.AccessController; import java.security.PrivilegedAction; @@ -140,6 +138,10 @@ public abstract class KeyboardFocusManager public void removeLastFocusRequest(Component heavyweight) { KeyboardFocusManager.removeLastFocusRequest(heavyweight); } + @Override + public Component getMostRecentFocusOwner(Window window) { + return KeyboardFocusManager.getMostRecentFocusOwner(window); + } public void setMostRecentFocusOwner(Window window, Component component) { KeyboardFocusManager.setMostRecentFocusOwner(window, component); } @@ -3053,32 +3055,9 @@ public abstract class KeyboardFocusManager } } - static Field proxyActive; // Accessor to private field isProxyActive of KeyEvent private static boolean isProxyActiveImpl(KeyEvent e) { - if (proxyActive == null) { - proxyActive = AccessController.doPrivileged(new PrivilegedAction() { - public Field run() { - Field field = null; - try { - field = KeyEvent.class.getDeclaredField("isProxyActive"); - if (field != null) { - field.setAccessible(true); - } - } catch (NoSuchFieldException nsf) { - assert(false); - } - return field; - } - }); - } - - try { - return proxyActive.getBoolean(e); - } catch (IllegalAccessException iae) { - assert(false); - } - return false; + return AWTAccessor.getKeyEventAccessor().isProxyActive(e); } // Returns the value of this KeyEvent's field isProxyActive diff --git a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java index 678067ab143..394686a7ba3 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java @@ -63,6 +63,10 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { public boolean isSequencedEvent(AWTEvent event) { return event instanceof SequencedEvent; } + + public AWTEvent create(AWTEvent event) { + return new SequencedEvent(event); + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java index d332d2d2735..ec9bd0be0a1 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java @@ -302,6 +302,12 @@ public abstract class InputEvent extends ComponentEvent { public boolean canAccessSystemClipboard(InputEvent event) { return event.canAccessSystemClipboard; } + + @Override + public void setCanAccessSystemClipboard(InputEvent event, + boolean canAccessSystemClipboard) { + event.canAccessSystemClipboard = canAccessSystemClipboard; + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java index f103d525271..0ca378d556b 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java @@ -1091,6 +1091,11 @@ public class KeyEvent extends InputEvent { public Component getOriginalSource( KeyEvent ev ) { return ev.originalSource; } + + @Override + public boolean isProxyActive(KeyEvent ev) { + return ev.isProxyActive; + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index cd4c9fdf224..738cd6c9dc9 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -25,7 +25,6 @@ package java.awt.font; -import java.lang.reflect.Field; import jdk.internal.misc.JavaAWTFontAccess; class JavaAWTFontAccessImpl implements JavaAWTFontAccess { @@ -33,19 +32,17 @@ class JavaAWTFontAccessImpl implements JavaAWTFontAccess { // java.awt.font.TextAttribute constants public Object getTextAttributeConstant(String name) { switch (name) { - case "RUN_DIRECTION": - case "NUMERIC_SHAPING": - case "BIDI_EMBEDDING": - case "RUN_DIRECTION_LTR": - try { - Field f = TextAttribute.class.getField(name); - return f.get(null); - } catch (NoSuchFieldException | IllegalAccessException x) { - throw new AssertionError(x); - } + case "RUN_DIRECTION": + return TextAttribute.RUN_DIRECTION; + case "NUMERIC_SHAPING": + return TextAttribute.NUMERIC_SHAPING; + case "BIDI_EMBEDDING": + return TextAttribute.BIDI_EMBEDDING; + case "RUN_DIRECTION_LTR": + return TextAttribute.RUN_DIRECTION_LTR; + default: + throw new AssertionError("Constant name is not recognized"); } - - throw new AssertionError("Constant name is not recognized"); } // java.awt.font.NumericShaper diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java index 936322af467..5e2d97b43e5 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java @@ -31,6 +31,7 @@ import java.util.Vector; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import sun.awt.AWTAccessor; /** *

            Base class used to maintain a strongly typed enumeration. This is @@ -53,6 +54,17 @@ public abstract class AccessibleBundle { private final String defaultResourceBundleName = "com.sun.accessibility.internal.resources.accessibility"; + static { + AWTAccessor.setAccessibleBundleAccessor( + new AWTAccessor.AccessibleBundleAccessor() { + + @Override + public String getKey(AccessibleBundle accessibleBundle) { + return accessibleBundle.key; + } + }); + } + /** * Construct an {@code AccessibleBundle}. */ diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java index 65a163fa4ca..c3a30f3a5ae 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java @@ -99,6 +99,16 @@ public abstract class AccessibleContext { public AppContext getAppContext(AccessibleContext accessibleContext) { return accessibleContext.targetAppContext; } + + @Override + public Object getNativeAXResource(AccessibleContext accessibleContext) { + return accessibleContext.nativeAXResource; + } + + @Override + public void setNativeAXResource(AccessibleContext accessibleContext, Object value) { + accessibleContext.nativeAXResource = value; + } }); } diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java index 7af7b77be77..523a857dbc1 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java @@ -462,10 +462,13 @@ public final class ImageIO { return new String[0]; } - HashSet s = new HashSet(); + HashSet s = new HashSet<>(); while (iter.hasNext()) { ImageReaderWriterSpi spi = iter.next(); - Collections.addAll(s, spiInfo.info(spi)); + String[] info = spiInfo.info(spi); + if (info != null) { + Collections.addAll(s, info); + } } return s.toArray(new String[s.size()]); diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index edcb086cb45..da9ade0d8f7 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -412,7 +412,7 @@ public class TIFFField implements Cloneable { /** * Creates a {@code TIFFField} from a TIFF native image - * metadata node. If the value of the "number" attribute + * metadata node. If the value of the {@code "number"} attribute * of the node is not found in {@code tagSet} then a new * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME} * will be created and assigned to the field. @@ -420,20 +420,22 @@ public class TIFFField implements Cloneable { * @param tagSet The {@code TIFFTagSet} to which the * {@code TIFFTag} of the field belongs. * @param node A native TIFF image metadata {@code TIFFField} node. - * @throws NullPointerException if {@code node} is - * {@code null}. - * @throws IllegalArgumentException if the name of the node is not - * {@code "TIFFField"}. - * @throws NullPointerException if the node does not contain any data. - * @throws IllegalArgumentException if the combination of node attributes - * and data is not legal per the {@link #TIFFField(TIFFTag,int,int,Object)} - * constructor specification. + * @throws IllegalArgumentException If the {@code Node} parameter content + * does not adhere to the {@code TIFFField} element structure defined by + * the + * TIFF native image metadata format specification, or if the + * combination of node attributes and data is not legal per the + * {@link #TIFFField(TIFFTag,int,int,Object)} constructor specification. + * Note that a cause might be set on such an exception. * @return A new {@code TIFFField}. */ public static TIFFField createFromMetadataNode(TIFFTagSet tagSet, Node node) { if (node == null) { - throw new NullPointerException("node == null!"); + // This method is specified to throw only IllegalArgumentExceptions + // so we create an IAE with a NullPointerException as its cause. + throw new IllegalArgumentException(new NullPointerException + ("node == null!")); } String name = node.getNodeName(); if (!name.equals("TIFFField")) { @@ -487,7 +489,17 @@ public class TIFFField implements Cloneable { tag = new TIFFTag(TIFFTag.UNKNOWN_TAG_NAME, tagNumber, 1 << type); } - return new TIFFField(tag, type, count, data); + TIFFField field; + try { + field = new TIFFField(tag, type, count, data); + } catch (NullPointerException npe) { + // This method is specified to throw only IllegalArgumentExceptions + // so we catch the NullPointerException and set it as the cause of + // the IAE which is thrown. + throw new IllegalArgumentException(npe); + } + + return field; } /** diff --git a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java index 82566e9f804..615de409bdf 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java +++ b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java @@ -40,6 +40,7 @@ import javax.print.attribute.AttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.Fidelity; +import sun.print.DialogOwner; import sun.print.ServiceDialog; import sun.print.SunAlternateMedia; @@ -187,9 +188,8 @@ public class ServiceUI { defaultIndex = 0; } - // For now we set owner to null. In the future, it may be passed - // as an argument. - Window owner = null; + DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); + Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null; Rectangle gcBounds = (gc == null) ? GraphicsEnvironment. getLocalGraphicsEnvironment().getDefaultScreenDevice(). diff --git a/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java b/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java index af5947e5eec..65fddf32df9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java @@ -26,6 +26,7 @@ package javax.swing; import java.awt.*; import java.awt.image.*; +import sun.awt.image.MultiResolutionCachedImage; /** * An image filter that "disables" an image by turning @@ -48,7 +49,16 @@ public class GrayFilter extends RGBImageFilter { * @param i an {@code Image} to be created as disabled * @return the new grayscale image created from {@code i} */ - public static Image createDisabledImage (Image i) { + public static Image createDisabledImage(Image i) { + if (i instanceof MultiResolutionImage) { + return MultiResolutionCachedImage + .map((MultiResolutionImage) i, + (img) -> createDisabledImageImpl(img)); + } + return createDisabledImageImpl(i); + } + + private static Image createDisabledImageImpl(Image i) { GrayFilter filter = new GrayFilter(true, 50); ImageProducer prod = new FilteredImageSource(i.getSource(), filter); Image grayImage = Toolkit.getDefaultToolkit().createImage(prod); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java index 8a63fe74cab..e12241f5771 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java @@ -40,8 +40,8 @@ import java.util.Locale; import javax.accessibility.*; import sun.awt.AppContext; -import java.lang.reflect.Field; import java.security.*; +import sun.awt.AWTAccessor; /** * An implementation of the Icon interface that paints Icons @@ -106,11 +106,8 @@ public class ImageIcon implements Icon, Serializable, Accessible { final Component component = createNoPermsComponent(); // 6482575 - clear the appContext field so as not to leak it - Field appContextField = - - Component.class.getDeclaredField("appContext"); - appContextField.setAccessible(true); - appContextField.set(component, null); + AWTAccessor.getComponentAccessor(). + setAppContext(component, null); return component; } catch (Throwable e) { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java index 3d6025407d9..74abca7dc54 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java @@ -55,6 +55,7 @@ import javax.accessibility.*; import sun.awt.AWTAccessor; import sun.awt.SunToolkit; +import sun.swing.SwingAccessor; import sun.swing.SwingUtilities2; /** @@ -376,6 +377,21 @@ public abstract class JComponent extends Container implements Serializable, private transient Object aaHint; private transient Object lcdRenderingHint; + static { + SwingAccessor.setJComponentAccessor(new SwingAccessor.JComponentAccessor() { + + @Override + public boolean getFlag(JComponent comp, int aFlag) { + return comp.getFlag(aFlag); + } + + @Override + public void compWriteObjectNotify(JComponent comp) { + comp.compWriteObjectNotify(); + } + }); + } + static Graphics safelyGetGraphics(Component c) { return safelyGetGraphics(c, SwingUtilities.getRoot(c)); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java index 2698c90bc6e..894f3fabe18 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java @@ -261,23 +261,7 @@ public class GlyphView extends View implements TabableView, Cloneable { if (painter == null) { if (defaultPainter == null) { // the classname should probably come from a property file. - String classname = "javax.swing.text.GlyphPainter1"; - try { - Class c; - ClassLoader loader = getClass().getClassLoader(); - if (loader != null) { - c = loader.loadClass(classname); - } else { - c = Class.forName(classname); - } - Object o = c.newInstance(); - if (o instanceof GlyphPainter) { - defaultPainter = (GlyphPainter) o; - } - } catch (Throwable e) { - throw new StateInvariantError("GlyphView: Can't load glyph painter: " - + classname); - } + defaultPainter = new GlyphPainter1(); } setGlyphPainter(defaultPainter.getPainter(this, getStartOffset(), getEndOffset())); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java index 154db5cf7ef..fc96021ccc3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java @@ -61,20 +61,8 @@ public class ParagraphView extends FlowView implements TabExpander { Object i18nFlag = doc.getProperty(AbstractDocument.I18NProperty); if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) { try { - if (i18nStrategy == null) { - // the classname should probably come from a property file. - String classname = "javax.swing.text.TextLayoutStrategy"; - ClassLoader loader = getClass().getClassLoader(); - if (loader != null) { - i18nStrategy = loader.loadClass(classname); - } else { - i18nStrategy = Class.forName(classname); - } - } - Object o = i18nStrategy.newInstance(); - if (o instanceof FlowStrategy) { - strategy = (FlowStrategy) o; - } + // the classname should probably come from a property file. + strategy = new TextLayoutStrategy(); } catch (Throwable e) { throw new StateInvariantError("ParagraphView: Can't create i18n strategy: " + e.getMessage()); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java index 78157460653..57beae1ddb9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java @@ -40,6 +40,7 @@ import javax.accessibility.*; import java.lang.ref.*; import java.security.AccessController; import java.security.PrivilegedAction; +import javax.swing.text.html.parser.ParserDelegator; /** * The Swing JEditorPane text component supports different kinds @@ -610,11 +611,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { */ protected Parser getParser() { if (defaultParser == null) { - try { - Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator"); - defaultParser = (Parser) c.newInstance(); - } catch (Throwable e) { - } + defaultParser = new ParserDelegator(); } return defaultParser; } diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java index 404131827fe..d03e5be0527 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java @@ -616,34 +616,8 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable { * calls KeyboardFocusManager directly. */ private Component getMostRecentFocusOwnerForWindow(Window w) { - Method meth = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Method run() { - Method meth = null; - try { - meth = KeyboardFocusManager.class.getDeclaredMethod( - "getMostRecentFocusOwner", - new Class[]{Window.class}); - meth.setAccessible(true); - } catch (Exception e) { - // Must never happen - e.printStackTrace(); - } - return meth; - } - }); - if (meth != null) { - // Meth refers static method - try { - return (Component)meth.invoke(null, new Object[] {w}); - } catch (Exception e) { - // Must never happen - e.printStackTrace(); - } - } - // Will get here if exception was thrown or meth is null - return w.getMostRecentFocusOwner(); + return AWTAccessor.getKeyboardFocusManagerAccessor() + .getMostRecentFocusOwner(w); } /* diff --git a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index 796b7ab5d79..f59f064c111 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -34,6 +34,7 @@ import java.awt.dnd.DragSourceContext; import java.awt.dnd.DropTargetContext; import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.dnd.peer.DropTargetContextPeer; +import java.awt.event.AWTEventListener; import java.awt.event.InputEvent; import java.awt.event.InvocationEvent; import java.awt.event.KeyEvent; @@ -48,6 +49,7 @@ import java.security.AccessControlContext; import java.io.File; import java.util.ResourceBundle; import java.util.Vector; +import javax.accessibility.AccessibleBundle; /** * The AWTAccessor utility class. @@ -406,6 +408,8 @@ public final class AWTAccessor { * Accessor for InputEvent.canAccessSystemClipboard field */ boolean canAccessSystemClipboard(InputEvent event); + void setCanAccessSystemClipboard(InputEvent event, + boolean canAccessSystemClipboard); } /* @@ -454,6 +458,11 @@ public final class AWTAccessor { */ void removeLastFocusRequest(Component heavyweight); + /** + * Gets the most recent focus owner in the window. + */ + Component getMostRecentFocusOwner(Window window); + /** * Sets the most recent focus owner in the window. */ @@ -708,6 +717,11 @@ public final class AWTAccessor { * Gets original source for KeyEvent */ Component getOriginalSource(KeyEvent ev); + + /** + * Gets isProxyActive field for KeyEvent + */ + boolean isProxyActive(KeyEvent ev); } /** @@ -758,6 +772,11 @@ public final class AWTAccessor { * Returns true if the event is an instances of SequencedEvent. */ boolean isSequencedEvent(AWTEvent event); + + /* + * Creates SequencedEvent with the given nested event + */ + AWTEvent create(AWTEvent event); } /* @@ -787,6 +806,15 @@ public final class AWTAccessor { public interface AccessibleContextAccessor { void setAppContext(AccessibleContext accessibleContext, AppContext appContext); AppContext getAppContext(AccessibleContext accessibleContext); + Object getNativeAXResource(AccessibleContext accessibleContext); + void setNativeAXResource(AccessibleContext accessibleContext, Object value); + } + + /* + * An accessor object for the AccessibleContext class + */ + public interface AccessibleBundleAccessor { + String getKey(AccessibleBundle accessibleBundle); } /* @@ -845,6 +873,7 @@ public final class AWTAccessor { private static InvocationEventAccessor invocationEventAccessor; private static SystemColorAccessor systemColorAccessor; private static AccessibleContextAccessor accessibleContextAccessor; + private static AccessibleBundleAccessor accessibleBundleAccessor; private static DragSourceContextAccessor dragSourceContextAccessor; private static DropTargetContextAccessor dropTargetContextAccessor; @@ -1235,9 +1264,13 @@ public final class AWTAccessor { * Get the accessor object for the java.awt.SequencedEvent class. */ public static SequencedEventAccessor getSequencedEventAccessor() { - // The class is not public. So we can't ensure it's initialized. - // Null returned value means it's not initialized - // (so not a single instance of the event has been created). + if (sequencedEventAccessor == null) { + try { + unsafe.ensureClassInitialized( + Class.forName("java.awt.SequencedEvent")); + } catch (ClassNotFoundException ignore) { + } + } return sequencedEventAccessor; } @@ -1301,6 +1334,23 @@ public final class AWTAccessor { return accessibleContextAccessor; } + /* + * Set the accessor object for the javax.accessibility.AccessibleBundle class. + */ + public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) { + AWTAccessor.accessibleBundleAccessor = accessor; + } + + /* + * Get the accessor object for the javax.accessibility.AccessibleBundle class. + */ + public static AccessibleBundleAccessor getAccessibleBundleAccessor() { + if (accessibleBundleAccessor == null) { + unsafe.ensureClassInitialized(AccessibleBundle.class); + } + return accessibleBundleAccessor; + } + /* * Set the accessor object for the javax.accessibility.AccessibleContext class. */ @@ -1342,4 +1392,4 @@ public final class AWTAccessor { AWTAccessor.dropTargetContextAccessor = accessor; } -} +} \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 8461974375f..c017454ec0f 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -372,26 +372,6 @@ public abstract class SunToolkit extends Toolkit cont.setFocusTraversalPolicy(defaultPolicy); } - private static FocusTraversalPolicy createLayoutPolicy() { - FocusTraversalPolicy policy = null; - try { - Class layoutPolicyClass = - Class.forName("javax.swing.LayoutFocusTraversalPolicy"); - policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance(); - } - catch (ClassNotFoundException e) { - assert false; - } - catch (InstantiationException e) { - assert false; - } - catch (IllegalAccessException e) { - assert false; - } - - return policy; - } - /* * Insert a mapping from target to AppContext, for later retrieval * via targetToAppContext() above. diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java index 8d8acdcf0a3..76bbfcff0f5 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.function.Function; import java.util.function.BiFunction; import java.util.stream.Collectors; +import java.awt.image.MultiResolutionImage; import java.awt.image.AbstractMultiResolutionImage; public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { @@ -44,17 +45,30 @@ public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { private int availableInfo; public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, - BiFunction mapper) { - this(baseImageWidth, baseImageHeight, new Dimension[]{new Dimension( - baseImageWidth, baseImageHeight) + BiFunction mapper) + { + this(baseImageWidth, baseImageHeight, + new Dimension[]{new Dimension( baseImageWidth, baseImageHeight) }, mapper); } public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, - Dimension2D[] sizes, BiFunction mapper) { + Dimension2D[] sizes, + BiFunction mapper) + { + this(baseImageWidth, baseImageHeight, sizes, mapper, true); + } + + private MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, + Dimension2D[] sizes, + BiFunction mapper, + boolean copySizes) + { this.baseImageWidth = baseImageWidth; this.baseImageHeight = baseImageHeight; - this.sizes = (sizes == null) ? null : Arrays.copyOf(sizes, sizes.length); + this.sizes = (copySizes && sizes != null) + ? Arrays.copyOf(sizes, sizes.length) + : sizes; this.mapper = mapper; } @@ -99,6 +113,35 @@ public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { mapper.apply(getResolutionVariant(width, height))); } + public static Image map(MultiResolutionImage mrImage, + Function mapper) { + + if (mrImage instanceof MultiResolutionToolkitImage) { + MultiResolutionToolkitImage mrtImage = + (MultiResolutionToolkitImage) mrImage; + return MultiResolutionToolkitImage.map(mrtImage, mapper); + } + + BiFunction sizeMapper + = (w, h) -> mapper.apply(mrImage.getResolutionVariant(w, h)); + + if (mrImage instanceof MultiResolutionCachedImage) { + MultiResolutionCachedImage mrcImage + = (MultiResolutionCachedImage) mrImage; + + return new MultiResolutionCachedImage(mrcImage.baseImageWidth, + mrcImage.baseImageHeight, + mrcImage.sizes, + sizeMapper, + false); + } + + Image image = (Image) mrImage; + int width = image.getWidth(null); + int height = image.getHeight(null); + return new MultiResolutionCachedImage(width, height, sizeMapper); + } + @Override public int getWidth(ImageObserver observer) { updateInfo(observer, ImageObserver.WIDTH); diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java index 26a86916824..dfe08735a15 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java @@ -29,6 +29,7 @@ import java.awt.image.ImageObserver; import java.awt.image.MultiResolutionImage; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import sun.awt.SoftCache; public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage { @@ -47,6 +48,13 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe ? this : resolutionVariant; } + public static Image map(MultiResolutionToolkitImage mrImage, + Function mapper) { + Image baseImage = mapper.apply(mrImage); + Image rvImage = mapper.apply(mrImage.resolutionVariant); + return new MultiResolutionToolkitImage(baseImage, rvImage); + } + private static void checkSize(double width, double height) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException(String.format( diff --git a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java index abe8bd9ab7a..f80e10c9778 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java +++ b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java @@ -33,11 +33,8 @@ import java.awt.GraphicsEnvironment; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.HeadlessException; -import java.awt.Rectangle; import java.awt.Shape; -import java.awt.image.BufferedImage; - import java.awt.font.FontRenderContext; import java.awt.geom.AffineTransform; @@ -46,7 +43,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import java.awt.peer.FontPeer; import java.awt.print.Pageable; import java.awt.print.PageFormat; import java.awt.print.Paper; @@ -55,14 +51,12 @@ import java.awt.print.PrinterException; import java.awt.print.PrinterIOException; import java.awt.print.PrinterJob; -import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.StreamPrintService; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.PrinterName; -import javax.print.attribute.standard.Chromaticity; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; @@ -72,7 +66,6 @@ import javax.print.attribute.standard.Sides; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; -import java.io.CharConversionException; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; @@ -85,17 +78,14 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import java.util.Properties; import sun.awt.CharsetString; import sun.awt.FontConfiguration; -import sun.awt.FontDescriptor; import sun.awt.PlatformFont; import sun.awt.SunToolkit; import sun.font.FontAccess; -import sun.font.FontManagerFactory; import sun.font.FontUtilities; import java.nio.charset.*; @@ -105,7 +95,9 @@ import java.nio.file.Files; //REMIND: Remove use of this class when IPPPrintService is moved to share directory. import java.lang.reflect.Method; +import javax.print.attribute.Attribute; import javax.print.attribute.standard.JobSheets; +import javax.print.attribute.standard.Media; /** * A class which initiates and executes a PostScript printer job. @@ -489,6 +481,23 @@ public class PSPrinterJob extends RasterPrinterJob { return doPrint; } + @Override + protected void setAttributes(PrintRequestAttributeSet attributes) + throws PrinterException { + super.setAttributes(attributes); + if (attributes == null) { + return; // now always use attributes, so this shouldn't happen. + } + Attribute attr = attributes.get(Media.class); + if (attr instanceof CustomMediaTray) { + CustomMediaTray customTray = (CustomMediaTray)attr; + String choice = customTray.getChoiceName(); + if (choice != null) { + mOptions = " InputSlot="+ choice; + } + } + } + /** * Invoked by the RasterPrinterJob super class * this method is called to mark the start of a @@ -1629,7 +1638,7 @@ public class PSPrinterJob extends RasterPrinterJob { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { - execCmd[n++] = new String(options); + execCmd[n++] = "-o" + options; } } else { ncomps+=1; //add 1 arg for lp diff --git a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java index 59797508b2e..5dd2b4de046 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java +++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java @@ -944,6 +944,10 @@ public class ServiceDialog extends JDialog implements ActionListener { } catch (MalformedURLException ex) { dstSupported = true; } + } else { + if (psCurrent.isAttributeCategorySupported(dstCategory)) { + dstSupported = true; + } } cbPrintToFile.setEnabled(dstSupported && dstAllowed); cbPrintToFile.setSelected(dstSelected && dstAllowed diff --git a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java index 66d20f2458b..76a9f63ec1b 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java @@ -50,6 +50,16 @@ public final class SwingAccessor { private SwingAccessor() { } + /** + * An accessor for the JComponent class. + */ + public interface JComponentAccessor { + + boolean getFlag(JComponent comp, int aFlag); + + void compWriteObjectNotify(JComponent comp); + } + /** * An accessor for the JTextComponent class. * Note that we intentionally introduce the JTextComponentAccessor, @@ -105,6 +115,29 @@ public final class SwingAccessor { KeyStroke create(); } + /** + * The javax.swing.JComponent class accessor object. + */ + private static JComponentAccessor jComponentAccessor; + + /** + * Set an accessor object for the javax.swing.JComponent class. + */ + public static void setJComponentAccessor(JComponentAccessor jCompAccessor) { + jComponentAccessor = jCompAccessor; + } + + /** + * Retrieve the accessor object for the javax.swing.JComponent class. + */ + public static JComponentAccessor getJComponentAccessor() { + if (jComponentAccessor == null) { + unsafe.ensureClassInitialized(JComponent.class); + } + + return jComponentAccessor; + } + /** * The javax.swing.text.JTextComponent class accessor object. */ diff --git a/jdk/src/java.desktop/share/native/include/jawt.h b/jdk/src/java.desktop/share/native/include/jawt.h index e0f682f4305..8cb2cb8564d 100644 --- a/jdk/src/java.desktop/share/native/include/jawt.h +++ b/jdk/src/java.desktop/share/native/include/jawt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #endif /* - * AWT native interface (new in JDK 1.3) + * AWT native interface. * * The AWT native interface allows a native C or C++ application a means * by which to access native structures in AWT. This is to facilitate moving @@ -279,6 +279,50 @@ typedef struct jawt { */ jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); + /** + * Since 9 + * Creates a java.awt.Frame placed in a native container. Container is + * referenced by the native platform handle. For example on Windows this + * corresponds to an HWND. For other platforms, see the appropriate + * machine-dependent header file for a description. The reference returned + * by this function is a local reference that is only valid in this + * environment. This function returns a NULL reference if no frame could be + * created with matching platform information. + */ + jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo); + + /** + * Since 9 + * Moves and resizes the embedded frame. The new location of the top-left + * corner is specified by x and y parameters relative to the native parent + * component. The new size is specified by width and height. + * + * The embedded frame should be created by CreateEmbeddedFrame() method, or + * this function will not have any effect. + * + * java.awt.Component.setLocation() and java.awt.Component.setBounds() for + * EmbeddedFrame really don't move it within the native parent. These + * methods always locate the embedded frame at (0, 0) for backward + * compatibility. To allow moving embedded frames this method was + * introduced, and it works just the same way as setLocation() and + * setBounds() for usual, non-embedded components. + * + * Using usual get/setLocation() and get/setBounds() together with this new + * method is not recommended. + */ + void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame, + jint x, jint y, jint w, jint h); + /** + * Since 9 + * Synthesize a native message to activate or deactivate an EmbeddedFrame + * window depending on the value of parameter doActivate, if "true" + * activates the window; otherwise, deactivates the window. + * + * The embedded frame should be created by CreateEmbeddedFrame() method, or + * this function will not have any effect. + */ + void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env, + jobject embeddedFrame, jboolean doActivate); } JAWT; /* @@ -291,6 +335,7 @@ jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); #define JAWT_VERSION_1_3 0x00010003 #define JAWT_VERSION_1_4 0x00010004 #define JAWT_VERSION_1_7 0x00010007 +#define JAWT_VERSION_9 0x00090000 #ifdef __cplusplus } /* extern "C" */ diff --git a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c index 472b5eed491..15c705a5fec 100644 --- a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c +++ b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -772,6 +772,7 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this, mlib_image *src; mlib_image *dst; int i; + int j = 0; int retStatus = 1; mlib_status status; double *matrix; @@ -824,6 +825,15 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this, return 0; } + /* Check for invalid double value in transformation matrix */ + for (j = 0; j < 6; j++) { + + if (!(IS_FINITE(matrix[j]))) { + (*env)->ReleasePrimitiveArrayCritical(env, jmatrix, matrix, JNI_ABORT); + return 0; + } + } + if (s_printIt) { printf("matrix is %g %g %g %g %g %g\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); @@ -980,6 +990,7 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this, mlib_image *src; mlib_image *dst; int i; + int j = 0; int retStatus = 1; mlib_status status; double *matrix; @@ -1044,6 +1055,18 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this, return 0; } + /* Check for invalid double value in transformation matrix */ + for (j = 0; j < 6; j++) { + + if (!(IS_FINITE(matrix[j]))) { + (*env)->ReleasePrimitiveArrayCritical(env, jmatrix, matrix, JNI_ABORT); + free(srcRasterP); + free(dstRasterP); + + return 0; + } + } + if (s_printIt) { printf("matrix is %g %g %g %g %g %g\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index 485c42a7b96..d8de3e36d92 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -72,12 +72,13 @@ static int init_JNI_IDs(JNIEnv *env) { int storeGVData(JNIEnv* env, jobject gvdata, jint slot, jint baseIndex, jobject startPt, int glyphCount, hb_glyph_info_t *glyphInfo, - hb_glyph_position_t *glyphPos, hb_direction_t direction) { + hb_glyph_position_t *glyphPos, hb_direction_t direction, + float devScale) { int i; float x=0, y=0; float startX, startY; - float scale = 1.0f/64.0f; + float scale = 1.0f/64.0f/devScale; unsigned int* glyphs; float* positions; int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; @@ -216,7 +217,11 @@ JDKFontInfo* fi->ptSize = ptSize; fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]); fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]); - + if (!aat && (getenv("HB_NODEVTX") != NULL)) { + fi->devScale = fi->xPtSize / fi->ptSize; + } else { + fi->devScale = 1.0f; + } return fi; } @@ -309,7 +314,8 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape // by calling code. storeGVData(env, gvdata, slot, baseIndex, startPt, - glyphCount, glyphInfo, glyphPos, direction); + glyphCount, glyphInfo, glyphPos, direction, + jdkFontInfo->devScale); hb_buffer_destroy (buffer); hb_font_destroy(hbfont); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index 1727bb80ea3..93ac190b4d1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -81,6 +81,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, return 0; } fadv = env->GetFloatField(pt, sunFontIDs.xFID); + fadv *= jdkFontInfo->devScale; env->DeleteLocalRef(pt); return FloatToF26Dot6(fadv); // should this round ? @@ -324,8 +325,8 @@ static hb_font_t* _hb_jdk_font_create(JDKFontInfo *jdkFontInfo, _hb_jdk_get_font_funcs (), jdkFontInfo, (hb_destroy_func_t) _do_nothing); hb_font_set_scale (font, - FloatToF26Dot6(jdkFontInfo->xPtSize), - FloatToF26Dot6(jdkFontInfo->yPtSize)); + FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale), + FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h index c17ea12ebbc..1cd8d5ba241 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h @@ -43,6 +43,7 @@ typedef struct JDKFontInfo_Struct { float ptSize; float xPtSize; float yPtSize; + float devScale; // How much applying the full glyph tx scales x distance. jboolean aat; } JDKFontInfo; diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c index 34c2171274e..e151de73cc9 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ #include "mlib_image.h" #include "mlib_SysMath.h" #include "mlib_ImageAffine.h" +#include "safe_math.h" + /***************************************************************/ mlib_status mlib_AffineEdges(mlib_affine_param *param, @@ -83,6 +85,12 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, dstYStride = mlib_ImageGetStride(dst); paddings = mlib_ImageGetPaddings(src); + /* All the transformation matrix parameters should be finite. if not, return failure */ + if (!(IS_FINITE(a) && IS_FINITE(b) && IS_FINITE(c) && IS_FINITE(d) && + IS_FINITE(tx) && IS_FINITE(ty))) { + return MLIB_FAILURE; + } + if (srcWidth >= (1 << 15) || srcHeight >= (1 << 15)) { return MLIB_FAILURE; } @@ -288,6 +296,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if (dY1 == dY2) continue; + if (!(IS_FINITE(slope))) { + continue; + } + if (dY1 < 0.0) y1 = 0; else { @@ -328,6 +340,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if (dY1 == dY2) continue; + if (!(IS_FINITE(slope))) { + continue; + } + if (dY1 < 0.0) y1 = 0; else { diff --git a/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h b/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h index 34c1fc56e9a..a87eba11723 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -26,10 +26,15 @@ #ifndef __SAFE_MATH_H__ #define __SAFE_MATH_H__ +#include "mlib_types.h" + #define SAFE_TO_MULT(a, b) \ (((a) > 0) && ((b) >= 0) && ((0x7fffffff / (a)) > (b))) #define SAFE_TO_ADD(a, b) \ (((a) >= 0) && ((b) >= 0) && ((0x7fffffff - (a)) > (b))) +#define IS_FINITE(a) \ + (((a) >= MLIB_D64_MIN) && ((a) <= MLIB_D64_MAX)) + #endif // __SAFE_MATH_H__ diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c index 2d3d88225e9..1c1b217654e 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c @@ -114,7 +114,7 @@ DGifOpenFileHandle(int FileHandle, int *Error) GifFile->SavedImages = NULL; GifFile->SColorMap = NULL; - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); + Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType)); if (Private == NULL) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; @@ -122,6 +122,9 @@ DGifOpenFileHandle(int FileHandle, int *Error) free((char *)GifFile); return NULL; } + + /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType)); + #ifdef _WIN32 _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ #endif /* _WIN32 */ @@ -197,13 +200,14 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error) GifFile->SavedImages = NULL; GifFile->SColorMap = NULL; - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); + Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType)); if (!Private) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; free((char *)GifFile); return NULL; } + /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType)); GifFile->Private = (void *)Private; Private->FileHandle = 0; @@ -417,8 +421,8 @@ DGifGetImageDesc(GifFileType *GifFile) if (GifFile->SavedImages) { SavedImage* new_saved_images = - (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); + (SavedImage *)reallocarray(GifFile->SavedImages, + (GifFile->ImageCount + 1), sizeof(SavedImage)); if (new_saved_images == NULL) { GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM; return GIF_ERROR; @@ -788,6 +792,12 @@ DGifSetupDecompress(GifFileType *GifFile) } BitsPerPixel = CodeSize; + /* this can only happen on a severely malformed GIF */ + if (BitsPerPixel > 8) { + GifFile->Error = D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */ + return GIF_ERROR; /* Failed to read Code size. */ + } + Private->Buf[0] = 0; /* Input Buffer empty. */ Private->BitsPerPixel = BitsPerPixel; Private->ClearCode = (1 << BitsPerPixel); @@ -1123,7 +1133,7 @@ DGifSlurp(GifFileType *GifFile) if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) { return GIF_ERROR; } - sp->RasterBits = (unsigned char *)malloc(ImageSize * + sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize, sizeof(GifPixelType)); if (sp->RasterBits == NULL) { diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h index aa356362bf6..e8d7090bd10 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h @@ -37,7 +37,7 @@ extern "C" { #define GIFLIB_MAJOR 5 #define GIFLIB_MINOR 1 -#define GIFLIB_RELEASE 1 +#define GIFLIB_RELEASE 4 #define GIF_ERROR 0 #define GIF_OK 1 @@ -274,6 +274,9 @@ extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1, GifPixelType ColorTransIn2[]); extern int GifBitSize(int n); +extern void * reallocarray(void *optr, size_t nmemb, size_t size); + + /****************************************************************************** Support for the in-core structures allocation (slurp mode). ******************************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c index f7a6a3d8f28..cc784d19bd8 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c @@ -212,8 +212,8 @@ GifUnionColorMap(const ColorMapObject *ColorIn1, /* perhaps we can shrink the map? */ if (RoundUpTo < ColorUnion->ColorCount) { - GifColorType *new_map = (GifColorType *)realloc(Map, - sizeof(GifColorType) * RoundUpTo); + GifColorType *new_map = (GifColorType *)reallocarray(Map, + RoundUpTo, sizeof(GifColorType)); if( new_map == NULL ) { GifFreeMapObject(ColorUnion); return ((ColorMapObject *) NULL); @@ -256,9 +256,9 @@ GifAddExtensionBlock(int *ExtensionBlockCount, if (*ExtensionBlocks == NULL) *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock)); else { - ExtensionBlock* ep_new = (ExtensionBlock *)realloc(*ExtensionBlocks, - sizeof(ExtensionBlock) * - (*ExtensionBlockCount + 1)); + ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray + (*ExtensionBlocks, (*ExtensionBlockCount + 1), + sizeof(ExtensionBlock)); if( ep_new == NULL ) return (GIF_ERROR); *ExtensionBlocks = ep_new; @@ -349,8 +349,8 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) if (GifFile->SavedImages == NULL) GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); else - GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); + GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages, + (GifFile->ImageCount + 1), sizeof(SavedImage)); if (GifFile->SavedImages == NULL) return ((SavedImage *)NULL); @@ -379,9 +379,10 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) } /* next, the raster */ - sp->RasterBits = (unsigned char *)malloc(sizeof(GifPixelType) * - CopyFrom->ImageDesc.Height * - CopyFrom->ImageDesc.Width); + sp->RasterBits = (unsigned char *)reallocarray(NULL, + (CopyFrom->ImageDesc.Height * + CopyFrom->ImageDesc.Width), + sizeof(GifPixelType)); if (sp->RasterBits == NULL) { FreeLastSavedImage(GifFile); return (SavedImage *)(NULL); @@ -392,9 +393,9 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) /* finally, the extension blocks */ if (sp->ExtensionBlocks != NULL) { - sp->ExtensionBlocks = (ExtensionBlock *)malloc( - sizeof(ExtensionBlock) * - CopyFrom->ExtensionBlockCount); + sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL, + CopyFrom->ExtensionBlockCount, + sizeof(ExtensionBlock)); if (sp->ExtensionBlocks == NULL) { FreeLastSavedImage(GifFile); return (SavedImage *)(NULL); diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c new file mode 100644 index 00000000000..1087671c27b --- /dev/null +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c @@ -0,0 +1,106 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/* $OpenBSD: reallocarray.c,v 1.1 2014/05/08 21:43:49 deraadt Exp $ */ +/* + * Copyright (c) 2008 Otto Moerbeek + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +/* + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW + */ +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) + +void * +reallocarray(void *optr, size_t nmemb, size_t size) +{ + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && + nmemb > 0 && SIZE_MAX / nmemb < size) { + errno = ENOMEM; + return NULL; + } + /* + * Head off variations in realloc behavior on different + * platforms (reported by MarkR ) + * + * The behaviour of reallocarray is implementation-defined if + * nmemb or size is zero. It can return NULL or non-NULL + * depending on the platform. + * https://www.securecoding.cert.org/confluence/display/c/MEM04-C.Beware+of+zero-lengthallocations + * + * Here are some extracts from realloc man pages on different platforms. + * + * void realloc( void memblock, size_t size ); + * + * Windows: + * + * If there is not enough available memory to expand the block + * to the given size, the original block is left unchanged, + * and NULL is returned. If size is zero, then the block + * pointed to by memblock is freed; the return value is NULL, + * and memblock is left pointing at a freed block. + * + * OpenBSD: + * + * If size or nmemb is equal to 0, a unique pointer to an + * access protected, zero sized object is returned. Access via + * this pointer will generate a SIGSEGV exception. + * + * Linux: + * + * If size was equal to 0, either NULL or a pointer suitable + * to be passed to free() is returned. + * + * OS X: + * + * If size is zero and ptr is not NULL, a new, minimum sized + * object is allocated and the original object is freed. + * + * It looks like images with zero width or height can trigger + * this, and fuzzing behaviour will differ by platform, so + * fuzzing on one platform may not detect zero-size allocation + * problems on other platforms. + */ + if (size == 0 || nmemb == 0) + return NULL; + return realloc(optr, size * nmemb); +} diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java index c65a7c79f96..846e06bb864 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java @@ -57,8 +57,6 @@ import java.awt.image.ImageProducer; import java.awt.image.VolatileImage; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; -import java.lang.reflect.*; -import java.security.*; import java.util.Collection; import java.util.Objects; import java.util.Set; @@ -241,46 +239,8 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget return false; } - private static Class seClass; - private static Constructor seCtor; - static final AWTEvent wrapInSequenced(AWTEvent event) { - try { - if (seClass == null) { - seClass = Class.forName("java.awt.SequencedEvent"); - } - - if (seCtor == null) { - seCtor = AccessController.doPrivileged(new - PrivilegedExceptionAction>() { - public Constructor run() throws Exception { - Constructor ctor = seClass.getConstructor( - new Class[] { AWTEvent.class }); - ctor.setAccessible(true); - return ctor; - } - }); - } - - return (AWTEvent) seCtor.newInstance(new Object[] { event }); - } - catch (ClassNotFoundException e) { - throw new NoClassDefFoundError("java.awt.SequencedEvent."); - } - catch (PrivilegedActionException ex) { - throw new NoClassDefFoundError("java.awt.SequencedEvent."); - } - catch (InstantiationException e) { - assert false; - } - catch (IllegalAccessException e) { - assert false; - } - catch (InvocationTargetException e) { - assert false; - } - - return null; + return AWTAccessor.getSequencedEventAccessor().create(event); } // TODO: consider moving it to KeyboardFocusManagerPeerImpl diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java index 4422e7a8b35..e457c43e91e 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java @@ -36,10 +36,6 @@ import java.awt.dnd.DragGestureListener; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -import java.lang.reflect.*; import sun.awt.dnd.SunDragSourceContextPeer; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java index 907446ad81c..0c5cc361c76 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java @@ -32,8 +32,6 @@ import java.awt.image.ColorModel; import java.lang.ref.WeakReference; -import java.lang.reflect.Method; - import sun.awt.AWTAccessor.ComponentAccessor; import sun.util.logging.PlatformLogger; @@ -395,7 +393,6 @@ class XWindow extends XBaseWindow implements X11ComponentPeer { return false; } - static Method m_sendMessage; static void sendEvent(final AWTEvent e) { // The uses of this method imply that the incoming event is system-generated SunToolkit.setSystemGenerated(e); diff --git a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java index 7d79243d393..06b086e59a2 100644 --- a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java +++ b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java @@ -41,14 +41,12 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.util.Vector; import javax.print.CancelablePrintJob; import javax.print.Doc; import javax.print.DocFlavor; -import javax.print.DocPrintJob; import javax.print.PrintService; import javax.print.PrintException; import javax.print.event.PrintJobEvent; @@ -56,7 +54,6 @@ import javax.print.event.PrintJobListener; import javax.print.event.PrintJobAttributeListener; import javax.print.attribute.Attribute; -import javax.print.attribute.AttributeSet; import javax.print.attribute.AttributeSetUtilities; import javax.print.attribute.DocAttributeSet; import javax.print.attribute.HashPrintJobAttributeSet; @@ -65,7 +62,6 @@ import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintJobAttributeSet; import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintRequestAttributeSet; -import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DocumentName; @@ -77,13 +73,17 @@ import javax.print.attribute.standard.Media; import javax.print.attribute.standard.MediaSize; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.OrientationRequested; -import javax.print.attribute.standard.PrinterName; import javax.print.attribute.standard.RequestingUserName; import javax.print.attribute.standard.NumberUp; import javax.print.attribute.standard.Sides; import javax.print.attribute.standard.PrinterIsAcceptingJobs; -import java.awt.print.*; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import java.awt.print.Pageable; +import java.awt.print.Paper; +import java.awt.print.Printable; +import java.awt.print.PrinterException; @@ -370,7 +370,7 @@ public class UnixPrintJob implements CancelablePrintJob { customTray instanceof CustomMediaTray) { String choice = customTray.getChoiceName(); if (choice != null) { - mOptions += " media="+choice; + mOptions += " InputSlot="+choice; } } diff --git a/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h b/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h index bb59b4658c7..bdc9830b07b 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h +++ b/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -28,7 +28,6 @@ #include #include -#include _JNI_IMPORT_OR_EXPORT_ JAWT_DrawingSurface* JNICALL awt_GetDrawingSurface(JNIEnv* env, jobject target); @@ -45,4 +44,14 @@ _JNI_IMPORT_OR_EXPORT_ void JNICALL _JNI_IMPORT_OR_EXPORT_ jobject JNICALL awt_GetComponent(JNIEnv* env, void* platformInfo); +_JNI_IMPORT_OR_EXPORT_ jobject JNICALL + awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo); + +_JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, jint y, + jint w, jint h); + +_JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame, + jboolean doActivate); #endif /* !_AWT_DRAWING_SURFACE_H_ */ diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c index de7e8488985..1cc09c9acac 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -383,3 +383,48 @@ JNIEXPORT jobject JNICALL return target; } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/awt/X11/XEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = (*env)->GetMethodID(env, cls, "", "(JZ)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return (*env)->NewObject(env, cls, mid, platformInfo, JNI_TRUE); +} + + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/unix/native/libjawt/jawt.c b/jdk/src/java.desktop/unix/native/libjawt/jawt.c index b6a5240a7c1..59e9a55cff2 100644 --- a/jdk/src/java.desktop/unix/native/libjawt/jawt.c +++ b/jdk/src/java.desktop/unix/native/libjawt/jawt.c @@ -45,7 +45,8 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) if (awt->version != JAWT_VERSION_1_3 && awt->version != JAWT_VERSION_1_4 - && awt->version != JAWT_VERSION_1_7) { + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -55,6 +56,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) awt->Lock = awt_Lock; awt->Unlock = awt_Unlock; awt->GetComponent = awt_GetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp index 05549673564..019295ac2b5 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -272,3 +272,47 @@ extern "C" JNIEXPORT void JNICALL DSUnlockAWT(JNIEnv* env) { // Do nothing on Windows } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/awt/windows/WEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = env->FindClass(embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = env->GetMethodID(cls, "", "(J)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return env->NewObject(cls, mid, platformInfo); +} + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = env->FindClass(embeddedClassName); + CHECK_NULL(cls); + mid = env->GetMethodID(cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + env->CallVoidMethod(embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = env->FindClass(embeddedClassName); + CHECK_NULL(cls); + mid = env->GetMethodID(cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + env->CallVoidMethod(embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h index cd135b947e2..a2a510797e9 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -162,6 +162,16 @@ extern "C" { jobject JNICALL DSGetComponent( JNIEnv* env, void* platformInfo); + _JNI_IMPORT_OR_EXPORT_ jobject JNICALL + awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo); + + _JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, + jint y, jint w, jint h); + + _JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame, + jboolean doActivate); #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp index 6c36d177fb2..6f75291d62f 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp @@ -1132,7 +1132,7 @@ BOOL AwtPrintControl::getDevmode( HANDLE hPrinter, if (dwRet != IDOK) { /* if failure, cleanup and return failure */ - GlobalFree(pDevMode); + GlobalFree(*pDevMode); *pDevMode = NULL; return FALSE; } diff --git a/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp b/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp index 218b7dd0864..1393dfcf8f6 100644 --- a/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp +++ b/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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 @@ -46,7 +46,9 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) } if (awt->version != JAWT_VERSION_1_3 - && awt->version != JAWT_VERSION_1_4) { + && awt->version != JAWT_VERSION_1_4 + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -56,6 +58,11 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) awt->Lock = DSLockAWT; awt->Unlock = DSUnlockAWT; awt->GetComponent = DSGetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html b/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html index 9b1b02ea06f..c1f6c852982 100644 --- a/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html +++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html @@ -105,6 +105,10 @@ method is not invoked. The agent class will be loaded by the system class loader (see {@link java.lang.ClassLoader#getSystemClassLoader ClassLoader.getSystemClassLoader}). This is the class loader which typically loads the class containing the application main method. +The system class loader must support a mechanism to add an agent JAR file to the system class path. +If it is a custom system class loader then it must define the +appendToClassPathForInstrumentation method as specified in +{@link Instrumentation#appendToSystemClassLoaderSearch appendToSystemClassLoaderSearch}. The premain methods will be run under the same security and classloader rules as the application main method. There are no modeling restrictions on what the agent premain method may do. @@ -140,7 +144,10 @@ supports the starting of agents after the VM has started the following applies:

          • The system class loader ( {@link java.lang.ClassLoader#getSystemClassLoader ClassLoader.getSystemClassLoader}) must - support a mechanism to add an agent JAR file to the system class path.

          • + support a mechanism to add an agent JAR file to the system class path. + If it is a custom system class loader then it must define the + appendToClassPathForInstrumentation method as specified in + {@link Instrumentation#appendToSystemClassLoaderSearch appendToSystemClassLoaderSearch}.

            diff --git a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c index a74b2b725ba..625ea1ad13d 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c +++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -190,10 +190,8 @@ DEF_Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) { return JNI_ERR; } - /* - * Add to the jarfile - */ - appendClassPath(agent, jarfile); + /* Save the jarfile name */ + agent->mJarfile = jarfile; /* * The value of the Premain-Class attribute becomes the agent @@ -241,7 +239,6 @@ DEF_Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) { /* * Clean-up */ - free(jarfile); if (options != NULL) free(options); freeAttributes(attributes); free(premainClass); @@ -459,7 +456,23 @@ eventHandlerVMInit( jvmtiEnv * jvmtienv, /* process the premain calls on the all the JPL agents */ if ( environment != NULL ) { - jthrowable outstandingException = preserveThrowable(jnienv); + jthrowable outstandingException = NULL; + /* + * Add the jarfile to the system class path + */ + JPLISAgent * agent = environment->mAgent; + if (appendClassPath(agent, agent->mJarfile)) { + fprintf(stderr, "Unable to add %s to system class path - " + "the system class loader does not define the " + "appendToClassPathForInstrumentation method or the method failed\n", + agent->mJarfile); + free((void *)agent->mJarfile); + abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART); + } + free((void *)agent->mJarfile); + agent->mJarfile = NULL; + + outstandingException = preserveThrowable(jnienv); success = processJavaStart( environment->mAgent, jnienv); restoreThrowable(jnienv, outstandingException); @@ -631,32 +644,19 @@ appendClassPath( JPLISAgent* agent, jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile); check_phase_ret_1(jvmtierr); - if (jvmtierr == JVMTI_ERROR_NONE) { - return 0; - } else { - jvmtiPhase phase; - jvmtiError err; - - err = (*jvmtienv)->GetPhase(jvmtienv, &phase); - /* can be called from any phase */ - jplis_assert(err == JVMTI_ERROR_NONE); - - if (phase == JVMTI_PHASE_LIVE) { - switch (jvmtierr) { - case JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED : - fprintf(stderr, "System class loader does not support adding " - "JAR file to system class path during the live phase!\n"); - break; - default: - fprintf(stderr, "Unexpected error (%d) returned by " - "AddToSystemClassLoaderSearch\n", jvmtierr); - break; - } - return -1; - } - jplis_assert(0); + switch (jvmtierr) { + case JVMTI_ERROR_NONE : + return 0; + case JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED : + fprintf(stderr, "System class loader does not define " + "the appendToClassPathForInstrumentation method\n"); + break; + default: + fprintf(stderr, "Unexpected error (%d) returned by " + "AddToSystemClassLoaderSearch\n", jvmtierr); + break; } - return -2; + return -1; } diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c index 3017cca1f7a..12f2a451e49 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c +++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c @@ -272,6 +272,7 @@ initializeJPLISAgent( JPLISAgent * agent, agent->mNativeMethodPrefixAdded = JNI_FALSE; agent->mAgentClassName = NULL; agent->mOptionsString = NULL; + agent->mJarfile = NULL; /* make sure we can recover either handle in either direction. * the agent has a ref to the jvmti; make it mutual diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h index 6ecfde2d5c5..008b2fabc6a 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h +++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h @@ -107,6 +107,7 @@ struct _JPLISAgent { jboolean mNativeMethodPrefixAdded; /* indicates if can_set_native_method_prefix capability has been added */ char const * mAgentClassName; /* agent class name */ char const * mOptionsString; /* -javaagent options string */ + const char * mJarfile; /* agent jar file name */ }; /* diff --git a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java index cbf32ee5834..93a5c7cbdd1 100644 --- a/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java +++ b/jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -64,6 +64,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.WeakHashMap; import java.util.stream.Collectors; @@ -1851,8 +1852,11 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable private static final class ObjectInputStreamWithLoader extends ObjectInputStream { ObjectInputStreamWithLoader(InputStream in, ClassLoader cl) - throws IOException { + throws IOException, IllegalArgumentException { super(in); + if (cl == null ) { + throw new IllegalArgumentException("class loader is null"); + } this.loader = cl; } @@ -1861,7 +1865,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable throws IOException, ClassNotFoundException { String name = classDesc.getName(); ReflectUtil.checkPackageAccess(name); - return Class.forName(name, false, loader); + return Class.forName(name, false, Objects.requireNonNull(loader)); } private final ClassLoader loader; diff --git a/jdk/src/java.management/share/classes/module-info.java b/jdk/src/java.management/share/classes/module-info.java index 6772da9d8ee..54ccb16107a 100644 --- a/jdk/src/java.management/share/classes/module-info.java +++ b/jdk/src/java.management/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -50,6 +50,7 @@ module java.management { uses javax.management.remote.JMXConnectorProvider; uses javax.management.remote.JMXConnectorServerProvider; uses sun.management.spi.PlatformMBeanProvider; + uses sun.management.spi.AgentProvider; provides javax.security.auth.spi.LoginModule with com.sun.jmx.remote.security.FileLoginModule; diff --git a/jdk/src/java.management/share/classes/sun/management/Agent.java b/jdk/src/java.management/share/classes/sun/management/Agent.java index be68601ce0e..fbc80433793 100644 --- a/jdk/src/java.management/share/classes/sun/management/Agent.java +++ b/jdk/src/java.management/share/classes/sun/management/Agent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,17 +31,19 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.management.ManagementFactory; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.UnknownHostException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; import java.util.Properties; import java.util.ResourceBundle; +import java.util.ServiceLoader; import java.util.function.Function; import java.util.function.Predicate; @@ -53,6 +55,7 @@ import sun.management.jmxremote.ConnectorBootstrap; import sun.management.jdp.JdpController; import sun.management.jdp.JdpException; import jdk.internal.vm.VMSupport; +import sun.management.spi.AgentProvider; /** * This Agent is started by the VM when -Dcom.sun.management.snmp or @@ -248,8 +251,8 @@ public class Agent { "com.sun.management.enableThreadContentionMonitoring"; private static final String LOCAL_CONNECTOR_ADDRESS_PROP = "com.sun.management.jmxremote.localConnectorAddress"; - private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME = - "sun.management.snmp.AdaptorBootstrap"; + private static final String SNMP_AGENT_NAME = + "SnmpAgent"; private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178"; private static final int JDP_DEFAULT_PORT = 7095; @@ -429,7 +432,7 @@ public class Agent { try { if (snmpPort != null) { - loadSnmpAgent(snmpPort, props); + loadSnmpAgent(props); } /* @@ -554,28 +557,24 @@ public class Agent { return mgmtProps; } - private static void loadSnmpAgent(String snmpPort, Properties props) { - try { - // invoke the following through reflection: - // AdaptorBootstrap.initialize(snmpPort, props); - final Class adaptorClass = - Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME, true, null); - final Method initializeMethod = - adaptorClass.getMethod("initialize", - String.class, Properties.class); - initializeMethod.invoke(null, snmpPort, props); - } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException x) { - // snmp runtime doesn't exist - initialization fails - throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, x); - } catch (InvocationTargetException x) { - final Throwable cause = x.getCause(); - if (cause instanceof RuntimeException) { - throw (RuntimeException) cause; - } else if (cause instanceof Error) { - throw (Error) cause; - } - // should not happen... - throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, cause); + private static void loadSnmpAgent(Properties props) { + /* + * Load the jdk.snmp service + */ + AgentProvider provider = AccessController.doPrivileged( + (PrivilegedAction) () -> { + for(AgentProvider aProvider : ServiceLoader.loadInstalled(AgentProvider.class)) { + if(aProvider.getName().equals(SNMP_AGENT_NAME)) + return aProvider; + } + return null; + }, null + ); + + if (provider != null) { + provider.startAgent(props); + } else { // snmp runtime doesn't exist - initialization fails + throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT); } } diff --git a/jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java b/jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java new file mode 100644 index 00000000000..f68343acacb --- /dev/null +++ b/jdk/src/java.management/share/classes/sun/management/spi/AgentProvider.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 sun.management.spi; + +import java.util.Properties; + +/** + * Service interface for management agent + */ +public abstract class AgentProvider { + + /** + * Instantiates a new AgentProvider. + * + * @throws SecurityException if the subclass (and calling code) does not + * have + * {@code RuntimePermission("sun.management.spi.AgentProvider.subclass")} + */ + protected AgentProvider() { + this(checkSubclassPermission()); + } + + private AgentProvider(Void unused) { + } + + private static Void checkSubclassPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission(AgentProvider.class.getName() + ".subclass")); + } + return null; + } + + /** + * Gets the name of the agent provider. + * + * @return name of agent provider + */ + public abstract String getName(); + + /** + * Initializes and starts the agent. + * + * @throws IllegalStateException if this agent has already been started. + */ + public abstract void startAgent(); + + /** + * Initializes and starts the agent at given port and with given properties + * + * @param props environment variables for agent + * + * @throws IllegalStateException if this agent has already been started. + */ + public abstract void startAgent(Properties props); + + /** + * Checks if agent is started and not terminated. + * + * @return true if agent is running, false otherwise. + */ + public abstract boolean isActive(); + + /** + * Stops this agent. + * + * @throws IllegalStateException if this agent is not started. + */ + public abstract void stopAgent(); +} diff --git a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java index de1410f3ef1..604fac30cc4 100644 --- a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java +++ b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -75,10 +75,10 @@ final class TerminalImpl extends CardTerminal { } } try { - card = new CardImpl(this, protocol); + card = new CardImpl(this, protocol); return card; } catch (PCSCException e) { - if (e.code == SCARD_W_REMOVED_CARD) { + if (e.code == SCARD_W_REMOVED_CARD || e.code == SCARD_E_NO_SMARTCARD) { throw new CardNotPresentException("No card present", e); } else { throw new CardException("connect() failed", e); diff --git a/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java index 0981b9cfaf5..8054ca86adc 100644 --- a/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java @@ -76,20 +76,29 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); diff --git a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java index 2bf3e74a8bd..5cc81e9a2d0 100644 --- a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java @@ -44,9 +44,6 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // Any changes to this needs to be synchronized with HotSpot. private static final String tmpdir = "/tmp"; - // Indicates if this machine uses the old LinuxThreads - static boolean isLinuxThreads; - // The patch to the socket file created by the target VM String path; @@ -73,44 +70,37 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { if (path == null) { File f = createAttachFile(pid); try { - // On LinuxThreads each thread is a process and we don't have the - // pid of the VMThread which has SIGQUIT unblocked. To workaround - // this we get the pid of the "manager thread" that is created - // by the first call to pthread_create. This is parent of all - // threads (except the initial thread). - if (isLinuxThreads) { - int mpid; - try { - mpid = getLinuxThreadsManager(pid); - } catch (IOException x) { - throw new AttachNotSupportedException(x.getMessage()); - } - assert(mpid >= 1); - sendQuitToChildrenOf(mpid); - } else { - sendQuitTo(pid); - } + sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); } - } + } // Check that the file owner/permission to avoid attaching to // bogus process @@ -340,6 +330,5 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { static { System.loadLibrary("attach"); - isLinuxThreads = isLinuxThreads(); } } diff --git a/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java index 0e304d0347d..9ed16330922 100644 --- a/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java @@ -70,26 +70,34 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // Then we attempt to find the socket file again. path = findSocketFile(pid); if (path == null) { - File f = new File(tmpdir, ".attach_pid" + pid); - createAttachFile(f.getPath()); + File f = createAttachFile(pid); try { sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); @@ -282,6 +290,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { write(fd, b, 0, 1); } + private File createAttachFile(int pid) throws IOException { + String fn = ".attach_pid" + pid; + File f = new File(tmpdir, fn); + createAttachFile0(f.getPath()); + return f; + } //-- native methods @@ -299,7 +313,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { static native void write(int fd, byte buf[], int off, int bufLen) throws IOException; - static native void createAttachFile(String path); + static native void createAttachFile0(String path); static native String getTempDir(); diff --git a/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c b/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c index 0f75dfe4e3d..42c4a256601 100644 --- a/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c +++ b/jdk/src/jdk.attach/macosx/native/libattach/VirtualMachineImpl.c @@ -270,7 +270,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_write * Method: createAttachFile * Signature: (Ljava.lang.String;)V */ -JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_createAttachFile(JNIEnv *env, jclass cls, jstring path) +JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_createAttachFile0(JNIEnv *env, jclass cls, jstring path) { const char* _path; jboolean isCopy; diff --git a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java index a5e965e5ec3..98d0ddc7e44 100644 --- a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java +++ b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java @@ -319,7 +319,7 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine { // -- attach timeout support - private static long defaultAttachTimeout = 5000; + private static long defaultAttachTimeout = 10000; private volatile long attachTimeout; /* diff --git a/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java b/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java index b93f745475e..4d0a3bc3dec 100644 --- a/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java @@ -71,27 +71,36 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { } catch (FileNotFoundException fnf1) { File f = createAttachFile(pid); try { - // kill -QUIT will tickle target VM to check for the - // attach file. sigquit(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } try { fd = openDoor(pid); - } catch (FileNotFoundException fnf2) { } - i++; - } while (i <= retries && fd == -1); - if (fd == -1) { + } catch (FileNotFoundException fnf2) { + // pass + } + + time_spend += delay; + if (time_spend > timeout/2 && fd == -1) { + // Send QUIT again to give target VM the last chance to react + sigquit(pid); + } + } while (time_spend <= timeout && fd == -1); + if (fd == -1) { throw new AttachNotSupportedException( - "Unable to open door: target process not responding or " + - "HotSpot VM not loaded"); + String.format("Unable to open door %s: " + + "target process %d doesn't respond within %dms " + + "or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete(); diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java index 9b7edac4d33..84341e1e181 100644 --- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java @@ -39,6 +39,7 @@ import java.util.ListIterator; //import java.util.Map; import java.util.ResourceBundle; import java.util.Stack; +import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.internal.jline.Terminal; @@ -2336,6 +2337,33 @@ public class ConsoleReader out.flush(); } + Stack pushBackChar = new Stack(); + + if (terminal.isAnsiSupported()) { + //detect the prompt length by reading the cursor position from the terminal + //the real prompt length could differ from the simple prompt length due to + //use of escape sequences: + out.write("\033[6n"); + out.flush(); + StringBuilder input = new StringBuilder(); + while (true) { + int read; + while ((read = in.read()) != 'R') { + input.appendCodePoint(read); + } + input.appendCodePoint(read); + Matcher m = CURSOR_COLUMN_PATTERN.matcher(input); + if (m.matches()) { + promptLen = Integer.parseInt(m.group("column")) - 1; + String prefix = m.group("prefix"); + for (int i = prefix.length() - 1; i >= 0; i--) { + pushBackChar.push(prefix.charAt(i)); + } + break; + } + } + } + // if the terminal is unsupported, just use plain-java reading if (!terminal.isSupported()) { return readLineSimple(); @@ -2352,7 +2380,6 @@ public class ConsoleReader boolean success = true; StringBuilder sb = new StringBuilder(); - Stack pushBackChar = new Stack(); while (true) { int c = pushBackChar.isEmpty() ? readCharacter() : pushBackChar.pop (); if (c == -1) { @@ -3193,6 +3220,9 @@ public class ConsoleReader } } } + //where: + private Pattern CURSOR_COLUMN_PATTERN = + Pattern.compile("(?.*)\033\\[[0-9]+;(?[0-9]+)R"); /** * Read a line for unsupported terminals. diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java index aaccb4269a0..850147aff31 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java @@ -189,12 +189,12 @@ public final class DefaultImageBuilder implements ImageBuilder { storeFiles(modules, release); if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) { - // launchers in the bin directory need execute permission + // launchers in the bin directory need execute permission. + // On Windows, "bin" also subdirectories containing jvm.dll. if (Files.isDirectory(bin)) { - Files.list(bin) - .filter(f -> !f.toString().endsWith(".diz")) - .filter(f -> Files.isRegularFile(f)) - .forEach(this::setExecutable); + Files.find(bin, 2, (path, attrs) -> { + return attrs.isRegularFile() && !path.toString().endsWith(".diz"); + }).forEach(this::setExecutable); } // jspawnhelper is in lib or lib/ diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java index df824856282..20e7ef26b1f 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java @@ -99,9 +99,15 @@ public final class ExcludeVMPlugin implements Plugin { * e.g.: /java.base/native/amd64/server/libjvm.so * /java.base/native/server/libjvm.dylib */ - private List getVMs(ResourcePoolModule javaBase, String jvmlib) { + private List getVMs(ResourcePoolModule javaBase, String[] jvmlibs) { List ret = javaBase.entries().filter((t) -> { - return t.path().endsWith("/" + jvmlib); + String path = t.path(); + for (String jvmlib : jvmlibs) { + if (t.path().endsWith("/" + jvmlib)) { + return true; + } + } + return false; }).collect(Collectors.toList()); return ret; } @@ -109,18 +115,21 @@ public final class ExcludeVMPlugin implements Plugin { @Override public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { ResourcePoolModule javaBase = in.moduleView().findModule("java.base").get(); - String jvmlib = jvmlib(javaBase.descriptor().osName().get()); + String[] jvmlibs = jvmlibs(javaBase.descriptor().osName().get()); TreeSet existing = new TreeSet<>(new JvmComparator()); TreeSet removed = new TreeSet<>(new JvmComparator()); if (!keepAll) { // First retrieve all available VM names and removed VM - List jvms = getVMs(javaBase, jvmlib); + List jvms = getVMs(javaBase, jvmlibs); for (Jvm jvm : Jvm.values()) { for (ResourcePoolEntry md : jvms) { - if (md.path().endsWith("/" + jvm.getName() + "/" + jvmlib)) { - existing.add(jvm); - if (isRemoved(md)) { - removed.add(jvm); + String mdPath = md.path(); + for (String jvmlib : jvmlibs) { + if (mdPath.endsWith("/" + jvm.getName() + "/" + jvmlib)) { + existing.add(jvm); + if (isRemoved(md)) { + removed.add(jvm); + } } } } @@ -248,14 +257,14 @@ public final class ExcludeVMPlugin implements Plugin { return orig.copyWithContent(content); } - private static String jvmlib(String osName) { - String lib = "libjvm.so"; + private static String[] jvmlibs(String osName) { if (isWindows(osName)) { - lib = "jvm.dll"; + return new String[] { "jvm.dll" }; } else if (isMac(osName)) { - lib = "libjvm.dylib"; + return new String[] { "libjvm.dylib", "libjvm.a" }; + } else { + return new String[] { "libjvm.so", "libjvm.a" }; } - return lib; } private static boolean isWindows(String osName) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index a60a1e934b5..115020953f3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -29,12 +29,12 @@ import java.io.IOException; import java.lang.invoke.MethodType; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Arrays; import java.util.EnumSet; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.internal.misc.SharedSecrets; @@ -69,11 +69,11 @@ public final class GenerateJLIClassesPlugin implements Plugin { private static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess(); - List speciesTypes; + Set speciesTypes; - List invokerTypes; + Set invokerTypes; - Map> dmhMethods; + Map> dmhMethods; public GenerateJLIClassesPlugin() { } @@ -110,8 +110,8 @@ public final class GenerateJLIClassesPlugin implements Plugin { * A better long-term solution is to define and run a set of quick * generators and extracting this list as a step in the build process. */ - public static List defaultSpecies() { - return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", + public static Set defaultSpecies() { + return Set.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", "L7II", "L7IIL", "L8", "L9", "L10", "L10I", "L10II", "L10IIL", "L11", "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL", "LILL", "I", "LLILL"); @@ -120,23 +120,23 @@ public final class GenerateJLIClassesPlugin implements Plugin { /** * @return the default invoker forms to generate. */ - private static List defaultInvokers() { - return List.of("LL_L", "LL_I", "LILL_I", "L6_L"); + private static Set defaultInvokers() { + return Set.of("LL_L", "LL_I", "LILL_I", "L6_L"); } /** * @return the list of default DirectMethodHandle methods to generate. */ - private static Map> defaultDMHMethods() { + private static Map> defaultDMHMethods() { return Map.of( - DMH_INVOKE_VIRTUAL, List.of("L_L", "LL_L", "LLI_I", "L3_V"), - DMH_INVOKE_SPECIAL, List.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L", + DMH_INVOKE_VIRTUAL, Set.of("L_L", "LL_L", "LLI_I", "L3_V"), + DMH_INVOKE_SPECIAL, Set.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "LLI_I", "LLI_L", "LLIL_I", "LLII_I", "LLII_L", "L3I_L", "L3I_I", "LLILI_I", "LLIIL_L", "LLIILL_L", "LLIILL_I", "LLIIL_I", "LLILIL_I", "LLILILL_I", "LLILII_I", "LLI3_I", "LLI3L_I", "LLI3LL_I", "LLI3_L", "LLI4_I"), - DMH_INVOKE_STATIC, List.of("LII_I", "LIL_I", "LILIL_I", "LILII_I", + DMH_INVOKE_STATIC, Set.of("LII_I", "LIL_I", "LILIL_I", "LILII_I", "L_I", "L_L", "L_V", "LD_L", "LF_L", "LI_I", "LII_L", "LLI_L", "LL_V", "LL_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "L9_L", "L10_L", "L10I_L", "L10II_L", "L10IIL_L", @@ -159,15 +159,48 @@ public final class GenerateJLIClassesPlugin implements Plugin { public void configure(Map config) { String mainArgument = config.get(NAME); - if (mainArgument != null && mainArgument.startsWith("@")) { + if ("none".equals(mainArgument)) { + speciesTypes = Set.of(); + invokerTypes = Set.of(); + dmhMethods = Map.of(); + return; + } + + // Start with the default configuration + Set defaultBMHSpecies = defaultSpecies(); + // Expand BMH species signatures + defaultBMHSpecies = defaultBMHSpecies.stream() + .map(type -> expandSignature(type)) + .collect(Collectors.toSet()); + + Set defaultInvokerTypes = defaultInvokers(); + validateMethodTypes(defaultInvokerTypes); + + Map> defaultDmhMethods = defaultDMHMethods(); + for (Set dmhMethodTypes : defaultDmhMethods.values()) { + validateMethodTypes(dmhMethodTypes); + } + + // Extend the default configuration with the contents in the supplied + // input file + if (mainArgument == null || !mainArgument.startsWith("@")) { + speciesTypes = defaultBMHSpecies; + invokerTypes = defaultInvokerTypes; + dmhMethods = defaultDmhMethods; + } else { File file = new File(mainArgument.substring(1)); if (file.exists()) { - speciesTypes = new ArrayList<>(); - invokerTypes = new ArrayList<>(); - dmhMethods = new HashMap<>(); - Stream lines = fileLines(file); - - lines.map(line -> line.split(" ")) + // Use TreeSet/TreeMap to keep things sorted in a deterministic + // order to avoid scrambling the layout on small changes and to + // ease finding methods in the generated code + speciesTypes = new TreeSet<>(defaultBMHSpecies); + invokerTypes = new TreeSet<>(defaultInvokerTypes); + dmhMethods = new TreeMap<>(); + for (Map.Entry> entry : defaultDmhMethods.entrySet()) { + dmhMethods.put(entry.getKey(), new TreeSet<>(entry.getValue())); + } + fileLines(file) + .map(line -> line.split(" ")) .forEach(parts -> { switch (parts[0]) { case "[BMH_RESOLVE]": @@ -191,28 +224,14 @@ public final class GenerateJLIClassesPlugin implements Plugin { } }); } - } else { - List bmhSpecies = defaultSpecies(); - // Expand BMH species signatures - speciesTypes = bmhSpecies.stream() - .map(type -> expandSignature(type)) - .collect(Collectors.toList()); - - invokerTypes = defaultInvokers(); - validateMethodTypes(invokerTypes); - - dmhMethods = defaultDMHMethods(); - for (List dmhMethodTypes : dmhMethods.values()) { - validateMethodTypes(dmhMethodTypes); - } } } private void addDMHMethodType(String dmh, String methodType) { validateMethodType(methodType); - List methodTypes = dmhMethods.get(dmh); + Set methodTypes = dmhMethods.get(dmh); if (methodTypes == null) { - methodTypes = new ArrayList<>(); + methodTypes = new TreeSet<>(); dmhMethods.put(dmh, methodTypes); } methodTypes.add(methodType); @@ -226,7 +245,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } - private void validateMethodTypes(List dmhMethodTypes) { + private void validateMethodTypes(Set dmhMethodTypes) { for (String type : dmhMethodTypes) { validateMethodType(type); } @@ -291,13 +310,13 @@ public final class GenerateJLIClassesPlugin implements Plugin { private void generateHolderClasses(ResourcePoolBuilder out) { int count = 0; - for (List entry : dmhMethods.values()) { + for (Set entry : dmhMethods.values()) { count += entry.size(); } MethodType[] directMethodTypes = new MethodType[count]; int[] dmhTypes = new int[count]; int index = 0; - for (Map.Entry> entry : dmhMethods.entrySet()) { + for (Map.Entry> entry : dmhMethods.entrySet()) { String dmhType = entry.getKey(); for (String type : entry.getValue()) { // The DMH type to actually ask for is retrieved by removing @@ -314,10 +333,11 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } MethodType[] invokerMethodTypes = new MethodType[this.invokerTypes.size()]; - for (int i = 0; i < invokerTypes.size(); i++) { + int i = 0; + for (String invokerType : invokerTypes) { // The invoker type to ask for is retrieved by removing the first // and the last argument, which needs to be of Object.class - MethodType mt = asMethodType(invokerTypes.get(i)); + MethodType mt = asMethodType(invokerType); final int lastParam = mt.parameterCount() - 1; if (mt.parameterCount() < 2 || mt.parameterType(0) != Object.class || @@ -327,6 +347,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { } mt = mt.dropParameterTypes(lastParam, lastParam + 1); invokerMethodTypes[i] = mt.dropParameterTypes(0, 1); + i++; } try { byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes( diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index b6e29bfccdc..a0b93962a8d 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -264,8 +264,8 @@ public final class IncludeLocalesPlugin implements Plugin, ResourcePrevisitor { // Add Thai BreakIterator related data files if (tag.equals("th")) { - files.add(".+sun/text/resources/thai_dict"); - files.add(".+sun/text/resources/[^_]+BreakIteratorData_th"); + files.add(".+sun/text/resources/ext/thai_dict"); + files.add(".+sun/text/resources/ext/[^_]+BreakIteratorData_th"); } // Add Taiwan resource bundles for Hong Kong diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 67c40903eb9..1303d5745c5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -68,12 +68,12 @@ exclude-resources.argument= resources to exclude exclude-resources.description=\ Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** -generate-jli-classes.argument=<@filename> +generate-jli-classes.argument= generate-jli-classes.description=\ Takes a file hinting to jlink what java.lang.invoke classes to pre-generate. If\n\ -this flag is not specified a default set of classes will be generated, so to \n\ -disable pre-generation supply the name of an empty or non-existing file +this flag is not specified a default set of classes will be generated. To \n\ +disable pre-generation specify none as the argument installed-modules.description=Fast loading of module descriptors (always enabled) @@ -139,7 +139,8 @@ plugin.opt.plugin-module-path=\ \ --plugin-module-path Custom plugin module path plugin.opt.c=\ -\ -c, --compress=2 Enable compression of resources (level 2) +\ -c, --compress=<0|1|2> Enable compression of resources\ +\n More details in --list-plugins option plugin.opt.G=\ \ -G, --strip-debug Strip debug information diff --git a/jdk/src/jdk.localedata/share/classes/sun/text/resources/thai_dict b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/thai_dict similarity index 100% rename from jdk/src/jdk.localedata/share/classes/sun/text/resources/thai_dict rename to jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/thai_dict diff --git a/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c b/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c index 8fb337b8ecd..b457950e0d9 100644 --- a/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c +++ b/jdk/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c @@ -87,9 +87,32 @@ JNIEXPORT void JNICALL Java_com_sun_management_internal_GcInfoBuilder_fillGcAttr for (i = 0; i < num_attributes; i++) { nativeTypes[i] = ext_att_info[i].type; attName = (*env)->NewStringUTF(env, ext_att_info[i].name); - desc = (*env)->NewStringUTF(env, ext_att_info[i].description); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } + (*env)->SetObjectArrayElement(env, attributeNames, i, attName); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } + + desc = (*env)->NewStringUTF(env, ext_att_info[i].description); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } + (*env)->SetObjectArrayElement(env, descriptions, i, desc); + if ((*env)->ExceptionCheck(env)) { + free(ext_att_info); + free(nativeTypes); + return; + } } (*env)->SetCharArrayRegion(env, types, 0, num_attributes, nativeTypes); diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2165bef4aba..83515fad418 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -213,8 +213,6 @@ java/rmi/transport/dgcDeadLock/DGCDeadLock.java 8029360 macosx-a sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all -sun/security/krb5/auto/Unreachable.java 7164518 macosx-all - sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all @@ -312,8 +310,6 @@ sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8157338 generic- tools/pack200/CommandLineTests.java 7143279,8059906 generic-all -tools/pack200/Pack200Test.java 8059906,8151901 generic-all - tools/launcher/FXLauncherTest.java 8068049 linux-all,macosx-all tools/pack200/Pack200Props.java 8155857 generic-all diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index be1540695df..d24280a517b 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -189,7 +189,6 @@ jdk_security3 = \ -sun/security/krb5 \ -sun/security/jgss \ javax/net \ - sun/net/www/protocol/https \ com/sun/net/ssl \ lib/security diff --git a/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java b/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java index e062996ee6a..b1eacad1e90 100644 --- a/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java +++ b/jdk/test/com/sun/jdi/SunBootClassPathEmptyTest.java @@ -32,7 +32,7 @@ import jdk.test.lib.Asserts; * @summary Verifies that PathSearchingVirtualMachine.bootClassPath() * returns an empty list in case no bootclass path specified * regardless of sun.boot.class.path option, which is now obsolete - * @library /test/lib/share/classes + * @library /test/lib * @compile TestClass.java * @compile SunBootClassPathEmptyTest.java * @run main/othervm SunBootClassPathEmptyTest diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java index 8a2c224f461..ac8e4f9c2a9 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 @@ -38,7 +38,7 @@ import com.sun.management.HotSpotDiagnosticMXBean; * @bug 6455258 * @summary Sanity test for com.sun.management.HotSpotDiagnosticMXBean.dumpHeap method * @library /lib/testlibrary - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.testlibrary.* * @build jdk.test.lib.hprof.* * @build jdk.test.lib.hprof.model.* diff --git a/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java b/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java new file mode 100644 index 00000000000..1dd861cf325 --- /dev/null +++ b/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2016, 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 8154218 + * @summary Verifies if owner Frame is associated with print dialog + * @run main/manual TestPrintJobFrameAssociation + */ +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.JobAttributes; +import java.awt.PrintJob; +import java.awt.Toolkit; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPrintJobFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Label dialogName; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPrintJobFrameAssociation::frameTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print dialog not disposed." + + " Print dialog is not associated with owner Frame`"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void frameTest() { + Panel panel =new Panel(); + + print = new Button("Print"); + print.setActionCommand("Print"); + print.addActionListener((e) -> { + JobAttributes ja = new JobAttributes(); + ja.setDialog(JobAttributes.DialogType.COMMON); + + t.start(); + start = true; + PrintJob pjob = Toolkit.getDefaultToolkit().getPrintJob(frame, + "Printing Test", + ja,null); + }); + + panel.add(print); + + frame = new Frame("Test Frame"); + frame.setLayout (new BorderLayout ()); + frame.add(panel,"South"); + frame.pack(); + frame.setVisible(true); + + t = new Thread (() -> { + if (start) { + try { + Thread.sleep(5000); + } catch (InterruptedException ex) {} + frame.dispose(); + } + }); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " A Frame with Print Button is shown. Press Print.\n" + + " A cross-platform print dialog will be shown. After 5 secs\n" + + " the frame along with this print dialog will be disposed.\n" + + " If the print dialog is not disposed, press FAIL else press PASS"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + + } +} diff --git a/jdk/test/java/awt/Window/8159168/SetShapeTest.java b/jdk/test/java/awt/Window/8159168/SetShapeTest.java index 19670a5f46e..9baaea1d084 100644 --- a/jdk/test/java/awt/Window/8159168/SetShapeTest.java +++ b/jdk/test/java/awt/Window/8159168/SetShapeTest.java @@ -1,29 +1,30 @@ /* -* Copyright (c) 2016, 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. + * Copyright (c) 2016, 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 8159168 + * @key headful + * @bug 8159168 8161913 * @summary [hidpi] Window.setShape() works incorrectly on HiDPI * @run main/othervm -Dsun.java2d.uiScale=2 SetShapeTest */ @@ -50,6 +51,7 @@ public class SetShapeTest { Rectangle rect = window.getBounds(); rect.x += rect.width - 10; rect.y += rect.height - 10; + robot.delay(1000); Color c = robot.getPixelColor(rect.x, rect.y); try { if (!c.equals(Color.RED)) { diff --git a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java index 0b6da116ede..81fdd4b049b 100644 --- a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java +++ b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java @@ -27,16 +27,14 @@ @bug 6758673 @summary Tests that windows are removed from owner's child windows list @author art: area=awt.toplevel - @run main OwnedWindowsLeak + @run main/othervm -mx128m OwnedWindowsLeak */ -import java.awt.*; -import java.awt.event.*; - -import java.lang.ref.*; -import java.lang.reflect.*; - -import java.util.*; +import java.awt.Frame; +import java.awt.Window; +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.util.Vector; public class OwnedWindowsLeak { diff --git a/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java b/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java new file mode 100644 index 00000000000..6eacad3a7a3 --- /dev/null +++ b/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2016, 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 8156099 + @summary Drag and drop of link from web browser, DataFlavor types + application/x-java-url and text/uri-list, getTransferData returns null + @run main/manual DragLinkFromBrowser + */ + +import java.awt.Frame; +import java.awt.Button; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.TransferHandler; +import javax.swing.SwingUtilities; +import javax.swing.JOptionPane; + +public class DragLinkFromBrowser implements ActionListener { + + private static GridBagLayout layout; + private static Panel mainControlPanel; + private static Panel resultButtonPanel; + private static TextArea instructionTextArea; + private static Button passButton; + private static Button failButton; + private static Frame mainFrame; + private static Thread mainThread = null; + private static volatile boolean testPassed = false; + private static volatile boolean isInterrupted = false; + private static volatile String failMessage; + private static final int testTimeOut = 300000; + private static JFrame urlFrame; + private static JPanel urlPanel; + + public static void dragLinkFromWebBrowser() { + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + + urlFrame = new JFrame(); + urlPanel = new JPanel(); + failMessage = "Dragging link from web browser Failed. " + + "getTransferData returns null"; + urlFrame.getContentPane().add(urlPanel); + urlPanel.setTransferHandler(new TransferHandler() { + @Override + public boolean canImport(final TransferSupport support) { + return true; + } + + @Override + public boolean importData(final TransferSupport support) { + final Transferable transferable = + support.getTransferable(); + final DataFlavor[] flavors + = transferable.getTransferDataFlavors(); + + for (final DataFlavor flavor : flavors) { + try { + final Object transferData + = transferable.getTransferData(flavor); + + if (transferData == null) { + JOptionPane.showMessageDialog(urlPanel, + failMessage); + break; + } else { + String flavorMessage = flavor.toString(); + String transferDataMessage = + transferData.toString(); + if (flavorMessage.contains("error") + || transferDataMessage.contains("null")) { + JOptionPane.showMessageDialog(urlPanel, + failMessage); + break; + } + } + } catch (UnsupportedFlavorException e) { + testFailed("UnsupportedFlavorException - " + + "test Failed"); + } catch (IOException e) { + testFailed("IOException - test Failed"); + } + } + + return true; + } + }); + + urlFrame.setBounds(500, 10, 200, 200); + urlFrame.setVisible(true); + } + }); + } + + private void createInstructionUI() { + mainFrame = new Frame("Drag and drop link from web browser"); + layout = new GridBagLayout(); + mainControlPanel = new Panel(layout); + resultButtonPanel = new Panel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + String instructions + = "INSTRUCTIONS:" + + "\n 1. Open any browser." + + "\n 2. Select and drag URL from the browser page and " + + "drop it on the panel" + + "\n 3. If test fails, then a popup message will be displayed," + + " click Ok and \n click Fail button." + + "\n 5. Otherwise test passed. Click Pass button."; + + instructionTextArea = new TextArea(); + instructionTextArea.setText(instructions); + instructionTextArea.setEnabled(false); + instructionTextArea.setBackground(Color.white); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionTextArea, gbc); + + passButton = new Button("Pass"); + passButton.setName("Pass"); + passButton.addActionListener(this); + + failButton = new Button("Fail"); + failButton.setName("Fail"); + failButton.addActionListener(this); + + gbc.gridx = 0; + gbc.gridy = 0; + resultButtonPanel.add(passButton, gbc); + gbc.gridx = 1; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + gbc.gridx = 0; + gbc.gridy = 1; + mainControlPanel.add(resultButtonPanel, gbc); + + mainFrame.add(mainControlPanel); + mainFrame.pack(); + mainFrame.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent ae) { + if (ae.getSource() instanceof Button) { + Button btn = (Button) ae.getSource(); + switch (btn.getName()) { + case "Pass": + testPassed = true; + isInterrupted = true; + mainThread.interrupt(); + break; + + case "Fail": + testFailed("Dragging link from web browser Failed"); + break; + } + } + } + + public static void cleanUp() { + urlFrame.dispose(); + mainFrame.dispose(); + } + + public static void testFailed(String message) { + testPassed = false; + isInterrupted = true; + failMessage = message; + mainThread.interrupt(); + } + + public static void main(final String[] args) throws Exception { + + DragLinkFromBrowser linkFromBrowser = new DragLinkFromBrowser(); + linkFromBrowser.createInstructionUI(); + linkFromBrowser.dragLinkFromWebBrowser(); + + mainThread = Thread.currentThread(); + try { + mainThread.sleep(testTimeOut); + } catch (InterruptedException ex) { + if (!testPassed) { + throw new RuntimeException(failMessage); + } + } finally { + cleanUp(); + } + + if (!isInterrupted) { + throw new RuntimeException("Test Timed out after " + + testTimeOut / 1000 + " seconds"); + } + } +} + diff --git a/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java b/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java new file mode 100644 index 00000000000..806381451df --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016, 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 8139176 + * @summary Test layout uses correct styled font. + * @run main StyledFontLayoutTest + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class StyledFontLayoutTest extends JPanel { + + static final int W=600, H=400; + static boolean interactive; + static BufferedImage im; + public static void main(String[] args) { + + interactive = args.length > 0; + + runTest(); + + if (!interactive) { + return; + } + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Styled Font Layout Test"); + frame.add(new StyledFontLayoutTest()); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setSize(W, H); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + } + + @Override + protected void paintComponent(Graphics g) { + g.drawImage(im, 0, 0, null); + } + + private static void runTest() { + im = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = im.createGraphics(); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, W, H); + g2d.setColor(Color.black); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + char[] chs = "Sample Text.".toCharArray(); + int len = chs.length; + + int x = 50, y = 100; + + FontRenderContext frc = g2d.getFontRenderContext(); + Font plain = new Font("Serif", Font.PLAIN, 48); + GlyphVector pgv = plain.layoutGlyphVector(frc, chs, 0, len, 0); + g2d.setFont(plain); + g2d.drawChars(chs, 0, len, x, y); y +=50; + + g2d.drawGlyphVector(pgv, x, y); y += 50; + Rectangle2D plainStrBounds = plain.getStringBounds(chs, 0, len, frc); + Rectangle2D plainGVBounds = pgv.getLogicalBounds(); + Font bold = new Font("Serif", Font.BOLD, 48); + GlyphVector bgv = bold.layoutGlyphVector(frc, chs, 0, len, 0); + Rectangle2D boldStrBounds = bold.getStringBounds(chs, 0, len, frc); + Rectangle2D boldGVBounds = bgv.getLogicalBounds(); + g2d.setFont(bold); + g2d.drawChars(chs, 0, len, x, y); y +=50; + g2d.drawGlyphVector(bgv, x, y); + System.out.println("Plain String Bounds = " + plainStrBounds); + System.out.println("Bold String Bounds = " + boldStrBounds); + System.out.println("Plain GlyphVector Bounds = " + plainGVBounds); + System.out.println("Bold GlyphVector Bounds = " + boldGVBounds); + if (!plainStrBounds.equals(boldStrBounds) && + plainGVBounds.equals(boldGVBounds)) + { + System.out.println("Test failed: Plain GV bounds same as Bold"); + if (!interactive) { + throw new RuntimeException("Plain GV bounds same as Bold"); + } + } + + }; +} diff --git a/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java b/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java new file mode 100644 index 00000000000..f8c36ec21e7 --- /dev/null +++ b/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2016, 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 8158356 + * @summary Test AffineTransform transformations do not result in SIGSEGV + * if NaN or infinity parameter is passed as argument. + * @run main InvalidTransformParameterTest + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImage; +import java.awt.image.ImagingOpException; +import java.awt.Point; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.PixelInterleavedSampleModel; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.image.RasterOp; +import java.awt.image.SampleModel; + +public class InvalidTransformParameterTest { + + public static void main(String[] args) { + int count = 0; + final int testScenarios = 12; + double NaNArg = 0.0 / 0.0; + double positiveInfArg = 1.0 / 0.0; + double negativeInfArg = -1.0 / 0.0; + + BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB); + + AffineTransform[] inputTransforms = new AffineTransform[testScenarios]; + + for (int i = 0; i < inputTransforms.length; i++) { + inputTransforms[i] = new AffineTransform(); + } + + inputTransforms[0].rotate(NaNArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[1].translate(NaNArg, NaNArg); + inputTransforms[2].scale(NaNArg, NaNArg); + inputTransforms[3].shear(NaNArg, NaNArg); + + inputTransforms[4].rotate(positiveInfArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[5].translate(positiveInfArg, positiveInfArg); + inputTransforms[6].scale(positiveInfArg, positiveInfArg); + inputTransforms[7].shear(positiveInfArg, positiveInfArg); + + inputTransforms[8].rotate(negativeInfArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[9].translate(negativeInfArg, negativeInfArg); + inputTransforms[10].scale(negativeInfArg, negativeInfArg); + inputTransforms[11].shear(negativeInfArg, negativeInfArg); + + // Test BufferedImage AffineTransform --------------------------------- + + for (int i = 0; i < inputTransforms.length; i++) { + try { + testImageTransform(img, inputTransforms[i]); + } catch (ImagingOpException ex) { + count++; + } + } + + if (count != testScenarios) { + throw new RuntimeException("Test failed. All test scenarios did not" + + " result in exception as expected."); + } + + // Test Raster AffineTransform --------------------------------- + + count = 0; + int[] bandOffsets = {0}; + Point location = new Point(0, 0); + DataBuffer db = new DataBufferByte(10 * 10); + SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, + 10, 10, 1, 10, + bandOffsets); + + Raster src = Raster.createRaster(sm, db, location); + WritableRaster dst = Raster.createWritableRaster(sm, db, location); + + for (int i = 0; i < inputTransforms.length; i++) { + try { + testRasterTransform(src, dst, inputTransforms[i]); + } catch (ImagingOpException ex) { + count++; + } + } + + if (count != testScenarios) { + throw new RuntimeException("Test failed. All test scenarios did not" + + " result in exception as expected."); + } + } + + public static BufferedImage testImageTransform(BufferedImage image, + AffineTransform transform) { + AffineTransformOp op = + new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); + + BufferedImage transformedImage = new BufferedImage(image.getWidth(), + image.getHeight(), + image.getType()); + + return op.filter(image, transformedImage); + } + + public static Raster testRasterTransform(Raster src, WritableRaster dst, + AffineTransform transform) { + AffineTransformOp op = + new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); + + return op.filter(src, dst); + } +} + diff --git a/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java new file mode 100644 index 00000000000..ce5c44d0d8a --- /dev/null +++ b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.MediaTracker; +import java.awt.Toolkit; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; +import javax.swing.GrayFilter; +import java.awt.image.MultiResolutionImage; +import javax.swing.JLabel; + +/** + * @test + * @bug 8156182 + * @summary [macosx] HiDPI/Retina icons do not work for disabled + * JButton/JMenuItem etc. + * @run main/othervm -Dsun.java2d.uiScale=2 MultiResolutionDisabledImageTest + */ +public class MultiResolutionDisabledImageTest { + + private static final String IMAGE_NAME_1X = "image.png"; + private static final String IMAGE_NAME_2X = "image@2x.png"; + private static final int IMAGE_SIZE = 100; + private static final Color COLOR_1X = Color.GREEN; + private static final Color COLOR_2X = Color.BLUE; + + public static void main(String[] args) throws Exception { + + Image baseMRImage = new BaseMultiResolutionImage(createImage(1), + createImage(2)); + testMRDisabledImage(baseMRImage); + + saveImages(); + Image toolkitMRImage = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X); + + if (toolkitMRImage instanceof MultiResolutionImage) { + testMRDisabledImage(toolkitMRImage); + } + } + + private static void testMRDisabledImage(Image image) throws Exception { + + Image disabledImage = GrayFilter.createDisabledImage(image); + MediaTracker mediaTracker = new MediaTracker(new JLabel()); + mediaTracker.addImage(disabledImage, 0); + mediaTracker.waitForID(0); + + BufferedImage buffImage = new BufferedImage(IMAGE_SIZE, + IMAGE_SIZE, + BufferedImage.TYPE_INT_RGB); + + int x = IMAGE_SIZE / 2; + int y = IMAGE_SIZE / 2; + + Graphics2D g = buffImage.createGraphics(); + + g.scale(1, 1); + g.drawImage(disabledImage, 0, 0, null); + int rgb1x = buffImage.getRGB(x, y); + + g.scale(2, 2); + g.drawImage(disabledImage, 0, 0, null); + int rgb2x = buffImage.getRGB(x, y); + + g.dispose(); + + if (rgb1x == rgb2x) { + throw new RuntimeException("Disabled image is the same for the base" + + "image and the resolution variant"); + } + + } + + private static BufferedImage createImage(int scale) throws Exception { + BufferedImage image = new BufferedImage(scale * 200, scale * 300, + BufferedImage.TYPE_INT_RGB); + Graphics g = image.createGraphics(); + g.setColor(scale == 1 ? COLOR_1X : COLOR_2X); + g.fillRect(0, 0, scale * 200, scale * 300); + g.dispose(); + return image; + } + + private static void saveImages() throws Exception { + saveImage(createImage(1), IMAGE_NAME_1X); + saveImage(createImage(2), IMAGE_NAME_2X); + } + + private static void saveImage(BufferedImage image, String name) throws Exception { + ImageIO.write(image, "png", new File(name)); + } +} diff --git a/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java b/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java new file mode 100644 index 00000000000..525099e24ff --- /dev/null +++ b/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2016, 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 4881082 4916294 5002129 8158524 + * @summary The test verifies whether the rendering operations on transparent + * and translucent VolatileImage objects generate identical output + * as generated with transparent and translucent BufferedImages. + * @key headful + * @run main/othervm -Dsun.java2d.uiScale=1 TransparentVImage + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=false TransparentVImage + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=true TransparentVImage + */ +import java.awt.GraphicsConfiguration; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; +import java.awt.Color; +import javax.swing.JFrame; +import javax.swing.JComponent; +import javax.swing.ImageIcon; +import javax.swing.SwingUtilities; + +/* + * This test draws the same contents to 4 images: 2 BufferedImages that are + * transparent and translucent and 2 VolatileImages that are transparent and + * translucent. It compares the results pixel-by-pixel and fails if the + * results are not the same. + */ +public class TransparentVImage + extends JComponent { + + BufferedImage cImgTransparent, cImgTranslucent; + VolatileImage vImgTransparent, vImgTranslucent; + Image sprite; + static final int IMAGE_SIZE = 250; + static final int WINDOW_SIZE = 600; + static boolean doneComparing = false; + static JFrame testFrame = null; + + @Override + public void paint(Graphics g) { + if (cImgTransparent == null) { + GraphicsConfiguration gc = getGraphicsConfiguration(); + // doesn't exist yet: create it (and the other images) + cImgTransparent = (BufferedImage) + gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, + Transparency.BITMASK); + cImgTranslucent = (BufferedImage) + gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, + Transparency.TRANSLUCENT); + vImgTransparent = gc.createCompatibleVolatileImage(IMAGE_SIZE, + IMAGE_SIZE, Transparency.BITMASK); + vImgTranslucent = gc.createCompatibleVolatileImage(IMAGE_SIZE, + IMAGE_SIZE, Transparency.TRANSLUCENT); + + String fileName = "duke.gif"; + String separator = System.getProperty("file.separator"); + String dirPath = System.getProperty("test.src", "."); + String filePath = dirPath + separator + fileName; + sprite = new ImageIcon(filePath).getImage(); + + // Now they exist; render to them + Graphics gImg[] = new Graphics[4]; + gImg[0] = cImgTransparent.getGraphics(); + gImg[1] = cImgTranslucent.getGraphics(); + gImg[2] = vImgTransparent.getGraphics(); + gImg[3] = vImgTranslucent.getGraphics(); + + for (int i = 0; i < gImg.length; ++i) { + /* + * VolatileImage utilizes the power of accelerated rendering + * using GPU. The GPU drivers for D3d and OpenGL are supplied + * by OEM vendors and are external to graphics subsystem. Thus + * one cannot guarentee that the drivers will render the + * primitives using exactly the same algorithms as those used + * by BufferedImage. This could result in minor differences in + * pixel values between BufferedImage and VolatileImage. + * + * The pipelines for D3d and OpenGL adjust the rendering with + * fudge factors to align output of GPU rendering with that of + * CPU rendering. Some of the draw calls in this paint method + * are commented indicating a need to fine tune the fudge + * factors in the future. Once they are found to work on all + * hardware, the draw calls will be enabled. + */ + // rectangular fill + gImg[i].setColor(Color.blue); + gImg[i].fillRect(0, 0, IMAGE_SIZE, IMAGE_SIZE); + + /* + * Image copy. Copy it 3 times to get any image management + * acceleration going + */ + int spriteW = sprite.getWidth(null); + gImg[i].drawImage(sprite, 0, 0, null); + gImg[i].drawImage(sprite, spriteW, 0, null); + gImg[i].drawImage(sprite, 2 * spriteW, 0, null); + + // horizontal/vertical/diagonal lines + gImg[i].setColor(Color.red); + gImg[i].drawLine(0, 0, + IMAGE_SIZE - 1, IMAGE_SIZE - 1); + gImg[i].drawLine(IMAGE_SIZE / 2, 0, + IMAGE_SIZE / 2, IMAGE_SIZE - 1); + //gImg[i].drawLine(IMAGE_SIZE, 0, + // 0, IMAGE_SIZE - 1); + gImg[i].drawLine(0, IMAGE_SIZE / 2, + IMAGE_SIZE - 1, IMAGE_SIZE / 2); + + // filled circle + //gImg[i].setColor(Color.yellow); + //gImg[i].fillOval(IMAGE_SIZE / 2 - 20, IMAGE_SIZE / 2 - 20, + // 40, 40); + } + + /* + * Now everything is drawn: let's compare pixels + * First, grab the pixel arrays + */ + int cRgbTransparent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int cRgbTranslucent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int vRgbTransparent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int vRgbTranslucent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + cImgTransparent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + cRgbTransparent, 0, IMAGE_SIZE); + cImgTranslucent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + cRgbTranslucent, 0, IMAGE_SIZE); + BufferedImage bImgTransparent = vImgTransparent.getSnapshot(); + bImgTransparent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + vRgbTransparent, 0, IMAGE_SIZE); + BufferedImage bImgTranslucent = vImgTranslucent.getSnapshot(); + bImgTranslucent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + vRgbTranslucent, 0, IMAGE_SIZE); + + boolean failed = false; + for (int pixel = 0; pixel < cRgbTransparent.length; ++pixel) { + if (cRgbTransparent[pixel] != vRgbTransparent[pixel]) { + failed = true; + System.out.println("Error in transparent image: " + + "BI[" + pixel + "] = " + + Integer.toHexString(cRgbTransparent[pixel]) + + "VI[" + pixel + "] = " + + Integer.toHexString(vRgbTransparent[pixel])); + break; + } + if (cRgbTranslucent[pixel] != vRgbTranslucent[pixel]) { + failed = true; + System.out.println("Error in translucent image: " + + "BI[" + pixel + "] = " + + Integer.toHexString(cRgbTranslucent[pixel]) + + "VI[" + pixel + "] = " + + Integer.toHexString(vRgbTranslucent[pixel])); + break; + } + } + if (failed) { + throw new RuntimeException("Failed: Pixel mis-match observed"); + } + else { + System.out.println("Passed"); + } + doneComparing = true; + } + + g.drawImage(cImgTransparent, 0, 0, null); + g.drawImage(cImgTranslucent, getWidth() - IMAGE_SIZE, 0, null); + g.drawImage(vImgTransparent, 0, getHeight() - IMAGE_SIZE, null); + g.drawImage(vImgTranslucent, getWidth() - IMAGE_SIZE, + getHeight() - IMAGE_SIZE, null); + } + + private static void constructTestUI() { + testFrame = new JFrame(); + testFrame.setSize(600, 600); + testFrame.setResizable(false); + testFrame.getContentPane().add(new TransparentVImage()); + + testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + testFrame.setLocationRelativeTo(null); + testFrame.setVisible(true); + } + + private static void destroyTestUI() { + testFrame.dispose(); + } + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + // Construct the test interface + constructTestUI(); + } catch (Exception ex) { + // Throw an exception indicating error while creating UI + throw new RuntimeException("Test Failed: Error while" + + " creating the test interface."); + } + } + }); + + /* + * Wait until the image comparison between VolatileImage and + * BufferedImage is complete. + */ + while (!doneComparing) { + try { + Thread.sleep(100); + } + catch (Exception e) {} + } + + /* + * Now sleep just a little longer to let the user see the resulting + * images in the frame + */ + try { + Thread.sleep(5000); + } + catch (Exception e) {} + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + // Destroy the test interface + destroyTestUI(); + } catch (Exception ex) { + // Throw an exception indicating error while deleting UI + throw new RuntimeException("Test Failed: Error while" + + " deleting the test interface."); + } + } + }); + } +} diff --git a/jdk/test/java/awt/image/VolatileImage/duke.gif b/jdk/test/java/awt/image/VolatileImage/duke.gif new file mode 100644 index 00000000000..ed32e0ff79b Binary files /dev/null and b/jdk/test/java/awt/image/VolatileImage/duke.gif differ diff --git a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java index 985041f6a1c..6083366e925 100644 --- a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java +++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java @@ -23,10 +23,10 @@ /** * @test - * @bug 8147648 + * @bug 8147648 8163160 * @summary [hidpi] multiresolution image: wrong resolution variant is used as * icon in the Unity panel - * @run main/othervm -Dsun.java2d.uiScale=2 IconTest + * @run main/manual/othervm -Dsun.java2d.uiScale=2 IconTest */ import java.awt.Color; import java.awt.Graphics; @@ -67,7 +67,7 @@ public class IconTest { if (g != null) { g.setColor(c); g.fillRect(0, 0, x, x); - g.setColor(Color.YELLOW); + g.setColor(Color.GREEN); g.drawRect(0, 0, x-1, x-1); } } finally { @@ -91,7 +91,8 @@ public class IconTest { GridBagConstraints gbc = new GridBagConstraints(); String instructions = "INSTRUCTIONS:
            " - + "Check if test button and unity icons are both blue with yellow border.

            " + + "Check if test button icon and unity icon are both " + + "blue with green border.

            " + "If Icon color is blue press pass" + " else press fail.

            "; diff --git a/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java new file mode 100644 index 00000000000..374928a56c5 --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2016, 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 6357887 + * @summary Verifies if selected printertray is used + * @requires (os.family == "linux" | os.family == "solaris") + * @run main/manual TestMediaTraySelection + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.print.DocFlavor; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.Media; +import javax.print.attribute.standard.MediaTray; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestMediaTraySelection implements Printable { + + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static PrintService prservices; + + public static void main(String[] args) throws Exception { + prservices = PrintServiceLookup.lookupDefaultPrintService(); + if (prservices == null) { + System.out.println("No print service found"); + return; + } + System.out.println(" Print service " + prservices); + SwingUtilities.invokeAndWait(() -> { + doTest(TestMediaTraySelection::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(90000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Banner page did not print"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void printTest() { + + MediaTray tray = null; + //tray = getMediaTray( prservices, "Bypass Tray" ); + tray = getMediaTray( prservices, "Tray 4" ); + PrintRequestAttributeSet atrset = new HashPrintRequestAttributeSet(); + //atrset.add( MediaSizeName.ISO_A4 ); + atrset.add(tray); + PrinterJob pjob = PrinterJob.getPrinterJob(); + pjob.setPrintable(new TestMediaTraySelection()); + try { + pjob.print(atrset); + } catch (PrinterException e) { + e.printStackTrace(); + fail(); + } + } + + static MediaTray getMediaTray( PrintService ps, String name) { + Media[] media = (Media[])ps.getSupportedAttributeValues( Media.class, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); + + for (Media m : media) { + if ( m instanceof MediaTray) { + System.out.println("MediaTray=" + m.toString() ); + if ( m.toString().trim().indexOf( name ) > -1 ) { + return (MediaTray)m; + } + } + } + return null; + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Please verify the \"Tray 4\" of printer is used for printout\n" + + " and not standard/auto tray. If yes, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printBannerTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + } + + @Override + public int print(Graphics g, PageFormat pf, int pi) { + System.out.println("pi = " + pi); + if (pi > 0) { + return NO_SUCH_PAGE; + } + g.drawString("Testing : " , 200, 200); + return PAGE_EXISTS; + } +} diff --git a/jdk/test/java/beans/Introspector/Test8027905.java b/jdk/test/java/beans/Introspector/Test8027905.java index 6c91694b4df..60318f34555 100644 --- a/jdk/test/java/beans/Introspector/Test8027905.java +++ b/jdk/test/java/beans/Introspector/Test8027905.java @@ -28,6 +28,7 @@ import java.beans.PropertyDescriptor; * @bug 8027905 * @summary Tests that GC does not affect a property type * @author Sergey Malenkov + * @run main/othervm -mx16m Test8027905 */ public class Test8027905 { diff --git a/jdk/test/java/lang/Class/GetModuleTest.java b/jdk/test/java/lang/Class/GetModuleTest.java index 918e4dd9dd1..359f7ca2ff7 100644 --- a/jdk/test/java/lang/Class/GetModuleTest.java +++ b/jdk/test/java/lang/Class/GetModuleTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/lang/Class/GetPackageTest.java b/jdk/test/java/lang/Class/GetPackageTest.java index f9cb5fb31ff..5f6c96f0d44 100644 --- a/jdk/test/java/lang/Class/GetPackageTest.java +++ b/jdk/test/java/lang/Class/GetPackageTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/lang/ClassLoader/GetDefinedPackage.java b/jdk/test/java/lang/ClassLoader/GetDefinedPackage.java new file mode 100644 index 00000000000..c20ca101c0f --- /dev/null +++ b/jdk/test/java/lang/ClassLoader/GetDefinedPackage.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, 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 8165346 + * @summary Basic test for ClassLoader::getDefinedPackage + */ + +public class GetDefinedPackage { + public static void main(String... args) { + TestClassLoader loader = new TestClassLoader(); + Package pkg = loader.getDefinedPackage(TestClassLoader.PKG_NAME); + if (pkg == null) { + throw new RuntimeException("package foo not found"); + } + + try { + loader.getDefinedPackage(null); + throw new RuntimeException("NullPointerException not thrown"); + } catch (NullPointerException e) { + } + } + + static class TestClassLoader extends ClassLoader { + public static final String PKG_NAME = "foo"; + + public TestClassLoader() { + super(); + definePackage(PKG_NAME); + } + + public Package definePackage(String name) { + return definePackage(name, null, null, null, null, null, null, null); + } + } +} diff --git a/jdk/test/java/lang/ClassLoader/GetSystemPackage.java b/jdk/test/java/lang/ClassLoader/GetSystemPackage.java index fba5648f5f4..56152b5907f 100644 --- a/jdk/test/java/lang/ClassLoader/GetSystemPackage.java +++ b/jdk/test/java/lang/ClassLoader/GetSystemPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/jdk/test/java/lang/ClassLoader/ResourcesStreamTest.java b/jdk/test/java/lang/ClassLoader/ResourcesStreamTest.java new file mode 100644 index 00000000000..789e0660cdc --- /dev/null +++ b/jdk/test/java/lang/ClassLoader/ResourcesStreamTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.net.URL; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/* + * @test + * @bug 8161230 + * @summary Test java.lang.ClassLoader.resources() method + * + * @build ResourcesStreamTest + * @run main ResourcesStreamTest + */ +public class ResourcesStreamTest { + + public static void main(String[] args) throws Exception { + testSuccess(); + testFailure(); + } + + public static void testSuccess() throws Exception { + // failing part first + try { + ClassLoader cl = new FailingClassLoader(); + // should create the stream pipe + Stream stream = cl.resources("the name"); + // expect function to throw an exception when calling the method + stream.forEach(System.out::println); + throw new Exception("expected UncheckedIOException not thrown"); + } catch (UncheckedIOException uio) { + String causeMessage = uio.getCause().getMessage(); + if (!"the name".equals(causeMessage)) + throw new Exception("unexpected cause message: " + causeMessage); + } + } + + public static void testFailure() throws Exception { + ClassLoader cl = new SuccessClassLoader(); + long count = cl.resources("the name").count(); + if (count != 1) + throw new Exception("expected resource is null or empty"); + + cl.resources("the name") + .filter(url -> "file:/somefile".equals(url.toExternalForm())) + .findFirst() + .orElseThrow(() -> new Exception("correct URL not found")); + } + + public static class SuccessClassLoader extends ClassLoader { + @Override + public Enumeration getResources(String name) throws IOException { + URL url = new URL("file:/somefile"); + return Collections.enumeration(Collections.singleton(url)); + } + } + + public static class FailingClassLoader extends ClassLoader { + @Override + public Enumeration getResources(String name) throws IOException { + throw new IOException(name); + } + } +} diff --git a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java index 26fbe3dd586..691c509e2e9 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java +++ b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 diff --git a/jdk/test/java/lang/ProcessBuilder/Basic.java b/jdk/test/java/lang/ProcessBuilder/Basic.java index 9a1d97647f7..e17e28865e4 100644 --- a/jdk/test/java/lang/ProcessBuilder/Basic.java +++ b/jdk/test/java/lang/ProcessBuilder/Basic.java @@ -2226,6 +2226,33 @@ public class Basic { reader.join(); } } + + //---------------------------------------------------------------- + // Check the Process toString() method + //---------------------------------------------------------------- + { + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("testIO"); + ProcessBuilder pb = new ProcessBuilder(childArgs); + pb.redirectInput(Redirect.PIPE); + pb.redirectOutput(DISCARD); + pb.redirectError(DISCARD); + final Process p = pb.start(); + // Child process waits until it gets input + String s = p.toString(); + check(s.contains("not exited")); + check(s.contains("pid=" + p.getPid() + ",")); + + new PrintStream(p.getOutputStream()).print("standard input"); + p.getOutputStream().close(); + + // Check the toString after it exits + int exitValue = p.waitFor(); + s = p.toString(); + check(s.contains("pid=" + p.getPid() + ",")); + check(s.contains("exitValue=" + exitValue) && + !s.contains("not exited")); + } } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- diff --git a/jdk/test/java/lang/ProcessBuilder/CloseRace.java b/jdk/test/java/lang/ProcessBuilder/CloseRace.java index a9afbd2ba91..1fa6d8d5e15 100644 --- a/jdk/test/java/lang/ProcessBuilder/CloseRace.java +++ b/jdk/test/java/lang/ProcessBuilder/CloseRace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 diff --git a/jdk/test/java/lang/ProcessBuilder/PipelineTest.java b/jdk/test/java/lang/ProcessBuilder/PipelineTest.java index 9f6ec99fb70..90b277ad9eb 100644 --- a/jdk/test/java/lang/ProcessBuilder/PipelineTest.java +++ b/jdk/test/java/lang/ProcessBuilder/PipelineTest.java @@ -19,7 +19,6 @@ * 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. - * */ import java.io.File; diff --git a/jdk/test/java/lang/ProcessBuilder/Zombies.java b/jdk/test/java/lang/ProcessBuilder/Zombies.java index 30f296cc513..10c804ee1d4 100644 --- a/jdk/test/java/lang/ProcessBuilder/Zombies.java +++ b/jdk/test/java/lang/ProcessBuilder/Zombies.java @@ -25,7 +25,6 @@ * @test * @run main/othervm Zombies * @bug 6474073 6180151 - * @key intermittent * @summary Make sure zombies don't get created on Unix * @author Martin Buchholz */ diff --git a/jdk/test/java/lang/ProcessHandle/Basic.java b/jdk/test/java/lang/ProcessHandle/Basic.java index b759e9c7c39..c34bcab098b 100644 --- a/jdk/test/java/lang/ProcessHandle/Basic.java +++ b/jdk/test/java/lang/ProcessHandle/Basic.java @@ -36,7 +36,7 @@ import org.testng.annotations.Test; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @run testng Basic diff --git a/jdk/test/java/lang/ProcessHandle/InfoTest.java b/jdk/test/java/lang/ProcessHandle/InfoTest.java index 7d8867d67da..fbd855db91d 100644 --- a/jdk/test/java/lang/ProcessHandle/InfoTest.java +++ b/jdk/test/java/lang/ProcessHandle/InfoTest.java @@ -48,7 +48,7 @@ import org.testng.annotations.Test; /* * @test * @bug 8077350 8081566 8081567 8098852 8136597 - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @build jdk.test.lib.Platform jdk.test.lib.Utils diff --git a/jdk/test/java/lang/ProcessHandle/OnExitTest.java b/jdk/test/java/lang/ProcessHandle/OnExitTest.java index c797f4a705b..ff9f4c2607c 100644 --- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java +++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java @@ -38,7 +38,7 @@ import org.testng.TestNG; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @build jdk.test.lib.Platform jdk.test.lib.Utils diff --git a/jdk/test/java/lang/ProcessHandle/TreeTest.java b/jdk/test/java/lang/ProcessHandle/TreeTest.java index bb62d06353c..a1493b65882 100644 --- a/jdk/test/java/lang/ProcessHandle/TreeTest.java +++ b/jdk/test/java/lang/ProcessHandle/TreeTest.java @@ -44,7 +44,7 @@ import org.testng.annotations.Test; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management * @build jdk.test.lib.Utils diff --git a/jdk/test/java/lang/StackWalker/CountLocalSlots.java b/jdk/test/java/lang/StackWalker/CountLocalSlots.java index c78a4cb7bf4..066055b0a1d 100644 --- a/jdk/test/java/lang/StackWalker/CountLocalSlots.java +++ b/jdk/test/java/lang/StackWalker/CountLocalSlots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java index b253ab27e81..f4f646549ec 100644 --- a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java +++ b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/lang/StackWalker/LocalsCrash.java b/jdk/test/java/lang/StackWalker/LocalsCrash.java index b50dd263f00..87415e4df0c 100644 --- a/jdk/test/java/lang/StackWalker/LocalsCrash.java +++ b/jdk/test/java/lang/StackWalker/LocalsCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java b/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java index 6f566c33eb9..5669bce2fd8 100644 --- a/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java +++ b/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java b/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java index 31b29cd30fd..7ee0d988529 100644 --- a/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java +++ b/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/String/concat/WithSecurityManager.java b/jdk/test/java/lang/String/concat/WithSecurityManager.java index 9359d29fbb1..2835a3813f4 100644 --- a/jdk/test/java/lang/String/concat/WithSecurityManager.java +++ b/jdk/test/java/lang/String/concat/WithSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 diff --git a/jdk/test/java/lang/Thread/ThreadStateController.java b/jdk/test/java/lang/Thread/ThreadStateController.java index 728a115c271..c426d1b34b4 100644 --- a/jdk/test/java/lang/Thread/ThreadStateController.java +++ b/jdk/test/java/lang/Thread/ThreadStateController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 diff --git a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java index e9608089763..084ed563809 100644 --- a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java +++ b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, 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 diff --git a/jdk/test/java/lang/instrument/CustomSystemLoader/Agent.java b/jdk/test/java/lang/instrument/CustomSystemLoader/Agent.java new file mode 100644 index 00000000000..0432c2d9587 --- /dev/null +++ b/jdk/test/java/lang/instrument/CustomSystemLoader/Agent.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.PrintStream; +import java.lang.instrument.*; +import java.lang.reflect.Field; + +/** + * @test + * @bug 8160950 + * @summary test for custom system class loader + * + * @run build App Agent CustomLoader + * @run shell ../MakeJAR3.sh Agent 'Can-Retransform-Classes: true' + * @run main/othervm -javaagent:Agent.jar -Djava.system.class.loader=CustomLoader App + */ + +public class Agent { + private static PrintStream err = System.err; + private static PrintStream out = System.out; + public static boolean failed = false; + + public static void premain(String agentArgs, Instrumentation instrumentation) { + ClassLoader myClassLoader = Agent.class.getClassLoader(); + out.println("Agent: started; myClassLoader: " + myClassLoader); + try { + Field fld = myClassLoader.getClass().getField("agentClassLoader"); + fld.set(myClassLoader.getClass(), myClassLoader); + } catch (Exception ex) { + failed = true; + ex.printStackTrace(); + } + out.println("Agent: finished"); + } +} diff --git a/jdk/test/java/lang/instrument/CustomSystemLoader/App.java b/jdk/test/java/lang/instrument/CustomSystemLoader/App.java new file mode 100644 index 00000000000..a5eac03f14e --- /dev/null +++ b/jdk/test/java/lang/instrument/CustomSystemLoader/App.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.PrintStream; + +public class App { + + public static void main(String args[]) throws Exception { + (new App()).run(args, System.out); + } + + public void run(String args[], PrintStream out) throws Exception { + out.println("App: Test started"); + if (CustomLoader.agentClassLoader != CustomLoader.myself) { + System.out.println("App: agentClassLoader: " + CustomLoader.agentClassLoader); + System.out.println("App: CustomLoader.myself: " + CustomLoader.myself); + System.out.println("App: myClassLoader: " + App.class.getClassLoader()); + throw new Exception("App: Agent's system class loader is not CustomLoader"); + } else if (Agent.failed) { + throw new Exception("App: Agent failed"); + } else if (CustomLoader.failed) { + throw new Exception("App: CustomLoader failed"); + } + out.println("App: Test passed"); + } +} diff --git a/jdk/test/java/lang/instrument/CustomSystemLoader/CustomLoader.java b/jdk/test/java/lang/instrument/CustomSystemLoader/CustomLoader.java new file mode 100644 index 00000000000..f90e244b4a1 --- /dev/null +++ b/jdk/test/java/lang/instrument/CustomSystemLoader/CustomLoader.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.DataInputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; + +public class CustomLoader extends ClassLoader { + private static PrintStream out = System.out; + public static ClassLoader myself; + public static ClassLoader agentClassLoader; + public static boolean failed = true; + + public CustomLoader(ClassLoader classLoader) { + super(classLoader); + myself = this; + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException { + out.println("CustomLoader: loading class: " + name); + if (name.equals("Agent")) { + Class c = null; + try { + byte[] buf = locateBytes(); + c = defineClass(name, buf, 0, buf.length); + } catch (IOException ex) { + throw new ClassNotFoundException(ex.getMessage()); + } + resolveClass(c); + out.println("CustomLoader.loadClass after resolveClass: " + name + + "; Class: " + c + "; ClassLoader: " + c.getClassLoader()); + return c; + } + return super.loadClass(name); + } + + private byte[] locateBytes() throws IOException { + try { + JarFile jar = new JarFile("Agent.jar"); + InputStream is = jar.getInputStream(jar.getEntry("Agent.class")); + int len = is.available(); + byte[] buf = new byte[len]; + DataInputStream in = new DataInputStream(is); + in.readFully(buf); + return buf; + } catch (IOException ioe) { + ioe.printStackTrace(); + throw new IOException("Test failed due to IOException!"); + } + } + + void appendToClassPathForInstrumentation(String path) { + out.println("CustomLoader.appendToClassPathForInstrumentation: " + + this + ", jar: " + path); + failed = false; + } +} diff --git a/jdk/test/java/lang/instrument/NMTHelper.java b/jdk/test/java/lang/instrument/NMTHelper.java index 09e60e4a623..07ee25be38d 100644 --- a/jdk/test/java/lang/instrument/NMTHelper.java +++ b/jdk/test/java/lang/instrument/NMTHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java b/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java index 4522d8b1055..47090167051 100644 --- a/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java +++ b/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java @@ -24,6 +24,7 @@ /** * @test * @bug 6263319 + * @requires ((vm.opt.StartFlightRecording == null) | (vm.opt.StartFlightRecording == false)) & ((vm.opt.FlightRecorder == null) | (vm.opt.FlightRecorder == false)) * @summary test setNativeMethodPrefix * @author Robert Field, Sun Microsystems * diff --git a/jdk/test/java/lang/instrument/RedefineBigClass.sh b/jdk/test/java/lang/instrument/RedefineBigClass.sh index 60fb081055a..4f625a7501c 100644 --- a/jdk/test/java/lang/instrument/RedefineBigClass.sh +++ b/jdk/test/java/lang/instrument/RedefineBigClass.sh @@ -70,7 +70,7 @@ else fi "${JAVA}" ${TESTVMOPTS} \ - -XX:TraceRedefineClasses=3 ${NMT} \ + -Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \ -javaagent:RedefineBigClassAgent.jar=BigClass.class \ -classpath "${TESTCLASSES}" RedefineBigClassApp \ > output.log 2>&1 diff --git a/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh b/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh index 357e24417f9..e583c9df469 100644 --- a/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh +++ b/jdk/test/java/lang/instrument/RedefineSubclassWithTwoInterfaces.sh @@ -87,23 +87,8 @@ mv RedefineSubclassWithTwoInterfacesImpl.class \ echo "INFO: launching RedefineSubclassWithTwoInterfacesApp" -# TraceRedefineClasses options: -# -# 0x00000001 | 1 - name each target class before loading, after -# loading and after redefinition is completed -# 0x00000002 | 2 - print info if parsing, linking or -# verification throws an exception -# 0x00000004 | 4 - print timer info for the VM operation -# 0x00001000 | 4096 - detect calls to obsolete methods -# 0x00002000 | 8192 - fail a guarantee() in addition to detection -# 0x00004000 | 16384 - detect old/obsolete methods in metadata -# 0x00100000 | 1048576 - impl details: vtable updates -# 0x00200000 | 2097152 - impl details: itable updates -# -# 1+2+4+4096+8192+16384+1048576+2097152 == 3174407 - "${JAVA}" ${TESTVMOPTS} \ - -XX:TraceRedefineClasses=3174407 \ + -Xlog:redefine+class+load=trace,redefine+class+load+exceptions=trace,redefine+class+timer=trace,redefine+class+obsolete=trace,redefine+class+obsolete+metadata=trace,redefine+class+constantpool=trace \ -javaagent:RedefineSubclassWithTwoInterfacesAgent.jar \ -classpath "${TESTCLASSES}" \ RedefineSubclassWithTwoInterfacesApp > output.log 2>&1 diff --git a/jdk/test/java/lang/instrument/RetransformBigClass.sh b/jdk/test/java/lang/instrument/RetransformBigClass.sh index 7144689722b..455f42a3247 100644 --- a/jdk/test/java/lang/instrument/RetransformBigClass.sh +++ b/jdk/test/java/lang/instrument/RetransformBigClass.sh @@ -70,7 +70,7 @@ else fi "${JAVA}" ${TESTVMOPTS} \ - -XX:TraceRedefineClasses=3 ${NMT} \ + -Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \ -javaagent:RetransformBigClassAgent.jar=BigClass.class \ -classpath "${TESTCLASSES}" RetransformBigClassApp \ > output.log 2>&1 diff --git a/jdk/test/java/lang/invoke/6987555/Test6987555.java b/jdk/test/java/lang/invoke/6987555/Test6987555.java index 7a2f45c6efe..eb939007326 100644 --- a/jdk/test/java/lang/invoke/6987555/Test6987555.java +++ b/jdk/test/java/lang/invoke/6987555/Test6987555.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/6991596/Test6991596.java b/jdk/test/java/lang/invoke/6991596/Test6991596.java index a7083bd8114..193009deafd 100644 --- a/jdk/test/java/lang/invoke/6991596/Test6991596.java +++ b/jdk/test/java/lang/invoke/6991596/Test6991596.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/6998541/Test6998541.java b/jdk/test/java/lang/invoke/6998541/Test6998541.java index 1edf14f9dc6..983c23b3640 100644 --- a/jdk/test/java/lang/invoke/6998541/Test6998541.java +++ b/jdk/test/java/lang/invoke/6998541/Test6998541.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/7087570/Test7087570.java b/jdk/test/java/lang/invoke/7087570/Test7087570.java index 732467b8c62..165968c6069 100644 --- a/jdk/test/java/lang/invoke/7087570/Test7087570.java +++ b/jdk/test/java/lang/invoke/7087570/Test7087570.java @@ -19,7 +19,6 @@ * 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 diff --git a/jdk/test/java/lang/invoke/7157574/Test7157574.java b/jdk/test/java/lang/invoke/7157574/Test7157574.java index acf9ef48a04..d2a91d92626 100644 --- a/jdk/test/java/lang/invoke/7157574/Test7157574.java +++ b/jdk/test/java/lang/invoke/7157574/Test7157574.java @@ -19,7 +19,6 @@ * 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. - * */ /* diff --git a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java index 4730efafb6c..e0797f0f741 100644 --- a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java +++ b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java index 24a9512ffaf..57a06d16b05 100644 --- a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java +++ b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8009222/Test8009222.java b/jdk/test/java/lang/invoke/8009222/Test8009222.java index 711969387ed..62ee09c066a 100644 --- a/jdk/test/java/lang/invoke/8009222/Test8009222.java +++ b/jdk/test/java/lang/invoke/8009222/Test8009222.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8022701/BogoLoader.java b/jdk/test/java/lang/invoke/8022701/BogoLoader.java index e77be6f44ff..e8c579a27c8 100644 --- a/jdk/test/java/lang/invoke/8022701/BogoLoader.java +++ b/jdk/test/java/lang/invoke/8022701/BogoLoader.java @@ -19,7 +19,6 @@ * 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. - * */ import java.io.BufferedInputStream; diff --git a/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java b/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java index 5c1f64bf9b0..011ae7f43a5 100644 --- a/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java +++ b/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java @@ -19,7 +19,6 @@ * 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. - * */ import java.lang.reflect.InvocationTargetException; diff --git a/jdk/test/java/lang/invoke/8022701/Invoker.java b/jdk/test/java/lang/invoke/8022701/Invoker.java index a97159e9e29..62015fae371 100644 --- a/jdk/test/java/lang/invoke/8022701/Invoker.java +++ b/jdk/test/java/lang/invoke/8022701/Invoker.java @@ -19,7 +19,6 @@ * 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. - * */ public class Invoker { diff --git a/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java b/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java index badc1a817f3..18d4a4c6752 100644 --- a/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java +++ b/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8022701/MethodSupplier.java b/jdk/test/java/lang/invoke/8022701/MethodSupplier.java index 4699a52aaff..5ef4d20f1ac 100644 --- a/jdk/test/java/lang/invoke/8022701/MethodSupplier.java +++ b/jdk/test/java/lang/invoke/8022701/MethodSupplier.java @@ -19,7 +19,6 @@ * 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. - * */ /* diff --git a/jdk/test/java/lang/invoke/CallSiteTest.java b/jdk/test/java/lang/invoke/CallSiteTest.java index 48b0d7b6d9a..bf0fe2e4dc7 100644 --- a/jdk/test/java/lang/invoke/CallSiteTest.java +++ b/jdk/test/java/lang/invoke/CallSiteTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/CallStaticInitOrder.java b/jdk/test/java/lang/invoke/CallStaticInitOrder.java index 83808f8fb9f..4090e8fff2d 100644 --- a/jdk/test/java/lang/invoke/CallStaticInitOrder.java +++ b/jdk/test/java/lang/invoke/CallStaticInitOrder.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java index edfe52af8a7..7356b290768 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java index 154109c883a..771e87f67aa 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java @@ -19,8 +19,8 @@ * 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 p1; import p2.T3; diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java index 9f4d7cee9bc..0deba761a74 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java @@ -19,8 +19,8 @@ * 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 p2; import p1.T2; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java index ed3160b9979..aa66b2fd726 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java @@ -132,7 +132,8 @@ abstract class VarHandleBaseTest { COMPARE_AND_SET, COMPARE_AND_EXCHANGE, GET_AND_SET, - GET_AND_ADD; + GET_AND_ADD, + GET_AND_BITWISE; } enum TestAccessMode { @@ -148,13 +149,26 @@ abstract class VarHandleBaseTest { COMPARE_AND_EXCHANGE(TestAccessType.COMPARE_AND_EXCHANGE), COMPARE_AND_EXCHANGE_ACQUIRE(TestAccessType.COMPARE_AND_EXCHANGE), COMPARE_AND_EXCHANGE_RELEASE(TestAccessType.COMPARE_AND_EXCHANGE), + WEAK_COMPARE_AND_SET_PLAIN(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET(TestAccessType.COMPARE_AND_SET), - WEAK_COMPARE_AND_SET_VOLATILE(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET_ACQUIRE(TestAccessType.COMPARE_AND_SET), WEAK_COMPARE_AND_SET_RELEASE(TestAccessType.COMPARE_AND_SET), GET_AND_SET(TestAccessType.GET_AND_SET), + GET_AND_SET_ACQUIRE(TestAccessType.GET_AND_SET), + GET_AND_SET_RELEASE(TestAccessType.GET_AND_SET), GET_AND_ADD(TestAccessType.GET_AND_ADD), - ADD_AND_GET(TestAccessType.GET_AND_ADD),; + GET_AND_ADD_ACQUIRE(TestAccessType.GET_AND_ADD), + GET_AND_ADD_RELEASE(TestAccessType.GET_AND_ADD), + GET_AND_BITWISE_OR(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_OR_ACQUIRE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_OR_RELEASE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_AND(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_AND_ACQUIRE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_AND_RELEASE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_XOR(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_XOR_ACQUIRE(TestAccessType.GET_AND_BITWISE), + GET_AND_BITWISE_XOR_RELEASE(TestAccessType.GET_AND_BITWISE), + ; final TestAccessType at; final boolean isPolyMorphicInReturnType; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index ae23346c689..a4d54635d95 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -266,8 +279,13 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(recv, true); + boolean o = (boolean) vh.getAndAddAcquire(recv, true); }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(recv, true); + }); + } @@ -321,8 +339,13 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(true); + boolean o = (boolean) vh.getAndAddAcquire(true); }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(true); + }); + } @@ -418,11 +441,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, true, false); + success = vh.weakCompareAndSetPlain(recv, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) vh.get(recv); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -448,21 +471,125 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, false, true); + success = vh.weakCompareAndSet(recv, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) vh.get(recv); - assertEquals(x, true, "weakCompareAndSetVolatile boolean value"); + assertEquals(x, true, "weakCompareAndSet boolean value"); } // Compare set and get { + vh.set(recv, true); + boolean o = (boolean) vh.getAndSet(recv, false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) vh.get(recv); assertEquals(x, false, "getAndSet boolean value"); } + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndSetAcquire(recv, false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndSetRelease(recv, false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseOr(recv, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseOrAcquire(recv, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseOrRelease(recv, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseAnd(recv, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseAndAcquire(recv, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseAndRelease(recv, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseXor(recv, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseXorAcquire(recv, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + vh.set(recv, true); + + boolean o = (boolean) vh.getAndBitwiseXorRelease(recv, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) vh.get(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testInstanceFieldUnsupported(VarHandleTestAccessBoolean recv, VarHandle vh) { @@ -472,8 +599,13 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(recv, true); + boolean o = (boolean) vh.getAndAddAcquire(recv, true); }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(recv, true); + }); + } @@ -569,11 +701,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(true, false); + success = vh.weakCompareAndSetPlain(true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) vh.get(); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -599,21 +731,125 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(false, true); + success = vh.weakCompareAndSet(false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) vh.get(); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get { + vh.set(true); + boolean o = (boolean) vh.getAndSet(false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) vh.get(); assertEquals(x, false, "getAndSet boolean value"); } + { + vh.set(true); + + boolean o = (boolean) vh.getAndSetAcquire(false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndSetRelease(false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseOr(false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseOrAcquire(false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseOrRelease(false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseAnd(false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseAndAcquire(false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseAndRelease(false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseXor(false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseXorAcquire(false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + vh.set(true); + + boolean o = (boolean) vh.getAndBitwiseXorRelease(false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) vh.get(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testStaticFieldUnsupported(VarHandle vh) { @@ -623,8 +859,13 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(true); + boolean o = (boolean) vh.getAndAddAcquire(true); }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(true); + }); + } @@ -723,11 +964,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, true, false); + success = vh.weakCompareAndSetPlain(array, i, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) vh.get(array, i); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -753,21 +994,125 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, false, true); + success = vh.weakCompareAndSet(array, i, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) vh.get(array, i); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get { + vh.set(array, i, true); + boolean o = (boolean) vh.getAndSet(array, i, false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) vh.get(array, i); assertEquals(x, false, "getAndSet boolean value"); } + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndSetAcquire(array, i, false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndSetRelease(array, i, false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseOr(array, i, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseOrAcquire(array, i, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseOrRelease(array, i, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseAnd(array, i, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseAndAcquire(array, i, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseAndRelease(array, i, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseXor(array, i, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseXorAcquire(array, i, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + vh.set(array, i, true); + + boolean o = (boolean) vh.getAndBitwiseXorRelease(array, i, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) vh.get(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } } @@ -781,8 +1126,13 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkUOE(() -> { - boolean o = (boolean) vh.addAndGet(array, i, true); + boolean o = (boolean) vh.getAndAddAcquire(array, i, true); }); + + checkUOE(() -> { + boolean o = (boolean) vh.getAndAddRelease(array, i, true); + }); + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -840,11 +1190,11 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, true, false); + boolean r = vh.weakCompareAndSetPlain(array, ci, true, false); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, true, false); + boolean r = vh.weakCompareAndSet(array, ci, true, false); }); checkIOOBE(() -> { @@ -859,6 +1209,50 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) vh.getAndSet(array, ci, true); }); + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndSetAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndSetRelease(array, ci, true); + }); + + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseOr(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseOrAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseOrRelease(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseAnd(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseAndAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseAndRelease(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseXor(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseXorAcquire(array, ci, true); + }); + + checkIOOBE(() -> { + boolean o = (boolean) vh.getAndBitwiseXorRelease(array, ci, true); + }); } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index 754f4908a8a..be79776202b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,7 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); + } @@ -309,6 +323,7 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); + } @@ -404,11 +419,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, (byte)0x01, (byte)0x23); + success = vh.weakCompareAndSetPlain(recv, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) vh.get(recv); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -434,34 +449,157 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, (byte)0x23, (byte)0x01); + success = vh.weakCompareAndSet(recv, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) vh.get(recv); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte value"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte value"); } // Compare set and get { + vh.set(recv, (byte)0x01); + byte o = (byte) vh.getAndSet(recv, (byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) vh.get(recv); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - vh.set(recv, (byte)0x01); + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndSetAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndSetRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { - byte o = (byte) vh.getAndAdd(recv, (byte)0x45); + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndAdd(recv, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) vh.addAndGet(recv, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndAddAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndAddRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddReleasebyte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOr(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAnd(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXor(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorAcquire(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + vh.set(recv, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorRelease(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) vh.get(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); } } static void testInstanceFieldUnsupported(VarHandleTestAccessByte recv, VarHandle vh) { + } @@ -557,11 +695,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet((byte)0x01, (byte)0x23); + success = vh.weakCompareAndSetPlain((byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) vh.get(); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -587,34 +725,157 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease((byte)0x23, (byte)0x01); + success = vh.weakCompareAndSet((byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) vh.get(); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get { + vh.set((byte)0x01); + byte o = (byte) vh.getAndSet((byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) vh.get(); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - vh.set((byte)0x01); + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndSetAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndSetRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { - byte o = (byte) vh.getAndAdd( (byte)0x45); + vh.set((byte)0x01); + + byte o = (byte) vh.getAndAdd((byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) vh.addAndGet((byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndAddAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndAddRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddReleasebyte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseOr((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseAnd((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseXor((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorAcquire((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + vh.set((byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorRelease((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) vh.get(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -713,11 +974,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, (byte)0x01, (byte)0x23); + success = vh.weakCompareAndSetPlain(array, i, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) vh.get(array, i); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -743,29 +1004,151 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, (byte)0x23, (byte)0x01); + success = vh.weakCompareAndSet(array, i, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) vh.get(array, i); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get { + vh.set(array, i, (byte)0x01); + byte o = (byte) vh.getAndSet(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) vh.get(array, i); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - vh.set(array, i, (byte)0x01); + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndSetAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndSetRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { - byte o = (byte) vh.getAndAdd(array, i, (byte)0x45); + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndAdd(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) vh.addAndGet(array, i, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndAddAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndAddRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddReleasebyte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOr(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseOrRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAnd(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseAndRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXor(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorAcquire(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + vh.set(array, i, (byte)0x01); + + byte o = (byte) vh.getAndBitwiseXorRelease(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) vh.get(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); } } } @@ -775,6 +1158,7 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1216,11 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, (byte)0x01, (byte)0x23); + boolean r = vh.weakCompareAndSetPlain(array, ci, (byte)0x01, (byte)0x23); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, (byte)0x01, (byte)0x23); + boolean r = vh.weakCompareAndSet(array, ci, (byte)0x01, (byte)0x23); }); checkIOOBE(() -> { @@ -852,11 +1236,59 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { }); checkIOOBE(() -> { - byte o = (byte) vh.getAndAdd(array, ci, (byte)0x45); + byte o = (byte) vh.getAndSetAcquire(array, ci, (byte)0x01); }); checkIOOBE(() -> { - byte o = (byte) vh.addAndGet(array, ci, (byte)0x45); + byte o = (byte) vh.getAndSetRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndAdd(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndAddAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndAddRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseOr(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseOrAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseOrRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseAnd(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseAndAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseAndRelease(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseXor(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseXorAcquire(array, ci, (byte)0x01); + }); + + checkIOOBE(() -> { + byte o = (byte) vh.getAndBitwiseXorRelease(array, ci, (byte)0x01); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index 9a0af41e930..6e2f42cee14 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,7 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); + } @@ -309,6 +323,7 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); + } @@ -404,11 +419,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, '\u0123', '\u4567'); + success = vh.weakCompareAndSetPlain(recv, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) vh.get(recv); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -434,34 +449,157 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, '\u4567', '\u0123'); + success = vh.weakCompareAndSet(recv, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) vh.get(recv); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char value"); + assertEquals(x, '\u0123', "weakCompareAndSet char value"); } // Compare set and get { + vh.set(recv, '\u0123'); + char o = (char) vh.getAndSet(recv, '\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) vh.get(recv); assertEquals(x, '\u4567', "getAndSet char value"); } - vh.set(recv, '\u0123'); + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndSetAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndSetRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { - char o = (char) vh.getAndAdd(recv, '\u89AB'); + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndAdd(recv, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) vh.addAndGet(recv, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndAddAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndAddRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddReleasechar"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseOr(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseOrAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseOrRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseAnd(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseAndAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseAndRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseXor(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseXorAcquire(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + vh.set(recv, '\u0123'); + + char o = (char) vh.getAndBitwiseXorRelease(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) vh.get(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); } } static void testInstanceFieldUnsupported(VarHandleTestAccessChar recv, VarHandle vh) { + } @@ -557,11 +695,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet('\u0123', '\u4567'); + success = vh.weakCompareAndSetPlain('\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) vh.get(); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -587,34 +725,157 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease('\u4567', '\u0123'); + success = vh.weakCompareAndSet('\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) vh.get(); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get { + vh.set('\u0123'); + char o = (char) vh.getAndSet('\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) vh.get(); assertEquals(x, '\u4567', "getAndSet char value"); } - vh.set('\u0123'); + { + vh.set('\u0123'); + + char o = (char) vh.getAndSetAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) vh.get(); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndSetRelease('\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) vh.get(); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { - char o = (char) vh.getAndAdd( '\u89AB'); + vh.set('\u0123'); + + char o = (char) vh.getAndAdd('\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) vh.addAndGet('\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndAddAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndAddRelease('\u4567'); + assertEquals(o, '\u0123', "getAndAddReleasechar"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseOr('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseOrAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseOrRelease('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseAnd('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseAndAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseAndRelease('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseXor('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseXorAcquire('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + vh.set('\u0123'); + + char o = (char) vh.getAndBitwiseXorRelease('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) vh.get(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -713,11 +974,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, '\u0123', '\u4567'); + success = vh.weakCompareAndSetPlain(array, i, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) vh.get(array, i); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -743,29 +1004,151 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, '\u4567', '\u0123'); + success = vh.weakCompareAndSet(array, i, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) vh.get(array, i); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get { + vh.set(array, i, '\u0123'); + char o = (char) vh.getAndSet(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) vh.get(array, i); assertEquals(x, '\u4567', "getAndSet char value"); } - vh.set(array, i, '\u0123'); + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndSetAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndSetRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { - char o = (char) vh.getAndAdd(array, i, '\u89AB'); + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndAdd(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) vh.addAndGet(array, i, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndAddAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndAddRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddReleasechar"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseOr(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseOrAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseOrRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseAnd(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseAndAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseAndRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseXor(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseXorAcquire(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + vh.set(array, i, '\u0123'); + + char o = (char) vh.getAndBitwiseXorRelease(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) vh.get(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); } } } @@ -775,6 +1158,7 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1216,11 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, '\u0123', '\u4567'); + boolean r = vh.weakCompareAndSetPlain(array, ci, '\u0123', '\u4567'); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, '\u0123', '\u4567'); + boolean r = vh.weakCompareAndSet(array, ci, '\u0123', '\u4567'); }); checkIOOBE(() -> { @@ -852,11 +1236,59 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { }); checkIOOBE(() -> { - char o = (char) vh.getAndAdd(array, ci, '\u89AB'); + char o = (char) vh.getAndSetAcquire(array, ci, '\u0123'); }); checkIOOBE(() -> { - char o = (char) vh.addAndGet(array, ci, '\u89AB'); + char o = (char) vh.getAndSetRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndAdd(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndAddAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, '\u0123'); + }); + + checkIOOBE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, '\u0123'); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index 710aae87fc1..e0564d5d002 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,42 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(recv, 1.0d); + }); } @@ -309,6 +358,42 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(1.0d); + }); } @@ -404,11 +489,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 1.0d, 2.0d); + success = vh.weakCompareAndSetPlain(recv, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(recv); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -434,34 +519,109 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 2.0d, 1.0d); + success = vh.weakCompareAndSet(recv, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(recv); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double value"); + assertEquals(x, 1.0d, "weakCompareAndSet double value"); } // Compare set and get { + vh.set(recv, 1.0d); + double o = (double) vh.getAndSet(recv, 2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) vh.get(recv); assertEquals(x, 2.0d, "getAndSet double value"); } - vh.set(recv, 1.0d); + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndSetAcquire(recv, 2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) vh.get(recv); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndSetRelease(recv, 2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) vh.get(recv); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { - double o = (double) vh.getAndAdd(recv, 3.0d); + vh.set(recv, 1.0d); + + double o = (double) vh.getAndAdd(recv, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) vh.addAndGet(recv, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) vh.get(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } + + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndAddAcquire(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) vh.get(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + vh.set(recv, 1.0d); + + double o = (double) vh.getAndAddRelease(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddReleasedouble"); + double x = (double) vh.get(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestAccessDouble recv, VarHandle vh) { + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(recv, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(recv, 1.0d); + }); } @@ -557,11 +717,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(1.0d, 2.0d); + success = vh.weakCompareAndSetPlain(1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -587,34 +747,109 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(2.0d, 1.0d); + success = vh.weakCompareAndSet(2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get { + vh.set(1.0d); + double o = (double) vh.getAndSet(2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) vh.get(); assertEquals(x, 2.0d, "getAndSet double value"); } - vh.set(1.0d); + { + vh.set(1.0d); + + double o = (double) vh.getAndSetAcquire(2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) vh.get(); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + vh.set(1.0d); + + double o = (double) vh.getAndSetRelease(2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) vh.get(); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { - double o = (double) vh.getAndAdd( 3.0d); + vh.set(1.0d); + + double o = (double) vh.getAndAdd(2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) vh.addAndGet(3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) vh.get(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } + + { + vh.set(1.0d); + + double o = (double) vh.getAndAddAcquire(2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) vh.get(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + vh.set(1.0d); + + double o = (double) vh.getAndAddRelease(2.0d); + assertEquals(o, 1.0d, "getAndAddReleasedouble"); + double x = (double) vh.get(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testStaticFieldUnsupported(VarHandle vh) { + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(1.0d); + }); } @@ -713,11 +948,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 1.0d, 2.0d); + success = vh.weakCompareAndSetPlain(array, i, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(array, i); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -743,30 +978,69 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 2.0d, 1.0d); + success = vh.weakCompareAndSet(array, i, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get { + vh.set(array, i, 1.0d); + double o = (double) vh.getAndSet(array, i, 2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, 2.0d, "getAndSet double value"); } - vh.set(array, i, 1.0d); + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndSetAcquire(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndSetRelease(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) vh.get(array, i); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { - double o = (double) vh.getAndAdd(array, i, 3.0d); + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndAdd(array, i, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) vh.addAndGet(array, i, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) vh.get(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } + + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndAddAcquire(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + vh.set(array, i, 1.0d); + + double o = (double) vh.getAndAddRelease(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddReleasedouble"); + double x = (double) vh.get(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } } @@ -775,6 +1049,42 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { int i = 0; + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, i, 1.0d); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, i, 1.0d); + }); } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1142,11 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 1.0d, 2.0d); + boolean r = vh.weakCompareAndSetPlain(array, ci, 1.0d, 2.0d); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 1.0d, 2.0d); + boolean r = vh.weakCompareAndSet(array, ci, 1.0d, 2.0d); }); checkIOOBE(() -> { @@ -852,12 +1162,25 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { }); checkIOOBE(() -> { - double o = (double) vh.getAndAdd(array, ci, 3.0d); + double o = (double) vh.getAndSetAcquire(array, ci, 1.0d); }); checkIOOBE(() -> { - double o = (double) vh.addAndGet(array, ci, 3.0d); + double o = (double) vh.getAndSetRelease(array, ci, 1.0d); }); + + checkIOOBE(() -> { + double o = (double) vh.getAndAdd(array, ci, 1.0d); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndAddAcquire(array, ci, 1.0d); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, 1.0d); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 4a2306bcab6..4fa6b41fd3c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,42 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); + }); } @@ -309,6 +358,42 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(1.0f); + }); } @@ -404,11 +489,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 1.0f, 2.0f); + success = vh.weakCompareAndSetPlain(recv, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(recv); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -434,34 +519,109 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 2.0f, 1.0f); + success = vh.weakCompareAndSet(recv, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(recv); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float value"); + assertEquals(x, 1.0f, "weakCompareAndSet float value"); } // Compare set and get { + vh.set(recv, 1.0f); + float o = (float) vh.getAndSet(recv, 2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) vh.get(recv); assertEquals(x, 2.0f, "getAndSet float value"); } - vh.set(recv, 1.0f); + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndSetAcquire(recv, 2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) vh.get(recv); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndSetRelease(recv, 2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) vh.get(recv); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { - float o = (float) vh.getAndAdd(recv, 3.0f); + vh.set(recv, 1.0f); + + float o = (float) vh.getAndAdd(recv, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) vh.addAndGet(recv, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) vh.get(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } + + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndAddAcquire(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) vh.get(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + vh.set(recv, 1.0f); + + float o = (float) vh.getAndAddRelease(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddReleasefloat"); + float x = (float) vh.get(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestAccessFloat recv, VarHandle vh) { + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(recv, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(recv, 1.0f); + }); } @@ -557,11 +717,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(1.0f, 2.0f); + success = vh.weakCompareAndSetPlain(1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -587,34 +747,109 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(2.0f, 1.0f); + success = vh.weakCompareAndSet(2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get { + vh.set(1.0f); + float o = (float) vh.getAndSet(2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) vh.get(); assertEquals(x, 2.0f, "getAndSet float value"); } - vh.set(1.0f); + { + vh.set(1.0f); + + float o = (float) vh.getAndSetAcquire(2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) vh.get(); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + vh.set(1.0f); + + float o = (float) vh.getAndSetRelease(2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) vh.get(); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { - float o = (float) vh.getAndAdd( 3.0f); + vh.set(1.0f); + + float o = (float) vh.getAndAdd(2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) vh.addAndGet(3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) vh.get(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } + + { + vh.set(1.0f); + + float o = (float) vh.getAndAddAcquire(2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) vh.get(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + vh.set(1.0f); + + float o = (float) vh.getAndAddRelease(2.0f); + assertEquals(o, 1.0f, "getAndAddReleasefloat"); + float x = (float) vh.get(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testStaticFieldUnsupported(VarHandle vh) { + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(1.0f); + }); } @@ -713,11 +948,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 1.0f, 2.0f); + success = vh.weakCompareAndSetPlain(array, i, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(array, i); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -743,30 +978,69 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 2.0f, 1.0f); + success = vh.weakCompareAndSet(array, i, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get { + vh.set(array, i, 1.0f); + float o = (float) vh.getAndSet(array, i, 2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, 2.0f, "getAndSet float value"); } - vh.set(array, i, 1.0f); + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndSetAcquire(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndSetRelease(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) vh.get(array, i); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { - float o = (float) vh.getAndAdd(array, i, 3.0f); + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndAdd(array, i, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) vh.addAndGet(array, i, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) vh.get(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } + + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndAddAcquire(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + vh.set(array, i, 1.0f); + + float o = (float) vh.getAndAddRelease(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddReleasefloat"); + float x = (float) vh.get(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } } @@ -775,6 +1049,42 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { int i = 0; + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, i, 1.0f); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, i, 1.0f); + }); } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1142,11 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 1.0f, 2.0f); + boolean r = vh.weakCompareAndSetPlain(array, ci, 1.0f, 2.0f); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 1.0f, 2.0f); + boolean r = vh.weakCompareAndSet(array, ci, 1.0f, 2.0f); }); checkIOOBE(() -> { @@ -852,12 +1162,25 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { }); checkIOOBE(() -> { - float o = (float) vh.getAndAdd(array, ci, 3.0f); + float o = (float) vh.getAndSetAcquire(array, ci, 1.0f); }); checkIOOBE(() -> { - float o = (float) vh.addAndGet(array, ci, 3.0f); + float o = (float) vh.getAndSetRelease(array, ci, 1.0f); }); + + checkIOOBE(() -> { + float o = (float) vh.getAndAdd(array, ci, 1.0f); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndAddAcquire(array, ci, 1.0f); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, 1.0f); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index 930ba12eb89..2fbcc9cb46d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); + } @@ -309,6 +323,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); + } @@ -404,11 +419,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 0x01234567, 0x89ABCDEF); + success = vh.weakCompareAndSetPlain(recv, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(recv); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -434,34 +449,157 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 0x89ABCDEF, 0x01234567); + success = vh.weakCompareAndSet(recv, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(recv); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int value"); + assertEquals(x, 0x01234567, "weakCompareAndSet int value"); } // Compare set and get { + vh.set(recv, 0x01234567); + int o = (int) vh.getAndSet(recv, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) vh.get(recv); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - vh.set(recv, 0x01234567); + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndSetAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndSetRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) vh.getAndAdd(recv, 0xCAFEBABE); + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndAdd(recv, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) vh.addAndGet(recv, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndAddAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndAddRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddReleaseint"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseOr(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseOrAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseOrRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseAnd(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseAndAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseAndRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseXor(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseXorAcquire(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(recv, 0x01234567); + + int o = (int) vh.getAndBitwiseXorRelease(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); } } static void testInstanceFieldUnsupported(VarHandleTestAccessInt recv, VarHandle vh) { + } @@ -557,11 +695,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(0x01234567, 0x89ABCDEF); + success = vh.weakCompareAndSetPlain(0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -587,34 +725,157 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(0x89ABCDEF, 0x01234567); + success = vh.weakCompareAndSet(0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get { + vh.set(0x01234567); + int o = (int) vh.getAndSet(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) vh.get(); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - vh.set(0x01234567); + { + vh.set(0x01234567); + + int o = (int) vh.getAndSetAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) vh.get(); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndSetRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) vh.get(); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) vh.getAndAdd( 0xCAFEBABE); + vh.set(0x01234567); + + int o = (int) vh.getAndAdd(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) vh.addAndGet(0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndAddAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndAddRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddReleaseint"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseOr(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseOrAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseOrRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseAnd(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseAndAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseAndRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseXor(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseXorAcquire(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(0x01234567); + + int o = (int) vh.getAndBitwiseXorRelease(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -713,11 +974,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 0x01234567, 0x89ABCDEF); + success = vh.weakCompareAndSetPlain(array, i, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(array, i); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -743,29 +1004,151 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 0x89ABCDEF, 0x01234567); + success = vh.weakCompareAndSet(array, i, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get { + vh.set(array, i, 0x01234567); + int o = (int) vh.getAndSet(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - vh.set(array, i, 0x01234567); + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndSetAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndSetRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) vh.getAndAdd(array, i, 0xCAFEBABE); + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndAdd(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) vh.addAndGet(array, i, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndAddAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndAddRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddReleaseint"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseOr(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseOrAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseOrRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseAnd(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseAndAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseAndRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseXor(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseXorAcquire(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(array, i, 0x01234567); + + int o = (int) vh.getAndBitwiseXorRelease(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); } } } @@ -775,6 +1158,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1216,11 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 0x01234567, 0x89ABCDEF); + boolean r = vh.weakCompareAndSetPlain(array, ci, 0x01234567, 0x89ABCDEF); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 0x01234567, 0x89ABCDEF); + boolean r = vh.weakCompareAndSet(array, ci, 0x01234567, 0x89ABCDEF); }); checkIOOBE(() -> { @@ -852,11 +1236,59 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { }); checkIOOBE(() -> { - int o = (int) vh.getAndAdd(array, ci, 0xCAFEBABE); + int o = (int) vh.getAndSetAcquire(array, ci, 0x01234567); }); checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, 0xCAFEBABE); + int o = (int) vh.getAndSetRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAdd(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, 0x01234567); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, 0x01234567); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index 257e56b3b32..d94cdc131d2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); + } @@ -309,6 +323,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); + } @@ -404,11 +419,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = vh.weakCompareAndSetPlain(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(recv); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -434,34 +449,157 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = vh.weakCompareAndSet(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(recv); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long value"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long value"); } // Compare set and get { + vh.set(recv, 0x0123456789ABCDEFL); + long o = (long) vh.getAndSet(recv, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) vh.get(recv); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - vh.set(recv, 0x0123456789ABCDEFL); + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) vh.getAndAdd(recv, 0xDEADBEEFDEADBEEFL); + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAdd(recv, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) vh.addAndGet(recv, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddReleaselong"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOr(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAnd(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXor(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorAcquire(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(recv, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorRelease(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); } } static void testInstanceFieldUnsupported(VarHandleTestAccessLong recv, VarHandle vh) { + } @@ -557,11 +695,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = vh.weakCompareAndSetPlain(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -587,34 +725,157 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = vh.weakCompareAndSet(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get { + vh.set(0x0123456789ABCDEFL); + long o = (long) vh.getAndSet(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) vh.get(); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - vh.set(0x0123456789ABCDEFL); + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) vh.get(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) vh.get(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) vh.getAndAdd( 0xDEADBEEFDEADBEEFL); + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndAdd(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) vh.addAndGet(0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddReleaselong"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOr(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAnd(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXor(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorAcquire(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorRelease(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -713,11 +974,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = vh.weakCompareAndSetPlain(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(array, i); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -743,29 +1004,151 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = vh.weakCompareAndSet(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get { + vh.set(array, i, 0x0123456789ABCDEFL); + long o = (long) vh.getAndSet(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - vh.set(array, i, 0x0123456789ABCDEFL); + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndSetRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) vh.getAndAdd(array, i, 0xDEADBEEFDEADBEEFL); + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAdd(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) vh.addAndGet(array, i, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndAddRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddReleaselong"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOr(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseOrRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAnd(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseAndRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXor(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorAcquire(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(array, i, 0x0123456789ABCDEFL); + + long o = (long) vh.getAndBitwiseXorRelease(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); } } } @@ -775,6 +1158,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1216,11 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + boolean r = vh.weakCompareAndSetPlain(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + boolean r = vh.weakCompareAndSet(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); }); checkIOOBE(() -> { @@ -852,11 +1236,59 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { }); checkIOOBE(() -> { - long o = (long) vh.getAndAdd(array, ci, 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndSetAcquire(array, ci, 0x0123456789ABCDEFL); }); checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, 0xDEADBEEFDEADBEEFL); + long o = (long) vh.getAndSetRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAdd(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, 0x0123456789ABCDEFL); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, 0x0123456789ABCDEFL); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index 53535de28c9..7ff96eb10ea 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -261,6 +274,7 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); + } @@ -309,6 +323,7 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); + } @@ -404,11 +419,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, (short)0x0123, (short)0x4567); + success = vh.weakCompareAndSetPlain(recv, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) vh.get(recv); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -434,34 +449,157 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, (short)0x4567, (short)0x0123); + success = vh.weakCompareAndSet(recv, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) vh.get(recv); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short value"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short value"); } // Compare set and get { + vh.set(recv, (short)0x0123); + short o = (short) vh.getAndSet(recv, (short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) vh.get(recv); assertEquals(x, (short)0x4567, "getAndSet short value"); } - vh.set(recv, (short)0x0123); + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndSetAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndSetRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { - short o = (short) vh.getAndAdd(recv, (short)0x89AB); + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndAdd(recv, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) vh.addAndGet(recv, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndAddAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndAddRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddReleaseshort"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseOr(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseAnd(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseXor(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorAcquire(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + vh.set(recv, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorRelease(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) vh.get(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); } } static void testInstanceFieldUnsupported(VarHandleTestAccessShort recv, VarHandle vh) { + } @@ -557,11 +695,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet((short)0x0123, (short)0x4567); + success = vh.weakCompareAndSetPlain((short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) vh.get(); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -587,34 +725,157 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease((short)0x4567, (short)0x0123); + success = vh.weakCompareAndSet((short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) vh.get(); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get { + vh.set((short)0x0123); + short o = (short) vh.getAndSet((short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) vh.get(); assertEquals(x, (short)0x4567, "getAndSet short value"); } - vh.set((short)0x0123); + { + vh.set((short)0x0123); + + short o = (short) vh.getAndSetAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndSetRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { - short o = (short) vh.getAndAdd( (short)0x89AB); + vh.set((short)0x0123); + + short o = (short) vh.getAndAdd((short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) vh.addAndGet((short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndAddAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndAddRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddReleaseshort"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseOr((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseOrAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseOrRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseAnd((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseAndAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseAndRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseXor((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseXorAcquire((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + vh.set((short)0x0123); + + short o = (short) vh.getAndBitwiseXorRelease((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) vh.get(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); } } static void testStaticFieldUnsupported(VarHandle vh) { + } @@ -713,11 +974,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, (short)0x0123, (short)0x4567); + success = vh.weakCompareAndSetPlain(array, i, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) vh.get(array, i); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -743,29 +1004,151 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, (short)0x4567, (short)0x0123); + success = vh.weakCompareAndSet(array, i, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) vh.get(array, i); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get { + vh.set(array, i, (short)0x0123); + short o = (short) vh.getAndSet(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) vh.get(array, i); assertEquals(x, (short)0x4567, "getAndSet short value"); } - vh.set(array, i, (short)0x0123); + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndSetAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndSetRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { - short o = (short) vh.getAndAdd(array, i, (short)0x89AB); + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndAdd(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) vh.addAndGet(array, i, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndAddAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndAddRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddReleaseshort"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseOr(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseOrRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseAnd(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseAndRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseXor(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorAcquire(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + vh.set(array, i, (short)0x0123); + + short o = (short) vh.getAndBitwiseXorRelease(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) vh.get(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); } } } @@ -775,6 +1158,7 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { int i = 0; + } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -832,11 +1216,11 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, (short)0x0123, (short)0x4567); + boolean r = vh.weakCompareAndSetPlain(array, ci, (short)0x0123, (short)0x4567); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, (short)0x0123, (short)0x4567); + boolean r = vh.weakCompareAndSet(array, ci, (short)0x0123, (short)0x4567); }); checkIOOBE(() -> { @@ -852,11 +1236,59 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { }); checkIOOBE(() -> { - short o = (short) vh.getAndAdd(array, ci, (short)0x89AB); + short o = (short) vh.getAndSetAcquire(array, ci, (short)0x0123); }); checkIOOBE(() -> { - short o = (short) vh.addAndGet(array, ci, (short)0x89AB); + short o = (short) vh.getAndSetRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndAdd(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndAddAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, (short)0x0123); + }); + + checkIOOBE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, (short)0x0123); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 0ac329d65f8..0904505db40 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -103,14 +103,27 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @@ -266,7 +279,47 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkUOE(() -> { - String o = (String) vh.addAndGet(recv, "foo"); + String o = (String) vh.getAndAddAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease(recv, "foo"); }); } @@ -321,7 +374,47 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkUOE(() -> { - String o = (String) vh.addAndGet("foo"); + String o = (String) vh.getAndAddAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease("foo"); }); } @@ -418,11 +511,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, "foo", "bar"); + success = vh.weakCompareAndSetPlain(recv, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) vh.get(recv); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -448,21 +541,42 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, "bar", "foo"); + success = vh.weakCompareAndSet(recv, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(recv); - assertEquals(x, "foo", "weakCompareAndSetVolatile String value"); + assertEquals(x, "foo", "weakCompareAndSet String value"); } // Compare set and get { + vh.set(recv, "foo"); + String o = (String) vh.getAndSet(recv, "bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(recv); assertEquals(x, "bar", "getAndSet String value"); } + { + vh.set(recv, "foo"); + + String o = (String) vh.getAndSetAcquire(recv, "bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) vh.get(recv); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + vh.set(recv, "foo"); + + String o = (String) vh.getAndSetRelease(recv, "bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) vh.get(recv); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } static void testInstanceFieldUnsupported(VarHandleTestAccessString recv, VarHandle vh) { @@ -472,7 +586,47 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkUOE(() -> { - String o = (String) vh.addAndGet(recv, "foo"); + String o = (String) vh.getAndAddAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire(recv, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease(recv, "foo"); }); } @@ -569,11 +723,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet("foo", "bar"); + success = vh.weakCompareAndSetPlain("foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) vh.get(); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -599,21 +753,42 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease("bar", "foo"); + success = vh.weakCompareAndSet("bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get { + vh.set("foo"); + String o = (String) vh.getAndSet("bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(); assertEquals(x, "bar", "getAndSet String value"); } + { + vh.set("foo"); + + String o = (String) vh.getAndSetAcquire("bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) vh.get(); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + vh.set("foo"); + + String o = (String) vh.getAndSetRelease("bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) vh.get(); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } static void testStaticFieldUnsupported(VarHandle vh) { @@ -623,7 +798,47 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkUOE(() -> { - String o = (String) vh.addAndGet("foo"); + String o = (String) vh.getAndAddAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire("foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease("foo"); }); } @@ -723,11 +938,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, "foo", "bar"); + success = vh.weakCompareAndSetPlain(array, i, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) vh.get(array, i); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -753,21 +968,42 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, "bar", "foo"); + success = vh.weakCompareAndSet(array, i, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(array, i); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get { + vh.set(array, i, "foo"); + String o = (String) vh.getAndSet(array, i, "bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(array, i); assertEquals(x, "bar", "getAndSet String value"); } + { + vh.set(array, i, "foo"); + + String o = (String) vh.getAndSetAcquire(array, i, "bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) vh.get(array, i); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + vh.set(array, i, "foo"); + + String o = (String) vh.getAndSetRelease(array, i, "bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) vh.get(array, i); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } } @@ -781,7 +1017,47 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkUOE(() -> { - String o = (String) vh.addAndGet(array, i, "foo"); + String o = (String) vh.getAndAddAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndAddRelease(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOr(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseOrRelease(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAnd(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseAndRelease(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXor(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorAcquire(array, i, "foo"); + }); + + checkUOE(() -> { + String o = (String) vh.getAndBitwiseXorRelease(array, i, "foo"); }); } @@ -840,11 +1116,11 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, "foo", "bar"); + boolean r = vh.weakCompareAndSetPlain(array, ci, "foo", "bar"); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, "foo", "bar"); + boolean r = vh.weakCompareAndSet(array, ci, "foo", "bar"); }); checkIOOBE(() -> { @@ -859,6 +1135,15 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { String o = (String) vh.getAndSet(array, ci, "foo"); }); + checkIOOBE(() -> { + String o = (String) vh.getAndSetAcquire(array, ci, "foo"); + }); + + checkIOOBE(() -> { + String o = (String) vh.getAndSetRelease(array, ci, "foo"); + }); + + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index dc9db6f2d26..89d22695e55 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -92,14 +92,27 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -201,11 +214,11 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -220,12 +233,60 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { char o = (char) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - char o = (char) vh.addAndGet(array, ci, VALUE_1); + char o = (char) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } @@ -270,11 +331,11 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -289,12 +350,60 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { char o = (char) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + char o = (char) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - char o = (char) vh.addAndGet(array, ci, VALUE_1); + char o = (char) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } else { @@ -315,11 +424,11 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -333,12 +442,59 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { checkUOE(() -> { char o = (char) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + char o = (char) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndSetRelease(array, ci, VALUE_1); + }); checkUOE(() -> { char o = (char) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - char o = (char) vh.addAndGet(array, ci, VALUE_1); + char o = (char) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + char o = (char) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -385,6 +541,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); + } } @@ -434,6 +591,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); + } } } @@ -518,6 +676,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { }); + } } } @@ -564,6 +723,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque char value"); } + } } } @@ -609,6 +769,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque char value"); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index a713e91b979..5757d1958c1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -92,14 +92,27 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -190,7 +203,47 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - double o = (double) vh.addAndGet(array, ci, VALUE_1); + double o = (double) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } @@ -236,11 +289,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -255,13 +308,61 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - double o = (double) vh.addAndGet(array, ci, VALUE_1); + double o = (double) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } else { @@ -270,7 +371,46 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - double o = (double) vh.addAndGet(array, ci, VALUE_1); + double o = (double) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + double o = (double) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -333,11 +473,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -352,6 +492,15 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } @@ -418,11 +567,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -437,6 +586,15 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -494,11 +652,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -513,6 +671,14 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + } } @@ -573,11 +739,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -592,6 +758,15 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + double o = (double) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + double o = (double) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -700,11 +875,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet double value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain double value"); } { @@ -728,20 +903,44 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile double value"); + assertEquals(x, VALUE_1, "weakCompareAndSet double"); } // Compare set and get { + vh.set(array, i, VALUE_1); + double o = (double) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet double value"); } + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire double value"); + } + + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease double value"); + } + + } } } @@ -849,11 +1048,11 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet double value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain double value"); } { @@ -877,20 +1076,44 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile double value"); + assertEquals(x, VALUE_1, "weakCompareAndSet double"); } // Compare set and get { + vh.set(array, i, VALUE_1); + double o = (double) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet double value"); } + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire double value"); + } + + { + vh.set(array, i, VALUE_1); + + double o = (double) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease double"); + double x = (double) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease double value"); + } + + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index 3e964dcd46a..89d8fe91502 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -92,14 +92,27 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -190,7 +203,47 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - float o = (float) vh.addAndGet(array, ci, VALUE_1); + float o = (float) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } @@ -236,11 +289,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -255,13 +308,61 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - float o = (float) vh.addAndGet(array, ci, VALUE_1); + float o = (float) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } else { @@ -270,7 +371,46 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - float o = (float) vh.addAndGet(array, ci, VALUE_1); + float o = (float) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + float o = (float) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -333,11 +473,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -352,6 +492,15 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } @@ -418,11 +567,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -437,6 +586,15 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -494,11 +652,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -513,6 +671,14 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + } } @@ -573,11 +739,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -592,6 +758,15 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + float o = (float) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + float o = (float) vh.getAndSetRelease(array, ci, VALUE_1); + }); + + } } } @@ -700,11 +875,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet float value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain float value"); } { @@ -728,20 +903,44 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile float value"); + assertEquals(x, VALUE_1, "weakCompareAndSet float"); } // Compare set and get { + vh.set(array, i, VALUE_1); + float o = (float) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet float value"); } + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire float value"); + } + + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease float value"); + } + + } } } @@ -849,11 +1048,11 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet float value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain float value"); } { @@ -877,20 +1076,44 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile float value"); + assertEquals(x, VALUE_1, "weakCompareAndSet float"); } // Compare set and get { + vh.set(array, i, VALUE_1); + float o = (float) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet float value"); } + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire float value"); + } + + { + vh.set(array, i, VALUE_1); + + float o = (float) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease float"); + float x = (float) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease float value"); + } + + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index bbda8c0270f..79e9daba605 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -92,14 +92,27 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -185,6 +198,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int ci = 1; + } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -229,11 +243,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -248,13 +262,61 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); checkROBE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } else { @@ -319,11 +381,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -338,12 +400,60 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } @@ -411,11 +521,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -430,12 +540,60 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); checkIOOBE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -494,11 +652,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -513,14 +671,61 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); checkISE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -580,11 +785,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -599,12 +804,60 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + int o = (int) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); }); checkISE(() -> { - int o = (int) vh.addAndGet(array, ci, VALUE_1); + int o = (int) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + int o = (int) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -714,11 +967,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet int value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain int value"); } { @@ -742,28 +995,153 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile int value"); + assertEquals(x, VALUE_1, "weakCompareAndSet int"); } // Compare set and get { + vh.set(array, i, VALUE_1); + int o = (int) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet int value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) vh.getAndAdd(array, i, VALUE_3); + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd int"); - int c = (int) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd int value"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease int value"); } } } @@ -872,11 +1250,11 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet int value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain int value"); } { @@ -900,28 +1278,153 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile int value"); + assertEquals(x, VALUE_1, "weakCompareAndSet int"); } // Compare set and get { + vh.set(array, i, VALUE_1); + int o = (int) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet int value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) vh.getAndAdd(array, i, VALUE_3); + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd int"); - int c = (int) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd int value"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease int value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire int value"); + } + + { + vh.set(array, i, VALUE_1); + + int o = (int) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease int"); + int x = (int) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease int value"); } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index e203f8e23f7..01cdfcef554 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -92,14 +92,27 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -185,6 +198,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { int ci = 1; + } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -229,11 +243,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -248,13 +262,61 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkROBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); checkROBE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } else { @@ -319,11 +381,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -338,12 +400,60 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } @@ -411,11 +521,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -430,12 +540,60 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkIOOBE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkIOOBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); checkIOOBE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -494,11 +652,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -513,14 +671,61 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); checkISE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); } } } @@ -580,11 +785,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -599,12 +804,60 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); + checkISE(() -> { + long o = (long) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkISE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); }); checkISE(() -> { - long o = (long) vh.addAndGet(array, ci, VALUE_1); + long o = (long) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + long o = (long) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -714,11 +967,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet long value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain long value"); } { @@ -742,28 +995,153 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile long value"); + assertEquals(x, VALUE_1, "weakCompareAndSet long"); } // Compare set and get { + vh.set(array, i, VALUE_1); + long o = (long) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet long value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) vh.getAndAdd(array, i, VALUE_3); + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd long"); - long c = (long) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd long value"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease long value"); } } } @@ -872,11 +1250,11 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet long value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain long value"); } { @@ -900,28 +1278,153 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile long value"); + assertEquals(x, VALUE_1, "weakCompareAndSet long"); } // Compare set and get { + vh.set(array, i, VALUE_1); + long o = (long) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet long value"); } - vh.set(array, i, VALUE_1); + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) vh.getAndAdd(array, i, VALUE_3); + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd long"); - long c = (long) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd long value"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease long value"); + } + + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire long value"); + } + + { + vh.set(array, i, VALUE_1); + + long o = (long) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease long"); + long x = (long) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease long value"); } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index d96715ed083..29e45a04c0e 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -92,14 +92,27 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); + + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); } @Test(dataProvider = "typesProvider") @@ -201,11 +214,11 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -220,12 +233,60 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { short o = (short) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - short o = (short) vh.addAndGet(array, ci, VALUE_1); + short o = (short) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } @@ -270,11 +331,11 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -289,12 +350,60 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { short o = (short) vh.getAndSet(array, ci, VALUE_1); }); + checkUOE(() -> { + short o = (short) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndSetRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - short o = (short) vh.addAndGet(array, ci, VALUE_1); + short o = (short) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } else { @@ -315,11 +424,11 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -333,12 +442,59 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { checkUOE(() -> { short o = (short) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + short o = (short) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndSetRelease(array, ci, VALUE_1); + }); checkUOE(() -> { short o = (short) vh.getAndAdd(array, ci, VALUE_1); }); checkUOE(() -> { - short o = (short) vh.addAndGet(array, ci, VALUE_1); + short o = (short) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndAddRelease(array, ci, VALUE_1); + }); + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + short o = (short) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); }); } } @@ -385,6 +541,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); + } } @@ -434,6 +591,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); + } } } @@ -518,6 +676,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { }); + } } } @@ -564,6 +723,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque short value"); } + } } } @@ -609,6 +769,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertEquals(x, VALUE_2, "setOpaque short value"); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java index 544fcb3c0ee..99904d32c02 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, true, false); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, false, true); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get @@ -255,6 +255,90 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { assertEquals(x, false, "getAndSet boolean value"); } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable { @@ -264,6 +348,7 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { boolean r = (boolean) hs.get(am).invokeExact(recv, true); }); } + } @@ -359,11 +444,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(true, false); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -389,21 +474,127 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(false, true); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get { - boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact( false); + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, false, "getAndSet boolean value"); } + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { @@ -413,6 +604,7 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { boolean r = (boolean) hs.get(am).invokeExact(true); }); } + } @@ -511,11 +703,11 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, true, false); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, true, false); } - assertEquals(success, true, "weakCompareAndSet boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, false, "weakCompareAndSet boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { @@ -541,21 +733,125 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, false, true); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, false, true); } - assertEquals(success, true, "weakCompareAndSetVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, true, "weakCompareAndSetVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, false); assertEquals(o, true, "getAndSet boolean"); boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, false, "getAndSet boolean value"); } + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndSetAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, false, "getAndSetAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndSetRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, false, "getAndSetRelease boolean value"); + } + + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseOr boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOr boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseOrAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseOrRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true | false), "getAndBitwiseOrRelease boolean value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseAnd boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAnd boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseAndAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseAndRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true & false), "getAndBitwiseAndRelease boolean value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseXor boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXor boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseXorAcquire boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorAcquire boolean value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, true); + + boolean o = (boolean) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, false); + assertEquals(o, true, "getAndBitwiseXorRelease boolean"); + boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (boolean)(true ^ false), "getAndBitwiseXorRelease boolean value"); + } } } @@ -569,6 +865,7 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { boolean o = (boolean) hs.get(am).invokeExact(array, i, true); }); } + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -607,6 +904,12 @@ public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + boolean o = (boolean) hs.get(am).invokeExact(array, ci, false); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java index 21e09b83953..7ab3b99f949 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (byte)0x01, (byte)0x23); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, (byte)0x23, (byte)0x01); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { assertEquals(x, (byte)0x23, "getAndSet byte value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); - // get and add, add and get { - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (byte)0x45); + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessByte recv, Handles hs) throws Throwable { + } @@ -363,11 +466,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((byte)0x01, (byte)0x23); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact((byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -393,34 +496,159 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact((byte)0x23, (byte)0x01); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get { - byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact( (byte)0x23); + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact((byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( (byte)0x45); + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact((byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -519,11 +747,11 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (byte)0x01, (byte)0x23); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSet byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (byte)0x23, "weakCompareAndSet byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { @@ -549,30 +777,152 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, (byte)0x23, (byte)0x01); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSetVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndSet byte"); byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, (byte)0x23, "getAndSet byte value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)0x23, "getAndSetAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndSetRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)0x23, "getAndSetRelease byte value"); + } // get and add, add and get { - byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (byte)0x45); + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (byte)0x23); assertEquals(o, (byte)0x01, "getAndAdd byte"); - byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (byte)0x45); - assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndAddRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAddRelease byte value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOr byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOr byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseOrRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 | (byte)0x23), "getAndBitwiseOrRelease byte value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAnd byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAnd byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseAndRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 & (byte)0x23), "getAndBitwiseAndRelease byte value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXor byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXor byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorAcquire byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorAcquire byte value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01); + + byte o = (byte) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, (byte)0x23); + assertEquals(o, (byte)0x01, "getAndBitwiseXorRelease byte"); + byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (byte)((byte)0x01 ^ (byte)0x23), "getAndBitwiseXorRelease byte value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest { byte o = (byte) hs.get(am).invokeExact(array, ci, (byte)0x45); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + byte o = (byte) hs.get(am).invokeExact(array, ci, (byte)0x45); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java index 1f2e5ee10c6..762134b625f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u4567'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, '\u4567', '\u0123'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { assertEquals(x, '\u4567', "getAndSet char value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); - // get and add, add and get { - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u89AB'); + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndAddRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable { + } @@ -363,11 +466,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact('\u0123', '\u4567'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact('\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -393,34 +496,159 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact('\u4567', '\u0123'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact('\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get { - char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact( '\u4567'); + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact('\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, '\u4567', "getAndSet char value"); } - hs.get(TestAccessMode.SET).invokeExact('\u0123'); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( '\u89AB'); + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact('\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact('\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndAddRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact('\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact('\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -519,11 +747,11 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u4567'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSet char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, '\u4567', "weakCompareAndSet char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { @@ -549,30 +777,152 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, '\u4567', '\u0123'); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSetVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, '\u0123', "weakCompareAndSetVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndSet char"); char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, '\u4567', "getAndSet char value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, '\u4567', "getAndSetAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndSetRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, '\u4567', "getAndSetRelease char value"); + } // get and add, add and get { - char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u89AB'); + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u4567'); assertEquals(o, '\u0123', "getAndAdd char"); - char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, '\u89AB'); - assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndAddRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAddRelease char value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOr char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOr char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseOrRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' | '\u4567'), "getAndBitwiseOrRelease char value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAnd char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAnd char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseAndRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' & '\u4567'), "getAndBitwiseAndRelease char value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXor char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXor char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorAcquire char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorAcquire char value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123'); + + char o = (char) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, '\u4567'); + assertEquals(o, '\u0123', "getAndBitwiseXorRelease char"); + char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (char)('\u0123' ^ '\u4567'), "getAndBitwiseXorRelease char value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest { char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB'); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB'); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java index 26cb426ab81..409d700c474 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1.0d, 2.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2.0d, 1.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get @@ -255,19 +255,44 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { assertEquals(x, 2.0d, "getAndSet double value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); - // get and add, add and get { - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3.0d); + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 2.0d); + assertEquals(o, 1.0d, "getAndAddRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessDouble recv, Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + double r = (double) hs.get(am).invokeExact(recv, 1.0d); + }); + } } @@ -363,11 +388,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1.0d, 2.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -393,34 +418,81 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2.0d, 1.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get { - double o = (double) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2.0d); + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2.0d, "getAndSet double value"); } - hs.get(TestAccessMode.SET).invokeExact(1.0d); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3.0d); + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(2.0d); + assertEquals(o, 1.0d, "getAndAddRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + double r = (double) hs.get(am).invokeExact(1.0d); + }); + } } @@ -519,11 +591,11 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1.0d, 2.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSet double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 2.0d, "weakCompareAndSet double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { @@ -549,30 +621,69 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2.0d, 1.0d); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSetVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 1.0d, "weakCompareAndSetVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + double o = (double) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2.0d); assertEquals(o, 1.0d, "getAndSet double"); double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2.0d, "getAndSet double value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0d, "getAndSetAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndSetRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0d, "getAndSetRelease double value"); + } // get and add, add and get { - double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3.0d); + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 2.0d); assertEquals(o, 1.0d, "getAndAdd double"); - double c = (double) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3.0d); - assertEquals(c, (double)(1.0d + 3.0d + 3.0d), "getAndAdd double value"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAdd double value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddAcquire double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddAcquire double value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0d); + + double o = (double) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 2.0d); + assertEquals(o, 1.0d, "getAndAddRelease double"); + double x = (double) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (double)(1.0d + 2.0d), "getAndAddRelease double value"); + } + } } @@ -581,6 +692,12 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { final int i = 0; + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + double o = (double) hs.get(am).invokeExact(array, i, 1.0d); + }); + } } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +741,7 @@ public class VarHandleTestMethodHandleAccessDouble extends VarHandleBaseTest { double o = (double) hs.get(am).invokeExact(array, ci, 3.0d); }); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java index d28e2f41b6e..b826e18d483 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1.0f, 2.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2.0f, 1.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get @@ -255,19 +255,44 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { assertEquals(x, 2.0f, "getAndSet float value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); - // get and add, add and get { - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3.0f); + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 2.0f); + assertEquals(o, 1.0f, "getAndAddRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessFloat recv, Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + float r = (float) hs.get(am).invokeExact(recv, 1.0f); + }); + } } @@ -363,11 +388,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1.0f, 2.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -393,34 +418,81 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2.0f, 1.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get { - float o = (float) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2.0f); + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET).invokeExact(2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2.0f, "getAndSet float value"); } - hs.get(TestAccessMode.SET).invokeExact(1.0f); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3.0f); + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(2.0f); + assertEquals(o, 1.0f, "getAndAddRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + float r = (float) hs.get(am).invokeExact(1.0f); + }); + } } @@ -519,11 +591,11 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1.0f, 2.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSet float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 2.0f, "weakCompareAndSet float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { @@ -549,30 +621,69 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2.0f, 1.0f); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSetVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 1.0f, "weakCompareAndSetVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + float o = (float) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2.0f); assertEquals(o, 1.0f, "getAndSet float"); float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2.0f, "getAndSet float value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0f, "getAndSetAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndSetRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 2.0f, "getAndSetRelease float value"); + } // get and add, add and get { - float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3.0f); + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 2.0f); assertEquals(o, 1.0f, "getAndAdd float"); - float c = (float) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3.0f); - assertEquals(c, (float)(1.0f + 3.0f + 3.0f), "getAndAdd float value"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAdd float value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddAcquire float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddAcquire float value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 1.0f); + + float o = (float) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 2.0f); + assertEquals(o, 1.0f, "getAndAddRelease float"); + float x = (float) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (float)(1.0f + 2.0f), "getAndAddRelease float value"); + } + } } @@ -581,6 +692,12 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { final int i = 0; + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + float o = (float) hs.get(am).invokeExact(array, i, 1.0f); + }); + } } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +741,7 @@ public class VarHandleTestMethodHandleAccessFloat extends VarHandleBaseTest { float o = (float) hs.get(am).invokeExact(array, ci, 3.0f); }); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index 56954238e27..da0c63fa155 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x01234567, 0x89ABCDEF); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 0x89ABCDEF, 0x01234567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); - // get and add, add and get { - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xCAFEBABE); + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessInt recv, Handles hs) throws Throwable { + } @@ -363,11 +466,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x01234567, 0x89ABCDEF); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -393,34 +496,159 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(0x89ABCDEF, 0x01234567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get { - int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 0x89ABCDEF); + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - hs.get(TestAccessMode.SET).invokeExact(0x01234567); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 0xCAFEBABE); + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -519,11 +747,11 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x01234567, 0x89ABCDEF); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSet int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { @@ -549,30 +777,152 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 0x89ABCDEF, 0x01234567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSetVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 0x89ABCDEF, "getAndSet int value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndSetRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0x89ABCDEF, "getAndSetRelease int value"); + } // get and add, add and get { - int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xCAFEBABE); + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0x89ABCDEF); assertEquals(o, 0x01234567, "getAndAdd int"); - int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xCAFEBABE); - assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndAddRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAddRelease int value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOr int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOr int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseOrRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 | 0x89ABCDEF), "getAndBitwiseOrRelease int value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAnd int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAnd int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseAndRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 & 0x89ABCDEF), "getAndBitwiseAndRelease int value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXor int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXor int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorAcquire int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorAcquire int value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567); + + int o = (int) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, 0x89ABCDEF); + assertEquals(o, 0x01234567, "getAndBitwiseXorRelease int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (int)(0x01234567 ^ 0x89ABCDEF), "getAndBitwiseXorRelease int value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { int o = (int) hs.get(am).invokeExact(array, ci, 0xCAFEBABE); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + int o = (int) hs.get(am).invokeExact(array, ci, 0xCAFEBABE); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 848da74e166..6e16e7c82da 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); - // get and add, add and get { - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xDEADBEEFDEADBEEFL); + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessLong recv, Handles hs) throws Throwable { + } @@ -363,11 +466,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -393,34 +496,159 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get { - long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 0xCAFEBABECAFEBABEL); + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 0xDEADBEEFDEADBEEFL); + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -519,11 +747,11 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSet long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { @@ -549,30 +777,152 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSetVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndSetRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSetRelease long value"); + } // get and add, add and get { - long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xDEADBEEFDEADBEEFL); + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xCAFEBABECAFEBABEL); assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long"); - long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xDEADBEEFDEADBEEFL); - assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndAddRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAddRelease long value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOr long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOr long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseOrRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL | 0xCAFEBABECAFEBABEL), "getAndBitwiseOrRelease long value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAnd long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAnd long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseAndRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL & 0xCAFEBABECAFEBABEL), "getAndBitwiseAndRelease long value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXor long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXor long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorAcquire long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorAcquire long value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL); + + long o = (long) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL); + assertEquals(o, 0x0123456789ABCDEFL, "getAndBitwiseXorRelease long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (long)(0x0123456789ABCDEFL ^ 0xCAFEBABECAFEBABEL), "getAndBitwiseXorRelease long value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { long o = (long) hs.get(am).invokeExact(array, ci, 0xDEADBEEFDEADBEEFL); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + long o = (long) hs.get(am).invokeExact(array, ci, 0xDEADBEEFDEADBEEFL); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java index ca4121e412e..5b6b8ad39c7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (short)0x0123, (short)0x4567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, (short)0x4567, (short)0x0123); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get @@ -255,19 +255,122 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { assertEquals(x, (short)0x4567, "getAndSet short value"); } - hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); - // get and add, add and get { - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (short)0x89AB); + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); } } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable { + } @@ -363,11 +466,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((short)0x0123, (short)0x4567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact((short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -393,34 +496,159 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact((short)0x4567, (short)0x0123); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get { - short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact( (short)0x4567); + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact((short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, (short)0x4567, "getAndSet short value"); } - hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( (short)0x89AB); + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact((short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact((short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact((short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); } } static void testStaticFieldUnsupported(Handles hs) throws Throwable { + } @@ -519,11 +747,11 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (short)0x0123, (short)0x4567); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSet short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (short)0x4567, "weakCompareAndSet short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { @@ -549,30 +777,152 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, (short)0x4567, (short)0x0123); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSetVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndSet short"); short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, (short)0x4567, "getAndSet short value"); } - hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)0x4567, "getAndSetAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndSetRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)0x4567, "getAndSetRelease short value"); + } // get and add, add and get { - short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (short)0x89AB); + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (short)0x4567); assertEquals(o, (short)0x0123, "getAndAdd short"); - short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (short)0x89AB); - assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndAddRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAddRelease short value"); + } + + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOr short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOr short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseOrRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 | (short)0x4567), "getAndBitwiseOrRelease short value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAnd short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAnd short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseAndRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 & (short)0x4567), "getAndBitwiseAndRelease short value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXor short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXor short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorAcquire short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorAcquire short value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123); + + short o = (short) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, (short)0x4567); + assertEquals(o, (short)0x0123, "getAndBitwiseXorRelease short"); + short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, (short)((short)0x0123 ^ (short)0x4567), "getAndBitwiseXorRelease short value"); + } } } @@ -581,6 +931,7 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { final int i = 0; + } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -624,6 +975,12 @@ public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest { short o = (short) hs.get(am).invokeExact(array, ci, (short)0x89AB); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + short o = (short) hs.get(am).invokeExact(array, ci, (short)0x89AB); + }); + } } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index 079d8053606..0eb978588b5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -210,11 +210,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -240,11 +240,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get @@ -255,6 +255,7 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "getAndSet String value"); } + } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessString recv, Handles hs) throws Throwable { @@ -264,6 +265,12 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { String r = (String) hs.get(am).invokeExact(recv, "foo"); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + String r = (String) hs.get(am).invokeExact(recv, "foo"); + }); + } } @@ -359,11 +366,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact("foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -389,21 +396,44 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get { - String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "bar"); + hs.get(TestAccessMode.SET).invokeExact("foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact("bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "bar", "getAndSet String value"); } + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact("foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact("bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact("foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact("bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } static void testStaticFieldUnsupported(Handles hs) throws Throwable { @@ -413,6 +443,12 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { String r = (String) hs.get(am).invokeExact("foo"); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + String r = (String) hs.get(am).invokeExact("foo"); + }); + } } @@ -511,11 +547,11 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSet String"); + assertEquals(success, true, "weakCompareAndSetPlain String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, "bar", "weakCompareAndSet String value"); + assertEquals(x, "bar", "weakCompareAndSetPlain String value"); } { @@ -541,21 +577,42 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo"); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSetVolatile String"); + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + assertEquals(x, "foo", "weakCompareAndSet String"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, "foo"); + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, "bar"); assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "bar", "getAndSet String value"); } + { + hs.get(TestAccessMode.SET).invokeExact(array, i, "foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, "bar"); + assertEquals(o, "foo", "getAndSetAcquire String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, "bar", "getAndSetAcquire String value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, "foo"); + + String o = (String) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, "bar"); + assertEquals(o, "foo", "getAndSetRelease String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, "bar", "getAndSetRelease String value"); + } + + } } @@ -569,6 +626,12 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { String o = (String) hs.get(am).invokeExact(array, i, "foo"); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + String o = (String) hs.get(am).invokeExact(array, i, "foo"); + }); + } } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -607,6 +670,7 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { }); } + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java index 624f98a8407..858913fc99e 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, true, true); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, true, true); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, true); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, true, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, true, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, true, true, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, true, true); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, true, true); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, true, true); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, true); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, true, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, true, true); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, true, true, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,333 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { boolean x = (boolean) vh.getAndSet(recv, true, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndSetAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndSetAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndSetAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetAcquire(recv, true, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndSetRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndSetRelease(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndSetRelease(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetRelease(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetRelease(recv, true, Void.class); + }); + + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseOr(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(recv, true, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseOrAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, true, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseOrRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(recv, true, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseAnd(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(recv, true, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseAndAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, true, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseAndRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(recv, true, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseXor(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(recv, true, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseXorAcquire(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorAcquire(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, true, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean x = (boolean) vh.getAndBitwiseXorRelease(null, true); + }); + checkCCE(() -> { // receiver reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(recv, true, Void.class); + }); } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeBoolean recv, Handles hs) throws Throwable { @@ -759,6 +1086,43 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact((VarHandleTestMethodTypeBoolean) null, true); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)). + invokeExact(Void.class, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, boolean.class)). + invokeExact(0, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact(recv, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact(recv, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact(recv, true, Void.class); + }); + } } @@ -891,6 +1255,23 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, true); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(true, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(true, true, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, true); }); @@ -906,23 +1287,6 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, true); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(true, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(true, true, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1049,6 +1413,236 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { boolean x = (boolean) vh.getAndSet(true, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetAcquire(true, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetRelease(true, Void.class); + }); + + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(true, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrAcquire(true, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrRelease(true, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(true, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndAcquire(true, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndRelease(true, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(true, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorAcquire(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorAcquire(true, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorRelease(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorRelease(true, Void.class); + }); } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1163,6 +1757,32 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, boolean.class)). + invokeExact(true); + }); + checkWMTE(() -> { // primitive class + int x = (int) hs.get(am, methodType(int.class, boolean.class)). + invokeExact(true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)). + invokeExact(true, Void.class); + }); + } } @@ -1425,6 +2045,35 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, true, true); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, true, true); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, true); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, true, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, true, true); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, true, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, true, true, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, true, true); }); @@ -1452,35 +2101,6 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, true, true); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, true, true); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, true); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, true, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, true, true); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, true, true); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, true, true, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1679,6 +2299,368 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { boolean x = (boolean) vh.getAndSet(array, 0, true, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndSetAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndSetAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + boolean x = (boolean) vh.getAndSetAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndSetAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetAcquire(array, 0, true, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndSetRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndSetRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + boolean x = (boolean) vh.getAndSetRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndSetRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndSetRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndSetRelease(array, 0, true, Void.class); + }); + + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseOr(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseOr(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseOr(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOr(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, true, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseOrAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, true, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseOrRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseOrRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, true, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseAnd(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseAnd(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseAnd(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAnd(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, true, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseAndAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, true, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseAndRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseAndRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, true, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseXor(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseXor(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseXor(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXor(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, true, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseXorAcquire(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorAcquire(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, true, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) vh.getAndBitwiseXorRelease(null, 0, true); + }); + checkCCE(() -> { // array reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) vh.getAndBitwiseXorRelease(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, true, Void.class); + }); } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -1880,6 +2862,48 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class)). + invokeExact((boolean[]) null, 0, true); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class)). + invokeExact(Void.class, 0, true); + }); + checkWMTE(() -> { // value reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class)). + invokeExact(0, 0, true); + }); + checkWMTE(() -> { // index reference class + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class)). + invokeExact(array, Void.class, true); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class, boolean.class)). + invokeExact(array, 0, true); + }); + checkWMTE(() -> { // primitive class + int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class, boolean.class)). + invokeExact(array, 0, true); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)). + invokeExact(array, 0, true, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index 692d667ac05..0f9097acd33 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, (byte)0x01, (byte)0x01); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, (byte)0x01, (byte)0x01); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (byte)0x01, (byte)0x01); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, (byte)0x01); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, (byte)0x01, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, (byte)0x01, (byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, (byte)0x01, (byte)0x01, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndSet(recv, (byte)0x01, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndSetAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndSetAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndSetAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetAcquire(recv, (byte)0x01, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndSetRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndSetRelease(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndSetRelease(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetRelease(recv, (byte)0x01, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,34 +669,331 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndAdd(recv, (byte)0x01, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - byte x = (byte) vh.addAndGet(null, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(null, (byte)0x01); }); checkCCE(() -> { // receiver reference class - byte x = (byte) vh.addAndGet(Void.class, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(Void.class, (byte)0x01); }); checkWMTE(() -> { // value reference class - byte x = (byte) vh.addAndGet(recv, Void.class); + byte x = (byte) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - byte x = (byte) vh.addAndGet(0, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(0, (byte)0x01); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, (byte)0x01); + Void r = (Void) vh.getAndAddAcquire(recv, (byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, (byte)0x01); + boolean x = (boolean) vh.getAndAddAcquire(recv, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.addAndGet(); + byte x = (byte) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - byte x = (byte) vh.addAndGet(recv, (byte)0x01, Void.class); + byte x = (byte) vh.getAndAddAcquire(recv, (byte)0x01, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndAddRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndAddRelease(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndAddRelease(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddRelease(recv, (byte)0x01, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseOr(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseOr(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseOrAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseOrAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrAcquire(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseOrRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseOr(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseAnd(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseAnd(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseAndAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseAndAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndAcquire(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseAndRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseAnd(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseXor(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseXor(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseXorAcquire(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseXorAcquire(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorAcquire(recv, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndBitwiseXorRelease(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndBitwiseXor(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor(recv, (byte)0x01, Void.class); }); } @@ -853,6 +1208,43 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { invokeExact(recv, (byte)0x01, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)). + invokeExact(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, byte.class)). + invokeExact(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact(recv, (byte)0x01, Void.class); + }); + } } @@ -985,6 +1377,23 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain((byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, (byte)0x01); }); @@ -1000,23 +1409,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (byte)0x01); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile((byte)0x01, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile((byte)0x01, (byte)0x01, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1535,48 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndSet((byte)0x01, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetAcquire((byte)0x01, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetRelease((byte)0x01, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,24 +1598,233 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - byte x = (byte) vh.addAndGet(Void.class); + byte x = (byte) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet((byte)0x01); + Void r = (Void) vh.getAndAddAcquire((byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet((byte)0x01); + boolean x = (boolean) vh.getAndAddAcquire((byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.addAndGet(); + byte x = (byte) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - byte x = (byte) vh.addAndGet((byte)0x01, Void.class); + byte x = (byte) vh.getAndAddAcquire((byte)0x01, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddRelease((byte)0x01, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr((byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrAcquire((byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrRelease((byte)0x01, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd((byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndAcquire((byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndRelease((byte)0x01, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor((byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorAcquire((byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorRelease((byte)0x01, Void.class); }); } @@ -1322,6 +1965,32 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { invokeExact((byte)0x01, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte.class)). + invokeExact((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class)). + invokeExact((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)). + invokeExact((byte)0x01, Void.class); + }); + } } @@ -1584,6 +2253,35 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, (byte)0x01, (byte)0x01); }); @@ -1611,35 +2309,6 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, (byte)0x01, (byte)0x01); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, (byte)0x01, (byte)0x01); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, (byte)0x01); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, (byte)0x01, (byte)0x01); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, (byte)0x01, (byte)0x01); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, (byte)0x01, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +2507,72 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { byte x = (byte) vh.getAndSet(array, 0, (byte)0x01, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndSetAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndSetAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + byte x = (byte) vh.getAndSetAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndSetAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndSetRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndSetRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + byte x = (byte) vh.getAndSetRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndSetRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSetRelease(array, 0, (byte)0x01, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,36 +2606,365 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - byte x = (byte) vh.addAndGet(null, 0, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(null, 0, (byte)0x01); }); checkCCE(() -> { // array reference class - byte x = (byte) vh.addAndGet(Void.class, 0, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(Void.class, 0, (byte)0x01); }); checkWMTE(() -> { // value reference class - byte x = (byte) vh.addAndGet(array, 0, Void.class); + byte x = (byte) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - byte x = (byte) vh.addAndGet(0, 0, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(0, 0, (byte)0x01); }); checkWMTE(() -> { // index reference class - byte x = (byte) vh.addAndGet(array, Void.class, (byte)0x01); + byte x = (byte) vh.getAndAddAcquire(array, Void.class, (byte)0x01); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, (byte)0x01); + Void r = (Void) vh.getAndAddAcquire(array, 0, (byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, (byte)0x01); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.addAndGet(); + byte x = (byte) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - byte x = (byte) vh.addAndGet(array, 0, (byte)0x01, Void.class); + byte x = (byte) vh.getAndAddAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndAddRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndAddRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndAddRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndAddRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAddRelease(array, 0, (byte)0x01, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseOr(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseOr(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseOr(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseOr(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOr(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseOrAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseOrAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseOrAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseOrRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseOrRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseOrRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseOrRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseOrRelease(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseAnd(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseAnd(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseAnd(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseAnd(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAnd(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseAndAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseAndAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseAndAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseAndRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseAndRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseAndRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseAndRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseAndRelease(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseXor(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseXor(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseXor(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseXor(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXor(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseXorAcquire(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseXorAcquire(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseXorAcquire(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorAcquire(array, 0, (byte)0x01, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAndBitwiseXorRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAndBitwiseXorRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAndBitwiseXorRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAndBitwiseXorRelease(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndBitwiseXorRelease(array, 0, (byte)0x01, Void.class); }); } @@ -2144,6 +3208,48 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { invokeExact(array, 0, (byte)0x01, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class)). + invokeExact((byte[]) null, 0, (byte)0x01); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class)). + invokeExact(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class)). + invokeExact(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class)). + invokeExact(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class, byte.class)). + invokeExact(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class)). + invokeExact(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)). + invokeExact(array, 0, (byte)0x01, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index 268e521f294..46ffc0f8cc7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, '\u0123', '\u0123'); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, '\u0123', '\u0123'); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, '\u0123'); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, '\u0123', Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, '\u0123', '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, '\u0123', '\u0123', Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, '\u0123', '\u0123'); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, '\u0123', '\u0123'); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, '\u0123', '\u0123'); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, '\u0123'); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, '\u0123', Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, '\u0123', '\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, '\u0123', '\u0123', Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndSet(recv, '\u0123', Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndSetAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndSetAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndSetAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetAcquire(recv, '\u0123', Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndSetRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndSetRelease(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndSetRelease(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetRelease(recv, '\u0123', Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,34 +669,331 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndAdd(recv, '\u0123', Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - char x = (char) vh.addAndGet(null, '\u0123'); + char x = (char) vh.getAndAddAcquire(null, '\u0123'); }); checkCCE(() -> { // receiver reference class - char x = (char) vh.addAndGet(Void.class, '\u0123'); + char x = (char) vh.getAndAddAcquire(Void.class, '\u0123'); }); checkWMTE(() -> { // value reference class - char x = (char) vh.addAndGet(recv, Void.class); + char x = (char) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - char x = (char) vh.addAndGet(0, '\u0123'); + char x = (char) vh.getAndAddAcquire(0, '\u0123'); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, '\u0123'); + Void r = (Void) vh.getAndAddAcquire(recv, '\u0123'); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, '\u0123'); + boolean x = (boolean) vh.getAndAddAcquire(recv, '\u0123'); }); // Incorrect arity checkWMTE(() -> { // 0 - char x = (char) vh.addAndGet(); + char x = (char) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - char x = (char) vh.addAndGet(recv, '\u0123', Void.class); + char x = (char) vh.getAndAddAcquire(recv, '\u0123', Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndAddRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndAddRelease(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndAddRelease(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddRelease(recv, '\u0123', Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseOr(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseOr(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseOr(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseOrAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseOrAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseOrAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrAcquire(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseOrRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseOr(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseOr(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseAnd(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseAnd(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseAnd(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseAndAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseAndAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseAndAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndAcquire(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseAndRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseAnd(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseAnd(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseXor(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseXor(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseXor(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseXorAcquire(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseXorAcquire(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseXorAcquire(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorAcquire(recv, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + char x = (char) vh.getAndBitwiseXorRelease(null, '\u0123'); + }); + checkCCE(() -> { // receiver reference class + char x = (char) vh.getAndBitwiseXor(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) vh.getAndBitwiseXor(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor(recv, '\u0123', Void.class); }); } @@ -853,6 +1208,43 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { invokeExact(recv, '\u0123', Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact((VarHandleTestMethodTypeChar) null, '\u0123'); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + char x = (char) hs.get(am, methodType(char.class, Class.class, char.class)). + invokeExact(Void.class, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + char x = (char) hs.get(am, methodType(char.class, int.class, char.class)). + invokeExact(0, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact(recv, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact(recv, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) hs.get(am, methodType(char.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact(recv, '\u0123', Void.class); + }); + } } @@ -985,6 +1377,23 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, '\u0123'); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain('\u0123', Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain('\u0123', '\u0123', Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, '\u0123'); }); @@ -1000,23 +1409,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, '\u0123'); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile('\u0123', Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile('\u0123', '\u0123', Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1535,48 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndSet('\u0123', Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetAcquire('\u0123', Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetRelease('\u0123', Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,24 +1598,233 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - char x = (char) vh.addAndGet(Void.class); + char x = (char) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet('\u0123'); + Void r = (Void) vh.getAndAddAcquire('\u0123'); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet('\u0123'); + boolean x = (boolean) vh.getAndAddAcquire('\u0123'); }); // Incorrect arity checkWMTE(() -> { // 0 - char x = (char) vh.addAndGet(); + char x = (char) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - char x = (char) vh.addAndGet('\u0123', Void.class); + char x = (char) vh.getAndAddAcquire('\u0123', Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddRelease('\u0123', Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr('\u0123', Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrAcquire('\u0123', Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrRelease('\u0123', Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd('\u0123', Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndAcquire('\u0123', Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndRelease('\u0123', Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor('\u0123', Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorAcquire('\u0123', Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorRelease('\u0123', Void.class); }); } @@ -1322,6 +1965,32 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { invokeExact('\u0123', Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + char x = (char) hs.get(am, methodType(char.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, char.class)). + invokeExact('\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, char.class)). + invokeExact('\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) hs.get(am, methodType(char.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + char x = (char) hs.get(am, methodType(char.class, char.class, Class.class)). + invokeExact('\u0123', Void.class); + }); + } } @@ -1584,6 +2253,35 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, '\u0123', '\u0123'); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, '\u0123', '\u0123'); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, '\u0123'); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, '\u0123', Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, '\u0123', '\u0123'); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, '\u0123', '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, '\u0123', '\u0123', Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, '\u0123', '\u0123'); }); @@ -1611,35 +2309,6 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, '\u0123', '\u0123'); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, '\u0123', '\u0123'); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, '\u0123'); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, '\u0123', Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, '\u0123', '\u0123'); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, '\u0123', '\u0123'); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, '\u0123', '\u0123', Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +2507,72 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { char x = (char) vh.getAndSet(array, 0, '\u0123', Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndSetAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndSetAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + char x = (char) vh.getAndSetAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndSetAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndSetRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndSetRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + char x = (char) vh.getAndSetRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndSetRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndSetRelease(array, 0, '\u0123', Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,36 +2606,365 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - char x = (char) vh.addAndGet(null, 0, '\u0123'); + char x = (char) vh.getAndAddAcquire(null, 0, '\u0123'); }); checkCCE(() -> { // array reference class - char x = (char) vh.addAndGet(Void.class, 0, '\u0123'); + char x = (char) vh.getAndAddAcquire(Void.class, 0, '\u0123'); }); checkWMTE(() -> { // value reference class - char x = (char) vh.addAndGet(array, 0, Void.class); + char x = (char) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - char x = (char) vh.addAndGet(0, 0, '\u0123'); + char x = (char) vh.getAndAddAcquire(0, 0, '\u0123'); }); checkWMTE(() -> { // index reference class - char x = (char) vh.addAndGet(array, Void.class, '\u0123'); + char x = (char) vh.getAndAddAcquire(array, Void.class, '\u0123'); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, '\u0123'); + Void r = (Void) vh.getAndAddAcquire(array, 0, '\u0123'); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, '\u0123'); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, '\u0123'); }); // Incorrect arity checkWMTE(() -> { // 0 - char x = (char) vh.addAndGet(); + char x = (char) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - char x = (char) vh.addAndGet(array, 0, '\u0123', Void.class); + char x = (char) vh.getAndAddAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndAddRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndAddRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndAddRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndAddRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndAddRelease(array, 0, '\u0123', Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseOr(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseOr(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseOr(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseOr(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOr(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseOrAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseOrAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseOrAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseOrAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseOrRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseOrRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseOrRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseOrRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseOrRelease(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseAnd(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseAnd(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseAnd(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseAnd(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAnd(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseAndAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseAndAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseAndAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseAndAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseAndRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseAndRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseAndRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseAndRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseAndRelease(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseXor(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseXor(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseXor(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseXor(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXor(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseXorAcquire(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseXorAcquire(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseXorAcquire(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseXorAcquire(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorAcquire(array, 0, '\u0123', Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) vh.getAndBitwiseXorRelease(null, 0, '\u0123'); + }); + checkCCE(() -> { // array reference class + char x = (char) vh.getAndBitwiseXorRelease(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) vh.getAndBitwiseXorRelease(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) vh.getAndBitwiseXorRelease(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + char x = (char) vh.getAndBitwiseXorRelease(array, 0, '\u0123', Void.class); }); } @@ -2144,6 +3208,48 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { invokeExact(array, 0, '\u0123', Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class)). + invokeExact((char[]) null, 0, '\u0123'); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + char x = (char) hs.get(am, methodType(char.class, Class.class, int.class, char.class)). + invokeExact(Void.class, 0, '\u0123'); + }); + checkWMTE(() -> { // value reference class + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + char x = (char) hs.get(am, methodType(char.class, int.class, int.class, char.class)). + invokeExact(0, 0, '\u0123'); + }); + checkWMTE(() -> { // index reference class + char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class, char.class)). + invokeExact(array, Void.class, '\u0123'); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, char[].class, int.class, char.class)). + invokeExact(array, 0, '\u0123'); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class)). + invokeExact(array, 0, '\u0123'); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + char x = (char) hs.get(am, methodType(char.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, Class.class)). + invokeExact(array, 0, '\u0123', Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index e3bf8363a15..af37433385c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 1.0d, 1.0d); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0d, 1.0d); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 1.0d); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 1.0d, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 1.0d, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 1.0d, 1.0d, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 1.0d, 1.0d); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 1.0d, 1.0d); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0d, 1.0d); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 1.0d); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0d, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 1.0d, 1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0d, 1.0d, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndSet(recv, 1.0d, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndSetAcquire(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndSetAcquire(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndSetAcquire(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetAcquire(recv, 1.0d, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndSetRelease(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndSetRelease(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndSetRelease(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetRelease(recv, 1.0d, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,35 +669,64 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndAdd(recv, 1.0d, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - double x = (double) vh.addAndGet(null, 1.0d); + double x = (double) vh.getAndAddAcquire(null, 1.0d); }); checkCCE(() -> { // receiver reference class - double x = (double) vh.addAndGet(Void.class, 1.0d); + double x = (double) vh.getAndAddAcquire(Void.class, 1.0d); }); checkWMTE(() -> { // value reference class - double x = (double) vh.addAndGet(recv, Void.class); + double x = (double) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - double x = (double) vh.addAndGet(0, 1.0d); + double x = (double) vh.getAndAddAcquire(0, 1.0d); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 1.0d); + Void r = (Void) vh.getAndAddAcquire(recv, 1.0d); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 1.0d); + boolean x = (boolean) vh.getAndAddAcquire(recv, 1.0d); }); // Incorrect arity checkWMTE(() -> { // 0 - double x = (double) vh.addAndGet(); + double x = (double) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - double x = (double) vh.addAndGet(recv, 1.0d, Void.class); + double x = (double) vh.getAndAddAcquire(recv, 1.0d, Void.class); }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + double x = (double) vh.getAndAddRelease(null, 1.0d); + }); + checkCCE(() -> { // receiver reference class + double x = (double) vh.getAndAddRelease(Void.class, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + double x = (double) vh.getAndAddRelease(0, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddRelease(recv, 1.0d, Void.class); + }); + } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeDouble recv, Handles hs) throws Throwable { @@ -853,6 +940,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { invokeExact(recv, 1.0d, Void.class); }); } + } @@ -985,6 +1073,23 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0d); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(1.0d, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(1.0d, 1.0d, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 1.0d); }); @@ -1000,23 +1105,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0d); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(1.0d, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(1.0d, 1.0d, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1231,48 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndSet(1.0d, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetAcquire(1.0d, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetRelease(1.0d, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,25 +1294,47 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - double x = (double) vh.addAndGet(Void.class); + double x = (double) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(1.0d); + Void r = (Void) vh.getAndAddAcquire(1.0d); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(1.0d); + boolean x = (boolean) vh.getAndAddAcquire(1.0d); }); // Incorrect arity checkWMTE(() -> { // 0 - double x = (double) vh.addAndGet(); + double x = (double) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - double x = (double) vh.addAndGet(1.0d, Void.class); + double x = (double) vh.getAndAddAcquire(1.0d, Void.class); }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddRelease(1.0d, Void.class); + }); + } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +1474,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { invokeExact(1.0d, Void.class); }); } + } @@ -1584,6 +1737,35 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 1.0d, 1.0d); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 1.0d, 1.0d); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 1.0d); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0d, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 1.0d, 1.0d); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 1.0d, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0d, 1.0d, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 1.0d, 1.0d); }); @@ -1611,35 +1793,6 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 1.0d, 1.0d); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 1.0d, 1.0d); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 1.0d); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0d, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 1.0d, 1.0d); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 1.0d, 1.0d); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0d, 1.0d, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +1991,72 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { double x = (double) vh.getAndSet(array, 0, 1.0d, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndSetAcquire(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndSetAcquire(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + double x = (double) vh.getAndSetAcquire(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndSetAcquire(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetAcquire(array, 0, 1.0d, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndSetRelease(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndSetRelease(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + double x = (double) vh.getAndSetRelease(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndSetRelease(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndSetRelease(array, 0, 1.0d, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,37 +2090,71 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - double x = (double) vh.addAndGet(null, 0, 1.0d); + double x = (double) vh.getAndAddAcquire(null, 0, 1.0d); }); checkCCE(() -> { // array reference class - double x = (double) vh.addAndGet(Void.class, 0, 1.0d); + double x = (double) vh.getAndAddAcquire(Void.class, 0, 1.0d); }); checkWMTE(() -> { // value reference class - double x = (double) vh.addAndGet(array, 0, Void.class); + double x = (double) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - double x = (double) vh.addAndGet(0, 0, 1.0d); + double x = (double) vh.getAndAddAcquire(0, 0, 1.0d); }); checkWMTE(() -> { // index reference class - double x = (double) vh.addAndGet(array, Void.class, 1.0d); + double x = (double) vh.getAndAddAcquire(array, Void.class, 1.0d); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 1.0d); + Void r = (Void) vh.getAndAddAcquire(array, 0, 1.0d); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 1.0d); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 1.0d); }); // Incorrect arity checkWMTE(() -> { // 0 - double x = (double) vh.addAndGet(); + double x = (double) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - double x = (double) vh.addAndGet(array, 0, 1.0d, Void.class); + double x = (double) vh.getAndAddAcquire(array, 0, 1.0d, Void.class); }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + double x = (double) vh.getAndAddRelease(null, 0, 1.0d); + }); + checkCCE(() -> { // array reference class + double x = (double) vh.getAndAddRelease(Void.class, 0, 1.0d); + }); + checkWMTE(() -> { // value reference class + double x = (double) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + double x = (double) vh.getAndAddRelease(0, 0, 1.0d); + }); + checkWMTE(() -> { // index reference class + double x = (double) vh.getAndAddRelease(array, Void.class, 1.0d); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 1.0d); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 1.0d); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + double x = (double) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + double x = (double) vh.getAndAddRelease(array, 0, 1.0d, Void.class); + }); + } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +2397,7 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { invokeExact(array, 0, 1.0d, Void.class); }); } + } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index 34617e2102e..b5d6711a3cb 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 1.0f, 1.0f); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0f, 1.0f); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 1.0f); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 1.0f, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 1.0f, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 1.0f, 1.0f, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 1.0f, 1.0f); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 1.0f, 1.0f); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0f, 1.0f); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 1.0f); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0f, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 1.0f, 1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 1.0f, 1.0f, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndSet(recv, 1.0f, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndSetAcquire(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndSetAcquire(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndSetAcquire(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetAcquire(recv, 1.0f, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndSetRelease(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndSetRelease(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndSetRelease(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetRelease(recv, 1.0f, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,35 +669,64 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndAdd(recv, 1.0f, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - float x = (float) vh.addAndGet(null, 1.0f); + float x = (float) vh.getAndAddAcquire(null, 1.0f); }); checkCCE(() -> { // receiver reference class - float x = (float) vh.addAndGet(Void.class, 1.0f); + float x = (float) vh.getAndAddAcquire(Void.class, 1.0f); }); checkWMTE(() -> { // value reference class - float x = (float) vh.addAndGet(recv, Void.class); + float x = (float) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - float x = (float) vh.addAndGet(0, 1.0f); + float x = (float) vh.getAndAddAcquire(0, 1.0f); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 1.0f); + Void r = (Void) vh.getAndAddAcquire(recv, 1.0f); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 1.0f); + boolean x = (boolean) vh.getAndAddAcquire(recv, 1.0f); }); // Incorrect arity checkWMTE(() -> { // 0 - float x = (float) vh.addAndGet(); + float x = (float) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - float x = (float) vh.addAndGet(recv, 1.0f, Void.class); + float x = (float) vh.getAndAddAcquire(recv, 1.0f, Void.class); }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + float x = (float) vh.getAndAddRelease(null, 1.0f); + }); + checkCCE(() -> { // receiver reference class + float x = (float) vh.getAndAddRelease(Void.class, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + float x = (float) vh.getAndAddRelease(0, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddRelease(recv, 1.0f, Void.class); + }); + } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeFloat recv, Handles hs) throws Throwable { @@ -853,6 +940,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { invokeExact(recv, 1.0f, Void.class); }); } + } @@ -985,6 +1073,23 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 1.0f); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(1.0f, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(1.0f, 1.0f, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 1.0f); }); @@ -1000,23 +1105,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 1.0f); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(1.0f, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(1.0f, 1.0f, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1231,48 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndSet(1.0f, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetAcquire(1.0f, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetRelease(1.0f, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,25 +1294,47 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - float x = (float) vh.addAndGet(Void.class); + float x = (float) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(1.0f); + Void r = (Void) vh.getAndAddAcquire(1.0f); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(1.0f); + boolean x = (boolean) vh.getAndAddAcquire(1.0f); }); // Incorrect arity checkWMTE(() -> { // 0 - float x = (float) vh.addAndGet(); + float x = (float) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - float x = (float) vh.addAndGet(1.0f, Void.class); + float x = (float) vh.getAndAddAcquire(1.0f, Void.class); }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddRelease(1.0f, Void.class); + }); + } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1322,6 +1474,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { invokeExact(1.0f, Void.class); }); } + } @@ -1584,6 +1737,35 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 1.0f, 1.0f); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 1.0f, 1.0f); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 1.0f); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0f, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 1.0f, 1.0f); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 1.0f, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 1.0f, 1.0f, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 1.0f, 1.0f); }); @@ -1611,35 +1793,6 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 1.0f, 1.0f); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 1.0f, 1.0f); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 1.0f); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0f, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 1.0f, 1.0f); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 1.0f, 1.0f); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 1.0f, 1.0f, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +1991,72 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { float x = (float) vh.getAndSet(array, 0, 1.0f, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndSetAcquire(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndSetAcquire(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + float x = (float) vh.getAndSetAcquire(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndSetAcquire(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetAcquire(array, 0, 1.0f, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndSetRelease(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndSetRelease(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + float x = (float) vh.getAndSetRelease(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndSetRelease(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndSetRelease(array, 0, 1.0f, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,37 +2090,71 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - float x = (float) vh.addAndGet(null, 0, 1.0f); + float x = (float) vh.getAndAddAcquire(null, 0, 1.0f); }); checkCCE(() -> { // array reference class - float x = (float) vh.addAndGet(Void.class, 0, 1.0f); + float x = (float) vh.getAndAddAcquire(Void.class, 0, 1.0f); }); checkWMTE(() -> { // value reference class - float x = (float) vh.addAndGet(array, 0, Void.class); + float x = (float) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - float x = (float) vh.addAndGet(0, 0, 1.0f); + float x = (float) vh.getAndAddAcquire(0, 0, 1.0f); }); checkWMTE(() -> { // index reference class - float x = (float) vh.addAndGet(array, Void.class, 1.0f); + float x = (float) vh.getAndAddAcquire(array, Void.class, 1.0f); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 1.0f); + Void r = (Void) vh.getAndAddAcquire(array, 0, 1.0f); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 1.0f); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 1.0f); }); // Incorrect arity checkWMTE(() -> { // 0 - float x = (float) vh.addAndGet(); + float x = (float) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - float x = (float) vh.addAndGet(array, 0, 1.0f, Void.class); + float x = (float) vh.getAndAddAcquire(array, 0, 1.0f, Void.class); }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + float x = (float) vh.getAndAddRelease(null, 0, 1.0f); + }); + checkCCE(() -> { // array reference class + float x = (float) vh.getAndAddRelease(Void.class, 0, 1.0f); + }); + checkWMTE(() -> { // value reference class + float x = (float) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + float x = (float) vh.getAndAddRelease(0, 0, 1.0f); + }); + checkWMTE(() -> { // index reference class + float x = (float) vh.getAndAddRelease(array, Void.class, 1.0f); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 1.0f); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 1.0f); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + float x = (float) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + float x = (float) vh.getAndAddRelease(array, 0, 1.0f, Void.class); + }); + } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2144,6 +2397,7 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { invokeExact(array, 0, 1.0f, Void.class); }); } + } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index 33b33970f80..9f0b995663c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0x01234567, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x01234567, 0x01234567); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 0x01234567); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 0x01234567, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0x01234567, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 0x01234567, 0x01234567, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0x01234567, 0x01234567); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0x01234567, 0x01234567); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x01234567, 0x01234567); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 0x01234567); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 0x01234567, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0x01234567, 0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 0x01234567, 0x01234567, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndSet(recv, 0x01234567, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndSetAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndSetAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndSetAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetAcquire(recv, 0x01234567, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndSetRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndSetRelease(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndSetRelease(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetRelease(recv, 0x01234567, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,34 +669,331 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndAdd(recv, 0x01234567, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - int x = (int) vh.addAndGet(null, 0x01234567); + int x = (int) vh.getAndAddAcquire(null, 0x01234567); }); checkCCE(() -> { // receiver reference class - int x = (int) vh.addAndGet(Void.class, 0x01234567); + int x = (int) vh.getAndAddAcquire(Void.class, 0x01234567); }); checkWMTE(() -> { // value reference class - int x = (int) vh.addAndGet(recv, Void.class); + int x = (int) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - int x = (int) vh.addAndGet(0, 0x01234567); + int x = (int) vh.getAndAddAcquire(0, 0x01234567); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 0x01234567); + Void r = (Void) vh.getAndAddAcquire(recv, 0x01234567); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 0x01234567); + boolean x = (boolean) vh.getAndAddAcquire(recv, 0x01234567); }); // Incorrect arity checkWMTE(() -> { // 0 - int x = (int) vh.addAndGet(); + int x = (int) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - int x = (int) vh.addAndGet(recv, 0x01234567, Void.class); + int x = (int) vh.getAndAddAcquire(recv, 0x01234567, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndAddRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndAddRelease(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndAddRelease(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddRelease(recv, 0x01234567, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseOr(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseOr(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseOr(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseOrAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseOrAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseOrAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrAcquire(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseOrRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseOr(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseOr(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseAnd(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseAnd(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseAnd(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseAndAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseAndAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseAndAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndAcquire(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseAndRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseAnd(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseAnd(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseXor(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseXor(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseXor(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseXorAcquire(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseXorAcquire(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseXorAcquire(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorAcquire(recv, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + int x = (int) vh.getAndBitwiseXorRelease(null, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + int x = (int) vh.getAndBitwiseXor(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) vh.getAndBitwiseXor(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(recv, 0x01234567, Void.class); }); } @@ -853,6 +1208,43 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { invokeExact(recv, 0x01234567, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). + invokeExact(Void.class, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). + invokeExact(0, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact(recv, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact(recv, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) hs.get(am, methodType(int.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact(recv, 0x01234567, Void.class); + }); + } } @@ -985,6 +1377,23 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x01234567); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(0x01234567, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(0x01234567, 0x01234567, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 0x01234567); }); @@ -1000,23 +1409,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x01234567); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(0x01234567, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(0x01234567, 0x01234567, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1535,48 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndSet(0x01234567, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetAcquire(0x01234567, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetRelease(0x01234567, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,24 +1598,233 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - int x = (int) vh.addAndGet(Void.class); + int x = (int) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(0x01234567); + Void r = (Void) vh.getAndAddAcquire(0x01234567); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(0x01234567); + boolean x = (boolean) vh.getAndAddAcquire(0x01234567); }); // Incorrect arity checkWMTE(() -> { // 0 - int x = (int) vh.addAndGet(); + int x = (int) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - int x = (int) vh.addAndGet(0x01234567, Void.class); + int x = (int) vh.getAndAddAcquire(0x01234567, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddRelease(0x01234567, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(0x01234567, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrAcquire(0x01234567, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrRelease(0x01234567, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(0x01234567, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndAcquire(0x01234567, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndRelease(0x01234567, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(0x01234567, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorAcquire(0x01234567, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorRelease(0x01234567, Void.class); }); } @@ -1322,6 +1965,32 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { invokeExact(0x01234567, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + int x = (int) hs.get(am, methodType(int.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, int.class)). + invokeExact(0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). + invokeExact(0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) hs.get(am, methodType(int.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). + invokeExact(0x01234567, Void.class); + }); + } } @@ -1584,6 +2253,35 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 0x01234567, 0x01234567); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 0x01234567, 0x01234567); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 0x01234567); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x01234567, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 0x01234567, 0x01234567); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 0x01234567, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x01234567, 0x01234567, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 0x01234567, 0x01234567); }); @@ -1611,35 +2309,6 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 0x01234567, 0x01234567); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 0x01234567, 0x01234567); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 0x01234567); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x01234567, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 0x01234567, 0x01234567); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 0x01234567, 0x01234567); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x01234567, 0x01234567, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +2507,72 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { int x = (int) vh.getAndSet(array, 0, 0x01234567, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndSetAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndSetAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + int x = (int) vh.getAndSetAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndSetAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndSetRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndSetRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + int x = (int) vh.getAndSetRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndSetRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndSetRelease(array, 0, 0x01234567, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,36 +2606,365 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - int x = (int) vh.addAndGet(null, 0, 0x01234567); + int x = (int) vh.getAndAddAcquire(null, 0, 0x01234567); }); checkCCE(() -> { // array reference class - int x = (int) vh.addAndGet(Void.class, 0, 0x01234567); + int x = (int) vh.getAndAddAcquire(Void.class, 0, 0x01234567); }); checkWMTE(() -> { // value reference class - int x = (int) vh.addAndGet(array, 0, Void.class); + int x = (int) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - int x = (int) vh.addAndGet(0, 0, 0x01234567); + int x = (int) vh.getAndAddAcquire(0, 0, 0x01234567); }); checkWMTE(() -> { // index reference class - int x = (int) vh.addAndGet(array, Void.class, 0x01234567); + int x = (int) vh.getAndAddAcquire(array, Void.class, 0x01234567); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 0x01234567); + Void r = (Void) vh.getAndAddAcquire(array, 0, 0x01234567); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 0x01234567); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 0x01234567); }); // Incorrect arity checkWMTE(() -> { // 0 - int x = (int) vh.addAndGet(); + int x = (int) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - int x = (int) vh.addAndGet(array, 0, 0x01234567, Void.class); + int x = (int) vh.getAndAddAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndAddRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndAddRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndAddRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndAddRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndAddRelease(array, 0, 0x01234567, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseOr(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseOr(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseOr(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseOr(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOr(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseOrAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseOrAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseOrAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseOrAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseOrRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseOrRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseOrRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseOrRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseOrRelease(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseAnd(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseAnd(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseAnd(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseAnd(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAnd(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseAndAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseAndAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseAndAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseAndAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseAndRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseAndRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseAndRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseAndRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseAndRelease(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseXor(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseXor(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseXor(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseXor(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXor(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseXorAcquire(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseXorAcquire(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseXorAcquire(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseXorAcquire(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorAcquire(array, 0, 0x01234567, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) vh.getAndBitwiseXorRelease(null, 0, 0x01234567); + }); + checkCCE(() -> { // array reference class + int x = (int) vh.getAndBitwiseXorRelease(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) vh.getAndBitwiseXorRelease(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) vh.getAndBitwiseXorRelease(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + int x = (int) vh.getAndBitwiseXorRelease(array, 0, 0x01234567, Void.class); }); } @@ -2144,6 +3208,48 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { invokeExact(array, 0, 0x01234567, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)). + invokeExact((int[]) null, 0, 0x01234567); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). + invokeExact(Void.class, 0, 0x01234567); + }); + checkWMTE(() -> { // value reference class + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)). + invokeExact(0, 0, 0x01234567); + }); + checkWMTE(() -> { // index reference class + int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)). + invokeExact(array, Void.class, 0x01234567); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)). + invokeExact(array, 0, 0x01234567); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)). + invokeExact(array, 0, 0x01234567); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + int x = (int) hs.get(am, methodType(int.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). + invokeExact(array, 0, 0x01234567, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index 654619335fe..576d5a197f2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, 0x0123456789ABCDEFL, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, 0x0123456789ABCDEFL, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndSet(recv, 0x0123456789ABCDEFL, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndSetAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndSetAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndSetAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndSetRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndSetRelease(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndSetRelease(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetRelease(recv, 0x0123456789ABCDEFL, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,34 +669,331 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndAdd(recv, 0x0123456789ABCDEFL, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - long x = (long) vh.addAndGet(null, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(null, 0x0123456789ABCDEFL); }); checkCCE(() -> { // receiver reference class - long x = (long) vh.addAndGet(Void.class, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(Void.class, 0x0123456789ABCDEFL); }); checkWMTE(() -> { // value reference class - long x = (long) vh.addAndGet(recv, Void.class); + long x = (long) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - long x = (long) vh.addAndGet(0, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(0, 0x0123456789ABCDEFL); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, 0x0123456789ABCDEFL); + Void r = (Void) vh.getAndAddAcquire(recv, 0x0123456789ABCDEFL); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, 0x0123456789ABCDEFL); + boolean x = (boolean) vh.getAndAddAcquire(recv, 0x0123456789ABCDEFL); }); // Incorrect arity checkWMTE(() -> { // 0 - long x = (long) vh.addAndGet(); + long x = (long) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - long x = (long) vh.addAndGet(recv, 0x0123456789ABCDEFL, Void.class); + long x = (long) vh.getAndAddAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndAddRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndAddRelease(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndAddRelease(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddRelease(recv, 0x0123456789ABCDEFL, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseOr(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseOr(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseOr(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseOrAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseOrAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseOrAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseOrRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseOr(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseOr(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseAnd(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseAnd(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseAnd(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseAndAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseAndAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseAndAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseAndRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseAnd(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseAnd(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseXor(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseXor(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseXor(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseXorAcquire(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseXorAcquire(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseXorAcquire(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorAcquire(recv, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + long x = (long) vh.getAndBitwiseXorRelease(null, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + long x = (long) vh.getAndBitwiseXor(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) vh.getAndBitwiseXor(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(recv, 0x0123456789ABCDEFL, Void.class); }); } @@ -853,6 +1208,43 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { invokeExact(recv, 0x0123456789ABCDEFL, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). + invokeExact(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + long x = (long) hs.get(am, methodType(long.class, int.class, long.class)). + invokeExact(0, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact(recv, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact(recv, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) hs.get(am, methodType(long.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact(recv, 0x0123456789ABCDEFL, Void.class); + }); + } } @@ -985,6 +1377,23 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(0x0123456789ABCDEFL, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, 0x0123456789ABCDEFL); }); @@ -1000,23 +1409,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(0x0123456789ABCDEFL, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1535,48 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndSet(0x0123456789ABCDEFL, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetRelease(0x0123456789ABCDEFL, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,24 +1598,233 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - long x = (long) vh.addAndGet(Void.class); + long x = (long) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(0x0123456789ABCDEFL); + Void r = (Void) vh.getAndAddAcquire(0x0123456789ABCDEFL); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(0x0123456789ABCDEFL); + boolean x = (boolean) vh.getAndAddAcquire(0x0123456789ABCDEFL); }); // Incorrect arity checkWMTE(() -> { // 0 - long x = (long) vh.addAndGet(); + long x = (long) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - long x = (long) vh.addAndGet(0x0123456789ABCDEFL, Void.class); + long x = (long) vh.getAndAddAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddRelease(0x0123456789ABCDEFL, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrRelease(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndRelease(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorAcquire(0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorRelease(0x0123456789ABCDEFL, Void.class); }); } @@ -1322,6 +1965,32 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { invokeExact(0x0123456789ABCDEFL, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + long x = (long) hs.get(am, methodType(long.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, long.class)). + invokeExact(0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)). + invokeExact(0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) hs.get(am, methodType(long.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). + invokeExact(0x0123456789ABCDEFL, Void.class); + }); + } } @@ -1584,6 +2253,35 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); }); @@ -1611,35 +2309,6 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x0123456789ABCDEFL, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +2507,72 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { long x = (long) vh.getAndSet(array, 0, 0x0123456789ABCDEFL, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndSetAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndSetAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + long x = (long) vh.getAndSetAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndSetAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndSetRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndSetRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + long x = (long) vh.getAndSetRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndSetRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndSetRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,36 +2606,365 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - long x = (long) vh.addAndGet(null, 0, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(null, 0, 0x0123456789ABCDEFL); }); checkCCE(() -> { // array reference class - long x = (long) vh.addAndGet(Void.class, 0, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(Void.class, 0, 0x0123456789ABCDEFL); }); checkWMTE(() -> { // value reference class - long x = (long) vh.addAndGet(array, 0, Void.class); + long x = (long) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - long x = (long) vh.addAndGet(0, 0, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(0, 0, 0x0123456789ABCDEFL); }); checkWMTE(() -> { // index reference class - long x = (long) vh.addAndGet(array, Void.class, 0x0123456789ABCDEFL); + long x = (long) vh.getAndAddAcquire(array, Void.class, 0x0123456789ABCDEFL); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, 0x0123456789ABCDEFL); + Void r = (Void) vh.getAndAddAcquire(array, 0, 0x0123456789ABCDEFL); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, 0x0123456789ABCDEFL); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, 0x0123456789ABCDEFL); }); // Incorrect arity checkWMTE(() -> { // 0 - long x = (long) vh.addAndGet(); + long x = (long) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - long x = (long) vh.addAndGet(array, 0, 0x0123456789ABCDEFL, Void.class); + long x = (long) vh.getAndAddAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndAddRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndAddRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndAddRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndAddRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndAddRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseOr(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseOr(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseOr(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseOr(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOr(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseOrAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseOrAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseOrAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseOrAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseOrRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseOrRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseOrRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseOrRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseOrRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseAnd(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseAnd(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseAnd(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseAnd(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAnd(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseAndAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseAndAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseAndAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseAndAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseAndRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseAndRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseAndRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseAndRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseAndRelease(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseXor(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseXor(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseXor(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseXor(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXor(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseXorAcquire(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseXorAcquire(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseXorAcquire(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseXorAcquire(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorAcquire(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) vh.getAndBitwiseXorRelease(null, 0, 0x0123456789ABCDEFL); + }); + checkCCE(() -> { // array reference class + long x = (long) vh.getAndBitwiseXorRelease(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) vh.getAndBitwiseXorRelease(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) vh.getAndBitwiseXorRelease(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + long x = (long) vh.getAndBitwiseXorRelease(array, 0, 0x0123456789ABCDEFL, Void.class); }); } @@ -2144,6 +3208,48 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)). + invokeExact((long[]) null, 0, 0x0123456789ABCDEFL); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)). + invokeExact(Void.class, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // value reference class + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)). + invokeExact(0, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // index reference class + long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)). + invokeExact(array, Void.class, 0x0123456789ABCDEFL); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)). + invokeExact(array, 0, 0x0123456789ABCDEFL); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)). + invokeExact(array, 0, 0x0123456789ABCDEFL); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + long x = (long) hs.get(am, methodType(long.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). + invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index 82b6f3cab78..b3f52611dcd 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, (short)0x0123, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (short)0x0123, (short)0x0123); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, (short)0x0123); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, (short)0x0123, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, (short)0x0123, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, (short)0x0123, (short)0x0123, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, (short)0x0123, (short)0x0123); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, (short)0x0123, (short)0x0123); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (short)0x0123, (short)0x0123); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, (short)0x0123); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, (short)0x0123, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, (short)0x0123, (short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, (short)0x0123, (short)0x0123, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndSet(recv, (short)0x0123, Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndSetAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndSetAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndSetAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetAcquire(recv, (short)0x0123, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndSetRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndSetRelease(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndSetRelease(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetRelease(recv, (short)0x0123, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null receiver @@ -611,34 +669,331 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndAdd(recv, (short)0x0123, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - short x = (short) vh.addAndGet(null, (short)0x0123); + short x = (short) vh.getAndAddAcquire(null, (short)0x0123); }); checkCCE(() -> { // receiver reference class - short x = (short) vh.addAndGet(Void.class, (short)0x0123); + short x = (short) vh.getAndAddAcquire(Void.class, (short)0x0123); }); checkWMTE(() -> { // value reference class - short x = (short) vh.addAndGet(recv, Void.class); + short x = (short) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - short x = (short) vh.addAndGet(0, (short)0x0123); + short x = (short) vh.getAndAddAcquire(0, (short)0x0123); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, (short)0x0123); + Void r = (Void) vh.getAndAddAcquire(recv, (short)0x0123); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(recv, (short)0x0123); + boolean x = (boolean) vh.getAndAddAcquire(recv, (short)0x0123); }); // Incorrect arity checkWMTE(() -> { // 0 - short x = (short) vh.addAndGet(); + short x = (short) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - short x = (short) vh.addAndGet(recv, (short)0x0123, Void.class); + short x = (short) vh.getAndAddAcquire(recv, (short)0x0123, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndAddRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndAddRelease(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndAddRelease(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddRelease(recv, (short)0x0123, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseOr(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseOr(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseOr(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseOrAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseOrAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseOrAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrAcquire(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseOrRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseOr(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseOr(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseAnd(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseAnd(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseAnd(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseAndAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseAndAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseAndAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndAcquire(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseAndRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseAnd(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseAnd(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseXor(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseXor(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseXor(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseXorAcquire(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseXorAcquire(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseXorAcquire(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorAcquire(recv, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + short x = (short) vh.getAndBitwiseXorRelease(null, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + short x = (short) vh.getAndBitwiseXor(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) vh.getAndBitwiseXor(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor(recv, (short)0x0123, Void.class); }); } @@ -853,6 +1208,43 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { invokeExact(recv, (short)0x0123, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + short x = (short) hs.get(am, methodType(short.class, Class.class, short.class)). + invokeExact(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + short x = (short) hs.get(am, methodType(short.class, int.class, short.class)). + invokeExact(0, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact(recv, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact(recv, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) hs.get(am, methodType(short.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact(recv, (short)0x0123, Void.class); + }); + } } @@ -985,6 +1377,23 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, (short)0x0123); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain((short)0x0123, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain((short)0x0123, (short)0x0123, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, (short)0x0123); }); @@ -1000,23 +1409,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, (short)0x0123); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile((short)0x0123, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile((short)0x0123, (short)0x0123, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkWMTE(() -> { // expected reference class @@ -1143,6 +1535,48 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndSet((short)0x0123, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetAcquire((short)0x0123, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetRelease((short)0x0123, Void.class); + }); + // GetAndAdd // Incorrect argument types checkWMTE(() -> { // value reference class @@ -1164,24 +1598,233 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkWMTE(() -> { // value reference class - short x = (short) vh.addAndGet(Void.class); + short x = (short) vh.getAndAddAcquire(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet((short)0x0123); + Void r = (Void) vh.getAndAddAcquire((short)0x0123); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet((short)0x0123); + boolean x = (boolean) vh.getAndAddAcquire((short)0x0123); }); // Incorrect arity checkWMTE(() -> { // 0 - short x = (short) vh.addAndGet(); + short x = (short) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - short x = (short) vh.addAndGet((short)0x0123, Void.class); + short x = (short) vh.getAndAddAcquire((short)0x0123, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddRelease((short)0x0123, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr((short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrAcquire((short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrRelease((short)0x0123, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd((short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndAcquire((short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndRelease((short)0x0123, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor((short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorAcquire((short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorRelease((short)0x0123, Void.class); }); } @@ -1322,6 +1965,32 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { invokeExact((short)0x0123, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkWMTE(() -> { // value reference class + short x = (short) hs.get(am, methodType(short.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, short.class)). + invokeExact((short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, short.class)). + invokeExact((short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) hs.get(am, methodType(short.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + short x = (short) hs.get(am, methodType(short.class, short.class, Class.class)). + invokeExact((short)0x0123, Void.class); + }); + } } @@ -1584,6 +2253,35 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, (short)0x0123, (short)0x0123); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, (short)0x0123, (short)0x0123); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, (short)0x0123); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, (short)0x0123, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, (short)0x0123, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, (short)0x0123, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, (short)0x0123, (short)0x0123, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, (short)0x0123, (short)0x0123); }); @@ -1611,35 +2309,6 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, (short)0x0123, (short)0x0123); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, (short)0x0123, (short)0x0123); - }); - checkWMTE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, (short)0x0123); - }); - checkWMTE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, (short)0x0123, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, (short)0x0123, (short)0x0123); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, (short)0x0123, (short)0x0123); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, (short)0x0123, (short)0x0123, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1838,6 +2507,72 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { short x = (short) vh.getAndSet(array, 0, (short)0x0123, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndSetAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndSetAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + short x = (short) vh.getAndSetAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndSetAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndSetRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndSetRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + short x = (short) vh.getAndSetRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndSetRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndSetRelease(array, 0, (short)0x0123, Void.class); + }); + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array @@ -1871,36 +2606,365 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - short x = (short) vh.addAndGet(null, 0, (short)0x0123); + short x = (short) vh.getAndAddAcquire(null, 0, (short)0x0123); }); checkCCE(() -> { // array reference class - short x = (short) vh.addAndGet(Void.class, 0, (short)0x0123); + short x = (short) vh.getAndAddAcquire(Void.class, 0, (short)0x0123); }); checkWMTE(() -> { // value reference class - short x = (short) vh.addAndGet(array, 0, Void.class); + short x = (short) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - short x = (short) vh.addAndGet(0, 0, (short)0x0123); + short x = (short) vh.getAndAddAcquire(0, 0, (short)0x0123); }); checkWMTE(() -> { // index reference class - short x = (short) vh.addAndGet(array, Void.class, (short)0x0123); + short x = (short) vh.getAndAddAcquire(array, Void.class, (short)0x0123); }); // Incorrect return type checkWMTE(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, (short)0x0123); + Void r = (Void) vh.getAndAddAcquire(array, 0, (short)0x0123); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.addAndGet(array, 0, (short)0x0123); + boolean x = (boolean) vh.getAndAddAcquire(array, 0, (short)0x0123); }); // Incorrect arity checkWMTE(() -> { // 0 - short x = (short) vh.addAndGet(); + short x = (short) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - short x = (short) vh.addAndGet(array, 0, (short)0x0123, Void.class); + short x = (short) vh.getAndAddAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndAddRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndAddRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndAddRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndAddRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAddRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndAddRelease(array, 0, (short)0x0123, Void.class); + }); + + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseOr(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseOr(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseOr(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseOr(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOr(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOr(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseOrAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseOrAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseOrAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseOrAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseOrRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseOrRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseOrRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseOrRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseOrRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseOrRelease(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseAnd(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseAnd(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseAnd(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseAnd(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAnd(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAnd(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseAndAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseAndAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseAndAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseAndAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseAndRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseAndRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseAndRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseAndRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseAndRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseAndRelease(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseXor(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseXor(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseXor(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseXor(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXor(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXor(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseXorAcquire(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseXorAcquire(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseXorAcquire(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseXorAcquire(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorAcquire(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorAcquire(array, 0, (short)0x0123, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) vh.getAndBitwiseXorRelease(null, 0, (short)0x0123); + }); + checkCCE(() -> { // array reference class + short x = (short) vh.getAndBitwiseXorRelease(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) vh.getAndBitwiseXorRelease(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) vh.getAndBitwiseXorRelease(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndBitwiseXorRelease(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + short x = (short) vh.getAndBitwiseXorRelease(array, 0, (short)0x0123, Void.class); }); } @@ -2144,6 +3208,48 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { invokeExact(array, 0, (short)0x0123, Void.class); }); } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class)). + invokeExact((short[]) null, 0, (short)0x0123); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + short x = (short) hs.get(am, methodType(short.class, Class.class, int.class, short.class)). + invokeExact(Void.class, 0, (short)0x0123); + }); + checkWMTE(() -> { // value reference class + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + short x = (short) hs.get(am, methodType(short.class, int.class, int.class, short.class)). + invokeExact(0, 0, (short)0x0123); + }); + checkWMTE(() -> { // index reference class + short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class, short.class)). + invokeExact(array, Void.class, (short)0x0123); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, short[].class, int.class, short.class)). + invokeExact(array, 0, (short)0x0123); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class)). + invokeExact(array, 0, (short)0x0123); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + short x = (short) hs.get(am, methodType(short.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, Class.class)). + invokeExact(array, 0, (short)0x0123, Void.class); + }); + } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java index 41d0e6b4702..9e2debed693 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -352,6 +352,32 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, "foo", "foo"); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, "foo", "foo"); + }); + checkCCE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, "foo"); + }); + checkCCE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, "foo", Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, "foo", "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, "foo", "foo", Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, "foo", "foo"); }); @@ -376,32 +402,6 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, "foo", "foo"); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, "foo", "foo"); - }); - checkCCE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, "foo"); - }); - checkCCE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, "foo", Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, "foo", "foo"); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, "foo", "foo", Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,65 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { String x = (String) vh.getAndSet(recv, "foo", Void.class); }); + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + String x = (String) vh.getAndSetAcquire(null, "foo"); + }); + checkCCE(() -> { // receiver reference class + String x = (String) vh.getAndSetAcquire(Void.class, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + String x = (String) vh.getAndSetAcquire(0, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(recv, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetAcquire(recv, "foo", Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + String x = (String) vh.getAndSetRelease(null, "foo"); + }); + checkCCE(() -> { // receiver reference class + String x = (String) vh.getAndSetRelease(Void.class, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + String x = (String) vh.getAndSetRelease(0, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(recv, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetRelease(recv, "foo", Void.class); + }); + + } static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeString recv, Handles hs) throws Throwable { @@ -759,6 +818,7 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); } + } @@ -891,6 +951,23 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkCCE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, "foo"); + }); + checkCCE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain("foo", Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain("foo", "foo", Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkCCE(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, "foo"); }); @@ -906,23 +983,6 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkCCE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, "foo"); - }); - checkCCE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile("foo", Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile("foo", "foo", Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkCCE(() -> { // expected reference class @@ -1049,6 +1109,49 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { String x = (String) vh.getAndSet("foo", Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire("foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire("foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetAcquire("foo", Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease("foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease("foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetRelease("foo", Void.class); + }); + + } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1163,6 +1266,7 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); } + } @@ -1425,6 +1529,35 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, "foo", "foo"); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, "foo", "foo"); + }); + checkCCE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, "foo"); + }); + checkCCE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, "foo", Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, "foo", "foo"); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, "foo", "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, "foo", "foo", Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, "foo", "foo"); }); @@ -1452,35 +1585,6 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, "foo", "foo"); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, "foo", "foo"); - }); - checkCCE(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, "foo"); - }); - checkCCE(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, "foo", Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, "foo", "foo"); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, "foo", "foo"); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, "foo", "foo", Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1679,6 +1783,73 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { String x = (String) vh.getAndSet(array, 0, "foo", Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + String x = (String) vh.getAndSetAcquire(null, 0, "foo"); + }); + checkCCE(() -> { // array reference class + String x = (String) vh.getAndSetAcquire(Void.class, 0, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + String x = (String) vh.getAndSetAcquire(0, 0, "foo"); + }); + checkWMTE(() -> { // index reference class + String x = (String) vh.getAndSetAcquire(array, Void.class, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetAcquire(array, 0, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetAcquire(array, 0, "foo", Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + String x = (String) vh.getAndSetRelease(null, 0, "foo"); + }); + checkCCE(() -> { // array reference class + String x = (String) vh.getAndSetRelease(Void.class, 0, "foo"); + }); + checkCCE(() -> { // value reference class + String x = (String) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + String x = (String) vh.getAndSetRelease(0, 0, "foo"); + }); + checkWMTE(() -> { // index reference class + String x = (String) vh.getAndSetRelease(array, Void.class, "foo"); + }); + // Incorrect return type + checkCCE(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, "foo"); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSetRelease(array, 0, "foo"); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + String x = (String) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + String x = (String) vh.getAndSetRelease(array, 0, "foo", Void.class); + }); + + } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -1880,6 +2051,7 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { }); } + } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index a0b48a90bda..3d36bd35efc 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -104,30 +104,58 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #else[CAS] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #end[CAS] #if[AtomicAdd] assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); #else[AtomicAdd] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); #end[AtomicAdd] + +#if[Bitwise] + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#else[Bitwise] + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#end[Bitwise] } @@ -295,11 +323,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); }); checkUOE(() -> { @@ -313,6 +341,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet(recv, $value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease(recv, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -321,9 +357,51 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(recv, $value1$); + $type$ o = ($type$) vh.getAndAddAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(recv, $value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value1$); + }); +#end[Bitwise] } @@ -389,11 +467,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet($value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain($value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile($value1$, $value2$); + boolean r = vh.weakCompareAndSet($value1$, $value2$); }); checkUOE(() -> { @@ -407,6 +485,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet($value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire($value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease($value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -415,9 +501,51 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet($value1$); + $type$ o = ($type$) vh.getAndAddAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease($value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease($value1$); + }); +#end[Bitwise] } @@ -514,11 +642,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(recv, $value1$, $value2$); + success = vh.weakCompareAndSetPlain(recv, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(recv); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -544,33 +672,157 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$); + success = vh.weakCompareAndSet(recv, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(recv); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value"); + assertEquals(x, $value1$, "weakCompareAndSet $type$ value"); } // Compare set and get { + vh.set(recv, $value1$); + $type$ o = ($type$) vh.getAndSet(recv, $value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndSetAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndSetRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(recv, $value1$); - // get and add, add and get { - $type$ o = ($type$) vh.getAndAdd(recv, $value3$); + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndAdd(recv, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(recv, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndAddAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndAddRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndAddRelease$type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOr(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAnd(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXor(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(recv, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testInstanceFieldUnsupported(VarHandleTestAccess$Type$ recv, VarHandle vh) { @@ -592,11 +844,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); }); checkUOE(() -> { @@ -610,6 +862,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet(recv, $value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease(recv, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -618,9 +878,51 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(recv, $value1$); + $type$ o = ($type$) vh.getAndAddAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(recv, $value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value1$); + }); +#end[Bitwise] } @@ -717,11 +1019,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet($value1$, $value2$); + success = vh.weakCompareAndSetPlain($value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -747,33 +1049,157 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetRelease($value2$, $value1$); + success = vh.weakCompareAndSet($value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get { + vh.set($value1$); + $type$ o = ($type$) vh.getAndSet($value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndSetAcquire($value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndSetRelease($value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set($value1$); - // get and add, add and get { - $type$ o = ($type$) vh.getAndAdd( $value3$); + vh.set($value1$); + + $type$ o = ($type$) vh.getAndAdd($value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet($value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndAddAcquire($value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndAddRelease($value2$); + assertEquals(o, $value1$, "getAndAddRelease$type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseOr($value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseAnd($value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseXor($value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set($value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testStaticFieldUnsupported(VarHandle vh) { @@ -795,11 +1221,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet($value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain($value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile($value1$, $value2$); + boolean r = vh.weakCompareAndSet($value1$, $value2$); }); checkUOE(() -> { @@ -813,6 +1239,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet($value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire($value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease($value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -821,9 +1255,51 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet($value1$); + $type$ o = ($type$) vh.getAndAddAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease($value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire($value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease($value1$); + }); +#end[Bitwise] } @@ -923,11 +1399,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, $value1$, $value2$); + success = vh.weakCompareAndSetPlain(array, i, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -953,33 +1429,157 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$); + success = vh.weakCompareAndSet(array, i, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get { + vh.set(array, i, $value1$); + $type$ o = ($type$) vh.getAndSet(array, i, $value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndSetAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndSetRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(array, i, $value1$); - // get and add, add and get { - $type$ o = ($type$) vh.getAndAdd(array, i, $value3$); + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndAdd(array, i, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(array, i, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndAddAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndAddRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddRelease$type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(array, i, $value1$); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } @@ -1005,11 +1605,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(array, i, $value1$, $value2$); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, i, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); }); checkUOE(() -> { @@ -1023,6 +1623,14 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { $type$ r = ($type$) vh.getAndSet(array, i, $value1$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSetRelease(array, i, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -1031,9 +1639,51 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, i, $value1$); + $type$ o = ($type$) vh.getAndAddAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, i, $value1$); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, $value1$); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, $value1$); + }); +#end[Bitwise] } static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable { @@ -1092,11 +1742,11 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, $value1$, $value2$); + boolean r = vh.weakCompareAndSetPlain(array, ci, $value1$, $value2$); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, $value1$, $value2$); + boolean r = vh.weakCompareAndSet(array, ci, $value1$, $value2$); }); checkIOOBE(() -> { @@ -1110,17 +1760,67 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, $value1$); }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, $value1$); + }); #end[CAS] #if[AtomicAdd] checkIOOBE(() -> { - $type$ o = ($type$) vh.getAndAdd(array, ci, $value3$); + $type$ o = ($type$) vh.getAndAdd(array, ci, $value1$); }); checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, $value3$); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, $value1$); }); #end[AtomicAdd] + +#if[Bitwise] + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, $value1$); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, $value1$); + }); +#end[Bitwise] } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index a7aef2b898c..caf18e0566a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -93,30 +93,58 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #else[CAS] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET_RELEASE)); #end[CAS] #if[AtomicAdd] assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); #else[AtomicAdd] assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD_RELEASE)); #end[AtomicAdd] + +#if[Bitwise] + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#else[Bitwise] + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)); +#end[Bitwise] } @Test(dataProvider = "typesProvider") @@ -219,11 +247,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -237,6 +265,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[!AtomicAdd] @@ -245,9 +281,51 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } static void testArrayUnsupported(ByteBufferSource bs, VarHandleSource vhs) { @@ -293,11 +371,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkROBE(() -> { @@ -312,6 +390,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + checkROBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); + #else[CAS] checkUOE(() -> { boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); @@ -330,11 +416,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -348,6 +434,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -356,7 +450,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkROBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #else[AtomicAdd] checkUOE(() -> { @@ -364,9 +462,87 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[Bitwise] + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkROBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#else[Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } else { #if[!CAS] @@ -387,11 +563,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkUOE(() -> { @@ -405,6 +581,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkUOE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[!AtomicAdd] checkUOE(() -> { @@ -412,9 +596,50 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkUOE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] +#if[!Bitwise] + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkUOE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } @@ -477,11 +702,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -495,6 +720,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -503,10 +736,52 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] +#if[Bitwise] + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] + } } @@ -573,11 +848,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkIOOBE(() -> { @@ -591,6 +866,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkIOOBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -599,9 +882,51 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkIOOBE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[Bitwise] + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkIOOBE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } } @@ -660,11 +985,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -678,6 +1003,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkISE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -686,10 +1019,51 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] +#if[Bitwise] + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } } @@ -750,11 +1124,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSetPlain(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { - boolean r = vh.weakCompareAndSetVolatile(array, ci, VALUE_1, VALUE_2); + boolean r = vh.weakCompareAndSet(array, ci, VALUE_1, VALUE_2); }); checkISE(() -> { @@ -768,6 +1142,14 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkISE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndSetRelease(array, ci, VALUE_1); + }); #end[CAS] #if[AtomicAdd] @@ -776,9 +1158,51 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { }); checkISE(() -> { - $type$ o = ($type$) vh.addAndGet(array, ci, VALUE_1); + $type$ o = ($type$) vh.getAndAddAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndAddRelease(array, ci, VALUE_1); }); #end[AtomicAdd] + +#if[Bitwise] + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOr(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAnd(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXor(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, ci, VALUE_1); + }); + + checkISE(() -> { + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, ci, VALUE_1); + }); +#end[Bitwise] } } } @@ -888,11 +1312,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain $type$ value"); } { @@ -916,32 +1340,159 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile $type$ value"); + assertEquals(x, VALUE_1, "weakCompareAndSet $type$"); } // Compare set and get { + vh.set(array, i, VALUE_1); + $type$ o = ($type$) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet $type$ value"); } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(array, i, VALUE_1); - // get and add, add and get { - $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_3); + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } } @@ -1050,11 +1601,11 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + success = vh.weakCompareAndSetPlain(array, i, VALUE_1, VALUE_2); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); + assertEquals(x, VALUE_2, "weakCompareAndSetPlain $type$ value"); } { @@ -1078,32 +1629,159 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSetVolatile(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetVolatile $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, VALUE_1, "weakCompareAndSetVolatile $type$ value"); + assertEquals(x, VALUE_1, "weakCompareAndSet $type$"); } // Compare set and get { + vh.set(array, i, VALUE_1); + $type$ o = ($type$) vh.getAndSet(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "getAndSet $type$ value"); } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndSetRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndSetRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_2, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - vh.set(array, i, VALUE_1); - // get and add, add and get { - $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_3); + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAdd(array, i, VALUE_2); assertEquals(o, VALUE_1, "getAndAdd $type$"); - $type$ c = ($type$) vh.addAndGet(array, i, VALUE_3); - assertEquals(c, VALUE_1 + VALUE_3 + VALUE_3, "getAndAdd $type$ value"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAdd $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndAddRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndAddRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 + VALUE_2, "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOr(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOr $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOr $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseOrRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 | VALUE_2, "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAnd(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAnd $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseAndRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 & VALUE_2, "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXor(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXor $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXor $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorAcquire(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorAcquire $type$ value"); + } + + { + vh.set(array, i, VALUE_1); + + $type$ o = ($type$) vh.getAndBitwiseXorRelease(array, i, VALUE_2); + assertEquals(o, VALUE_1, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, VALUE_1 ^ VALUE_2, "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index 6df8b203e3a..c82d533878a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -211,11 +211,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(recv, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -241,11 +241,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get @@ -258,16 +258,120 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { #end[CAS] #if[AtomicAdd] - hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); - // get and add, add and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value3$); + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndAddRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(recv, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccess$Type$ recv, Handles hs) throws Throwable { @@ -298,6 +402,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[!Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + $type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$); + }); + } +#end[Bitwise] } @@ -394,11 +506,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact($value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -424,33 +536,159 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value2$); + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact($value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + // Compare set and get + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - hs.get(TestAccessMode.SET).invokeExact($value1$); - // get and add, add and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( $value3$); + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact($value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact($value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndAddRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact($value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact($value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } static void testStaticFieldUnsupported(Handles hs) throws Throwable { @@ -481,6 +719,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[!Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + $type$ r = ($type$) hs.get(am).invokeExact($value1$); + }); + } +#end[Bitwise] } @@ -580,11 +826,11 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_PLAIN).invokeExact(array, i, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSet $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { @@ -610,33 +856,157 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$); + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } // Compare set and get { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value2$); assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value2$, "getAndSet $type$ value"); } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, $value2$, "getAndSetAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndSetRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, $value2$, "getAndSetRelease $type$ value"); + } #end[CAS] #if[AtomicAdd] - hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); - // get and add, add and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value3$); + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); - $type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, $value3$); - assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndAddRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ + $value2$), "getAndAddRelease $type$ value"); } #end[AtomicAdd] + +#if[Bitwise] + // get and bitwise or + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOr $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOr $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_OR_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseOrRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ | $value2$), "getAndBitwiseOrRelease $type$ value"); + } + + // get and bitwise and + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAnd $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAnd $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_AND_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseAndRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ & $value2$), "getAndBitwiseAndRelease $type$ value"); + } + + // get and bitwise xor + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXor $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXor $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_ACQUIRE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorAcquire $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorAcquire $type$ value"); + } + + { + hs.get(TestAccessMode.SET).invokeExact(array, i, $value1$); + + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_BITWISE_XOR_RELEASE).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndBitwiseXorRelease $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, ($type$)($value1$ ^ $value2$), "getAndBitwiseXorRelease $type$ value"); + } +#end[Bitwise] } } @@ -671,6 +1041,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[!Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkUOE(am, () -> { + $type$ o = ($type$) hs.get(am).invokeExact(array, i, $value1$); + }); + } +#end[Bitwise] } static void testArrayIndexOutOfBounds(Handles hs) throws Throwable { @@ -718,6 +1096,14 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkIOOBE(am, () -> { + $type$ o = ($type$) hs.get(am).invokeExact(array, ci, $value3$); + }); + } +#end[Bitwise] } } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template index 15c4610df43..0116e5d61f1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template @@ -353,6 +353,32 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, $value1$, $value1$); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, $value1$, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(recv, Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, $value1$, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(recv, $value1$, $value1$, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, $value1$, $value1$); }); @@ -377,32 +403,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, $value1$, $value1$); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, $value1$, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, $value1$, $value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value1$, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -582,6 +582,64 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndSet(recv, $value1$, Void.class); }); + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndSetAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndSetAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndSetAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetAcquire(recv, $value1$, Void.class); + }); + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndSetRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndSetRelease(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndSetRelease(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetRelease(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetRelease(recv, $value1$, Void.class); + }); #end[CAS] #if[AtomicAdd] @@ -614,36 +672,335 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { $type$ x = ($type$) vh.getAndAdd(recv, $value1$, Void.class); }); - - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null receiver - $type$ x = ($type$) vh.addAndGet(null, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(null, $value1$); }); checkCCE(() -> { // receiver reference class - $type$ x = ($type$) vh.addAndGet(Void.class, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(Void.class, $value1$); }); check{#if[String]?CCE:WMTE}(() -> { // value reference class - $type$ x = ($type$) vh.addAndGet(recv, Void.class); + $type$ x = ($type$) vh.getAndAddAcquire(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - $type$ x = ($type$) vh.addAndGet(0, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(0, $value1$); }); // Incorrect return type check{#if[String]?CCE:WMTE}(() -> { // reference class - Void r = (Void) vh.addAndGet(recv, $value1$); + Void r = (Void) vh.getAndAddAcquire(recv, $value1$); }); checkWMTE(() -> { // primitive class - $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet(recv, $value1$); + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddAcquire(recv, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 - $type$ x = ($type$) vh.addAndGet(); + $type$ x = ($type$) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - $type$ x = ($type$) vh.addAndGet(recv, $value1$, Void.class); + $type$ x = ($type$) vh.getAndAddAcquire(recv, $value1$, Void.class); + }); + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndAddRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndAddRelease(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddRelease(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndAddRelease(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddRelease(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddRelease(recv, $value1$, Void.class); }); #end[AtomicAdd] + +#if[Bitwise] + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseOr(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseOr(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseOrRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseOr(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseAnd(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseAnd(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseAndRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseAnd(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseXor(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseXor(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorAcquire(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(recv, $value1$, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + $type$ x = ($type$) vh.getAndBitwiseXorRelease(null, $value1$); + }); + checkCCE(() -> { // receiver reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) vh.getAndBitwiseXor(0, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor(recv, $value1$, Void.class); + }); +#end[Bitwise] } static void testInstanceFieldWrongMethodType(VarHandleTestMethodType$Type$ recv, Handles hs) throws Throwable { @@ -861,6 +1218,45 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + checkNPE(() -> { // null receiver + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$); + }); + hs.checkWMTEOrCCE(() -> { // receiver reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). + invokeExact(Void.class, $value1$); + }); + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). + invokeExact(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). + invokeExact(0, $value1$); + }); + // Incorrect return type + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact(recv, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact(recv, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) hs.get(am, methodType($type$.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact(recv, $value1$, Void.class); + }); + } +#end[Bitwise] } @@ -994,6 +1390,23 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain($value1$, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain($value1$, $value1$, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // expected reference class boolean r = vh.weakCompareAndSet(Void.class, $value1$); }); @@ -1009,23 +1422,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - check{#if[String]?CCE:WMTE}(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile($value1$, Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile($value1$, $value1$, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // expected reference class @@ -1151,6 +1547,48 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndSet($value1$, Void.class); }); + + + // GetAndSetAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetAcquire($value1$, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetRelease($value1$, Void.class); + }); #end[CAS] #if[AtomicAdd] @@ -1175,26 +1613,237 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // value reference class - $type$ x = ($type$) vh.addAndGet(Void.class); + $type$ x = ($type$) vh.getAndAddAcquire(Void.class); }); // Incorrect return type check{#if[String]?CCE:WMTE}(() -> { // reference class - Void r = (Void) vh.addAndGet($value1$); + Void r = (Void) vh.getAndAddAcquire($value1$); }); checkWMTE(() -> { // primitive class - $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet($value1$); + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddAcquire($value1$); }); // Incorrect arity checkWMTE(() -> { // 0 - $type$ x = ($type$) vh.addAndGet(); + $type$ x = ($type$) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - $type$ x = ($type$) vh.addAndGet($value1$, Void.class); + $type$ x = ($type$) vh.getAndAddAcquire($value1$, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddRelease($value1$, Void.class); }); #end[AtomicAdd] + +#if[Bitwise] + // GetAndBitwiseOr + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr($value1$, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrAcquire($value1$, Void.class); + }); + + + // GetAndBitwiseOrReleaseRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrRelease($value1$, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd($value1$, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndAcquire($value1$, Void.class); + }); + + + // GetAndBitwiseAndReleaseRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndRelease($value1$, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor($value1$, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorAcquire($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorAcquire($value1$, Void.class); + }); + + + // GetAndBitwiseXorReleaseRelease + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorRelease($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorRelease($value1$, Void.class); + }); +#end[Bitwise] } static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { @@ -1338,6 +1987,34 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). + invokeExact(Void.class); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). + invokeExact($value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). + invokeExact($value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) hs.get(am, methodType($type$.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). + invokeExact($value1$, Void.class); + }); + } +#end[Bitwise] } @@ -1601,6 +2278,35 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // WeakCompareAndSet // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetPlain(null, 0, $value1$, $value1$); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetPlain(Void.class, 0, $value1$, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // expected reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, Void.class, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // actual reference class + boolean r = vh.weakCompareAndSetPlain(array, 0, $value1$, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetPlain(0, 0, $value1$, $value1$); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetPlain(array, Void.class, $value1$, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetPlain(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetPlain(array, 0, $value1$, $value1$, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types checkNPE(() -> { // null receiver boolean r = vh.weakCompareAndSet(null, 0, $value1$, $value1$); }); @@ -1628,35 +2334,6 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // WeakCompareAndSetVolatile - // Incorrect argument types - checkNPE(() -> { // null receiver - boolean r = vh.weakCompareAndSetVolatile(null, 0, $value1$, $value1$); - }); - checkCCE(() -> { // receiver reference class - boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, $value1$, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, $value1$); - }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class - boolean r = vh.weakCompareAndSetVolatile(array, 0, $value1$, Void.class); - }); - checkWMTE(() -> { // receiver primitive class - boolean r = vh.weakCompareAndSetVolatile(0, 0, $value1$, $value1$); - }); - checkWMTE(() -> { // index reference class - boolean r = vh.weakCompareAndSetVolatile(array, Void.class, $value1$, $value1$); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - boolean r = vh.weakCompareAndSetVolatile(); - }); - checkWMTE(() -> { // > - boolean r = vh.weakCompareAndSetVolatile(array, 0, $value1$, $value1$, Void.class); - }); - - // WeakCompareAndSetAcquire // Incorrect argument types checkNPE(() -> { // null receiver @@ -1854,6 +2531,72 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { checkWMTE(() -> { // > $type$ x = ($type$) vh.getAndSet(array, 0, $value1$, Void.class); }); + + + // GetAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndSetAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndSetAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + $type$ x = ($type$) vh.getAndSetAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndSetAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndSetRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndSetRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndSetRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // reciarrayever primitive class + $type$ x = ($type$) vh.getAndSetRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndSetRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndSetRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndSetRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndSetRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndSetRelease(array, 0, $value1$, Void.class); + }); #end[CAS] #if[AtomicAdd] @@ -1890,38 +2633,369 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); - // AddAndGet + // GetAndAddAcquire // Incorrect argument types checkNPE(() -> { // null array - $type$ x = ($type$) vh.addAndGet(null, 0, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(null, 0, $value1$); }); checkCCE(() -> { // array reference class - $type$ x = ($type$) vh.addAndGet(Void.class, 0, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(Void.class, 0, $value1$); }); check{#if[String]?CCE:WMTE}(() -> { // value reference class - $type$ x = ($type$) vh.addAndGet(array, 0, Void.class); + $type$ x = ($type$) vh.getAndAddAcquire(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - $type$ x = ($type$) vh.addAndGet(0, 0, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(0, 0, $value1$); }); checkWMTE(() -> { // index reference class - $type$ x = ($type$) vh.addAndGet(array, Void.class, $value1$); + $type$ x = ($type$) vh.getAndAddAcquire(array, Void.class, $value1$); }); // Incorrect return type check{#if[String]?CCE:WMTE}(() -> { // reference class - Void r = (Void) vh.addAndGet(array, 0, $value1$); + Void r = (Void) vh.getAndAddAcquire(array, 0, $value1$); }); checkWMTE(() -> { // primitive class - $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.addAndGet(array, 0, $value1$); + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddAcquire(array, 0, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 - $type$ x = ($type$) vh.addAndGet(); + $type$ x = ($type$) vh.getAndAddAcquire(); }); checkWMTE(() -> { // > - $type$ x = ($type$) vh.addAndGet(array, 0, $value1$, Void.class); + $type$ x = ($type$) vh.getAndAddAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndAddRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndAddRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndAddRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndAddRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndAddRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndAddRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndAddRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndAddRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndAddRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndAddRelease(array, 0, $value1$, Void.class); }); #end[AtomicAdd] + +#if[Bitwise] + // GetAndBitwiseOr + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseOr(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseOr(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOr(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseOr(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseOr(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOr(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOr(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOr(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOr(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseOrAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseOrRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseOrRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseOrRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseOrRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseOrRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseOrRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseOrRelease(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseAnd + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseAnd(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseAnd(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseAnd(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAnd(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAnd(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAnd(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAnd(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseAndAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseAndRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseAndRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseAndRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseAndRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseAndRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseAndRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseAndRelease(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseXor + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseXor(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseXor(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXor(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseXor(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseXor(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXor(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXor(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXor(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXor(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseXorAcquire + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorAcquire(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorAcquire(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorAcquire(array, 0, $value1$, Void.class); + }); + + + // GetAndBitwiseXorRelease + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) vh.getAndBitwiseXorRelease(null, 0, $value1$); + }); + checkCCE(() -> { // array reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(Void.class, 0, $value1$); + }); + check{#if[String]?CCE:WMTE}(() -> { // value reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) vh.getAndBitwiseXorRelease(array, Void.class, $value1$); + }); + // Incorrect return type + check{#if[String]?CCE:WMTE}(() -> { // reference class + Void r = (Void) vh.getAndBitwiseXorRelease(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) vh.getAndBitwiseXorRelease(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) vh.getAndBitwiseXorRelease(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) vh.getAndBitwiseXorRelease(array, 0, $value1$, Void.class); + }); +#end[Bitwise] } static void testArrayWrongMethodType(Handles hs) throws Throwable { @@ -2168,6 +3242,50 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { }); } #end[AtomicAdd] + +#if[Bitwise] + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) { + // Incorrect argument types + checkNPE(() -> { // null array + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$); + }); + hs.checkWMTEOrCCE(() -> { // array reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). + invokeExact(Void.class, 0, $value1$); + }); + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). + invokeExact(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). + invokeExact(0, 0, $value1$); + }); + checkWMTE(() -> { // index reference class + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). + invokeExact(array, Void.class, $value1$); + }); + // Incorrect return type + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). + invokeExact(array, 0, $value1$); + }); + checkWMTE(() -> { // primitive class + $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). + invokeExact(array, 0, $value1$); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + $type$ x = ($type$) hs.get(am, methodType($type$.class)). + invokeExact(); + }); + checkWMTE(() -> { // > + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). + invokeExact(array, 0, $value1$, Void.class); + }); + } +#end[Bitwise] } } diff --git a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh index 02ae5ae304f..2641f8d58d5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh +++ b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh @@ -22,6 +22,12 @@ do ;; esac + case $type in + boolean|byte|short|char|int|long) + args="$args -KBitwise" + ;; + esac + wrong_primitive_type=boolean case $type in @@ -109,6 +115,12 @@ do ;; esac + case $type in + int|long) + args="$args -KBitwise" + ;; + esac + # The value of `value3` is chosen such that when added to `value1` or `value2` # it will result in carrying of bits over to the next byte, thereby detecting # possible errors in endianness conversion e.g. if say for atomic addition the diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java b/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java index 190761dd6df..a129ea254a4 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java @@ -19,7 +19,6 @@ * 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. - * */ import java.io.BufferedInputStream; diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java b/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java index d14e7ef8a35..fae5e466646 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java @@ -19,7 +19,6 @@ * 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. - * */ import anotherpkg.MethodSupplierOuter; diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java b/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java index b83496f692f..96b3fb637a1 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java b/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java index 314f8eab707..cd40ed2050c 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java @@ -19,7 +19,6 @@ * 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 anotherpkg; diff --git a/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java b/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java index a8bb8badf9b..13ae1e030c5 100644 --- a/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java +++ b/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, 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 diff --git a/jdk/test/java/lang/ref/CleanerTest.java b/jdk/test/java/lang/ref/CleanerTest.java index 25c50dc24c1..c6778669f00 100644 --- a/jdk/test/java/lang/ref/CleanerTest.java +++ b/jdk/test/java/lang/ref/CleanerTest.java @@ -49,7 +49,7 @@ import org.testng.annotations.Test; /* * @test - * @library /test/lib/share/classes /lib/testlibrary /test/lib + * @library /lib/testlibrary /test/lib * @build sun.hotspot.WhiteBox * @build jdk.test.lib.Utils * @modules java.base/jdk.internal diff --git a/jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java b/jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java new file mode 100644 index 00000000000..3c2ec8922af --- /dev/null +++ b/jdk/test/java/net/HttpURLConnection/HttpURLConWithProxy.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, 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 8161016 + * @summary When proxy is set HttpURLConnection should not use DIRECT connection. + * @run main/othervm HttpURLConWithProxy + */ +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.ServerSocket; +import java.net.SocketAddress; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +public class HttpURLConWithProxy { + + public static void main(String... arg) { + // Remove the default nonProxyHosts to use localhost for testing + System.setProperty("http.nonProxyHosts", ""); + + System.setProperty("http.proxyHost", "1.1.1.1"); + System.setProperty("http.proxyPort", "1111"); + + ServerSocket ss; + URL url; + URLConnection con; + + // Test1: using Proxy set by System Property: + try { + ss = new ServerSocket(0); + url = new URL("http://localhost:" + ss.getLocalPort()); + con = url.openConnection(); + con.setConnectTimeout(10 * 1000); + con.connect(); + throw new RuntimeException("Shouldn't use DIRECT connection " + + "when proxy is invalid/down"); + } catch (IOException ie) { + System.out.println("Test1 Passed with: " + ie.getMessage()); + } + + // Test2: using custom ProxySelector implementation + MyProxySelector myProxySel = new MyProxySelector(); + ProxySelector.setDefault(myProxySel); + try { + ss = new ServerSocket(0); + url = new URL("http://localhost:" + ss.getLocalPort()); + con = url.openConnection(); + con.setConnectTimeout(10 * 1000); + con.connect(); + throw new RuntimeException("Shouldn't use DIRECT connection " + + "when proxy is invalid/down"); + } catch (IOException ie) { + System.out.println("Test2 Passed with: " + ie.getMessage()); + } + } +} + + +class MyProxySelector extends ProxySelector { + + List proxies = new ArrayList<>(); + + MyProxySelector() { + Proxy p1 = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("2.2.2.2", 2222)); + Proxy p2 = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("3.3.3.3", 3333)); + proxies.add(p1); + proxies.add(p2); + } + + @Override + public List select(URI uri) { + return proxies; + } + + @Override + public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + // System.out.println("MyProxySelector.connectFailed(): "+sa); + } +} diff --git a/jdk/test/java/net/Inet4Address/textToNumericFormat.java b/jdk/test/java/net/Inet4Address/textToNumericFormat.java index 1d010d0b912..7d75bc9f534 100644 --- a/jdk/test/java/net/Inet4Address/textToNumericFormat.java +++ b/jdk/test/java/net/Inet4Address/textToNumericFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 diff --git a/jdk/test/java/net/ProxySelector/B8035158.java b/jdk/test/java/net/ProxySelector/B8035158.java index 21b1e99d702..432e457c303 100644 --- a/jdk/test/java/net/ProxySelector/B8035158.java +++ b/jdk/test/java/net/ProxySelector/B8035158.java @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @bug 8035158 8145732 diff --git a/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java b/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java index 64c9af0192e..0b65c506a6f 100644 --- a/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java +++ b/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java @@ -27,7 +27,7 @@ * @bug 8048052 * @summary Test a series of methods which requires "setFactory" runtime permission * @modules java.rmi - * @run main SetFactoryPermission success + * @run main/othervm SetFactoryPermission success * @run main/othervm/policy=policy.fail SetFactoryPermission fail * @run main/othervm/policy=policy.success SetFactoryPermission success */ diff --git a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java index 0b009606624..c31441d8b1a 100644 --- a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java +++ b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/net/URLPermission/nstest/LookupTest.java b/jdk/test/java/net/URLPermission/nstest/LookupTest.java index f69522de22f..d5b9141c1d4 100644 --- a/jdk/test/java/net/URLPermission/nstest/LookupTest.java +++ b/jdk/test/java/net/URLPermission/nstest/LookupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/jdk/test/java/net/URLPermission/nstest/lookup.sh b/jdk/test/java/net/URLPermission/nstest/lookup.sh index 89798669f53..798e1c168f6 100644 --- a/jdk/test/java/net/URLPermission/nstest/lookup.sh +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh @@ -27,6 +27,7 @@ # @build jdk.testlibrary.* # @compile -XDignore.symbol.file=true LookupTest.java # @run shell/timeout=50 lookup.sh +# @key intermittent # OS=`uname -s` diff --git a/jdk/test/java/net/httpclient/BasicAuthTest.java b/jdk/test/java/net/httpclient/BasicAuthTest.java index fb227e3f672..b78739e682a 100644 --- a/jdk/test/java/net/httpclient/BasicAuthTest.java +++ b/jdk/test/java/net/httpclient/BasicAuthTest.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/HeadersTest1.java b/jdk/test/java/net/httpclient/HeadersTest1.java index 79f62006722..e3c892ef2c1 100644 --- a/jdk/test/java/net/httpclient/HeadersTest1.java +++ b/jdk/test/java/net/httpclient/HeadersTest1.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/ImmutableHeaders.java b/jdk/test/java/net/httpclient/ImmutableHeaders.java index 7286c2e1b0b..7773061dc30 100644 --- a/jdk/test/java/net/httpclient/ImmutableHeaders.java +++ b/jdk/test/java/net/httpclient/ImmutableHeaders.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/security/Driver.java b/jdk/test/java/net/httpclient/security/Driver.java index 078be5f5e51..3253fe2fd3c 100644 --- a/jdk/test/java/net/httpclient/security/Driver.java +++ b/jdk/test/java/net/httpclient/security/Driver.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/security/Security.java b/jdk/test/java/net/httpclient/security/Security.java index 2108c9fce29..5c282be9a36 100644 --- a/jdk/test/java/net/httpclient/security/Security.java +++ b/jdk/test/java/net/httpclient/security/Security.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/nio/channels/Selector/SelectTimeout.java b/jdk/test/java/nio/channels/Selector/SelectTimeout.java new file mode 100644 index 00000000000..aaeff367d84 --- /dev/null +++ b/jdk/test/java/nio/channels/Selector/SelectTimeout.java @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2016, 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 8165000 + * @summary Verify no IOException on OS X for large timeout value in select(). + * @requires (os.family == "mac") + */ +import java.io.IOException; +import java.nio.channels.Selector; + +public class SelectTimeout { + private static final long HUGE_TIMEOUT = 100000001000L; + private static final long SLEEP_MILLIS = 10000; + + private static Exception theException; + + public static void main(String[] args) + throws IOException, InterruptedException { + int failures = 0; + long[] timeouts = + new long[] {0, HUGE_TIMEOUT/2, HUGE_TIMEOUT - 1, HUGE_TIMEOUT}; + for (long t : timeouts) { + if (!test(t)) { + failures++; + } + } + if (failures > 0) { + throw new RuntimeException("Test failed!"); + } else { + System.out.println("Test succeeded"); + } + } + + private static boolean test(final long timeout) + throws InterruptedException, IOException { + theException = null; + + Selector selector = Selector.open(); + + Thread t = new Thread(() -> { + try { + selector.select(timeout); + } catch (IOException ioe) { + theException = ioe; + } + }); + t.start(); + + Thread.currentThread().sleep(SLEEP_MILLIS); + t.interrupt(); + + if (theException == null) { + System.out.printf("Test succeeded with timeout %d%n", timeout); + return true; + } else { + System.err.printf("Test failed with timeout %d%n", timeout); + theException.printStackTrace(); + return false; + } + } +} diff --git a/jdk/test/java/nio/file/DirectoryStream/SecureDS.java b/jdk/test/java/nio/file/DirectoryStream/SecureDS.java index 60ca72ec3e6..250e84763db 100644 --- a/jdk/test/java/nio/file/DirectoryStream/SecureDS.java +++ b/jdk/test/java/nio/file/DirectoryStream/SecureDS.java @@ -45,6 +45,9 @@ public class SecureDS { DirectoryStream stream = newDirectoryStream(dir); stream.close(); if (!(stream instanceof SecureDirectoryStream)) { + if (System.getProperty("os.name").equals("Linux")) + throw new AssertionError( + "SecureDirectoryStream not supported."); System.out.println("SecureDirectoryStream not supported."); return; } diff --git a/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java b/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java index 07ada993a35..f633576f4f0 100644 --- a/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java +++ b/jdk/test/java/security/SecureRandom/DrbgParametersSpec.java @@ -24,7 +24,7 @@ /* @test * @bug 8051408 8158534 * @summary Make sure DrbgParameters coded as specified - * @library /test/lib/share/classes + * @library /test/lib */ import jdk.test.lib.Asserts; diff --git a/jdk/test/java/text/Bidi/BidiConformance.java b/jdk/test/java/text/Bidi/BidiConformance.java index 73689659cc3..45e49cb632f 100644 --- a/jdk/test/java/text/Bidi/BidiConformance.java +++ b/jdk/test/java/text/Bidi/BidiConformance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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 @@ -25,6 +25,7 @@ * @test * @bug 6850113 8032446 * @summary confirm the behavior of new Bidi implementation. (Backward compatibility) + * @modules java.desktop */ import java.awt.font.NumericShaper; diff --git a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java index 86578f4f1be..fb4d5f7418c 100644 --- a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java +++ b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ -28,6 +28,7 @@ * indicate overrides, rather than using bit 7. Also tests Bidi without loading awt classes to * confirm that Bidi can be used without awt. Verify that embedding level 0 is properly mapped * to the base embedding level. + * @modules java.desktop */ import java.awt.Color; diff --git a/jdk/test/java/text/Bidi/Bug7042148.java b/jdk/test/java/text/Bidi/Bug7042148.java index 92c3001dde9..d905a49b746 100644 --- a/jdk/test/java/text/Bidi/Bug7042148.java +++ b/jdk/test/java/text/Bidi/Bug7042148.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -25,6 +25,7 @@ * @test * @bug 7042148 * @summary verify that Bidi.baseIsLeftToRight() returns the correct value even if an incorrect position is set in the given AttributedCharacterIterator. + * @modules java.desktop */ import java.awt.font.*; import java.text.*; diff --git a/jdk/test/java/text/Bidi/Bug7051769.java b/jdk/test/java/text/Bidi/Bug7051769.java index 9b1326021b5..a0737ec0afc 100644 --- a/jdk/test/java/text/Bidi/Bug7051769.java +++ b/jdk/test/java/text/Bidi/Bug7051769.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -26,6 +26,7 @@ * @bug 7051769 8038092 * @summary verify that Bidi.toString() returns the corect result. * The second run is intended to test lazy SharedSectets init for 8038092 + * @modules java.desktop * @run main Bug7051769 * @run main/othervm -DpreloadBidi=true Bug7051769 */ diff --git a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java index 467cbc574c3..4e114d75bf3 100644 --- a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java +++ b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java @@ -22,9 +22,10 @@ */ /* - @test - @summary test Comparison of New Collators against Old Collators in the en_US locale -*/ + * @test + * @summary test Comparison of New Collators against Old Collators in the en_US locale + * @modules jdk.localedata + */ import java.io.*; import java.util.Enumeration; diff --git a/jdk/test/java/text/Collator/APITest.java b/jdk/test/java/text/Collator/APITest.java index f2b0a019a29..43782c5ad90 100644 --- a/jdk/test/java/text/Collator/APITest.java +++ b/jdk/test/java/text/Collator/APITest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Collation API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/CollationKeyTest.java b/jdk/test/java/text/Collator/CollationKeyTest.java index 9146bf97e9a..901a6347a57 100644 --- a/jdk/test/java/text/Collator/CollationKeyTest.java +++ b/jdk/test/java/text/Collator/CollationKeyTest.java @@ -29,6 +29,7 @@ * RuleBasedCollationKey. This test basically tests on the two features: * 1. Existing code using CollationKey works (backward compatiblility) * 2. CollationKey can be extended by its subclass. + * @modules jdk.localedata */ diff --git a/jdk/test/java/text/Collator/DanishTest.java b/jdk/test/java/text/Collator/DanishTest.java index b5194a83c2a..0c35d22e488 100644 --- a/jdk/test/java/text/Collator/DanishTest.java +++ b/jdk/test/java/text/Collator/DanishTest.java @@ -26,6 +26,7 @@ * @bug 4930708 4174436 5008498 * @library /java/text/testlib * @summary test Danish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/FinnishTest.java b/jdk/test/java/text/Collator/FinnishTest.java index 6df18ef0146..9efc3cd861d 100644 --- a/jdk/test/java/text/Collator/FinnishTest.java +++ b/jdk/test/java/text/Collator/FinnishTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Finnish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/FrenchTest.java b/jdk/test/java/text/Collator/FrenchTest.java index 939ef322253..38492db023c 100644 --- a/jdk/test/java/text/Collator/FrenchTest.java +++ b/jdk/test/java/text/Collator/FrenchTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test French Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/G7Test.java b/jdk/test/java/text/Collator/G7Test.java index 0b41566bd2e..f7bdfa4f868 100644 --- a/jdk/test/java/text/Collator/G7Test.java +++ b/jdk/test/java/text/Collator/G7Test.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test G7 Collation + * @modules jdk.localedata */ /* * diff --git a/jdk/test/java/text/Collator/JapaneseTest.java b/jdk/test/java/text/Collator/JapaneseTest.java index 2bd5f6d0179..7333da34b12 100644 --- a/jdk/test/java/text/Collator/JapaneseTest.java +++ b/jdk/test/java/text/Collator/JapaneseTest.java @@ -25,6 +25,7 @@ * @test 1.1 02/09/11 * @bug 4176141 4655819 * @summary Regression tests for Japanese Collation + * @modules jdk.localedata */ import java.text.*; diff --git a/jdk/test/java/text/Collator/KoreanTest.java b/jdk/test/java/text/Collator/KoreanTest.java index fd314ee13ed..fb3c5eae941 100644 --- a/jdk/test/java/text/Collator/KoreanTest.java +++ b/jdk/test/java/text/Collator/KoreanTest.java @@ -25,6 +25,7 @@ * @test 1.1 02/09/12 * @bug 4176141 4655819 * @summary Regression tests for Korean Collation + * @modules jdk.localedata */ import java.text.*; diff --git a/jdk/test/java/text/Collator/Regression.java b/jdk/test/java/text/Collator/Regression.java index 958ce29c524..212ab39d557 100644 --- a/jdk/test/java/text/Collator/Regression.java +++ b/jdk/test/java/text/Collator/Regression.java @@ -29,6 +29,7 @@ * 4133509 4139572 4141640 4179126 4179686 4244884 4663220 * @library /java/text/testlib * @summary Regression tests for Collation and associated classes + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/ThaiTest.java b/jdk/test/java/text/Collator/ThaiTest.java index 7d643446434..7a961ed5968 100644 --- a/jdk/test/java/text/Collator/ThaiTest.java +++ b/jdk/test/java/text/Collator/ThaiTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Thai Collation + * @modules jdk.localedata */ /* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. diff --git a/jdk/test/java/text/Collator/TurkishTest.java b/jdk/test/java/text/Collator/TurkishTest.java index f83ef228e06..d8c078abb4d 100644 --- a/jdk/test/java/text/Collator/TurkishTest.java +++ b/jdk/test/java/text/Collator/TurkishTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Turkish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/VietnameseTest.java b/jdk/test/java/text/Collator/VietnameseTest.java index faa4921073c..6708622d096 100644 --- a/jdk/test/java/text/Collator/VietnameseTest.java +++ b/jdk/test/java/text/Collator/VietnameseTest.java @@ -26,6 +26,7 @@ * @bug 4932968 5015215 * @library /java/text/testlib * @summary test Vietnamese Collation + * @modules jdk.localedata */ /* diff --git a/jdk/test/java/text/Format/DateFormat/Bug4823811.java b/jdk/test/java/text/Format/DateFormat/Bug4823811.java index 524f790e1fb..c2d35e9f64f 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4823811.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4823811.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ -25,6 +25,7 @@ * @test * @bug 4823811 8008577 * @summary Confirm that text which includes numbers with a trailing minus sign is parsed correctly. + * @modules jdk.localedata * @run main/othervm -Duser.timezone=GMT+09:00 -Djava.locale.providers=JRE,SPI Bug4823811 */ diff --git a/jdk/test/java/text/Format/DateFormat/Bug6683975.java b/jdk/test/java/text/Format/DateFormat/Bug6683975.java index e0c8cd75f15..1f401058e5a 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug6683975.java +++ b/jdk/test/java/text/Format/DateFormat/Bug6683975.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ -25,6 +25,7 @@ * @test * @bug 6683975 8008577 * @summary Make sure that date is formatted correctlyin th locale. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6683975 */ import java.text.*; diff --git a/jdk/test/java/text/Format/DateFormat/Bug8139572.java b/jdk/test/java/text/Format/DateFormat/Bug8139572.java index d55196b3a23..13154c836c5 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug8139572.java +++ b/jdk/test/java/text/Format/DateFormat/Bug8139572.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -26,6 +26,7 @@ * @bug 8139572 * @summary SimpleDateFormat parse month stand-alone format bug * @compile -encoding utf-8 Bug8139572.java + * @modules jdk.localedata * @run main Bug8139572 */ import java.text.ParseException; diff --git a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java index 6f38bfb15c1..60632b0fcce 100644 --- a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java +++ b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -25,6 +25,7 @@ * @test * @bug 7079560 8008577 * @summary Unit test for context-sensitive month names + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI ContextMonthNamesTest */ diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java index c4f148f3d77..7384a82af0c 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java @@ -26,6 +26,7 @@ * @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571 * @summary test DateFormat and SimpleDateFormat. * @library /java/text/testlib + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI DateFormatTest */ diff --git a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java index bff177ff7e4..9241e59c3bd 100644 --- a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java +++ b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +24,7 @@ /** * @test * @bug 8080774 + * @modules jdk.localedata * @run testng/othervm -Djava.locale.providers=JRE,CLDR LocaleDateFormats * @summary This file contains tests for JRE locales date formats */ diff --git a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java index 69808d47645..b811900901d 100644 --- a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java +++ b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java @@ -25,6 +25,7 @@ * @test * @bug 4833268 6253991 8008577 * @summary Test formatting and parsing with non-Gregorian calendars + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI NonGregorianFormatTest */ diff --git a/jdk/test/java/text/Format/DateFormat/bug4117335.java b/jdk/test/java/text/Format/DateFormat/bug4117335.java index 6c9af2a4716..d9b59eda005 100644 --- a/jdk/test/java/text/Format/DateFormat/bug4117335.java +++ b/jdk/test/java/text/Format/DateFormat/bug4117335.java @@ -25,6 +25,7 @@ * @test * * @bug 4117335 4432617 + * @modules jdk.localedata */ import java.text.DateFormatSymbols ; diff --git a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java index 1a4ca1d092d..55c9869c373 100644 --- a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java +++ b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java @@ -25,6 +25,7 @@ * @test * @bug 4112090 8008577 * @summary verify that MessageFormat can handle large numbers of arguments + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI LargeMessageFormat */ diff --git a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java index e19b2cd17eb..9f713324a21 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -25,6 +25,7 @@ * @test * @bug 8132125 * @summary Checks Swiss' number elements + * @modules jdk.localedata */ import java.text.*; diff --git a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java index 96fa3976701..44b53d25ec1 100644 --- a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java +++ b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java @@ -25,6 +25,7 @@ * @test * @bug 4290801 4942982 5102005 8008577 8021121 * @summary Basic tests for currency formatting. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI CurrencyFormat */ diff --git a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java index ab1069bdfc2..011db2bdea3 100644 --- a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java +++ b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test International Number Format API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved diff --git a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java index 0edaa11ccf5..b194d270a5c 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java @@ -34,6 +34,7 @@ * @library /java/text/testlib * @build IntlTest HexDumpReader TestUtils * @modules java.base/sun.util.resources + * jdk.localedata * @compile -XDignore.symbol.file NumberRegression.java * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberRegression */ diff --git a/jdk/test/java/text/Format/NumberFormat/NumberTest.java b/jdk/test/java/text/Format/NumberFormat/NumberTest.java index ca519bb6dab..cf64a431a55 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberTest.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberTest.java @@ -27,6 +27,7 @@ * @summary test NumberFormat * @library /java/text/testlib * @modules java.base/sun.util.resources + * jdk.localedata * @compile -XDignore.symbol.file NumberTest.java * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberTest */ diff --git a/jdk/test/java/time/TEST.properties b/jdk/test/java/time/TEST.properties index f480a511913..82224020e8e 100644 --- a/jdk/test/java/time/TEST.properties +++ b/jdk/test/java/time/TEST.properties @@ -1,4 +1,6 @@ # Threeten test uses TestNG TestNG.dirs = . othervm.dirs = tck/java/time/chrono test/java/time/chrono test/java/time/format +modules = jdk.localedata lib.dirs = ../../lib/testlibrary +lib.build = jdk.testlibrary.RandomFactory diff --git a/jdk/test/java/util/Arrays/Correct.java b/jdk/test/java/util/Arrays/Correct.java index e9ddc7edef5..f69ea9160ff 100644 --- a/jdk/test/java/util/Arrays/Correct.java +++ b/jdk/test/java/util/Arrays/Correct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, 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 diff --git a/jdk/test/java/util/Base64/TestBase64.java b/jdk/test/java/util/Base64/TestBase64.java index 0c5e27fd9fd..d28f0d0f88a 100644 --- a/jdk/test/java/util/Base64/TestBase64.java +++ b/jdk/test/java/util/Base64/TestBase64.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,11 @@ /** * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925 - * 8014217 8025003 8026330 8028397 8129544 + * 8014217 8025003 8026330 8028397 8129544 8165243 * @summary tests java.util.Base64 + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @run main TestBase64 * @key randomness */ @@ -35,11 +38,17 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.util.Arrays; +import java.util.ArrayList; import java.util.Base64; +import java.util.List; import java.util.Random; +import jdk.testlibrary.RandomFactory; + public class TestBase64 { + private static final Random rnd = RandomFactory.getRandom(); + public static void main(String args[]) throws Throwable { int numRuns = 10; int numBytes = 200; @@ -52,7 +61,6 @@ public class TestBase64 { test(Base64.getUrlEncoder(), Base64.getUrlDecoder(), numRuns, numBytes); test(Base64.getMimeEncoder(), Base64.getMimeDecoder(), numRuns, numBytes); - Random rnd = new java.util.Random(); byte[] nl_1 = new byte[] {'\n'}; byte[] nl_2 = new byte[] {'\n', '\r'}; byte[] nl_3 = new byte[] {'\n', '\r', '\n'}; @@ -76,7 +84,7 @@ public class TestBase64 { testNull(Base64.getDecoder()); testNull(Base64.getUrlDecoder()); testNull(Base64.getMimeDecoder()); - checkNull(new Runnable() { public void run() { Base64.getMimeEncoder(10, null); }}); + checkNull(() -> Base64.getMimeEncoder(10, null)); testIOE(Base64.getEncoder()); testIOE(Base64.getUrlEncoder()); @@ -84,26 +92,23 @@ public class TestBase64 { testIOE(Base64.getMimeEncoder(10, new byte[]{'\n'})); byte[] src = new byte[1024]; - new Random().nextBytes(src); + rnd.nextBytes(src); final byte[] decoded = Base64.getEncoder().encode(src); testIOE(Base64.getDecoder(), decoded); testIOE(Base64.getMimeDecoder(), decoded); testIOE(Base64.getUrlDecoder(), Base64.getUrlEncoder().encode(src)); // illegal line separator - checkIAE(new Runnable() { public void run() { Base64.getMimeEncoder(10, new byte[]{'\r', 'N'}); }}); + checkIAE(() -> Base64.getMimeEncoder(10, new byte[]{'\r', 'N'})); // malformed padding/ending testMalformedPadding(); // illegal base64 character decoded[2] = (byte)0xe0; - checkIAE(new Runnable() { - public void run() { Base64.getDecoder().decode(decoded); }}); - checkIAE(new Runnable() { - public void run() { Base64.getDecoder().decode(decoded, new byte[1024]); }}); - checkIAE(new Runnable() { public void run() { - Base64.getDecoder().decode(ByteBuffer.wrap(decoded)); }}); + checkIAE(() -> Base64.getDecoder().decode(decoded)); + checkIAE(() -> Base64.getDecoder().decode(decoded, new byte[1024])); + checkIAE(() -> Base64.getDecoder().decode(ByteBuffer.wrap(decoded))); // test single-non-base64 character for mime decoding testSingleNonBase64MimeDec(); @@ -113,12 +118,20 @@ public class TestBase64 { // test mime decoding with ignored character after padding testDecodeIgnoredAfterPadding(); + + // given invalid args, encoder should not produce output + testEncoderKeepsSilence(Base64.getEncoder()); + testEncoderKeepsSilence(Base64.getUrlEncoder()); + testEncoderKeepsSilence(Base64.getMimeEncoder()); + + // given invalid args, decoder should not consume input + testDecoderKeepsAbstinence(Base64.getDecoder()); + testDecoderKeepsAbstinence(Base64.getUrlDecoder()); + testDecoderKeepsAbstinence(Base64.getMimeDecoder()); } private static void test(Base64.Encoder enc, Base64.Decoder dec, int numRuns, int numBytes) throws Throwable { - Random rnd = new java.util.Random(); - enc.encode(new byte[0]); dec.decode(new byte[0]); @@ -258,48 +271,49 @@ public class TestBase64 { private static final String str_null = null; private static final ByteBuffer bb_null = null; - private static void testNull(final Base64.Encoder enc) { - checkNull(new Runnable() { public void run() { enc.encode(ba_null); }}); - checkNull(new Runnable() { public void run() { enc.encodeToString(ba_null); }}); - checkNull(new Runnable() { public void run() { enc.encode(ba_null, new byte[10]); }}); - checkNull(new Runnable() { public void run() { enc.encode(new byte[10], ba_null); }}); - checkNull(new Runnable() { public void run() { enc.encode(bb_null); }}); - checkNull(new Runnable() { public void run() { enc.wrap((OutputStream)null); }}); + private static void testNull(Base64.Encoder enc) { + checkNull(() -> enc.encode(ba_null)); + checkNull(() -> enc.encodeToString(ba_null)); + checkNull(() -> enc.encode(ba_null, new byte[10])); + checkNull(() -> enc.encode(new byte[10], ba_null)); + checkNull(() -> enc.encode(bb_null)); + checkNull(() -> enc.wrap((OutputStream)null)); } - private static void testNull(final Base64.Decoder dec) { - checkNull(new Runnable() { public void run() { dec.decode(ba_null); }}); - checkNull(new Runnable() { public void run() { dec.decode(str_null); }}); - checkNull(new Runnable() { public void run() { dec.decode(ba_null, new byte[10]); }}); - checkNull(new Runnable() { public void run() { dec.decode(new byte[10], ba_null); }}); - checkNull(new Runnable() { public void run() { dec.decode(bb_null); }}); - checkNull(new Runnable() { public void run() { dec.wrap((InputStream)null); }}); + private static void testNull(Base64.Decoder dec) { + checkNull(() -> dec.decode(ba_null)); + checkNull(() -> dec.decode(str_null)); + checkNull(() -> dec.decode(ba_null, new byte[10])); + checkNull(() -> dec.decode(new byte[10], ba_null)); + checkNull(() -> dec.decode(bb_null)); + checkNull(() -> dec.wrap((InputStream)null)); } + @FunctionalInterface private static interface Testable { public void test() throws Throwable; } - private static void testIOE(final Base64.Encoder enc) throws Throwable { + private static void testIOE(Base64.Encoder enc) throws Throwable { ByteArrayOutputStream baos = new ByteArrayOutputStream(8192); - final OutputStream os = enc.wrap(baos); + OutputStream os = enc.wrap(baos); os.write(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9}); os.close(); - checkIOE(new Testable() { public void test() throws Throwable { os.write(10); }}); - checkIOE(new Testable() { public void test() throws Throwable { os.write(new byte[] {10}); }}); - checkIOE(new Testable() { public void test() throws Throwable { os.write(new byte[] {10}, 1, 4); }}); + checkIOE(() -> os.write(10)); + checkIOE(() -> os.write(new byte[] {10})); + checkIOE(() -> os.write(new byte[] {10}, 1, 4)); } - private static void testIOE(final Base64.Decoder dec, byte[] decoded) throws Throwable { + private static void testIOE(Base64.Decoder dec, byte[] decoded) throws Throwable { ByteArrayInputStream bais = new ByteArrayInputStream(decoded); - final InputStream is = dec.wrap(bais); + InputStream is = dec.wrap(bais); is.read(new byte[10]); is.close(); - checkIOE(new Testable() { public void test() throws Throwable { is.read(); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.read(new byte[] {10}); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.read(new byte[] {10}, 1, 4); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.available(); }}); - checkIOE(new Testable() { public void test() throws Throwable { is.skip(20); }}); + checkIOE(() -> is.read()); + checkIOE(() -> is.read(new byte[] {10})); + checkIOE(() -> is.read(new byte[] {10}, 1, 4)); + checkIOE(() -> is.available()); + checkIOE(() -> is.skip(20)); } private static final void checkNull(Runnable r) { @@ -391,13 +405,13 @@ public class TestBase64 { int pos = (Integer)data[i + 2]; // decode(byte[]) - checkIAE(new Runnable() { public void run() { dec.decode(srcBytes); }}); + checkIAE(() -> dec.decode(srcBytes)); // decode(String) - checkIAE(new Runnable() { public void run() { dec.decode(srcStr); }}); + checkIAE(() -> dec.decode(srcStr)); // decode(ByteBuffer) - checkIAE(new Runnable() { public void run() { dec.decode(srcBB); }}); + checkIAE(() -> dec.decode(srcBB)); // wrap stream checkIOE(new Testable() { @@ -412,10 +426,8 @@ public class TestBase64 { // anything left after padding is "invalid"/IAE, if // not MIME. In case of MIME, non-base64 character(s) // is ignored. - checkIAE(new Runnable() { public void run() { - Base64.getDecoder().decode("AA==\u00D2"); }}); - checkIAE(new Runnable() { public void run() { - Base64.getUrlDecoder().decode("AA==\u00D2"); }}); + checkIAE(() -> Base64.getDecoder().decode("AA==\u00D2")); + checkIAE(() -> Base64.getUrlDecoder().decode("AA==\u00D2")); Base64.getMimeDecoder().decode("AA==\u00D2"); } @@ -516,4 +528,67 @@ public class TestBase64 { } return ret; } + + private static void testEncoderKeepsSilence(Base64.Encoder enc) + throws Throwable { + List vals = new ArrayList<>(List.of(Integer.MIN_VALUE, + Integer.MIN_VALUE + 1, -1111, -2, -1, 0, 1, 2, 3, 1111, + Integer.MAX_VALUE - 1, Integer.MAX_VALUE)); + vals.addAll(List.of(rnd.nextInt(), rnd.nextInt(), rnd.nextInt(), + rnd.nextInt())); + byte[] buf = new byte[] {1, 0, 91}; + for (int off : vals) { + for (int len : vals) { + if (off >= 0 && len >= 0 && off <= buf.length - len) { + // valid args, skip them + continue; + } + // invalid args, test them + System.out.println("testing off=" + off + ", len=" + len); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(100); + try (OutputStream os = enc.wrap(baos)) { + os.write(buf, off, len); + throw new RuntimeException("Expected IOOBEx was not thrown"); + } catch (IndexOutOfBoundsException expected) { + } + if (baos.size() > 0) + throw new RuntimeException("No output was expected, but got " + + baos.size() + " bytes"); + } + } + } + + private static void testDecoderKeepsAbstinence(Base64.Decoder dec) + throws Throwable { + List vals = new ArrayList<>(List.of(Integer.MIN_VALUE, + Integer.MIN_VALUE + 1, -1111, -2, -1, 0, 1, 2, 3, 1111, + Integer.MAX_VALUE - 1, Integer.MAX_VALUE)); + vals.addAll(List.of(rnd.nextInt(), rnd.nextInt(), rnd.nextInt(), + rnd.nextInt())); + byte[] buf = new byte[3]; + for (int off : vals) { + for (int len : vals) { + if (off >= 0 && len >= 0 && off <= buf.length - len) { + // valid args, skip them + continue; + } + // invalid args, test them + System.out.println("testing off=" + off + ", len=" + len); + + String input = "AAAAAAAAAAAAAAAAAAAAAA"; + ByteArrayInputStream bais = + new ByteArrayInputStream(input.getBytes("Latin1")); + try (InputStream is = dec.wrap(bais)) { + is.read(buf, off, len); + throw new RuntimeException("Expected IOOBEx was not thrown"); + } catch (IndexOutOfBoundsException expected) { + } + if (bais.available() != input.length()) + throw new RuntimeException("No input should be consumed, " + + "but consumed " + (input.length() - bais.available()) + + " bytes"); + } + } + } } diff --git a/jdk/test/java/util/Calendar/Bug4302966.java b/jdk/test/java/util/Calendar/Bug4302966.java index 6c3b9c3d60e..0dce8e2b367 100644 --- a/jdk/test/java/util/Calendar/Bug4302966.java +++ b/jdk/test/java/util/Calendar/Bug4302966.java @@ -24,6 +24,7 @@ /* * @test * @bug 4302966 + * @modules jdk.localedata * @summary In Czech Republic first day of week is Monday not Sunday */ diff --git a/jdk/test/java/util/Collection/MOAT.java b/jdk/test/java/util/Collection/MOAT.java index fe17c5034a3..f74a1785e26 100644 --- a/jdk/test/java/util/Collection/MOAT.java +++ b/jdk/test/java/util/Collection/MOAT.java @@ -112,7 +112,6 @@ public class MOAT { testCollection(Arrays.asList(1,2,3)); testCollection(nCopies(25,1)); testImmutableList(nCopies(25,1)); - testImmutableList(unmodifiableList(Arrays.asList(1,2,3))); testMap(new HashMap()); testMap(new LinkedHashMap()); @@ -134,6 +133,20 @@ public class MOAT { testMap(Collections.synchronizedSortedMap(new TreeMap())); testMap(Collections.synchronizedNavigableMap(new TreeMap())); + // Unmodifiable wrappers + testImmutableSet(unmodifiableSet(new HashSet<>(Arrays.asList(1,2,3)))); + testImmutableList(unmodifiableList(Arrays.asList(1,2,3))); + testImmutableMap(unmodifiableMap(Collections.singletonMap(1,2))); + testCollMutatorsAlwaysThrow(unmodifiableSet(new HashSet<>(Arrays.asList(1,2,3)))); + testCollMutatorsAlwaysThrow(unmodifiableSet(Collections.emptySet())); + testEmptyCollMutatorsAlwaysThrow(unmodifiableSet(Collections.emptySet())); + testListMutatorsAlwaysThrow(unmodifiableList(Arrays.asList(1,2,3))); + testListMutatorsAlwaysThrow(unmodifiableList(Collections.emptyList())); + testEmptyListMutatorsAlwaysThrow(unmodifiableList(Collections.emptyList())); + testMapMutatorsAlwaysThrow(unmodifiableMap(Collections.singletonMap(1,2))); + testMapMutatorsAlwaysThrow(unmodifiableMap(Collections.emptyMap())); + testEmptyMapMutatorsAlwaysThrow(unmodifiableMap(Collections.emptyMap())); + // Empty collections final List emptyArray = Arrays.asList(new Integer[]{}); testCollection(emptyArray); @@ -196,6 +209,8 @@ public class MOAT { // Immutable List testEmptyList(List.of()); + testListMutatorsAlwaysThrow(List.of()); + testEmptyListMutatorsAlwaysThrow(List.of()); for (List list : Arrays.asList( List.of(), List.of(1), @@ -211,10 +226,13 @@ public class MOAT { List.of(integerArray))) { testCollection(list); testImmutableList(list); + testListMutatorsAlwaysThrow(list); } // Immutable Set testEmptySet(Set.of()); + testCollMutatorsAlwaysThrow(Set.of()); + testEmptyCollMutatorsAlwaysThrow(Set.of()); for (Set set : Arrays.asList( Set.of(), Set.of(1), @@ -230,6 +248,7 @@ public class MOAT { Set.of(integerArray))) { testCollection(set); testImmutableSet(set); + testCollMutatorsAlwaysThrow(set); } // Immutable Map @@ -241,6 +260,8 @@ public class MOAT { } testEmptyMap(Map.of()); + testMapMutatorsAlwaysThrow(Map.of()); + testEmptyMapMutatorsAlwaysThrow(Map.of()); for (Map map : Arrays.asList( Map.of(), Map.of(1, 101), @@ -256,6 +277,7 @@ public class MOAT { Map.ofEntries(ea))) { testMap(map); testImmutableMap(map); + testMapMutatorsAlwaysThrow(map); } } @@ -358,6 +380,93 @@ public class MOAT { it.remove(); }); } + /** + * Test that calling a mutator always throws UOE, even if the mutator + * wouldn't actually do anything, given its arguments. + * + * @param c the collection instance to test + */ + private static void testCollMutatorsAlwaysThrow(Collection c) { + THROWS(UnsupportedOperationException.class, + () -> c.addAll(Collections.emptyList()), + () -> c.remove(ABSENT_VALUE), + () -> c.removeAll(Collections.emptyList()), + () -> c.removeIf(x -> false), + () -> c.retainAll(c)); + } + + /** + * Test that calling a mutator always throws UOE, even if the mutator + * wouldn't actually do anything on an empty collection. + * + * @param c the collection instance to test, must be empty + */ + private static void testEmptyCollMutatorsAlwaysThrow(Collection c) { + if (! c.isEmpty()) { + fail("collection is not empty"); + } + THROWS(UnsupportedOperationException.class, + () -> c.clear()); + } + + /** + * As above, for a list. + * + * @param c the list instance to test + */ + private static void testListMutatorsAlwaysThrow(List c) { + testCollMutatorsAlwaysThrow(c); + THROWS(UnsupportedOperationException.class, + () -> c.addAll(0, Collections.emptyList())); + } + + /** + * As above, for an empty list. + * + * @param c the list instance to test, must be empty + */ + private static void testEmptyListMutatorsAlwaysThrow(List c) { + if (! c.isEmpty()) { + fail("list is not empty"); + } + testEmptyCollMutatorsAlwaysThrow(c); + THROWS(UnsupportedOperationException.class, + () -> c.replaceAll(x -> x), + () -> c.sort(null)); + } + + /** + * As above, for a map. + * + * @param m the map instance to test + */ + private static void testMapMutatorsAlwaysThrow(Map m) { + THROWS(UnsupportedOperationException.class, + () -> m.compute(ABSENT_VALUE, (k, v) -> null), + () -> m.computeIfAbsent(ABSENT_VALUE, k -> null), + () -> m.computeIfPresent(ABSENT_VALUE, (k, v) -> null), + () -> m.merge(ABSENT_VALUE, 0, (k, v) -> null), + () -> m.putAll(Collections.emptyMap()), + () -> m.remove(ABSENT_VALUE), + () -> m.remove(ABSENT_VALUE, 0), + () -> m.replace(ABSENT_VALUE, 0), + () -> m.replace(ABSENT_VALUE, 0, 1)); + } + + /** + * As above, for an empty map. + * + * @param map the map instance to test, must be empty + */ + private static void testEmptyMapMutatorsAlwaysThrow(Map m) { + if (! m.isEmpty()) { + fail("map is not empty"); + } + THROWS(UnsupportedOperationException.class, + () -> m.clear(), + () -> m.replaceAll((k, v) -> v)); + } + private static void clear(Collection c) { try { c.clear(); } catch (Throwable t) { unexpected(t); } diff --git a/jdk/test/java/util/Date/Bug8135055.java b/jdk/test/java/util/Date/Bug8135055.java index b0d1c144caa..55bfd606141 100644 --- a/jdk/test/java/util/Date/Bug8135055.java +++ b/jdk/test/java/util/Date/Bug8135055.java @@ -24,6 +24,7 @@ /* * @test * @bug 8135055 + * @modules java.sql * @summary Test java.sql.TimeStamp instance should come after java.util.Date * if Nanos component of TimeStamp is not equal to 0 milliseconds. */ diff --git a/jdk/test/java/util/Formatter/FormatLocale.java b/jdk/test/java/util/Formatter/FormatLocale.java index 55aae027c6c..79aac6349a0 100644 --- a/jdk/test/java/util/Formatter/FormatLocale.java +++ b/jdk/test/java/util/Formatter/FormatLocale.java @@ -24,6 +24,7 @@ /** * @test * @bug 8146156 8159548 + * @modules jdk.localedata * @summary test whether uppercasing follows Locale.Category.FORMAT locale. * @run main/othervm FormatLocale */ diff --git a/jdk/test/java/util/Map/FunctionalCMEs.java b/jdk/test/java/util/Map/FunctionalCMEs.java index 6f92b018185..4d83d241c94 100644 --- a/jdk/test/java/util/Map/FunctionalCMEs.java +++ b/jdk/test/java/util/Map/FunctionalCMEs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.util.Arrays; import java.util.ConcurrentModificationException; import java.util.HashMap; diff --git a/jdk/test/java/util/Objects/CheckIndex.java b/jdk/test/java/util/Objects/CheckIndex.java index bcfa1d5b23d..594e806dcd0 100644 --- a/jdk/test/java/util/Objects/CheckIndex.java +++ b/jdk/test/java/util/Objects/CheckIndex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/jdk/test/java/util/PriorityQueue/NoNulls.java b/jdk/test/java/util/PriorityQueue/NoNulls.java index 5ef7c536c8a..f2e147a34b6 100644 --- a/jdk/test/java/util/PriorityQueue/NoNulls.java +++ b/jdk/test/java/util/PriorityQueue/NoNulls.java @@ -38,10 +38,8 @@ */ import java.util.ArrayList; -import java.util.Arrays; import java.util.Comparator; import java.util.Collection; -import java.util.Collections; import java.util.PriorityQueue; import java.util.SortedSet; import java.util.TreeSet; diff --git a/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java b/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java index 4e68a347af8..14db7ad2113 100644 --- a/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java +++ b/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java @@ -69,6 +69,7 @@ public class TestPermission { @Test public void runTest() throws Exception { int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "m1", "-m", "test/jdk.test.Main") .outputTo(System.out) .errorTo(System.out) diff --git a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java index a9084f3437b..ff6d1bc1726 100644 --- a/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java +++ b/jdk/test/java/util/ServiceLoader/modules/ServicesTest.java @@ -42,7 +42,7 @@ import static org.testng.Assert.*; * @test * @library /lib/testlibrary * @modules java.scripting - jdk.compiler + * jdk.compiler * @build ServicesTest CompilerUtils jdk.testlibrary.* * @run testng ServicesTest * @summary Tests ServiceLoader to locate service providers on the module path @@ -112,6 +112,7 @@ public class ServicesTest { public void runWithModulePath() throws Exception { int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), + "--add-modules", "bananascript", "-m", "test/test.Main", "BananaScriptEngine") .outputTo(System.out) @@ -131,6 +132,7 @@ public class ServicesTest { int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), "-cp", CLASSES_DIR.toString(), + "--add-modules", "bananascript", "-m", "test/test.Main", "BananaScriptEngine", "PearScriptEngine") .outputTo(System.out) diff --git a/jdk/test/java/util/TimeZone/HongKong.java b/jdk/test/java/util/TimeZone/HongKong.java index ef9c3f923f5..ead08f37387 100644 --- a/jdk/test/java/util/TimeZone/HongKong.java +++ b/jdk/test/java/util/TimeZone/HongKong.java @@ -24,6 +24,7 @@ /* * @test * @bug 4487276 8008577 + * @modules jdk.localedata * @summary Verify that Hong Kong locale uses traditional Chinese names. * @run main/othervm -Djava.locale.providers=COMPAT,SPI HongKong */ diff --git a/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java b/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java index 9154683995d..9d6f289634a 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.SplittableRandom; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CyclicBarrier; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedTransferQueue; diff --git a/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java b/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java b/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java b/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java index 96008fa67b2..bc6d7a99a72 100644 --- a/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java +++ b/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java @@ -43,7 +43,6 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedTransferQueue; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.Semaphore; -import java.util.concurrent.ThreadLocalRandom; @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) public class OfferRemoveLoops { diff --git a/jdk/test/java/util/concurrent/DelayQueue/Stress.java b/jdk/test/java/util/concurrent/DelayQueue/Stress.java index 5a25b077521..44a20fff936 100644 --- a/jdk/test/java/util/concurrent/DelayQueue/Stress.java +++ b/jdk/test/java/util/concurrent/DelayQueue/Stress.java @@ -22,7 +22,6 @@ */ import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; import java.util.concurrent.DelayQueue; import java.util.concurrent.Delayed; diff --git a/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java b/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java b/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java b/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java b/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java index f2e18f6d1bf..37cf4359580 100644 --- a/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java +++ b/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 diff --git a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java index 4aff18e2a25..23ce8bb0e95 100644 --- a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java +++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java @@ -33,7 +33,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import jdk.testlibrary.Utils; /** diff --git a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java index f78c8d854d3..87dfd6ed4bd 100644 --- a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java +++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java @@ -40,7 +40,6 @@ import static java.util.concurrent.TimeUnit.HOURS; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; import java.lang.reflect.Field; import java.util.concurrent.BlockingQueue; diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java index a7ff015bc77..71862dc8935 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java @@ -28,13 +28,13 @@ * @library /lib/testlibrary/ * @build jdk.testlibrary.RandomFactory * @run main/othervm ConfigChanges - * @key randomness intermittent + * @key randomness * @author Martin Buchholz */ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.MINUTES; -import static java.util.concurrent.TimeUnit.SECONDS; +import static java.util.concurrent.TimeUnit.NANOSECONDS; import java.security.Permission; import java.util.Random; @@ -44,7 +44,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.atomic.AtomicInteger; import jdk.testlibrary.RandomFactory; public class ConfigChanges { @@ -95,10 +94,10 @@ public class ConfigChanges { check(tpe.getQueue().isEmpty()); check(tpe.isTerminated()); check(! tpe.isTerminating()); - equal(tpe.getActiveCount(), 0); - equal(tpe.getPoolSize(), 0); + equal(0, tpe.getActiveCount()); + equal(0, tpe.getPoolSize()); equal(tpe.getTaskCount(), tpe.getCompletedTaskCount()); - check(tpe.awaitTermination(0L, SECONDS)); + check(tpe.awaitTermination(0L, MINUTES)); } catch (Throwable t) { unexpected(t); } } @@ -110,6 +109,21 @@ public class ConfigChanges { static volatile Runnable runnableDuJour; + static void awaitIdleness(ThreadPoolExecutor tpe, long taskCount) { + restart: for (;;) { + // check twice to make chance of race vanishingly small + for (int i = 0; i < 2; i++) { + if (tpe.getQueue().size() != 0 || + tpe.getActiveCount() != 0 || + tpe.getCompletedTaskCount() != taskCount) { + Thread.yield(); + continue restart; + } + } + return; + } + } + private static void realMain(String[] args) throws Throwable { if (rnd.nextBoolean()) System.setSecurityManager(new PermissiveSecurityManger()); @@ -137,8 +151,9 @@ public class ConfigChanges { if (prestart) { tpe.prestartAllCoreThreads(); - equal(tg.activeCount(), n); - equal(tg.activeCount(), tpe.getCorePoolSize()); + equal(n, tg.activeCount()); + equal(n, tpe.getCorePoolSize()); + equal(n, tpe.getLargestPoolSize()); } final Runnable runRunnableDuJour = @@ -153,7 +168,7 @@ public class ConfigChanges { tpe.execute(runRunnableDuJour); // Wait for prestarted threads to dequeue their initial tasks. while (! tpe.getQueue().isEmpty()) - Thread.sleep(10); + Thread.sleep(1); for (int i = 0; i < 5*n; i++) tpe.execute(runRunnableDuJour); } else { @@ -163,73 +178,76 @@ public class ConfigChanges { //report("submitted", tpe); pumpedUp.await(); - equal(tg.activeCount(), 3*n); - equal(tg.activeCount(), tpe.getMaximumPoolSize()); - equal(tpe.getCorePoolSize(), n); + equal(3*n, tg.activeCount()); + equal(3*n, tpe.getMaximumPoolSize()); + equal(3*n, tpe.getLargestPoolSize()); + equal(n, tpe.getCorePoolSize()); + equal(3*n, tpe.getActiveCount()); + equal(6L*n, tpe.getTaskCount()); + equal(0L, tpe.getCompletedTaskCount()); + //report("pumped up", tpe); - equal(tpe.getMaximumPoolSize(), 3*n); tpe.setMaximumPoolSize(4*n); - equal(tpe.getMaximumPoolSize(), 4*n); + equal(4*n, tpe.getMaximumPoolSize()); //report("pumped up2", tpe); final CyclicBarrier pumpedUp2 = new CyclicBarrier(n + 1); runnableDuJour = waiter(pumpedUp2); for (int i = 0; i < 1*n; i++) tpe.execute(runRunnableDuJour); pumpedUp2.await(); - equal(tg.activeCount(), 4*n); - equal(tg.activeCount(), tpe.getMaximumPoolSize()); - equal(tpe.getCompletedTaskCount(), 0L); + equal(4*n, tg.activeCount()); + equal(4*n, tpe.getMaximumPoolSize()); + equal(4*n, tpe.getLargestPoolSize()); + equal(4*n, tpe.getActiveCount()); + equal(7L*n, tpe.getTaskCount()); + equal(0L, tpe.getCompletedTaskCount()); //report("pumped up2", tpe); runnableDuJour = new Runnable() { public void run() {}}; tpe.setMaximumPoolSize(2*n); - //report("after set", tpe); + //report("after setMaximumPoolSize", tpe); pumpedUp2.await(); pumpedUp.await(); -// while (tg.activeCount() != n && -// tg.activeCount() != n) -// Thread.sleep(10); -// equal(tg.activeCount(), n); -// equal(tg.activeCount(), tpe.getCorePoolSize()); - while (tg.activeCount() != 2*n && tg.activeCount() != 2*n) - Thread.sleep(10); - equal(tg.activeCount(), 2*n); - equal(tg.activeCount(), tpe.getMaximumPoolSize()); + Thread.yield(); + equal(2*n, tg.activeCount()); + equal(2*n, tpe.getMaximumPoolSize()); + equal(4*n, tpe.getLargestPoolSize()); + //report("draining", tpe); + awaitIdleness(tpe, 7L*n); -//report("draining", tpe); - while (tpe.getCompletedTaskCount() < 7*n && - tpe.getCompletedTaskCount() < 7*n) - Thread.sleep(10); + equal(2*n, tg.activeCount()); + equal(2*n, tpe.getMaximumPoolSize()); + equal(4*n, tpe.getLargestPoolSize()); - //equal(tg.activeCount(), n); - //equal(tg.activeCount(), tpe.getCorePoolSize()); - equal(tg.activeCount(), 2*n); - equal(tg.activeCount(), tpe.getMaximumPoolSize()); + equal(7L*n, tpe.getTaskCount()); + equal(7L*n, tpe.getCompletedTaskCount()); + equal(0, tpe.getActiveCount()); - equal(tpe.getTaskCount(), 7L*n); - equal(tpe.getCompletedTaskCount(), 7L*n); - - equal(tpe.getKeepAliveTime(MINUTES), 3L); + equal(3L, tpe.getKeepAliveTime(MINUTES)); + long t0 = System.nanoTime(); tpe.setKeepAliveTime(7L, MILLISECONDS); - equal(tpe.getKeepAliveTime(MILLISECONDS), 7L); + equal(7L, tpe.getKeepAliveTime(MILLISECONDS)); while (tg.activeCount() > n && tg.activeCount() > n) - Thread.sleep(10); - equal(tg.activeCount(), n); + Thread.sleep(4); + equal(n, tg.activeCount()); + check(System.nanoTime() - t0 >= tpe.getKeepAliveTime(NANOSECONDS)); //report("idle", tpe); check(! tpe.allowsCoreThreadTimeOut()); + t0 = System.nanoTime(); tpe.allowCoreThreadTimeOut(true); check(tpe.allowsCoreThreadTimeOut()); while (tg.activeCount() > 0 && tg.activeCount() > 0) - Thread.sleep(10); + Thread.sleep(4); equal(tg.activeCount(), 0); + check(System.nanoTime() - t0 >= tpe.getKeepAliveTime(NANOSECONDS)); //report("idle", tpe); diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java index 5d10213dc99..1a51d583e20 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java @@ -40,7 +40,6 @@ */ import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java index 463d388b5da..007c52c8cb1 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java @@ -34,7 +34,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import jdk.testlibrary.Utils; public class TimeOutShrink { diff --git a/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java b/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java index d1a4fddbcd0..008ac062afb 100644 --- a/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java +++ b/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java @@ -22,7 +22,6 @@ */ import java.util.concurrent.atomic.AtomicReference; -import java.util.function.UnaryOperator; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java b/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java index 5a3db577ddd..24ffd259217 100644 --- a/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java +++ b/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java @@ -22,27 +22,35 @@ */ import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import jdk.testlibrary.Utils; /* * @test * @bug 8078490 * @summary Test submission and execution of task without joining + * @library /lib/testlibrary/ */ public class SubmissionTest { + static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000); + + static long millisElapsedSince(long startTime) { + return (System.nanoTime() - startTime) / (1000L * 1000L); + } + public static void main(String[] args) throws Throwable { final ForkJoinPool e = new ForkJoinPool(1); final AtomicBoolean b = new AtomicBoolean(); final Runnable setFalse = () -> b.set(false); - for (int i = 0; i < 100000; i++) { + for (int i = 0; i < 30_000; i++) { b.set(true); e.execute(setFalse); - long st = System.nanoTime(); + long startTime = System.nanoTime(); while (b.get()) { - if (System.nanoTime() - st >= TimeUnit.SECONDS.toNanos(10)) { + if (millisElapsedSince(startTime) >= LONG_DELAY_MS) { throw new RuntimeException("Submitted task failed to execute"); } + Thread.yield(); } } } diff --git a/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java b/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/locks/Lock/Mutex.java b/jdk/test/java/util/concurrent/locks/Lock/Mutex.java index 40bb16064a8..1a118f18a36 100644 --- a/jdk/test/java/util/concurrent/locks/Lock/Mutex.java +++ b/jdk/test/java/util/concurrent/locks/Lock/Mutex.java @@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.AbstractQueuedSynchronizer; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; -import java.util.concurrent.atomic.AtomicInteger; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java b/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java index 2d82c455574..dc204906551 100644 --- a/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java +++ b/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java @@ -43,7 +43,6 @@ import java.util.SplittableRandom; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.locks.LockSupport; diff --git a/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java b/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java index ed3d8719dff..3f664d54570 100644 --- a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java +++ b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java @@ -31,8 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.concurrent.atomic.AtomicLong; - /** * Misc utilities in JSR166 performance tests */ diff --git a/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java index 6d459372515..be721a7b128 100644 --- a/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java +++ b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java @@ -22,7 +22,6 @@ /* * @test - * @run main/othervm/timeout=60 ReadersUnlockAfterWriteUnlock * @bug 8023234 * @summary StampedLock serializes readers on writer unlock * @author Dmitry Chyuko @@ -30,26 +29,23 @@ */ import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.StampedLock; public class ReadersUnlockAfterWriteUnlock { - static final int RNUM = 2; - static final StampedLock sl = new StampedLock(); - static volatile boolean isDone; + public static void main(String[] args) throws InterruptedException { + final int RNUM = 2; + final int REPS = 128; + final StampedLock sl = new StampedLock(); + final AtomicReference bad = new AtomicReference<>(); - static CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1); - static CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM); - static CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1); + final CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1); + final CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM); + final CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1); - static class Reader extends Thread { - final String name; - Reader(String name) { - super(); - this.name = name; - } - public void run() { - while (!isDone && !isInterrupted()) { - try { + Runnable reader = () -> { + try { + for (int i = 0; i < REPS; i++) { iterationStart.await(); writerHasLock.await(); long rs = sl.readLock(); @@ -59,30 +55,45 @@ public class ReadersUnlockAfterWriteUnlock { readersHaveLocks.await(); sl.unlockRead(rs); - } catch (Exception e) { - throw new IllegalStateException(e); } + } catch (Throwable ex) { + ex.printStackTrace(); + bad.set(ex); } - } - } + }; - public static void main(String[] args) throws InterruptedException { - for (int r = 0 ; r < RNUM; ++r) { - new Reader("r" + r).start(); + Thread[] threads = new Thread[RNUM]; + for (int i = 0 ; i < RNUM; i++) { + Thread thread = new Thread(reader, "Reader"); + threads[i] = thread; + thread.start(); } - int i; - for (i = 0; i < 1024; ++i) { + for (int i = 0; i < REPS; i++) { try { iterationStart.await(); long ws = sl.writeLock(); writerHasLock.await(); - Thread.sleep(10); + awaitWaitState(threads); sl.unlockWrite(ws); } catch (Exception e) { throw new IllegalStateException(e); } } - isDone = true; + for (Thread thread : threads) + thread.join(); + if (bad.get() != null) + throw new AssertionError(bad.get()); } + static void awaitWaitState(Thread[] threads) { + restart: for (;;) { + for (Thread thread : threads) { + if (thread.getState() != Thread.State.WAITING) { + Thread.yield(); + continue restart; + } + } + break; + } + } } diff --git a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java index d074b140ba2..b7b20bdf6b0 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java +++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java @@ -31,7 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.Arrays; import java.util.concurrent.atomic.AtomicIntegerArray; import junit.framework.Test; diff --git a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java index 488b195e014..2011c789b91 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java +++ b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java @@ -31,7 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.Arrays; import java.util.concurrent.atomic.AtomicLongArray; import junit.framework.Test; diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java index 9ebec5b2ef6..44bcdbe281f 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java +++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java @@ -31,7 +31,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.Arrays; import java.util.concurrent.atomic.AtomicReferenceArray; import junit.framework.Test; diff --git a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java index 203fd812ec5..a29f50e0a24 100644 --- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java +++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java @@ -59,7 +59,6 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeoutException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiConsumer; diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java index 18695548129..fd62ada71cb 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java @@ -38,7 +38,6 @@ import static java.util.Spliterator.NONNULL; import java.util.AbstractMap; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java index e8be651d53d..c457f6b85f9 100644 --- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java +++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java index 21f932e09a3..db7536856fe 100644 --- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java +++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Set; diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java index 8be66850920..88ff1f33a99 100644 --- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java +++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java @@ -40,9 +40,12 @@ import java.util.concurrent.CountedCompleter; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiConsumer; +import java.util.function.Consumer; import junit.framework.Test; import junit.framework.TestSuite; @@ -1869,4 +1872,115 @@ public class CountedCompleterTest extends JSR166TestCase { testInvokeOnPool(singletonPool(), a); } + /** CountedCompleter class javadoc code sample, version 1. */ + public static void forEach1(E[] array, Consumer action) { + class Task extends CountedCompleter { + final int lo, hi; + Task(Task parent, int lo, int hi) { + super(parent); this.lo = lo; this.hi = hi; + } + + public void compute() { + if (hi - lo >= 2) { + int mid = (lo + hi) >>> 1; + // must set pending count before fork + setPendingCount(2); + new Task(this, mid, hi).fork(); // right child + new Task(this, lo, mid).fork(); // left child + } + else if (hi > lo) + action.accept(array[lo]); + tryComplete(); + } + } + new Task(null, 0, array.length).invoke(); + } + + /** CountedCompleter class javadoc code sample, version 2. */ + public static void forEach2(E[] array, Consumer action) { + class Task extends CountedCompleter { + final int lo, hi; + Task(Task parent, int lo, int hi) { + super(parent); this.lo = lo; this.hi = hi; + } + + public void compute() { + if (hi - lo >= 2) { + int mid = (lo + hi) >>> 1; + setPendingCount(1); // looks off by one, but correct! + new Task(this, mid, hi).fork(); // right child + new Task(this, lo, mid).compute(); // direct invoke + } else { + if (hi > lo) + action.accept(array[lo]); + tryComplete(); + } + } + } + new Task(null, 0, array.length).invoke(); + } + + /** CountedCompleter class javadoc code sample, version 3. */ + public static void forEach3(E[] array, Consumer action) { + class Task extends CountedCompleter { + final int lo, hi; + Task(Task parent, int lo, int hi) { + super(parent); this.lo = lo; this.hi = hi; + } + + public void compute() { + int n = hi - lo; + for (; n >= 2; n /= 2) { + addToPendingCount(1); + new Task(this, lo + n/2, lo + n).fork(); + } + if (n > 0) + action.accept(array[lo]); + propagateCompletion(); + } + } + new Task(null, 0, array.length).invoke(); + } + + /** CountedCompleter class javadoc code sample, version 4. */ + public static void forEach4(E[] array, Consumer action) { + class Task extends CountedCompleter { + final int lo, hi; + Task(Task parent, int lo, int hi) { + super(parent, 31 - Integer.numberOfLeadingZeros(hi - lo)); + this.lo = lo; this.hi = hi; + } + + public void compute() { + for (int n = hi - lo; n >= 2; n /= 2) + new Task(this, lo + n/2, lo + n).fork(); + action.accept(array[lo]); + propagateCompletion(); + } + } + if (array.length > 0) + new Task(null, 0, array.length).invoke(); + } + + void testRecursiveDecomposition( + BiConsumer> action) { + int n = ThreadLocalRandom.current().nextInt(8); + Integer[] a = new Integer[n]; + for (int i = 0; i < n; i++) a[i] = i + 1; + AtomicInteger ai = new AtomicInteger(0); + action.accept(a, (x) -> ai.addAndGet(x)); + assertEquals(n * (n + 1) / 2, ai.get()); + } + + /** + * Variants of divide-by-two recursive decomposition into leaf tasks, + * as described in the CountedCompleter class javadoc code samples + */ + public void testRecursiveDecomposition() { + testRecursiveDecomposition(CountedCompleterTest::forEach1); + testRecursiveDecomposition(CountedCompleterTest::forEach2); + testRecursiveDecomposition(CountedCompleterTest::forEach3); + testRecursiveDecomposition(CountedCompleterTest::forEach4); + } + } diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java index 8169d5fa5f6..d72d7dcc78f 100644 --- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java +++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java @@ -42,7 +42,6 @@ import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import junit.framework.Test; diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java index 6e4d00f3d0f..0ab6084b978 100644 --- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java +++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java @@ -40,7 +40,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java index ee991a21c80..b0fea9a0bfe 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java @@ -296,12 +296,11 @@ public class ForkJoinPool8Test extends JSR166TestCase { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); - final Thread myself = Thread.currentThread(); + final Thread currentThread = Thread.currentThread(); // test join() assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); assertNull(f.join()); Thread.interrupted(); assertEquals(21, f.result); @@ -310,8 +309,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { f = new FibAction(8); f.cancel(true); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); try { f.join(); shouldThrow(); @@ -323,8 +321,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { f = new FibAction(8); f.completeExceptionally(new FJException()); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); try { f.join(); shouldThrow(); @@ -336,8 +333,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { // test quietlyJoin() f = new FibAction(8); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); Thread.interrupted(); assertEquals(21, f.result); @@ -346,8 +342,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { f = new FibAction(8); f.cancel(true); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); Thread.interrupted(); checkCancelled(f); @@ -355,8 +350,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { f = new FibAction(8); f.completeExceptionally(new FJException()); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); Thread.interrupted(); checkCompletedAbnormally(f, f.getException()); diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java index 54e944b54d0..c1063da31aa 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java @@ -35,7 +35,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import java.util.Arrays; -import java.util.Collections; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java b/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java index c3e1c1802a5..807785aced6 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java @@ -35,9 +35,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; diff --git a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java index f6c3e2a930c..aaa97d8abcb 100644 --- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java +++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java @@ -1264,7 +1264,7 @@ public class JSR166TestCase extends TestCase { * Sleeps until the given time has elapsed. * Throws AssertionFailedError if interrupted. */ - void sleep(long millis) { + static void sleep(long millis) { try { delay(millis); } catch (InterruptedException fail) { diff --git a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java index 9ce68c34166..01bd92770b7 100644 --- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java +++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java @@ -285,12 +285,11 @@ public class RecursiveActionTest extends JSR166TestCase { RecursiveAction a = new CheckedRecursiveAction() { protected void realCompute() { FibAction f = new FibAction(8); - final Thread myself = Thread.currentThread(); + final Thread currentThread = Thread.currentThread(); // test join() assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); assertNull(f.join()); Thread.interrupted(); assertEquals(21, f.result); @@ -299,8 +298,7 @@ public class RecursiveActionTest extends JSR166TestCase { f = new FibAction(8); f.cancel(true); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); try { f.join(); shouldThrow(); @@ -312,8 +310,7 @@ public class RecursiveActionTest extends JSR166TestCase { f = new FibAction(8); f.completeExceptionally(new FJException()); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); try { f.join(); shouldThrow(); @@ -325,8 +322,7 @@ public class RecursiveActionTest extends JSR166TestCase { // test quietlyJoin() f = new FibAction(8); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); Thread.interrupted(); assertEquals(21, f.result); @@ -335,8 +331,7 @@ public class RecursiveActionTest extends JSR166TestCase { f = new FibAction(8); f.cancel(true); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); Thread.interrupted(); checkCancelled(f); @@ -344,8 +339,7 @@ public class RecursiveActionTest extends JSR166TestCase { f = new FibAction(8); f.completeExceptionally(new FJException()); assertSame(f, f.fork()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); Thread.interrupted(); checkCompletedAbnormally(f, f.getException()); @@ -385,22 +379,20 @@ public class RecursiveActionTest extends JSR166TestCase { public void realRun() throws InterruptedException { FibAction[] fibActions = sq.take(); FibAction f; - final Thread myself = Thread.currentThread(); + final Thread currentThread = Thread.currentThread(); // test join() ------------ f = fibActions[0]; assertFalse(ForkJoinTask.inForkJoinPool()); - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); assertNull(f.join()); assertTrue(Thread.interrupted()); assertEquals(21, f.result); checkCompletedNormally(f); f = fibActions[1]; - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); try { f.join(); shouldThrow(); @@ -410,8 +402,7 @@ public class RecursiveActionTest extends JSR166TestCase { } f = fibActions[2]; - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); try { f.join(); shouldThrow(); @@ -423,23 +414,20 @@ public class RecursiveActionTest extends JSR166TestCase { // test quietlyJoin() --------- f = fibActions[3]; - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); assertTrue(Thread.interrupted()); assertEquals(21, f.result); checkCompletedNormally(f); f = fibActions[4]; - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); assertTrue(Thread.interrupted()); checkCancelled(f); f = fibActions[5]; - myself.interrupt(); - assertTrue(myself.isInterrupted()); + currentThread.interrupt(); f.quietlyJoin(); assertTrue(Thread.interrupted()); assertTrue(f.getException() instanceof FJException); diff --git a/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java index ead869ed648..30cf187a64b 100644 --- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java +++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java @@ -44,7 +44,6 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Delayed; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; diff --git a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java index 53ebc5ea179..1cb2a472658 100644 --- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java +++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java @@ -45,7 +45,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; diff --git a/jdk/test/java/util/concurrent/tck/StampedLockTest.java b/jdk/test/java/util/concurrent/tck/StampedLockTest.java index 5ced6c93d4d..a03be993f88 100644 --- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java +++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java @@ -44,7 +44,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.StampedLock; import java.util.function.BiConsumer; -import java.util.function.Consumer; import java.util.function.Function; import junit.framework.Test; diff --git a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java index ab4c9e90438..d72f1af9f5c 100644 --- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java +++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java @@ -37,24 +37,14 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.Flow; import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.SubmissionPublisher; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.BiPredicate; -import java.util.stream.Stream; import junit.framework.Test; import junit.framework.TestSuite; -import static java.util.concurrent.Flow.Publisher; import static java.util.concurrent.Flow.Subscriber; import static java.util.concurrent.Flow.Subscription; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; public class SubmissionPublisherTest extends JSR166TestCase { diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java index 3959527af70..83a4f42412c 100644 --- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java +++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java @@ -44,7 +44,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java index 5df3c94b120..8a72586f3ae 100644 --- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java +++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java @@ -55,7 +55,6 @@ import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java index 4ea94150844..b620e2316ee 100644 --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java @@ -23,23 +23,29 @@ /* * @test - * @bug 8132734 8144062 + * @bug 8132734 8144062 8165723 * @summary Test the extended API and the aliasing additions in JarFile that * support multi-release jar files - * @library /lib/testlibrary/java/util/jar + * @library /lib/testlibrary/java/util/jar /lib/testlibrary/ * @build Compiler JarBuilder CreateMultiReleaseTestJars + * @build jdk.testlibrary.RandomFactory * @run testng MultiReleaseJarAPI */ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; +import java.util.Map; +import java.util.Random; import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import jdk.testlibrary.RandomFactory; + import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -48,12 +54,15 @@ import org.testng.annotations.Test; public class MultiReleaseJarAPI { + private static final Random RANDOM = RandomFactory.getRandom(); + String userdir = System.getProperty("user.dir","."); CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); File unversioned = new File(userdir, "unversioned.jar"); File multirelease = new File(userdir, "multi-release.jar"); File signedmultirelease = new File(userdir, "signed-multi-release.jar"); + @BeforeClass public void initialize() throws Exception { creator.compileEntries(); @@ -99,10 +108,35 @@ public class MultiReleaseJarAPI { testCustomMultiReleaseValue("true\r ", false); testCustomMultiReleaseValue("true\n true", false); testCustomMultiReleaseValue("true\r\n true", false); + + // generate "random" Strings to use as extra attributes, and + // verify that Multi-Release: true is always properly matched + for (int i = 0; i < 100; i++) { + byte[] keyBytes = new byte[RANDOM.nextInt(70) + 1]; + Arrays.fill(keyBytes, (byte)('a' + RANDOM.nextInt(24))); + byte[] valueBytes = new byte[RANDOM.nextInt(70) + 1]; + Arrays.fill(valueBytes, (byte)('a' + RANDOM.nextInt(24))); + + String key = new String(keyBytes, StandardCharsets.UTF_8); + String value = new String(valueBytes, StandardCharsets.UTF_8); + // test that Multi-Release: true anywhere in the manifest always + // return true + testCustomMultiReleaseValue("true", Map.of(key, value), true); + + // test that we don't get any false positives + testCustomMultiReleaseValue("false", Map.of(key, value), false); + } } - private void testCustomMultiReleaseValue(String value, boolean expected) throws Exception { - creator.buildCustomMultiReleaseJar("custom-mr.jar", value); + private void testCustomMultiReleaseValue(String value, boolean expected) + throws Exception { + testCustomMultiReleaseValue(value, Map.of(), expected); + } + + private void testCustomMultiReleaseValue(String value, + Map extraAttributes, boolean expected) + throws Exception { + creator.buildCustomMultiReleaseJar("custom-mr.jar", value, extraAttributes); File custom = new File(userdir, "custom-mr.jar"); try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Runtime.version())) { Assert.assertEquals(jf.isMultiRelease(), expected); diff --git a/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java b/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java index d63e619830a..d9b494741ab 100644 --- a/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java +++ b/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff --git a/jdk/test/java/util/logging/XMLFormatterDate.java b/jdk/test/java/util/logging/XMLFormatterDate.java index ee0eeb98b57..3b0d7029464 100644 --- a/jdk/test/java/util/logging/XMLFormatterDate.java +++ b/jdk/test/java/util/logging/XMLFormatterDate.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -21,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/jdk/test/java/util/logging/modules/GetResourceBundleTest.java b/jdk/test/java/util/logging/modules/GetResourceBundleTest.java index 8bf01eb654d..5c771b949e5 100644 --- a/jdk/test/java/util/logging/modules/GetResourceBundleTest.java +++ b/jdk/test/java/util/logging/modules/GetResourceBundleTest.java @@ -37,6 +37,7 @@ import static org.testng.Assert.*; * @bug 8129126 8136802 8137316 8137317 8136804 8139350 * @library /lib/testlibrary * @modules jdk.compiler + * java.logging * @build GetResourceBundleTest CompilerUtils jdk.testlibrary.ProcessTools * @run testng GetResourceBundleTest * @summary Tests Logger.getLogger + logger.getResourceBundle in an named/unnamed module, diff --git a/jdk/test/java/util/regex/PatternStreamTest.java b/jdk/test/java/util/regex/PatternStreamTest.java index 1f02e410321..9809ea20aef 100644 --- a/jdk/test/java/util/regex/PatternStreamTest.java +++ b/jdk/test/java/util/regex/PatternStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 diff --git a/jdk/test/java/util/zip/TestCRC32.java b/jdk/test/java/util/zip/TestCRC32.java index 68c15aed44b..15d919ddb61 100644 --- a/jdk/test/java/util/zip/TestCRC32.java +++ b/jdk/test/java/util/zip/TestCRC32.java @@ -1,6 +1,3 @@ - -import java.util.zip.CRC32; - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +21,8 @@ import java.util.zip.CRC32; * questions. */ +import java.util.zip.CRC32; + /** * @test @summary Check that CRC-32 returns the expected CRC value for the * string 123456789 diff --git a/jdk/test/java/util/zip/TestCRC32C.java b/jdk/test/java/util/zip/TestCRC32C.java index bb5ea0447c5..6adf260dbab 100644 --- a/jdk/test/java/util/zip/TestCRC32C.java +++ b/jdk/test/java/util/zip/TestCRC32C.java @@ -1,6 +1,3 @@ - -import java.util.zip.CRC32C; - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +21,8 @@ import java.util.zip.CRC32C; * questions. */ +import java.util.zip.CRC32C; + /** * @test @summary Check that CRC-32C returns the expected CRC value for the * string 123456789 diff --git a/jdk/test/java/util/zip/ZipFile/TestZipFile.java b/jdk/test/java/util/zip/ZipFile/TestZipFile.java index 515ed356c2b..25b87ff1242 100644 --- a/jdk/test/java/util/zip/ZipFile/TestZipFile.java +++ b/jdk/test/java/util/zip/ZipFile/TestZipFile.java @@ -8,7 +8,7 @@ * * 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 + * 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). * diff --git a/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java b/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java new file mode 100644 index 00000000000..5e9679cfe7f --- /dev/null +++ b/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2016, 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 8163258 + * @summary Test verifies that when we create our own ImageReaderSpi + * implementaion with MIMEType or FileSuffix as null, it should + * not throw NullPointerException when we call + * ImageIO.getReaderMIMETypes() or ImageIO.getReaderFileSuffixes(). + * @run main GetReaderWriterInfoNullTest + */ + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Iterator; +import java.util.Locale; +import javax.imageio.IIOException; +import javax.imageio.ImageReadParam; +import javax.imageio.ImageReader; +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.spi.ImageReaderSpi; +import javax.imageio.stream.ImageInputStream; +import javax.imageio.ImageIO; +import javax.imageio.spi.IIORegistry; + +class TestImageReaderSpi extends ImageReaderSpi { + + public TestImageReaderSpi(String[] FORMATNAMES, String[] SUFFIXES, + String[] MIMETYPES) { + super("J Duke", // vendor + "1.0", // version + FORMATNAMES, // format names + SUFFIXES, // file suffixes + MIMETYPES, // mimetypes + "readTest.TestImageReader", // reader class name + new Class[] { ImageInputStream.class }, // input types + null, // writer class names. + true, // supports native metadata, + null, // [no] native stream metadata format + null, // [no] native stream metadata class + null, // [no] native extra stream metadata format + null, // [no] native extra stream metadata class + true, // supports standard metadata, + null, // metadata format name, + null, // metadata format class name + null, // [no] extra image metadata format + null // [no] extra image metadata format class + ); + } + + @Override + public boolean canDecodeInput(Object source) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDescription(Locale locale) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ImageReader createReaderInstance(Object extension) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} + +class TestImageReader extends ImageReader { + + public TestImageReader(ImageReaderSpi originatingProvider) { + super(originatingProvider); + } + + @Override + public int getNumImages(boolean allowSearch) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getWidth(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHeight(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Iterator getImageTypes(int imageIndex) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IIOMetadata getStreamMetadata() throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IIOMetadata getImageMetadata(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BufferedImage read(int imageIndex, ImageReadParam param) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } +} +public class GetReaderWriterInfoNullTest { + static final String[] FORMATNAMES = {"readTest"}; + static final String[] SUFFIXES = {"readTest"}; + static final String[] MIMETYPES = {"readTest"}; + public static void main (String[] args) throws IIOException { + // Verify getReaderMIMETypes() behavior by keeping MIMEType as null. + TestImageReaderSpi mimeNullReadSpi = + new TestImageReaderSpi(FORMATNAMES, SUFFIXES, null); + IIORegistry.getDefaultInstance(). + registerServiceProvider(mimeNullReadSpi); + ImageIO.getReaderMIMETypes(); + IIORegistry.getDefaultInstance(). + deregisterServiceProvider(mimeNullReadSpi); + + /* + * Verify getReaderFileSuffixes() behavior by keeping + * file suffix as null. + */ + TestImageReaderSpi suffixNullReadSpi = + new TestImageReaderSpi(FORMATNAMES, null, MIMETYPES); + IIORegistry.getDefaultInstance(). + registerServiceProvider(suffixNullReadSpi); + ImageIO.getReaderFileSuffixes(); + IIORegistry.getDefaultInstance(). + deregisterServiceProvider(suffixNullReadSpi); + } +} + diff --git a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java index a50929e8a46..936a5e3af68 100644 --- a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java +++ b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8152183 + * @bug 8152183 8149562 * @author a.stepanov * @summary Some checks for TIFFField methods * @run main TIFFFieldTest @@ -455,8 +455,17 @@ public class TIFFFieldTest { TIFFTagSet ts = new TIFFTagSet(tags); boolean ok = false; - try { TIFFField.createFromMetadataNode(ts, null); } - catch (NullPointerException e) { ok = true; } + try { + TIFFField.createFromMetadataNode(ts, null); + } catch (IllegalArgumentException e) { + // createFromMetadataNode() formerly threw a NullPointerException + // if its Node parameter was null, but the specification has been + // modified to allow only IllegalArgumentExceptions, perhaps with + // a cause set. In the present invocation the cause would be set + // to a NullPointerException but this is not explicitly specified + // hence not verified here. + ok = true; + } check(ok, "can create TIFFField from a null node"); TIFFField f = new TIFFField(tag, v); diff --git a/jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java b/jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java new file mode 100644 index 00000000000..44a59113732 --- /dev/null +++ b/jdk/test/javax/management/remote/mandatory/connection/ObjectInputStreamWithLoaderNullCheckTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016, 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 8009560 + * @summary Test RMIConnector.ObjectInputStreamWithLoader constructor with + * null Class loader. The test expects a IllegalArgumentException + * thrown when constructor is invoked with null class loader as + * an argument. + * @author Amit Sapre + * @modules java.management + * @run clean ObjectInputStreamWithLoaderNullCheckTest + * @run build ObjectInputStreamWithLoaderNullCheckTest + * @run main ObjectInputStreamWithLoaderNullCheckTest + */ + +import java.lang.reflect.*; +import javax.management.remote.*; +import javax.management.remote.rmi.*; +import java.io.*; + +public class ObjectInputStreamWithLoaderNullCheckTest { + + private static Class innerClass; + + public static void main(String[] args) throws Exception { + + System.out.println(">> == ObjectInputStreamWithLoaderNullCheckTest started..."); + + try { + innerClass = Class.forName("javax.management.remote.rmi.RMIConnector$ObjectInputStreamWithLoader"); + Constructor ctor = innerClass.getDeclaredConstructor(InputStream.class,ClassLoader.class); + ctor.setAccessible(true); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutput objOut = new ObjectOutputStream(baos); + objOut.writeObject(new String("Serialize")); + objOut.close(); + baos.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + System.out.println(">> == Testing constructor with null class loader."); + Object obj = ctor.newInstance(bais,null); + + System.out.println(">> == Test case failed. No error occured"); + System.exit(1); + } catch (InvocationTargetException ex) { + Throwable cause = ex.getCause(); + System.out.println(">> == InvocationTargetException Cause message : " + cause.toString()); + if (cause instanceof IllegalArgumentException) { + System.out.println(">> == Test case Passed."); + } else { + System.out.println(">> == Test case Failed."); + ex.printStackTrace(); + System.exit(1); + } + } catch (Exception ex) { + System.out.println(">>> == Test case failed with error " + ex.getCause().getMessage()); + ex.printStackTrace(); + System.exit(1); + } + } +} diff --git a/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java b/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java index 3f91fc38085..50777b00220 100644 --- a/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java +++ b/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -115,9 +115,8 @@ public class DeadListenerTest { mbean.sendNotification(notif); // Make sure notifs are working normally. - long deadline = System.currentTimeMillis() + 2000; - while ((count1Val.get() != 1 || count2Val.get() != 1) && System.currentTimeMillis() < deadline) { - Thread.sleep(10); + while ((count1Val.get() != 1 || count2Val.get() != 1) ) { + Thread.sleep(20); } assertTrue("New value of count1 == 1", count1Val.get() == 1); assertTrue("Initial value of count2 == 1", count2Val.get() == 1); diff --git a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java index 4216da6f015..929f76869cf 100644 --- a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java +++ b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 5049012 + * @bug 5049012 8163922 * @summary Verify if PrintToFile option is disabled for flavors that do not * support Destination * @requires (os.family == "linux") @@ -30,6 +30,8 @@ */ import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.File; import javax.print.DocFlavor; import javax.print.PrintService; @@ -72,6 +74,9 @@ public class ServiceDialogValidateTest { defService = ServiceUI.printDialog(null, 100, 100, service, defService, flavor, prSet); + ServiceUI.printDialog(null, 100, 100, service, defService, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + new HashPrintRequestAttributeSet()); } /** @@ -87,7 +92,8 @@ public class ServiceDialogValidateTest { } catch (InterruptedException e) { if (!testPassed && testGeneratedInterrupt) { throw new RuntimeException("PrintToFile option is not disabled " - + "for flavors that do not support destination"); + + "for flavors that do not support destination and/or" + + " disabled for flavors that supports destination"); } } if (!testGeneratedInterrupt) { @@ -110,10 +116,15 @@ public class ServiceDialogValidateTest { private static void doTest(Runnable action) { String description = " Visual inspection of print dialog is required.\n" - + " A print dialog will be shown.\n " - + " Please verify Print-To-File option is disabled.\n" + + " 2 print dialog will be shown.\n " + + " Please verify Print-To-File option is disabled " + + " in the 1st print dialog.\n" + " Press Cancel to close the print dialog.\n" - + " If Print-To-File option is disabled, press PASS else press FAIL"; + + " Please verify Print-To-File option is enabled " + + " in 2nd print dialog\n" + + " Press Cancel to close the print dialog.\n" + + " If the print dialog's Print-to-File behaves as mentioned, " + + " press PASS else press FAIL"; final JDialog dialog = new JDialog(); dialog.setTitle("printSelectionTest"); @@ -148,6 +159,14 @@ public class ServiceDialogValidateTest { dialog.add(mainPanel); dialog.pack(); dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); } } diff --git a/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java b/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java index b35d687b7c0..ab17680cefc 100644 --- a/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java +++ b/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java @@ -22,13 +22,15 @@ */ /* * @test - * @bug 5080098 + * @bug 5080098 8164205 * @summary Verify if PageRanges option is disabled for Non service-formatted * flavors. * @run main/manual ServiceDlgPageRangeTest */ import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.PrintServiceLookup; diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java index e1a39d3c500..72a19c9e80a 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,7 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +56,13 @@ public class GetInputStream { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { @@ -76,7 +78,9 @@ public class GetInputStream { buff = new ModelByteBuffer(test_byte_array); byte[] b = new byte[test_byte_array.length]; - buff.getInputStream().read(b); + try (InputStream is = buff.getInputStream()) { + is.read(b); + } for (int j = 0; j < b.length; j++) if(b[i] != test_byte_array[i]) throw new RuntimeException("Byte array compare fails!"); diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java index b9928253678..829900f8ba9 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class GetRoot { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java index 734ed37b4ac..b589048ff98 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +55,13 @@ public class Load { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java index e912ee98698..5549393fcda 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -56,13 +57,13 @@ public class LoadAll { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java index edcef873e0a..801926a5c5e 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferByteArray { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java index 3d1ad726598..4c193b9e484 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferByteArrayIntInt { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java index 5a200045671..90b4be57bf2 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferFile { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java index d55466ae5e8..85f93bd852b 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferFileLongLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java index c4da3ad8183..659f33c66d0 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Available { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java index 2bfd5891953..4785d4097d0 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Close { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java index bcd8584834e..f8a3570aef7 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class MarkReset { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java index e505d0b9d96..41ed42e08fa 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class MarkSupported { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java index e8fb2818fca..523adf4eaca 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Read { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java index a847b56783b..ceb33fb25fd 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class ReadByte { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java index c8c0a0fe64d..1570df03fae 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class ReadByteIntInt { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java index 96ce0fef5e8..d80a1c6ada5 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Skip { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java index 14eba08157e..ad4dc48ea6e 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java index d6f9cd82521..75b7bbc45c2 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLongLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java index d59349ce709..df84eaf6601 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,6 +28,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLongLongBoolean { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java index 1c15fa3a176..8d8895f0266 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -28,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +55,13 @@ public class Unload { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java index 61ebd221659..2f0b1960c90 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,9 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +57,13 @@ public class WriteTo { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java index 01e3b7a26af..7e659d46499 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -30,6 +30,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -99,16 +101,15 @@ public class OpenStream { buffer_wave = new ModelByteBuffer(baos.toByteArray()); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(baos.toByteArray()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(baos.toByteArray()); + } buffer_wave_ondisk = new ModelByteBuffer(test_file); } static void tearDown() throws Exception { - if (!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void testOpenStream(ModelByteBufferWavetable wavetable) diff --git a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java index e32e7723db5..f61126bd609 100644 --- a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java +++ b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java @@ -26,6 +26,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -162,7 +164,7 @@ public final class FrameLengthAfterConversion { ais = AudioSystem.getAudioInputStream(temp); final long frameLength = ais.getFrameLength(); ais.close(); - temp.delete(); + Files.delete(Paths.get(temp.getAbsolutePath())); validate(frameLength); } catch (IllegalArgumentException | UnsupportedAudioFileException | IOException ignored) { diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java b/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java index 893205944c3..8b0d8993e87 100644 --- a/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java +++ b/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java @@ -27,6 +27,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -91,7 +93,6 @@ public final class WriteUnsupportedAudioFormat { } catch (final IOException e) { throw new RuntimeException(e); } - FILE.deleteOnExit(); for (final Boolean end : new boolean[]{false, true}) { for (final int sampleSize : sampleBits) { @@ -134,6 +135,7 @@ public final class WriteUnsupportedAudioFormat { } } } + Files.delete(Paths.get(FILE.getAbsolutePath())); } /** diff --git a/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java b/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java new file mode 100644 index 00000000000..9bf4065b099 --- /dev/null +++ b/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.SwingUtilities; + +/** + * @test + * @bug 8151303 + * @summary [macosx] [hidpi] JButton's low-res. icon is visible when clicking on it + * @run main/othervm PressedIconTest + * @run main/othervm -Dsun.java2d.uiScale=2 PressedIconTest + */ +public class PressedIconTest { + + private final static int IMAGE_SIZE = 300; + + private final static Color COLOR_1X = Color.RED; + private final static Color COLOR_2X = Color.BLUE; + private static JFrame frame; + private static volatile double scale = -1; + private static volatile int centerX; + private static volatile int centerY; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(() -> createAndShowGUI()); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + scale = frame.getGraphicsConfiguration().getDefaultTransform() + .getScaleX(); + Point location = frame.getLocation(); + Dimension size = frame.getSize(); + centerX = location.x + size.width / 2; + centerY = location.y + size.height / 2; + }); + robot.waitForIdle(); + + robot.mouseMove(centerX, centerY); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + Thread.sleep(100); + Color color = robot.getPixelColor(centerX, centerY); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + SwingUtilities.invokeAndWait(() -> frame.dispose()); + + if ((scale == 1 && !similar(color, COLOR_1X)) + || (scale == 2 && !similar(color, COLOR_2X))) { + throw new RuntimeException("Colors are different!"); + } + } + + private static void createAndShowGUI() { + frame = new JFrame(); + frame.setSize(IMAGE_SIZE, IMAGE_SIZE); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + + BufferedImage img1x = generateImage(1, COLOR_1X); + + BufferedImage img2x = generateImage(2, COLOR_2X); + BaseMultiResolutionImage mri = new BaseMultiResolutionImage( + new BufferedImage[]{img1x, img2x}); + Icon mrIcon = new ImageIcon(mri); + + JToggleButton button = new JToggleButton(); + button.setIcon(mrIcon); + panel.add(button, BorderLayout.CENTER); + + frame.getContentPane().add(panel); + frame.setVisible(true); + } + + private static boolean similar(Color c1, Color c2) { + return similar(c1.getRed(), c2.getRed()) + && similar(c1.getGreen(), c2.getGreen()) + && similar(c1.getBlue(), c2.getBlue()); + } + + private static boolean similar(int n, int m) { + return Math.abs(n - m) <= 50; + } + + private static BufferedImage generateImage(int scale, Color c) { + + int size = IMAGE_SIZE * scale; + BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); + Graphics g = img.createGraphics(); + g.setColor(c); + g.fillRect(0, 0, size, size); + g.dispose(); + return img; + } +} diff --git a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java index f7146318ad0..4c773c0f7b1 100644 --- a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java +++ b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java @@ -23,7 +23,7 @@ /* @test * @key headful - * @bug 8129940 8132770 8161470 + * @bug 8129940 8132770 8161470 8163169 * @summary JRadioButton should run custom FocusTraversalKeys for all LaFs * @run main FocusTraversal */ @@ -61,6 +61,7 @@ public class FocusTraversal { public static void main(String[] args) throws Exception { robot = new Robot(); + robot.setAutoDelay(100); robot.waitForIdle(); UIManager.LookAndFeelInfo[] lookAndFeelArray = UIManager.getInstalledLookAndFeels(); diff --git a/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java b/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java index d8146b61b09..3731bed23ea 100644 --- a/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java +++ b/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java @@ -22,9 +22,10 @@ */ /* @test - @bug 8057791 8160438 - @summary Selection in JList is drawn with wrong colors in Nimbus L&F - @run main bug8057791 + @key headful + @bug 8057791 8160438 8163161 + @summary Selection in JList is drawn with wrong colors in Nimbus L&F + @run main/timeout=500 bug8057791 */ import java.awt.Color; import java.awt.Font; diff --git a/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java b/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java index f3308c480e6..aff92170577 100644 --- a/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java +++ b/jdk/test/jdk/internal/ref/Cleaner/ExitOnThrow.java @@ -24,7 +24,7 @@ /* * @test * @bug 4954921 8009259 - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.ref * java.base/jdk.internal.misc * @build jdk.test.lib.* diff --git a/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java index 672b7c2d205..504472f1f7e 100644 --- a/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java +++ b/jdk/test/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java @@ -88,31 +88,35 @@ public class CreateMultiReleaseTestJars { } public void buildMultiReleaseJar() throws IOException { - buildCustomMultiReleaseJar("multi-release.jar", "true"); - } - - public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue) throws IOException { - JarBuilder jb = new JarBuilder(filename); - jb.addAttribute("Multi-Release", multiReleaseValue); - jb.addEntry("README", readme8.getBytes()); - jb.addEntry("version/Main.java", main.getBytes()); - jb.addEntry("version/Main.class", rootClasses.get("version.Main")); - jb.addEntry("version/Version.java", java8.getBytes()); - jb.addEntry("version/Version.class", rootClasses.get("version.Version")); - jb.addEntry("META-INF/versions/9/README", readme9.getBytes()); - jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes()); - jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes()); + JarBuilder jb = customMultiReleaseJar("multi-release.jar", "true"); + addEntries(jb); jb.addEntry("META-INF/versions/9/version/Version.class", version9Classes.get("version.Version")); - jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate")); - jb.addEntry("META-INF/versions/10/README", readme10.getBytes()); - jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes()); - jb.addEntry("META-INF/versions/10/version/Version.class", version10Classes.get("version.Version")); jb.build(); } public void buildShortMultiReleaseJar() throws IOException { - JarBuilder jb = new JarBuilder("short-multi-release.jar"); - jb.addAttribute("Multi-Release", "true"); + JarBuilder jb = customMultiReleaseJar("short-multi-release.jar", "true"); + addEntries(jb); + jb.build(); + } + + private JarBuilder customMultiReleaseJar(String filename, String multiReleaseValue) + throws IOException { + JarBuilder jb = new JarBuilder(filename); + jb.addAttribute("Multi-Release", multiReleaseValue); + return jb; + } + + public void buildCustomMultiReleaseJar(String filename, String multiReleaseValue, + Map extraAttributes) throws IOException { + JarBuilder jb = new JarBuilder(filename); + extraAttributes.entrySet() + .forEach(entry -> jb.addAttribute(entry.getKey(), entry.getValue())); + jb.addAttribute("Multi-Release", multiReleaseValue); + jb.build(); + } + + private void addEntries(JarBuilder jb) { jb.addEntry("README", readme8.getBytes()); jb.addEntry("version/Main.java", main.getBytes()); jb.addEntry("version/Main.class", rootClasses.get("version.Main")); @@ -121,12 +125,10 @@ public class CreateMultiReleaseTestJars { jb.addEntry("META-INF/versions/9/README", readme9.getBytes()); jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes()); jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes()); - // no entry for META-INF/versions/9/version/Version.class jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate")); jb.addEntry("META-INF/versions/10/README", readme10.getBytes()); jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes()); jb.addEntry("META-INF/versions/10/version/Version.class", version10Classes.get("version.Version")); - jb.build(); } public void buildSignedMultiReleaseJar() throws Exception { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java index 594b12e3ede..621885ae50c 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Asserts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,7 @@ import java.util.Objects; * * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public class Asserts { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java index c4815229eb7..7b16a600d78 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import java.nio.file.Paths; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public final class JDKToolFinder { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java index 777e8cf5336..cd3b7cea022 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -46,7 +46,7 @@ import java.util.List; * } * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public class JDKToolLauncher { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java index 839c3228294..1a641efde90 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -36,7 +36,7 @@ import java.util.regex.Pattern; * Utility class for verifying output and exit value from a {@code Process}. * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} * */ @Deprecated diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java index c8a5d7aab12..9759f22b9e9 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -30,7 +30,7 @@ import java.util.concurrent.Future; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} */ @Deprecated class OutputBuffer { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java index 635f37f0b82..59b6d7c04c9 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java @@ -29,7 +29,7 @@ import java.io.IOException; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public class Platform { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java index e2c2f110fc5..224ab0e067d 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,7 +43,7 @@ import java.util.stream.Collectors; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} */ @Deprecated public final class ProcessTools { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java b/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java index 2f3c205db3c..1107563738f 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean; /** * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib/process} + * {@code /test/lib/jdk/test/lib/process} */ @Deprecated public final class StreamPumper implements Runnable { diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java index c76339107c8..31008f554f2 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,7 +43,7 @@ import java.util.function.Function; * Common library for various test helper functions. * * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/share/classes/jdk/test/lib} + * {@code /test/lib/jdk/test/lib} */ @Deprecated public final class Utils { diff --git a/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java b/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java index 826edfb4e58..3d521ad5bc5 100644 --- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java +++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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 @@ -42,7 +42,7 @@ import sun.jvmstat.monitor.VmIdentifier; * @summary setInterval() for local MonitoredHost and local MonitoredVm * @modules jdk.jvmstat/sun.jvmstat.monitor * @library /lib/testlibrary - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* * @run main TestPollingInterval diff --git a/jdk/test/sun/misc/SunMiscSignalTest.java b/jdk/test/sun/misc/SunMiscSignalTest.java index 2e998ba8d77..33d4d3ac41c 100644 --- a/jdk/test/sun/misc/SunMiscSignalTest.java +++ b/jdk/test/sun/misc/SunMiscSignalTest.java @@ -43,7 +43,7 @@ import sun.misc.SignalHandler; /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules jdk.unsupported * java.base/jdk.internal.misc * @build jdk.test.lib.Platform jdk.test.lib.Utils diff --git a/jdk/test/sun/security/krb5/auto/Unreachable.java b/jdk/test/sun/security/krb5/auto/Unreachable.java index b010b54837e..fdc1aa2ee25 100644 --- a/jdk/test/sun/security/krb5/auto/Unreachable.java +++ b/jdk/test/sun/security/krb5/auto/Unreachable.java @@ -23,31 +23,108 @@ /* * @test - * @bug 7162687 + * @bug 7162687 8015595 * @key intermittent * @summary enhance KDC server availability detection * @compile -XDignore.symbol.file Unreachable.java - * @run main/othervm/timeout=10 Unreachable + * @run main/othervm Unreachable */ - -import java.io.File; +import java.net.PortUnreachableException; +import java.net.SocketTimeoutException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetSocketAddress; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.Executors; import javax.security.auth.login.LoginException; import sun.security.krb5.Config; public class Unreachable { - public static void main(String[] args) throws Exception { - File f = new File( - System.getProperty("test.src", "."), "unreachable.krb5.conf"); - System.setProperty("java.security.krb5.conf", f.getPath()); - Config.refresh(); + // Wait for 20 second until unreachable KDC throws PortUnreachableException. + private static final int TIMEOUT = 20; + private static final String REALM = "RABBIT.HOLE"; + private static final String HOST = "127.0.0.1"; + private static final int PORT = 13434; + private static final String KRB_CONF = "unreachable.krb5.conf"; - // If PortUnreachableException is not received, the login will consume - // about 3*3*30 seconds and the test will timeout. + public static void main(String[] args) throws Exception { + + // - Only PortUnreachableException will allow to continue execution. + // - SocketTimeoutException may occur on Mac because it will not throw + // PortUnreachableException for unreachable port in which case the Test + // execution will be skipped. + // - For Reachable port, the Test execution will get skipped. + // - Any other Exception will be treated as Test failure. + if (!findPortUnreachableExc()) { + System.out.println(String.format("WARNING: Either a reachable " + + "connection found to %s:%s or SocketTimeoutException " + + "occured which means PortUnreachableException not thrown" + + " by the platform.", HOST, PORT)); + return; + } + KDC kdc = KDC.existing(REALM, HOST, PORT); + KDC.saveConfig(KRB_CONF, kdc); + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future future = executor.submit(new Callable() { + @Override + public Exception call() { + System.setProperty("java.security.krb5.conf", KRB_CONF); + try { + Config.refresh(); + // If PortUnreachableException is not received, the login + // will consume about 3*3*30 seconds and the test will + // timeout. + try { + Context.fromUserPass("name", "pass".toCharArray(), true); + } catch (LoginException le) { + // This is OK + } + System.out.println("Execution successful."); + } catch (Exception e) { + return e; + } + return null; + } + }); try { - Context.fromUserPass("name", "pass".toCharArray(), true); - } catch (LoginException le) { - // This is OK + Exception ex = null; + if ((ex = future.get(TIMEOUT, TimeUnit.SECONDS)) != null) { + throw new RuntimeException(ex); + } + } catch (TimeoutException e) { + future.cancel(true); + throw new RuntimeException("PortUnreachableException not thrown."); + } finally { + executor.shutdownNow(); } } + + /** + * If the remote destination to which the socket is connected does not + * exist, or is otherwise unreachable, and if an ICMP destination unreachable + * packet has been received for that address, then a subsequent call to + * send or receive may throw a PortUnreachableException. Note, there is no + * guarantee that the exception will be thrown. + */ + private static boolean findPortUnreachableExc() throws Exception { + try { + InetSocketAddress iaddr = new InetSocketAddress(HOST, PORT); + DatagramSocket dgSocket = new DatagramSocket(); + dgSocket.setSoTimeout(5000); + dgSocket.connect(iaddr); + byte[] data = new byte[]{}; + dgSocket.send(new DatagramPacket(data, data.length, iaddr)); + dgSocket.receive(new DatagramPacket(data, data.length)); + } catch (PortUnreachableException e) { + return true; + } catch (SocketTimeoutException e) { + return false; + } + return false; + } } diff --git a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf b/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf deleted file mode 100644 index 8ff4cc173aa..00000000000 --- a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf +++ /dev/null @@ -1,9 +0,0 @@ -[libdefaults] - default_realm = RABBIT.HOLE -[realms] - -RABBIT.HOLE = { - kdc = 127.0.0.1:13434 - kdc = 127.0.0.1:13435 - kdc = 127.0.0.1:13436 -} diff --git a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java index 48361f225d5..0cdce177b1e 100644 --- a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java +++ b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.security.SecureRandom; import java.security.Security; @@ -27,15 +28,15 @@ import java.security.Security; * @test * @bug 8051408 * @summary make sure nextBytes etc can be called before setSeed + * @run main/othervm -Djava.security.egd=file:/dev/urandom AutoReseed */ public class AutoReseed { public static void main(String[] args) throws Exception { SecureRandom sr; - String old = Security.getProperty("securerandom.drbg.config"); - try { - for (String mech : - new String[]{"Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + boolean pass = true; + for (String mech : new String[]{"Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + try { System.out.println("Testing " + mech + "..."); Security.setProperty("securerandom.drbg.config", mech); @@ -46,9 +47,13 @@ public class AutoReseed { sr.reseed(); sr = SecureRandom.getInstance("DRBG"); sr.generateSeed(10); + } catch (Exception e) { + pass = false; + e.printStackTrace(System.out); } - } finally { - Security.setProperty("securerandom.drbg.config", old); + } + if (!pass) { + throw new RuntimeException("At least one test case failed"); } } } diff --git a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java index b812ba5f60e..b10431b6444 100644 --- a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java +++ b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java @@ -30,12 +30,13 @@ /* * @test - * @bug 7113275 + * @bug 7113275 8164846 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * @run main/othervm TrustTrustedCert PKIX TLSv1.1 - * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 - * @run main/othervm TrustTrustedCert PKIX TLSv1.2 - * @run main/othervm TrustTrustedCert SunX509 TLSv1.2 + * @run main/othervm TrustTrustedCert PKIX TLSv1.1 true + * @run main/othervm TrustTrustedCert PKIX TLSv1.1 false + * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 false + * @run main/othervm TrustTrustedCert PKIX TLSv1.2 false + * @run main/othervm TrustTrustedCert SunX509 TLSv1.2 false */ import java.net.*; @@ -181,23 +182,32 @@ public class TrustTrustedCert { Thread.sleep(50); } - SSLContext context = generateSSLContext(); - SSLSocketFactory sslsf = context.getSocketFactory(); + SSLSocket sslSocket = null; + try { + SSLContext context = generateSSLContext(); + SSLSocketFactory sslsf = context.getSocketFactory(); - SSLSocket sslSocket = - (SSLSocket)sslsf.createSocket("localhost", serverPort); + sslSocket = (SSLSocket)sslsf.createSocket("localhost", serverPort); - // enable the specified TLS protocol - sslSocket.setEnabledProtocols(new String[] {tlsProtocol}); + // enable the specified TLS protocol + sslSocket.setEnabledProtocols(new String[] {tlsProtocol}); - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - sslOS.write('B'); - sslOS.flush(); - sslIS.read(); - - sslSocket.close(); + InputStream sslIS = sslSocket.getInputStream(); + OutputStream sslOS = sslSocket.getOutputStream(); + sslOS.write('B'); + sslOS.flush(); + sslIS.read(); + } catch (SSLHandshakeException e) { + // focus in on the CertPathValidatorException + Throwable t = e.getCause().getCause(); + if ((t == null) || (expectFail && + !t.toString().contains("MD5withRSA"))) { + throw new RuntimeException( + "Expected to see MD5withRSA in exception output " + t); + } + } finally { + if (sslSocket != null) sslSocket.close(); + } } /* @@ -206,10 +216,13 @@ public class TrustTrustedCert { */ private static String tmAlgorithm; // trust manager private static String tlsProtocol; // trust manager + // set this flag to test context of CertificateException + private static boolean expectFail; private static void parseArguments(String[] args) { tmAlgorithm = args[0]; tlsProtocol = args[1]; + expectFail = Boolean.parseBoolean(args[2]); } private static SSLContext generateSSLContext() throws Exception { @@ -232,7 +245,7 @@ public class TrustTrustedCert { // generate the private key. PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(targetPrivateKey)); + Base64.getMimeDecoder().decode(targetPrivateKey)); KeyFactory kf = KeyFactory.getInstance("RSA"); RSAPrivateKey priKey = (RSAPrivateKey)kf.generatePrivate(priKeySpec); @@ -338,20 +351,25 @@ public class TrustTrustedCert { volatile Exception clientException = null; public static void main(String[] args) throws Exception { - // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty("jdk.certpath.disabledAlgorithms", + /* + * Get the customized arguments. + */ + parseArguments(args); + + /* + * MD5 is used in this test case, don't disable MD5 algorithm. + * if expectFail is set, we're testing exception message + */ + if (!expectFail) { + Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + } Security.setProperty("jdk.tls.disabledAlgorithms", "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); - /* - * Get the customized arguments. - */ - parseArguments(args); - /* * Start the tests. */ @@ -376,7 +394,8 @@ public class TrustTrustedCert { startServer(false); } } catch (Exception e) { - // swallow for now. Show later + System.out.println("Unexpected exception: "); + e.printStackTrace(); } /* @@ -440,7 +459,11 @@ public class TrustTrustedCert { */ System.err.println("Server died..."); serverReady = true; - serverException = e; + if (!expectFail) { + // only record if we weren't expecting. + // client side will record exception + serverException = e; + } } } }; @@ -449,7 +472,11 @@ public class TrustTrustedCert { try { doServerSide(); } catch (Exception e) { - serverException = e; + // only record if we weren't expecting. + // client side will record exception + if (!expectFail) { + serverException = e; + } } finally { serverReady = true; } diff --git a/jdk/test/sun/security/tools/jarsigner/AltProvider.java b/jdk/test/sun/security/tools/jarsigner/AltProvider.java index b93455670b9..2717ef9e22e 100644 --- a/jdk/test/sun/security/tools/jarsigner/AltProvider.java +++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.java @@ -25,7 +25,7 @@ * @test * @bug 4906940 8130302 * @summary -providerPath, -providerClass, -addprovider, and -providerArg - * @library /lib/testlibrary /test/lib/share/classes + * @library /lib/testlibrary /test/lib * @modules java.base/jdk.internal.misc */ diff --git a/jdk/test/sun/text/resources/Collator/Bug4248694.java b/jdk/test/sun/text/resources/Collator/Bug4248694.java index b9339744f7e..a22ffa2ae3c 100644 --- a/jdk/test/sun/text/resources/Collator/Bug4248694.java +++ b/jdk/test/sun/text/resources/Collator/Bug4248694.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,11 +24,13 @@ /* * @test * @bug 4248694 + * @modules jdk.localedata * @summary updating collation tables for icelandic */ -import java.text.*; -import java.util.*; +import java.text.Collator; +import java.util.Arrays; +import java.util.Locale; public class Bug4248694 { diff --git a/jdk/test/sun/text/resources/Collator/Bug4804273.java b/jdk/test/sun/text/resources/Collator/Bug4804273.java index 0d60f3062e7..200280b3dab 100644 --- a/jdk/test/sun/text/resources/Collator/Bug4804273.java +++ b/jdk/test/sun/text/resources/Collator/Bug4804273.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,11 +24,13 @@ /* * @test * @bug 4804273 + * @modules jdk.localedata * @summary updating collation tables for swedish */ -import java.text.*; -import java.util.*; +import java.text.Collator; +import java.util.Arrays; +import java.util.Locale; public class Bug4804273 { diff --git a/jdk/test/sun/text/resources/Collator/Bug6755060.java b/jdk/test/sun/text/resources/Collator/Bug6755060.java index ee23487d44b..88b3d849a02 100644 --- a/jdk/test/sun/text/resources/Collator/Bug6755060.java +++ b/jdk/test/sun/text/resources/Collator/Bug6755060.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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,11 +24,13 @@ /* * @test * @bug 6755060 + * @modules jdk.localedata * @summary updating collation tables for thai to make it consistent with CLDR 1.9 */ -import java.text.*; -import java.util.*; +import java.text.Collator; +import java.util.Arrays; +import java.util.Locale; public class Bug6755060 { diff --git a/jdk/test/sun/text/resources/Format/Bug4395196.java b/jdk/test/sun/text/resources/Format/Bug4395196.java index a36a140aa02..f73f7f17a88 100644 --- a/jdk/test/sun/text/resources/Format/Bug4395196.java +++ b/jdk/test/sun/text/resources/Format/Bug4395196.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,15 +22,18 @@ */ /* - *@test - *@bug 4395196 4930708 4900884 4890240 8008577 - *@summary verify the ko DateFormat - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug4395196 -*/ + * @test + * @bug 4395196 4930708 4900884 4890240 8008577 + * @modules jdk.localedata + * @summary verify the ko DateFormat + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4395196 + */ -import java.io.*; -import java.text.*; -import java.util.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; public class Bug4395196 { diff --git a/jdk/test/sun/text/resources/Format/Bug4442855.java b/jdk/test/sun/text/resources/Format/Bug4442855.java index 6b3c1954bb8..fbc344ec050 100644 --- a/jdk/test/sun/text/resources/Format/Bug4442855.java +++ b/jdk/test/sun/text/resources/Format/Bug4442855.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,14 +22,16 @@ */ /* - *@test - *@bug 4442855 - *@summary verify the era's translation for tradition chinese + * @test + * @bug 4442855 + * @modules jdk.localedata + * @summary verify the era's translation for tradition chinese */ -import java.io.*; -import java.util.*; -import java.text.*; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; public class Bug4442855 { diff --git a/jdk/test/sun/text/resources/Format/Bug4621320.java b/jdk/test/sun/text/resources/Format/Bug4621320.java index 2555dbfffbb..1331fb72616 100644 --- a/jdk/test/sun/text/resources/Format/Bug4621320.java +++ b/jdk/test/sun/text/resources/Format/Bug4621320.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,10 +24,12 @@ /* * @test * @bug 4621320 + * @modules jdk.localedata * @summary Verify that Ukrainian month name is correct. */ -import java.text.*; -import java.util.*; + +import java.text.DateFormatSymbols; +import java.util.Locale; public class Bug4621320 { diff --git a/jdk/test/sun/text/resources/Format/Bug4651568.java b/jdk/test/sun/text/resources/Format/Bug4651568.java index c5b4ababa6f..354e3926e28 100644 --- a/jdk/test/sun/text/resources/Format/Bug4651568.java +++ b/jdk/test/sun/text/resources/Format/Bug4651568.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,10 +22,11 @@ */ /* - *@test - *@bug 4651568 8008577 - *@summary Verifies the currency pattern for pt_BR locale - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug4651568 + * @test + * @bug 4651568 8008577 + * @modules jdk.localedata + * @summary Verifies the currency pattern for pt_BR locale + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4651568 */ import java.text.DecimalFormat; diff --git a/jdk/test/sun/text/resources/Format/Bug4762201.java b/jdk/test/sun/text/resources/Format/Bug4762201.java index 78dfce9e42c..83863d25894 100644 --- a/jdk/test/sun/text/resources/Format/Bug4762201.java +++ b/jdk/test/sun/text/resources/Format/Bug4762201.java @@ -22,15 +22,17 @@ */ /* - *@test - *@bug 4762201 - *@summary verify the zh_CN full time pattern (and other time patterns) - *@run main/othervm -Djava.locale.providers=COMPAT,SPI Bug4762201 -*/ + * @test + * @bug 4762201 + * @modules jdk.localedata + * @summary verify the zh_CN full time pattern (and other time patterns) + * @run main/othervm -Djava.locale.providers=COMPAT,SPI Bug4762201 + */ -import java.io.*; -import java.text.*; -import java.util.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; public class Bug4762201 { diff --git a/jdk/test/sun/text/resources/Format/Bug4807540.java b/jdk/test/sun/text/resources/Format/Bug4807540.java index fc6a4922faa..972b8fc5b63 100644 --- a/jdk/test/sun/text/resources/Format/Bug4807540.java +++ b/jdk/test/sun/text/resources/Format/Bug4807540.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +24,7 @@ /* * @test %i% * @bug 4807540 8008577 + * @modules jdk.localedata * @summary updating dateformat for sl_SI * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4807540 */ diff --git a/jdk/test/sun/text/resources/Format/Bug4810032.java b/jdk/test/sun/text/resources/Format/Bug4810032.java index ccfe357f552..2da7742abc8 100644 --- a/jdk/test/sun/text/resources/Format/Bug4810032.java +++ b/jdk/test/sun/text/resources/Format/Bug4810032.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,14 +22,16 @@ */ /* - *@test - *@bug 4810032 8008577 - *@summary verify the ja full time pattern parsing + * @test + * @bug 4810032 8008577 + * @modules jdk.localedata + * @summary verify the ja full time pattern parsing * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4810032 */ -import java.text.*; -import java.util.*; +import java.text.DateFormat; +import java.text.ParseException; +import java.util.Locale; public class Bug4810032 { diff --git a/jdk/test/sun/text/resources/Format/Bug4994312.java b/jdk/test/sun/text/resources/Format/Bug4994312.java index 401dde809e8..691923e914b 100644 --- a/jdk/test/sun/text/resources/Format/Bug4994312.java +++ b/jdk/test/sun/text/resources/Format/Bug4994312.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,9 +22,10 @@ */ /* - *@test - *@bug 4994312 8008577 - *@summary verify the German locale will accept localized pattern chars 't' and 'u'. + * @test + * @bug 4994312 8008577 + * @modules jdk.localedata + * @summary verify the German locale will accept localized pattern chars 't' and 'u'. * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4994312 */ diff --git a/jdk/test/sun/text/resources/Format/Bug5096553.java b/jdk/test/sun/text/resources/Format/Bug5096553.java index 661a38e24b1..a3f377feaff 100644 --- a/jdk/test/sun/text/resources/Format/Bug5096553.java +++ b/jdk/test/sun/text/resources/Format/Bug5096553.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +24,7 @@ /* * @test * @bug 5096553 8008577 + * @modules jdk.localedata * @summary updating dateformat for da_DK * following resources: * http://oss.software.ibm.com/cvs/icu/~checkout~/locale/common/main/da.xml diff --git a/jdk/test/sun/text/resources/Format/Bug8037343.java b/jdk/test/sun/text/resources/Format/Bug8037343.java index 6884193fd25..fa13c9d2887 100644 --- a/jdk/test/sun/text/resources/Format/Bug8037343.java +++ b/jdk/test/sun/text/resources/Format/Bug8037343.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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,6 +24,7 @@ /* * @test * @bug 8008577 8037343 + * @modules jdk.localedata * @summary updating dateformat for es_DO * @run main/othervm -Djava.locale.providers=JRE,SPI Bug8037343 */ diff --git a/jdk/test/sun/text/resources/Format/Bug8074791.java b/jdk/test/sun/text/resources/Format/Bug8074791.java index 138158ca090..de23f738216 100644 --- a/jdk/test/sun/text/resources/Format/Bug8074791.java +++ b/jdk/test/sun/text/resources/Format/Bug8074791.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +24,7 @@ /* * @test * @bug 8074791 + * @modules jdk.localedata * @summary Make sure that Finnish month names are correct in formatted text. */ @@ -32,7 +33,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; -import static java.text.DateFormat.*; +import static java.text.DateFormat.LONG; import static java.util.Calendar.JANUARY; public class Bug8074791 { diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java index 6f1dca3e0d0..b428fa6a422 100644 --- a/jdk/test/sun/text/resources/LocaleDataTest.java +++ b/jdk/test/sun/text/resources/LocaleDataTest.java @@ -40,6 +40,7 @@ * 8145136 * @summary Verify locale data * @modules java.base/sun.util.resources + * @modules jdk.localedata * @run main LocaleDataTest * @run main LocaleDataTest -cldr * @@ -145,12 +146,20 @@ * this test against the new version of the data. */ -import java.io.*; -import java.text.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FilterReader; +import java.io.FilterWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; import java.util.Locale; -import java.util.ResourceBundle; -import java.util.ResourceBundle.Control; import java.util.MissingResourceException; +import java.util.ResourceBundle; import sun.util.resources.LocaleData; public class LocaleDataTest diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java index e18b5c76c1d..31384717ac9 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -24,7 +24,7 @@ /* * @test * @summary Basic test for jhsdb launcher - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* diff --git a/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java index c768dd6eb01..1f88fd325b1 100644 --- a/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java +++ b/jdk/test/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -37,7 +37,7 @@ import jdk.testlibrary.Platform; * @bug 8042397 * @summary Unit test for jmap utility test heap configuration reader * @modules jdk.hotspot.agent/sun.jvm.hotspot - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* diff --git a/jdk/test/sun/tools/jinfo/JInfoTest.java b/jdk/test/sun/tools/jinfo/JInfoTest.java index 4710cfb974a..720874ba567 100644 --- a/jdk/test/sun/tools/jinfo/JInfoTest.java +++ b/jdk/test/sun/tools/jinfo/JInfoTest.java @@ -37,7 +37,7 @@ import jdk.test.lib.apps.LingeredApp; * @test * @summary Unit test for jinfo utility * @modules java.base/jdk.internal.misc - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.test.lib.* * @build jdk.test.lib.apps.* * @build jdk.test.lib.process.* diff --git a/jdk/test/sun/tools/jmap/BasicJMapTest.java b/jdk/test/sun/tools/jmap/BasicJMapTest.java index fa333cddea7..c0432deded8 100644 --- a/jdk/test/sun/tools/jmap/BasicJMapTest.java +++ b/jdk/test/sun/tools/jmap/BasicJMapTest.java @@ -37,7 +37,7 @@ import jdk.testlibrary.ProcessTools; * @summary Unit test for jmap utility * @key intermittent * @library /lib/testlibrary - * @library /test/lib/share/classes + * @library /test/lib * @build jdk.testlibrary.* * @build jdk.test.lib.hprof.* * @build jdk.test.lib.hprof.model.* diff --git a/jdk/test/sun/tools/jps/TestJpsSanity.java b/jdk/test/sun/tools/jps/TestJpsSanity.java index 457a667a251..47d15635961 100644 --- a/jdk/test/sun/tools/jps/TestJpsSanity.java +++ b/jdk/test/sun/tools/jps/TestJpsSanity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import jdk.test.lib.apps.LingeredApp; * @test * @summary This test verifies jps usage and checks that appropriate error message is shown * when running jps with illegal arguments. - * @library /lib/testlibrary /test/lib/share/classes + * @library /lib/testlibrary /test/lib * @modules jdk.jartool/sun.tools.jar * java.management * java.base/jdk.internal.misc diff --git a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java index 771fd128ff7..c51e402e06d 100644 --- a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java +++ b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -37,7 +37,7 @@ import jdk.testlibrary.ProcessTools; /* * @test * @summary Test deadlock detection - * @library /test/lib/share/classes + * @library /test/lib * @library /lib/testlibrary * @build jdk.testlibrary.* * @build jdk.test.lib.apps.* diff --git a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java index 9d124ffb21d..0c1d7650c48 100644 --- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java +++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java @@ -22,11 +22,15 @@ */ /* - *@test - *@bug 8007572 8008161 - *@summary Test whether the TimeZone generated from JSR310 tzdb is the same - *as the one from the tz data from javazic + * @test + * @bug 8007572 8008161 8157792 + * @summary Test whether the TimeZone generated from JSR310 tzdb is the same + * as the one from the tz data from javazic * @modules java.base/sun.util.calendar + * @build BackEnd Checksum DayOfWeek Gen GenDoc Main Mappings Month + * Rule RuleDay RuleRec Simple TestZoneInfo310 Time Timezone + * TzIDOldMapping Zone ZoneInfoFile ZoneInfoOld ZoneRec Zoneinfo + * @run main TestZoneInfo310 */ import java.io.File; @@ -164,10 +168,6 @@ public class TestZoneInfo310 { } for (String zid : zids_new) { - if (zid.equals("Asia/Oral") || zid.equals("Asia/Qyzylorda")) { - // JDK-8157792 tracking this issue - continue; - } ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); if (! zi.equalsTo(ziOLD)) { diff --git a/jdk/test/sun/util/calendar/zi/Zoneinfo.java b/jdk/test/sun/util/calendar/zi/Zoneinfo.java index 9e48655181f..e58fd188a30 100644 --- a/jdk/test/sun/util/calendar/zi/Zoneinfo.java +++ b/jdk/test/sun/util/calendar/zi/Zoneinfo.java @@ -373,6 +373,7 @@ class Zoneinfo { tz.getOffsetIndex(zrec.getGmtOffset()); int lastGmtOffsetValue = -1; + ZoneRec prevzrec = null; int currentSave = 0; boolean usedZone; for (int zindex = 0; zindex < zone.size(); zindex++) { @@ -441,6 +442,15 @@ class Zoneinfo { currentSave); if (zrec.hasUntil()) { if (transition >= zrec.getUntilTime(currentSave)) { + // If the GMT offset changed from the previous one, + // record fromTime as a transition. + if (!fromTimeUsed && prevzrec != null + && gmtOffset != prevzrec.getGmtOffset()) { + tz.addTransition(fromTime, + tz.getOffsetIndex(gmtOffset+currentSave), + tz.getDstOffsetIndex(currentSave)); + fromTimeUsed = true; // for consistency + } break year_loop; } } @@ -452,8 +462,6 @@ class Zoneinfo { if (fromTime != minTime) { int prevsave; - ZoneRec prevzrec = zone.get(zindex - 1); - // See if until time in the previous // ZoneRec is the same thing as the // local time in the next rule. @@ -555,6 +563,7 @@ class Zoneinfo { fromYear = zrec.getUntilYear(); year = zrec.getUntilYear(); } + prevzrec = zrec; } if (tz.getDSTType() == Timezone.UNDEF_DST) { diff --git a/jdk/test/sun/util/locale/provider/Bug8038436.java b/jdk/test/sun/util/locale/provider/Bug8038436.java index e112ed51804..96287fca0ef 100644 --- a/jdk/test/sun/util/locale/provider/Bug8038436.java +++ b/jdk/test/sun/util/locale/provider/Bug8038436.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -27,15 +27,25 @@ * @summary Test for changes in 8038436 * @modules java.base/sun.util.locale.provider * java.base/sun.util.spi + * jdk.localedata * @compile -XDignore.symbol.file Bug8038436.java * @run main/othervm --limit-modules java.base Bug8038436 security * @run main/othervm -Djava.locale.providers=COMPAT Bug8038436 availlocs */ -import java.security.*; -import java.util.*; -import java.util.stream.*; -import sun.util.locale.provider.*; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Arrays; +import java.util.Formatter; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; +import sun.util.locale.provider.LocaleProviderAdapter; public class Bug8038436 { public static void main(String[] args) { diff --git a/jdk/test/sun/util/locale/provider/Bug8152817.java b/jdk/test/sun/util/locale/provider/Bug8152817.java index bd0c5a0e55a..7bbcc0f2433 100644 --- a/jdk/test/sun/util/locale/provider/Bug8152817.java +++ b/jdk/test/sun/util/locale/provider/Bug8152817.java @@ -28,6 +28,7 @@ * @bug 8152817 * @summary Make sure that resource bundles in the jdk.localedata module are * loaded under a security manager. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT * -Djava.security.debug=access,failure,codebase=jrt:/jdk.localedata Bug8152817 */ diff --git a/jdk/test/sun/util/resources/Calendar/Bug4518811.java b/jdk/test/sun/util/resources/Calendar/Bug4518811.java index 05d246269c3..3c14d7c1e21 100644 --- a/jdk/test/sun/util/resources/Calendar/Bug4518811.java +++ b/jdk/test/sun/util/resources/Calendar/Bug4518811.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,9 +22,10 @@ */ /* - *@test - *@bug 4518811 - *@summary Verifies the minimum days of the week for euro locales + * @test + * @bug 4518811 + * @modules jdk.localedata + * @summary Verifies the minimum days of the week for euro locales */ // this code is a bit brute-force, but I've been coding in nothing but Shell for the last year, so I'm rusty. diff --git a/jdk/test/sun/util/resources/Calendar/Bug4527203.java b/jdk/test/sun/util/resources/Calendar/Bug4527203.java index f55e252dced..7692bef1120 100644 --- a/jdk/test/sun/util/resources/Calendar/Bug4527203.java +++ b/jdk/test/sun/util/resources/Calendar/Bug4527203.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,6 +24,7 @@ /* * @test 1.1 11/02/01 * @bug 4527203 + * @modules jdk.localedata * @summary In Hungary and Ukraine first day of week is Monday not Sunday */ diff --git a/jdk/test/sun/util/resources/Locale/Bug4429024.java b/jdk/test/sun/util/resources/Locale/Bug4429024.java index 9b06ccba3bc..e01ac99215c 100644 --- a/jdk/test/sun/util/resources/Locale/Bug4429024.java +++ b/jdk/test/sun/util/resources/Locale/Bug4429024.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -20,12 +20,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/** - @test - @summary checking localised language/country names in finnish - @bug 4429024 4964035 6558856 8008577 - @run main/othervm -Djava.locale.providers=JRE,SPI Bug4429024 -*/ +/* + * @test + * @summary checking localised language/country names in finnish + * @modules jdk.localedata + * @bug 4429024 4964035 6558856 8008577 + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4429024 + */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/Locale/Bug4965260.java b/jdk/test/sun/util/resources/Locale/Bug4965260.java index 4f46870a17c..1280fe974dd 100644 --- a/jdk/test/sun/util/resources/Locale/Bug4965260.java +++ b/jdk/test/sun/util/resources/Locale/Bug4965260.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -20,11 +20,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/** - *@test - *@bug 4965260 8008577 - *@summary Verifies the language name of "nl" for supported locales - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug4965260 +/* + * @test + * @bug 4965260 8008577 + * @modules jdk.localedata + * @summary Verifies the language name of "nl" for supported locales + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4965260 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/Locale/Bug6275682.java b/jdk/test/sun/util/resources/Locale/Bug6275682.java index 41d2b3c85d0..cfc89d44660 100644 --- a/jdk/test/sun/util/resources/Locale/Bug6275682.java +++ b/jdk/test/sun/util/resources/Locale/Bug6275682.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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,10 +21,11 @@ * questions. */ -/** - @test - @summary Verifying that the language names starts with lowercase in spanish - @bug 6275682 +/* + * @test + * @summary Verifying that the language names starts with lowercase in spanish + * @modules jdk.localedata + * @bug 6275682 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/TimeZone/Bug4938846.java b/jdk/test/sun/util/resources/TimeZone/Bug4938846.java index cbcaa008e37..4776ac642aa 100644 --- a/jdk/test/sun/util/resources/TimeZone/Bug4938846.java +++ b/jdk/test/sun/util/resources/TimeZone/Bug4938846.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,10 +22,11 @@ */ /* - *@test - *@bug 4938846 8008577 - *@summary Test case for en_IE TimeZone info - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug4938846 + * @test + * @bug 4938846 8008577 + * @modules jdk.localedata + * @summary Test case for en_IE TimeZone info + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4938846 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/TimeZone/Bug6271396.java b/jdk/test/sun/util/resources/TimeZone/Bug6271396.java index fd6fb80bddc..0fc42870533 100644 --- a/jdk/test/sun/util/resources/TimeZone/Bug6271396.java +++ b/jdk/test/sun/util/resources/TimeZone/Bug6271396.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,10 +22,11 @@ */ /* - *@test - *@bug 6271396 8008577 - *@summary Test case for verifying typo of timezone display name Australia/Lord_Howe - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug6271396 + * @test + * @bug 6271396 8008577 + * @modules jdk.localedata + * @summary Test case for verifying typo of timezone display name Australia/Lord_Howe + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6271396 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/TimeZone/Bug6317929.java b/jdk/test/sun/util/resources/TimeZone/Bug6317929.java index 55b5ead55a6..101e13805a4 100644 --- a/jdk/test/sun/util/resources/TimeZone/Bug6317929.java +++ b/jdk/test/sun/util/resources/TimeZone/Bug6317929.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,10 +22,11 @@ */ /* - *@test - *@bug 6317929 6409419 8008577 - *@summary Test case for tzdata2005m support for 9 locales - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug6317929 + * @test + * @bug 6317929 6409419 8008577 + * @modules jdk.localedata + * @summary Test case for tzdata2005m support for 9 locales + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6317929 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/TimeZone/Bug6377794.java b/jdk/test/sun/util/resources/TimeZone/Bug6377794.java index 6ca10735c93..47b00aca1d4 100644 --- a/jdk/test/sun/util/resources/TimeZone/Bug6377794.java +++ b/jdk/test/sun/util/resources/TimeZone/Bug6377794.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,10 +22,11 @@ */ /* - *@test - *@bug 6377794 - *@summary Test case for tzdata2005r support for 9 locales - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug6377794 + * @test + * @bug 6377794 + * @modules jdk.localedata + * @summary Test case for tzdata2005r support for 9 locales + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6377794 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/TimeZone/Bug6442006.java b/jdk/test/sun/util/resources/TimeZone/Bug6442006.java index 7202e444112..81cc40e29bc 100644 --- a/jdk/test/sun/util/resources/TimeZone/Bug6442006.java +++ b/jdk/test/sun/util/resources/TimeZone/Bug6442006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -22,10 +22,11 @@ */ /* - *@test - *@bug 6442006 8008577 - *@summary Test case for verifying timezone display name for Asia/Taipei - *@run main/othervm -Djava.locale.providers=JRE,SPI Bug6442006 + * @test + * @bug 6442006 8008577 + * @modules jdk.localedata + * @summary Test case for verifying timezone display name for Asia/Taipei + * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6442006 */ import java.util.Locale; diff --git a/jdk/test/sun/util/resources/cldr/Bug8134250.java b/jdk/test/sun/util/resources/cldr/Bug8134250.java index 95f827b75f5..d38fce53352 100644 --- a/jdk/test/sun/util/resources/cldr/Bug8134250.java +++ b/jdk/test/sun/util/resources/cldr/Bug8134250.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +24,7 @@ /* * @test * @bug 8134250 8134520 + * @modules jdk.localedata * @summary Tests CLDR/LDML features are correctly reflected in JDK. * @run main/othervm -Djava.locale.providers=CLDR Bug8134250 */ @@ -31,10 +32,15 @@ // Note this test highly depends on a particular version of CLDR. Results // may vary in the future. -import java.time.*; -import java.time.chrono.*; -import java.time.format.*; -import java.util.*; +import java.time.LocalDate; +import java.time.Month; +import java.time.ZoneId; +import java.time.chrono.Chronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.FormatStyle; +import java.time.format.TextStyle; +import java.util.Locale; public class Bug8134250 { public static void main(String [] args) { diff --git a/jdk/test/sun/util/resources/cldr/Bug8145136.java b/jdk/test/sun/util/resources/cldr/Bug8145136.java index 8a9f34e6f24..b158c5ac905 100644 --- a/jdk/test/sun/util/resources/cldr/Bug8145136.java +++ b/jdk/test/sun/util/resources/cldr/Bug8145136.java @@ -25,6 +25,7 @@ /* * @test * @bug 8145136 + * @modules jdk.localedata * @summary Tests CLDR 28/29 newly added feature LikelySubtags is correctly reflected in JDK. * @run main/othervm -Djava.locale.providers=CLDR Bug8145136 */ diff --git a/jdk/test/tools/jar/multiRelease/Basic.java b/jdk/test/tools/jar/multiRelease/Basic.java index 589615ad1e9..9f76b36e06d 100644 --- a/jdk/test/tools/jar/multiRelease/Basic.java +++ b/jdk/test/tools/jar/multiRelease/Basic.java @@ -23,7 +23,7 @@ /* * @test - * @library /test/lib/share/classes + * @library /test/lib * @modules java.base/jdk.internal.misc * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Platform * @run testng Basic diff --git a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java index ae2d3ec5945..d1510affb5e 100644 --- a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java @@ -22,6 +22,7 @@ */ import java.nio.file.Path; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -75,7 +76,7 @@ public class GenerateJLIClassesPluginTest { } - private static List classFilesForSpecies(List species) { + private static List classFilesForSpecies(Collection species) { return species.stream() .map(s -> "/java.base/java/lang/invoke/BoundMethodHandle$Species_" + s + ".class") .collect(Collectors.toList()); diff --git a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java index deb65ca13f8..4298e48d84d 100644 --- a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java @@ -126,11 +126,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es_419.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_es_AR.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", @@ -165,11 +164,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class", @@ -206,11 +204,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_150.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_AT.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", @@ -235,11 +232,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_kok_IN.class", "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_pa_Guru_IN.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", @@ -261,11 +257,10 @@ public class IncludeLocalesPluginTest { "--include-locales=th", "jdk.localedata", List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class"), List.of( "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", @@ -290,11 +285,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/ext/FormatData_zh_TW.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", @@ -318,11 +312,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/ext/FormatData_zh_SG.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", @@ -346,11 +339,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nb.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_nn.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", @@ -376,11 +368,10 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_iw.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ji.class"), List.of( - "/jdk.localedata/sun/text/resources/LineBreakIteratorData_th", - "/jdk.localedata/sun/text/resources/thai_dict", - "/jdk.localedata/sun/text/resources/WordBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", + "/jdk.localedata/sun/text/resources/ext/thai_dict", + "/jdk.localedata/sun/text/resources/ext/WordBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/BreakIteratorInfo_th.class", - "/jdk.localedata/sun/text/resources/ext/BreakIteratorRules_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", diff --git a/jdk/test/tools/pack200/Pack200Test.java b/jdk/test/tools/pack200/Pack200Test.java index fb6d9b1f83d..5c50da1e503 100644 --- a/jdk/test/tools/pack200/Pack200Test.java +++ b/jdk/test/tools/pack200/Pack200Test.java @@ -21,6 +21,14 @@ * questions. */ + /* + * @test + * @bug 6521334 6712743 8007902 8151901 + * @summary test general packer/unpacker functionality + * using native and java unpackers + * @compile -XDignore.symbol.file Utils.java Pack200Test.java + * @run main/othervm/timeout=1200 -Xmx1280m -Xshare:off Pack200Test + */ import java.util.*; import java.io.*; @@ -28,17 +36,6 @@ import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.util.jar.*; - /* - * @test - * @bug 6521334 6712743 8007902 - * @key intermittent - * @summary check for memory leaks, test general packer/unpacker functionality\ - * using native and java unpackers - * @compile -XDignore.symbol.file Utils.java Pack200Test.java - * @run main/othervm/timeout=1200 -Xmx1280m -Xshare:off Pack200Test - * @author ksrini - */ - /** * Tests the packing/unpacking via the APIs. */ @@ -48,6 +45,9 @@ public class Pack200Test { static final MemoryMXBean mmxbean = ManagementFactory.getMemoryMXBean(); static final long m0 = getUsedMemory(); static final int LEAK_TOLERANCE = 21000; // OS and GC related variations. + // enable leak checks only if required, GC charecteristics vary on + // platforms and this may not yield consistent results + static final boolean LEAK_CHECK = Boolean.getBoolean("Pack200Test.enableLeakCheck"); /** Creates a new instance of Pack200Test */ private Pack200Test() {} @@ -60,9 +60,11 @@ public class Pack200Test { } private static void leakCheck() throws Exception { + if (!LEAK_CHECK) + return; long diff = getUsedMemory() - m0; System.out.println(" Info: memory diff = " + diff + "K"); - if ( diff > LEAK_TOLERANCE) { + if (diff > LEAK_TOLERANCE) { throw new Exception("memory leak detected " + diff); } } @@ -126,7 +128,7 @@ public class Pack200Test { /** * @param args the command line arguments */ - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws Exception { // select the jars carefully, adding more jars will increase the // testing time, especially for jprt. jarList.add(Utils.createRtJar()); diff --git a/jdk/test/tools/pack200/pack200-verifier/data/golden.jar b/jdk/test/tools/pack200/pack200-verifier/data/golden.jar index 511cc0f43ab..a80ea6621a6 100644 Binary files a/jdk/test/tools/pack200/pack200-verifier/data/golden.jar and b/jdk/test/tools/pack200/pack200-verifier/data/golden.jar differ diff --git a/langtools/.hgtags b/langtools/.hgtags index 4fdf92ea61c..cddf72d74e6 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -376,3 +376,5 @@ e181909291981038b041ed4d22714c4760e049cd jdk-9+129 aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131 2c17b65a37a8d7afdb9f96d5f11b28a3f21c78f2 jdk-9+132 7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133 +f08683786207a48b652266b3b7b908e6c863c3fc jdk-9+134 +af5eb8f3ffd21288305a54ea177ffad75021a741 jdk-9+135 diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java index d928ee13f3a..7cccabeb5bd 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java @@ -119,10 +119,6 @@ public class ClassFinder { */ final Name completionFailureName; - /** Module specified with -Xmodule: - */ - final Name moduleOverride; - /** Access to files */ private final JavaFileManager fileManager; @@ -210,9 +206,6 @@ public class ClassFinder { ? names.fromString(options.get("failcomplete")) : null; - moduleOverride = options.isSet(Option.XMODULE) ? names.fromString(options.get(Option.XMODULE)) - : null; - // Temporary, until more info is available from the module system. boolean useCtProps; JavaFileManager fm = context.get(JavaFileManager.class); @@ -527,16 +520,15 @@ public class ClassFinder { if (msym == syms.noModule) { preferCurrent = false; if (userPathsFirst) { - scanUserPaths(p); + scanUserPaths(p, true); preferCurrent = true; scanPlatformPath(p); } else { scanPlatformPath(p); - scanUserPaths(p); + scanUserPaths(p, true); } } else if (msym.classLocation == StandardLocation.CLASS_PATH) { - // assert p.modle.sourceLocation == StandardLocation.SOURCE_PATH); - scanUserPaths(p); + scanUserPaths(p, msym.sourceLocation == StandardLocation.SOURCE_PATH); } else { scanModulePaths(p, msym); } @@ -561,23 +553,6 @@ public class ClassFinder { String packageName = p.fullname.toString(); - if (msym.name == moduleOverride) { - if (wantClassFiles) { - fillIn(p, CLASS_PATH, - fileManager.list(CLASS_PATH, - packageName, - classKinds, - false)); - } - if (wantSourceFiles && fileManager.hasLocation(SOURCE_PATH)) { - fillIn(p, SOURCE_PATH, - fileManager.list(SOURCE_PATH, - packageName, - sourceKinds, - false)); - } - } - Location classLocn = msym.classLocation; Location sourceLocn = msym.sourceLocation; @@ -600,7 +575,7 @@ public class ClassFinder { /** * Scans class path and source path for files in given package. */ - private void scanUserPaths(PackageSymbol p) throws IOException { + private void scanUserPaths(PackageSymbol p, boolean includeSourcePath) throws IOException { Set kinds = getPackageFileKinds(); Set classKinds = EnumSet.copyOf(kinds); @@ -611,7 +586,7 @@ public class ClassFinder { sourceKinds.remove(JavaFileObject.Kind.CLASS); boolean wantSourceFiles = !sourceKinds.isEmpty(); - boolean haveSourcePath = fileManager.hasLocation(SOURCE_PATH); + boolean haveSourcePath = includeSourcePath && fileManager.hasLocation(SOURCE_PATH); if (verbose && verbosePath) { if (fileManager instanceof StandardJavaFileManager) { diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java index d5480816c34..ddd61d65615 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java @@ -165,6 +165,11 @@ public class Lint */ EMPTY("empty"), + /** + * Warn about issues regarding module exports. + */ + EXPORTS("exports"), + /** * Warn about falling through from one case of a switch statement to the next. */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index 959d3ac1a91..d99fbeee26e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -359,6 +359,19 @@ public abstract class Symbol extends AnnoConstruct implements Element { return (flags_field & DEPRECATED) != 0; } + public boolean isDeprecatableViaAnnotation() { + switch (getKind()) { + case LOCAL_VARIABLE: + case PACKAGE: + case PARAMETER: + case RESOURCE_VARIABLE: + case EXCEPTION_PARAMETER: + return false; + default: + return true; + } + } + public boolean isStatic() { return (flags() & STATIC) != 0 || @@ -915,11 +928,6 @@ public abstract class Symbol extends AnnoConstruct implements Element { return msym; } - public ModuleSymbol() { - super(MDL, 0, null, null, null); - this.type = new ModuleType(this); - } - public ModuleSymbol(Name name, Symbol owner) { super(MDL, 0, name, null, owner); this.type = new ModuleType(this); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index 034ffda0ad0..339fe486bea 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -27,6 +27,7 @@ package com.sun.tools.javac.code; import java.util.Collection; import java.util.Collections; +import java.util.EnumSet; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -363,6 +364,17 @@ public class Symtab { // create the basic builtin symbols unnamedModule = new ModuleSymbol(names.empty, null) { + { + directives = List.nil(); + exports = List.nil(); + provides = List.nil(); + uses = List.nil(); + ModuleSymbol java_base = enterModule(names.java_base); + com.sun.tools.javac.code.Directive.RequiresDirective d = + new com.sun.tools.javac.code.Directive.RequiresDirective(java_base, + EnumSet.of(com.sun.tools.javac.code.Directive.RequiresFlag.MANDATED)); + requires = List.of(d); + } @Override public String toString() { return messages.getLocalizedString("compiler.misc.unnamed.module"); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 7e2f823d3c9..5767f9c45e4 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -3192,7 +3192,7 @@ public class Check { } void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) { - if (lint.isEnabled(LintCategory.DEP_ANN) && + if (lint.isEnabled(LintCategory.DEP_ANN) && s.isDeprecatableViaAnnotation() && (s.flags() & DEPRECATED) != 0 && !syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) == null) { @@ -3200,18 +3200,10 @@ public class Check { pos, "missing.deprecated.annotation"); } // Note: @Deprecated has no effect on local variables, parameters and package decls. - if (lint.isEnabled(LintCategory.DEPRECATION)) { + if (lint.isEnabled(LintCategory.DEPRECATION) && !s.isDeprecatableViaAnnotation()) { if (!syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) != null) { - switch (s.getKind()) { - case LOCAL_VARIABLE: - case PACKAGE: - case PARAMETER: - case RESOURCE_VARIABLE: - case EXCEPTION_PARAMETER: - log.warning(LintCategory.DEPRECATION, pos, - "deprecated.annotation.has.no.effect", Kinds.kindName(s)); - break; - } + log.warning(LintCategory.DEPRECATION, pos, + "deprecated.annotation.has.no.effect", Kinds.kindName(s)); } } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index d24b79529e8..8b8a0379546 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -392,6 +392,7 @@ public class Modules extends JCTree.Visitor { if (moduleOverride != null) { checkNoAllModulePath(); defaultModule = moduleFinder.findModule(names.fromString(moduleOverride)); + defaultModule.sourceLocation = StandardLocation.SOURCE_PATH; } else { // Question: why not do findAllModules and initVisiblePackages here? // i.e. body of unnamedModuleCompleter @@ -432,7 +433,9 @@ public class Modules extends JCTree.Visitor { if (defaultModule != syms.unnamedModule) { syms.unnamedModule.completer = getUnnamedModuleCompleter(); - syms.unnamedModule.sourceLocation = StandardLocation.SOURCE_PATH; + if (moduleOverride == null) { + syms.unnamedModule.sourceLocation = StandardLocation.SOURCE_PATH; + } syms.unnamedModule.classLocation = StandardLocation.CLASS_PATH; } @@ -1090,7 +1093,7 @@ public class Modules extends JCTree.Visitor { Set requiresPublic = requiresPublicCache.get(msym); if (requiresPublic == null) { - //the module graph may contain cycles involving automatic modules or -XaddReads edges + //the module graph may contain cycles involving automatic modules or --add-reads edges requiresPublic = new HashSet<>(); Set seen = new HashSet<>(); @@ -1192,7 +1195,7 @@ public class Modules extends JCTree.Visitor { } // Terminology comes from - // -XaddExports:module/package=target,... + // --add-exports module/package=target,... // Compare to // module module { exports package to target, ... } String moduleName = em.group(1); @@ -1245,7 +1248,7 @@ public class Modules extends JCTree.Visitor { } // Terminology comes from - // -XaddReads:target-module=source-module,... + // --add-reads target-module=source-module,... // Compare to // module target-module { requires source-module; ... } String targetName = rm.group(1); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index ef7f1ce0236..422f72f13d8 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -810,7 +810,7 @@ public class Locations { * SYSTEM_MODULES and MODULE_PATH. * * The Location can be specified to accept overriding classes from the - * {@code -Xpatch:= } parameter. + * {@code --patch-module = } parameter. */ private class ModuleLocationHandler extends LocationHandler implements Location { protected final String name; diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index a8e79f79928..e9a423ffd95 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -426,8 +426,8 @@ public class JavaCompiler { verboseCompilePolicy = options.isSet("verboseCompilePolicy"); - if (options.isSet("shouldstop.at") && - CompileState.valueOf(options.get("shouldstop.at")) == CompileState.ATTR) + if (options.isSet("should-stop.at") && + CompileState.valueOf(options.get("should-stop.at")) == CompileState.ATTR) compilePolicy = CompilePolicy.ATTR_ONLY; else compilePolicy = CompilePolicy.decode(options.get("compilePolicy")); @@ -440,14 +440,14 @@ public class JavaCompiler { : null; shouldStopPolicyIfError = - options.isSet("shouldstop.at") // backwards compatible - ? CompileState.valueOf(options.get("shouldstop.at")) - : options.isSet("shouldstop.ifError") - ? CompileState.valueOf(options.get("shouldstop.ifError")) + options.isSet("should-stop.at") // backwards compatible + ? CompileState.valueOf(options.get("should-stop.at")) + : options.isSet("should-stop.ifError") + ? CompileState.valueOf(options.get("should-stop.ifError")) : CompileState.INIT; shouldStopPolicyIfNoError = - options.isSet("shouldstop.ifNoError") - ? CompileState.valueOf(options.get("shouldstop.ifNoError")) + options.isSet("should-stop.ifNoError") + ? CompileState.valueOf(options.get("should-stop.ifNoError")) : CompileState.GENERATE; if (options.isUnset("diags.legacy")) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java index f20ff057191..03327387b47 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java @@ -183,15 +183,15 @@ public enum Option { SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER), - MODULE_SOURCE_PATH("--module-source-path -modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), + MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), - MODULE_PATH("--module-path -p -modulepath -mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), + MODULE_PATH("--module-path -p", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), - UPGRADE_MODULE_PATH("--upgrade-module-path -upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), + UPGRADE_MODULE_PATH("--upgrade-module-path", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), - SYSTEM("--system -system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), + SYSTEM("--system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), - PATCH_MODULE("--patch-module -Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { + PATCH_MODULE("--patch-module", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { // The deferred filemanager diagnostics mechanism assumes a single value per option, // but --patch-module can be used multiple times, once per module. Therefore we compose // a value for the option containing the last value specified for each module, and separate @@ -273,7 +273,7 @@ public enum Option { PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), - PROCESSOR_MODULE_PATH("--processor-module-path -processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), + PROCESSOR_MODULE_PATH("--processor-module-path", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC), @@ -311,7 +311,7 @@ public enum Option { } }, - RELEASE("--release -release", "opt.arg.release", "opt.release", STANDARD, BASIC) { + RELEASE("--release", "opt.arg.release", "opt.release", STANDARD, BASIC) { @Override protected void help(Log log) { Iterable providers = @@ -509,33 +509,21 @@ public enum Option { XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"), - XDEBUG("-Xdebug:", null, HIDDEN, BASIC) { + DEBUG("--debug:", null, HIDDEN, BASIC) { @Override public boolean process(OptionHelper helper, String option) { - String p = option.substring(option.indexOf(':') + 1).trim(); - String[] subOptions = p.split(";"); - for (String subOption : subOptions) { - subOption = "debug." + subOption.trim(); - XD.process(helper, subOption, subOption); - } - return false; + return HiddenGroup.DEBUG.process(helper, option); } }, - XSHOULDSTOP("-Xshouldstop:", null, HIDDEN, BASIC) { + SHOULDSTOP("--should-stop:", null, HIDDEN, BASIC) { @Override public boolean process(OptionHelper helper, String option) { - String p = option.substring(option.indexOf(':') + 1).trim(); - String[] subOptions = p.split(";"); - for (String subOption : subOptions) { - subOption = "shouldstop." + subOption.trim(); - XD.process(helper, subOption, subOption); - } - return false; + return HiddenGroup.SHOULDSTOP.process(helper, option); } }, - DIAGS("-diags:", null, HIDDEN, BASIC) { + DIAGS("--diags:", null, HIDDEN, BASIC) { @Override public boolean process(OptionHelper helper, String option) { return HiddenGroup.DIAGS.process(helper, option); @@ -566,7 +554,7 @@ public enum Option { } }, - ADD_EXPORTS("--add-exports -XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { + ADD_EXPORTS("--add-exports", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { @Override public boolean process(OptionHelper helper, String option, String arg) { String prev = helper.get(ADD_EXPORTS); @@ -575,7 +563,7 @@ public enum Option { } }, - ADD_READS("--add-reads -XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { + ADD_READS("--add-reads", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { @Override public boolean process(OptionHelper helper, String option, String arg) { String prev = helper.get(ADD_READS); @@ -598,9 +586,9 @@ public enum Option { MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC), - ADD_MODULES("--add-modules -addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), + ADD_MODULES("--add-modules", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), - LIMIT_MODULES("--limit-modules -limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), + LIMIT_MODULES("--limit-modules", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), // This option exists only for the purpose of documenting itself. // It's actually implemented by the CommandLine class. @@ -645,7 +633,7 @@ public enum Option { } }, - MULTIRELEASE("--multi-release -multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), + MULTIRELEASE("--multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment", EXTENDED, BASIC) { @@ -754,7 +742,12 @@ public enum Option { } enum HiddenGroup { - DIAGS("diags"); + DIAGS("diags"), + DEBUG("debug"), + SHOULDSTOP("should-stop"); + + static final Set skipSet = new java.util.HashSet<>( + Arrays.asList("--diags:", "--debug:", "--should-stop:")); final String text; @@ -771,6 +764,10 @@ public enum Option { } return false; } + + static boolean skip(String name) { + return skipSet.contains(name); + } } /** @@ -930,7 +927,7 @@ public enum Option { } private boolean matches(String option, String name) { - if (name.startsWith("--")) { + if (name.startsWith("--") && !HiddenGroup.skip(name)) { return option.equals(name) || hasArg() && option.startsWith(name + "="); } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java index fa1fab05401..4db3712b207 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformDescription.java @@ -36,7 +36,7 @@ import javax.annotation.processing.Processor; import com.sun.source.util.Plugin; -/**A description of settings needed for a particular {@code -release name} option. +/**A description of settings needed for a particular {@code --release name} option. * *

            This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java index db273a4cbc5..b552c6acf22 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/PlatformProvider.java @@ -25,7 +25,7 @@ package com.sun.tools.javac.platform; -/** A collection of platform descriptions that can be selected using {@code -release name} +/** A collection of platform descriptions that can be selected using {@code --release name} * command line option. * Register in {@code META-INF/services/com.sun.tools.javac.platform.PlatformProvider}. * @@ -36,7 +36,7 @@ package com.sun.tools.javac.platform; */ public interface PlatformProvider { - /**Names of platforms supported by this provider. Each returned name can be used as the key for -release. + /**Names of platforms supported by this provider. Each returned name can be used as the key for --release. * * @return the platform keys */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java index f843a8adc52..d236ea181f4 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/package-info.java @@ -24,7 +24,7 @@ */ /** - * An internal API for plugging in -release implementations. + * An internal API for plugging in --release implementations. * *

            This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index dcb7b2e7fee..f46d344ad18 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2780,10 +2780,10 @@ compiler.err.module-info.with.xmodule.classpath=\ illegal combination of -Xmodule and module-info on classpath compiler.err.xmodule.no.module.sourcepath=\ - illegal combination of -Xmodule and -modulesourcepath + illegal combination of -Xmodule and --module-source-path compiler.err.processorpath.no.processormodulepath=\ - illegal combination of -processorpath and -processormodulepath + illegal combination of -processorpath and --processor-module-path # 0: symbol compiler.err.package.in.other.module=\ @@ -2817,22 +2817,22 @@ compiler.err.duplicate.module.on.path=\ # 0: string compiler.err.xaddexports.malformed.entry=\ - bad value for -XaddExports: {0} + bad value for --add-exports {0} # 0: string compiler.err.xaddexports.too.many=\ - multiple -XaddExports options for {0} + multiple --add-exports options for {0} # 0: string compiler.err.xaddreads.malformed.entry=\ - bad value for -XaddReads: {0} + bad value for --add-reads {0} # 0: string compiler.err.xaddreads.too.many=\ - multiple -XaddReads options for {0} + multiple --add-reads options for {0} compiler.err.addmods.all.module.path.invalid=\ - -addmods ALL-MODULE-PATH can only be used when compiling the unnamed module + --add-modules ALL-MODULE-PATH can only be used when compiling the unnamed module compiler.misc.locn.module_source_path=\ module source path diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties index 6d17bc7ef89..44634e703e0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties @@ -192,6 +192,9 @@ javac.opt.Xlint.desc.divzero=\ javac.opt.Xlint.desc.empty=\ Warn about empty statement after if. +javac.opt.Xlint.desc.exports=\ + Warn about issues regarding module exports. + javac.opt.Xlint.desc.fallthrough=\ Warn about falling through from one case of a switch statement to the next. @@ -390,10 +393,10 @@ javac.version={0} {1} javac.fullVersion={0} full version "{1}" javac.err.release.bootclasspath.conflict=\ - option {0} cannot be used together with -release + option {0} cannot be used together with --release javac.err.unsupported.release.version=\ release version {0} not supported javac.err.release.not.standard.file.manager=\ - -release option specified, but the provided JavaFileManager is not a StandardJavaFileManager. + --release option specified, but the provided JavaFileManager is not a StandardJavaFileManager. diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java index 6cdb8fc7020..15481349fc0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java @@ -26,6 +26,8 @@ package com.sun.tools.javac.util; import java.util.*; + +import com.sun.tools.javac.code.Source; import com.sun.tools.javac.main.Option; import static com.sun.tools.javac.main.Option.*; @@ -176,7 +178,17 @@ public class Options { // disabled return isSet(XLINT_CUSTOM, s) || - (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) && + (isSet(XLINT) || isSet(XLINT_CUSTOM, "all") || (s.equals("dep-ann") && depAnnOnByDefault())) && isUnset(XLINT_CUSTOM, "-" + s); } + // where + private boolean depAnnOnByDefault() { + String sourceName = get(Option.SOURCE); + Source source = null; + if (sourceName != null) + source = Source.lookup(sourceName); + if (source == null) + source = Source.DEFAULT; + return source.compareTo(Source.JDK1_9) >= 0; + } } diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java index fb07a4fdae0..13df6ef4d8e 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java @@ -85,13 +85,7 @@ public enum Option { helper.modulepath(paths); } }, - MODULEPATH("-modulepath", "An alias for -modulepath") { - @Override - protected void processMatching(ArgumentIterator iter, OptionHelper helper) { - MODULE_PATH.processMatching(iter, helper); - } - }, - P("-p", "An alias for -modulepath") { + P("-p", "An alias for --module-path") { @Override protected void processMatching(ArgumentIterator iter, OptionHelper helper) { MODULE_PATH.processMatching(iter, helper); diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java index a6299916709..4f212a86a19 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java @@ -313,7 +313,7 @@ public class Options { } // Enable dependency generation - args.add("-Xdebug:completionDeps=source,class"); + args.add("--debug:completionDeps=source,class"); // This can't be anything but 'none'. Enforced by sjavac main method. args.add("-implicit:" + implicitPolicy); diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java index 0838966e1c4..d3d7073f9f0 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java @@ -104,13 +104,6 @@ public enum ToolOption { } }, - MODULESOURCEPATH("-modulesourcepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); - } - }, - MODULE_SOURCE_PATH("--module-source-path", true) { @Override public void process(Helper helper, String arg) { @@ -118,13 +111,6 @@ public enum ToolOption { } }, - UPGRADEMODULEPATH("-upgrademodulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); - } - }, - UPGRADE_MODULE_PATH("--upgrade-module-path", true) { @Override public void process(Helper helper, String arg) { @@ -132,13 +118,6 @@ public enum ToolOption { } }, - SYSTEM("-system", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.SYSTEM, arg); - } - }, - SYSTEM_("--system", true) { @Override public void process(Helper helper, String arg) { @@ -146,13 +125,6 @@ public enum ToolOption { } }, - MODULEPATH("-modulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_PATH, arg); - } - }, - MODULE_PATH("--module-path", true) { @Override public void process(Helper helper, String arg) { @@ -167,13 +139,6 @@ public enum ToolOption { } }, - ADDMODS("-addmods", true) { - @Override - public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); - } - }, - ADD_MODULES("--add-modules", true) { @Override public void process(Helper helper, String arg) { @@ -181,13 +146,6 @@ public enum ToolOption { } }, - LIMITMODS("-limitmods", true) { - @Override - public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); - } - }, - LIMIT_MODULES("--limit-modules", true) { @Override public void process(Helper helper, String arg) { @@ -210,13 +168,6 @@ public enum ToolOption { } }, - RELEASE_OLD("-release", true) { - @Override - public void process(Helper helper, String arg) { - helper.setCompilerOpt("--release", arg); - } - }, - SOURCE("-source", true) { @Override public void process(Helper helper, String arg) { @@ -238,13 +189,6 @@ public enum ToolOption { } }, - XADDREADS("-XaddReads:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_READS.process(helper.getOptionHelper(), arg); - } - }, - ADD_READS("--add-reads", true) { @Override public void process(Helper helper, String arg) { @@ -252,13 +196,6 @@ public enum ToolOption { } }, - ADDEXPORTS("-XaddExports:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg); - } - }, - ADD_EXPORTS("--add-exports", true) { @Override public void process(Helper helper, String arg) { @@ -273,13 +210,6 @@ public enum ToolOption { } }, - XPATCH("-Xpatch:", false) { - @Override - public void process(Helper helper, String arg) { - Option.XMODULE.process(helper.getOptionHelper(), arg); - } - }, - PATCH_MODULE("--patch-module", true) { @Override public void process(Helper helper, String arg) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java index fd07699fa83..0f5cf65cbe2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java @@ -106,13 +106,6 @@ public enum ToolOption { } }, - MODULESOURCEPATH("-modulesourcepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg); - } - }, - MODULE_SOURCE_PATH("--module-source-path", true) { @Override public void process(Helper helper, String arg) { @@ -120,13 +113,6 @@ public enum ToolOption { } }, - UPGRADEMODULEPATH("-upgrademodulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg); - } - }, - UPGRADE_MODULE_PATH("--upgrade-module-path", true) { @Override public void process(Helper helper, String arg) { @@ -134,27 +120,13 @@ public enum ToolOption { } }, - SYSTEM("-system", true) { + SYSTEM("--system", true) { @Override public void process(Helper helper, String arg) { helper.setFileManagerOpt(Option.SYSTEM, arg); } }, - SYSTEM_("--system", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.SYSTEM, arg); - } - }, - - MODULEPATH("-modulepath", true) { - @Override - public void process(Helper helper, String arg) { - helper.setFileManagerOpt(Option.MODULE_PATH, arg); - } - }, - MODULE_PATH("--module-path", true) { @Override public void process(Helper helper, String arg) { @@ -169,13 +141,6 @@ public enum ToolOption { } }, - ADDMODS("-addmods", true) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg); - } - }, - ADD_MODULES("--add-modules", true) { @Override public void process(Helper helper, String arg) { @@ -183,13 +148,6 @@ public enum ToolOption { } }, - LIMITMODS("-limitmods", true) { - @Override - public void process(Helper helper, String arg) { - Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg); - } - }, - LIMIT_MODULES("--limit-modules", true) { @Override public void process(Helper helper, String arg) { @@ -218,13 +176,6 @@ public enum ToolOption { } }, - RELEASE_OLD("-release", true) { - @Override - public void process(Helper helper, String arg) { - Option.RELEASE.process(helper.getOptionHelper(), opt, arg); - } - }, - SOURCE("-source", true) { @Override public void process(Helper helper, String arg) { @@ -246,13 +197,6 @@ public enum ToolOption { } }, - XADDREADS("-XaddReads:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_READS.process(helper.getOptionHelper(), arg); - } - }, - ADD_READS("--add-reads", true) { @Override public void process(Helper helper, String arg) { @@ -260,13 +204,6 @@ public enum ToolOption { } }, - ADDEXPORTS("-XaddExports:", false) { - @Override - public void process(Helper helper, String arg) { - Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg); - } - }, - ADD_EXPORTS("--add-exports", true) { @Override public void process(Helper helper, String arg) { @@ -281,13 +218,6 @@ public enum ToolOption { } }, - XPATCH("-Xpatch:", false) { - @Override - public void process(Helper helper, String arg) { - Option.XMODULE.process(helper.getOptionHelper(), arg); - } - }, - PATCH_MODULE("--patch-module", true) { @Override public void process(Helper helper, String arg) { diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java index 28d4b33e886..3a024981393 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java @@ -81,7 +81,7 @@ import javax.lang.model.element.TypeElement; * - more rigorous GNU style option parsing; use joptsimple? * * FUTURES: - * - add module support: -addmods, -modulepath, module arg + * - add module support: --add-modules, --module-path, module arg * - load deprecation declarations from a designated class library instead * of the JDK * - load deprecation declarations from a module @@ -181,7 +181,7 @@ public class Main implements DiagnosticListener { .filter(name -> !name.endsWith("package-info.class")) .filter(name -> !name.endsWith("module-info.class")) .map(s -> s.replaceAll("\\.class$", "")) - .map(s -> s.replace('/', '.')) + .map(s -> s.replace(File.separatorChar, '.')) .collect(toList())); } @@ -331,7 +331,7 @@ public class Main implements DiagnosticListener { * @throws IOException if an I/O error occurs */ boolean processSelf(Collection classes) throws IOException { - options.add("-addmods"); + options.add("--add-modules"); options.add("java.se.ee,jdk.xml.bind"); // TODO why jdk.xml.bind? if (classes.isEmpty()) { @@ -360,7 +360,7 @@ public class Main implements DiagnosticListener { * @return success value */ boolean processRelease(String release, Collection classes) throws IOException { - options.addAll(List.of("-release", release)); + options.addAll(List.of("--release", release)); if (release.equals("9")) { List rootMods = List.of("java.se", "java.se.ee"); @@ -368,7 +368,7 @@ public class Main implements DiagnosticListener { JavaCompiler.CompilationTask task = compiler.getTask(null, fm, this, // options - List.of("-addmods", String.join(",", rootMods)), + List.of("--add-modules", String.join(",", rootMods)), // classes List.of("java.lang.Object"), null); @@ -377,7 +377,7 @@ public class Main implements DiagnosticListener { return false; } Map> types = proc.getPublicTypes(); - options.add("-addmods"); + options.add("--add-modules"); options.add(String.join(",", rootMods)); return doClassNames( types.values().stream() diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java index 128e2ea7456..2975813c14f 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java @@ -56,7 +56,7 @@ import static java.util.stream.Collectors.*; * 1. archives specified in the command line arguments * 2. observable modules matching the source filter * 3. classpath archives matching the source filter or target filter - * 4. -addmods and -m root modules + * 4. --add-modules and -m root modules */ public class DepsAnalyzer { final JdepsConfiguration configuration; diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java index 2975651e373..3c4632a8078 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java @@ -127,7 +127,7 @@ public class JdepsConfiguration implements AutoCloseable { } } - // all roots specified in -addmods or -m are included + // all roots specified in --add-modules or -m are included // as the initial set for analysis. roots.stream() .map(nameToModule::get) @@ -342,7 +342,7 @@ public class JdepsConfiguration implements AutoCloseable { SystemModuleFinder(String javaHome) throws IOException { if (javaHome == null) { - // -system none + // --system none this.fileSystem = null; this.root = null; this.systemModules = Collections.emptyMap(); diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java index 2cdca8bb839..38e1d08c6ef 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -313,7 +313,7 @@ class JdepsTask { } }, - // Another alternative to list modules in -addmods option + // Another alternative to list modules in --add-modules option new HiddenOption(true, "--include-system-modules") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.includeSystemModulePattern = Pattern.compile(arg); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java index ca475115c10..b4df8efbe54 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java @@ -57,6 +57,8 @@ import jdk.internal.jline.console.ConsoleReader; import jdk.internal.jline.console.KeyMap; import jdk.internal.jline.console.UserInterruptException; import jdk.internal.jline.console.completer.Completer; +import jdk.internal.jline.console.history.History; +import jdk.internal.jline.console.history.MemoryHistory; import jdk.internal.jline.extra.EditingHistory; import jdk.internal.jshell.tool.StopDetectingInputStream.State; @@ -68,6 +70,7 @@ class ConsoleIOContext extends IOContext { final StopDetectingInputStream input; final ConsoleReader in; final EditingHistory history; + final MemoryHistory userInputHistory = new MemoryHistory(); String prefix = ""; @@ -299,6 +302,9 @@ class ConsoleIOContext extends IOContext { } public void beforeUserCode() { + synchronized (this) { + inputBytes = null; + } input.setState(State.BUFFER); } @@ -380,6 +386,36 @@ class ConsoleIOContext extends IOContext { } } + private byte[] inputBytes; + private int inputBytesPointer; + + @Override + public synchronized int readUserInput() { + while (inputBytes == null || inputBytes.length <= inputBytesPointer) { + boolean prevHandleUserInterrupt = in.getHandleUserInterrupt(); + History prevHistory = in.getHistory(); + + try { + input.setState(State.WAIT); + in.setHandleUserInterrupt(true); + in.setHistory(userInputHistory); + inputBytes = (in.readLine("") + System.getProperty("line.separator")).getBytes(); + inputBytesPointer = 0; + } catch (IOException ex) { + ex.printStackTrace(); + return -1; + } catch (UserInterruptException ex) { + repl.state.stop(); + return -1; + } finally { + in.setHistory(prevHistory); + in.setHandleUserInterrupt(prevHandleUserInterrupt); + input.setState(State.BUFFER); + } + } + return inputBytes[inputBytesPointer++]; + } + /** * A possible action which the user can choose to perform. */ diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java new file mode 100644 index 00000000000..0fc6f6ca8a5 --- /dev/null +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ContinuousCompletionProvider.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 jdk.internal.jshell.tool; + +import java.util.List; +import static java.util.Comparator.comparing; +import java.util.Map; +import java.util.function.BiPredicate; +import java.util.function.Supplier; +import static java.util.stream.Collectors.toList; +import java.util.stream.Stream; +import jdk.internal.jshell.tool.JShellTool.CompletionProvider; +import jdk.jshell.SourceCodeAnalysis; +import jdk.jshell.SourceCodeAnalysis.Suggestion; + +class ContinuousCompletionProvider implements CompletionProvider { + + static final BiPredicate STARTSWITH_MATCHER = + (word, input) -> word.startsWith(input); + static final BiPredicate PERFECT_MATCHER = + (word, input) -> word.equals(input); + + private final Supplier> wordCompletionProviderSupplier; + private final BiPredicate matcher; + + ContinuousCompletionProvider( + Map wordCompletionProvider, + BiPredicate matcher) { + this(() -> wordCompletionProvider, matcher); + } + + ContinuousCompletionProvider( + Supplier> wordCompletionProviderSupplier, + BiPredicate matcher) { + this.wordCompletionProviderSupplier = wordCompletionProviderSupplier; + this.matcher = matcher; + } + + @Override + public List completionSuggestions(String input, int cursor, int[] anchor) { + String prefix = input.substring(0, cursor); + int space = prefix.indexOf(' '); + + Stream result; + + Map wordCompletionProvider = wordCompletionProviderSupplier.get(); + + if (space == (-1)) { + result = wordCompletionProvider.keySet().stream() + .distinct() + .filter(key -> key.startsWith(prefix)) + .map(key -> new JShellTool.ArgSuggestion(key + " ")); + anchor[0] = 0; + } else { + String rest = prefix.substring(space + 1); + String word = prefix.substring(0, space); + + List candidates = wordCompletionProvider.entrySet().stream() + .filter(e -> matcher.test(e.getKey(), word)) + .map(Map.Entry::getValue) + .collect(toList()); + if (candidates.size() == 1) { + result = candidates.get(0).completionSuggestions(rest, cursor - space - 1, anchor).stream(); + } else { + result = Stream.empty(); + } + anchor[0] += space + 1; + } + + return result.sorted(comparing(Suggestion::continuation)) + .collect(toList()); + } + +} diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java index 7f78c2f9962..b6d97b30215 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java @@ -35,9 +35,14 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toMap; +import static jdk.internal.jshell.tool.ContinuousCompletionProvider.PERFECT_MATCHER; +import jdk.internal.jshell.tool.JShellTool.CompletionProvider; +import static jdk.internal.jshell.tool.JShellTool.EMPTY_COMPLETION_PROVIDER; /** * Feedback customization support @@ -146,6 +151,17 @@ class Feedback { .forEach(m -> m.readOnly = true); } + JShellTool.CompletionProvider modeCompletions() { + return modeCompletions(EMPTY_COMPLETION_PROVIDER); + } + + JShellTool.CompletionProvider modeCompletions(CompletionProvider successor) { + return new ContinuousCompletionProvider( + () -> modeMap.keySet().stream() + .collect(toMap(Function.identity(), m -> successor)), + PERFECT_MATCHER); + } + { for (FormatCase e : FormatCase.all) selectorMap.put(e.name().toLowerCase(Locale.US), e); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java index 8f8606fed05..4f4a51a44b0 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/IOContext.java @@ -54,6 +54,8 @@ abstract class IOContext implements AutoCloseable { public abstract void replaceLastHistoryEntry(String source); + public abstract int readUserInput(); + class InputInterruptedException extends Exception { private static final long serialVersionUID = 1L; } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index fa83c0fd40e..203132444f2 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -26,7 +26,6 @@ package jdk.internal.jshell.tool; import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; @@ -112,6 +111,7 @@ import static jdk.internal.jshell.debug.InternalDebugControl.DBG_DEP; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_EVNT; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_FMGR; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN; +import static jdk.internal.jshell.tool.ContinuousCompletionProvider.STARTSWITH_MATCHER; /** * Command line REPL tool for Java using the JShell API. @@ -138,6 +138,25 @@ public class JShellTool implements MessageHandler { final Feedback feedback = new Feedback(); + /** + * The constructor for the tool (used by tool launch via main and by test + * harnesses to capture ins and outs. + * @param in command line input -- snippets, commands and user input + * @param cmdout command line output, feedback including errors + * @param cmderr start-up errors and debugging info + * @param console console control interaction + * @param userout code execution output -- System.out.printf("hi") + * @param usererr code execution error stream -- System.err.printf("Oops") + * @param prefs preferences to use + * @param locale locale to use + */ + public JShellTool(InputStream in, PrintStream cmdout, PrintStream cmderr, + PrintStream console, + PrintStream userout, PrintStream usererr, + Preferences prefs, Locale locale) { + this(in, cmdout, cmderr, console, null, userout, usererr, prefs, locale); + } + /** * The constructor for the tool (used by tool launch via main and by test * harnesses to capture ins and outs. @@ -145,7 +164,7 @@ public class JShellTool implements MessageHandler { * @param cmdout command line output, feedback including errors * @param cmderr start-up errors and debugging info * @param console console control interaction - * @param userin code execution input (not yet functional) + * @param userin code execution input, or null to use IOContext * @param userout code execution output -- System.out.printf("hi") * @param usererr code execution error stream -- System.err.printf("Oops") * @param prefs preferences to use @@ -159,7 +178,12 @@ public class JShellTool implements MessageHandler { this.cmdout = cmdout; this.cmderr = cmderr; this.console = console; - this.userin = userin; + this.userin = userin != null ? userin : new InputStream() { + @Override + public int read() throws IOException { + return input.readUserInput(); + } + }; this.userout = userout; this.usererr = usererr; this.prefs = prefs; @@ -451,7 +475,7 @@ public class JShellTool implements MessageHandler { */ public static void main(String[] args) throws Exception { new JShellTool(System.in, System.out, System.err, System.out, - new ByteArrayInputStream(new byte[0]), System.out, System.err, + System.out, System.err, Preferences.userRoot().node("tool/JShell"), Locale.getDefault()) .start(args); @@ -909,6 +933,7 @@ public class JShellTool implements MessageHandler { interface CompletionProvider { List completionSuggestions(String input, int cursor, int[] anchor); + } enum CommandKind { @@ -953,14 +978,31 @@ public class JShellTool implements MessageHandler { } - private static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider(); + static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider(); private static final CompletionProvider KEYWORD_COMPLETION_PROVIDER = new FixedCompletionProvider("-all ", "-start ", "-history "); private static final CompletionProvider RELOAD_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("-restore", "-quiet"); + private static final CompletionProvider SET_MODE_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("-command", "-quiet", "-delete"); private static final CompletionProvider FILE_COMPLETION_PROVIDER = fileCompletions(p -> true); private final Map commands = new LinkedHashMap<>(); private void registerCommand(Command cmd) { commands.put(cmd.command, cmd); } + + private static CompletionProvider skipWordThenCompletion(CompletionProvider completionProvider) { + return (input, cursor, anchor) -> { + List result = Collections.emptyList(); + + int space = input.indexOf(' '); + if (space != -1) { + String rest = input.substring(space + 1); + result = completionProvider.completionSuggestions(rest, cursor - space - 1, anchor); + anchor[0] += space + 1; + } + + return result; + }; + } + private static CompletionProvider fileCompletions(Predicate accept) { return (code, cursor, anchor) -> { int lastSlash = code.lastIndexOf('/'); @@ -1037,6 +1079,31 @@ public class JShellTool implements MessageHandler { }; } + private static CompletionProvider orMostSpecificCompletion( + CompletionProvider left, CompletionProvider right) { + return (code, cursor, anchor) -> { + int[] leftAnchor = {-1}; + int[] rightAnchor = {-1}; + + List leftSuggestions = left.completionSuggestions(code, cursor, leftAnchor); + List rightSuggestions = right.completionSuggestions(code, cursor, rightAnchor); + + List suggestions = new ArrayList<>(); + + if (leftAnchor[0] >= rightAnchor[0]) { + anchor[0] = leftAnchor[0]; + suggestions.addAll(leftSuggestions); + } + + if (leftAnchor[0] <= rightAnchor[0]) { + anchor[0] = rightAnchor[0]; + suggestions.addAll(rightSuggestions); + } + + return suggestions; + }; + } + // Snippet lists Stream allSnippets() { @@ -1123,10 +1190,26 @@ public class JShellTool implements MessageHandler { EMPTY_COMPLETION_PROVIDER)); registerCommand(new Command("/set", arg -> cmdSet(arg), - new FixedCompletionProvider(SET_SUBCOMMANDS))); + new ContinuousCompletionProvider(Map.of( + // need more completion for format for usability + "format", feedback.modeCompletions(), + "truncation", feedback.modeCompletions(), + "feedback", feedback.modeCompletions(), + "mode", skipWordThenCompletion(orMostSpecificCompletion( + feedback.modeCompletions(SET_MODE_OPTIONS_COMPLETION_PROVIDER), + SET_MODE_OPTIONS_COMPLETION_PROVIDER)), + "prompt", feedback.modeCompletions(), + "editor", fileCompletions(Files::isExecutable), + "start", FILE_COMPLETION_PROVIDER), + STARTSWITH_MATCHER))); registerCommand(new Command("/retain", arg -> cmdRetain(arg), - new FixedCompletionProvider(RETAIN_SUBCOMMANDS))); + new ContinuousCompletionProvider(Map.of( + "feedback", feedback.modeCompletions(), + "mode", feedback.modeCompletions(), + "editor", fileCompletions(Files::isExecutable), + "start", FILE_COMPLETION_PROVIDER), + STARTSWITH_MATCHER))); registerCommand(new Command("/?", "help.quest", arg -> cmdHelp(arg), @@ -1151,36 +1234,18 @@ public class JShellTool implements MessageHandler { registerCommand(new Command("shortcuts", "help.shortcuts", CommandKind.HELP_SUBJECT)); + + commandCompletions = new ContinuousCompletionProvider( + commands.values().stream() + .filter(c -> c.kind.shouldSuggestCompletions) + .collect(toMap(c -> c.command, c -> c.completions)), + STARTSWITH_MATCHER); } + private ContinuousCompletionProvider commandCompletions; + public List commandCompletionSuggestions(String code, int cursor, int[] anchor) { - String prefix = code.substring(0, cursor); - int space = prefix.indexOf(' '); - Stream result; - - if (space == (-1)) { - result = commands.values() - .stream() - .distinct() - .filter(cmd -> cmd.kind.shouldSuggestCompletions) - .map(cmd -> cmd.command) - .filter(key -> key.startsWith(prefix)) - .map(key -> new ArgSuggestion(key + " ")); - anchor[0] = 0; - } else { - String arg = prefix.substring(space + 1); - String cmd = prefix.substring(0, space); - Command[] candidates = findCommand(cmd, c -> true); - if (candidates.length == 1) { - result = candidates[0].completions.completionSuggestions(arg, cursor - space, anchor).stream(); - anchor[0] += space + 1; - } else { - result = Stream.empty(); - } - } - - return result.sorted((s1, s2) -> s1.continuation().compareTo(s2.continuation())) - .collect(Collectors.toList()); + return commandCompletions.completionSuggestions(code, cursor, anchor); } public String commandDocumentation(String code, int cursor) { @@ -2484,7 +2549,7 @@ public class JShellTool implements MessageHandler { } } - private static class ArgSuggestion implements Suggestion { + static class ArgSuggestion implements Suggestion { private final String continuation; @@ -2579,6 +2644,11 @@ class ScannerIOContext extends NonInteractiveIOContext { public void close() { scannerIn.close(); } + + @Override + public int readUserInput() { + return -1; + } } class FileScannerIOContext extends ScannerIOContext { @@ -2617,4 +2687,9 @@ class ReloadIOContext extends NonInteractiveIOContext { @Override public void close() { } + + @Override + public int readUserInput() { + return -1; + } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java index 10a00697231..c652b45b308 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java @@ -46,6 +46,8 @@ import com.sun.source.tree.Tree; import static jdk.jshell.CompletenessAnalyzer.TK.*; import jdk.jshell.TaskFactory.ParseTask; import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; /** * Low level scanner to determine completeness of input. @@ -81,13 +83,13 @@ class CompletenessAnalyzer { CaInfo scan(String s) { try { - Scanner scanner = scannerFactory.newScanner(s, false); - Matched in = new Matched(scanner); - Parser parser = new Parser(in, proc, s); + Parser parser = new Parser( + () -> new Matched(scannerFactory.newScanner(s, false)), + () -> proc.taskFactory.new ParseTask(s)); Completeness stat = parser.parseUnit(); int endPos = stat == Completeness.UNKNOWN ? s.length() - : in.prevCT.endPos; + : parser.endPos(); return new CaInfo(stat, endPos); } catch (SyntaxException ex) { return new CaInfo(error(), s.length()); @@ -188,7 +190,7 @@ class CompletenessAnalyzer { ERROR(TokenKind.ERROR, XERRO), // IDENTIFIER(TokenKind.IDENTIFIER, XEXPR1|XDECL1|XTERM), // UNDERSCORE(TokenKind.UNDERSCORE, XERRO), // _ - CLASS(TokenKind.CLASS, XEXPR|XDECL1|XTERM), // class decl and .class + CLASS(TokenKind.CLASS, XEXPR|XDECL1), // class decl (MAPPED: DOTCLASS) MONKEYS_AT(TokenKind.MONKEYS_AT, XEXPR|XDECL1), // @ IMPORT(TokenKind.IMPORT, XDECL1|XSTART), // import -- consider declaration SEMI(TokenKind.SEMI, XSTMT1|XTERM|XSTART), // ; @@ -206,15 +208,15 @@ class CompletenessAnalyzer { THROWS(TokenKind.THROWS, XDECL), // throws // Primarive type names - BOOLEAN(TokenKind.BOOLEAN, XEXPR|XDECL1), // boolean - BYTE(TokenKind.BYTE, XEXPR|XDECL1), // byte - CHAR(TokenKind.CHAR, XEXPR|XDECL1), // char - DOUBLE(TokenKind.DOUBLE, XEXPR|XDECL1), // double - FLOAT(TokenKind.FLOAT, XEXPR|XDECL1), // float - INT(TokenKind.INT, XEXPR|XDECL1), // int - LONG(TokenKind.LONG, XEXPR|XDECL1), // long - SHORT(TokenKind.SHORT, XEXPR|XDECL1), // short - VOID(TokenKind.VOID, XEXPR|XDECL1), // void + BOOLEAN(TokenKind.BOOLEAN, XEXPR1|XDECL1), // boolean + BYTE(TokenKind.BYTE, XEXPR1|XDECL1), // byte + CHAR(TokenKind.CHAR, XEXPR1|XDECL1), // char + DOUBLE(TokenKind.DOUBLE, XEXPR1|XDECL1), // double + FLOAT(TokenKind.FLOAT, XEXPR1|XDECL1), // float + INT(TokenKind.INT, XEXPR1|XDECL1), // int + LONG(TokenKind.LONG, XEXPR1|XDECL1), // long + SHORT(TokenKind.SHORT, XEXPR1|XDECL1), // short + VOID(TokenKind.VOID, XEXPR1|XDECL1), // void // Modifiers keywords ABSTRACT(TokenKind.ABSTRACT, XDECL1), // abstract @@ -230,7 +232,7 @@ class CompletenessAnalyzer { // Declarations and type parameters (thus expressions) EXTENDS(TokenKind.EXTENDS, XEXPR|XDECL), // extends - COMMA(TokenKind.COMMA, XEXPR|XDECL), // , + COMMA(TokenKind.COMMA, XEXPR|XDECL|XTERM), // , AMP(TokenKind.AMP, XEXPR|XDECL), // & GT(TokenKind.GT, XEXPR|XDECL), // > LT(TokenKind.LT, XEXPR|XDECL1), // < @@ -239,7 +241,7 @@ class CompletenessAnalyzer { GTGTGT(TokenKind.GTGTGT, XEXPR|XDECL), // >>> QUES(TokenKind.QUES, XEXPR|XDECL), // ? DOT(TokenKind.DOT, XEXPR|XDECL), // . - STAR(TokenKind.STAR, XEXPR|XDECL|XTERM), // * -- import foo.* //TODO handle these case separately, XTERM + STAR(TokenKind.STAR, XEXPR), // * (MAPPED: DOTSTAR) // Statement keywords ASSERT(TokenKind.ASSERT, XSTMT1|XSTART), // assert @@ -280,7 +282,7 @@ class CompletenessAnalyzer { // Expressions cannot terminate INSTANCEOF(TokenKind.INSTANCEOF, XEXPR), // instanceof - NEW(TokenKind.NEW, XEXPR1), // new + NEW(TokenKind.NEW, XEXPR1), // new (MAPPED: COLCOLNEW) SUPER(TokenKind.SUPER, XEXPR1|XDECL), // super -- shouldn't see as rec. But in type parameters ARROW(TokenKind.ARROW, XEXPR), // -> COLCOL(TokenKind.COLCOL, XEXPR), // :: @@ -323,24 +325,29 @@ class CompletenessAnalyzer { UNMATCHED(XERRO), PARENS(XEXPR1|XDECL|XSTMT|XTERM), BRACKETS(XEXPR|XDECL|XTERM), - BRACES(XSTMT1|XEXPR|XTERM); + BRACES(XSTMT1|XEXPR|XTERM), + DOTSTAR(XDECL|XTERM), // import foo.* + COLCOLNEW(XEXPR|XTERM), // :: new + DOTCLASS(XEXPR|XTERM), // class decl and .class + ; static final EnumMap tokenKindToTKMap = new EnumMap<>(TokenKind.class); final TokenKind tokenKind; final int belongs; + Function mapping; TK(int b) { - this.tokenKind = null; - this.belongs = b; + this(null, b); } TK(TokenKind tokenKind, int b) { this.tokenKind = tokenKind; this.belongs = b; + this.mapping = null; } - private static TK tokenKindToTK(TokenKind kind) { + private static TK tokenKindToTK(TK prev, TokenKind kind) { TK tk = tokenKindToTKMap.get(kind); if (tk == null) { System.err.printf("No corresponding %s for %s: %s\n", @@ -349,7 +356,9 @@ class CompletenessAnalyzer { kind); throw new InternalError("No corresponding TK for TokenKind: " + kind); } - return tk; + return tk.mapping != null + ? tk.mapping.apply(prev) + : tk; } boolean isOkToTerminate() { @@ -383,8 +392,12 @@ class CompletenessAnalyzer { } } for (TokenKind kind : TokenKind.values()) { - tokenKindToTK(kind); // assure they can be retrieved without error + tokenKindToTK(null, kind); // assure they can be retrieved without error } + // Mappings of disambiguated contexts + STAR.mapping = prev -> prev == DOT ? DOTSTAR : STAR; + NEW.mapping = prev -> prev == COLCOL ? COLCOLNEW : NEW; + CLASS.mapping = prev -> prev == DOT ? DOTCLASS : CLASS; } } @@ -520,7 +533,7 @@ class CompletenessAnalyzer { ct = match(BRACKETS, TokenKind.LBRACKET); break; default: - ct = new CT(TK.tokenKindToTK(current.kind), advance()); + ct = new CT(TK.tokenKindToTK(prevTK, current.kind), advance()); break; } if (ct.kind.isStart() && !prevTK.isOkToTerminate()) { @@ -539,21 +552,21 @@ class CompletenessAnalyzer { */ private static class Parser { - final Matched in; - CT token; - Completeness checkResult; + private final Supplier matchedFactory; + private final Supplier parseFactory; + private Matched in; + private CT token; + private Completeness checkResult; - final JShell proc; - final String scannedInput; + Parser(Supplier matchedFactory, Supplier parseFactory) { + this.matchedFactory = matchedFactory; + this.parseFactory = parseFactory; + resetInput(); + } - - - Parser(Matched in, JShell proc, String scannedInput) { - this.in = in; + final void resetInput() { + this.in = matchedFactory.get(); nextToken(); - - this.proc = proc; - this.scannedInput = scannedInput; } final void nextToken() { @@ -598,6 +611,10 @@ class CompletenessAnalyzer { return flags != Completeness.COMPLETE; } + public int endPos() { + return in.prevCT.endPos; + } + public Completeness parseUnit() { //System.err.printf("%s: belongs %o XANY1 %o\n", token.kind, token.kind.belongs, token.kind.belongs & XANY1); switch (token.kind.belongs & XANY1) { @@ -651,11 +668,11 @@ class CompletenessAnalyzer { case IDENTIFIER: case BRACKETS: return Completeness.COMPLETE_WITH_SEMI; - case STAR: + case DOTSTAR: if (isImport) { return Completeness.COMPLETE_WITH_SEMI; } else { - return Completeness.DEFINITELY_INCOMPLETE; + return Completeness.UNKNOWN; } default: return Completeness.DEFINITELY_INCOMPLETE; @@ -667,7 +684,7 @@ class CompletenessAnalyzer { public Completeness disambiguateDeclarationVsExpression() { // String folding messes up position information. - ParseTask pt = proc.taskFactory.new ParseTask(scannedInput); + ParseTask pt = parseFactory.get(); List units = pt.units(); if (units.isEmpty()) { return error(); @@ -679,7 +696,7 @@ class CompletenessAnalyzer { case LABELED_STATEMENT: if (shouldAbort(IDENTIFIER)) return checkResult; if (shouldAbort(COLON)) return checkResult; - return parseStatement(); + return parseStatement(); case VARIABLE: case IMPORT: case CLASS: @@ -693,51 +710,6 @@ class CompletenessAnalyzer { } } -// public Status parseExpressionOrDeclaration() { -// if (token.kind == IDENTIFIER) { -// nextToken(); -// switch (token.kind) { -// case IDENTIFIER: -// return parseDeclaration(); -// } -// } -// while (token.kind.isExpressionOrDeclaration()) { -// if (!token.kind.isExpression()) { -// return parseDeclaration(); -// } -// if (!token.kind.isDeclaration()) { -// // Expression not declaration -// if (token.kind == EQ) { -// // Check for array initializer -// nextToken(); -// if (token.kind == BRACES) { -// nextToken(); -// return lastly(SEMI); -// } -// } -// return parseExpressionStatement(); -// } -// nextToken(); -// } -// switch (token.kind) { -// case BRACES: -// case SEMI: -// nextToken(); -// return Status.COMPLETE; -// case UNMATCHED: -// nextToken(); -// return Status.DEFINITELY_INCOMPLETE; -// case EOF: -// if (in.prevCT.kind.isOkToTerminate()) { -// return Status.COMPLETE_WITH_SEMI; -// } else { -// return Status.DEFINITELY_INCOMPLETE; -// } -// default: -// return error(); -// } -// } - public Completeness parseExpressionStatement() { if (shouldAbort(parseExpression())) return checkResult; return lastly(SEMI); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java index 87f8d5af44d..79b8b221db5 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java @@ -555,9 +555,11 @@ class Eval { : ""; } catch (ResolutionException ex) { DeclarationSnippet sn = (DeclarationSnippet) state.maps.getSnippetDeadOrAlive(ex.id()); - exception = new UnresolvedReferenceException(sn, ex.getStackTrace()); + exception = new UnresolvedReferenceException(sn, translateExceptionStack(ex)); } catch (UserException ex) { - exception = translateExecutionException(ex); + exception = new EvalException(translateExceptionMessage(ex), + ex.causeExceptionClass(), + translateExceptionStack(ex)); } catch (RunException ex) { // StopException - no-op } catch (InternalException ex) { @@ -732,7 +734,7 @@ class Eval { } } - private EvalException translateExecutionException(UserException ex) { + private StackTraceElement[] translateExceptionStack(Exception ex) { StackTraceElement[] raw = ex.getStackTrace(); int last = raw.length; do { @@ -759,11 +761,14 @@ class Eval { elems[i] = r; } } + return elems; + } + + private String translateExceptionMessage(Exception ex) { String msg = ex.getMessage(); - if (msg.equals("")) { - msg = null; - } - return new EvalException(msg, ex.causeExceptionClass(), elems); + return msg.equals("") + ? null + : msg; } private boolean isWrap(StackTraceElement ste) { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java index a0ec79e9469..fd97832b676 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java @@ -51,8 +51,6 @@ import jdk.jshell.spi.ExecutionControl.EngineTerminationException; import jdk.jshell.spi.ExecutionControl.ExecutionControlException; import jdk.jshell.spi.ExecutionEnv; import static jdk.jshell.execution.Util.failOverExecutionControlGenerator; -import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.toList; import static jdk.jshell.Util.expunge; /** @@ -120,7 +118,8 @@ public class JShell implements AutoCloseable { this.executionControlGenerator = b.executionControlGenerator==null ? failOverExecutionControlGenerator( JDIDefaultExecutionControl.launch(), - JDIDefaultExecutionControl.listen()) + JDIDefaultExecutionControl.listen("localhost"), + JDIDefaultExecutionControl.listen(null)) : b.executionControlGenerator; this.maps = new SnippetMaps(this); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java index 5712a2202fe..7b9d73c1a66 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java @@ -95,24 +95,6 @@ class ReplParser extends JavacParser { mods = modifiersOpt(); } - if (token.kind == PACKAGE) { - int packagePos = token.pos; - List annotations = List.nil(); - seenPackage = true; - if (mods != null) { - checkNoMods(mods.flags); - annotations = mods.annotations; - mods = null; - } - nextToken(); - JCExpression pid = qualident(false); - accept(SEMI); - JCPackageDecl pd = F.at(packagePos).PackageDecl(annotations, pid); - attach(pd, firstToken.comment(CommentStyle.JAVADOC)); - storeEnd(pd, token.pos); - defs.append(pd); - } - boolean firstTypeDecl = true; while (token.kind != EOF) { if (token.pos > 0 && token.pos <= endPosTable.errorEndPos) { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 090bfb6d969..309f4b4ba09 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -838,8 +838,31 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { } private Stream localElements(Scope scope) { - @SuppressWarnings("unchecked") - Stream elements = Util.stream((Iterable)scope.getLocalElements()); + //workaround for: JDK-8024687 + Iterable elementsIt = () -> new Iterator() { + Iterator it = scope.getLocalElements().iterator(); + @Override + public boolean hasNext() { + while (true) { + try { + return it.hasNext(); + } catch (CompletionFailure cf) { + //ignore... + } + } + } + @Override + public Element next() { + while (true) { + try { + return it.next(); + } catch (CompletionFailure cf) { + //ignore... + } + } + } + }; + Stream elements = Util.stream(elementsIt); if (scope.getEnclosingScope() != null && scope.getEnclosingClass() != scope.getEnclosingScope().getEnclosingClass()) { diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java index 191d43cc088..28ed2d2acb8 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TaskFactory.java @@ -222,7 +222,7 @@ class TaskFactory { this(wraps.stream(), new WrapSourceHandler(), Util.join(new String[] { - "-Xshouldstop:at=FLOW", "-Xlint:unchecked", + "--should-stop:at=FLOW", "-Xlint:unchecked", "-proc:none" }, extraArgs)); } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java index ca400d536d0..09912801f7b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DemultiplexInput.java @@ -40,15 +40,14 @@ import java.util.Map; class DemultiplexInput extends Thread { private final DataInputStream delegate; - private final PipeInputStream command; private final Map io; + private final Iterable closeList; - DemultiplexInput(InputStream input, PipeInputStream command, - Map io) { + DemultiplexInput(InputStream input, Map io, Iterable closeList) { super("output reader"); this.delegate = new DataInputStream(input); - this.command = command; this.io = io; + this.closeList = closeList; } @Override @@ -65,23 +64,23 @@ class DemultiplexInput extends Thread { byte[] data = new byte[dataLen]; DemultiplexInput.this.delegate.readFully(data); String chan = new String(name, "UTF-8"); - if (chan.equals("command")) { - for (byte b : data) { - command.write(Byte.toUnsignedInt(b)); - } + OutputStream out = io.get(chan); + if (out == null) { + debug("Unexpected channel name: %s", chan); } else { - OutputStream out = io.get(chan); - if (out == null) { - debug("Unexpected channel name: %s", chan); - } else { - out.write(data); - } + out.write(data); } } } catch (IOException ex) { debug(ex, "Failed reading output"); } finally { - command.close(); + for (OutputStream out : closeList) { + try { + out.close(); + } catch (IOException ex) { + debug(ex, "Failed reading output"); + } + } } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java index 75f644efebd..18f8282f93b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java @@ -25,9 +25,9 @@ package jdk.jshell.execution; import java.io.IOException; +import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; @@ -48,7 +48,7 @@ import com.sun.jdi.VMDisconnectedException; import com.sun.jdi.VirtualMachine; import jdk.jshell.spi.ExecutionControl; import jdk.jshell.spi.ExecutionEnv; -import static jdk.jshell.execution.Util.remoteInput; +import static jdk.jshell.execution.Util.remoteInputOutput; /** * The implementation of {@link jdk.jshell.spi.ExecutionControl} that the @@ -77,17 +77,19 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { * @return the generator */ public static ExecutionControl.Generator launch() { - return env -> create(env, true); + return env -> create(env, true, null); } /** * Creates an ExecutionControl instance based on a JDI * {@code ListeningConnector}. * + * @param host explicit hostname to use, if null use discovered + * hostname, applies to listening only (!isLaunch) * @return the generator */ - public static ExecutionControl.Generator listen() { - return env -> create(env, false); + public static ExecutionControl.Generator listen(String host) { + return env -> create(env, false, host); } /** @@ -100,10 +102,15 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { * * @param env the context passed by * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) } + * @param isLaunch does JDI do the launch? That is, LaunchingConnector, + * otherwise we start explicitly and use ListeningConnector + * @param host explicit hostname to use, if null use discovered + * hostname, applies to listening only (!isLaunch) * @return the channel * @throws IOException if there are errors in set-up */ - private static JDIDefaultExecutionControl create(ExecutionEnv env, boolean isLaunch) throws IOException { + private static ExecutionControl create(ExecutionEnv env, + boolean isLaunch, String host) throws IOException { try (final ServerSocket listener = new ServerSocket(0)) { // timeout after 60 seconds listener.setSoTimeout(60000); @@ -111,14 +118,10 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { // Set-up the JDI connection JDIInitiator jdii = new JDIInitiator(port, - env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch); + env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch, host); VirtualMachine vm = jdii.vm(); Process process = jdii.process(); - // Forward input to the remote agent - Util.forwardInputToRemote(env.userIn(), process.getOutputStream(), - ex -> debug(ex, "input forwarding failure")); - List> deathListeners = new ArrayList<>(); deathListeners.add(s -> env.closeDown()); Util.detectJDIExitEvent(vm, s -> { @@ -131,12 +134,13 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl { // output. Socket socket = listener.accept(); // out before in -- match remote creation so we don't hang - ObjectOutput cmdout = new ObjectOutputStream(socket.getOutputStream()); - Map io = new HashMap<>(); - io.put("out", env.userOut()); - io.put("err", env.userErr()); - ObjectInput cmdin = remoteInput(socket.getInputStream(), io); - return new JDIDefaultExecutionControl(cmdout, cmdin, vm, process, deathListeners); + OutputStream out = socket.getOutputStream(); + Map outputs = new HashMap<>(); + outputs.put("out", env.userOut()); + outputs.put("err", env.userErr()); + Map input = new HashMap<>(); + input.put("in", env.userIn()); + return remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new JDIDefaultExecutionControl(objOut, objIn, vm, process, deathListeners)); } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java index 2c7b8d02a58..37d51db8c55 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java @@ -56,9 +56,11 @@ public class JDIInitiator { * @param remoteAgent full class name of remote agent to launch * @param isLaunch does JDI do the launch? That is, LaunchingConnector, * otherwise we start explicitly and use ListeningConnector + * @param host explicit hostname to use, if null use discovered + * hostname, applies to listening only (!isLaunch) */ - public JDIInitiator(int port, List remoteVMOptions, - String remoteAgent, boolean isLaunch) { + public JDIInitiator(int port, List remoteVMOptions, String remoteAgent, + boolean isLaunch, String host) { this.remoteAgent = remoteAgent; String connectorName = isLaunch @@ -72,6 +74,9 @@ public class JDIInitiator { = isLaunch ? launchArgs(port, String.join(" ", remoteVMOptions)) : new HashMap<>(); + if (host != null && !isLaunch) { + argumentName2Value.put("localAddress", host); + } this.connectorArgs = mergeConnectorArgs(connector, argumentName2Value); this.vm = isLaunch ? launchTarget() diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java index 43e3bc52287..4cc13d8673a 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/MultiplexingOutputStream.java @@ -50,13 +50,7 @@ class MultiplexingOutputStream extends OutputStream { @Override public void write(int b) throws IOException { - synchronized (delegate) { - delegate.write(name.length); //assuming the len is small enough to fit into byte - delegate.write(name); - delegate.write(1); - delegate.write(b); - delegate.flush(); - } + write(new byte[] {(byte) b}); } @Override @@ -65,10 +59,12 @@ class MultiplexingOutputStream extends OutputStream { int i = 0; while (len > 0) { int size = Math.min(PACKET_SIZE, len); - delegate.write(name.length); //assuming the len is small enough to fit into byte - delegate.write(name); - delegate.write(size); - delegate.write(b, off + i, size); + byte[] data = new byte[name.length + 1 + size + 1]; + data[0] = (byte) name.length; //assuming the len is small enough to fit into byte + System.arraycopy(name, 0, data, 1, name.length); + data[name.length + 1] = (byte) size; + System.arraycopy(b, off + i, data, name.length + 2, size); + delegate.write(data); i += size; len -= size; } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java index 1470827ff29..1b582fa9b10 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/PipeInputStream.java @@ -24,7 +24,9 @@ */ package jdk.jshell.execution; +import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; /** * @@ -39,7 +41,10 @@ class PipeInputStream extends InputStream { private boolean closed; @Override - public synchronized int read() { + public synchronized int read() throws IOException { + if (start == end) { + inputNeeded(); + } while (start == end) { if (closed) { return -1; @@ -57,7 +62,9 @@ class PipeInputStream extends InputStream { } } - public synchronized void write(int b) { + protected void inputNeeded() throws IOException {} + + private synchronized void write(int b) { if (closed) { throw new IllegalStateException("Already closed."); } @@ -85,4 +92,22 @@ class PipeInputStream extends InputStream { notifyAll(); } + public OutputStream createOutput() { + return new OutputStream() { + @Override public void write(int b) throws IOException { + PipeInputStream.this.write(b); + } + @Override + public void write(byte[] b, int off, int len) throws IOException { + for (int i = 0 ; i < len ; i++) { + write(Byte.toUnsignedInt(b[off + i])); + } + } + @Override + public void close() throws IOException { + PipeInputStream.this.close(); + } + }; + } + } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java index 9ea549c5fdb..8a131422b5a 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java @@ -61,10 +61,12 @@ public class RemoteExecutionControl extends DirectExecutionControl implements Ex Socket socket = new Socket(loopBack, Integer.parseInt(args[0])); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream(); - Map> chans = new HashMap<>(); - chans.put("out", st -> System.setOut(new PrintStream(st, true))); - chans.put("err", st -> System.setErr(new PrintStream(st, true))); - forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, chans); + Map> outputs = new HashMap<>(); + outputs.put("out", st -> System.setOut(new PrintStream(st, true))); + outputs.put("err", st -> System.setErr(new PrintStream(st, true))); + Map> input = new HashMap<>(); + input.put("in", st -> System.setIn(st)); + forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input); } // These three variables are used by the main JShell process in interrupting diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java index 9f1521572ff..da8decab065 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/Util.java @@ -25,6 +25,7 @@ package jdk.jshell.execution; import jdk.jshell.spi.ExecutionEnv; + import java.io.IOException; import java.io.InputStream; import java.io.ObjectInput; @@ -32,9 +33,13 @@ import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.io.OutputStream; +import java.util.Arrays; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.function.BiFunction; import java.util.function.Consumer; + import com.sun.jdi.VirtualMachine; import jdk.jshell.spi.ExecutionControl; @@ -99,21 +104,40 @@ public class Util { * instance, then responses back on the output. * @param ec the direct instance of {@link ExecutionControl} to process commands * @param inStream the stream from which to create the command input - * @param outStream the stream that will carry {@code System.out}, - * {@code System.err}, any specified auxiliary channels, and the - * command response output. - * @param streamMap a map between names of additional streams to carry and setters - * for the stream + * @param outStream the stream that will carry any specified auxiliary channels (like + * {@code System.out} and {@code System.err}), and the command response output. + * @param outputStreamMap a map between names of additional streams to carry and setters + * for the stream. Names starting with '$' are reserved for internal use. + * @param inputStreamMap a map between names of additional streams to carry and setters + * for the stream. Names starting with '$' are reserved for internal use. * @throws IOException if there are errors using the passed streams */ public static void forwardExecutionControlAndIO(ExecutionControl ec, InputStream inStream, OutputStream outStream, - Map> streamMap) throws IOException { - ObjectInputStream cmdIn = new ObjectInputStream(inStream); - for (Entry> e : streamMap.entrySet()) { + Map> outputStreamMap, + Map> inputStreamMap) throws IOException { + for (Entry> e : outputStreamMap.entrySet()) { e.getValue().accept(multiplexingOutputStream(e.getKey(), outStream)); } - ObjectOutputStream cmdOut = new ObjectOutputStream(multiplexingOutputStream("command", outStream)); + + ObjectOutputStream cmdOut = new ObjectOutputStream(multiplexingOutputStream("$command", outStream)); + PipeInputStream cmdInPipe = new PipeInputStream(); + Map inputs = new HashMap<>(); + inputs.put("$command", cmdInPipe.createOutput()); + for (Entry> e : inputStreamMap.entrySet()) { + OutputStream inputSignal = multiplexingOutputStream("$" + e.getKey() + "-input-requested", outStream); + PipeInputStream inputPipe = new PipeInputStream() { + @Override protected void inputNeeded() throws IOException { + inputSignal.write('1'); + inputSignal.flush(); + } + }; + inputs.put(e.getKey(), inputPipe.createOutput()); + e.getValue().accept(inputPipe); + } + new DemultiplexInput(inStream, inputs, inputs.values()).start(); + ObjectInputStream cmdIn = new ObjectInputStream(cmdInPipe); + forwardExecutionControl(ec, cmdIn, cmdOut); } @@ -122,18 +146,41 @@ public class Util { } /** - * Reads from an InputStream which has been packetized and write its contents - * to the out and err OutputStreams; Copies the command stream. + * Creates an ExecutionControl for given packetized input and output. The given InputStream + * is de-packetized, and content forwarded to ObjectInput and given OutputStreams. The ObjectOutput + * and values read from the given InputStream are packetized and sent to the given OutputStream. + * * @param input the packetized input stream - * @param streamMap a map between stream names and the output streams to forward - * @return the command stream + * @param output the packetized output stream + * @param outputStreamMap a map between stream names and the output streams to forward. + * Names starting with '$' are reserved for internal use. + * @param inputStreamMap a map between stream names and the input streams to forward. + * Names starting with '$' are reserved for internal use. + * @param factory to create the ExecutionControl from ObjectInput and ObjectOutput. + * @return the created ExecutionControl * @throws IOException if setting up the streams raised an exception */ - public static ObjectInput remoteInput(InputStream input, - Map streamMap) throws IOException { + public static ExecutionControl remoteInputOutput(InputStream input, OutputStream output, + Map outputStreamMap, Map inputStreamMap, + BiFunction factory) throws IOException { + Map augmentedStreamMap = new HashMap<>(outputStreamMap); + ObjectOutput commandOut = new ObjectOutputStream(Util.multiplexingOutputStream("$command", output)); + for (Entry e : inputStreamMap.entrySet()) { + InputStream in = e.getValue(); + OutputStream inTarget = Util.multiplexingOutputStream(e.getKey(), output); + augmentedStreamMap.put("$" + e.getKey() + "-input-requested", new OutputStream() { + @Override + public void write(int b) throws IOException { + //value ignored, just a trigger to read from the input + inTarget.write(in.read()); + } + }); + } PipeInputStream commandIn = new PipeInputStream(); - new DemultiplexInput(input, commandIn, streamMap).start(); - return new ObjectInputStream(commandIn); + OutputStream commandInTarget = commandIn.createOutput(); + augmentedStreamMap.put("$command", commandInTarget); + new DemultiplexInput(input, augmentedStreamMap, Arrays.asList(commandInTarget)).start(); + return factory.apply(new ObjectInputStream(commandIn), commandOut); } /** @@ -151,32 +198,4 @@ public class Util { } } - /** - * Creates a Thread that will ship all input to the remote agent. - * - * @param inputStream the user input - * @param outStream the input to the remote agent - * @param handler a failure handler - */ - public static void forwardInputToRemote(final InputStream inputStream, - final OutputStream outStream, final Consumer handler) { - Thread thr = new Thread("input reader") { - @Override - public void run() { - try { - byte[] buf = new byte[256]; - int cnt; - while ((cnt = inputStream.read(buf)) != -1) { - outStream.write(buf, 0, cnt); - outStream.flush(); - } - } catch (Exception ex) { - handler.accept(ex); - } - } - }; - thr.setPriority(Thread.MAX_PRIORITY - 1); - thr.start(); - } - } diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index a90395e8734..8ed5359b3be 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -77,10 +77,3 @@ tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires i ########################################################################### # # jdeps - -########################################################################### -# -# jdeprscan - -tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java 8164837 windows-all probably line breaks or encoding -tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java 8164837 windows-all probably line breaks or encoding diff --git a/langtools/test/jdk/javadoc/tool/ReleaseOption.java b/langtools/test/jdk/javadoc/tool/ReleaseOption.java index 9761af3f039..774b10ed658 100644 --- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java +++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java @@ -33,7 +33,7 @@ import jdk.javadoc.internal.tool.Main; /** * @test * @bug 8086737 - * @summary Test -release option in javadoc + * @summary Test --release option in javadoc * @run main ReleaseOption * @modules jdk.javadoc/jdk.javadoc.internal.tool */ @@ -43,10 +43,10 @@ public class ReleaseOption { } void run() { - doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "7"); - doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "8"); - doRunTest(1, out -> true, "-release", "7", "-source", "7"); - doRunTest(1, out -> true, "-release", "7", "-bootclasspath", "any"); + doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7"); + doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8"); + doRunTest(1, out -> true, "--release", "7", "-source", "7"); + doRunTest(1, out -> true, "--release", "7", "-bootclasspath", "any"); } void doRunTest(int expectedResult, Predicate validate, String... args) { diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java index 6544084a133..ad01de44959 100644 --- a/langtools/test/jdk/jshell/CommandCompletionTest.java +++ b/langtools/test/jdk/jshell/CommandCompletionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8144095 + * @bug 8144095 8164825 * @summary Test Command Completion * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -40,6 +40,7 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Predicate; @@ -148,6 +149,80 @@ public class CommandCompletionTest extends ReplToolTesting { assertCompletion("/classpath ~/|", false, completions.toArray(new String[completions.size()])); } + public void testSet() throws IOException { + List p1 = listFiles(Paths.get("")); + FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString())); + Collections.sort(p1); + + String[] modes = {"concise ", "normal ", "silent ", "verbose "}; + String[] options = {"-command", "-delete", "-quiet"}; + String[] modesWithOptions = Stream.concat(Arrays.stream(options), Arrays.stream(modes)).sorted().toArray(String[]::new); + test(false, new String[] {"--no-startup"}, + a -> assertCompletion(a, "/se|", false, "/set "), + a -> assertCompletion(a, "/set |", false, "editor ", "feedback ", "format ", "mode ", "prompt ", "start ", "truncation "), + + // /set editor + a -> assertCompletion(a, "/set e|", false, "editor "), + a -> assertCompletion(a, "/set editor |", false, p1.toArray(new String[p1.size()])), + + // /set feedback + a -> assertCompletion(a, "/set fe|", false, "feedback "), + a -> assertCompletion(a, "/set fe |", false, modes), + + // /set format + a -> assertCompletion(a, "/set fo|", false, "format "), + a -> assertCompletion(a, "/set fo |", false, modes), + + // /set mode + a -> assertCompletion(a, "/set mo|", false, "mode "), + a -> assertCompletion(a, "/set mo |", false), + a -> assertCompletion(a, "/set mo newmode |", false, modesWithOptions), + a -> assertCompletion(a, "/set mo newmode -|", false, options), + a -> assertCompletion(a, "/set mo newmode -command |", false), + a -> assertCompletion(a, "/set mo newmode normal |", false, options), + + // /set prompt + a -> assertCompletion(a, "/set pro|", false, "prompt "), + a -> assertCompletion(a, "/set pro |", false, modes), + + // /set start + a -> assertCompletion(a, "/set st|", false, "start "), + a -> assertCompletion(a, "/set st |", false, p1.toArray(new String[p1.size()])), + + // /set truncation + a -> assertCompletion(a, "/set tr|", false, "truncation "), + a -> assertCompletion(a, "/set tr |", false, modes) + ); + } + + public void testRetain() throws IOException { + List p1 = listFiles(Paths.get("")); + FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString())); + Collections.sort(p1); + + String[] modes = {"concise ", "normal ", "silent ", "verbose "}; + test(false, new String[] {"--no-startup"}, + a -> assertCompletion(a, "/ret|", false, "/retain "), + a -> assertCompletion(a, "/retain |", false, "editor ", "feedback ", "mode ", "start "), + + // /retain editor + a -> assertCompletion(a, "/retain e|", false, "editor "), + a -> assertCompletion(a, "/retain editor |", false, p1.toArray(new String[p1.size()])), + + // /retain feedback + a -> assertCompletion(a, "/retain fe|", false, "feedback "), + a -> assertCompletion(a, "/retain fe |", false, modes), + + // /retain mode + a -> assertCompletion(a, "/retain mo|", false, "mode "), + a -> assertCompletion(a, "/retain mo |", false, modes), + + // /retain start + a -> assertCompletion(a, "/retain st|", false, "start "), + a -> assertCompletion(a, "/retain st |", false, p1.toArray(new String[p1.size()])) + ); + } + private void createIfNeeded(Path file) throws IOException { if (!Files.exists(file)) Files.createFile(file); diff --git a/langtools/test/jdk/jshell/CompletenessTest.java b/langtools/test/jdk/jshell/CompletenessTest.java index bf95b51f311..b0e5a781036 100644 --- a/langtools/test/jdk/jshell/CompletenessTest.java +++ b/langtools/test/jdk/jshell/CompletenessTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8149524 8131024 + * @bug 8149524 8131024 8165211 8080071 8130454 * @summary Test SourceCodeAnalysis * @build KullaTesting TestingInputStream * @run testng CompletenessTest @@ -63,6 +63,7 @@ public class CompletenessTest extends KullaTesting { "foo: while (true) { printf(\"Innn\"); break foo; }", "class Case, E2 extends Enum, E3 extends Enum> {}", ";", + "enum Tt { FOO, BAR, BAZ,; }" }; static final String[] expression = new String[] { @@ -77,6 +78,8 @@ public class CompletenessTest extends KullaTesting { "new int[] {1, 2,3}", "new Foo() {}", "i >= 0 && Character.isWhitespace(s.charAt(i))", + "int.class", + "String.class", }; static final String[] complete_with_semi = new String[] { @@ -113,6 +116,7 @@ public class CompletenessTest extends KullaTesting { "BufferedReader br = new BufferedReader(new FileReader(path))", "bar: g()", "baz: while (true) if (t()) printf('-'); else break baz", + "java.util.function.IntFunction ggg = int[]::new", }; static final String[] considered_incomplete = new String[] { @@ -141,6 +145,8 @@ public class CompletenessTest extends KullaTesting { "if (match.kind == BRACES && (prevCT.kind == ARROW || prevCT.kind == NEW_MIDDLE)) {", "if (match.kind == BRACES && (prevCT.kind == ARROW || prevCT.kind == NEW_MIDDLE)) { new CT(UNMATCHED, current, \"Unmatched \" + unmatched);", "x +", + "x *", + "3 *", "int", "for (int i = 0; i < lines.length(); ++i) {", "new", @@ -156,6 +162,7 @@ public class CompletenessTest extends KullaTesting { "enum TK { EOF(TokenKind.EOF, 0),", "enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM)", "enum TK { EOF(TokenKind.EOF, 0), NEW_MIDDLE(XEXPR1|XTERM); ", + "enum Tt { FOO, BAR, BAZ,;" }; static final String[] unknown = new String[] { diff --git a/langtools/test/jdk/jshell/CompletionSuggestionTest.java b/langtools/test/jdk/jshell/CompletionSuggestionTest.java index 93767169bed..b3a40be8e87 100644 --- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java +++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8141092 8153761 + * @bug 8131025 8141092 8153761 * @summary Test Completion * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -419,9 +419,9 @@ public class CompletionSuggestionTest extends KullaTesting { public void testUncompletedDeclaration() { assertCompletion("class Clazz { Claz|", "Clazz"); assertCompletion("class Clazz { class A extends Claz|", "Clazz"); - assertCompletion("class Clazz { Clazz clazz; Object o = cla|", "clazz"); - assertCompletion("class Clazz { static Clazz clazz; Object o = cla|", "clazz"); - assertCompletion("class Clazz { Clazz clazz; static Object o = cla|", true); + assertCompletion("class Clazz { Clazz clazz; Object o = claz|", "clazz"); + assertCompletion("class Clazz { static Clazz clazz; Object o = claz|", "clazz"); + assertCompletion("class Clazz { Clazz clazz; static Object o = claz|", true); assertCompletion("class Clazz { void method(Claz|", "Clazz"); assertCompletion("class A { int method() { return 0; } int a = meth|", "method()"); assertCompletion("class A { int field = 0; int method() { return fiel|", "field"); @@ -610,4 +610,26 @@ public class CompletionSuggestionTest extends KullaTesting { keepParameterNames.setAccessible(true); keepParameterNames.set(getAnalysis(), new String[0]); } + + public void testBrokenClassFile2() throws IOException { + Path broken = outDir.resolve("broken"); + compiler.compile(broken, + "package p;\n" + + "public class BrokenA {\n" + + "}", + "package p.q;\n" + + "public class BrokenB {\n" + + "}", + "package p;\n" + + "public class BrokenC {\n" + + "}"); + Path cp = compiler.getPath(broken); + Path target = cp.resolve("p").resolve("BrokenB.class"); + Files.deleteIfExists(target); + Files.move(cp.resolve("p").resolve("q").resolve("BrokenB.class"), target); + addToClasspath(cp); + + assertEval("import p.*;"); + assertCompletion("Broke|", "BrokenA", "BrokenC"); + } } diff --git a/langtools/test/jdk/jshell/IdGeneratorTest.java b/langtools/test/jdk/jshell/IdGeneratorTest.java index 1a3f167ba3c..38ccc1b3de5 100644 --- a/langtools/test/jdk/jshell/IdGeneratorTest.java +++ b/langtools/test/jdk/jshell/IdGeneratorTest.java @@ -99,19 +99,18 @@ public class IdGeneratorTest { } } - @Test(enabled = false) // TODO 8133507 public void testIdInException() { JShell.Builder builder = getBuilder().idGenerator(((snippet, id) -> "custom" + id)); try (JShell jShell = builder.build()) { EvalException evalException = (EvalException) jShell.eval("throw new Error();").get(0).exception(); for (StackTraceElement ste : evalException.getStackTrace()) { - assertTrue(ste.getFileName().startsWith("custom"), "Not started with \"custom\": " + assertTrue(ste.getFileName().startsWith("#custom"), "Not started with \"#custom\": " + ste.getFileName()); } jShell.eval("void f() { g(); }"); UnresolvedReferenceException unresolvedException = (UnresolvedReferenceException) jShell.eval("f();").get(0).exception(); for (StackTraceElement ste : unresolvedException.getStackTrace()) { - assertTrue(ste.getFileName().startsWith("custom"), "Not started with \"custom\": " + assertTrue(ste.getFileName().startsWith("#custom"), "Not started with \"#custom\": " + ste.getFileName()); } } diff --git a/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java b/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java new file mode 100644 index 00000000000..3baa5378d7b --- /dev/null +++ b/langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, 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 8164518 + * @summary Tests for standard JDI connector (without failover) -- launching + * @modules jdk.jshell/jdk.jshell.execution + * @build KullaTesting ExecutionControlTestBase + * @run testng JDILaunchingExecutionControlTest + */ + + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import jdk.jshell.execution.JDIDefaultExecutionControl; + +@Test +public class JDILaunchingExecutionControlTest extends ExecutionControlTestBase { + + @BeforeMethod + @Override + public void setUp() { + setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.launch())); + } +} diff --git a/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java b/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java index dda377f6017..2540b90a1e3 100644 --- a/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java +++ b/langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8131029 8159935 8160127 + * @bug 8131029 8159935 8160127 8164518 * @summary Tests for alternate JDI connector -- listening * @modules jdk.jshell/jdk.jshell.execution * @build KullaTesting ExecutionControlTestBase @@ -41,6 +41,6 @@ public class JDIListeningExecutionControlTest extends ExecutionControlTestBase { @BeforeMethod @Override public void setUp() { - setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen())); + setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen(null))); } } diff --git a/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java b/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java new file mode 100644 index 00000000000..52a4487c674 --- /dev/null +++ b/langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, 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 8164518 + * @summary Tests for alternate JDI connector -- listening to "localhost" + * @modules jdk.jshell/jdk.jshell.execution + * @build KullaTesting ExecutionControlTestBase + * @run testng JDIListeningLocalhostExecutionControlTest + */ + + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import jdk.jshell.execution.JDIDefaultExecutionControl; + +@Test +public class JDIListeningLocalhostExecutionControlTest extends ExecutionControlTestBase { + + @BeforeMethod + @Override + public void setUp() { + setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen("localhost"))); + } +} diff --git a/langtools/test/jdk/jshell/RejectedFailedTest.java b/langtools/test/jdk/jshell/RejectedFailedTest.java index b9d8bece7cb..5411d5d8aee 100644 --- a/langtools/test/jdk/jshell/RejectedFailedTest.java +++ b/langtools/test/jdk/jshell/RejectedFailedTest.java @@ -22,7 +22,7 @@ */ /* - * @test + * @test 8080352 * @summary Tests for hard errors, like syntax errors * @build KullaTesting * @run testng RejectedFailedTest @@ -81,6 +81,7 @@ public class RejectedFailedTest extends KullaTesting { " a b c", ")", "class interface A", + "package foo;" }; checkByKind(inputsErroneous, Kind.ERRONEOUS); } diff --git a/langtools/test/jdk/jshell/ReplToolTesting.java b/langtools/test/jdk/jshell/ReplToolTesting.java index a2e80a78260..23c70af0690 100644 --- a/langtools/test/jdk/jshell/ReplToolTesting.java +++ b/langtools/test/jdk/jshell/ReplToolTesting.java @@ -247,7 +247,6 @@ public class ReplToolTesting { new PrintStream(cmdout), new PrintStream(cmderr), new PrintStream(console), - userin, new PrintStream(userout), new PrintStream(usererr), prefs, @@ -463,7 +462,7 @@ public class ReplToolTesting { private List computeCompletions(String code, boolean isSmart) { JShellTool js = this.repl != null ? this.repl - : new JShellTool(null, null, null, null, null, null, null, prefs, Locale.ROOT); + : new JShellTool(null, null, null, null, null, null, prefs, Locale.ROOT); int cursor = code.indexOf('|'); code = code.replace("|", ""); assertTrue(cursor > -1, "'|' not found: " + code); diff --git a/langtools/test/jdk/jshell/StartOptionTest.java b/langtools/test/jdk/jshell/StartOptionTest.java index 5ca48854341..dbbbf0943f6 100644 --- a/langtools/test/jdk/jshell/StartOptionTest.java +++ b/langtools/test/jdk/jshell/StartOptionTest.java @@ -63,7 +63,6 @@ public class StartOptionTest { new PrintStream(cmdout), new PrintStream(cmderr), new PrintStream(console), - new TestingInputStream(), new PrintStream(userout), new PrintStream(usererr), new ReplToolTesting.MemoryPreferences(), diff --git a/langtools/test/jdk/jshell/UserInputTest.java b/langtools/test/jdk/jshell/UserInputTest.java new file mode 100644 index 00000000000..5289ab7c56b --- /dev/null +++ b/langtools/test/jdk/jshell/UserInputTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, 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 8131023 + * @summary Verify that the user's code can read System.in + * @build KullaTesting TestingInputStream + * @run testng UserInputTest + */ + +import org.testng.annotations.Test; + +@Test +public class UserInputTest extends KullaTesting { + + public void testReadInput() { + setInput("AB\n"); + assertEval("System.in.read()", "65"); + setInput("BC\n"); + assertEval("System.in.read()", "66"); + } + +} diff --git a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java b/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java index e1e658ab44b..bfd04a1289c 100644 --- a/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java +++ b/langtools/test/jdk/jshell/UserJDIUserRemoteTest.java @@ -37,7 +37,6 @@ import static jdk.jshell.Snippet.Status.VALID; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.util.ArrayList; import java.util.List; @@ -62,7 +61,7 @@ import jdk.jshell.spi.ExecutionEnv; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; import static jdk.jshell.execution.Util.forwardExecutionControlAndIO; -import static jdk.jshell.execution.Util.remoteInput; +import static jdk.jshell.execution.Util.remoteInputOutput; @Test public class UserJDIUserRemoteTest extends ExecutionControlTestBase { @@ -146,7 +145,7 @@ class MyExecutionControl extends JDIExecutionControl { * @return the channel * @throws IOException if there are errors in set-up */ - static MyExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException { + static ExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException { try (final ServerSocket listener = new ServerSocket(0)) { // timeout after 60 seconds listener.setSoTimeout(60000); @@ -159,7 +158,7 @@ class MyExecutionControl extends JDIExecutionControl { + System.getProperty("path.separator") + System.getProperty("user.dir")); JDIInitiator jdii = new JDIInitiator(port, - opts, REMOTE_AGENT, true); + opts, REMOTE_AGENT, true, null); VirtualMachine vm = jdii.vm(); Process process = jdii.process(); @@ -175,13 +174,14 @@ class MyExecutionControl extends JDIExecutionControl { // output. Socket socket = listener.accept(); // out before in -- match remote creation so we don't hang - ObjectOutput cmdout = new ObjectOutputStream(socket.getOutputStream()); - Map io = new HashMap<>(); - io.put("out", env.userOut()); - io.put("err", env.userErr()); - io.put("aux", test.auxStream); - ObjectInput cmdin = remoteInput(socket.getInputStream(), io); - MyExecutionControl myec = new MyExecutionControl(cmdout, cmdin, vm, process, deathListeners); + OutputStream out = socket.getOutputStream(); + Map outputs = new HashMap<>(); + outputs.put("out", env.userOut()); + outputs.put("err", env.userErr()); + outputs.put("aux", test.auxStream); + Map input = new HashMap<>(); + input.put("in", env.userIn()); + ExecutionControl myec = remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new MyExecutionControl(objOut, objIn, vm, process, deathListeners)); test.currentEC = myec; return myec; } @@ -255,11 +255,13 @@ class MyRemoteExecutionControl extends DirectExecutionControl implements Executi Socket socket = new Socket(loopBack, Integer.parseInt(args[0])); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream(); - Map> chans = new HashMap<>(); - chans.put("out", st -> System.setOut(new PrintStream(st, true))); - chans.put("err", st -> System.setErr(new PrintStream(st, true))); - chans.put("aux", st -> { auxPrint = new PrintStream(st, true); }); - forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, chans); + Map> outputs = new HashMap<>(); + outputs.put("out", st -> System.setOut(new PrintStream(st, true))); + outputs.put("err", st -> System.setErr(new PrintStream(st, true))); + outputs.put("aux", st -> { auxPrint = new PrintStream(st, true); }); + Map> input = new HashMap<>(); + input.put("in", st -> System.setIn(st)); + forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, outputs, input); } catch (Throwable ex) { throw ex; } diff --git a/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java b/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java index 728ddbda217..77bf387f7e7 100644 --- a/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java +++ b/langtools/test/tools/javac/ClassFileModifiers/ClassModifiers.java @@ -28,7 +28,7 @@ * file are correct, including those within InnerClasses attributes. * @author John Rose (jrose). Entered as a regression test by Bill Maddox (maddox). * - * @compile/ref=ClassModifiers.out -Xdebug:dumpmodifiers=ci ClassModifiers.java + * @compile/ref=ClassModifiers.out --debug:dumpmodifiers=ci ClassModifiers.java * */ diff --git a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java index b6697d0afa0..fa134f816ae 100644 --- a/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java +++ b/langtools/test/tools/javac/ClassFileModifiers/MemberModifiers.java @@ -26,7 +26,7 @@ * @bug 4249112 4785453 * @summary Verify that implicit member modifiers are set correctly. * - * @compile/ref=MemberModifiers.out -Xdebug:dumpmodifiers=cfm MemberModifiers.java + * @compile/ref=MemberModifiers.out --debug:dumpmodifiers=cfm MemberModifiers.java */ // Currently, we check only that members of final classes are not final. diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java index 0d48df3d2a4..04008efcfb3 100644 --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234a.java @@ -3,8 +3,8 @@ * @bug 6722234 * @summary javac diagnostics need better integration with the type-system * @author mcimadamore - * @compile/fail/ref=T6722234a_1.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars T6722234a.java - * @compile/fail/ref=T6722234a_2.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T6722234a.java + * @compile/fail/ref=T6722234a_1.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars T6722234a.java + * @compile/fail/ref=T6722234a_2.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T6722234a.java */ class T6722234a { diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java index 6c58f552b56..47a1716cf2a 100644 --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234b.java @@ -3,8 +3,8 @@ * @bug 6722234 8078024 * @summary javac diagnostics need better integration with the type-system * @author mcimadamore - * @compile/fail/ref=T6722234b_1.out -XDrawDiagnostics -diags:formatterOptions=simpleNames T6722234b.java - * @compile/fail/ref=T6722234b_2.out -XDrawDiagnostics -diags:formatterOptions=simpleNames,where T6722234b.java + * @compile/fail/ref=T6722234b_1.out -XDrawDiagnostics --diags:formatterOptions=simpleNames T6722234b.java + * @compile/fail/ref=T6722234b_2.out -XDrawDiagnostics --diags:formatterOptions=simpleNames,where T6722234b.java */ import java.util.*; diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java index 443e53b921f..4b12953003d 100644 --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234c.java @@ -3,7 +3,7 @@ * @bug 6722234 * @summary javac diagnostics need better integration with the type-system * @author mcimadamore - * @compile/fail/ref=T6722234c.out -XDrawDiagnostics -diags:formatterOptions=simpleNames T6722234c.java + * @compile/fail/ref=T6722234c.out -XDrawDiagnostics --diags:formatterOptions=simpleNames T6722234c.java */ class T6722234c { diff --git a/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java b/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java index 7cdcbf7c26f..95fa4fb24ab 100644 --- a/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java +++ b/langtools/test/tools/javac/Diagnostics/6722234/T6722234d.java @@ -3,8 +3,8 @@ * @bug 6722234 8078024 * @summary javac diagnostics need better integration with the type-system * @author mcimadamore - * @compile/fail/ref=T6722234d_1.out -XDrawDiagnostics -diags:formatterOptions=where T6722234d.java - * @compile/fail/ref=T6722234d_2.out -XDrawDiagnostics -diags:formatterOptions=where,simpleNames T6722234d.java + * @compile/fail/ref=T6722234d_1.out -XDrawDiagnostics --diags:formatterOptions=where T6722234d.java + * @compile/fail/ref=T6722234d_2.out -XDrawDiagnostics --diags:formatterOptions=where,simpleNames T6722234d.java */ class T6722234d { diff --git a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java index 2117363a939..1713c05e202 100644 --- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java +++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.java @@ -3,7 +3,7 @@ * @bug 6862608 * @summary rich diagnostic sometimes contain wrong type variable numbering * @author mcimadamore - * @compile/fail/ref=T6862608a.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T6862608a.java + * @compile/fail/ref=T6862608a.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T6862608a.java */ diff --git a/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java b/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java index 9889b3bc8c9..14c61a33142 100644 --- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java +++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608b.java @@ -3,7 +3,7 @@ * @bug 6862608 * @summary rich diagnostic sometimes contain wrong type variable numbering * @author mcimadamore - * @compile/fail/ref=T6862608b.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T6862608b.java + * @compile/fail/ref=T6862608b.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T6862608b.java */ class T66862608b { diff --git a/langtools/test/tools/javac/Diagnostics/7010608/Test.java b/langtools/test/tools/javac/Diagnostics/7010608/Test.java index 9265995685e..332d26a0d9d 100644 --- a/langtools/test/tools/javac/Diagnostics/7010608/Test.java +++ b/langtools/test/tools/javac/Diagnostics/7010608/Test.java @@ -46,9 +46,9 @@ public class Test { try { test(Arrays.asList(), "myfo://test:1: error: cannot find symbol"); - test(Arrays.asList("-diags:layout=OLD"), + test(Arrays.asList("--diags:layout=OLD"), "myfo://test:1: cannot find symbol"); - test(Arrays.asList("-diags:legacy"), + test(Arrays.asList("--diags:legacy"), "myfo://test:1: cannot find symbol"); } finally { Locale.setDefault(prev); diff --git a/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java index 0ab5f0229c9..74a664cd160 100644 --- a/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java +++ b/langtools/test/tools/javac/Diagnostics/8010387/T8010387.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8010387 * @summary rich diagnostic sometimes contain wrong type variable numbering - * @compile/fail/ref=T8010387.out -XDrawDiagnostics -diags:formatterOptions=disambiguateTvars,where T8010387.java + * @compile/fail/ref=T8010387.out -XDrawDiagnostics --diags:formatterOptions=disambiguateTvars,where T8010387.java */ abstract class T8010387 { diff --git a/langtools/test/tools/javac/InterfaceMemberClassModifiers.java b/langtools/test/tools/javac/InterfaceMemberClassModifiers.java index 638cb731ff9..bb5fd1367e6 100644 --- a/langtools/test/tools/javac/InterfaceMemberClassModifiers.java +++ b/langtools/test/tools/javac/InterfaceMemberClassModifiers.java @@ -4,7 +4,7 @@ * @summary Verify that invalid access modifiers on interface members don't cause crash. * @author maddox * - * @compile/fail/ref=InterfaceMemberClassModifiers.out -diags:layout=%b:%l:%_%m InterfaceMemberClassModifiers.java + * @compile/fail/ref=InterfaceMemberClassModifiers.out --diags:layout=%b:%l:%_%m InterfaceMemberClassModifiers.java */ public interface InterfaceMemberClassModifiers { diff --git a/langtools/test/tools/javac/T4994049/DeprecatedYES.out b/langtools/test/tools/javac/T4994049/DeprecatedYES.out index 0750441a39c..3925e16ded9 100644 --- a/langtools/test/tools/javac/T4994049/DeprecatedYES.out +++ b/langtools/test/tools/javac/T4994049/DeprecatedYES.out @@ -1,4 +1,5 @@ -DeprecatedYES.java:18:10: compiler.warn.has.been.deprecated: foo(), A +DeprecatedYES.java:12:10: compiler.warn.missing.deprecated.annotation - compiler.err.warnings.and.werror +DeprecatedYES.java:18:10: compiler.warn.has.been.deprecated: foo(), A 1 error -1 warning +2 warnings diff --git a/langtools/test/tools/javac/T5003235/T5003235a.java b/langtools/test/tools/javac/T5003235/T5003235a.java index f30ad7a8ebf..1eea9628b3b 100644 --- a/langtools/test/tools/javac/T5003235/T5003235a.java +++ b/langtools/test/tools/javac/T5003235/T5003235a.java @@ -3,7 +3,7 @@ * @bug 5003235 * @summary Private inner class accessible from subclasses * @author Peter von der Ah\u00e9 - * @compile/fail/ref=T5003235a.out -diags:layout=%b:%l:%_%m T5003235a.java + * @compile/fail/ref=T5003235a.out --diags:layout=%b:%l:%_%m T5003235a.java */ class Super { diff --git a/langtools/test/tools/javac/T5003235/T5003235b.java b/langtools/test/tools/javac/T5003235/T5003235b.java index 3384f909b6c..629e077dba5 100644 --- a/langtools/test/tools/javac/T5003235/T5003235b.java +++ b/langtools/test/tools/javac/T5003235/T5003235b.java @@ -3,7 +3,7 @@ * @bug 5003235 * @summary Accessibility of private inner class * @author Peter von der Ah\u00e9 - * @compile/fail/ref=T5003235b.out -diags:layout=%b:%l:%_%m T5003235b.java + * @compile/fail/ref=T5003235b.out --diags:layout=%b:%l:%_%m T5003235b.java */ class Outer { diff --git a/langtools/test/tools/javac/T6214885.java b/langtools/test/tools/javac/T6214885.java index 73fff2c10a9..f79b752ecbc 100644 --- a/langtools/test/tools/javac/T6214885.java +++ b/langtools/test/tools/javac/T6214885.java @@ -2,8 +2,8 @@ * @test /nodynamiccopyright/ * @bug 6214885 * @summary This test exercises features provided by the new internal Diagnostics API - * @compile/fail/ref=T6214885a.out -diags:layout=%b:%l%_%t%m|%p%m T6214885.java - * @compile/fail/ref=T6214885b.out -diags:layout=%b:%l:%c%_%t%m|%p%m T6214885.java + * @compile/fail/ref=T6214885a.out --diags:layout=%b:%l%_%t%m|%p%m T6214885.java + * @compile/fail/ref=T6214885b.out --diags:layout=%b:%l:%c%_%t%m|%p%m T6214885.java */ class T6214885 { diff --git a/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java b/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java index 83707369e62..49fd4d46cf7 100644 --- a/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java +++ b/langtools/test/tools/javac/T8026963/TypeAnnotationsCrashWithErroneousTreeTest.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8026963 * @summary type annotations code crashes for lambdas with void argument - * @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics -Xshouldstop:at=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java + * @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics --should-stop:at=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java */ public class TypeAnnotationsCrashWithErroneousTreeTest { diff --git a/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java b/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java index 5e0c19cddb3..38f9f583884 100644 --- a/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java +++ b/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java @@ -24,8 +24,8 @@ /* * @test * bug 8139474 - * @summary -release 7 -verbose causes Javac exception - * @compile -release 7 -verbose DashRelease7DashVerboseTest.java + * @summary --release 7 -verbose causes Javac exception + * @compile --release 7 -verbose DashRelease7DashVerboseTest.java */ public class DashRelease7DashVerboseTest {} diff --git a/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java b/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java index 61809f98a25..263a145af38 100644 --- a/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java +++ b/langtools/test/tools/javac/annotations/neg/8022765/VerifyErroneousAnnotationsAttributed.java @@ -237,7 +237,7 @@ public class VerifyErroneousAnnotationsAttributed { JavacTask task = tool.getTask(null, fm, devNull, - Arrays.asList("-Xshouldstop:at=FLOW"), + Arrays.asList("--should-stop:at=FLOW"), null, Arrays.asList(new MyFileObject(code))); diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java index 0fae6e01d5d..bea25e934c8 100644 --- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java +++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/AfterMethodTypeParams.java @@ -54,7 +54,7 @@ public class AfterMethodTypeParams { String test = TEMPLATE.replace("CONTENT", tc.snippet); List files = Arrays.asList(new MyFileObject(test)); StringWriter out = new StringWriter(); - List options = Arrays.asList("-XDrawDiagnostics", "-Xshouldstop:at=FLOW"); + List options = Arrays.asList("-XDrawDiagnostics", "--should-stop:at=FLOW"); JavacTask task = (JavacTask) compiler.getTask(out, null, null, options, null, files); new TreePathScanner() { diff --git a/langtools/test/tools/javac/api/6731573/T6731573.java b/langtools/test/tools/javac/api/6731573/T6731573.java index 141cc9d7234..435e2b26f98 100644 --- a/langtools/test/tools/javac/api/6731573/T6731573.java +++ b/langtools/test/tools/javac/api/6731573/T6731573.java @@ -62,8 +62,8 @@ public class T6731573 extends ToolTester { enum SourceLine { STANDARD(null), - ENABLED("-diags:showSource=true"), - DISABLED("-diags:showSource=false"); + ENABLED("--diags:showSource=true"), + DISABLED("--diags:showSource=false"); String optValue; diff --git a/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java index 1b51e2af078..b55053c7a81 100644 --- a/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java +++ b/langtools/test/tools/javac/api/taskListeners/EventsBalancedTest.java @@ -63,11 +63,11 @@ public class EventsBalancedTest { test(null, Arrays.asList(b, a)); for (CompileState stop : CompileState.values()) { - test(Arrays.asList("-Xshouldstop:ifNoError=" + stop, - "-Xshouldstop:ifError=" + stop), + test(Arrays.asList("--should-stop:ifNoError=" + stop, + "--should-stop:ifError=" + stop), Arrays.asList(a, b)); - test(Arrays.asList("-Xshouldstop:ifNoError=" + stop, - "-Xshouldstop:ifError=" + stop), + test(Arrays.asList("--should-stop:ifNoError=" + stop, + "--should-stop:ifError=" + stop), Arrays.asList(b, a)); } } diff --git a/langtools/test/tools/javac/completionDeps/DepsAndAnno.java b/langtools/test/tools/javac/completionDeps/DepsAndAnno.java index 072010bc40e..8ba7f54e183 100644 --- a/langtools/test/tools/javac/completionDeps/DepsAndAnno.java +++ b/langtools/test/tools/javac/completionDeps/DepsAndAnno.java @@ -47,7 +47,7 @@ public class DepsAndAnno { public static void main(String[] args) { ToolBox toolBox = new ToolBox(); new JavacTask(toolBox, Task.Mode.CMDLINE) - .options("-Xdebug:completionDeps") + .options("--debug:completionDeps") .outdir(".") .files(ToolBox.testSrc + "/DepsAndAnno.java") .run(); diff --git a/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java b/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java index 86501ea091d..95912f01c52 100644 --- a/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java +++ b/langtools/test/tools/javac/completionDeps/DepsAndDocLint.java @@ -25,7 +25,7 @@ * @test * @bug 8078389 * @summary Make sure there is no interference between completionDeps and doclint - * @compile -Xdebug:completionDeps -Xdoclint DepsAndDocLint.java + * @compile --debug:completionDeps -Xdoclint DepsAndDocLint.java */ public class DepsAndDocLint { diff --git a/langtools/test/tools/javac/danglingDep/DepX.out b/langtools/test/tools/javac/danglingDep/DepX.out index 7260f4c18a3..433e1871b92 100644 --- a/langtools/test/tools/javac/danglingDep/DepX.out +++ b/langtools/test/tools/javac/danglingDep/DepX.out @@ -1,2 +1,4 @@ +DepX.java:38:1: compiler.warn.missing.deprecated.annotation - compiler.note.deprecated.filename: RefX.java - compiler.note.deprecated.recompile +1 warning diff --git a/langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java b/langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java new file mode 100644 index 00000000000..dbfc6b55011 --- /dev/null +++ b/langtools/test/tools/javac/depDocComment/SuppressDepAnnWithSwitchTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, 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 8164073 + * @summary Verify that -Xlint:-dep-ann suppresses warnings. + * @compile -Xlint:-dep-ann -Werror SuppressDepAnnWithSwitchTest.java + */ + +public class SuppressDepAnnWithSwitchTest { + /** @deprecated */ + int f; +} diff --git a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java index 4d8849cd579..7968487f129 100644 --- a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java +++ b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.java @@ -1,10 +1,11 @@ /** * @test /nodynamiccopyright/ - * @bug 4216683 4346296 4656556 4785453 + * @bug 4216683 4346296 4656556 4785453 8164073 * @summary New rules for when deprecation messages are suppressed * @author gafter * * @compile/ref=SuppressDeprecation.out -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java + * @compile/ref=SuppressDeprecation8.out -source 8 -Xlint:deprecation -XDrawDiagnostics SuppressDeprecation.java */ /* Test for the contexts in which deprecations warnings should diff --git a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out index 4a8b15f33fd..ff1bc124eb0 100644 --- a/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out +++ b/langtools/test/tools/javac/depDocComment/SuppressDeprecation.out @@ -1,8 +1,20 @@ -SuppressDeprecation.java:82:10: compiler.warn.has.been.deprecated: g(), T -SuppressDeprecation.java:83:14: compiler.warn.has.been.deprecated: g(), T -SuppressDeprecation.java:84:9: compiler.warn.has.been.deprecated: var, T -SuppressDeprecation.java:87:9: compiler.warn.has.been.deprecated: T(), T -SuppressDeprecation.java:90:9: compiler.warn.has.been.deprecated: T(int), T -SuppressDeprecation.java:98:1: compiler.warn.has.been.deprecated: T(), T -SuppressDeprecation.java:130:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package -7 warnings +SuppressDeprecation.java:29:9: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:33:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:38:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:48:5: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:53:5: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:67:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:74:9: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:80:10: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:83:10: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:84:14: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:85:9: compiler.warn.has.been.deprecated: var, T +SuppressDeprecation.java:88:9: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:91:9: compiler.warn.has.been.deprecated: T(int), T +SuppressDeprecation.java:99:1: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:124:9: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:103:1: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:129:1: compiler.warn.missing.deprecated.annotation +SuppressDeprecation.java:131:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package +SuppressDeprecation.java:135:1: compiler.warn.missing.deprecated.annotation +19 warnings diff --git a/langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out b/langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out new file mode 100644 index 00000000000..7a12c45d637 --- /dev/null +++ b/langtools/test/tools/javac/depDocComment/SuppressDeprecation8.out @@ -0,0 +1,9 @@ +- compiler.warn.source.no.bootclasspath: 1.8 +SuppressDeprecation.java:83:10: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:84:14: compiler.warn.has.been.deprecated: g(), T +SuppressDeprecation.java:85:9: compiler.warn.has.been.deprecated: var, T +SuppressDeprecation.java:88:9: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:91:9: compiler.warn.has.been.deprecated: T(int), T +SuppressDeprecation.java:99:1: compiler.warn.has.been.deprecated: T(), T +SuppressDeprecation.java:131:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package +8 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1.java b/langtools/test/tools/javac/depOverrides/doccomment/Test1.java index 563492d4d29..571f1ce02ea 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1.java +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,11 +26,11 @@ * @bug 5086088 * @summary check warnings generated when overriding deprecated methods * - * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation I.java + * @compile/ref=Test1I.out -XDrawDiagnostics -Xlint:deprecation I.java * @compile/ref=Test1A.out -XDrawDiagnostics -Xlint:deprecation A.java * @compile/ref=Test1B.out -XDrawDiagnostics -Xlint:deprecation B.java * @compile/ref=Test1B2.out -XDrawDiagnostics -Xlint:deprecation B2.java - * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation B3.java + * @compile/ref=Test1B3.out -XDrawDiagnostics -Xlint:deprecation B3.java * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation Test1.java */ diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out index 0cbe50c23ae..ef477945691 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1A.out @@ -1,4 +1,10 @@ A.java:13:36: compiler.warn.has.been.deprecated: iDep_aUnd_bInh(), I A.java:12:36: compiler.warn.has.been.deprecated: iDep_aUnd_bUnd(), I A.java:11:36: compiler.warn.has.been.deprecated: iDep_aUnd_bDep(), I -3 warnings +A.java:8:36: compiler.warn.missing.deprecated.annotation +A.java:9:36: compiler.warn.missing.deprecated.annotation +A.java:10:36: compiler.warn.missing.deprecated.annotation +A.java:17:36: compiler.warn.missing.deprecated.annotation +A.java:18:36: compiler.warn.missing.deprecated.annotation +A.java:19:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out index a2681b91475..d59496b2961 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1B.out @@ -1,4 +1,10 @@ B.java:15:36: compiler.warn.has.been.deprecated: iDep_aInh_bUnd(), I +B.java:8:36: compiler.warn.missing.deprecated.annotation B.java:9:36: compiler.warn.has.been.deprecated: iDep_aDep_bUnd(), A +B.java:11:36: compiler.warn.missing.deprecated.annotation +B.java:14:36: compiler.warn.missing.deprecated.annotation +B.java:17:36: compiler.warn.missing.deprecated.annotation B.java:18:36: compiler.warn.has.been.deprecated: iUnd_aDep_bUnd(), A -3 warnings +B.java:20:36: compiler.warn.missing.deprecated.annotation +B.java:23:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out index 12c51462051..17efd646d1b 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1B2.out @@ -2,6 +2,12 @@ B2.java:15:36: compiler.warn.has.been.deprecated: iDep_aInh_bUnd(), I B2.java:7:10: compiler.warn.has.been.deprecated: iDep_aUnd_bInh(), I B2.java:12:36: compiler.warn.has.been.deprecated: iDep_aUnd_bUnd(), I B2.java:9:36: compiler.warn.has.been.deprecated: iDep_aDep_bUnd(), I +B2.java:8:36: compiler.warn.missing.deprecated.annotation B2.java:9:36: compiler.warn.has.been.deprecated: iDep_aDep_bUnd(), A +B2.java:11:36: compiler.warn.missing.deprecated.annotation +B2.java:14:36: compiler.warn.missing.deprecated.annotation +B2.java:17:36: compiler.warn.missing.deprecated.annotation B2.java:18:36: compiler.warn.has.been.deprecated: iUnd_aDep_bUnd(), A -6 warnings +B2.java:20:36: compiler.warn.missing.deprecated.annotation +B2.java:23:36: compiler.warn.missing.deprecated.annotation +12 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out new file mode 100644 index 00000000000..c1bb87237da --- /dev/null +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1B3.out @@ -0,0 +1,8 @@ +B3.java:32:36: compiler.warn.missing.deprecated.annotation +B3.java:35:36: compiler.warn.missing.deprecated.annotation +B3.java:38:36: compiler.warn.missing.deprecated.annotation +B3.java:41:36: compiler.warn.missing.deprecated.annotation +B3.java:44:36: compiler.warn.missing.deprecated.annotation +B3.java:47:36: compiler.warn.missing.deprecated.annotation +B3.java:31:10: compiler.warn.missing.deprecated.annotation +7 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test1I.out b/langtools/test/tools/javac/depOverrides/doccomment/Test1I.out new file mode 100644 index 00000000000..67e135cdd7f --- /dev/null +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test1I.out @@ -0,0 +1,9 @@ +I.java:30:36: compiler.warn.missing.deprecated.annotation +I.java:31:36: compiler.warn.missing.deprecated.annotation +I.java:32:36: compiler.warn.missing.deprecated.annotation +I.java:33:36: compiler.warn.missing.deprecated.annotation +I.java:34:36: compiler.warn.missing.deprecated.annotation +I.java:35:36: compiler.warn.missing.deprecated.annotation +I.java:36:36: compiler.warn.missing.deprecated.annotation +I.java:37:36: compiler.warn.missing.deprecated.annotation +8 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2.java b/langtools/test/tools/javac/depOverrides/doccomment/Test2.java index 6595ca22de3..b4fb656a6aa 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test2.java +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -26,7 +26,7 @@ * @bug 5086088 * @summary check warnings generated when overriding deprecated methods * - * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation P.java + * @compile/ref=Test2P.out -XDrawDiagnostics -Xlint:deprecation P.java * @compile/ref=Test2Q.out -XDrawDiagnostics -Xlint:deprecation Q.java * @compile/ref=Test2R.out -XDrawDiagnostics -Xlint:deprecation R.java * @compile/ref=empty -XDrawDiagnostics -Xlint:deprecation Test2.java diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2P.out b/langtools/test/tools/javac/depOverrides/doccomment/Test2P.out new file mode 100644 index 00000000000..89147214dce --- /dev/null +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2P.out @@ -0,0 +1,10 @@ +P.java:30:36: compiler.warn.missing.deprecated.annotation +P.java:31:36: compiler.warn.missing.deprecated.annotation +P.java:32:36: compiler.warn.missing.deprecated.annotation +P.java:33:36: compiler.warn.missing.deprecated.annotation +P.java:34:36: compiler.warn.missing.deprecated.annotation +P.java:35:36: compiler.warn.missing.deprecated.annotation +P.java:36:36: compiler.warn.missing.deprecated.annotation +P.java:37:36: compiler.warn.missing.deprecated.annotation +P.java:38:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out b/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out index 3b6f8c487ac..f092f2f4c88 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2Q.out @@ -1,4 +1,10 @@ +Q.java:8:36: compiler.warn.missing.deprecated.annotation +Q.java:9:36: compiler.warn.missing.deprecated.annotation +Q.java:10:36: compiler.warn.missing.deprecated.annotation Q.java:11:36: compiler.warn.has.been.deprecated: pDep_qUnd_rDep(), P Q.java:12:36: compiler.warn.has.been.deprecated: pDep_qUnd_rUnd(), P Q.java:13:36: compiler.warn.has.been.deprecated: pDep_qUnd_rInh(), P -3 warnings +Q.java:17:36: compiler.warn.missing.deprecated.annotation +Q.java:18:36: compiler.warn.missing.deprecated.annotation +Q.java:19:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out b/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out index 181c583fd82..d3f30728086 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test2R.out @@ -1,4 +1,10 @@ +R.java:8:36: compiler.warn.missing.deprecated.annotation R.java:9:36: compiler.warn.has.been.deprecated: pDep_qDep_rUnd(), Q +R.java:11:36: compiler.warn.missing.deprecated.annotation +R.java:14:36: compiler.warn.missing.deprecated.annotation R.java:15:36: compiler.warn.has.been.deprecated: pDep_qInh_rUnd(), P +R.java:17:36: compiler.warn.missing.deprecated.annotation R.java:18:36: compiler.warn.has.been.deprecated: pUnd_qDep_rUnd(), Q -3 warnings +R.java:20:36: compiler.warn.missing.deprecated.annotation +R.java:23:36: compiler.warn.missing.deprecated.annotation +9 warnings diff --git a/langtools/test/tools/javac/depOverrides/doccomment/Test3.out b/langtools/test/tools/javac/depOverrides/doccomment/Test3.out index 6d939718fb5..491828e5247 100644 --- a/langtools/test/tools/javac/depOverrides/doccomment/Test3.out +++ b/langtools/test/tools/javac/depOverrides/doccomment/Test3.out @@ -1,2 +1,3 @@ +Test3.java:11:14: compiler.warn.missing.deprecated.annotation Test3.java:18:1: compiler.warn.has.been.deprecated: m(), LibInterface -1 warning +2 warnings diff --git a/langtools/test/tools/javac/diags/CheckResourceKeys.java b/langtools/test/tools/javac/diags/CheckResourceKeys.java index dfd43d6e9c2..dde2681054b 100644 --- a/langtools/test/tools/javac/diags/CheckResourceKeys.java +++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java @@ -260,8 +260,8 @@ public class CheckResourceKeys { // ignore debug flag names if (cs.startsWith("debug.")) continue; - // ignore shouldstop flag names - if (cs.startsWith("shouldstop.")) + // ignore should-stop flag names + if (cs.startsWith("should-stop.")) continue; // ignore diagsformat flag names if (cs.startsWith("diags.")) diff --git a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java index 8eb43ad566a..bb324afa790 100644 --- a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java +++ b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound.java @@ -23,7 +23,7 @@ // key: compiler.misc.applicable.method.found // key: compiler.note.verbose.resolve.multi -// options: -Xdebug:verboseResolution=applicable,success +// options: --debug:verboseResolution=applicable,success class ApplicableMethodFound { diff --git a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java index 67e70c3423e..5ecca3a329f 100644 --- a/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java +++ b/langtools/test/tools/javac/diags/examples/ApplicableMethodFound1.java @@ -24,7 +24,7 @@ // key: compiler.misc.applicable.method.found.1 // key: compiler.note.verbose.resolve.multi // key: compiler.misc.partial.inst.sig -// options: -Xdebug:verboseResolution=applicable,success +// options: --debug:verboseResolution=applicable,success class ApplicableMethodFound1 { diff --git a/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java b/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java index f0c2c853dad..59bfd4c37f8 100644 --- a/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java +++ b/langtools/test/tools/javac/diags/examples/DeferredMethodInst.java @@ -25,7 +25,7 @@ // key: compiler.note.verbose.resolve.multi // key: compiler.note.deferred.method.inst // key: compiler.misc.partial.inst.sig -// options: -Xdebug:verboseResolution=applicable,success,deferred-inference +// options: --debug:verboseResolution=applicable,success,deferred-inference class DeferredMethodInst { diff --git a/langtools/test/tools/javac/diags/examples/LambdaStat.java b/langtools/test/tools/javac/diags/examples/LambdaStat.java index a57b4e33778..c3ee38d6f8e 100644 --- a/langtools/test/tools/javac/diags/examples/LambdaStat.java +++ b/langtools/test/tools/javac/diags/examples/LambdaStat.java @@ -22,7 +22,7 @@ */ // key: compiler.note.lambda.stat -// options: -Xdebug:dumpLambdaToMethodStats +// options: --debug:dumpLambdaToMethodStats class LambdaStat { Runnable r = ()->{}; diff --git a/langtools/test/tools/javac/diags/examples/MrefStat.java b/langtools/test/tools/javac/diags/examples/MrefStat.java index 5d79977c1f1..7f84baa8ca0 100644 --- a/langtools/test/tools/javac/diags/examples/MrefStat.java +++ b/langtools/test/tools/javac/diags/examples/MrefStat.java @@ -22,7 +22,7 @@ */ // key: compiler.note.mref.stat -// options: -Xdebug:dumpLambdaToMethodStats +// options: --debug:dumpLambdaToMethodStats class MrefStat { Runnable r = MrefStat::m; diff --git a/langtools/test/tools/javac/diags/examples/MrefStat1.java b/langtools/test/tools/javac/diags/examples/MrefStat1.java index b3128eedbe7..c4bdf4cff2d 100644 --- a/langtools/test/tools/javac/diags/examples/MrefStat1.java +++ b/langtools/test/tools/javac/diags/examples/MrefStat1.java @@ -22,7 +22,7 @@ */ // key: compiler.note.mref.stat.1 -// options: -Xdebug:dumpLambdaToMethodStats +// options: --debug:dumpLambdaToMethodStats class MrefStat1 { diff --git a/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java b/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java index edbaabe8c6e..dc199bc3e38 100644 --- a/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java +++ b/langtools/test/tools/javac/diags/examples/NotApplicableMethodFound.java @@ -26,7 +26,7 @@ // key: compiler.err.cant.apply.symbol // key: compiler.misc.no.conforming.assignment.exists // key: compiler.misc.inconvertible.types -// options: -Xdebug:verboseResolution=inapplicable,failure +// options: --debug:verboseResolution=inapplicable,failure class NotApplicableMethodFound { diff --git a/langtools/test/tools/javac/diags/examples/PartialInstSig.java b/langtools/test/tools/javac/diags/examples/PartialInstSig.java index e2a9c8e0aa0..4a56058856f 100644 --- a/langtools/test/tools/javac/diags/examples/PartialInstSig.java +++ b/langtools/test/tools/javac/diags/examples/PartialInstSig.java @@ -24,7 +24,7 @@ // key: compiler.misc.applicable.method.found.1 // key: compiler.note.verbose.resolve.multi // key: compiler.misc.partial.inst.sig -// options: -Xdebug:verboseResolution=applicable,success +// options: --debug:verboseResolution=applicable,success class PartialInstSig { diff --git a/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java b/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java index 2e5d323df34..11c404cff50 100644 --- a/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java +++ b/langtools/test/tools/javac/diags/examples/ProcessorPathNoProcessorModulePath/ProcessorPathNoProcessorModulePath.java @@ -22,6 +22,6 @@ */ // key: compiler.err.processorpath.no.processormodulepath -// options: -processormodulepath mods -processorpath mods +// options: --processor-module-path mods -processorpath mods class ProcessorPathNoProcessorModulePath {} diff --git a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java index 40108785d0e..c097c74085a 100644 --- a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java +++ b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti.java @@ -23,7 +23,7 @@ // key: compiler.misc.applicable.method.found // key: compiler.note.verbose.resolve.multi -// options: -Xdebug:verboseResolution=applicable,success +// options: --debug:verboseResolution=applicable,success class VerboseResolveMulti { diff --git a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java index d9a5b8bcc3e..33e7a2deef4 100644 --- a/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java +++ b/langtools/test/tools/javac/diags/examples/VerboseResolveMulti1.java @@ -26,7 +26,7 @@ // key: compiler.err.cant.apply.symbol // key: compiler.misc.no.conforming.assignment.exists // key: compiler.misc.inconvertible.types -// options: -Xdebug:verboseResolution=inapplicable,failure +// options: --debug:verboseResolution=inapplicable,failure class VerboseResolveMulti1 { diff --git a/langtools/test/tools/javac/diags/examples/WhereCaptured.java b/langtools/test/tools/javac/diags/examples/WhereCaptured.java index 5ea17aea1ed..22fc86530dd 100644 --- a/langtools/test/tools/javac/diags/examples/WhereCaptured.java +++ b/langtools/test/tools/javac/diags/examples/WhereCaptured.java @@ -28,7 +28,7 @@ // key: compiler.err.cant.apply.symbol // key: compiler.misc.incompatible.eq.bounds // key: compiler.misc.captured.type -// options: -diags:formatterOptions=where,simpleNames +// options: --diags:formatterOptions=where,simpleNames // run: simple import java.util.*; diff --git a/langtools/test/tools/javac/diags/examples/WhereCaptured1.java b/langtools/test/tools/javac/diags/examples/WhereCaptured1.java index f5ce62e2188..26fdf3e8f5b 100644 --- a/langtools/test/tools/javac/diags/examples/WhereCaptured1.java +++ b/langtools/test/tools/javac/diags/examples/WhereCaptured1.java @@ -29,7 +29,7 @@ // key: compiler.misc.incompatible.eq.bounds // key: compiler.misc.captured.type // key: compiler.misc.type.null -// options: -diags:formatterOptions=where,simpleNames +// options: --diags:formatterOptions=where,simpleNames // run: simple import java.util.*; diff --git a/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java b/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java index eb894a9f2cb..fb060c89c1e 100644 --- a/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java +++ b/langtools/test/tools/javac/diags/examples/WhereFreshTvar.java @@ -25,7 +25,7 @@ // key: compiler.misc.where.description.typevar // key: compiler.err.prob.found.req // key: compiler.misc.inconvertible.types -// options: -diags:formatterOptions=where,simpleNames +// options: --diags:formatterOptions=where,simpleNames // run: simple import java.util.*; diff --git a/langtools/test/tools/javac/diags/examples/WhereIntersection.java b/langtools/test/tools/javac/diags/examples/WhereIntersection.java index 8b8a6fbd612..beec1d7cd6e 100644 --- a/langtools/test/tools/javac/diags/examples/WhereIntersection.java +++ b/langtools/test/tools/javac/diags/examples/WhereIntersection.java @@ -26,7 +26,7 @@ // key: compiler.misc.where.description.intersection.1 // key: compiler.misc.where.intersection // key: compiler.err.prob.found.req -// options: -diags:formatterOptions=where +// options: --diags:formatterOptions=where // run: simple class WhereIntersection { diff --git a/langtools/test/tools/javac/diags/examples/WhereIntersection2.java b/langtools/test/tools/javac/diags/examples/WhereIntersection2.java index 6850627db88..91cab029c46 100644 --- a/langtools/test/tools/javac/diags/examples/WhereIntersection2.java +++ b/langtools/test/tools/javac/diags/examples/WhereIntersection2.java @@ -29,7 +29,7 @@ // key: compiler.misc.where.description.intersection // key: compiler.misc.where.intersection // key: compiler.err.prob.found.req -// options: -diags:formatterOptions=where +// options: --diags:formatterOptions=where // run: simple class WhereIntersection2 { diff --git a/langtools/test/tools/javac/diags/examples/WhereTypeVar.java b/langtools/test/tools/javac/diags/examples/WhereTypeVar.java index 9adca945a28..55097a8ce6a 100644 --- a/langtools/test/tools/javac/diags/examples/WhereTypeVar.java +++ b/langtools/test/tools/javac/diags/examples/WhereTypeVar.java @@ -27,7 +27,7 @@ // key: compiler.err.cant.apply.symbol // key: compiler.misc.no.conforming.assignment.exists // key: compiler.misc.inconvertible.types -// options: -diags:formatterOptions=where,disambiguateTvars +// options: --diags:formatterOptions=where,disambiguateTvars // run: simple class WhereTypeVar { diff --git a/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java b/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java index 41341f68275..1f6f51b9431 100644 --- a/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java +++ b/langtools/test/tools/javac/diags/examples/WhereTypeVar2.java @@ -25,7 +25,7 @@ // key: compiler.misc.where.description.typevar // key: compiler.misc.where.typevar // key: compiler.err.prob.found.req -// options: -diags:formatterOptions=where +// options: --diags:formatterOptions=where // run: simple class WhereTypeVar2 { diff --git a/langtools/test/tools/javac/failover/CheckAttributedTree.java b/langtools/test/tools/javac/failover/CheckAttributedTree.java index b9bb22bac2d..6c2d2cbc60d 100644 --- a/langtools/test/tools/javac/failover/CheckAttributedTree.java +++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java @@ -311,7 +311,7 @@ public class CheckAttributedTree { final List trees = new ArrayList<>(); Iterable elems = newCompilationTask() .withWriter(pw) - .withOption("-Xshouldstop:at=ATTR") + .withOption("--should-stop:at=ATTR") .withOption("-XDverboseCompilePolicy") .withSource(files.iterator().next()) .withListener(new TaskListener() { diff --git a/langtools/test/tools/javac/failover/FailOver01.java b/langtools/test/tools/javac/failover/FailOver01.java index 473adfd4759..e8d4da79272 100644 --- a/langtools/test/tools/javac/failover/FailOver01.java +++ b/langtools/test/tools/javac/failover/FailOver01.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver01.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver01.java + * @compile/fail/ref=FailOver01.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver01.java */ class Test { { x = "" } } diff --git a/langtools/test/tools/javac/failover/FailOver02.java b/langtools/test/tools/javac/failover/FailOver02.java index 75c44665418..0aac6fa4546 100644 --- a/langtools/test/tools/javac/failover/FailOver02.java +++ b/langtools/test/tools/javac/failover/FailOver02.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver02.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver02.java + * @compile/fail/ref=FailOver02.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver02.java */ class Test implements AutoCloseable { diff --git a/langtools/test/tools/javac/failover/FailOver03.java b/langtools/test/tools/javac/failover/FailOver03.java index 268f8acd044..cdfe3a8d81c 100644 --- a/langtools/test/tools/javac/failover/FailOver03.java +++ b/langtools/test/tools/javac/failover/FailOver03.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver03.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver03.java + * @compile/fail/ref=FailOver03.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver03.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver04.java b/langtools/test/tools/javac/failover/FailOver04.java index e8b72ddd521..e9a723d1a19 100644 --- a/langtools/test/tools/javac/failover/FailOver04.java +++ b/langtools/test/tools/javac/failover/FailOver04.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver04.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver04.java + * @compile/fail/ref=FailOver04.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver04.java */ class Test { diff --git a/langtools/test/tools/javac/failover/FailOver05.java b/langtools/test/tools/javac/failover/FailOver05.java index 5209373272a..cbbbc222b7c 100644 --- a/langtools/test/tools/javac/failover/FailOver05.java +++ b/langtools/test/tools/javac/failover/FailOver05.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver05.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver05.java + * @compile/fail/ref=FailOver05.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver05.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver06.java b/langtools/test/tools/javac/failover/FailOver06.java index fb28274cde7..14f7fa34f97 100644 --- a/langtools/test/tools/javac/failover/FailOver06.java +++ b/langtools/test/tools/javac/failover/FailOver06.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver06.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver06.java + * @compile/fail/ref=FailOver06.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver06.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver07.java b/langtools/test/tools/javac/failover/FailOver07.java index 216c462d50a..a73037a0e99 100644 --- a/langtools/test/tools/javac/failover/FailOver07.java +++ b/langtools/test/tools/javac/failover/FailOver07.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver07.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver07.java + * @compile/fail/ref=FailOver07.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver07.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver08.java b/langtools/test/tools/javac/failover/FailOver08.java index e993f3dee09..d2446ae59af 100644 --- a/langtools/test/tools/javac/failover/FailOver08.java +++ b/langtools/test/tools/javac/failover/FailOver08.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver08.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver08.java + * @compile/fail/ref=FailOver08.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver08.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver09.java b/langtools/test/tools/javac/failover/FailOver09.java index ca4976895fb..bc126e140f6 100644 --- a/langtools/test/tools/javac/failover/FailOver09.java +++ b/langtools/test/tools/javac/failover/FailOver09.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver09.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver09.java + * @compile/fail/ref=FailOver09.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver09.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver10.java b/langtools/test/tools/javac/failover/FailOver10.java index 2265de57442..5d32c85437d 100644 --- a/langtools/test/tools/javac/failover/FailOver10.java +++ b/langtools/test/tools/javac/failover/FailOver10.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver10.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver10.java + * @compile/fail/ref=FailOver10.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver10.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver11.java b/langtools/test/tools/javac/failover/FailOver11.java index aaad2800747..863053982bc 100644 --- a/langtools/test/tools/javac/failover/FailOver11.java +++ b/langtools/test/tools/javac/failover/FailOver11.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver11.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver11.java + * @compile/fail/ref=FailOver11.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver11.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver12.java b/langtools/test/tools/javac/failover/FailOver12.java index da1e126ffeb..ed8699e039c 100644 --- a/langtools/test/tools/javac/failover/FailOver12.java +++ b/langtools/test/tools/javac/failover/FailOver12.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver12.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver12.java + * @compile/fail/ref=FailOver12.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver12.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver13.java b/langtools/test/tools/javac/failover/FailOver13.java index 03cf4259011..f85249d0833 100644 --- a/langtools/test/tools/javac/failover/FailOver13.java +++ b/langtools/test/tools/javac/failover/FailOver13.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver13.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver13.java + * @compile/fail/ref=FailOver13.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver13.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver14.java b/langtools/test/tools/javac/failover/FailOver14.java index 6f24ff3e558..c0d3ab78abd 100644 --- a/langtools/test/tools/javac/failover/FailOver14.java +++ b/langtools/test/tools/javac/failover/FailOver14.java @@ -4,7 +4,7 @@ * @summary Flow.java should be more error-friendly * @author mcimadamore * - * @compile/fail/ref=FailOver14.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver14.java + * @compile/fail/ref=FailOver14.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver14.java */ class Test extends Test { diff --git a/langtools/test/tools/javac/failover/FailOver15.java b/langtools/test/tools/javac/failover/FailOver15.java index 6fe5e5ae485..619cfd3a5ac 100644 --- a/langtools/test/tools/javac/failover/FailOver15.java +++ b/langtools/test/tools/javac/failover/FailOver15.java @@ -3,7 +3,7 @@ * @bug 6970584 7060926 * @summary Attr.PostAttrAnalyzer misses a case * - * @compile/fail/ref=FailOver15.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver15.java + * @compile/fail/ref=FailOver15.out -XDrawDiagnostics --should-stop:at=FLOW -XDdev FailOver15.java */ class Test { diff --git a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java index ae83a78ee7b..d89b16c577d 100644 --- a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java +++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarAwareSJFM.java @@ -174,7 +174,7 @@ public class MultiReleaseJarAwareSJFM { jfm.setLocation(jloc, List.of(new File("multi-release.jar"))); if (version.length() > 0) { - jfm.handleOption("-multi-release", List.of(version).iterator()); + jfm.handleOption("--multi-release", List.of(version).iterator()); } CustomClassLoader cldr = new CustomClassLoader(jfm); diff --git a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java index 39e14ab1057..ce2ce4530f8 100644 --- a/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java +++ b/langtools/test/tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java @@ -135,12 +135,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 8 -cp multi-release.jar Main.java -> succeeds + // javac -d classes --release 8 -cp multi-release.jar Main.java -> succeeds public void main1Release8(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main1); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "8") + .options("--release", "8") .classpath("multi-release.jar") .files("Main.java") .run(); @@ -149,12 +149,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 9 -cp multi-release.jar Main.java -> fails + // javac -d classes --release 9 -cp multi-release.jar Main.java -> fails public void main1Release9(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main1); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "9") + .options("--release", "9") .classpath("multi-release.jar") .files("Main.java") .run(Task.Expect.FAIL, 1); @@ -177,12 +177,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 8 -cp multi-release.jar Main.java -> fails + // javac -d classes --release 8 -cp multi-release.jar Main.java -> fails public void main2Release8(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main2); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "8") + .options("--release", "8") .classpath("multi-release.jar") .files("Main.java") .run(Task.Expect.FAIL, 1); @@ -191,12 +191,12 @@ public class MultiReleaseJarTest { } @Test(dataProvider="modes") - // javac -d classes -release 9 -cp multi-release.jar Main.java -> succeeds + // javac -d classes --release 9 -cp multi-release.jar Main.java -> succeeds public void main2Release9(Task.Mode mode) throws Exception { tb.writeFile("Main.java", main2); Task.Result result = new JavacTask(tb, mode) .outdir("classes") - .options("-release", "9") + .options("--release", "9") .classpath("multi-release.jar") .files("Main.java") .run(); diff --git a/langtools/test/tools/javac/generics/inference/8158355/T8158355.java b/langtools/test/tools/javac/generics/inference/8158355/T8158355.java index a123a33ab91..edc6fe95254 100644 --- a/langtools/test/tools/javac/generics/inference/8158355/T8158355.java +++ b/langtools/test/tools/javac/generics/inference/8158355/T8158355.java @@ -27,7 +27,7 @@ * @test * @bug 8158355 * @summary Inference graph dot support broken - * @compile -Xdebug:dumpInferenceGraphsTo=. T8158355.java + * @compile --debug:dumpInferenceGraphsTo=. T8158355.java */ import java.util.List; diff --git a/langtools/test/tools/javac/lambda/MostSpecific09.java b/langtools/test/tools/javac/lambda/MostSpecific09.java index 311af8d7b1a..82e12d69839 100644 --- a/langtools/test/tools/javac/lambda/MostSpecific09.java +++ b/langtools/test/tools/javac/lambda/MostSpecific09.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8029718 * @summary Should always use lambda body structure to disambiguate overload resolution - * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -Xshouldstop:at=ATTR -Xdebug:verboseResolution=applicable,success MostSpecific09.java + * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop:at=ATTR --debug:verboseResolution=applicable,success MostSpecific09.java */ class MostSpecific09 { diff --git a/langtools/test/tools/javac/lambda/MostSpecific09.out b/langtools/test/tools/javac/lambda/MostSpecific09.out index 75330535ba0..5359cb7f3bf 100644 --- a/langtools/test/tools/javac/lambda/MostSpecific09.out +++ b/langtools/test/tools/javac/lambda/MostSpecific09.out @@ -3,7 +3,7 @@ MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible -MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @681,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} +MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @682,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 MostSpecific09.java:29:28: compiler.note.verbose.resolve.multi: , java.lang.RuntimeException, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, java.lang.RuntimeException(), null)} @@ -11,7 +11,7 @@ MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo( MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible -MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1130,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} +MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1131,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: , Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} diff --git a/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java b/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java index b7d2e0f9f6d..6546f3ddf26 100644 --- a/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java +++ b/langtools/test/tools/javac/lambda/TestLambdaToMethodStats.java @@ -122,7 +122,7 @@ public class TestLambdaToMethodStats extends ComboInstance annotations, RoundEnvironment roundEnv) { + for (Element e: roundEnv.getRootElements()) { + Element m = e.getEnclosingElement(); + while (!(m instanceof ModuleElement)) { + m = m.getEnclosingElement(); + } + ((ModuleSymbol)m).getDirectives(); + RequiresDirective requiresDirective = ((ModuleSymbol)m).requires.head; + Assert.check(requiresDirective.getDependency().getQualifiedName().toString().equals("java.base")); + Assert.check(requiresDirective.flags.contains(MANDATED)); + } + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } +} diff --git a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java index cd83ef49734..1a923e940f8 100644 --- a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java +++ b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java @@ -23,7 +23,7 @@ /* * @test - * @summary tests for -upgrademodulepath + * @summary tests for --upgrade-module-path * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api diff --git a/langtools/test/tools/javac/modules/XModuleTest.java b/langtools/test/tools/javac/modules/XModuleTest.java index b4f49f64d3d..5dc5d8f35dd 100644 --- a/langtools/test/tools/javac/modules/XModuleTest.java +++ b/langtools/test/tools/javac/modules/XModuleTest.java @@ -27,7 +27,9 @@ * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.code * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.processing * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase * @run main XModuleTest */ @@ -35,12 +37,22 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.List; +import java.util.Set; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.ModuleElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.Elements; + +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; import toolbox.JavacTask; import toolbox.ModuleBuilder; import toolbox.Task; -import toolbox.TestRunner; -import toolbox.ToolBox; +import toolbox.Task.Expect; public class XModuleTest extends ModuleTestBase { @@ -111,15 +123,22 @@ public class XModuleTest extends ModuleTestBase { Path classes = base.resolve("classes"); tb.createDirectories(classes); - String log = new JavacTask(tb) - .options("-Xmodule:java.compiler", "--class-path", cpClasses.toString()) + List log = new JavacTask(tb) + .options("-Xmodule:java.compiler", + "--class-path", cpClasses.toString(), + "-XDrawDiagnostics") .outdir(classes) .files(src.resolve("javax/lang/model/element/Extra.java")) - .run() + .run(Expect.FAIL) .writeAll() - .getOutput(Task.OutputKind.DIRECT); + .getOutputLines(Task.OutputKind.DIRECT); - if (!log.isEmpty()) + List expectedOut = Arrays.asList( + "Extra.java:1:76: compiler.err.doesnt.exist: p", + "1 error" + ); + + if (!expectedOut.equals(log)) throw new Exception("expected output not found: " + log); } @@ -302,4 +321,103 @@ public class XModuleTest extends ModuleTestBase { .run() .writeAll(); } + + @Test + public void testUnnamedIsolation(Path base) throws Exception { + //note: avoiding use of java.base, as that gets special handling on some places: + Path sourcePath = base.resolve("source-path"); + tb.writeJavaFiles(sourcePath, "package src; public class Src {}"); + + Path classPathSrc = base.resolve("class-path-src"); + tb.writeJavaFiles(classPathSrc, "package cp; public class CP { }"); + Path classPath = base.resolve("classPath"); + tb.createDirectories(classPath); + + String cpLog = new JavacTask(tb) + .outdir(classPath) + .files(findJavaFiles(classPathSrc)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!cpLog.isEmpty()) + throw new Exception("expected output not found: " + cpLog); + + Path modulePathSrc = base.resolve("module-path-src"); + tb.writeJavaFiles(modulePathSrc, + "module m {}", + "package m; public class M {}"); + Path modulePath = base.resolve("modulePath"); + tb.createDirectories(modulePath.resolve("m")); + + String modLog = new JavacTask(tb) + .outdir(modulePath.resolve("m")) + .files(findJavaFiles(modulePathSrc)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!modLog.isEmpty()) + throw new Exception("expected output not found: " + modLog); + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, "package m; public class Extra { }"); + Path classes = base.resolve("classes"); + tb.createDirectories(classes); + + String log = new JavacTask(tb) + .options("-Xmodule:m", + "--class-path", classPath.toString(), + "--source-path", sourcePath.toString(), + "--module-path", modulePath.toString(), + "--processor-path", System.getProperty("test.classes"), + "-XDaccessInternalAPI=true", + "-processor", CheckModuleContentProcessing.class.getName()) + .outdir(classes) + .files(findJavaFiles(sourcePath)) + .run() + .writeAll() + .getOutput(Task.OutputKind.DIRECT); + + if (!log.isEmpty()) + throw new Exception("expected output not found: " + log); + } + + @SupportedAnnotationTypes("*") + public static final class CheckModuleContentProcessing extends AbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + Symtab syms = Symtab.instance(((JavacProcessingEnvironment) processingEnv).getContext()); + Elements elements = processingEnv.getElementUtils(); + ModuleElement unnamedModule = syms.unnamedModule; + ModuleElement mModule = elements.getModuleElement("m"); + + assertNonNull("mModule found", mModule); + assertNonNull("src.Src from m", elements.getTypeElement(mModule, "src.Src")); + assertNull("cp.CP not from m", elements.getTypeElement(mModule, "cp.CP")); + assertNull("src.Src not from unnamed", elements.getTypeElement(unnamedModule, "src.Src")); + assertNonNull("cp.CP from unnamed", elements.getTypeElement(unnamedModule, "cp.CP")); + + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + private static void assertNonNull(String msg, Object val) { + if (val == null) { + throw new AssertionError(msg); + } + } + + private static void assertNull(String msg, Object val) { + if (val != null) { + throw new AssertionError(msg); + } + } + } + } diff --git a/langtools/test/tools/javac/options/release/ReleaseOption.java b/langtools/test/tools/javac/options/release/ReleaseOption.java index 58f3a1d1cb1..2a7566aeb2e 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOption.java +++ b/langtools/test/tools/javac/options/release/ReleaseOption.java @@ -1,9 +1,9 @@ /** * @test /nodynamiccopyright/ * @bug 8072480 - * @summary Verify that javac rejects Java 8 program with -release 7 + * @summary Verify that javac rejects Java 8 program with --release 7 * @compile ReleaseOption.java - * @compile/fail/ref=ReleaseOption-release7.out -XDrawDiagnostics -release 7 ReleaseOption.java + * @compile/fail/ref=ReleaseOption-release7.out -XDrawDiagnostics --release 7 ReleaseOption.java */ interface ReleaseOption extends java.util.stream.Stream { diff --git a/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java b/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java index f16e5081935..80c8f6c4d8d 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java +++ b/langtools/test/tools/javac/options/release/ReleaseOptionClashes.java @@ -24,7 +24,7 @@ /** * @test * @bug 8072480 - * @summary Verify option clash between -release and -source is reported correctly. + * @summary Verify option clash between --release and -source is reported correctly. * @modules jdk.compiler/com.sun.tools.javac.util */ @@ -62,7 +62,7 @@ public class ReleaseOptionClashes { useRawMessages.setBoolean(null, true); ByteArrayOutputStream out = new ByteArrayOutputStream(); List options = new ArrayList<>(); - options.addAll(Arrays.asList("-release", "7")); + options.addAll(Arrays.asList("--release", "7")); options.addAll(Arrays.asList(args)); options.add(System.getProperty("test.src") + File.separator + "ReleaseOptionClashes.java"); compiler.run(null, null, out, options.toArray(new String[0])); diff --git a/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java b/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java index 705b395e6f6..3196e8cbcbf 100644 --- a/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java +++ b/langtools/test/tools/javac/options/release/ReleaseOptionThroughAPI.java @@ -24,7 +24,7 @@ /** * @test * @bug 8072480 - * @summary Verify that javac can handle -release when invoked using the Compiler API + * @summary Verify that javac can handle --release when invoked using the Compiler API */ import java.io.IOException; @@ -50,7 +50,7 @@ public class ReleaseOptionThroughAPI { PrintWriter outWriter = new PrintWriter(out)) { Iterable input = fm.getJavaFileObjects(System.getProperty("test.src") + "/ReleaseOption.java"); - List options = Arrays.asList("-release", "7", "-XDrawDiagnostics"); + List options = Arrays.asList("--release", "7", "-XDrawDiagnostics"); compiler.getTask(outWriter, fm, null, options, null, input).call(); String expected = diff --git a/langtools/test/tools/javac/platform/PlatformProviderTest.java b/langtools/test/tools/javac/platform/PlatformProviderTest.java index 52cb7e3bb4d..2481d02d2dd 100644 --- a/langtools/test/tools/javac/platform/PlatformProviderTest.java +++ b/langtools/test/tools/javac/platform/PlatformProviderTest.java @@ -101,7 +101,7 @@ public class PlatformProviderTest implements PlatformProvider { "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", "-XDrawDiagnostics", - "-release", + "--release", platformSpec, System.getProperty("test.src") + "/PlatformProviderTestSource.java") .run(); @@ -135,7 +135,7 @@ public class PlatformProviderTest implements PlatformProvider { .options("-J--class-path=" + System.getProperty("test.classes"), "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED", "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", - "-release", + "--release", "fail", System.getProperty("test.src") + "/PlatformProviderTestSource.java") .run(Task.Expect.FAIL); diff --git a/langtools/test/tools/javac/policy/test3/Test.java b/langtools/test/tools/javac/policy/test3/Test.java index c3d1957d6b2..8f620a700b7 100644 --- a/langtools/test/tools/javac/policy/test3/Test.java +++ b/langtools/test/tools/javac/policy/test3/Test.java @@ -30,7 +30,7 @@ import java.io.*; import java.util.*; -// Simple test of -Xshouldstop:at. +// Simple test of --should-stop:at. // For each of the permissable values, we compile a file with an error in it, // then using -XDverboseCompilePolicy we check that the compilation gets as // far as expected, but no further. @@ -83,7 +83,7 @@ public class Test { args.add("-d"); args.add("."); if (ssp.needOption) - args.add("-Xshouldstop:at=" + ssp); + args.add("--should-stop:at=" + ssp); args.add(new File(System.getProperty("test.src", "."), "A.java").getPath()); StringWriter sw = new StringWriter(); diff --git a/langtools/test/tools/javac/positions/TreeEndPosTest.java b/langtools/test/tools/javac/positions/TreeEndPosTest.java index e1a8be99452..523ec5dcf3c 100644 --- a/langtools/test/tools/javac/positions/TreeEndPosTest.java +++ b/langtools/test/tools/javac/positions/TreeEndPosTest.java @@ -145,7 +145,7 @@ public class TreeEndPosTest { options.add(tempDir.getPath()); options.add("-d"); options.add(tempDir.getPath()); - options.add("-Xshouldstop:at=GENERATE"); + options.add("--should-stop:at=GENERATE"); List sources = new ArrayList<>(); sources.add(src); diff --git a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java index 0963135bf37..5910eaa73c4 100644 --- a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java +++ b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess2.java @@ -4,7 +4,7 @@ * @summary Verify correct implementation of JLS2e 6.6.2.1 * @author maddox * - * @compile/fail/ref=ProtectedMemberAccess2.out -diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess2.java + * @compile/fail/ref=ProtectedMemberAccess2.out --diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess2.java */ // 71 errors expected. diff --git a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java index eacc53e8280..82b8d1b51a1 100644 --- a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java +++ b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess3.java @@ -4,7 +4,7 @@ * @summary Verify correct implementation of JLS2e 6.6.2.1 * @author maddox * - * @compile/fail/ref=ProtectedMemberAccess3.out -diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess3.java + * @compile/fail/ref=ProtectedMemberAccess3.out --diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess3.java */ // 46 errors expected. diff --git a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java index 695ccf46b29..d8a55813524 100644 --- a/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java +++ b/langtools/test/tools/javac/protectedAccess/ProtectedMemberAccess4.java @@ -4,7 +4,7 @@ * @summary Verify correct implementation of JLS2e 6.6.2.1 * @author maddox * - * @compile/fail/ref=ProtectedMemberAccess4.out -diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess4.java + * @compile/fail/ref=ProtectedMemberAccess4.out --diags:formatterOptions=-simpleNames;layout=%b:%l:%_%m ProtectedMemberAccess4.java */ // 33 errors expected. diff --git a/langtools/test/tools/javac/resolve/ResolveHarness.java b/langtools/test/tools/javac/resolve/ResolveHarness.java index 099fa4989ef..8de0a6b2432 100644 --- a/langtools/test/tools/javac/resolve/ResolveHarness.java +++ b/langtools/test/tools/javac/resolve/ResolveHarness.java @@ -132,8 +132,8 @@ public class ResolveHarness implements javax.tools.DiagnosticListener options = Arrays.asList("-release", version, "-classpath", ""); + List options = Arrays.asList("--release", version, "-classpath", ""); List files = Arrays.asList(new ToolBox.JavaSource("Test", "")); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, null, options, null, files); diff --git a/langtools/test/tools/javac/synthesize/Main.java b/langtools/test/tools/javac/synthesize/Main.java index 5817142cc41..d92cff2a96e 100644 --- a/langtools/test/tools/javac/synthesize/Main.java +++ b/langtools/test/tools/javac/synthesize/Main.java @@ -99,7 +99,7 @@ public class Main if (stdBootClassPath) { args.add("-Xmodule:java.base"); } else { - args.add("-system"); + args.add("--system"); args.add("none"); files.add("module-info.java"); } diff --git a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java index e2b7676add3..24519b4cd83 100644 --- a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java +++ b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -41,7 +41,7 @@ * jdk.compiler/com.sun.tools.javac.tree * jdk.compiler/com.sun.tools.javac.util * @build AbstractTreeScannerTest JavacTreeScannerTest - * @run main JavacTreeScannerTest -q -r . + * @run main/othervm JavacTreeScannerTest -q -r . */ import java.io.*; diff --git a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java index 5882037e1f6..1d1bc2cc0df 100644 --- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java +++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -41,7 +41,7 @@ * jdk.compiler/com.sun.tools.javac.tree * jdk.compiler/com.sun.tools.javac.util * @build AbstractTreeScannerTest SourceTreeScannerTest - * @run main SourceTreeScannerTest -q -r . + * @run main/othervm SourceTreeScannerTest -q -r . */ import java.io.*; diff --git a/langtools/test/tools/javac/unicode/UnicodeNewline.java b/langtools/test/tools/javac/unicode/UnicodeNewline.java index 3010041d327..535be3f8bd9 100644 --- a/langtools/test/tools/javac/unicode/UnicodeNewline.java +++ b/langtools/test/tools/javac/unicode/UnicodeNewline.java @@ -3,7 +3,7 @@ * @bug 4739428 4785453 * @summary when \u000a is used, diagnostics are reported on the wrong line. * - * @compile/fail/ref=UnicodeNewline.out -diags:layout=%b:%l:%_%m UnicodeNewline.java + * @compile/fail/ref=UnicodeNewline.out --diags:layout=%b:%l:%_%m UnicodeNewline.java */ class UnicodeNewline { diff --git a/langtools/test/tools/javadoc/ReleaseOption.java b/langtools/test/tools/javadoc/ReleaseOption.java index d786e36e512..54e505c3bf1 100644 --- a/langtools/test/tools/javadoc/ReleaseOption.java +++ b/langtools/test/tools/javadoc/ReleaseOption.java @@ -34,7 +34,7 @@ import com.sun.tools.javadoc.Main; /** * @test * @bug 8086737 - * @summary Test -release option in javadoc + * @summary Test --release option in javadoc * @run main ReleaseOption */ public class ReleaseOption { @@ -43,10 +43,10 @@ public class ReleaseOption { } void run() { - doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "7"); - doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "-release", "8"); - doRunTest(1, out -> true, "-release", "7", "-source", "7"); - doRunTest(1, out -> true, "-release", "7", "-bootclasspath", "any"); + doRunTest(0, out -> out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "7"); + doRunTest(0, out -> !out.contains("compiler.err.doesnt.exist: java.util.stream"), "--release", "8"); + doRunTest(1, out -> true, "--release", "7", "-source", "7"); + doRunTest(1, out -> true, "--release", "7", "-bootclasspath", "any"); } void doRunTest(int expectedResult, Predicate validate, String... args) { diff --git a/langtools/test/tools/lib/toolbox/ModuleBuilder.java b/langtools/test/tools/lib/toolbox/ModuleBuilder.java index fc2b0440a57..8c7390261a2 100644 --- a/langtools/test/tools/lib/toolbox/ModuleBuilder.java +++ b/langtools/test/tools/lib/toolbox/ModuleBuilder.java @@ -205,7 +205,7 @@ public class ModuleBuilder { .collect(Collectors.joining(File.pathSeparator)); new JavacTask(tb) .outdir(Files.createDirectories(modules.resolve(name))) - .options("-mp", mp) + .options("--module-path", mp) .files(tb.findJavaFiles(moduleSrc)) .run() .writeAll(); diff --git a/langtools/test/tools/sjavac/JavacOptionPrep.java b/langtools/test/tools/sjavac/JavacOptionPrep.java index 36fc7960150..9e3bb21b1e0 100644 --- a/langtools/test/tools/sjavac/JavacOptionPrep.java +++ b/langtools/test/tools/sjavac/JavacOptionPrep.java @@ -96,7 +96,7 @@ public class JavacOptionPrep { // Ignore this option for now. When the file=... requirement goes // away, this will be easier to handle. - if (option.startsWith("-Xdebug:completionDeps")) + if (option.startsWith("--debug:completionDeps")) continue; switch (option) { diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 65e43933dec..75e7cc6a0bb 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -458,7 +458,7 @@ sun.charsets_COPY := .dat jdk.localedata_COPY := _dict _th # Exclude BreakIterator classes that are just used in compile process to generate # data files and shouldn't go in the product -jdk.localedata_EXCLUDE_FILES += sun/text/resources/th/BreakIteratorRules_th.java +jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java ################################################################################ # Setup the compilation for the module @@ -504,7 +504,7 @@ $(eval $(call SetupJavaCompilation, $(MODULE), \ $($(MODULE)_ADD_JAVAC_FLAGS) \ --module-source-path $(MODULESOURCEPATH) \ --module-path $(MODULEPATH) \ - -system none, \ + --system none, \ )) TARGETS += $($(MODULE)) $($(MODULE)_COPY_EXTRA) diff --git a/make/Images.gmk b/make/Images.gmk index c7df894ceaf..75a8cb5e04b 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -116,8 +116,10 @@ JMODS := $(wildcard $(IMAGES_OUTPUTDIR)/jmods/*.jmod) JIMAGE_TARGET_FILE := bin/java$(EXE_SUFFIX) JLINK_ORDER_RESOURCES := **module-info.class +JLINK_JLI_CLASSES := ifeq ($(ENABLE_GENERATE_CLASSLIST), true) JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/classlist/classlist + JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out endif JLINK_ORDER_RESOURCES += \ /java.base/java/** \ @@ -131,6 +133,7 @@ JLINK_TOOL := $(JLINK) --module-path $(IMAGES_OUTPUTDIR)/jmods \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) \ --release-info $(BASE_RELEASE_FILE) \ --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \ + $(JLINK_JLI_CLASSES) \ # ifeq ($(JLINK_KEEP_PACKAGED_MODULES), true) diff --git a/make/Init.gmk b/make/Init.gmk index 6ed612b28a2..15ae487555c 100644 --- a/make/Init.gmk +++ b/make/Init.gmk @@ -314,6 +314,9 @@ else # HAS_SPEC=true endif on-failure: + $(call CleanupSmartJavac) + $(call StopGlobalTimer) + $(call ReportBuildTimes) $(call PrintFailureReports) $(call PrintBuildLogFailures) $(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors.\n\n" diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk index 52b2cc337fe..65fc170404d 100644 --- a/make/common/SetupJavaCompilers.gmk +++ b/make/common/SetupJavaCompilers.gmk @@ -88,7 +88,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \ $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \ JVM := $(JAVA_SMALL), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules -system none $(DISABLE_WARNINGS), \ + FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) diff --git a/make/common/TestFilesCompilation.gmk b/make/common/TestFilesCompilation.gmk index 1dd40a0a877..74414a9ca30 100644 --- a/make/common/TestFilesCompilation.gmk +++ b/make/common/TestFilesCompilation.gmk @@ -86,6 +86,7 @@ define SetupTestFilesCompilationBody LANG := C, \ CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$($1_PREFIX)$$(name)), \ LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \ + LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \ OPTIMIZATION := LOW, \ )) \ $$(eval $1 += $$(BUILD_TEST_$$(name)) ) \ diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index 382341a47e4..7593ac74766 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2016, 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 @@ -48,7 +48,7 @@ TARGETS += $(BUILD_WB_JAR) # test-lib.jar will contain only hprof classes until JDK-8081381 is resolved $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ SETUP := GENERATE_USINGJDKBYTECODE, \ - SRC := $(TEST_LIB_SOURCE_DIR)/share/classes/jdk/test/lib/hprof, \ + SRC := $(TEST_LIB_SOURCE_DIR)/jdk/test/lib/hprof, \ BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ )) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index f68987a568a..afea5d568b8 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -367,3 +367,5 @@ ff07be6106fa56b72c163244f45a3ecb4c995564 jdk-9+127 ee77c6b3713ab293e027ac3ea1cc16f86dac535f jdk-9+131 55a75af751dfe44039baef2b762ee7347021025b jdk-9+132 3a924b820d02b108cf57b51e145b5150d1eedcca jdk-9+133 +e05400ba935753c77697af936db24657eb811022 jdk-9+134 +cb00d5ef023a18a66fcb4311ed4474d4145c66e9 jdk-9+135 diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java index 56bab71752e..3c71880c13f 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java @@ -1273,7 +1273,11 @@ public class ScriptFunction extends ScriptObject { // a new zeroth element that is set to bindName value. final MethodType methodType = methodHandle.type(); final int parameterCount = methodType.parameterCount(); - final boolean isVarArg = parameterCount > 0 && methodType.parameterType(parameterCount - 1).isArray(); + + if (parameterCount < 2) { + return methodHandle; // method does not have enough parameters + } + final boolean isVarArg = methodType.parameterType(parameterCount - 1).isArray(); if (isVarArg) { return MH.filterArguments(methodHandle, 1, MH.insertArguments(ADD_ZEROTH_ELEMENT, 1, bindName)); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java index 059cf1d80e1..df348e148b5 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java @@ -2172,6 +2172,21 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { return switchPoints.toArray(new SwitchPoint[0]); } + // Similar to getProtoSwitchPoints method above, but used for additional prototype switchpoints of + // properties that are known not to exist, e.g. the original property name in a __noSuchProperty__ invocation. + private SwitchPoint getProtoSwitchPoint(final String name) { + if (getProto() == null) { + return null; + } + + for (ScriptObject obj = this; obj.getProto() != null; obj = obj.getProto()) { + final ScriptObject parent = obj.getProto(); + parent.getMap().addListener(name, obj.getMap()); + } + + return getMap().getSwitchPoint(name); + } + private void checkSharedProtoMap() { // Check if our map has an expected shared prototype property map. If it has, make sure that // the prototype map has not been invalidated, and that it does match the actual map of the prototype. @@ -2343,7 +2358,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { final boolean scopeCall = isScope() && NashornCallSiteDescriptor.isScope(desc); if (find == null) { - return noSuchProperty(desc, request); + return noSuchProperty(desc, request) + // Add proto switchpoint to switch from no-such-property to no-such-method if it is ever defined. + .addSwitchPoint(getProtoSwitchPoint(NO_SUCH_METHOD_NAME)); } final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request); @@ -2366,7 +2383,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { Object.class), NashornGuards.combineGuards( NashornGuards.getIdentityGuard(this), - NashornGuards.getMapGuard(getMap(), true))); + NashornGuards.getMapGuard(getMap(), true))) + // Add a protoype switchpoint for the original name so this gets invalidated if it is ever defined. + .addSwitchPoint(getProtoSwitchPoint(name)); } /** @@ -2412,7 +2431,9 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { func), getProtoSwitchPoints(NO_SUCH_PROPERTY_NAME, find.getOwner()), //TODO this doesn't need a ClassCastException as guard always checks script object - null); + null) + // Add a protoype switchpoint for the original name so this gets invalidated if it is ever defined. + .addSwitchPoint(getProtoSwitchPoint(name)); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java index 215d0c85ad8..5277c4faad4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SharedPropertyMap.java @@ -29,7 +29,7 @@ import java.lang.invoke.SwitchPoint; /** * This class represents a property map that can be shared among multiple prototype objects, allowing all inheriting - * top-level objects to also share one property map. This is class is only used for prototype objects, the + * top-level objects to also share one property map. This class is only used for prototype objects, the * top-level objects use ordinary {@link PropertyMap}s with the {@link PropertyMap#sharedProtoMap} field * set to the expected shared prototype map. * diff --git a/nashorn/test/script/basic/JDK-8077149.js b/nashorn/test/script/basic/JDK-8077149.js new file mode 100644 index 00000000000..b980ff81027 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8077149.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8077149: __noSuchProperty__ and __noSuchMethod__ invocations are not properly guarded + * + * @test + * @run + */ + +var o = {}; + +function invoke() { + return o._(); +} + +Object.prototype.__noSuchProperty__ = function() { + return function() { return "no such property" }; +}; + +Assert.assertEquals(invoke(), "no such property"); + +Object.prototype.__noSuchMethod__ = function() { + return "no such method"; +}; + +Assert.assertEquals(invoke(), "no such method"); + +Object.prototype._ = function() { + return "underscore method"; +}; + +Assert.assertEquals(invoke(), "underscore method"); diff --git a/test/lib/ClassFileInstaller.java b/test/lib/ClassFileInstaller.java new file mode 100644 index 00000000000..2486bd2ef81 --- /dev/null +++ b/test/lib/ClassFileInstaller.java @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2016, 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. + */ + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + * Dump a class file for a class on the class path in the current directory, or + * in the specified JAR file. This class is usually used when you build a class + * from a test library, but want to use this class in a sub-process. + * + * For example, to build the following library class: + * test/lib/sun/hotspot/WhiteBox.java + * + * You would use the following tags: + * + * @library /test/lib + * @build sun.hotspot.WhiteBox + * + * JTREG would build the class file under + * ${JTWork}/classes/test/lib/sun/hotspot/WhiteBox.class + * + * With you run your main test class using "@run main MyMainClass", JTREG would setup the + * -classpath to include "${JTWork}/classes/test/lib/", so MyMainClass would be able to + * load the WhiteBox class. + * + * However, if you run a sub process, and do not wish to use the exact same -classpath, + * You can use ClassFileInstaller to ensure that WhiteBox is available in the current + * directory of your test: + * + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * + * Or, you can use the -jar option to store the class in the specified JAR file. If a relative + * path name is given, the JAR file would be relative to the current directory of + * + * @run main ClassFileInstaller -jar myjar.jar sun.hotspot.WhiteBox + */ +public class ClassFileInstaller { + /** + * You can enable debug tracing of ClassFileInstaller by running JTREG with + * jtreg -DClassFileInstaller.debug=true ... + */ + public static boolean DEBUG = Boolean.getBoolean("ClassFileInstaller.debug"); + + /** + * @param args The names of the classes to dump + * @throws Exception + */ + public static void main(String... args) throws Exception { + if (args.length > 1 && args[0].equals("-jar")) { + if (args.length < 2) { + throw new RuntimeException("Usage: ClassFileInstaller \n" + + "where possible options include:\n" + + " -jar Write to the JAR file "); + } + writeJar(args[1], null, args, 2, args.length); + } else { + if (DEBUG) { + System.out.println("ClassFileInstaller: Writing to " + System.getProperty("user.dir")); + } + for (String arg : args) { + writeClassToDisk(arg); + } + } + } + + public static class Manifest { + private InputStream in; + + private Manifest(InputStream in) { + this.in = in; + } + + static Manifest fromSourceFile(String fileName) throws Exception { + String pathName = System.getProperty("test.src") + File.separator + fileName; + return new Manifest(new FileInputStream(pathName)); + } + + // Example: + // String manifest = "Premain-Class: RedefineClassHelper\n" + + // "Can-Redefine-Classes: true\n"; + // ClassFileInstaller.writeJar("redefineagent.jar", + // ClassFileInstaller.Manifest.fromString(manifest), + // "RedefineClassHelper"); + static Manifest fromString(String manifest) throws Exception { + return new Manifest(new ByteArrayInputStream(manifest.getBytes())); + } + + public InputStream getInputStream() { + return in; + } + } + + private static void writeJar(String jarFile, Manifest manifest, String classes[], int from, int to) throws Exception { + if (DEBUG) { + System.out.println("ClassFileInstaller: Writing to " + getJarPath(jarFile)); + } + + (new File(jarFile)).delete(); + FileOutputStream fos = new FileOutputStream(jarFile); + ZipOutputStream zos = new ZipOutputStream(fos); + + // The manifest must be the first or second entry. See comments in JarInputStream + // constructor and JDK-5046178. + if (manifest != null) { + writeToDisk(zos, "META-INF/MANIFEST.MF", manifest.getInputStream()); + } + + for (int i=from; i 0) { + pathName = prependPath + "/" + pathName; + } + writeToDisk(zos, pathName, is); + } + + public static void writeClassToDisk(String className, byte[] bytecode) throws Exception { + writeClassToDisk(null, className, bytecode); + } + private static void writeClassToDisk(ZipOutputStream zos, String className, byte[] bytecode) throws Exception { + writeClassToDisk(zos, className, bytecode, ""); + } + + public static void writeClassToDisk(String className, byte[] bytecode, String prependPath) throws Exception { + writeClassToDisk(null, className, bytecode, prependPath); + } + private static void writeClassToDisk(ZipOutputStream zos, String className, byte[] bytecode, String prependPath) throws Exception { + // Convert dotted class name to a path to a class file + String pathName = className.replace('.', '/').concat(".class"); + if (prependPath.length() > 0) { + pathName = prependPath + "/" + pathName; + } + writeToDisk(zos, pathName, new ByteArrayInputStream(bytecode)); + } + + private static void writeToDisk(ZipOutputStream zos, String pathName, InputStream is) throws Exception { + if (DEBUG) { + System.out.println("ClassFileInstaller: Writing " + pathName); + } + if (zos != null) { + ZipEntry ze = new ZipEntry(pathName); + zos.putNextEntry(ze); + byte[] buf = new byte[1024]; + int len; + while ((len = is.read(buf))>0){ + zos.write(buf, 0, len); + } + } else { + // Create the class file's package directory + Path p = Paths.get(pathName); + if (pathName.contains("/")) { + Files.createDirectories(p.getParent()); + } + // Create the class file + Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); + } + is.close(); + } +} diff --git a/test/lib/RedefineClassHelper.java b/test/lib/RedefineClassHelper.java new file mode 100644 index 00000000000..75768092365 --- /dev/null +++ b/test/lib/RedefineClassHelper.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, 2016, 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. + */ + +import java.io.PrintWriter; +import java.lang.instrument.*; +import jdk.test.lib.InMemoryJavaCompiler; + +/* + * Helper class to write tests that redefine classes. + * When main method is run, it will create a redefineagent.jar that can be used + * with the -javaagent option to support redefining classes in jtreg tests. + * + * See sample test in test/testlibrary_tests/RedefineClassTest.java + */ +public class RedefineClassHelper { + + public static Instrumentation instrumentation; + public static void premain(String agentArgs, Instrumentation inst) { + instrumentation = inst; + } + + /** + * Redefine a class + * + * @param clazz Class to redefine + * @param javacode String with the new java code for the class to be redefined + */ + public static void redefineClass(Class clazz, String javacode) throws Exception { + byte[] bytecode = InMemoryJavaCompiler.compile(clazz.getName(), javacode); + redefineClass(clazz, bytecode); + } + + /** + * Redefine a class + * + * @param clazz Class to redefine + * @param bytecode byte[] with the new class + */ + public static void redefineClass(Class clazz, byte[] bytecode) throws Exception { + instrumentation.redefineClasses(new ClassDefinition(clazz, bytecode)); + } + + /** + * Main method to be invoked before test to create the redefineagent.jar + */ + public static void main(String[] args) throws Exception { + ClassFileInstaller.main("RedefineClassHelper"); + + PrintWriter pw = new PrintWriter("MANIFEST.MF"); + pw.println("Premain-Class: RedefineClassHelper"); + pw.println("Can-Redefine-Classes: true"); + pw.close(); + + sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); + if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineClassHelper.class" })) { + throw new Exception("jar operation failed"); + } + } +} diff --git a/test/lib/share/classes/jdk/test/lib/Asserts.java b/test/lib/jdk/test/lib/Asserts.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/Asserts.java rename to test/lib/jdk/test/lib/Asserts.java index f0be92ef331..8aa0105d994 100644 --- a/test/lib/share/classes/jdk/test/lib/Asserts.java +++ b/test/lib/jdk/test/lib/Asserts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/jdk/test/lib/BuildHelper.java b/test/lib/jdk/test/lib/BuildHelper.java new file mode 100644 index 00000000000..1e9d697b35b --- /dev/null +++ b/test/lib/jdk/test/lib/BuildHelper.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib; + +import java.io.File; +import java.io.FileReader; +import java.util.Properties; + +public class BuildHelper { + + /** + * Commercial builds should have the BUILD_TYPE set to commercial + * within the release file, found at the root of the JDK. + */ + public static boolean isCommercialBuild() throws Exception { + String buildType = getReleaseProperty("BUILD_TYPE","notFound"); + return buildType.equals("commercial"); + } + + + /** + * Return the value for property key, or defaultValue if no property not found. + * If present, double quotes are trimmed. + */ + public static String getReleaseProperty(String key, String defaultValue) throws Exception { + Properties properties = getReleaseProperties(); + String value = properties.getProperty(key, defaultValue); + return trimDoubleQuotes(value); + } + + /** + * Return the value for property key, or null if no property not found. + * If present, double quotes are trimmed. + */ + public static String getReleaseProperty(String key) throws Exception { + return getReleaseProperty(key, null); + } + + /** + * Get properties from the release file + */ + public static Properties getReleaseProperties() throws Exception { + Properties properties = new Properties(); + properties.load(new FileReader(getReleaseFile())); + return properties; + } + + /** + * Every JDK has a release file in its root. + * @return A handler to the release file. + */ + public static File getReleaseFile() throws Exception { + String jdkPath = getJDKRoot(); + File releaseFile = new File(jdkPath,"release"); + if ( ! releaseFile.canRead() ) { + throw new Exception("Release file is not readable, or it is absent: " + + releaseFile.getCanonicalPath()); + } + return releaseFile; + } + + /** + * Returns path to the JDK under test. + * This path is obtained through the test.jdk property, usually set by JTREG. + */ + public static String getJDKRoot() { + String jdkPath = System.getProperty("test.jdk"); + if (jdkPath == null) { + throw new RuntimeException("System property 'test.jdk' not set. This property is normally set by jtreg. " + + "When running test separately, set this property using '-Dtest.jdk=/path/to/jdk'."); + } + return jdkPath; + } + + /** + * Trim double quotes from the beginning and the end of the given string. + * @param original string to trim. + * @return a new trimmed string. + */ + public static String trimDoubleQuotes(String original) { + if (original == null) { return null; } + String trimmed = original.replaceAll("^\"+|\"+$", ""); + return trimmed; + } +} diff --git a/test/lib/jdk/test/lib/ByteCodeLoader.java b/test/lib/jdk/test/lib/ByteCodeLoader.java new file mode 100644 index 00000000000..14f98f8747b --- /dev/null +++ b/test/lib/jdk/test/lib/ByteCodeLoader.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, 2016, 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 jdk.test.lib; + +import java.security.SecureClassLoader; + +/** + * {@code ByteCodeLoader} can be used for easy loading of byte code already + * present in memory. + * + * {@code InMemoryCompiler} can be used for compiling source code in a string + * into byte code, which then can be loaded with {@code ByteCodeLoader}. + * + * @see InMemoryCompiler + */ +public class ByteCodeLoader extends SecureClassLoader { + private final String className; + private final byte[] byteCode; + private volatile Class holder; + + /** + * Creates a new {@code ByteCodeLoader} ready to load a class with the + * given name and the given byte code. + * + * @param className The name of the class + * @param byteCode The byte code of the class + */ + public ByteCodeLoader(String className, byte[] byteCode) { + this.className = className; + this.byteCode = byteCode; + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException { + if (!name.equals(className)) { + return super.loadClass(name); + } + if (holder == null) { + synchronized(this) { + if (holder == null) { + holder = findClass(name); + } + } + } + return holder; + } + + @Override + protected Class findClass(String name) throws ClassNotFoundException { + if (!name.equals(className)) { + throw new ClassNotFoundException(name); + } + + return defineClass(name, byteCode, 0, byteCode.length); + } + + /** + * Utility method for creating a new {@code ByteCodeLoader} and then + * directly load the given byte code. + * + * @param className The name of the class + * @param byteCode The byte code for the class + * @throws ClassNotFoundException if the class can't be loaded + * @return A {@see Class} object representing the class + */ + public static Class load(String className, byte[] byteCode) throws ClassNotFoundException { + return new ByteCodeLoader(className, byteCode).loadClass(className); + } +} diff --git a/test/lib/jdk/test/lib/DynamicVMOption.java b/test/lib/jdk/test/lib/DynamicVMOption.java new file mode 100644 index 00000000000..17f545e126e --- /dev/null +++ b/test/lib/jdk/test/lib/DynamicVMOption.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib; + +import com.sun.management.HotSpotDiagnosticMXBean; +import java.lang.management.ManagementFactory; + +/** + * A utility class to work with VM options which could be altered during + * execution. + * + * This class is a wrapper around {@code com.sun.management.VMOption}. + * It provides more convenient interface to read/write the values. + * + */ +public class DynamicVMOption { + + private final HotSpotDiagnosticMXBean mxBean; + + /** + * VM option name, like "MinHeapFreeRatio". + */ + public final String name; + + /** + * Creates an instance of DynamicVMOption. + * + * @param name the VM option name + */ + public DynamicVMOption(String name) { + this.name = name; + mxBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); + } + + /** + * Sets a new value for the option. + * Trying to set not applicable value will cause IllegalArgumentException. + * Behavior with null is undefined, most likely NPE will be thrown. + * + * @param newValue the value to be set + * @see #getValue() + * @throws IllegalArgumentException if newValue is not applicable to the option + */ + public final void setValue(String newValue) { + mxBean.setVMOption(name, newValue); + } + + /** + * Returns the value of option. + * + * @return the current option value + * @see #setValue(java.lang.String) + */ + public final String getValue() { + return mxBean.getVMOption(name).getValue(); + } + + /** + * Returns true, if option is writable, false otherwise. + * + * @return true, if option is writable, false otherwise + */ + public final boolean isWriteable() { + return mxBean.getVMOption(name).isWriteable(); + } + + /** + * Checks if the given value is applicable for the option. + * + * This method tries to set the option to the new value. If no exception + * has been thrown the value is treated as valid. + * + * Calling this method will not change the option value. After an attempt + * to set a new value, the option will be restored to its previous value. + * + * @param value the value to verify + * @return true if option could be set to the given value + */ + public boolean isValidValue(String value) { + boolean isValid = true; + String oldValue = getValue(); + try { + setValue(value); + } catch (NullPointerException e) { + if (value == null) { + isValid = false; + } + } catch (IllegalArgumentException e) { + isValid = false; + } finally { + setValue(oldValue); + } + return isValid; + } + + /** + * Returns the value of the given VM option as String. + * + * This is a simple shortcut for {@code new DynamicVMOption(name).getValue()} + * + * @param name the name of VM option + * @return value as a string + * @see #getValue() + */ + public static String getString(String name) { + return new DynamicVMOption(name).getValue(); + } + + /** + * Returns the value of the given option as int. + * + * @param name the name of VM option + * @return value parsed as integer + * @see #getString(java.lang.String) + * + */ + public static int getInt(String name) { + return Integer.parseInt(getString(name)); + } + + /** + * Sets the VM option to a new value. + * + * This is a simple shortcut for {@code new DynamicVMOption(name).setValue(value)} + * + * @param name the name of VM option + * @param value the value to be set + * @see #setValue(java.lang.String) + */ + public static void setString(String name, String value) { + new DynamicVMOption(name).setValue(value); + } + + /** + * Sets the VM option value to a new integer value. + * + * @param name the name of VM option + * @param value the integer value to be set + * @see #setString(java.lang.String, java.lang.String) + */ + public static void setInt(String name, int value) { + new DynamicVMOption(name).setValue(Integer.toString(value)); + } + +} diff --git a/test/lib/jdk/test/lib/FileInstaller.java b/test/lib/jdk/test/lib/FileInstaller.java new file mode 100644 index 00000000000..1247deedcb1 --- /dev/null +++ b/test/lib/jdk/test/lib/FileInstaller.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; + +/** + * Copy a resource: file or directory recursively, using relative path(src and dst) + * which are applied to test source directory(src) and current directory(dst) + */ +public class FileInstaller { + /** + * @param args source and destination + * @throws IOException if an I/O error occurs + */ + public static void main(String[] args) throws IOException { + if (args.length != 2) { + throw new IllegalArgumentException("Unexpected number of arguments for file copy"); + } + Path src = Paths.get(Utils.TEST_SRC, args[0]).toAbsolutePath(); + Path dst = Paths.get(args[1]).toAbsolutePath(); + if (src.toFile().exists()) { + if (src.toFile().isDirectory()) { + Files.walkFileTree(src, new CopyFileVisitor(src, dst)); + } else { + Path dstDir = dst.getParent(); + if (!dstDir.toFile().exists()) { + Files.createDirectories(dstDir); + } + Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING); + } + } else { + throw new IOException("Can't find source " + src); + } + } + + private static class CopyFileVisitor extends SimpleFileVisitor { + private final Path copyFrom; + private final Path copyTo; + + public CopyFileVisitor(Path copyFrom, Path copyTo) { + this.copyFrom = copyFrom; + this.copyTo = copyTo; + } + + @Override + public FileVisitResult preVisitDirectory(Path file, + BasicFileAttributes attrs) throws IOException { + Path relativePath = file.relativize(copyFrom); + Path destination = copyTo.resolve(relativePath); + if (!destination.toFile().exists()) { + Files.createDirectories(destination); + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + if (!file.toFile().isFile()) { + return FileVisitResult.CONTINUE; + } + Path relativePath = copyFrom.relativize(file); + Path destination = copyTo.resolve(relativePath); + Files.copy(file, destination, StandardCopyOption.COPY_ATTRIBUTES); + return FileVisitResult.CONTINUE; + } + } +} diff --git a/test/lib/jdk/test/lib/InMemoryJavaCompiler.java b/test/lib/jdk/test/lib/InMemoryJavaCompiler.java new file mode 100644 index 00000000000..5fb78e4441f --- /dev/null +++ b/test/lib/jdk/test/lib/InMemoryJavaCompiler.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2013, 2016, 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 jdk.test.lib; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import java.net.URI; +import java.util.Arrays; + +import javax.tools.ForwardingJavaFileManager; +import javax.tools.FileObject; +import javax.tools.JavaCompiler; +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileObject; +import javax.tools.JavaFileObject.Kind; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +/** + * {@code InMemoryJavaCompiler} can be used for compiling a {@link + * CharSequence} to a {@code byte[]}. + * + * The compiler will not use the file system at all, instead using a {@link + * ByteArrayOutputStream} for storing the byte code. For the source code, any + * kind of {@link CharSequence} can be used, e.g. {@link String}, {@link + * StringBuffer} or {@link StringBuilder}. + * + * The {@code InMemoryCompiler} can easily be used together with a {@code + * ByteClassLoader} to easily compile and load source code in a {@link String}: + * + *

            + * {@code
            + * import jdk.test.lib.InMemoryJavaCompiler;
            + * import jdk.test.lib.ByteClassLoader;
            + *
            + * class Example {
            + *     public static void main(String[] args) {
            + *         String className = "Foo";
            + *         String sourceCode = "public class " + className + " {" +
            + *                             "    public void bar() {" +
            + *                             "        System.out.println("Hello from bar!");" +
            + *                             "    }" +
            + *                             "}";
            + *         byte[] byteCode = InMemoryJavaCompiler.compile(className, sourceCode);
            + *         Class fooClass = ByteClassLoader.load(className, byteCode);
            + *     }
            + * }
            + * }
            + * 
            + */ +public class InMemoryJavaCompiler { + private static class MemoryJavaFileObject extends SimpleJavaFileObject { + private final String className; + private final CharSequence sourceCode; + private final ByteArrayOutputStream byteCode; + + public MemoryJavaFileObject(String className, CharSequence sourceCode) { + super(URI.create("string:///" + className.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE); + this.className = className; + this.sourceCode = sourceCode; + this.byteCode = new ByteArrayOutputStream(); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return sourceCode; + } + + @Override + public OutputStream openOutputStream() throws IOException { + return byteCode; + } + + public byte[] getByteCode() { + return byteCode.toByteArray(); + } + + public String getClassName() { + return className; + } + } + + private static class FileManagerWrapper extends ForwardingJavaFileManager { + private MemoryJavaFileObject file; + + public FileManagerWrapper(MemoryJavaFileObject file) { + super(getCompiler().getStandardFileManager(null, null, null)); + this.file = file; + } + + @Override + public JavaFileObject getJavaFileForOutput(Location location, String className, + Kind kind, FileObject sibling) + throws IOException { + if (!file.getClassName().equals(className)) { + throw new IOException("Expected class with name " + file.getClassName() + + ", but got " + className); + } + return file; + } + } + + /** + * Compiles the class with the given name and source code. + * + * @param className The name of the class + * @param sourceCode The source code for the class with name {@code className} + * @param options additional command line options + * @throws RuntimeException if the compilation did not succeed + * @return The resulting byte code from the compilation + */ + public static byte[] compile(String className, CharSequence sourceCode, String... options) { + MemoryJavaFileObject file = new MemoryJavaFileObject(className, sourceCode); + CompilationTask task = getCompilationTask(file, options); + + if(!task.call()) { + throw new RuntimeException("Could not compile " + className + " with source code " + sourceCode); + } + + return file.getByteCode(); + } + + private static JavaCompiler getCompiler() { + return ToolProvider.getSystemJavaCompiler(); + } + + private static CompilationTask getCompilationTask(MemoryJavaFileObject file, String... options) { + return getCompiler().getTask(null, new FileManagerWrapper(file), null, Arrays.asList(options), null, Arrays.asList(file)); + } +} diff --git a/test/lib/share/classes/jdk/test/lib/JDKToolFinder.java b/test/lib/jdk/test/lib/JDKToolFinder.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/JDKToolFinder.java rename to test/lib/jdk/test/lib/JDKToolFinder.java index 3ad008e0005..a9a3598f10d 100644 --- a/test/lib/share/classes/jdk/test/lib/JDKToolFinder.java +++ b/test/lib/jdk/test/lib/JDKToolFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/JDKToolLauncher.java b/test/lib/jdk/test/lib/JDKToolLauncher.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/JDKToolLauncher.java rename to test/lib/jdk/test/lib/JDKToolLauncher.java index 3948d474ec1..38e7b4530bf 100644 --- a/test/lib/share/classes/jdk/test/lib/JDKToolLauncher.java +++ b/test/lib/jdk/test/lib/JDKToolLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -26,7 +26,7 @@ package jdk.test.lib; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import jdk.test.lib.process.*; +import jdk.test.lib.process.ProcessTools; /** * A utility for constructing command lines for starting JDK tool processes. diff --git a/test/lib/share/classes/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/Platform.java rename to test/lib/jdk/test/lib/Platform.java index 8c55f091467..ec4fa8b63ba 100644 --- a/test/lib/share/classes/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ public class Platform { private static final String osName = System.getProperty("os.name"); private static final String dataModel = System.getProperty("sun.arch.data.model"); private static final String vmVersion = System.getProperty("java.vm.version"); - private static final String javaVersion = System.getProperty("java.version"); + private static final String jdkDebug = System.getProperty("jdk.debug"); private static final String osArch = System.getProperty("os.arch"); private static final String userName = System.getProperty("user.name"); private static final String compiler = System.getProperty("sun.management.compiler"); @@ -113,8 +113,7 @@ public class Platform { } public static boolean isDebugBuild() { - return (vmVersion.toLowerCase().contains("debug") || - javaVersion.toLowerCase().contains("debug")); + return (jdkDebug.toLowerCase().contains("debug")); } public static String getVMVersion() { diff --git a/test/lib/share/classes/jdk/test/lib/Utils.java b/test/lib/jdk/test/lib/Utils.java similarity index 91% rename from test/lib/share/classes/jdk/test/lib/Utils.java rename to test/lib/jdk/test/lib/Utils.java index 95e2bbab48a..aececb0301f 100644 --- a/test/lib/share/classes/jdk/test/lib/Utils.java +++ b/test/lib/jdk/test/lib/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -40,7 +40,10 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; +import java.util.Map; +import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.Random; import java.util.function.BooleanSupplier; import java.util.concurrent.TimeUnit; @@ -50,8 +53,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.internal.misc.Unsafe; -import jdk.test.lib.process.*; import static jdk.test.lib.Asserts.assertTrue; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; /** * Common library for various test helper functions. @@ -446,6 +450,23 @@ public final class Utils { return iterator.next(); } + /** + * Returns random element of non empty array + * + * @param a type of array element + * @param array array of elements + * @return random element of array + * @throws IllegalArgumentException if array is empty + */ + public static T getRandomElement(T[] array) + throws IllegalArgumentException { + if (array == null || array.length == 0) { + throw new IllegalArgumentException("Empty or null array"); + } + Random random = getRandomInstance(); + return array[random.nextInt(array.length)]; + } + /** * Wait for condition to be true * @@ -636,5 +657,38 @@ public final class Utils { } return result; } + + public static Object[] getNullValues(Class... types) { + Object[] result = new Object[types.length]; + int i = 0; + for (Class type : types) { + result[i++] = NULL_VALUES.get(type); + } + return result; + } + private static Map, Object> NULL_VALUES = new HashMap<>(); + static { + NULL_VALUES.put(boolean.class, false); + NULL_VALUES.put(byte.class, (byte) 0); + NULL_VALUES.put(short.class, (short) 0); + NULL_VALUES.put(char.class, '\0'); + NULL_VALUES.put(int.class, 0); + NULL_VALUES.put(long.class, 0L); + NULL_VALUES.put(float.class, 0.0f); + NULL_VALUES.put(double.class, 0.0d); + } + + /** + * Returns mandatory property value + * @param propName is a name of property to request + * @return a String with requested property value + */ + public static String getMandatoryProperty(String propName) { + Objects.requireNonNull(propName, "Requested null property"); + String prop = System.getProperty(propName); + Objects.requireNonNull(prop, + String.format("A mandatory property '%s' isn't set", propName)); + return prop; + } } diff --git a/test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java rename to test/lib/jdk/test/lib/apps/LingeredApp.java index d5675a3f635..ac375b62faf 100644 --- a/test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/apps/LingeredAppWithDeadlock.java b/test/lib/jdk/test/lib/apps/LingeredAppWithDeadlock.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/apps/LingeredAppWithDeadlock.java rename to test/lib/jdk/test/lib/apps/LingeredAppWithDeadlock.java index 85d96f29f95..2b52c1523db 100644 --- a/test/lib/share/classes/jdk/test/lib/apps/LingeredAppWithDeadlock.java +++ b/test/lib/jdk/test/lib/apps/LingeredAppWithDeadlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 diff --git a/test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java new file mode 100644 index 00000000000..121d81d8d95 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/CPUSpecificCommandLineOptionTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.cli; + +import jdk.test.lib.cli.predicate.CPUSpecificPredicate; + +/** + * Base class for command line options tests that + * requires specific CPU arch or specific CPU features. + */ +public abstract class CPUSpecificCommandLineOptionTest + extends CommandLineOptionTest { + /** + * Creates new CPU specific test instance that does not + * require any CPU features. + * + * @param cpuArchPattern Regular expression that should + * match os.arch. + */ + public CPUSpecificCommandLineOptionTest(String cpuArchPattern) { + this(cpuArchPattern, null, null); + } + + /** + * Creates new CPU specific test instance that does not + * require from CPU support of {@code supportedCPUFeatures} features + * and no support of {@code unsupportedCPUFeatures}. + * + * @param cpuArchPattern Regular expression that should + * match os.arch. + * @param supportedCPUFeatures Array with names of features that + * should be supported by CPU. If {@code null}, + * then no features have to be supported. + * @param unsupportedCPUFeatures Array with names of features that + * should not be supported by CPU. + * If {@code null}, then CPU may support any + * features. + */ + public CPUSpecificCommandLineOptionTest(String cpuArchPattern, + String supportedCPUFeatures[], String unsupportedCPUFeatures[]) { + super(new CPUSpecificPredicate(cpuArchPattern, supportedCPUFeatures, + unsupportedCPUFeatures)); + } +} diff --git a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java new file mode 100644 index 00000000000..f794ef36090 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.cli; + +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; +import java.util.function.BooleanSupplier; + +import jdk.test.lib.process.ExitCode; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; + +/** + * Base class for command line option tests. + */ +public abstract class CommandLineOptionTest { + public static final String UNLOCK_DIAGNOSTIC_VM_OPTIONS + = "-XX:+UnlockDiagnosticVMOptions"; + public static final String UNLOCK_EXPERIMENTAL_VM_OPTIONS + = "-XX:+UnlockExperimentalVMOptions"; + protected static final String UNRECOGNIZED_OPTION_ERROR_FORMAT + = "Unrecognized VM option '[+-]?%s(=.*)?'"; + protected static final String EXPERIMENTAL_OPTION_ERROR_FORMAT + = "VM option '%s' is experimental and must be enabled via " + + "-XX:\\+UnlockExperimentalVMOptions."; + protected static final String DIAGNOSTIC_OPTION_ERROR_FORMAT + = " VM option '%s' is diagnostic and must be enabled via " + + "-XX:\\+UnlockDiagnosticVMOptions."; + private static final String PRINT_FLAGS_FINAL_FORMAT = "%s\\s*:?=\\s*%s"; + + /** + * Verifies that JVM startup behavior matches our expectations. + * + * @param option an option that should be passed to JVM + * @param expectedMessages an array of patterns that should occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not + * occur in JVM output. If {@code null} then + * JVM output could be empty. + * @param exitErrorMessage message that will be shown if exit code is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. + * @param exitCode expected exit code. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyJVMStartup(String option, + String expectedMessages[], String unexpectedMessages[], + String exitErrorMessage, String wrongWarningMessage, + ExitCode exitCode) throws Throwable { + CommandLineOptionTest.verifyJVMStartup(expectedMessages, + unexpectedMessages, exitErrorMessage, + wrongWarningMessage, exitCode, false, option); + } + + /** + * Verifies that JVM startup behavior matches our expectations. + * + * @param expectedMessages an array of patterns that should occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not + * occur in JVM output. If {@code null} then + * JVM output could be empty. + * @param exitErrorMessage message that will be shown if exit code is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. + * @param exitCode expected exit code. + * @param addTestVMOptions if {@code true} then test VM options will be + * passed to VM. + * @param options options that should be passed to VM in addition to mode + * flag. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyJVMStartup(String expectedMessages[], + String unexpectedMessages[], String exitErrorMessage, + String wrongWarningMessage, ExitCode exitCode, + boolean addTestVMOptions, String... options) + throws Throwable { + List finalOptions = new ArrayList<>(); + if (addTestVMOptions) { + Collections.addAll(finalOptions, ProcessTools.getVmInputArgs()); + Collections.addAll(finalOptions, Utils.getTestJavaOpts()); + } + Collections.addAll(finalOptions, options); + finalOptions.add("-version"); + + ProcessBuilder processBuilder + = ProcessTools.createJavaProcessBuilder(finalOptions.toArray( + new String[finalOptions.size()])); + OutputAnalyzer outputAnalyzer + = new OutputAnalyzer(processBuilder.start()); + + try { + outputAnalyzer.shouldHaveExitValue(exitCode.value); + } catch (RuntimeException e) { + String errorMessage = String.format( + "JVM process should have exit value '%d'.%n%s", + exitCode.value, exitErrorMessage); + throw new AssertionError(errorMessage, e); + } + + verifyOutput(expectedMessages, unexpectedMessages, + wrongWarningMessage, outputAnalyzer); + } + + /** + * Verifies that JVM startup behavior matches our expectations. + * + * @param expectedMessages an array of patterns that should occur in JVM + * output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param wrongWarningMessage message that will be shown if messages are + * not as expected. + * @param outputAnalyzer OutputAnalyzer instance + * @throws AssertionError if verification fails. + */ + public static void verifyOutput(String[] expectedMessages, + String[] unexpectedMessages, String wrongWarningMessage, + OutputAnalyzer outputAnalyzer) { + if (expectedMessages != null) { + for (String expectedMessage : expectedMessages) { + try { + outputAnalyzer.shouldMatch(expectedMessage); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Expected message not found: '%s'.%n%s", + expectedMessage, wrongWarningMessage); + throw new AssertionError(errorMessage, e); + } + } + } + + if (unexpectedMessages != null) { + for (String unexpectedMessage : unexpectedMessages) { + try { + outputAnalyzer.shouldNotMatch(unexpectedMessage); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Unexpected message found: '%s'.%n%s", + unexpectedMessage, wrongWarningMessage); + throw new AssertionError(errorMessage, e); + } + } + } + } + + /** + * Verifies that JVM startup behavior matches our expectations when type + * of newly started VM is the same as the type of current. + * + * @param expectedMessages an array of patterns that should occur + * in JVM output. If {@code null} then + * JVM output could be empty. + * @param unexpectedMessages an array of patterns that should not + * occur in JVM output. If {@code null} then + * JVM output could be empty. + * @param exitErrorMessage Message that will be shown if exit value is not + * as expected. + * @param wrongWarningMessage message that will be shown if warning + * messages are not as expected. + * @param exitCode expected exit code. + * @param options options that should be passed to VM in addition to mode + * flag. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifySameJVMStartup(String expectedMessages[], + String unexpectedMessages[], String exitErrorMessage, + String wrongWarningMessage, ExitCode exitCode, String... options) + throws Throwable { + List finalOptions = new ArrayList<>(); + finalOptions.add(CommandLineOptionTest.getVMTypeOption()); + Collections.addAll(finalOptions, options); + + CommandLineOptionTest.verifyJVMStartup(expectedMessages, + unexpectedMessages, exitErrorMessage, + wrongWarningMessage, exitCode, false, + finalOptions.toArray(new String[finalOptions.size()])); + } + + /** + * Verifies that value of specified JVM option is the same as + * expected value. + * This method filter out option with {@code optionName} + * name from test java options. + * + * @param optionName a name of tested option. + * @param expectedValue expected value of tested option. + * @param optionErrorString message will be shown if option value is not as + * expected. + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValue(String optionName, + String expectedValue, String optionErrorString, + String... additionalVMOpts) throws Throwable { + verifyOptionValue(optionName, expectedValue, optionErrorString, + true, additionalVMOpts); + } + + /** + * Verifies that value of specified JVM option is the same as + * expected value. + * This method filter out option with {@code optionName} + * name from test java options. + * + * @param optionName a name of tested option. + * @param expectedValue expected value of tested option. + * @param addTestVmOptions if {@code true}, then test VM options + * will be used. + * @param optionErrorString message will be shown if option value is not as + * expected. + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @throws Throwable if verification fails or some other issues + * occur. + */ + public static void verifyOptionValue(String optionName, + String expectedValue, String optionErrorString, + boolean addTestVmOptions, String... additionalVMOpts) + throws Throwable { + List vmOpts = new ArrayList<>(); + + if (addTestVmOptions) { + Collections.addAll(vmOpts, + Utils.getFilteredTestJavaOpts(optionName)); + } + Collections.addAll(vmOpts, additionalVMOpts); + Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version"); + + ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + vmOpts.toArray(new String[vmOpts.size()])); + + OutputAnalyzer outputAnalyzer + = new OutputAnalyzer(processBuilder.start()); + + try { + outputAnalyzer.shouldHaveExitValue(0); + } catch (RuntimeException e) { + String errorMessage = String.format( + "JVM should start with option '%s' without errors.", + optionName); + throw new AssertionError(errorMessage, e); + } + verifyOptionValue(optionName, expectedValue, optionErrorString, + outputAnalyzer); + } + + /** + * Verifies that value of specified JVM option is the same as + * expected value. + * + * @param optionName a name of tested option. + * @param expectedValue expected value of tested option. + * @param optionErrorString message will be shown if option value is not + * as expected. + * @param outputAnalyzer OutputAnalyzer instance + * @throws AssertionError if verification fails + */ + public static void verifyOptionValue(String optionName, + String expectedValue, String optionErrorString, + OutputAnalyzer outputAnalyzer) { + try { + outputAnalyzer.shouldMatch(String.format( + CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, + optionName, expectedValue)); + } catch (RuntimeException e) { + String errorMessage = String.format( + "Option '%s' is expected to have '%s' value%n%s", + optionName, expectedValue, + optionErrorString); + throw new AssertionError(errorMessage, e); + } + } + + /** + * Start VM with given options and values. + * Generates command line option flags from + * {@code optionNames} and {@code optionValues}. + * + * @param optionNames names of options to pass in + * @param optionValues values of option + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @return output from vm process + */ + public static OutputAnalyzer startVMWithOptions(String[] optionNames, + String[] optionValues, + String... additionalVMOpts) throws Throwable { + List vmOpts = new ArrayList<>(); + if (optionNames == null || optionValues == null || optionNames.length != optionValues.length) { + throw new IllegalArgumentException("optionNames and/or optionValues"); + } + + for (int i = 0; i < optionNames.length; i++) { + vmOpts.add(prepareFlag(optionNames[i], optionValues[i])); + } + Collections.addAll(vmOpts, additionalVMOpts); + Collections.addAll(vmOpts, "-version"); + + ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + vmOpts.toArray(new String[vmOpts.size()])); + + return new OutputAnalyzer(processBuilder.start()); + } + + /** + * Verifies from the output that values of specified JVM options were the same as + * expected values. + * + * @param outputAnalyzer search output for expect options and values. + * @param optionNames names of tested options. + * @param expectedValues expected values of tested options. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValuesFromOutput(OutputAnalyzer outputAnalyzer, + String[] optionNames, + String[] expectedValues) throws Throwable { + outputAnalyzer.shouldHaveExitValue(0); + for (int i = 0; i < optionNames.length; i++) { + outputAnalyzer.shouldMatch(String.format( + CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT, + optionNames[i], expectedValues[i])); + } + } + + /** + * Verifies that value of specified JVM options are the same as + * expected values. + * Generates command line option flags from + * {@code optionNames} and {@code expectedValues}. + * + * @param optionNames names of tested options. + * @param expectedValues expected values of tested options. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValues(String[] optionNames, + String[] expectedValues) throws Throwable { + OutputAnalyzer outputAnalyzer = startVMWithOptions(optionNames, expectedValues, "-XX:+PrintFlagsFinal"); + verifyOptionValuesFromOutput(outputAnalyzer, optionNames, expectedValues); + } + + /** + * Verifies that value of specified JVM when type of newly started VM + * is the same as the type of current. + * This method filter out option with {@code optionName} + * name from test java options. + * Only mode flag will be passed to VM in addition to + * {@code additionalVMOpts} + * + * @param optionName name of tested option. + * @param expectedValue expected value of tested option. + * @param optionErrorString message to show if option has another value + * @param additionalVMOpts additional options that should be + * passed to JVM. + * @throws Throwable if verification fails or some other issues occur. + */ + public static void verifyOptionValueForSameVM(String optionName, + String expectedValue, String optionErrorString, + String... additionalVMOpts) throws Throwable { + List finalOptions = new ArrayList<>(); + finalOptions.add(CommandLineOptionTest.getVMTypeOption()); + Collections.addAll(finalOptions, additionalVMOpts); + + CommandLineOptionTest.verifyOptionValue(optionName, expectedValue, + optionErrorString, false, + finalOptions.toArray(new String[finalOptions.size()])); + } + + /** + * Prepares boolean command line flag with name {@code name} according + * to it's {@code value}. + * + * @param name the name of option to be prepared + * @param value the value of option + * @return prepared command line flag + */ + public static String prepareBooleanFlag(String name, boolean value) { + return String.format("-XX:%c%s", (value ? '+' : '-'), name); + } + + /** + * Prepares numeric command line flag with name {@code name} by setting + * it's value to {@code value}. + * + * @param name the name of option to be prepared + * @param value the value of option + * @return prepared command line flag + */ + public static String prepareNumericFlag(String name, Number value) { + return String.format("-XX:%s=%s", name, value.toString()); + } + + /** + * Prepares generic command line flag with name {@code name} by setting + * it's value to {@code value}. + * + * @param name the name of option to be prepared + * @param value the value of option ("+" or "-" can be used instead of "true" or "false") + * @return prepared command line flag + */ + public static String prepareFlag(String name, String value) { + if (value.equals("+") || value.equalsIgnoreCase("true")) { + return "-XX:+" + name; + } else if (value.equals("-") || value.equalsIgnoreCase("false")) { + return "-XX:-" + name; + } else { + return "-XX:" + name + "=" + value; + } + } + + /** + * Returns message that should occur in VM output if option + * {@code optionName} if unrecognized. + * + * @param optionName the name of option for which message should be returned + * @return message saying that option {@code optionName} is unrecognized + */ + public static String getUnrecognizedOptionErrorMessage(String optionName) { + return String.format( + CommandLineOptionTest.UNRECOGNIZED_OPTION_ERROR_FORMAT, + optionName); + } + + /** + * Returns message that should occur in VM output if option + * {@code optionName} is experimental and + * -XX:+UnlockExperimentalVMOptions was not passed to VM. + * + * @param optionName the name of option for which message should be returned + * @return message saying that option {@code optionName} is experimental + */ + public static String getExperimentalOptionErrorMessage(String optionName) { + return String.format( + CommandLineOptionTest.EXPERIMENTAL_OPTION_ERROR_FORMAT, + optionName); + } + + /** + * Returns message that should occur in VM output if option + * {@code optionName} is diagnostic and -XX:+UnlockDiagnosticVMOptions + * was not passed to VM. + * + * @param optionName the name of option for which message should be returned + * @return message saying that option {@code optionName} is diganostic + */ + public static String getDiagnosticOptionErrorMessage(String optionName) { + return String.format( + CommandLineOptionTest.DIAGNOSTIC_OPTION_ERROR_FORMAT, + optionName); + } + + /** + * @return option required to start a new VM with the same type as current. + * @throws RuntimeException when VM type is unknown. + */ + private static String getVMTypeOption() { + if (Platform.isServer()) { + return "-server"; + } else if (Platform.isClient()) { + return "-client"; + } else if (Platform.isMinimal()) { + return "-minimal"; + } else if (Platform.isGraal()) { + return "-graal"; + } + throw new RuntimeException("Unknown VM mode."); + } + + private final BooleanSupplier predicate; + + /** + * Constructs new CommandLineOptionTest that will be executed only if + * predicate {@code predicate} return {@code true}. + * @param predicate a predicate responsible for test's preconditions check. + */ + public CommandLineOptionTest(BooleanSupplier predicate) { + this.predicate = predicate; + } + + /** + * Runs command line option test. + */ + public final void test() throws Throwable { + if (predicate.getAsBoolean()) { + runTestCases(); + } + } + + /** + * @throws Throwable if some issue happened during test cases execution. + */ + protected abstract void runTestCases() throws Throwable; +} diff --git a/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java b/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java new file mode 100644 index 00000000000..1e70abc2e00 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/AndPredicate.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.cli.predicate; + +import java.util.function.BooleanSupplier; + +public class AndPredicate implements BooleanSupplier { + private final BooleanSupplier a; + private final BooleanSupplier b; + + public AndPredicate(BooleanSupplier a, BooleanSupplier b) { + this.a = a; + this.b = b; + } + + @Override + public boolean getAsBoolean() { + return a.getAsBoolean() && b.getAsBoolean(); + } +} diff --git a/test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java b/test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java new file mode 100644 index 00000000000..69f753f5a84 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.cli.predicate; + +import jdk.test.lib.Platform; +import sun.hotspot.cpuinfo.CPUInfo; + +import java.util.function.BooleanSupplier; + +public class CPUSpecificPredicate implements BooleanSupplier { + private final String cpuArchPattern; + private final String supportedCPUFeatures[]; + private final String unsupportedCPUFeatures[]; + + public CPUSpecificPredicate(String cpuArchPattern, + String supportedCPUFeatures[], + String unsupportedCPUFeatures[]) { + this.cpuArchPattern = cpuArchPattern; + this.supportedCPUFeatures = supportedCPUFeatures; + this.unsupportedCPUFeatures = unsupportedCPUFeatures; + } + + @Override + public boolean getAsBoolean() { + if (!Platform.getOsArch().matches(cpuArchPattern)) { + System.out.println("CPU arch " + Platform.getOsArch() + " does not match " + cpuArchPattern); + return false; + } + + if (supportedCPUFeatures != null) { + for (String feature : supportedCPUFeatures) { + if (!CPUInfo.hasFeature(feature)) { + System.out.println("CPU does not support " + feature + + " feature"); + return false; + } + } + } + + if (unsupportedCPUFeatures != null) { + for (String feature : unsupportedCPUFeatures) { + if (CPUInfo.hasFeature(feature)) { + System.out.println("CPU support " + feature + " feature"); + return false; + } + } + } + return true; + } +} diff --git a/test/lib/jdk/test/lib/cli/predicate/NotPredicate.java b/test/lib/jdk/test/lib/cli/predicate/NotPredicate.java new file mode 100644 index 00000000000..481f878e228 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/NotPredicate.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.cli.predicate; + +import java.util.function.BooleanSupplier; + +public class NotPredicate implements BooleanSupplier { + private final BooleanSupplier s; + + public NotPredicate(BooleanSupplier s) { + this.s = s; + } + + @Override + public boolean getAsBoolean() { + return !s.getAsBoolean(); + } +} diff --git a/test/lib/jdk/test/lib/cli/predicate/OrPredicate.java b/test/lib/jdk/test/lib/cli/predicate/OrPredicate.java new file mode 100644 index 00000000000..35f5e979966 --- /dev/null +++ b/test/lib/jdk/test/lib/cli/predicate/OrPredicate.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.cli.predicate; + +import java.util.function.BooleanSupplier; + +public class OrPredicate implements BooleanSupplier { + private final BooleanSupplier a; + private final BooleanSupplier b; + + public OrPredicate(BooleanSupplier a, BooleanSupplier b) { + this.a = a; + this.b = b; + } + + @Override + public boolean getAsBoolean() { + return a.getAsBoolean() || b.getAsBoolean(); + } +} diff --git a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java new file mode 100644 index 00000000000..e8c5791f487 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +import jdk.test.lib.process.OutputAnalyzer; + +/** + * Abstract base class for Diagnostic Command executors + */ +public abstract class CommandExecutor { + + /** + * Execute a diagnostic command + * + * @param cmd The diagnostic command to execute + * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command + * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the + * Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in + * stderr, regardless of the specific executor used. + */ + public final OutputAnalyzer execute(String cmd) throws CommandExecutorException { + return execute(cmd, false); + } + + /** + * Execute a diagnostic command + * + * @param cmd The diagnostic command to execute + * @param silent Do not print the command output + * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command + * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the + * Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in + * stderr, regardless of the specific executor used. + */ + public final OutputAnalyzer execute(String cmd, boolean silent) throws CommandExecutorException { + if (!silent) { + System.out.printf("Running DCMD '%s' through '%s'%n", cmd, this.getClass().getSimpleName()); + } + + OutputAnalyzer oa = executeImpl(cmd); + + if (!silent) { + System.out.println("---------------- stdout ----------------"); + System.out.println(oa.getStdout()); + System.out.println("---------------- stderr ----------------"); + System.out.println(oa.getStderr()); + System.out.println("----------------------------------------"); + System.out.println(); + } + return oa; + } + + protected abstract OutputAnalyzer executeImpl(String cmd) throws CommandExecutorException; +} diff --git a/test/lib/jdk/test/lib/dcmd/CommandExecutorException.java b/test/lib/jdk/test/lib/dcmd/CommandExecutorException.java new file mode 100644 index 00000000000..89aa1b3dee0 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/CommandExecutorException.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +/** + * CommandExecutorException encapsulates exceptions thrown (on the "calling side") from the execution of Diagnostic + * Commands + */ +public class CommandExecutorException extends RuntimeException { + private static final long serialVersionUID = -7039597746579144280L; + + public CommandExecutorException(String message, Throwable e) { + super(message, e); + } +} diff --git a/test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java new file mode 100644 index 00000000000..563b65fd20e --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/FileJcmdExecutor.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.List; + +/** + * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool and its ability to read + * Diagnostic Commands from a file. + */ +public class FileJcmdExecutor extends PidJcmdExecutor { + + /** + * Instantiates a new FileJcmdExecutor targeting the current VM + */ + public FileJcmdExecutor() { + super(); + } + + /** + * Instantiates a new FileJcmdExecutor targeting the VM indicated by the given pid + * + * @param target Pid of the target VM + */ + public FileJcmdExecutor(String target) { + super(target); + } + + protected List createCommandLine(String cmd) throws CommandExecutorException { + File cmdFile = createTempFile(); + writeCommandToTemporaryFile(cmd, cmdFile); + + return Arrays.asList(jcmdBinary, Long.toString(pid), + "-f", cmdFile.getAbsolutePath()); + } + + private void writeCommandToTemporaryFile(String cmd, File cmdFile) { + try (PrintWriter pw = new PrintWriter(cmdFile)) { + pw.println(cmd); + } catch (IOException e) { + String message = "Could not write to file: " + cmdFile.getAbsolutePath(); + throw new CommandExecutorException(message, e); + } + } + + private File createTempFile() { + try { + File cmdFile = File.createTempFile("input", "jcmd"); + cmdFile.deleteOnExit(); + return cmdFile; + } catch (IOException e) { + throw new CommandExecutorException("Could not create temporary file", e); + } + } + +} diff --git a/test/lib/jdk/test/lib/dcmd/JMXExecutor.java b/test/lib/jdk/test/lib/dcmd/JMXExecutor.java new file mode 100644 index 00000000000..677b5db0def --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/JMXExecutor.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +import jdk.test.lib.process.OutputAnalyzer; + +import javax.management.*; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import java.lang.management.ManagementFactory; + +import java.util.HashMap; + +/** + * Executes Diagnostic Commands on the target VM (specified by a host/port combination or a full JMX Service URL) using + * the JMX interface. If the target is not the current VM, the JMX Remote interface must be enabled beforehand. + */ +public class JMXExecutor extends CommandExecutor { + + private final MBeanServerConnection mbs; + + /** + * Instantiates a new JMXExecutor targeting the current VM + */ + public JMXExecutor() { + super(); + mbs = ManagementFactory.getPlatformMBeanServer(); + } + + /** + * Instantiates a new JMXExecutor targeting the VM indicated by the given host/port combination or a full JMX + * Service URL + * + * @param target a host/port combination on the format "host:port" or a full JMX Service URL of the target VM + */ + public JMXExecutor(String target) { + String urlStr; + + if (target.matches("^\\w[\\w\\-]*(\\.[\\w\\-]+)*:\\d+$")) { + /* Matches "hostname:port" */ + urlStr = String.format("service:jmx:rmi:///jndi/rmi://%s/jmxrmi", target); + } else if (target.startsWith("service:")) { + urlStr = target; + } else { + throw new IllegalArgumentException("Could not recognize target string: " + target); + } + + try { + JMXServiceURL url = new JMXServiceURL(urlStr); + JMXConnector c = JMXConnectorFactory.connect(url, new HashMap<>()); + mbs = c.getMBeanServerConnection(); + } catch (IOException e) { + throw new CommandExecutorException("Could not initiate connection to target: " + target, e); + } + } + + protected OutputAnalyzer executeImpl(String cmd) throws CommandExecutorException { + String stdout = ""; + String stderr = ""; + + String[] cmdParts = cmd.split(" ", 2); + String operation = commandToMethodName(cmdParts[0]); + Object[] dcmdArgs = produceArguments(cmdParts); + String[] signature = {String[].class.getName()}; + + ObjectName beanName = getMBeanName(); + + try { + stdout = (String) mbs.invoke(beanName, operation, dcmdArgs, signature); + } + + /* Failures on the "local" side, the one invoking the command. */ + catch (ReflectionException e) { + Throwable cause = e.getCause(); + if (cause instanceof NoSuchMethodException) { + /* We want JMXExecutor to match the behavior of the other CommandExecutors */ + String message = "Unknown diagnostic command: " + operation; + stderr = exceptionTraceAsString(new IllegalArgumentException(message, e)); + } else { + rethrowExecutorException(operation, dcmdArgs, e); + } + } + + /* Failures on the "local" side, the one invoking the command. */ + catch (InstanceNotFoundException | IOException e) { + rethrowExecutorException(operation, dcmdArgs, e); + } + + /* Failures on the remote side, the one executing the invoked command. */ + catch (MBeanException e) { + stdout = exceptionTraceAsString(e); + } + + return new OutputAnalyzer(stdout, stderr); + } + + private void rethrowExecutorException(String operation, Object[] dcmdArgs, + Exception e) throws CommandExecutorException { + String message = String.format("Could not invoke: %s %s", operation, + String.join(" ", (String[]) dcmdArgs[0])); + throw new CommandExecutorException(message, e); + } + + private ObjectName getMBeanName() throws CommandExecutorException { + String MBeanName = "com.sun.management:type=DiagnosticCommand"; + + try { + return new ObjectName(MBeanName); + } catch (MalformedObjectNameException e) { + String message = "MBean not found: " + MBeanName; + throw new CommandExecutorException(message, e); + } + } + + private Object[] produceArguments(String[] cmdParts) { + Object[] dcmdArgs = {new String[0]}; /* Default: No arguments */ + + if (cmdParts.length == 2) { + dcmdArgs[0] = cmdParts[1].split(" "); + } + return dcmdArgs; + } + + /** + * Convert from diagnostic command to MBean method name + * + * Examples: + * help --> help + * VM.version --> vmVersion + * VM.command_line --> vmCommandLine + */ + private static String commandToMethodName(String cmd) { + String operation = ""; + boolean up = false; /* First letter is to be lower case */ + + /* + * If a '.' or '_' is encountered it is not copied, + * instead the next character will be converted to upper case + */ + for (char c : cmd.toCharArray()) { + if (('.' == c) || ('_' == c)) { + up = true; + } else if (up) { + operation = operation.concat(Character.toString(c).toUpperCase()); + up = false; + } else { + operation = operation.concat(Character.toString(c).toLowerCase()); + } + } + + return operation; + } + + private static String exceptionTraceAsString(Throwable cause) { + StringWriter sw = new StringWriter(); + cause.printStackTrace(new PrintWriter(sw)); + return sw.toString(); + } + +} diff --git a/test/lib/jdk/test/lib/dcmd/JcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/JcmdExecutor.java new file mode 100644 index 00000000000..6bf940cda6e --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/JcmdExecutor.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import java.util.List; + +/** + * Base class for Diagnostic Command Executors using the jcmd tool + */ +public abstract class JcmdExecutor extends CommandExecutor { + protected String jcmdBinary; + + protected abstract List createCommandLine(String cmd) throws CommandExecutorException; + + protected JcmdExecutor() { + jcmdBinary = JDKToolFinder.getJDKTool("jcmd"); + } + + protected OutputAnalyzer executeImpl(String cmd) throws CommandExecutorException { + List commandLine = createCommandLine(cmd); + + try { + System.out.printf("Executing command '%s'%n", commandLine); + OutputAnalyzer output = ProcessTools.executeProcess(new ProcessBuilder(commandLine)); + System.out.printf("Command returned with exit code %d%n", output.getExitValue()); + + return output; + } catch (Exception e) { + String message = String.format("Caught exception while executing '%s'", commandLine); + throw new CommandExecutorException(message, e); + } + } +} diff --git a/test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java new file mode 100644 index 00000000000..84608c11632 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/MainClassJcmdExecutor.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +import java.util.Arrays; +import java.util.List; + +/** + * Executes Diagnostic Commands on the target VM (specified by main class) using the jcmd tool + */ +public class MainClassJcmdExecutor extends JcmdExecutor { + private final String mainClass; + + /** + * Instantiates a new MainClassJcmdExecutor targeting the current VM + */ + public MainClassJcmdExecutor() { + super(); + mainClass = System.getProperty("sun.java.command").split(" ")[0]; + } + + /** + * Instantiates a new MainClassJcmdExecutor targeting the VM indicated by the given main class + * + * @param target Main class of the target VM + */ + public MainClassJcmdExecutor(String target) { + super(); + mainClass = target; + } + + protected List createCommandLine(String cmd) throws CommandExecutorException { + return Arrays.asList(jcmdBinary, mainClass, cmd); + } + +} diff --git a/test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java b/test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java new file mode 100644 index 00000000000..25b3f532fc6 --- /dev/null +++ b/test/lib/jdk/test/lib/dcmd/PidJcmdExecutor.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.dcmd; + +import jdk.test.lib.process.ProcessTools; + +import java.util.Arrays; +import java.util.List; + +/** + * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool + */ +public class PidJcmdExecutor extends JcmdExecutor { + protected final long pid; + + /** + * Instantiates a new PidJcmdExecutor targeting the current VM + */ + public PidJcmdExecutor() { + super(); + try { + pid = ProcessTools.getProcessId(); + } catch (Exception e) { + throw new CommandExecutorException("Could not determine own pid", e); + } + } + + /** + * Instantiates a new PidJcmdExecutor targeting the VM indicated by the given pid + * + * @param target Pid of the target VM + */ + public PidJcmdExecutor(String target) { + super(); + pid = Long.valueOf(target); + } + + protected List createCommandLine(String cmd) throws CommandExecutorException { + return Arrays.asList(jcmdBinary, Long.toString(pid), cmd); + } + +} diff --git a/test/lib/share/classes/jdk/test/lib/hprof/HprofParser.java b/test/lib/jdk/test/lib/hprof/HprofParser.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/HprofParser.java rename to test/lib/jdk/test/lib/hprof/HprofParser.java index cb39c0d9ac0..88841f9e6d4 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/HprofParser.java +++ b/test/lib/jdk/test/lib/hprof/HprofParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/README b/test/lib/jdk/test/lib/hprof/README similarity index 100% rename from test/lib/share/classes/jdk/test/lib/hprof/README rename to test/lib/jdk/test/lib/hprof/README diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java b/test/lib/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java rename to test/lib/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java index dcaf3624085..4624347ff6b 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java +++ b/test/lib/jdk/test/lib/hprof/model/AbstractJavaHeapObjectVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ArrayTypeCodes.java b/test/lib/jdk/test/lib/hprof/model/ArrayTypeCodes.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ArrayTypeCodes.java rename to test/lib/jdk/test/lib/hprof/model/ArrayTypeCodes.java index d3c9a9eaeb4..c6ac3ac372a 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ArrayTypeCodes.java +++ b/test/lib/jdk/test/lib/hprof/model/ArrayTypeCodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/HackJavaValue.java b/test/lib/jdk/test/lib/hprof/model/HackJavaValue.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/HackJavaValue.java rename to test/lib/jdk/test/lib/hprof/model/HackJavaValue.java index fda40a9c07f..6da7b2df648 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/HackJavaValue.java +++ b/test/lib/jdk/test/lib/hprof/model/HackJavaValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaBoolean.java b/test/lib/jdk/test/lib/hprof/model/JavaBoolean.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaBoolean.java rename to test/lib/jdk/test/lib/hprof/model/JavaBoolean.java index 3c298457856..e96766ddba6 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaBoolean.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaByte.java b/test/lib/jdk/test/lib/hprof/model/JavaByte.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaByte.java rename to test/lib/jdk/test/lib/hprof/model/JavaByte.java index aa32ca532c2..e4a1d330008 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaByte.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaChar.java b/test/lib/jdk/test/lib/hprof/model/JavaChar.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaChar.java rename to test/lib/jdk/test/lib/hprof/model/JavaChar.java index 629af171d9e..7c04f503efd 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaChar.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaClass.java b/test/lib/jdk/test/lib/hprof/model/JavaClass.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaClass.java rename to test/lib/jdk/test/lib/hprof/model/JavaClass.java index c25e8adcf79..c2a9563e0aa 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaClass.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaDouble.java b/test/lib/jdk/test/lib/hprof/model/JavaDouble.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaDouble.java rename to test/lib/jdk/test/lib/hprof/model/JavaDouble.java index 347fd4f9c86..3b643029896 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaDouble.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaField.java b/test/lib/jdk/test/lib/hprof/model/JavaField.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaField.java rename to test/lib/jdk/test/lib/hprof/model/JavaField.java index 87dc48e679b..d343f913abd 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaField.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaFloat.java b/test/lib/jdk/test/lib/hprof/model/JavaFloat.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaFloat.java rename to test/lib/jdk/test/lib/hprof/model/JavaFloat.java index 838b72b2ad5..44692125024 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaFloat.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObject.java b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObject.java rename to test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java index 6ab1242473b..dbe54f0ef28 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java b/test/lib/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java rename to test/lib/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java index d31d382dab8..77607655a8e 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaHeapObjectVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaInt.java b/test/lib/jdk/test/lib/hprof/model/JavaInt.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaInt.java rename to test/lib/jdk/test/lib/hprof/model/JavaInt.java index 4b2e7d2ad8f..9360f858eb8 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaInt.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLazyReadObject.java b/test/lib/jdk/test/lib/hprof/model/JavaLazyReadObject.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaLazyReadObject.java rename to test/lib/jdk/test/lib/hprof/model/JavaLazyReadObject.java index 3baaf3ca1dd..5428a2b5ede 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLazyReadObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaLazyReadObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLong.java b/test/lib/jdk/test/lib/hprof/model/JavaLong.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaLong.java rename to test/lib/jdk/test/lib/hprof/model/JavaLong.java index d86dc50658d..28aca95670b 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaLong.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObject.java b/test/lib/jdk/test/lib/hprof/model/JavaObject.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaObject.java rename to test/lib/jdk/test/lib/hprof/model/JavaObject.java index a419348eff8..74bdb0d6c28 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectArray.java b/test/lib/jdk/test/lib/hprof/model/JavaObjectArray.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectArray.java rename to test/lib/jdk/test/lib/hprof/model/JavaObjectArray.java index 4ed0afeaea6..98ae116cafb 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectArray.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObjectArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectRef.java b/test/lib/jdk/test/lib/hprof/model/JavaObjectRef.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectRef.java rename to test/lib/jdk/test/lib/hprof/model/JavaObjectRef.java index 009c03b0dc7..f0958f7db4c 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaObjectRef.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObjectRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaShort.java b/test/lib/jdk/test/lib/hprof/model/JavaShort.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaShort.java rename to test/lib/jdk/test/lib/hprof/model/JavaShort.java index d3bf75952b3..7c4e46acc02 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaShort.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaStatic.java b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaStatic.java rename to test/lib/jdk/test/lib/hprof/model/JavaStatic.java index b9dc399cf8b..79a5b0d64b7 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaStatic.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaThing.java b/test/lib/jdk/test/lib/hprof/model/JavaThing.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaThing.java rename to test/lib/jdk/test/lib/hprof/model/JavaThing.java index 5b14eb68b94..2a663ab443e 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaThing.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaThing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValue.java b/test/lib/jdk/test/lib/hprof/model/JavaValue.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaValue.java rename to test/lib/jdk/test/lib/hprof/model/JavaValue.java index 30ac6653d28..e7cad68b4d0 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValue.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValueArray.java b/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/JavaValueArray.java rename to test/lib/jdk/test/lib/hprof/model/JavaValueArray.java index 7c0c2c6773f..d65780d527f 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/JavaValueArray.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludes.java b/test/lib/jdk/test/lib/hprof/model/ReachableExcludes.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludes.java rename to test/lib/jdk/test/lib/hprof/model/ReachableExcludes.java index 6133e539b80..b95183251ab 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludes.java +++ b/test/lib/jdk/test/lib/hprof/model/ReachableExcludes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludesImpl.java b/test/lib/jdk/test/lib/hprof/model/ReachableExcludesImpl.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludesImpl.java rename to test/lib/jdk/test/lib/hprof/model/ReachableExcludesImpl.java index 8a15e635523..5038f71ddc0 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableExcludesImpl.java +++ b/test/lib/jdk/test/lib/hprof/model/ReachableExcludesImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableObjects.java b/test/lib/jdk/test/lib/hprof/model/ReachableObjects.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReachableObjects.java rename to test/lib/jdk/test/lib/hprof/model/ReachableObjects.java index da7a4a1e58a..c3fcd7521d4 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReachableObjects.java +++ b/test/lib/jdk/test/lib/hprof/model/ReachableObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/ReferenceChain.java b/test/lib/jdk/test/lib/hprof/model/ReferenceChain.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/model/ReferenceChain.java rename to test/lib/jdk/test/lib/hprof/model/ReferenceChain.java index b21ed0bb95e..3b217519447 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/ReferenceChain.java +++ b/test/lib/jdk/test/lib/hprof/model/ReferenceChain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/Root.java b/test/lib/jdk/test/lib/hprof/model/Root.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/model/Root.java rename to test/lib/jdk/test/lib/hprof/model/Root.java index 54a893b9dcd..ae7c08bfeb1 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/Root.java +++ b/test/lib/jdk/test/lib/hprof/model/Root.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/Snapshot.java b/test/lib/jdk/test/lib/hprof/model/Snapshot.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/model/Snapshot.java rename to test/lib/jdk/test/lib/hprof/model/Snapshot.java index 6150543b36b..fcef29a1b85 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/Snapshot.java +++ b/test/lib/jdk/test/lib/hprof/model/Snapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/StackFrame.java b/test/lib/jdk/test/lib/hprof/model/StackFrame.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/StackFrame.java rename to test/lib/jdk/test/lib/hprof/model/StackFrame.java index f6e2996b005..723cf64986e 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/StackFrame.java +++ b/test/lib/jdk/test/lib/hprof/model/StackFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/model/StackTrace.java b/test/lib/jdk/test/lib/hprof/model/StackTrace.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/model/StackTrace.java rename to test/lib/jdk/test/lib/hprof/model/StackTrace.java index d581257430c..75c92fc9cdf 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/model/StackTrace.java +++ b/test/lib/jdk/test/lib/hprof/model/StackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/FileReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/FileReadBuffer.java rename to test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java index 716b9469868..7beb2e7dd28 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/FileReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/HprofReader.java b/test/lib/jdk/test/lib/hprof/parser/HprofReader.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/HprofReader.java rename to test/lib/jdk/test/lib/hprof/parser/HprofReader.java index 15bd6af7fda..693bec6b9b7 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/HprofReader.java +++ b/test/lib/jdk/test/lib/hprof/parser/HprofReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/MappedReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/MappedReadBuffer.java rename to test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java index b3657e6f0c5..c7247fae68f 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/MappedReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionDataInputStream.java b/test/lib/jdk/test/lib/hprof/parser/PositionDataInputStream.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/PositionDataInputStream.java rename to test/lib/jdk/test/lib/hprof/parser/PositionDataInputStream.java index b27e1dc1927..8435dd12a3a 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionDataInputStream.java +++ b/test/lib/jdk/test/lib/hprof/parser/PositionDataInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionInputStream.java b/test/lib/jdk/test/lib/hprof/parser/PositionInputStream.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/PositionInputStream.java rename to test/lib/jdk/test/lib/hprof/parser/PositionInputStream.java index aecc72629ad..0c0e43de8e5 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/PositionInputStream.java +++ b/test/lib/jdk/test/lib/hprof/parser/PositionInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/ReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/ReadBuffer.java rename to test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java index 99c15e5698f..fe548a74ff8 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/ReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/parser/Reader.java b/test/lib/jdk/test/lib/hprof/parser/Reader.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/parser/Reader.java rename to test/lib/jdk/test/lib/hprof/parser/Reader.java index 19ddad5997c..5263035df72 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/parser/Reader.java +++ b/test/lib/jdk/test/lib/hprof/parser/Reader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/ArraySorter.java b/test/lib/jdk/test/lib/hprof/util/ArraySorter.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/util/ArraySorter.java rename to test/lib/jdk/test/lib/hprof/util/ArraySorter.java index 4101529dabb..04dbad7ff0b 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/ArraySorter.java +++ b/test/lib/jdk/test/lib/hprof/util/ArraySorter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/Comparer.java b/test/lib/jdk/test/lib/hprof/util/Comparer.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/hprof/util/Comparer.java rename to test/lib/jdk/test/lib/hprof/util/Comparer.java index b6ae50364ee..182f37edf61 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/Comparer.java +++ b/test/lib/jdk/test/lib/hprof/util/Comparer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/CompositeEnumeration.java b/test/lib/jdk/test/lib/hprof/util/CompositeEnumeration.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/hprof/util/CompositeEnumeration.java rename to test/lib/jdk/test/lib/hprof/util/CompositeEnumeration.java index 2c49fad85c1..ddebd0fb3ed 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/CompositeEnumeration.java +++ b/test/lib/jdk/test/lib/hprof/util/CompositeEnumeration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/Misc.java b/test/lib/jdk/test/lib/hprof/util/Misc.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/util/Misc.java rename to test/lib/jdk/test/lib/hprof/util/Misc.java index 98592f634e2..e654d71d4ce 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/Misc.java +++ b/test/lib/jdk/test/lib/hprof/util/Misc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/hprof/util/VectorSorter.java b/test/lib/jdk/test/lib/hprof/util/VectorSorter.java similarity index 98% rename from test/lib/share/classes/jdk/test/lib/hprof/util/VectorSorter.java rename to test/lib/jdk/test/lib/hprof/util/VectorSorter.java index 112d90959b6..fb2ac13e175 100644 --- a/test/lib/share/classes/jdk/test/lib/hprof/util/VectorSorter.java +++ b/test/lib/jdk/test/lib/hprof/util/VectorSorter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 diff --git a/test/lib/jdk/test/lib/process/ExitCode.java b/test/lib/jdk/test/lib/process/ExitCode.java new file mode 100644 index 00000000000..bb66da17911 --- /dev/null +++ b/test/lib/jdk/test/lib/process/ExitCode.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.process; + +/** + * Exit code values that could be returned by the JVM. + */ +public enum ExitCode { + OK(0), + FAIL(1), + CRASH(134); + + public final int value; + + ExitCode(int value) { + this.value = value; + } +} + diff --git a/test/lib/share/classes/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java similarity index 97% rename from test/lib/share/classes/jdk/test/lib/process/OutputAnalyzer.java rename to test/lib/jdk/test/lib/process/OutputAnalyzer.java index fc3a4de2905..97d9ae0db50 100644 --- a/test/lib/share/classes/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -374,14 +374,14 @@ public final class OutputAnalyzer { * - exit code * Note: the command line is printed by the ProcessTools */ - private void reportDiagnosticSummary() { - String msg = - " stdout: [" + stdout + "];\n" + - " stderr: [" + stderr + "]\n" + - " exitValue = " + getExitValue() + "\n"; + public void reportDiagnosticSummary() { + String msg = + " stdout: [" + stdout + "];\n" + + " stderr: [" + stderr + "]\n" + + " exitValue = " + getExitValue() + "\n"; - System.err.println(msg); - } + System.err.println(msg); + } /** diff --git a/test/lib/share/classes/jdk/test/lib/process/OutputBuffer.java b/test/lib/jdk/test/lib/process/OutputBuffer.java similarity index 96% rename from test/lib/share/classes/jdk/test/lib/process/OutputBuffer.java rename to test/lib/jdk/test/lib/process/OutputBuffer.java index 23976d8272f..a41e8436ba0 100644 --- a/test/lib/share/classes/jdk/test/lib/process/OutputBuffer.java +++ b/test/lib/jdk/test/lib/process/OutputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/share/classes/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java similarity index 93% rename from test/lib/share/classes/jdk/test/lib/process/ProcessTools.java rename to test/lib/jdk/test/lib/process/ProcessTools.java index 3189a0fe277..3f4bbb7fa79 100644 --- a/test/lib/share/classes/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -28,10 +28,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.CountDownLatch; +import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -301,6 +304,16 @@ public final class ProcessTools { public static long getProcessId() throws Exception { return ProcessHandle.current().getPid(); } + /** + * Gets the array of strings containing input arguments passed to the VM + * + * @return arguments + */ + public static String[] getVmInputArgs() { + RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); + List args = runtime.getInputArguments(); + return args.toArray(new String[args.size()]); + } /** * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris) @@ -342,16 +355,10 @@ public final class ProcessTools { args.add(javapath); Collections.addAll(args, getPlatformSpecificVMArgs()); + args.add("-cp"); + args.add(System.getProperty("java.class.path")); + if (addTestVmAndJavaOptions) { - // -cp is needed to make sure the same classpath is used whether the test is - // run in AgentVM mode or OtherVM mode. It was added to the hotspot version - // of this API as part of 8077608. However, for the jdk version it is only - // added when addTestVmAndJavaOptions is true in order to minimize - // disruption to existing JDK tests, which have yet to be tested with -cp - // being added. At some point -cp should always be added to be consistent - // with what the hotspot version does. - args.add("-cp"); - args.add(System.getProperty("java.class.path")); Collections.addAll(args, Utils.getTestJavaOpts()); } @@ -377,6 +384,26 @@ public final class ProcessTools { } } + /** + * Executes a test jvm process, waits for it to finish and returns the process output. + * The default jvm options from the test's run command, jtreg, test.vm.opts and test.java.opts, are added. + * The java from the test.jdk is used to execute the command. + * + * The command line will be like: + * {test.jdk}/bin/java {test.fromRun.opts} {test.vm.opts} {test.java.opts} cmds + * + * @param cmds User specifed arguments. + * @return The output from the process. + */ + public static OutputAnalyzer executeTestJvmAllArgs(String... cmds) throws Throwable { + List argsList = new ArrayList<>(); + String[] testArgs = getVmInputArgs(); + Collections.addAll(argsList, testArgs); + Collections.addAll(argsList, Utils.addTestJavaOpts(cmds)); + ProcessBuilder pb = createJavaProcessBuilder(argsList.toArray(new String[argsList.size()])); + return executeProcess(pb); + } + /** * Executes a test jvm process, waits for it to finish and returns the process output. * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. diff --git a/test/lib/share/classes/jdk/test/lib/process/StreamPumper.java b/test/lib/jdk/test/lib/process/StreamPumper.java similarity index 99% rename from test/lib/share/classes/jdk/test/lib/process/StreamPumper.java rename to test/lib/jdk/test/lib/process/StreamPumper.java index b1780c4ef08..8dd7f0cf0ec 100644 --- a/test/lib/share/classes/jdk/test/lib/process/StreamPumper.java +++ b/test/lib/jdk/test/lib/process/StreamPumper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 diff --git a/test/lib/jdk/test/lib/util/Pair.java b/test/lib/jdk/test/lib/util/Pair.java new file mode 100644 index 00000000000..ca29586b045 --- /dev/null +++ b/test/lib/jdk/test/lib/util/Pair.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.util; + +import java.util.Objects; + +/** + * Pair - a two element tuple + * + * @param first type + * @param second type + */ +public class Pair { + public final F first; + public final S second; + + public Pair(F first, S second) { + this.first = first; + this.second = second; + } + + @Override + public String toString() { + return "(" + first + ":" + second + ")"; + } + + @Override + public boolean equals(Object other) { + if (other instanceof Pair) { + Pair otherPair = (Pair) other; + return Objects.equals(first, otherPair.first) && + Objects.equals(second, otherPair.second); + } + return false; + } + + @Override + public int hashCode() { + if (first == null) { + return (second == null) ? 0 : second.hashCode(); + } else if (second == null) { + return first.hashCode(); + } else { + return first.hashCode() * 17 + second.hashCode(); + } + } +} diff --git a/test/lib/jdk/test/lib/util/Triple.java b/test/lib/jdk/test/lib/util/Triple.java new file mode 100644 index 00000000000..fbc82532286 --- /dev/null +++ b/test/lib/jdk/test/lib/util/Triple.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015, 2016, 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 jdk.test.lib.util; + +import java.util.Objects; + +/** + * Triple - a three element tuple + * + * @param first element type + * @param second element type + * @param third element type + */ +public class Triple { + private final Pair> container; + + /** + * Constructor + * + * @param first first element of the triple + * @param second second element of the triple + * @param third third element of the triple + */ + public Triple(F first, S second, T third) { + container = new Pair<>(first, new Pair<>(second, third)); + } + + /** + * Gets first element of the triple + */ + public F getFirst() { + return container.first; + } + + /** + * Gets second element of the triple + */ + public S getSecond() { + return container.second.first; + } + + /** + * Gets third element of the triple + */ + public T getThird() { + return container.second.second; + } + + @Override + public int hashCode() { + return container.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Triple) { + Triple objTriple = (Triple) obj; + return Objects.equals(container.first, objTriple.container.first) + && Objects.equals(container.second, + objTriple.container.second); + } + return false; + } + + @Override + public String toString() { + return "(" + getFirst() + " : " + getSecond() + " : " + getThird() + ")"; + } +} diff --git a/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java b/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java new file mode 100644 index 00000000000..dbee901f8c0 --- /dev/null +++ b/test/lib/jdk/test/lib/wrappers/InfiniteLoop.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.wrappers; + +import java.util.Objects; + +/** + * Class which runs another Runnable in infinite loop with certain pauses + * between cycles. + */ +public class InfiniteLoop implements Runnable { + private final Runnable target; + private final long mills; + + + /** + * @param target a target to run in a loop + * @param mills the length of pause time in milliseconds + * @throws NullPointerException if target is null + * @throws IllegalArgumentException if the value of millis is negative + */ + public InfiniteLoop(Runnable target, long mills) { + Objects.requireNonNull(target); + if (mills < 0) { + throw new IllegalArgumentException("mills < 0"); + } + this.target = target; + this.mills = mills; + } + + @Override + public void run() { + try { + while (true) { + target.run(); + if (mills > 0) { + Thread.sleep(mills); + } + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new Error(e); + } + } +} diff --git a/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java b/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java new file mode 100644 index 00000000000..73d53b43b12 --- /dev/null +++ b/test/lib/jdk/test/lib/wrappers/TimeLimitedRunner.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2014, 2016, 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 jdk.test.lib.wrappers; + +import java.util.Objects; +import java.util.concurrent.Callable; + +/** + * Auxiliary class to run target w/ given timeout. + */ +public class TimeLimitedRunner implements Callable { + private final long stoptime; + private final long timeout; + private final double factor; + private final Callable target; + + /** + * @param timeout a timeout. zero means no time limitation + * @param factor a multiplier used to estimate next iteration time + * @param target a target to run + * @throws NullPointerException if target is null + * @throws IllegalArgumentException if timeout is negative or + factor isn't positive + */ + public TimeLimitedRunner(long timeout, double factor, + Callable target) { + Objects.requireNonNull(target, "target must not be null"); + if (timeout < 0) { + throw new IllegalArgumentException("timeout[" + timeout + "] < 0"); + } + if (factor <= 0d) { + throw new IllegalArgumentException("factor[" + factor + "] <= 0"); + } + this.stoptime = System.currentTimeMillis() + timeout; + this.timeout = timeout; + this.factor = factor; + this.target = target; + } + + /** + * Runs @{linkplan target} while it returns true and timeout isn't exceeded + */ + @Override + public Void call() throws Exception { + long maxDuration = 0L; + long iterStart = System.currentTimeMillis(); + if (timeout != 0 && iterStart > stoptime) { + return null; + } + while (target.call()) { + if (timeout != 0) { + long iterDuration = System.currentTimeMillis() - iterStart; + maxDuration = Math.max(maxDuration, iterDuration); + iterStart = System.currentTimeMillis(); + if (iterStart + (maxDuration * factor) > stoptime) { + System.out.println("Not enough time to continue execution. " + + "Interrupted."); + break; + } + } + } + return null; + } + +}