diff --git a/.hgtags b/.hgtags index 28f9ad5279c..14aa9215059 100644 --- a/.hgtags +++ b/.hgtags @@ -376,3 +376,6 @@ e613affb88d178dc7c589f1679db113d589bddb4 jdk-9+130 4d2a15091124488080d65848b704e25599b2aaeb jdk-9+131 2e83d21d78cd9c1d52e6cd2599e9c8aa36ea1f52 jdk-9+132 e17429a7e843c4a4ed3651458d0f950970edcbcc jdk-9+133 +a71210c0d9800eb6925b61ecd6198abd554f90ee jdk-9+134 +e384420383a5b79fa0012ebcb25d8f83cff7f777 jdk-9+135 +1b4b5d01aa11edf24b6fadbe3d2f3e411e3b02cd jdk-9+136 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 9b00c6661fd..e540680549f 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -376,3 +376,6 @@ d94d54a3192fea79234c3ac55cd0b4052d45e954 jdk-9+130 8728756c2f70a79a90188f4019cfd6b9a275765c jdk-9+131 a24702d4d5ab0015a5c553ed57f66fce7d85155e jdk-9+132 be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133 +065724348690eda41fc69112278d8da6dcde548c jdk-9+134 +82b94cb5f342319d2cda77f9fa59703ad7fde576 jdk-9+135 +3ec350f5f32af249b59620d7e37b54bdcd77b233 jdk-9+136 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..e8dba874e9c 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -376,3 +376,6 @@ c3e83ccab3bb1733ae903d681879a33f85ed465c jdk-9+129 f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131 1ab4b9399c4cba584f66c1c088188f2f565fbf9c jdk-9+132 2021bfedf1c478a4808a7711a6090682a12f4c0e jdk-9+133 +1a497f5ca0cfd88115cc7daa8af8a62b8741caf2 jdk-9+134 +094d0db606db976045f594dba47d4593b715cc81 jdk-9+135 +aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136 diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 8d8a2e6cf99..d842722fa52 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -536,3 +536,6 @@ e96b34b76d863ed1fa04e0eeb3f297ac17b490fd jdk-9+129 943bf73b49c33c2d7cbd796f6a4ae3c7a00ae932 jdk-9+131 713951c08aa26813375175c2ab6cc99ff2a56903 jdk-9+132 a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133 +b8b694c6b4d2ab0939aed7adaf0eec1ac321a085 jdk-9+134 +3b1c4562953db47e36b237a500f368d5c9746d47 jdk-9+135 +a20da289f646ee44440695b81abc0548330e4ca7 jdk-9+136 diff --git a/hotspot/make/symbols/symbols-unix b/hotspot/make/symbols/symbols-unix index 406d6f99db3..04dd4aeff53 100644 --- a/hotspot/make/symbols/symbols-unix +++ b/hotspot/make/symbols/symbols-unix @@ -67,6 +67,7 @@ JVM_FindSignal JVM_FreeMemory JVM_GC JVM_GetAllThreads +JVM_GetAndClearReferencePendingList JVM_GetArrayElement JVM_GetArrayLength JVM_GetCallerClass @@ -130,6 +131,7 @@ JVM_GetSystemPackages JVM_GetTemporaryDirectory JVM_GetVmArguments JVM_Halt +JVM_HasReferencePendingList JVM_HoldsLock JVM_IHashCode JVM_InitProperties @@ -179,6 +181,7 @@ JVM_SuspendThread JVM_ToStackTraceElement JVM_TotalMemory JVM_UnloadLibrary +JVM_WaitForReferencePendingList JVM_Yield # Module related API's 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/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp index 93aea2a18d7..925ae225476 100644 --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp @@ -65,10 +65,10 @@ define_pd_global(intx, InlineSmallCode, 1000); #ifdef AMD64 // Very large C++ stack frames using solaris-amd64 optimized builds // due to lack of optimization caused by C++ compiler bugs -#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(6) DEBUG_ONLY(+2)) +#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(7) DEBUG_ONLY(+2)) // For those clients that do not use write socket, we allow // the min range value to be below that of the default -#define MIN_STACK_SHADOW_PAGES (NOT_WIN64(10) WIN64_ONLY(6) DEBUG_ONLY(+2)) +#define MIN_STACK_SHADOW_PAGES (NOT_WIN64(10) WIN64_ONLY(7) DEBUG_ONLY(+2)) #else #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5)) #define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES 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 37bba8d3cf9..dd978fd1020 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/oops/InstanceKlass.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index 79ae9497496..99dbadf0e2b 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -68,6 +68,7 @@ public class InstanceKlass extends Klass { Type type = db.lookupType("InstanceKlass"); arrayKlasses = new MetadataField(type.getAddressField("_array_klasses"), 0); methods = type.getAddressField("_methods"); + defaultMethods = type.getAddressField("_default_methods"); methodOrdering = type.getAddressField("_method_ordering"); localInterfaces = type.getAddressField("_local_interfaces"); transitiveInterfaces = type.getAddressField("_transitive_interfaces"); @@ -128,6 +129,7 @@ public class InstanceKlass extends Klass { private static MetadataField arrayKlasses; private static AddressField methods; + private static AddressField defaultMethods; private static AddressField methodOrdering; private static AddressField localInterfaces; private static AddressField transitiveInterfaces; @@ -335,6 +337,20 @@ public class InstanceKlass extends Klass { // Accessors for declared fields public Klass getArrayKlasses() { return (Klass) arrayKlasses.getValue(this); } public MethodArray getMethods() { return new MethodArray(methods.getValue(getAddress())); } + + public MethodArray getDefaultMethods() { + if (defaultMethods != null) { + Address addr = defaultMethods.getValue(getAddress()); + if ((addr != null) && (addr.getAddressAt(0) != null)) { + return new MethodArray(addr); + } else { + return null; + } + } else { + return null; + } + } + public KlassArray getLocalInterfaces() { return new KlassArray(localInterfaces.getValue(getAddress())); } public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); } public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java index 1549538a10e..f01bb5e6ce5 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -36,6 +36,7 @@ import sun.jvm.hotspot.utilities.*; public class MethodData extends Metadata implements MethodDataInterface { static int TypeProfileWidth = 2; static int BciProfileWidth = 2; + static int MethodProfileWidth = 0; static int CompileThreshold; static int Reason_many; // indicates presence of several reasons @@ -142,6 +143,8 @@ public class MethodData extends Metadata implements MethodDataInterface parametersTypeData() { int di = (int)parametersTypeDataDi.getValue(getAddress()); - if (di == -1) { + if (di == -1 || di == -2) { return null; } DataLayout dataLayout = new DataLayout(this, di + (int)data.getOffset()); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java index 7ac053fe0c5..ed2a120ca61 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java @@ -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 @@ -38,9 +38,21 @@ import sun.jvm.hotspot.utilities.*; // that the check is reached, and a series of (Klass, count) pairs // which are used to store a type profile for the receiver of the check. public class ReceiverTypeData extends CounterData { - static final int receiver0Offset = counterCellCount; - static final int count0Offset = receiver0Offset + 1; - static final int receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset; + static final int INCLUDE_JVMCI; + static final int nonProfiledCountOffset = counterCellCount; + static final int receiver0Offset; + static final int count0Offset; + static final int receiverTypeRowCellCount; + static { + INCLUDE_JVMCI = VM.getVM().getTypeDataBase().lookupIntConstant("INCLUDE_JVMCI"); + if (INCLUDE_JVMCI == 1) { + receiver0Offset = nonProfiledCountOffset + 1; + } else { + receiver0Offset = counterCellCount; + } + count0Offset = receiver0Offset + 1; + receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset; + } final MethodDataInterface methodData; public ReceiverTypeData(MethodDataInterface methodData, DataLayout layout) { @@ -53,7 +65,11 @@ public class ReceiverTypeData extends CounterData { boolean isReceivertypedata() { return true; } static int staticCellCount() { - return counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount; + int cellCount = counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount; + if (INCLUDE_JVMCI == 1) { + cellCount += 1; + } + return cellCount; } public int cellCount() { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java index eec5000a6a4..fe7183822a1 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java @@ -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 @@ -44,7 +44,11 @@ public class VirtualCallData extends ReceiverTypeData { static int staticCellCount() { // At this point we could add more profile state, e.g., for arguments. // But for now it's the same size as the base record type. - return ReceiverTypeData.staticCellCount(); + int cellCount = ReceiverTypeData.staticCellCount(); + if (INCLUDE_JVMCI == 1) { + cellCount += MethodData.MethodProfileWidth * receiverTypeRowCellCount; + } + return cellCount; } public int cellCount() { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index cfcab6b8413..1e471412d58 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -129,8 +129,6 @@ public class Threads { virtualConstructor.addMapping("CompilerThread", CompilerThread.class); virtualConstructor.addMapping("CodeCacheSweeperThread", CodeCacheSweeperThread.class); } - // for now, use JavaThread itself. fix it later with appropriate class if needed - virtualConstructor.addMapping("ReferencePendingListLockerThread", JavaThread.class); virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class); virtualConstructor.addMapping("ServiceThread", ServiceThread.class); } @@ -172,7 +170,7 @@ public class Threads { return thread; } catch (Exception e) { throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + - " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread, ReferencePendingListLockerThread, or CodeCacheSweeperThread)", e); + " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread or CodeCacheSweeperThread)", e); } } 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/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index 7a7f4501493..2bd5c556d0d 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -837,7 +837,6 @@ vmType2Class["InterpreterCodelet"] = sapkg.interpreter.InterpreterCodelet; vmType2Class["JavaThread"] = sapkg.runtime.JavaThread; vmType2Class["CompilerThread"] = sapkg.runtime.CompilerThread; vmType2Class["CodeCacheSweeperThread"] = sapkg.runtime.CodeCacheSweeperThread; -vmType2Class["ReferencePendingListLockerThread"] = sapkg.runtime.JavaThread; vmType2Class["DebuggerThread"] = sapkg.runtime.DebuggerThread; // gc 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 9248eb72e35..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 @@ -2875,7 +2848,7 @@ void os::Linux::rebuild_cpu_to_node_map() { // in the library. const size_t BitsPerCLong = sizeof(long) * CHAR_BIT; - size_t cpu_num = os::active_processor_count(); + size_t cpu_num = processor_count(); size_t cpu_map_size = NCPUS / BitsPerCLong; size_t cpu_map_valid_size = MIN2((cpu_num + BitsPerCLong - 1) / BitsPerCLong, cpu_map_size); @@ -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 24b39189e76..3b075455d92 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -2504,13 +2504,15 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // It write enables the page immediately after protecting it // so just return. if (exception_code == EXCEPTION_ACCESS_VIOLATION) { - JavaThread* thread = (JavaThread*) t; - PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; - address addr = (address) exceptionRecord->ExceptionInformation[1]; - if (os::is_memory_serialize_page(thread, addr)) { - // Block current thread until the memory serialize page permission restored. - os::block_on_serialize_page_trap(); - return EXCEPTION_CONTINUE_EXECUTION; + if (t != NULL && t->is_Java_thread()) { + JavaThread* thread = (JavaThread*) t; + PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; + address addr = (address) exceptionRecord->ExceptionInformation[1]; + if (os::is_memory_serialize_page(thread, addr)) { + // Block current thread until the memory serialize page permission restored. + os::block_on_serialize_page_trap(); + return EXCEPTION_CONTINUE_EXECUTION; + } } } @@ -2564,7 +2566,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { } #endif if (thread->stack_guards_enabled()) { - if (_thread_in_Java) { + if (in_java) { frame fr; PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; @@ -2576,6 +2578,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // Yellow zone violation. The o/s has unprotected the first yellow // zone page for us. Note: must call disable_stack_yellow_zone to // update the enabled status, even if the zone contains only one page. + assert(thread->thread_state() != _thread_in_vm, "Undersized StackShadowPages"); thread->disable_stack_yellow_reserved_zone(); // If not in java code, return and hope for the best. return in_java @@ -3793,6 +3796,11 @@ void os::win32::initialize_system_info() { GlobalMemoryStatusEx(&ms); _physical_memory = ms.ullTotalPhys; + if (FLAG_IS_DEFAULT(MaxRAM)) { + // Adjust MaxRAM according to the maximum virtual address space available. + FLAG_SET_DEFAULT(MaxRAM, MIN2(MaxRAM, (uint64_t) ms.ullTotalVirtual)); + } + OSVERSIONINFOEX oi; oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); GetVersionEx((OSVERSIONINFO*)&oi); @@ -4207,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..1e440ca8579 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 @@ -192,8 +192,10 @@ frame os::current_frame() { intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); // hack. frame topframe(csp, (address)0x8); - // return sender of current topframe which hopefully has pc != NULL. - return os::get_sender_for_C_frame(&topframe); + // Return sender of sender of current topframe which hopefully + // both have pc != NULL. + frame tmp = os::get_sender_for_C_frame(&topframe); + return os::get_sender_for_C_frame(&tmp); } // Utility functions @@ -533,23 +535,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..c0aeb994f41 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 @@ -205,8 +205,10 @@ frame os::current_frame() { intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); // hack. frame topframe(csp, (address)0x8); - // return sender of current topframe which hopefully has pc != NULL. - return os::get_sender_for_C_frame(&topframe); + // Return sender of sender of current topframe which hopefully + // both have pc != NULL. + frame tmp = os::get_sender_for_C_frame(&topframe); + return os::get_sender_for_C_frame(&tmp); } // Utility functions @@ -533,15 +535,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 a4a4e3da963..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() { @@ -444,7 +448,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { - if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { + if (sig == SIGBUS && thread->doing_unsafe_access()) { stub = SharedRuntime::handle_unsafe_access(thread, npc); } } 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/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 0efb4d9818d..b25255bd7db 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -223,6 +223,9 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { case vmIntrinsics::_putCharStringU: #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: +#if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT) + case vmIntrinsics::_getClassId: +#endif #endif break; default: diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index d616629ff2b..65c13d5912f 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -3092,6 +3092,37 @@ void LIRGenerator::do_IfOp(IfOp* x) { __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type())); } +#ifdef TRACE_HAVE_INTRINSICS +void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) { + CodeEmitInfo* info = state_for(x); + CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check + + assert(info != NULL, "must have info"); + LIRItem arg(x->argument_at(0), this); + + arg.load_item(); + LIR_Opr klass = new_register(T_METADATA); + __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info); + LIR_Opr id = new_register(T_LONG); + ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET; + LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG); + + __ move(trace_id_addr, id); + __ logical_or(id, LIR_OprFact::longConst(0x01l), id); + __ store(id, trace_id_addr); + +#ifdef TRACE_ID_META_BITS + __ logical_and(id, LIR_OprFact::longConst(~TRACE_ID_META_BITS), id); +#endif +#ifdef TRACE_ID_CLASS_SHIFT + __ unsigned_shift_right(id, TRACE_ID_CLASS_SHIFT, id); +#endif + + __ move(id, rlock_result(x)); +} +#endif + + void LIRGenerator::do_RuntimeCall(address routine, Intrinsic* x) { assert(x->number_of_arguments() == 0, "wrong type"); // Enforce computation of _reserved_argument_area_size which is required on some platforms. @@ -3117,6 +3148,9 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { } #ifdef TRACE_HAVE_INTRINSICS + case vmIntrinsics::_getClassId: + do_ClassIDIntrinsic(x); + break; case vmIntrinsics::_counterTime: do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), x); break; diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index 6b69a4fad88..04dae206422 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -439,6 +439,10 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { SwitchRangeArray* create_lookup_ranges(LookupSwitch* x); void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux); +#ifdef TRACE_HAVE_INTRINSICS + void do_ClassIDIntrinsic(Intrinsic* x); +#endif + void do_RuntimeCall(address routine, Intrinsic* x); ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k, diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp index ec788919c32..50a1dd37c3b 100644 --- a/hotspot/src/share/vm/ci/ciReplay.cpp +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -29,7 +29,6 @@ #include "ci/ciKlass.hpp" #include "ci/ciUtilities.hpp" #include "compiler/compileBroker.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "memory/allocation.inline.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" @@ -577,9 +576,7 @@ class CompileReplay : public StackObj { Method* method = parse_method(CHECK); if (had_error()) return; /* just copied from Method, to build interpret data*/ - if (ReferencePendingListLocker::is_locked_by_self()) { - return; - } + // To be properly initialized, some profiling in the MDO needs the // method to be rewritten (number of arguments at a call for // instance) diff --git a/hotspot/src/share/vm/classfile/altHashing.cpp b/hotspot/src/share/vm/classfile/altHashing.cpp index ee6b810d1e6..df3f9446aef 100644 --- a/hotspot/src/share/vm/classfile/altHashing.cpp +++ b/hotspot/src/share/vm/classfile/altHashing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, 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 @@ -205,103 +205,3 @@ juint AltHashing::murmur3_32(juint seed, const int* data, int len) { juint AltHashing::murmur3_32(const int* data, int len) { return murmur3_32(0, data, len); } - -#ifndef PRODUCT -// Overloaded versions for internal test. -juint AltHashing::murmur3_32(const jbyte* data, int len) { - return murmur3_32(0, data, len); -} - -juint AltHashing::murmur3_32(const jchar* data, int len) { - return murmur3_32(0, data, len); -} - -// Internal test for alternate hashing. Translated from JDK version -// test/sun/misc/Hashing.java -static const jbyte ONE_BYTE[] = { (jbyte) 0x80}; -static const jbyte TWO_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81}; -static const jchar ONE_CHAR[] = { (jchar) 0x8180}; -static const jbyte THREE_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82}; -static const jbyte FOUR_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83}; -static const jchar TWO_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382}; -static const jint ONE_INT[] = { (jint)0x83828180}; -static const jbyte SIX_BYTE[] = { (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85}; -static const jchar THREE_CHAR[] = { (jchar) 0x8180, (jchar) 0x8382, (jchar) 0x8584}; -static const jbyte EIGHT_BYTE[] = { - (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, - (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85, - (jbyte) 0x86, (jbyte) 0x87}; -static const jchar FOUR_CHAR[] = { - (jchar) 0x8180, (jchar) 0x8382, - (jchar) 0x8584, (jchar) 0x8786}; - -static const jint TWO_INT[] = { (jint)0x83828180, (jint)0x87868584}; - -static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; - -void AltHashing::testMurmur3_32_ByteArray() { - // printf("testMurmur3_32_ByteArray\n"); - - jbyte vector[256]; - jbyte hashes[4 * 256]; - - for (int i = 0; i < 256; i++) { - vector[i] = (jbyte) i; - } - - // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} - for (int i = 0; i < 256; i++) { - juint hash = murmur3_32(256 - i, vector, i); - hashes[i * 4] = (jbyte) hash; - hashes[i * 4 + 1] = (jbyte)(hash >> 8); - hashes[i * 4 + 2] = (jbyte)(hash >> 16); - hashes[i * 4 + 3] = (jbyte)(hash >> 24); - } - - // hash to get const result. - juint final_hash = murmur3_32(hashes, 4*256); - - assert (MURMUR3_32_X86_CHECK_VALUE == final_hash, - "Calculated hash result not as expected. Expected %08X got %08X\n", - MURMUR3_32_X86_CHECK_VALUE, - final_hash); -} - -void AltHashing::testEquivalentHashes() { - juint jbytes, jchars, ints; - - // printf("testEquivalentHashes\n"); - - jbytes = murmur3_32(TWO_BYTE, 2); - jchars = murmur3_32(ONE_CHAR, 1); - assert (jbytes == jchars, - "Hashes did not match. b:%08x != c:%08x\n", jbytes, jchars); - - jbytes = murmur3_32(FOUR_BYTE, 4); - jchars = murmur3_32(TWO_CHAR, 2); - ints = murmur3_32(ONE_INT, 1); - assert ((jbytes == jchars) && (jbytes == ints), - "Hashes did not match. b:%08x != c:%08x != i:%08x\n", jbytes, jchars, ints); - - jbytes = murmur3_32(SIX_BYTE, 6); - jchars = murmur3_32(THREE_CHAR, 3); - assert (jbytes == jchars, - "Hashes did not match. b:%08x != c:%08x\n", jbytes, jchars); - - jbytes = murmur3_32(EIGHT_BYTE, 8); - jchars = murmur3_32(FOUR_CHAR, 4); - ints = murmur3_32(TWO_INT, 2); - assert ((jbytes == jchars) && (jbytes == ints), - "Hashes did not match. b:%08x != c:%08x != i:%08x\n", jbytes, jchars, ints); -} - -// Returns true if the alternate hashcode is correct -void AltHashing::test_alt_hash() { - testMurmur3_32_ByteArray(); - testEquivalentHashes(); -} - -void AltHashing_test() { - AltHashing::test_alt_hash(); -} -#endif // PRODUCT diff --git a/hotspot/src/share/vm/classfile/altHashing.hpp b/hotspot/src/share/vm/classfile/altHashing.hpp index 2e04fd33a2d..43af02f39ce 100644 --- a/hotspot/src/share/vm/classfile/altHashing.hpp +++ b/hotspot/src/share/vm/classfile/altHashing.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, 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 @@ -37,26 +37,18 @@ */ class AltHashing : AllStatic { + friend class AltHashingTest; // utility function copied from java/lang/Integer static juint Integer_rotateLeft(juint i, int distance) { - return (i << distance) | (i >> (32-distance)); + return (i << distance) | (i >> (32 - distance)); } static juint murmur3_32(const int* data, int len); static juint murmur3_32(juint seed, const int* data, int len); -#ifndef PRODUCT - // Hashing functions used for internal testing - static juint murmur3_32(const jbyte* data, int len); - static juint murmur3_32(const jchar* data, int len); - static void testMurmur3_32_ByteArray(); - static void testEquivalentHashes(); -#endif // PRODUCT - public: static juint compute_seed(); static juint murmur3_32(juint seed, const jbyte* data, int len); static juint murmur3_32(juint seed, const jchar* data, int len); - NOT_PRODUCT(static void test_alt_hash();) }; #endif // SHARE_VM_CLASSFILE_ALTHASHING_HPP diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 13c8ce71e9e..5f0b1ca442a 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -95,7 +95,6 @@ #define JAVA_6_VERSION 50 // Used for backward compatibility reasons: -// - to check NameAndType_info signatures more aggressively // - to disallow argument and require ACC_STATIC for methods #define JAVA_7_VERSION 51 @@ -564,7 +563,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, break; } case JVM_CONSTANT_NameAndType: { - if (_need_verify && _major_version >= JAVA_7_VERSION) { + if (_need_verify) { const int sig_index = cp->signature_ref_index_at(index); const int name_index = cp->name_ref_index_at(index); const Symbol* const name = cp->symbol_at(name_index); @@ -572,9 +571,17 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, guarantee_property(sig->utf8_length() != 0, "Illegal zero length constant pool entry at %d in class %s", sig_index, CHECK); + guarantee_property(name->utf8_length() != 0, + "Illegal zero length constant pool entry at %d in class %s", + name_index, CHECK); + if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) { + // Format check method name and signature + verify_legal_method_name(name, CHECK); verify_legal_method_signature(name, sig, CHECK); } else { + // Format check field name and signature + verify_legal_field_name(name, CHECK); verify_legal_field_signature(name, sig, CHECK); } } @@ -595,42 +602,32 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, const Symbol* const name = cp->symbol_at(name_ref_index); const Symbol* const signature = cp->symbol_at(signature_ref_index); if (tag == JVM_CONSTANT_Fieldref) { - verify_legal_field_name(name, CHECK); - if (_need_verify && _major_version >= JAVA_7_VERSION) { - // Signature is verified above, when iterating NameAndType_info. - // Need only to be sure it's non-zero length and the right type. + if (_need_verify) { + // Field name and signature are verified above, when iterating NameAndType_info. + // Need only to be sure signature is non-zero length and the right type. if (signature->utf8_length() == 0 || signature->byte_at(0) == JVM_SIGNATURE_FUNC) { - throwIllegalSignature( - "Field", name, signature, CHECK); + throwIllegalSignature("Field", name, signature, CHECK); } - } else { - verify_legal_field_signature(name, signature, CHECK); } } else { - verify_legal_method_name(name, CHECK); - if (_need_verify && _major_version >= JAVA_7_VERSION) { - // Signature is verified above, when iterating NameAndType_info. - // Need only to be sure it's non-zero length and the right type. + if (_need_verify) { + // Method name and signature are verified above, when iterating NameAndType_info. + // Need only to be sure signature is non-zero length and the right type. if (signature->utf8_length() == 0 || signature->byte_at(0) != JVM_SIGNATURE_FUNC) { - throwIllegalSignature( - "Method", name, signature, CHECK); + throwIllegalSignature("Method", name, signature, CHECK); } - } else { - verify_legal_method_signature(name, signature, CHECK); } - if (tag == JVM_CONSTANT_Methodref) { - // 4509014: If a class method name begins with '<', it must be "". - assert(name != NULL, "method name in constant pool is null"); - const unsigned int name_len = name->utf8_length(); - if (name_len != 0 && name->byte_at(0) == '<') { - if (name != vmSymbols::object_initializer_name()) { - classfile_parse_error( - "Bad method name at constant pool index %u in class file %s", - name_ref_index, CHECK); - } - } + // 4509014: If a class method name begins with '<', it must be "" + const unsigned int name_len = name->utf8_length(); + if (tag == JVM_CONSTANT_Methodref && + name_len != 0 && + name->byte_at(0) == '<' && + name != vmSymbols::object_initializer_name()) { + classfile_parse_error( + "Bad method name at constant pool index %u in class file %s", + name_ref_index, CHECK); } } break; @@ -4843,19 +4840,28 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, } } else { - // 4900761: For class version > 48, any unicode is allowed in class name. + // Skip leading 'L' and ignore first appearance of ';' length--; signature++; - while (length > 0 && signature[0] != ';') { - if (signature[0] == '.') { - classfile_parse_error("Class name contains illegal character '.' in descriptor in class file %s", CHECK_0); - } - length--; - signature++; - } - if (signature[0] == ';') { return signature + 1; } - } + char* c = strchr((char*) signature, ';'); + // Format check signature + if (c != NULL) { + ResourceMark rm(THREAD); + int newlen = c - (char*) signature; + char* sig = NEW_RESOURCE_ARRAY(char, newlen + 1); + strncpy(sig, signature, newlen); + sig[newlen] = '\0'; + bool legal = verify_unqualified_name(sig, newlen, LegalClass); + if (!legal) { + classfile_parse_error("Class name contains illegal character " + "in descriptor in class file %s", + CHECK_0); + return NULL; + } + return signature + newlen + 1; + } + } return NULL; } case JVM_SIGNATURE_ARRAY: @@ -4869,7 +4875,6 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, length--; void_ok = false; break; - default: return NULL; } @@ -5402,6 +5407,59 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa debug_only(ik->verify();) } +// For an anonymous class that is in the unnamed package, move it to its host class's +// package by prepending its host class's package name to its class name and setting +// its _class_name field. +void ClassFileParser::prepend_host_package_name(const InstanceKlass* host_klass, TRAPS) { + ResourceMark rm(THREAD); + assert(strrchr(_class_name->as_C_string(), '/') == NULL, + "Anonymous class should not be in a package"); + const char* host_pkg_name = + ClassLoader::package_from_name(host_klass->name()->as_C_string(), NULL); + + if (host_pkg_name != NULL) { + size_t host_pkg_len = strlen(host_pkg_name); + int class_name_len = _class_name->utf8_length(); + char* new_anon_name = + NEW_RESOURCE_ARRAY(char, host_pkg_len + 1 + class_name_len); + // Copy host package name and trailing /. + strncpy(new_anon_name, host_pkg_name, host_pkg_len); + new_anon_name[host_pkg_len] = '/'; + // Append anonymous class name. The anonymous class name can contain odd + // characters. So, do a strncpy instead of using sprintf("%s..."). + strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len); + + // Create a symbol and update the anonymous class name. + _class_name = SymbolTable::new_symbol(new_anon_name, + (int)host_pkg_len + 1 + class_name_len, + CHECK); + } +} + +// If the host class and the anonymous class are in the same package then do +// nothing. If the anonymous class is in the unnamed package then move it to its +// host's package. If the classes are in different packages then throw an IAE +// exception. +void ClassFileParser::fix_anonymous_class_name(TRAPS) { + assert(_host_klass != NULL, "Expected an anonymous class"); + + const jbyte* anon_last_slash = UTF8::strrchr(_class_name->base(), + _class_name->utf8_length(), '/'); + if (anon_last_slash == NULL) { // Unnamed package + prepend_host_package_name(_host_klass, CHECK); + } else { + if (!InstanceKlass::is_same_class_package(_host_klass->class_loader(), + _host_klass->name(), + _host_klass->class_loader(), + _class_name)) { + ResourceMark rm(THREAD); + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + err_msg("Host class %s and anonymous class %s are in different packages", + _host_klass->name()->as_C_string(), _class_name->as_C_string())); + } + } +} + static bool relax_format_check_for(ClassLoaderData* loader_data) { bool trusted = (loader_data->is_the_null_class_loader_data() || SystemDictionary::is_platform_class_loader(loader_data->class_loader())); @@ -5417,7 +5475,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, Publicity pub_level, TRAPS) : @@ -5692,6 +5750,13 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, return; } + // if this is an anonymous class fix up its name if it's in the unnamed + // package. Otherwise, throw IAE if it is in a different package than + // its host class. + if (_host_klass != NULL) { + fix_anonymous_class_name(CHECK); + } + // Verification prevents us from creating names with dots in them, this // asserts that that's the case. assert(is_internal_format(_class_name), "external class name format used internally"); diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp index 4b6287588c3..8cc820a450a 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.hpp +++ b/hotspot/src/share/vm/classfile/classFileParser.hpp @@ -79,7 +79,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { const Symbol* _requested_name; Symbol* _class_name; mutable ClassLoaderData* _loader_data; - const Klass* _host_klass; + const InstanceKlass* _host_klass; GrowableArray* _cp_patches; // overrides for CP entries // Metadata created before the instance klass is created. Must be deallocated @@ -155,6 +155,9 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { ConstantPool* cp, TRAPS); + void prepend_host_package_name(const InstanceKlass* host_klass, TRAPS); + void fix_anonymous_class_name(TRAPS); + void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS); void set_klass(InstanceKlass* instance); @@ -474,7 +477,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, Publicity pub_level, TRAPS); @@ -500,7 +503,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { bool is_anonymous() const { return _host_klass != NULL; } bool is_interface() const { return _access_flags.is_interface(); } - const Klass* host_klass() const { return _host_klass; } + const InstanceKlass* host_klass() const { return _host_klass; } const GrowableArray* cp_patches() const { return _cp_patches; } ClassLoaderData* loader_data() const { return _loader_data; } const Symbol* class_name() const { return _class_name; } diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 2cb586f1f54..6e74496d80c 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -1358,7 +1358,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray { private: - ClassPathEntry* _next; + ClassPathEntry* volatile _next; public: // Next entry in class path - ClassPathEntry* next() const { return _next; } + ClassPathEntry* next() const { + return (ClassPathEntry*) OrderAccess::load_ptr_acquire(&_next); + } void set_next(ClassPathEntry* next) { - // may have unlocked readers, so write atomically. + // may have unlocked readers, so ensure visibility. OrderAccess::release_store_ptr(&_next, next); } virtual bool is_jrt() = 0; diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index ba1191614b1..9dea595e3aa 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -966,7 +966,7 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure, // Klasses to delete. bool walk_all_metadata = clean_previous_versions && JvmtiExport::has_redefined_a_class() && - InstanceKlass::has_previous_versions(); + InstanceKlass::has_previous_versions_and_reset(); MetadataOnStackMark md_on_stack(walk_all_metadata); // Save previous _unloading pointer for CMS which may add to unloading list before diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 6df74ae4244..eac3f934276 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -773,6 +773,41 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k, InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); } +// Set the java.lang.reflect.Module module field in the java_lang_Class mirror +void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Handle module, TRAPS) { + if (module.is_null()) { + // During startup, the module may be NULL only if java.base has not been defined yet. + // Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module + // for java.base is known. + assert(!Universe::is_module_initialized(), "Incorrect java.lang.reflect.Module pre module system initialization"); + MutexLocker m1(Module_lock, THREAD); + // Keep list of classes needing java.base module fixup + if (!ModuleEntryTable::javabase_defined()) { + if (fixup_module_field_list() == NULL) { + GrowableArray* list = + new (ResourceObj::C_HEAP, mtModule) GrowableArray(500, true); + set_fixup_module_field_list(list); + } + k->class_loader_data()->inc_keep_alive(); + fixup_module_field_list()->push(k()); + } else { + // java.base was defined at some point between calling create_mirror() + // and obtaining the Module_lock, patch this particular class with java.base. + ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry(); + assert(javabase_entry != NULL && javabase_entry->module() != NULL, + "Setting class module field, java.base should be defined"); + Handle javabase_handle(THREAD, JNIHandles::resolve(javabase_entry->module())); + set_module(mirror(), javabase_handle()); + } + } else { + assert(Universe::is_module_initialized() || + (ModuleEntryTable::javabase_defined() && + (module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))), + "Incorrect java.lang.reflect.Module specification while creating mirror"); + set_module(mirror(), module()); + } +} + void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, Handle module, Handle protection_domain, TRAPS) { assert(k->java_mirror() == NULL, "should only assign mirror once"); @@ -835,25 +870,13 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, set_class_loader(mirror(), class_loader()); // set the module field in the java_lang_Class instance - // This may be null during bootstrap but will get fixed up later on. - set_module(mirror(), module()); + set_mirror_module_field(k, mirror, module, THREAD); // Setup indirection from klass->mirror last // after any exceptions can happen during allocations. if (!k.is_null()) { k->set_java_mirror(mirror()); } - - // Keep list of classes needing java.base module fixup. - if (!ModuleEntryTable::javabase_defined()) { - if (fixup_module_field_list() == NULL) { - GrowableArray* list = - new (ResourceObj::C_HEAP, mtModule) GrowableArray(500, true); - set_fixup_module_field_list(list); - } - k->class_loader_data()->inc_keep_alive(); - fixup_module_field_list()->push(k()); - } } else { if (fixup_mirror_list() == NULL) { GrowableArray* list = @@ -3015,41 +3038,6 @@ void java_lang_boxing_object::print(BasicType type, jvalue* value, outputStream* } } - -// Support for java_lang_ref_Reference -HeapWord *java_lang_ref_Reference::pending_list_lock_addr() { - InstanceKlass* ik = SystemDictionary::Reference_klass(); - address addr = ik->static_field_addr(static_lock_offset); - return (HeapWord*) addr; -} - -oop java_lang_ref_Reference::pending_list_lock() { - InstanceKlass* ik = SystemDictionary::Reference_klass(); - address addr = ik->static_field_addr(static_lock_offset); - if (UseCompressedOops) { - return oopDesc::load_decode_heap_oop((narrowOop *)addr); - } else { - return oopDesc::load_decode_heap_oop((oop*)addr); - } -} - -HeapWord *java_lang_ref_Reference::pending_list_addr() { - InstanceKlass* ik = SystemDictionary::Reference_klass(); - address addr = ik->static_field_addr(static_pending_offset); - // XXX This might not be HeapWord aligned, almost rather be char *. - return (HeapWord*)addr; -} - -oop java_lang_ref_Reference::pending_list() { - char *addr = (char *)pending_list_addr(); - if (UseCompressedOops) { - return oopDesc::load_decode_heap_oop((narrowOop *)addr); - } else { - return oopDesc::load_decode_heap_oop((oop*)addr); - } -} - - // Support for java_lang_ref_SoftReference jlong java_lang_ref_SoftReference::timestamp(oop ref) { @@ -3616,8 +3604,6 @@ int java_lang_ref_Reference::referent_offset; int java_lang_ref_Reference::queue_offset; int java_lang_ref_Reference::next_offset; int java_lang_ref_Reference::discovered_offset; -int java_lang_ref_Reference::static_lock_offset; -int java_lang_ref_Reference::static_pending_offset; int java_lang_ref_Reference::number_of_fake_oop_fields; int java_lang_ref_SoftReference::timestamp_offset; int java_lang_ref_SoftReference::static_clock_offset; @@ -3772,8 +3758,6 @@ void JavaClasses::compute_hard_coded_offsets() { java_lang_ref_Reference::queue_offset = java_lang_ref_Reference::hc_queue_offset * x + header; java_lang_ref_Reference::next_offset = java_lang_ref_Reference::hc_next_offset * x + header; java_lang_ref_Reference::discovered_offset = java_lang_ref_Reference::hc_discovered_offset * x + header; - java_lang_ref_Reference::static_lock_offset = java_lang_ref_Reference::hc_static_lock_offset * x; - java_lang_ref_Reference::static_pending_offset = java_lang_ref_Reference::hc_static_pending_offset * x; // Artificial fields for java_lang_ref_Reference // The first field is for the discovered field added in 1.4 java_lang_ref_Reference::number_of_fake_oop_fields = 1; @@ -4006,8 +3990,6 @@ void JavaClasses::check_offsets() { CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, next, "Ljava/lang/ref/Reference;"); // Fake field //CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, discovered, "Ljava/lang/ref/Reference;"); - CHECK_STATIC_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, lock, "Ljava/lang/ref/Reference$Lock;"); - CHECK_STATIC_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, pending, "Ljava/lang/ref/Reference;"); // java.lang.ref.SoftReference diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 7d101b88ea6..448bb4d5bd8 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -219,6 +219,7 @@ class java_lang_Class : AllStatic { static void set_class_loader(oop java_class, oop class_loader); static void set_component_mirror(oop java_class, oop comp_mirror); static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS); + static void set_mirror_module_field(KlassHandle K, Handle mirror, Handle module, TRAPS); public: static void compute_offsets(); @@ -886,17 +887,11 @@ class java_lang_ref_Reference: AllStatic { hc_next_offset = 2, hc_discovered_offset = 3 // Is not last, see SoftRefs. }; - enum { - hc_static_lock_offset = 0, - hc_static_pending_offset = 1 - }; static int referent_offset; static int queue_offset; static int next_offset; static int discovered_offset; - static int static_lock_offset; - static int static_pending_offset; static int number_of_fake_oop_fields; // Accessors @@ -912,13 +907,6 @@ class java_lang_ref_Reference: AllStatic { static inline void set_discovered(oop ref, oop value); static inline void set_discovered_raw(oop ref, oop value); static inline HeapWord* discovered_addr(oop ref); - - // Accessors for statics - static oop pending_list_lock(); - static oop pending_list(); - - static HeapWord* pending_list_lock_addr(); - static HeapWord* pending_list_addr(); }; diff --git a/hotspot/src/share/vm/classfile/klassFactory.cpp b/hotspot/src/share/vm/classfile/klassFactory.cpp index 4d08ea3329c..0c95ac7907d 100644 --- a/hotspot/src/share/vm/classfile/klassFactory.cpp +++ b/hotspot/src/share/vm/classfile/klassFactory.cpp @@ -25,12 +25,85 @@ #include "precompiled.hpp" #include "classfile/classFileParser.hpp" #include "classfile/classFileStream.hpp" +#include "classfile/classLoader.hpp" #include "classfile/classLoaderData.hpp" +#include "classfile/classLoaderData.inline.hpp" #include "classfile/klassFactory.hpp" +#include "classfile/sharedClassUtil.hpp" +#include "memory/metaspaceShared.hpp" #include "memory/resourceArea.hpp" #include "prims/jvmtiEnvBase.hpp" +#include "prims/jvmtiRedefineClasses.hpp" #include "trace/traceMacros.hpp" +// called during initial loading of a shared class +instanceKlassHandle KlassFactory::check_shared_class_file_load_hook( + instanceKlassHandle ik, + Symbol* class_name, + Handle class_loader, + Handle protection_domain, TRAPS) { +#if INCLUDE_CDS && INCLUDE_JVMTI + assert(ik.not_null(), "sanity"); + assert(ik()->is_shared(), "expecting a shared class"); + + if (JvmtiExport::should_post_class_file_load_hook()) { + assert(THREAD->is_Java_thread(), "must be JavaThread"); + + // Post the CFLH + JvmtiCachedClassFileData* cached_class_file = NULL; + JvmtiCachedClassFileData* archived_class_data = ik->get_archived_class_data(); + assert(archived_class_data != NULL, "shared class has no archived class data"); + unsigned char* ptr = + VM_RedefineClasses::get_cached_class_file_bytes(archived_class_data); + unsigned char* end_ptr = + ptr + VM_RedefineClasses::get_cached_class_file_len(archived_class_data); + unsigned char* old_ptr = ptr; + JvmtiExport::post_class_file_load_hook(class_name, + class_loader, + protection_domain, + &ptr, + &end_ptr, + &cached_class_file); + if (old_ptr != ptr) { + // JVMTI agent has modified class file data. + // Set new class file stream using JVMTI agent modified class file data. + ClassLoaderData* loader_data = + ClassLoaderData::class_loader_data(class_loader()); + int path_index = ik->shared_classpath_index(); + SharedClassPathEntry* ent = + (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index); + ClassFileStream* stream = new ClassFileStream(ptr, + end_ptr - ptr, + ent->_name, + ClassFileStream::verify); + ClassFileParser parser(stream, + class_name, + loader_data, + protection_domain, + NULL, + NULL, + ClassFileParser::BROADCAST, // publicity level + CHECK_NULL); + instanceKlassHandle new_ik = parser.create_instance_klass(true /* changed_by_loadhook */, + CHECK_NULL); + if (cached_class_file != NULL) { + new_ik->set_cached_class_file(cached_class_file); + } + + if (class_loader.is_null()) { + ResourceMark rm; + ClassLoader::add_package(class_name->as_C_string(), path_index, THREAD); + } + + return new_ik; + } + } +#endif + + return NULL; +} + + static ClassFileStream* check_class_file_load_hook(ClassFileStream* stream, Symbol* name, ClassLoaderData* loader_data, @@ -94,10 +167,9 @@ instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream, Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS) { - assert(stream != NULL, "invariant"); assert(loader_data != NULL, "invariant"); assert(THREAD->is_Java_thread(), "must be a JavaThread"); @@ -142,5 +214,27 @@ instanceKlassHandle KlassFactory::create_from_stream(ClassFileStream* stream, TRACE_KLASS_CREATION(result, parser, THREAD); +#if INCLUDE_CDS && INCLUDE_JVMTI + if (DumpSharedSpaces) { + assert(cached_class_file == NULL, "Sanity"); + // Archive the class stream data into the optional data section + JvmtiCachedClassFileData *p; + int len; + const unsigned char *bytes; + // event based tracing might set cached_class_file + if ((bytes = result->get_cached_class_file_bytes()) != NULL) { + len = result->get_cached_class_file_len(); + } else { + len = stream->length(); + bytes = stream->buffer(); + } + p = (JvmtiCachedClassFileData*)MetaspaceShared::optional_data_space_alloc( + offset_of(JvmtiCachedClassFileData, data) + len); + p->length = len; + memcpy(p->data, bytes, len); + result->set_archived_class_data(p); + } +#endif + return result; } diff --git a/hotspot/src/share/vm/classfile/klassFactory.hpp b/hotspot/src/share/vm/classfile/klassFactory.hpp index 6783f2753a3..6624e31658e 100644 --- a/hotspot/src/share/vm/classfile/klassFactory.hpp +++ b/hotspot/src/share/vm/classfile/klassFactory.hpp @@ -72,9 +72,15 @@ class KlassFactory : AllStatic { Symbol* name, ClassLoaderData* loader_data, Handle protection_domain, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS); + public: + static instanceKlassHandle check_shared_class_file_load_hook( + instanceKlassHandle ik, + Symbol* class_name, + Handle class_loader, + Handle protection_domain, TRAPS); }; #endif // SHARE_VM_CLASSFILE_KLASSFACTORY_HPP diff --git a/hotspot/src/share/vm/classfile/moduleEntry.cpp b/hotspot/src/share/vm/classfile/moduleEntry.cpp index a8b67c54e64..2be85c2ebd8 100644 --- a/hotspot/src/share/vm/classfile/moduleEntry.cpp +++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp @@ -92,7 +92,7 @@ bool ModuleEntry::can_read(ModuleEntry* m) const { // read java.base. If either of these conditions // hold, readability has been established. if (!this->is_named() || - (m == ModuleEntryTable::javabase_module())) { + (m == ModuleEntryTable::javabase_moduleEntry())) { return true; } @@ -358,16 +358,27 @@ void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version, } // Set java.lang.reflect.Module, version and location for java.base - ModuleEntry* jb_module = javabase_module(); + ModuleEntry* jb_module = javabase_moduleEntry(); assert(jb_module != NULL, "java.base ModuleEntry not defined"); - jb_module->set_module(boot_loader_data->add_handle(module_handle)); jb_module->set_version(version); jb_module->set_location(location); + // Once java.base's ModuleEntry _module field is set with the known + // java.lang.reflect.Module, java.base is considered "defined" to the VM. + jb_module->set_module(boot_loader_data->add_handle(module_handle)); + // Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object. java_lang_reflect_Module::set_module_entry(module_handle(), jb_module); + + // Patch any previously loaded classes' module field with java.base's java.lang.reflect.Module. + patch_javabase_entries(module_handle); } +// Within java.lang.Class instances there is a java.lang.reflect.Module field +// that must be set with the defining module. During startup, prior to java.base's +// definition, classes needing their module field set are added to the fixup_module_list. +// Their module field is set once java.base's java.lang.reflect.Module is known to the VM. void ModuleEntryTable::patch_javabase_entries(Handle module_handle) { + assert(Module_lock->owned_by_self(), "should have the Module_lock"); if (module_handle.is_null()) { fatal("Unable to patch the module field of classes loaded prior to java.base's definition, invalid java.lang.reflect.Module"); } @@ -389,9 +400,7 @@ void ModuleEntryTable::patch_javabase_entries(Handle module_handle) { for (int i = 0; i < list_length; i++) { Klass* k = list->at(i); assert(k->is_klass(), "List should only hold classes"); - Thread* THREAD = Thread::current(); - KlassHandle kh(THREAD, k); - java_lang_Class::fixup_module_field(kh, module_handle); + java_lang_Class::fixup_module_field(KlassHandle(k), module_handle); k->class_loader_data()->dec_keep_alive(); } diff --git a/hotspot/src/share/vm/classfile/moduleEntry.hpp b/hotspot/src/share/vm/classfile/moduleEntry.hpp index 8ec8237ec3f..82f0747a2ae 100644 --- a/hotspot/src/share/vm/classfile/moduleEntry.hpp +++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp @@ -78,11 +78,11 @@ public: _must_walk_reads = false; } - Symbol* name() const { return literal(); } - void set_name(Symbol* n) { set_literal(n); } + Symbol* name() const { return literal(); } + void set_name(Symbol* n) { set_literal(n); } - jobject module() const { return _module; } - void set_module(jobject j) { _module = j; } + jobject module() const { return _module; } + void set_module(jobject j) { _module = j; } // The shared ProtectionDomain reference is set once the VM loads a shared class // originated from the current Module. The referenced ProtectionDomain object is @@ -217,13 +217,13 @@ public: // Special handling for unnamed module, one per class loader's ModuleEntryTable void create_unnamed_module(ClassLoaderData* loader_data); - ModuleEntry* unnamed_module() { return _unnamed_module; } + ModuleEntry* unnamed_module() { return _unnamed_module; } // Special handling for java.base - static ModuleEntry* javabase_module() { return _javabase_module; } - static void set_javabase_module(ModuleEntry* java_base) { _javabase_module = java_base; } - static bool javabase_defined() { return ((_javabase_module != NULL) && - (_javabase_module->module() != NULL)); } + static ModuleEntry* javabase_moduleEntry() { return _javabase_module; } + static void set_javabase_moduleEntry(ModuleEntry* java_base) { _javabase_module = java_base; } + static bool javabase_defined() { return ((_javabase_module != NULL) && + (_javabase_module->module() != NULL)); } static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location); static void patch_javabase_entries(Handle module_handle); diff --git a/hotspot/src/share/vm/classfile/modules.cpp b/hotspot/src/share/vm/classfile/modules.cpp index 8986eb64e96..f7b15b141d7 100644 --- a/hotspot/src/share/vm/classfile/modules.cpp +++ b/hotspot/src/share/vm/classfile/modules.cpp @@ -206,7 +206,7 @@ static void define_javabase_module(jobject module, jstring version, assert(pkg_list->length() == 0 || package_table != NULL, "Bad package_table"); // Ensure java.base's ModuleEntry has been created - assert(ModuleEntryTable::javabase_module() != NULL, "No ModuleEntry for java.base"); + assert(ModuleEntryTable::javabase_moduleEntry() != NULL, "No ModuleEntry for java.base"); bool duplicate_javabase = false; { @@ -226,7 +226,7 @@ static void define_javabase_module(jobject module, jstring version, for (int x = 0; x < pkg_list->length(); x++) { // Some of java.base's packages were added early in bootstrapping, ignore duplicates. if (package_table->lookup_only(pkg_list->at(x)) == NULL) { - pkg = package_table->locked_create_entry_or_null(pkg_list->at(x), ModuleEntryTable::javabase_module()); + pkg = package_table->locked_create_entry_or_null(pkg_list->at(x), ModuleEntryTable::javabase_moduleEntry()); assert(pkg != NULL, "Unable to create a java.base package entry"); } // Unable to have a GrowableArray of TempNewSymbol. Must decrement the refcount of @@ -255,9 +255,6 @@ static void define_javabase_module(jobject module, jstring version, log_trace(modules)("define_javabase_module(): creation of package %s for module java.base", (pkg_list->at(x))->as_C_string()); } - - // Patch any previously loaded classes' module field with java.base's jlr.Module. - ModuleEntryTable::patch_javabase_entries(module_handle); } void Modules::define_module(jobject module, jstring version, diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 70f9e6a169f..02e1dbae6bc 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1027,7 +1027,7 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name, Handle class_loader, Handle protection_domain, ClassFileStream* st, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS) { @@ -1210,16 +1210,12 @@ Klass* SystemDictionary::find_shared_class(Symbol* class_name) { instanceKlassHandle SystemDictionary::load_shared_class( Symbol* class_name, Handle class_loader, TRAPS) { - // Don't load shared class when JvmtiExport::should_post_class_file_load_hook() - // is enabled since posting CFLH is not supported when loading shared class. - if (!JvmtiExport::should_post_class_file_load_hook()) { - instanceKlassHandle ik (THREAD, find_shared_class(class_name)); - // Make sure we only return the boot class for the NULL classloader. - if (ik.not_null() && - ik->is_shared_boot_class() && class_loader.is_null()) { - Handle protection_domain; - return load_shared_class(ik, class_loader, protection_domain, THREAD); - } + instanceKlassHandle ik (THREAD, find_shared_class(class_name)); + // Make sure we only return the boot class for the NULL classloader. + if (ik.not_null() && + ik->is_shared_boot_class() && class_loader.is_null()) { + Handle protection_domain; + return load_shared_class(ik, class_loader, protection_domain, THREAD); } return instanceKlassHandle(); } @@ -1303,11 +1299,6 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik, Handle class_loader, Handle protection_domain, TRAPS) { instanceKlassHandle nh = instanceKlassHandle(); // null Handle - if (JvmtiExport::should_post_class_file_load_hook()) { - // Don't load shared class when JvmtiExport::should_post_class_file_load_hook() - // is enabled since posting CFLH is not supported when loading shared class. - return nh; - } if (ik.not_null()) { Symbol* class_name = ik->name(); @@ -1358,6 +1349,14 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik, } } + instanceKlassHandle new_ik = KlassFactory::check_shared_class_file_load_hook( + ik, class_name, class_loader, protection_domain, CHECK_(nh)); + if (new_ik.not_null()) { + // The class is changed by CFLH. Return the new class. The shared class is + // not used. + return new_ik; + } + // Adjust methods to recover missing data. They need addresses for // interpreter entry points and their default native method address // must be reset. diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index 6dd7d20e456..bf10995a578 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -299,7 +299,7 @@ public: Handle class_loader, Handle protection_domain, ClassFileStream* st, - const Klass* host_klass, + const InstanceKlass* host_klass, GrowableArray* cp_patches, TRAPS); diff --git a/hotspot/src/share/vm/classfile/verificationType.hpp b/hotspot/src/share/vm/classfile/verificationType.hpp index a654f48acb5..92e2043334c 100644 --- a/hotspot/src/share/vm/classfile/verificationType.hpp +++ b/hotspot/src/share/vm/classfile/verificationType.hpp @@ -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 @@ -95,7 +95,8 @@ class VerificationType VALUE_OBJ_CLASS_SPEC { Category2_2nd = (Category2_2ndFlag << 1 * BitsPerByte) | Primitive, // Primitive values (type descriminator stored in most-signifcant bytes) - Bogus = (ITEM_Bogus << 2 * BitsPerByte) | Category1, + // Bogus needs the " | Primitive". Else, is_reference(Bogus) returns TRUE. + Bogus = (ITEM_Bogus << 2 * BitsPerByte) | Primitive, Boolean = (ITEM_Boolean << 2 * BitsPerByte) | Category1, Byte = (ITEM_Byte << 2 * BitsPerByte) | Category1, Short = (ITEM_Short << 2 * BitsPerByte) | Category1, diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 2194859c30c..ba58b175305 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -67,12 +67,12 @@ static void* volatile _verify_byte_codes_fn = NULL; static volatile jint _is_new_verify_byte_codes_fn = (jint) true; static void* verify_byte_codes_fn() { - if (_verify_byte_codes_fn == NULL) { + if (OrderAccess::load_ptr_acquire(&_verify_byte_codes_fn) == NULL) { void *lib_handle = os::native_java_library(); void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion"); OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); if (func == NULL) { - OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false); + _is_new_verify_byte_codes_fn = false; func = os::dll_lookup(lib_handle, "VerifyClassCodes"); OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); } @@ -2786,7 +2786,7 @@ void ClassVerifier::verify_invoke_instructions( // direct interface relative to the host class have_imr_indirect = (have_imr_indirect && !is_same_or_direct_interface( - InstanceKlass::cast(current_class()->host_klass()), + current_class()->host_klass(), host_klass_type, ref_class_type)); } if (!subtype) { diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp index aa7c7a0261f..ad17837fb0d 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.cpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp @@ -368,6 +368,7 @@ bool vmIntrinsics::can_trap(vmIntrinsics::ID id) { switch(id) { #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: + case vmIntrinsics::_getClassId: #endif case vmIntrinsics::_currentTimeMillis: case vmIntrinsics::_nanoTime: diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index b3bc80c6a51..62433c1c088 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -32,7 +32,6 @@ #include "compiler/compileLog.hpp" #include "compiler/compilerOracle.hpp" #include "compiler/directivesParser.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "interpreter/linkResolver.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -893,15 +892,6 @@ void CompileBroker::compile_method_base(const methodHandle& method, return; } - // If the requesting thread is holding the pending list lock - // then we just return. We can't risk blocking while holding - // the pending list lock or a 3-way deadlock may occur - // between the reference handler thread, a GC (instigated - // by a compiler thread), and compiled method registration. - if (ReferencePendingListLocker::is_locked_by_self()) { - return; - } - if (TieredCompilation) { // Tiered policy requires MethodCounters to exist before adding a method to // the queue. Create if we don't have them yet. diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp index 6d78865ac43..2a1be1af777 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp @@ -3511,6 +3511,7 @@ bool CMSCollector::do_marking_mt() { conc_workers()->active_workers(), Threads::number_of_non_daemon_threads()); num_workers = conc_workers()->update_active_workers(num_workers); + log_info(gc,task)("Using %u workers of %u for marking", num_workers, conc_workers()->total_workers()); CompactibleFreeListSpace* cms_space = _cmsGen->cmsSpace(); diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp index 3ea77838462..43a32e913e8 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepThread.cpp @@ -28,7 +28,6 @@ #include "gc/cms/concurrentMarkSweepThread.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/genCollectedHeap.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "oops/oop.inline.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.hpp" @@ -77,23 +76,6 @@ void ConcurrentMarkSweepThread::run_service() { log_warning(gc)("Couldn't bind CMS thread to processor " UINTX_FORMAT, CPUForCMSThread); } - { - MutexLockerEx x(CGC_lock, true); - set_CMS_flag(CMS_cms_wants_token); - assert(is_init_completed() && Universe::is_fully_initialized(), "ConcurrentGCThread::run() should have waited for this."); - - // Wait until the surrogate locker thread that will do - // pending list locking on our behalf has been created. - // We cannot start the SLT thread ourselves since we need - // to be a JavaThread to do so. - CMSLoopCountWarn loopY("CMS::run", "waiting for SLT installation", 2); - while (!ReferencePendingListLocker::is_initialized() && !should_terminate()) { - CGC_lock->wait(true, 200); - loopY.tick(); - } - clear_CMS_flag(CMS_cms_wants_token); - } - while (!should_terminate()) { sleepBeforeNextCycle(); if (should_terminate()) break; diff --git a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp index e8f606eecc8..78839d983f6 100644 --- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp @@ -899,6 +899,8 @@ void ParNewGeneration::collect(bool full, workers->active_workers(), Threads::number_of_non_daemon_threads()); active_workers = workers->update_active_workers(active_workers); + log_info(gc,task)("Using %u workers of %u for evacuation", active_workers, workers->total_workers()); + _old_gen = gch->old_gen(); // If the next generation is too full to accommodate worst-case promotion @@ -1364,22 +1366,25 @@ bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan return false; } assert(prefix != NULL && prefix != BUSY, "Error"); - size_t i = 1; oop cur = prefix; - while (i < objsFromOverflow && cur->klass_or_null() != NULL) { - i++; cur = cur->list_ptr_from_klass(); + for (size_t i = 1; i < objsFromOverflow; ++i) { + oop next = cur->list_ptr_from_klass(); + if (next == NULL) break; + cur = next; } + assert(cur != NULL, "Loop postcondition"); // Reattach remaining (suffix) to overflow list - if (cur->klass_or_null() == NULL) { + oop suffix = cur->list_ptr_from_klass(); + if (suffix == NULL) { // Write back the NULL in lieu of the BUSY we wrote // above and it is still the same value. if (_overflow_list == BUSY) { (void) Atomic::cmpxchg_ptr(NULL, &_overflow_list, BUSY); } } else { - assert(cur->klass_or_null() != (Klass*)(address)BUSY, "Error"); - oop suffix = cur->list_ptr_from_klass(); // suffix will be put back on global list + assert(suffix != BUSY, "Error"); + // suffix will be put back on global list cur->set_klass_to_list_ptr(NULL); // break off suffix // It's possible that the list is still in the empty(busy) state // we left it in a short while ago; in that case we may be @@ -1399,8 +1404,10 @@ bool ParNewGeneration::take_from_overflow_list_work(ParScanThreadState* par_scan // Too bad, someone else got in in between; we'll need to do a splice. // Find the last item of suffix list oop last = suffix; - while (last->klass_or_null() != NULL) { - last = last->list_ptr_from_klass(); + while (true) { + oop next = last->list_ptr_from_klass(); + if (next == NULL) break; + last = next; } // Atomically prepend suffix to current overflow list observed_overflow_list = _overflow_list; diff --git a/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp b/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp index 73f205485db..3aa8a0ccd6b 100644 --- a/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp +++ b/hotspot/src/share/vm/gc/cms/vmCMSOperations.cpp @@ -37,14 +37,6 @@ ////////////////////////////////////////////////////////// // Methods in abstract class VM_CMS_Operation ////////////////////////////////////////////////////////// -void VM_CMS_Operation::acquire_pending_list_lock() { - _pending_list_locker.lock(); -} - -void VM_CMS_Operation::release_and_notify_pending_list_lock() { - _pending_list_locker.unlock(); -} - void VM_CMS_Operation::verify_before_gc() { if (VerifyBeforeGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { @@ -85,17 +77,10 @@ bool VM_CMS_Operation::doit_prologue() { assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(), "Possible deadlock"); - if (needs_pending_list_lock()) { - acquire_pending_list_lock(); - } - // Get the Heap_lock after the pending_list_lock. Heap_lock->lock(); if (lost_race()) { assert(_prologue_succeeded == false, "Initialized in c'tor"); Heap_lock->unlock(); - if (needs_pending_list_lock()) { - release_and_notify_pending_list_lock(); - } } else { _prologue_succeeded = true; } @@ -108,11 +93,10 @@ void VM_CMS_Operation::doit_epilogue() { assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(), "Possible deadlock"); - // Release the Heap_lock first. - Heap_lock->unlock(); - if (needs_pending_list_lock()) { - release_and_notify_pending_list_lock(); + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); } + Heap_lock->unlock(); } ////////////////////////////////////////////////////////// @@ -230,9 +214,11 @@ void VM_GenCollectFullConcurrent::doit_epilogue() { Thread* thr = Thread::current(); assert(thr->is_Java_thread(), "just checking"); JavaThread* jt = (JavaThread*)thr; - // Release the Heap_lock first. + + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); + } Heap_lock->unlock(); - release_and_notify_pending_list_lock(); // It is fine to test whether completed collections has // exceeded our request count without locking because diff --git a/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp b/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp index e6fe2c2ac25..fd39fe479d9 100644 --- a/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp +++ b/hotspot/src/share/vm/gc/cms/vmCMSOperations.hpp @@ -28,7 +28,6 @@ #include "gc/cms/concurrentMarkSweepGeneration.hpp" #include "gc/shared/gcCause.hpp" #include "gc/shared/gcId.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/vmGCOperations.hpp" #include "runtime/vm_operations.hpp" @@ -52,9 +51,6 @@ class CMSCollector; class VM_CMS_Operation: public VM_Operation { - private: - ReferencePendingListLocker _pending_list_locker; - protected: CMSCollector* _collector; // associated collector bool _prologue_succeeded; // whether doit_prologue succeeded @@ -62,10 +58,6 @@ class VM_CMS_Operation: public VM_Operation { bool lost_race() const; - // java.lang.ref.Reference support - void acquire_pending_list_lock(); - void release_and_notify_pending_list_lock(); - public: VM_CMS_Operation(CMSCollector* collector): _collector(collector), diff --git a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp index 469412245bf..9c94863a43b 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp +++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp @@ -175,7 +175,7 @@ void ConcurrentMarkThread::run_service() { TimeHelper::counter_to_millis(mark_end - mark_start)); CMCheckpointRootsFinalClosure final_cl(_cm); - VM_CGC_Operation op(&final_cl, "Pause Remark", true /* needs_pll */); + VM_CGC_Operation op(&final_cl, "Pause Remark"); VMThread::execute(&op); } if (cm()->restart_for_overflow()) { @@ -199,7 +199,7 @@ void ConcurrentMarkThread::run_service() { delay_to_keep_mmu(g1_policy, false /* cleanup */); CMCleanUp cl_cl(_cm); - VM_CGC_Operation op(&cl_cl, "Pause Cleanup", false /* needs_pll */); + VM_CGC_Operation op(&cl_cl, "Pause Cleanup"); VMThread::execute(&op); } else { // We don't want to update the marking status if a GC pause diff --git a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp index afbe72c8c6a..88611f472ca 100644 --- a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "code/codeCache.hpp" #include "code/nmethod.hpp" +#include "gc/g1/g1CodeRootSetTable.hpp" #include "gc/g1/g1CodeCacheRemSet.hpp" #include "gc/g1/heapRegion.hpp" #include "memory/heap.hpp" @@ -33,58 +34,13 @@ #include "utilities/hashtable.inline.hpp" #include "utilities/stack.inline.hpp" -class CodeRootSetTable : public Hashtable { - friend class G1CodeRootSetTest; - typedef HashtableEntry Entry; +G1CodeRootSetTable* volatile G1CodeRootSetTable::_purge_list = NULL; - static CodeRootSetTable* volatile _purge_list; - - CodeRootSetTable* _purge_next; - - unsigned int compute_hash(nmethod* nm) { - uintptr_t hash = (uintptr_t)nm; - return hash ^ (hash >> 7); // code heap blocks are 128byte aligned - } - - void remove_entry(Entry* e, Entry* previous); - Entry* new_entry(nmethod* nm); - - public: - CodeRootSetTable(int size) : Hashtable(size, sizeof(Entry)), _purge_next(NULL) {} - ~CodeRootSetTable(); - - // Needs to be protected locks - bool add(nmethod* nm); - bool remove(nmethod* nm); - - // Can be called without locking - bool contains(nmethod* nm); - - int entry_size() const { return BasicHashtable::entry_size(); } - - void copy_to(CodeRootSetTable* new_table); - void nmethods_do(CodeBlobClosure* blk); - - template - int remove_if(CB& should_remove); - - static void purge_list_append(CodeRootSetTable* tbl); - static void purge(); - - static size_t static_mem_size() { - return sizeof(_purge_list); - } - - size_t mem_size(); -}; - -CodeRootSetTable* volatile CodeRootSetTable::_purge_list = NULL; - -size_t CodeRootSetTable::mem_size() { - return sizeof(CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket) * table_size()); +size_t G1CodeRootSetTable::mem_size() { + return sizeof(G1CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket) * table_size()); } -CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) { +G1CodeRootSetTable::Entry* G1CodeRootSetTable::new_entry(nmethod* nm) { unsigned int hash = compute_hash(nm); Entry* entry = (Entry*) new_entry_free_list(); if (entry == NULL) { @@ -96,7 +52,7 @@ CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) { return entry; } -void CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { +void G1CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { int index = hash_to_index(e->hash()); assert((e == bucket(index)) == (previous == NULL), "if e is the first entry then previous should be null"); @@ -108,7 +64,7 @@ void CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { free_entry(e); } -CodeRootSetTable::~CodeRootSetTable() { +G1CodeRootSetTable::~G1CodeRootSetTable() { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; ) { Entry* to_remove = e; @@ -125,7 +81,7 @@ CodeRootSetTable::~CodeRootSetTable() { } } -bool CodeRootSetTable::add(nmethod* nm) { +bool G1CodeRootSetTable::add(nmethod* nm) { if (!contains(nm)) { Entry* e = new_entry(nm); int index = hash_to_index(e->hash()); @@ -135,7 +91,7 @@ bool CodeRootSetTable::add(nmethod* nm) { return false; } -bool CodeRootSetTable::contains(nmethod* nm) { +bool G1CodeRootSetTable::contains(nmethod* nm) { int index = hash_to_index(compute_hash(nm)); for (Entry* e = bucket(index); e != NULL; e = e->next()) { if (e->literal() == nm) { @@ -145,7 +101,7 @@ bool CodeRootSetTable::contains(nmethod* nm) { return false; } -bool CodeRootSetTable::remove(nmethod* nm) { +bool G1CodeRootSetTable::remove(nmethod* nm) { int index = hash_to_index(compute_hash(nm)); Entry* previous = NULL; for (Entry* e = bucket(index); e != NULL; previous = e, e = e->next()) { @@ -157,7 +113,7 @@ bool CodeRootSetTable::remove(nmethod* nm) { return false; } -void CodeRootSetTable::copy_to(CodeRootSetTable* new_table) { +void G1CodeRootSetTable::copy_to(G1CodeRootSetTable* new_table) { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; e = e->next()) { new_table->add(e->literal()); @@ -166,7 +122,7 @@ void CodeRootSetTable::copy_to(CodeRootSetTable* new_table) { new_table->copy_freelist(this); } -void CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { +void G1CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; e = e->next()) { blk->do_code_blob(e->literal()); @@ -175,7 +131,7 @@ void CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { } template -int CodeRootSetTable::remove_if(CB& should_remove) { +int G1CodeRootSetTable::remove_if(CB& should_remove) { int num_removed = 0; for (int index = 0; index < table_size(); ++index) { Entry* previous = NULL; @@ -198,52 +154,52 @@ G1CodeRootSet::~G1CodeRootSet() { delete _table; } -CodeRootSetTable* G1CodeRootSet::load_acquire_table() { - return (CodeRootSetTable*) OrderAccess::load_ptr_acquire(&_table); +G1CodeRootSetTable* G1CodeRootSet::load_acquire_table() { + return (G1CodeRootSetTable*) OrderAccess::load_ptr_acquire(&_table); } void G1CodeRootSet::allocate_small_table() { - CodeRootSetTable* temp = new CodeRootSetTable(SmallSize); + G1CodeRootSetTable* temp = new G1CodeRootSetTable(SmallSize); OrderAccess::release_store_ptr(&_table, temp); } -void CodeRootSetTable::purge_list_append(CodeRootSetTable* table) { +void G1CodeRootSetTable::purge_list_append(G1CodeRootSetTable* table) { for (;;) { table->_purge_next = _purge_list; - CodeRootSetTable* old = (CodeRootSetTable*) Atomic::cmpxchg_ptr(table, &_purge_list, table->_purge_next); + G1CodeRootSetTable* old = (G1CodeRootSetTable*) Atomic::cmpxchg_ptr(table, &_purge_list, table->_purge_next); if (old == table->_purge_next) { break; } } } -void CodeRootSetTable::purge() { - CodeRootSetTable* table = _purge_list; +void G1CodeRootSetTable::purge() { + G1CodeRootSetTable* table = _purge_list; _purge_list = NULL; while (table != NULL) { - CodeRootSetTable* to_purge = table; + G1CodeRootSetTable* to_purge = table; table = table->_purge_next; delete to_purge; } } void G1CodeRootSet::move_to_large() { - CodeRootSetTable* temp = new CodeRootSetTable(LargeSize); + G1CodeRootSetTable* temp = new G1CodeRootSetTable(LargeSize); _table->copy_to(temp); - CodeRootSetTable::purge_list_append(_table); + G1CodeRootSetTable::purge_list_append(_table); OrderAccess::release_store_ptr(&_table, temp); } void G1CodeRootSet::purge() { - CodeRootSetTable::purge(); + G1CodeRootSetTable::purge(); } size_t G1CodeRootSet::static_mem_size() { - return CodeRootSetTable::static_mem_size(); + return G1CodeRootSetTable::static_mem_size(); } void G1CodeRootSet::add(nmethod* method) { @@ -278,7 +234,7 @@ bool G1CodeRootSet::remove(nmethod* method) { } bool G1CodeRootSet::contains(nmethod* method) { - CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync. + G1CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync. if (table != NULL) { return table->contains(method); } @@ -348,67 +304,3 @@ void G1CodeRootSet::clean(HeapRegion* owner) { clear(); } } - -#ifndef PRODUCT - -class G1CodeRootSetTest { - public: - static void test() { - { - G1CodeRootSet set1; - assert(set1.is_empty(), "Code root set must be initially empty but is not."); - - assert(G1CodeRootSet::static_mem_size() == sizeof(void*), - "The code root set's static memory usage is incorrect, " SIZE_FORMAT " bytes", G1CodeRootSet::static_mem_size()); - - set1.add((nmethod*)1); - assert(set1.length() == 1, "Added exactly one element, but set contains " - SIZE_FORMAT " elements", set1.length()); - - const size_t num_to_add = (size_t)G1CodeRootSet::Threshold + 1; - - for (size_t i = 1; i <= num_to_add; i++) { - set1.add((nmethod*)1); - } - assert(set1.length() == 1, - "Duplicate detection should not have increased the set size but " - "is " SIZE_FORMAT, set1.length()); - - for (size_t i = 2; i <= num_to_add; i++) { - set1.add((nmethod*)(uintptr_t)(i)); - } - assert(set1.length() == num_to_add, - "After adding in total " SIZE_FORMAT " distinct code roots, they " - "need to be in the set, but there are only " SIZE_FORMAT, - num_to_add, set1.length()); - - assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); - - size_t num_popped = 0; - for (size_t i = 1; i <= num_to_add; i++) { - bool removed = set1.remove((nmethod*)i); - if (removed) { - num_popped += 1; - } else { - break; - } - } - assert(num_popped == num_to_add, - "Managed to pop " SIZE_FORMAT " code roots, but only " SIZE_FORMAT " " - "were added", num_popped, num_to_add); - assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable"); - - G1CodeRootSet::purge(); - - assert(CodeRootSetTable::_purge_list == NULL, "should have purged old small tables"); - - } - - } -}; - -void TestCodeCacheRemSet_test() { - G1CodeRootSetTest::test(); -} - -#endif diff --git a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp index fcd82187909..3c7ed50d81c 100644 --- a/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CodeCacheRemSet.hpp @@ -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 @@ -28,7 +28,7 @@ #include "memory/allocation.hpp" class CodeBlobClosure; -class CodeRootSetTable; +class G1CodeRootSetTable; class HeapRegion; class nmethod; @@ -42,8 +42,8 @@ class G1CodeRootSet VALUE_OBJ_CLASS_SPEC { const static size_t Threshold = 24; const static size_t LargeSize = 512; - CodeRootSetTable* _table; - CodeRootSetTable* load_acquire_table(); + G1CodeRootSetTable* _table; + G1CodeRootSetTable* load_acquire_table(); size_t _length; diff --git a/hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp b/hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp new file mode 100644 index 00000000000..4a3b6bbc25b --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1CodeRootSetTable.hpp @@ -0,0 +1,76 @@ +/* + * 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. + */ + +#ifndef SHARE_VM_GC_G1_G1CODEROOTSETTABLE_HPP +#define SHARE_VM_GC_G1_G1CODEROOTSETTABLE_HPP + +#include "utilities/hashtable.hpp" + +class nmethod; + +class G1CodeRootSetTable : public Hashtable { + friend class G1CodeRootSetTest; + typedef HashtableEntry Entry; + + static G1CodeRootSetTable* volatile _purge_list; + + G1CodeRootSetTable* _purge_next; + + unsigned int compute_hash(nmethod* nm) { + uintptr_t hash = (uintptr_t)nm; + return hash ^ (hash >> 7); // code heap blocks are 128byte aligned + } + + void remove_entry(Entry* e, Entry* previous); + Entry* new_entry(nmethod* nm); + + public: + G1CodeRootSetTable(int size) : Hashtable(size, sizeof(Entry)), _purge_next(NULL) {} + ~G1CodeRootSetTable(); + + // Needs to be protected by locks + bool add(nmethod* nm); + bool remove(nmethod* nm); + + // Can be called without locking + bool contains(nmethod* nm); + + int entry_size() const { return BasicHashtable::entry_size(); } + + void copy_to(G1CodeRootSetTable* new_table); + void nmethods_do(CodeBlobClosure* blk); + + template + int remove_if(CB& should_remove); + + static void purge_list_append(G1CodeRootSetTable* tbl); + static void purge(); + + static size_t static_mem_size() { + return sizeof(_purge_list); + } + + size_t mem_size(); +}; + +#endif /* SHARE_VM_GC_G1_G1CODEROOTSETTABLE_HPP */ diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index e1462e9343c..9ffbaeaad8b 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -1332,6 +1332,7 @@ bool G1CollectedHeap::do_full_collection(bool explicit_gc, workers()->active_workers(), Threads::number_of_non_daemon_threads()); workers()->update_active_workers(n_workers); + log_info(gc,task)("Using %u workers of %u to rebuild remembered set", n_workers, workers()->total_workers()); ParRebuildRSTask rebuild_rs_task(this); workers()->run_task(&rebuild_rs_task); @@ -1478,7 +1479,7 @@ void G1CollectedHeap::resize_if_necessary_after_full_collection() { "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B min_desired_capacity: " SIZE_FORMAT "B (" UINTX_FORMAT " %%)", capacity_after_gc, used_after_gc, minimum_desired_capacity, MinHeapFreeRatio); - expand(expand_bytes); + expand(expand_bytes, _workers); // No expansion, now see if we want to shrink } else if (capacity_after_gc > maximum_desired_capacity) { @@ -1598,7 +1599,7 @@ HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size, AllocationConte word_size * HeapWordSize); - if (expand(expand_bytes)) { + if (expand(expand_bytes, _workers)) { _hrm.verify_optional(); _verifier->verify_region_sets_optional(); return attempt_allocation_at_safepoint(word_size, @@ -1608,7 +1609,7 @@ HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size, AllocationConte return NULL; } -bool G1CollectedHeap::expand(size_t expand_bytes, double* expand_time_ms) { +bool G1CollectedHeap::expand(size_t expand_bytes, WorkGang* pretouch_workers, double* expand_time_ms) { size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes); aligned_expand_bytes = align_size_up(aligned_expand_bytes, HeapRegion::GrainBytes); @@ -1625,7 +1626,7 @@ bool G1CollectedHeap::expand(size_t expand_bytes, double* expand_time_ms) { uint regions_to_expand = (uint)(aligned_expand_bytes / HeapRegion::GrainBytes); assert(regions_to_expand > 0, "Must expand by at least one region"); - uint expanded_by = _hrm.expand_by(regions_to_expand); + uint expanded_by = _hrm.expand_by(regions_to_expand, pretouch_workers); if (expand_time_ms != NULL) { *expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS; } @@ -1926,7 +1927,7 @@ jint G1CollectedHeap::initialize() { _cmThread = _cm->cmThread(); // Now expand into the initial heap size. - if (!expand(init_byte_size)) { + if (!expand(init_byte_size, _workers)) { vm_shutdown_during_initialization("Failed to allocate initial heap."); return JNI_ENOMEM; } @@ -3068,6 +3069,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { workers()->active_workers(), Threads::number_of_non_daemon_threads()); workers()->update_active_workers(active_workers); + log_info(gc,task)("Using %u workers of %u for evacuation", active_workers, workers()->total_workers()); TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); TraceMemoryManagerStats tms(false /* fullGC */, gc_cause()); @@ -3163,7 +3165,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { assert(_verifier->check_cset_fast_test(), "Inconsistency in the InCSetState table."); - _cm->note_start_of_gc(); // We call this after finalize_cset() to // ensure that the CSet has been finalized. _cm->verify_no_cset_oops(); @@ -3239,7 +3240,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { // No need for an ergo logging here, // expansion_amount() does this when it returns a value > 0. double expand_ms; - if (!expand(expand_bytes, &expand_ms)) { + if (!expand(expand_bytes, _workers, &expand_ms)) { // We failed to expand the heap. Cannot do anything about it. } g1_policy()->phase_times()->record_expand_heap_time(expand_ms); @@ -3249,7 +3250,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { // We redo the verification but now wrt to the new CSet which // has just got initialized after the previous CSet was freed. _cm->verify_no_cset_oops(); - _cm->note_end_of_gc(); // This timing is only used by the ergonomics to handle our pause target. // It is unclear why this should not include the full pause. We will @@ -4513,6 +4513,7 @@ void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_in #if defined(COMPILER2) || INCLUDE_JVMCI DerivedPointerTable::update_pointers(); #endif + g1_policy()->print_age_table(); } void G1CollectedHeap::record_obj_copy_mem_stats() { diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index b47778324b4..d1e8dcafb14 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -557,7 +557,7 @@ public: // Returns true if the heap was expanded by the requested amount; // false otherwise. // (Rounds up to a HeapRegion boundary.) - bool expand(size_t expand_bytes, double* expand_time_ms = NULL); + bool expand(size_t expand_bytes, WorkGang* pretouch_workers = NULL, double* expand_time_ms = NULL); // Returns the PLAB statistics for a given destination. inline G1EvacStats* alloc_buffer_stats(InCSetState dest); @@ -1273,12 +1273,6 @@ public: return true; } - // The reference pending list lock is acquired from from the - // ConcurrentMarkThread. - virtual bool needs_reference_pending_list_locker_thread() const { - return true; - } - inline bool is_in_young(const oop obj); virtual bool is_scavengable(const void* addr); 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 27f4071b7bf..52a9f4817ab 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -133,129 +133,184 @@ void G1CMBitMap::clear_range(MemRegion mr) { } G1CMMarkStack::G1CMMarkStack() : - _reserved_space(), + _max_chunk_capacity(0), _base(NULL), - _capacity(0), - _saved_index((size_t)AllBits), + _chunk_capacity(0), + _out_of_memory(false), _should_expand(false) { set_empty(); } bool G1CMMarkStack::resize(size_t new_capacity) { assert(is_empty(), "Only resize when stack is empty."); - assert(new_capacity <= MarkStackSizeMax, - "Trying to resize stack to " SIZE_FORMAT " elements when the maximum is " SIZE_FORMAT, new_capacity, MarkStackSizeMax); + assert(new_capacity <= _max_chunk_capacity, + "Trying to resize stack to " SIZE_FORMAT " chunks when the maximum is " SIZE_FORMAT, new_capacity, _max_chunk_capacity); - size_t reservation_size = ReservedSpace::allocation_align_size_up(new_capacity * sizeof(oop)); + OopChunk* new_base = MmapArrayAllocator::allocate_or_null(new_capacity); - ReservedSpace rs(reservation_size); - if (!rs.is_reserved()) { - log_warning(gc)("Failed to reserve memory for new overflow mark stack with " SIZE_FORMAT " elements and size " SIZE_FORMAT "B.", new_capacity, reservation_size); + if (new_base == NULL) { + log_warning(gc)("Failed to reserve memory for new overflow mark stack with " SIZE_FORMAT " chunks and size " SIZE_FORMAT "B.", new_capacity, new_capacity * sizeof(OopChunk)); return false; } - - VirtualSpace vs; - - if (!vs.initialize(rs, rs.size())) { - rs.release(); - log_warning(gc)("Failed to commit memory for new overflow mark stack of size " SIZE_FORMAT "B.", rs.size()); - return false; - } - - assert(vs.committed_size() == rs.size(), "Failed to commit all of the mark stack."); - // Release old mapping. - _reserved_space.release(); + if (_base != NULL) { + MmapArrayAllocator::free(_base, _chunk_capacity); + } - // Save new mapping for future unmapping. - _reserved_space = rs; - - MemTracker::record_virtual_memory_type((address)_reserved_space.base(), mtGC); - - _base = (oop*) vs.low(); - _capacity = new_capacity; + _base = new_base; + _chunk_capacity = new_capacity; set_empty(); _should_expand = false; return true; } -bool G1CMMarkStack::allocate(size_t capacity) { - return resize(capacity); +size_t G1CMMarkStack::capacity_alignment() { + return (size_t)lcm(os::vm_allocation_granularity(), sizeof(OopChunk)) / sizeof(void*); +} + +bool G1CMMarkStack::initialize(size_t initial_capacity, size_t max_capacity) { + guarantee(_max_chunk_capacity == 0, "G1CMMarkStack already initialized."); + + size_t const OopChunkSizeInVoidStar = sizeof(OopChunk) / sizeof(void*); + + _max_chunk_capacity = (size_t)align_size_up(max_capacity, capacity_alignment()) / OopChunkSizeInVoidStar; + size_t initial_chunk_capacity = (size_t)align_size_up(initial_capacity, capacity_alignment()) / OopChunkSizeInVoidStar; + + guarantee(initial_chunk_capacity <= _max_chunk_capacity, + "Maximum chunk capacity " SIZE_FORMAT " smaller than initial capacity " SIZE_FORMAT, + _max_chunk_capacity, + initial_chunk_capacity); + + log_debug(gc)("Initialize mark stack with " SIZE_FORMAT " chunks, maximum " SIZE_FORMAT, + initial_chunk_capacity, _max_chunk_capacity); + + return resize(initial_chunk_capacity); } void G1CMMarkStack::expand() { // Clear expansion flag _should_expand = false; - if (_capacity == MarkStackSizeMax) { - log_debug(gc)("Can not expand overflow mark stack further, already at maximum capacity of " SIZE_FORMAT " elements.", _capacity); + if (_chunk_capacity == _max_chunk_capacity) { + log_debug(gc)("Can not expand overflow mark stack further, already at maximum capacity of " SIZE_FORMAT " chunks.", _chunk_capacity); return; } - size_t old_capacity = _capacity; + size_t old_capacity = _chunk_capacity; // Double capacity if possible - size_t new_capacity = MIN2(old_capacity * 2, MarkStackSizeMax); + size_t new_capacity = MIN2(old_capacity * 2, _max_chunk_capacity); if (resize(new_capacity)) { - log_debug(gc)("Expanded marking stack capacity from " SIZE_FORMAT " to " SIZE_FORMAT " elements", + log_debug(gc)("Expanded mark stack capacity from " SIZE_FORMAT " to " SIZE_FORMAT " chunks", old_capacity, new_capacity); } else { - log_warning(gc)("Failed to expand marking stack capacity from " SIZE_FORMAT " to " SIZE_FORMAT " elements", + log_warning(gc)("Failed to expand mark stack capacity from " SIZE_FORMAT " to " SIZE_FORMAT " chunks", old_capacity, new_capacity); } } G1CMMarkStack::~G1CMMarkStack() { if (_base != NULL) { - _base = NULL; - _reserved_space.release(); + MmapArrayAllocator::free(_base, _chunk_capacity); } } -void G1CMMarkStack::par_push_arr(oop* buffer, size_t n) { - MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); - size_t start = _index; - size_t next_index = start + n; - if (next_index > _capacity) { - _overflow = true; - return; - } - // Otherwise. - _index = next_index; - for (size_t i = 0; i < n; i++) { - size_t ind = start + i; - assert(ind < _capacity, "By overflow test above."); - _base[ind] = buffer[i]; - } +void G1CMMarkStack::add_chunk_to_list(OopChunk* volatile* list, OopChunk* elem) { + elem->next = *list; + *list = elem; } -bool G1CMMarkStack::par_pop_arr(oop* buffer, size_t max, size_t* n) { - MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); - size_t index = _index; - if (index == 0) { - *n = 0; +void G1CMMarkStack::add_chunk_to_chunk_list(OopChunk* elem) { + MutexLockerEx x(MarkStackChunkList_lock, Mutex::_no_safepoint_check_flag); + add_chunk_to_list(&_chunk_list, elem); + _chunks_in_chunk_list++; +} + +void G1CMMarkStack::add_chunk_to_free_list(OopChunk* elem) { + MutexLockerEx x(MarkStackFreeList_lock, Mutex::_no_safepoint_check_flag); + add_chunk_to_list(&_free_list, elem); +} + +G1CMMarkStack::OopChunk* G1CMMarkStack::remove_chunk_from_list(OopChunk* volatile* list) { + OopChunk* result = *list; + if (result != NULL) { + *list = (*list)->next; + } + return result; +} + +G1CMMarkStack::OopChunk* G1CMMarkStack::remove_chunk_from_chunk_list() { + MutexLockerEx x(MarkStackChunkList_lock, Mutex::_no_safepoint_check_flag); + OopChunk* result = remove_chunk_from_list(&_chunk_list); + if (result != NULL) { + _chunks_in_chunk_list--; + } + return result; +} + +G1CMMarkStack::OopChunk* G1CMMarkStack::remove_chunk_from_free_list() { + MutexLockerEx x(MarkStackFreeList_lock, Mutex::_no_safepoint_check_flag); + return remove_chunk_from_list(&_free_list); +} + +G1CMMarkStack::OopChunk* G1CMMarkStack::allocate_new_chunk() { + // This dirty read of _hwm is okay because we only ever increase the _hwm in parallel code. + // Further this limits _hwm to a value of _chunk_capacity + #threads, avoiding + // wraparound of _hwm. + if (_hwm >= _chunk_capacity) { + return NULL; + } + + size_t cur_idx = Atomic::add(1, &_hwm) - 1; + if (cur_idx >= _chunk_capacity) { + return NULL; + } + + OopChunk* result = ::new (&_base[cur_idx]) OopChunk; + result->next = NULL; + return result; +} + +bool G1CMMarkStack::par_push_chunk(oop* ptr_arr) { + // Get a new chunk. + OopChunk* new_chunk = remove_chunk_from_free_list(); + + if (new_chunk == NULL) { + // Did not get a chunk from the free list. Allocate from backing memory. + new_chunk = allocate_new_chunk(); + } + + if (new_chunk == NULL) { + _out_of_memory = true; return false; - } else { - size_t k = MIN2(max, index); - size_t new_ind = index - k; - for (size_t j = 0; j < k; j++) { - buffer[j] = _base[new_ind + j]; - } - _index = new_ind; - *n = k; - return true; } + + Copy::conjoint_memory_atomic(ptr_arr, new_chunk->data, OopsPerChunk * sizeof(oop)); + + add_chunk_to_chunk_list(new_chunk); + + return true; } -void G1CMMarkStack::note_start_of_gc() { - assert(_saved_index == (size_t)AllBits, "note_start_of_gc()/end_of_gc() calls bracketed incorrectly"); - _saved_index = _index; +bool G1CMMarkStack::par_pop_chunk(oop* ptr_arr) { + OopChunk* cur = remove_chunk_from_chunk_list(); + + if (cur == NULL) { + return false; + } + + Copy::conjoint_memory_atomic(cur->data, ptr_arr, OopsPerChunk * sizeof(oop)); + + add_chunk_to_free_list(cur); + return true; } -void G1CMMarkStack::note_end_of_gc() { - guarantee(!stack_modified(), "Saved index " SIZE_FORMAT " must be the same as " SIZE_FORMAT, _saved_index, _index); - - _saved_index = (size_t)AllBits; +void G1CMMarkStack::set_empty() { + _chunks_in_chunk_list = 0; + _hwm = 0; + clear_out_of_memory(); + _chunk_list = NULL; + _free_list = NULL; } G1CMRootRegions::G1CMRootRegions() : @@ -483,9 +538,8 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h, G1RegionToSpaceMapper* } } - if (!_global_mark_stack.allocate(MarkStackSize)) { + if (!_global_mark_stack.initialize(MarkStackSize, MarkStackSizeMax)) { vm_exit_during_initialization("Failed to allocate initial concurrent mark overflow mark stack."); - return; } _tasks = NEW_C_HEAP_ARRAY(G1CMTask*, _max_worker_id, mtGC); @@ -1035,6 +1089,8 @@ void G1ConcurrentMark::mark_from_roots() { // worker threads may currently exist and more may not be // available. active_workers = _parallel_workers->update_active_workers(active_workers); + log_info(gc, task)("Using %u workers of %u for marking", active_workers, _parallel_workers->total_workers()); + // Parallel task terminator is set in "set_concurrency_and_phase()" set_concurrency_and_phase(active_workers, true /* concurrent */); @@ -1693,10 +1749,10 @@ void G1ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { // oop closures will set the has_overflown flag if we overflow the // global marking stack. - assert(_global_mark_stack.overflow() || _global_mark_stack.is_empty(), - "mark stack should be empty (unless it overflowed)"); + assert(_global_mark_stack.is_out_of_memory() || _global_mark_stack.is_empty(), + "Mark stack should be empty (unless it is out of memory)"); - if (_global_mark_stack.overflow()) { + if (_global_mark_stack.is_out_of_memory()) { // This should have been done already when we tried to push an // entry on to the global mark stack. But let's do it again. set_has_overflown(); @@ -1902,7 +1958,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; @@ -2340,49 +2397,54 @@ void G1CMTask::decrease_limits() { } void G1CMTask::move_entries_to_global_stack() { - // local array where we'll store the entries that will be popped - // from the local queue - oop buffer[global_stack_transfer_size]; + // Local array where we'll store the entries that will be popped + // from the local queue. + oop buffer[G1CMMarkStack::OopsPerChunk]; - int n = 0; + size_t n = 0; oop obj; - while (n < global_stack_transfer_size && _task_queue->pop_local(obj)) { + while (n < G1CMMarkStack::OopsPerChunk && _task_queue->pop_local(obj)) { buffer[n] = obj; ++n; } + if (n < G1CMMarkStack::OopsPerChunk) { + buffer[n] = NULL; + } if (n > 0) { - // we popped at least one entry from the local queue - - if (!_cm->mark_stack_push(buffer, n)) { + if (!_cm->mark_stack_push(buffer)) { set_has_aborted(); } } - // this operation was quite expensive, so decrease the limits + // This operation was quite expensive, so decrease the limits. decrease_limits(); } -void G1CMTask::get_entries_from_global_stack() { - // local array where we'll store the entries that will be popped +bool G1CMTask::get_entries_from_global_stack() { + // Local array where we'll store the entries that will be popped // from the global stack. - oop buffer[global_stack_transfer_size]; - size_t n; - _cm->mark_stack_pop(buffer, global_stack_transfer_size, &n); - assert(n <= global_stack_transfer_size, - "we should not pop more than the given limit"); - if (n > 0) { - // yes, we did actually pop at least one entry - for (size_t i = 0; i < n; ++i) { - bool success = _task_queue->push(buffer[i]); - // We only call this when the local queue is empty or under a - // given target limit. So, we do not expect this push to fail. - assert(success, "invariant"); - } + oop buffer[G1CMMarkStack::OopsPerChunk]; + + if (!_cm->mark_stack_pop(buffer)) { + return false; } - // this operation was quite expensive, so decrease the limits + // We did actually pop at least one entry. + for (size_t i = 0; i < G1CMMarkStack::OopsPerChunk; ++i) { + oop elem = buffer[i]; + if (elem == NULL) { + break; + } + bool success = _task_queue->push(elem); + // We only call this when the local queue is empty or under a + // given target limit. So, we do not expect this push to fail. + assert(success, "invariant"); + } + + // This operation was quite expensive, so decrease the limits decrease_limits(); + return true; } void G1CMTask::drain_local_queue(bool partially) { @@ -2426,20 +2488,21 @@ void G1CMTask::drain_global_stack(bool partially) { // Decide what the target size is, depending whether we're going to // drain it partially (so that other tasks can steal if they run out - // of things to do) or totally (at the very end). Notice that, - // because we move entries from the global stack in chunks or - // because another task might be doing the same, we might in fact - // drop below the target. But, this is not a problem. - size_t target_size; + // of things to do) or totally (at the very end). + // Notice that when draining the global mark stack partially, due to the racyness + // of the mark stack size update we might in fact drop below the target. But, + // this is not a problem. + // In case of total draining, we simply process until the global mark stack is + // totally empty, disregarding the size counter. if (partially) { - target_size = _cm->partial_mark_stack_size_target(); - } else { - target_size = 0; - } - - if (_cm->mark_stack_size() > target_size) { + size_t const target_size = _cm->partial_mark_stack_size_target(); while (!has_aborted() && _cm->mark_stack_size() > target_size) { - get_entries_from_global_stack(); + if (get_entries_from_global_stack()) { + drain_local_queue(partially); + } + } + } else { + while (!has_aborted() && get_entries_from_global_stack()) { drain_local_queue(partially); } } diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp index 0331976a4a6..68cc2b42bb8 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp @@ -149,42 +149,98 @@ class G1CMBitMap : public G1CMBitMapRO { // // Stores oops in a huge buffer in virtual memory that is always fully committed. // Resizing may only happen during a STW pause when the stack is empty. +// +// Memory is allocated on a "chunk" basis, i.e. a set of oops. For this, the mark +// stack memory is split into evenly sized chunks of oops. Users can only +// add or remove entries on that basis. +// Chunks are filled in increasing address order. Not completely filled chunks +// have a NULL element as a terminating element. +// +// Every chunk has a header containing a single pointer element used for memory +// management. This wastes some space, but is negligible (< .1% with current sizing). +// +// Memory management is done using a mix of tracking a high water-mark indicating +// that all chunks at a lower address are valid chunks, and a singly linked free +// list connecting all empty chunks. class G1CMMarkStack VALUE_OBJ_CLASS_SPEC { - ReservedSpace _reserved_space; // Space currently reserved for the mark stack. +public: + // Number of oops that can fit in a single chunk. + static const size_t OopsPerChunk = 1024 - 1 /* One reference for the next pointer */; +private: + struct OopChunk { + OopChunk* next; + oop data[OopsPerChunk]; + }; - oop* _base; // Bottom address of allocated memory area. - size_t _capacity; // Maximum number of elements. - size_t _index; // One more than last occupied index. + size_t _max_chunk_capacity; // Maximum number of OopChunk elements on the stack. - size_t _saved_index; // Value of _index saved at start of GC to detect mark stack modifications during that time. + OopChunk* _base; // Bottom address of allocated memory area. + size_t _chunk_capacity; // Current maximum number of OopChunk elements. + + char _pad0[DEFAULT_CACHE_LINE_SIZE]; + OopChunk* volatile _free_list; // Linked list of free chunks that can be allocated by users. + char _pad1[DEFAULT_CACHE_LINE_SIZE - sizeof(OopChunk*)]; + OopChunk* volatile _chunk_list; // List of chunks currently containing data. + volatile size_t _chunks_in_chunk_list; + char _pad2[DEFAULT_CACHE_LINE_SIZE - sizeof(OopChunk*) - sizeof(size_t)]; + + volatile size_t _hwm; // High water mark within the reserved space. + char _pad4[DEFAULT_CACHE_LINE_SIZE - sizeof(size_t)]; + + // Allocate a new chunk from the reserved memory, using the high water mark. Returns + // NULL if out of memory. + OopChunk* allocate_new_chunk(); + + volatile bool _out_of_memory; + + // Atomically add the given chunk to the list. + void add_chunk_to_list(OopChunk* volatile* list, OopChunk* elem); + // Atomically remove and return a chunk from the given list. Returns NULL if the + // list is empty. + OopChunk* remove_chunk_from_list(OopChunk* volatile* list); + + void add_chunk_to_chunk_list(OopChunk* elem); + void add_chunk_to_free_list(OopChunk* elem); + + OopChunk* remove_chunk_from_chunk_list(); + OopChunk* remove_chunk_from_free_list(); - bool _overflow; bool _should_expand; // Resizes the mark stack to the given new capacity. Releases any previous // memory if successful. bool resize(size_t new_capacity); - bool stack_modified() const { return _index != _saved_index; } public: G1CMMarkStack(); ~G1CMMarkStack(); - bool allocate(size_t capacity); + // Alignment and minimum capacity of this mark stack in number of oops. + static size_t capacity_alignment(); - // Pushes the first "n" elements of the given buffer on the stack. - void par_push_arr(oop* buffer, size_t n); + // Allocate and initialize the mark stack with the given number of oops. + bool initialize(size_t initial_capacity, size_t max_capacity); - // Moves up to max elements from the stack into the given buffer. Returns - // the number of elements pushed, and false if the array has been empty. - // Returns true if the buffer contains at least one element. - bool par_pop_arr(oop* buffer, size_t max, size_t* n); + // Pushes the given buffer containing at most OopsPerChunk elements on the mark + // stack. If less than OopsPerChunk elements are to be pushed, the array must + // be terminated with a NULL. + // Returns whether the buffer contents were successfully pushed to the global mark + // stack. + bool par_push_chunk(oop* buffer); - bool is_empty() const { return _index == 0; } - size_t capacity() const { return _capacity; } + // Pops a chunk from this mark stack, copying them into the given buffer. This + // chunk may contain up to OopsPerChunk elements. If there are less, the last + // element in the array is a NULL pointer. + bool par_pop_chunk(oop* buffer); - bool overflow() const { return _overflow; } - void clear_overflow() { _overflow = false; } + // Return whether the chunk list is empty. Racy due to unsynchronized access to + // _chunk_list. + bool is_empty() const { return _chunk_list == NULL; } + + size_t capacity() const { return _chunk_capacity; } + + bool is_out_of_memory() const { return _out_of_memory; } + void clear_out_of_memory() { _out_of_memory = false; } bool should_expand() const { return _should_expand; } void set_should_expand(bool value) { _should_expand = value; } @@ -192,20 +248,15 @@ class G1CMMarkStack VALUE_OBJ_CLASS_SPEC { // Expand the stack, typically in response to an overflow condition void expand(); - size_t size() const { return _index; } + // Return the approximate number of oops on this mark stack. Racy due to + // unsynchronized access to _chunks_in_chunk_list. + size_t size() const { return _chunks_in_chunk_list * OopsPerChunk; } - void set_empty() { _index = 0; clear_overflow(); } + void set_empty(); - // Record the current index. - void note_start_of_gc(); - - // Make sure that we have not added any entries to the stack during GC. - void note_end_of_gc(); - - // Apply fn to each oop in the mark stack, up to the bound recorded - // via one of the above "note" functions. The mark stack must not + // Apply Fn to every oop on the mark stack. The mark stack must not // be modified while iterating. - template void iterate(Fn fn); + template void iterate(Fn fn) const PRODUCT_RETURN; }; // Root Regions are regions that are not empty at the beginning of a @@ -278,7 +329,6 @@ class G1ConcurrentMark: public CHeapObj { friend class G1CMDrainMarkingStackClosure; friend class G1CMBitMapClosure; friend class G1CMConcurrentMarkingTask; - friend class G1CMMarkStack; friend class G1CMRemarkTask; friend class G1CMTask; @@ -479,22 +529,20 @@ protected: public: // Manipulation of the global mark stack. // The push and pop operations are used by tasks for transfers - // between task-local queues and the global mark stack, and use - // locking for concurrency safety. - bool mark_stack_push(oop* arr, size_t n) { - _global_mark_stack.par_push_arr(arr, n); - if (_global_mark_stack.overflow()) { + // between task-local queues and the global mark stack. + bool mark_stack_push(oop* arr) { + if (!_global_mark_stack.par_push_chunk(arr)) { set_has_overflown(); return false; } return true; } - void mark_stack_pop(oop* arr, size_t max, size_t* n) { - _global_mark_stack.par_pop_arr(arr, max, n); + bool mark_stack_pop(oop* arr) { + return _global_mark_stack.par_pop_chunk(arr); } size_t mark_stack_size() { return _global_mark_stack.size(); } size_t partial_mark_stack_size_target() { return _global_mark_stack.capacity()/3; } - bool mark_stack_overflow() { return _global_mark_stack.overflow(); } + bool mark_stack_overflow() { return _global_mark_stack.is_out_of_memory(); } bool mark_stack_empty() { return _global_mark_stack.is_empty(); } G1CMRootRegions* root_regions() { return &_root_regions; } @@ -599,16 +647,6 @@ public: // read-only, so use this carefully! void clearRangePrevBitmap(MemRegion mr); - // Notify data structures that a GC has started. - void note_start_of_gc() { - _global_mark_stack.note_start_of_gc(); - } - - // Notify data structures that a GC is finished. - void note_end_of_gc() { - _global_mark_stack.note_end_of_gc(); - } - // Verify that there are no CSet oops on the stacks (taskqueues / // global mark stack) and fingers (global / per-task). // If marking is not in progress, it's a no-op. @@ -670,10 +708,7 @@ private: // references reaches this limit refs_reached_period = 384, // Initial value for the hash seed, used in the work stealing code - init_hash_seed = 17, - // How many entries will be transferred between global stack and - // local queues at once. - global_stack_transfer_size = 1024 + init_hash_seed = 17 }; uint _worker_id; @@ -858,9 +893,10 @@ public: // It pushes an object on the local queue. inline void push(oop obj); - // These two move entries to/from the global stack. + // Move entries to the global stack. void move_entries_to_global_stack(); - void get_entries_from_global_stack(); + // Move entries from the global stack, return true if we were successful to do so. + bool get_entries_from_global_stack(); // It pops and scans objects from the local queue. If partially is // true, then it stops when the queue size is of a given limit. If diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.inline.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.inline.hpp index 40336ae6885..af42c85920c 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.inline.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.inline.hpp @@ -89,14 +89,28 @@ inline bool G1CMBitMap::parMark(HeapWord* addr) { #undef check_mark +#ifndef PRODUCT template -inline void G1CMMarkStack::iterate(Fn fn) { +inline void G1CMMarkStack::iterate(Fn fn) const { assert_at_safepoint(true); - assert(!stack_modified(), "Saved index " SIZE_FORMAT " must be the same as " SIZE_FORMAT, _saved_index, _index); - for (size_t i = 0; i < _index; ++i) { - fn(_base[i]); + + size_t num_chunks = 0; + + OopChunk* cur = _chunk_list; + while (cur != NULL) { + guarantee(num_chunks <= _chunks_in_chunk_list, "Found " SIZE_FORMAT " oop chunks which is more than there should be", num_chunks); + + for (size_t i = 0; i < OopsPerChunk; ++i) { + if (cur->data[i] == NULL) { + break; + } + fn(cur->data[i]); + } + cur = cur->next; + num_chunks++; } } +#endif // It scans an object and visits its children. inline void G1CMTask::scan_object(oop obj) { process_grey_object(obj); } diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 454f73bc0c6..803c1b62d79 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -885,6 +885,15 @@ bool G1DefaultPolicy::adaptive_young_list_length() const { return _young_gen_sizer.adaptive_young_list_length(); } +size_t G1DefaultPolicy::desired_survivor_size() const { + size_t const survivor_capacity = HeapRegion::GrainWords * _max_survivor_regions; + return (size_t)((((double)survivor_capacity) * TargetSurvivorRatio) / 100); +} + +void G1DefaultPolicy::print_age_table() { + _survivors_age_table.print_age_table(_tenuring_threshold); +} + void G1DefaultPolicy::update_max_gc_locker_expansion() { uint expansion_region_num = 0; if (GCLockerEdenExpansionPercent > 0) { @@ -908,8 +917,11 @@ void G1DefaultPolicy::update_survivors_policy() { // smaller than 1.0) we'll get 1. _max_survivor_regions = (uint) ceil(max_survivor_regions_d); - _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( - HeapRegion::GrainWords * _max_survivor_regions, _policy_counters); + _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(desired_survivor_size()); + if (UsePerfData) { + _policy_counters->tenuring_threshold()->set_value(_tenuring_threshold); + _policy_counters->desired_survivor_size()->set_value(desired_survivor_size() * oopSize); + } } bool G1DefaultPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp index 21ab55a4ab4..6eba7e76e20 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -360,6 +360,8 @@ private: AgeTable _survivors_age_table; +protected: + size_t desired_survivor_size() const; public: uint tenuring_threshold() const { return _tenuring_threshold; } @@ -379,6 +381,8 @@ public: _survivors_age_table.merge(age_table); } + void print_age_table(); + void update_max_gc_locker_expansion(); void update_survivors_policy(); 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/g1OopClosures.hpp b/hotspot/src/share/vm/gc/g1/g1OopClosures.hpp index 5de38f71bd2..bc594ed86e9 100644 --- a/hotspot/src/share/vm/gc/g1/g1OopClosures.hpp +++ b/hotspot/src/share/vm/gc/g1/g1OopClosures.hpp @@ -34,7 +34,6 @@ class G1RemSet; class G1ConcurrentMark; class DirtyCardToOopClosure; class G1CMBitMap; -class G1CMMarkStack; class G1ParScanThreadState; class G1CMTask; class ReferenceProcessor; diff --git a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp index 7f419bd409f..254baeab68e 100644 --- a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp +++ b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp @@ -24,8 +24,10 @@ #include "precompiled.hpp" #include "gc/g1/g1PageBasedVirtualSpace.hpp" +#include "gc/shared/workgroup.hpp" #include "oops/markOop.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.hpp" #include "runtime/os.inline.hpp" #include "services/memTracker.hpp" #include "utilities/bitMap.inline.hpp" @@ -177,7 +179,7 @@ void G1PageBasedVirtualSpace::pretouch_internal(size_t start_page, size_t end_pa guarantee(start_page < end_page, "Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page); - os::pretouch_memory(page_start(start_page), bounded_end_addr(end_page)); + os::pretouch_memory(page_start(start_page), bounded_end_addr(end_page), _page_size); } bool G1PageBasedVirtualSpace::commit(size_t start_page, size_t size_in_pages) { @@ -198,9 +200,6 @@ bool G1PageBasedVirtualSpace::commit(size_t start_page, size_t size_in_pages) { } _committed.set_range(start_page, end_page); - if (AlwaysPreTouch) { - pretouch_internal(start_page, end_page); - } return zero_filled; } @@ -227,6 +226,53 @@ void G1PageBasedVirtualSpace::uncommit(size_t start_page, size_t size_in_pages) _committed.clear_range(start_page, end_page); } +class G1PretouchTask : public AbstractGangTask { +private: + char* volatile _cur_addr; + char* const _start_addr; + char* const _end_addr; + size_t const _page_size; +public: + G1PretouchTask(char* start_address, char* end_address, size_t page_size) : + AbstractGangTask("G1 PreTouch", + Universe::is_fully_initialized() ? GCId::current_raw() : + // During VM initialization there is + // no GC cycle that this task can be + // associated with. + GCId::undefined()), + _cur_addr(start_address), + _start_addr(start_address), + _end_addr(end_address), + _page_size(page_size) { + } + + virtual void work(uint worker_id) { + size_t const actual_chunk_size = MAX2(chunk_size(), _page_size); + while (true) { + char* touch_addr = (char*)Atomic::add_ptr((intptr_t)actual_chunk_size, (volatile void*) &_cur_addr) - actual_chunk_size; + if (touch_addr < _start_addr || touch_addr >= _end_addr) { + break; + } + char* end_addr = touch_addr + MIN2(actual_chunk_size, pointer_delta(_end_addr, touch_addr, sizeof(char))); + os::pretouch_memory(touch_addr, end_addr, _page_size); + } + } + + static size_t chunk_size() { return PreTouchParallelChunkSize; } +}; + +void G1PageBasedVirtualSpace::pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang) { + guarantee(pretouch_gang != NULL, "No pretouch gang specified."); + + size_t num_chunks = MAX2((size_t)1, size_in_pages * _page_size / MAX2(G1PretouchTask::chunk_size(), _page_size)); + + uint num_workers = MIN2((uint)num_chunks, pretouch_gang->active_workers()); + G1PretouchTask cl(page_start(start_page), bounded_end_addr(start_page + size_in_pages), _page_size); + log_debug(gc, heap)("Running %s with %u workers for " SIZE_FORMAT " work units pre-touching " SIZE_FORMAT "B.", + cl.name(), num_workers, num_chunks, size_in_pages * _page_size); + pretouch_gang->run_task(&cl, num_workers); +} + bool G1PageBasedVirtualSpace::contains(const void* p) const { return _low_boundary <= (const char*) p && (const char*) p < _high_boundary; } diff --git a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp index ed16fac9553..f684c103f0b 100644 --- a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp +++ b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp @@ -30,6 +30,8 @@ #include "memory/virtualspace.hpp" #include "utilities/bitMap.hpp" +class WorkGang; + // Virtual space management helper for a virtual space with an OS page allocation // granularity. // (De-)Allocation requests are always OS page aligned by passing a page index @@ -117,6 +119,8 @@ class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC { // Uncommit the given area of pages starting at start being size_in_pages large. void uncommit(size_t start_page, size_t size_in_pages); + void pretouch(size_t start_page, size_t size_in_pages, WorkGang* pretouch_gang = NULL); + // Initialize the given reserved space with the given base address and the size // actually used. // Prefer to commit in page_size chunks. diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 78240032d2d..92aa6050e70 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -181,6 +181,9 @@ public: virtual void note_stop_adding_survivor_regions() = 0; virtual void record_age_table(AgeTable* age_table) = 0; + virtual void print_age_table() = 0; +protected: + virtual size_t desired_survivor_size() const = 0; }; #endif // SHARE_VM_GC_G1_G1POLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1Predictions.cpp b/hotspot/src/share/vm/gc/g1/g1Predictions.cpp deleted file mode 100644 index 12092beeca4..00000000000 --- a/hotspot/src/share/vm/gc/g1/g1Predictions.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 - * 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 "precompiled.hpp" -#include "gc/g1/g1Predictions.hpp" - -#ifndef PRODUCT - -void G1Predictions::test() { - double const epsilon = 1e-6; - { - // Some basic formula tests with confidence = 0.0 - G1Predictions predictor(0.0); - TruncatedSeq s; - - double p0 = predictor.get_new_prediction(&s); - assert(p0 < epsilon, "Initial prediction of empty sequence must be 0.0 but is %f", p0); - - s.add(5.0); - double p1 = predictor.get_new_prediction(&s); - assert(fabs(p1 - 5.0) < epsilon, "Prediction should be 5.0 but is %f", p1); - for (int i = 0; i < 40; i++) { - s.add(5.0); - } - double p2 = predictor.get_new_prediction(&s); - assert(fabs(p2 - 5.0) < epsilon, "Prediction should be 5.0 but is %f", p1); - } - - { - // The following tests checks that the initial predictions are based on the - // average of the sequence and not on the stddev (which is 0). - G1Predictions predictor(0.5); - TruncatedSeq s; - - s.add(1.0); - double p1 = predictor.get_new_prediction(&s); - assert(p1 > 1.0, "First prediction must be larger than average, but avg is %f and prediction %f", s.davg(), p1); - s.add(1.0); - double p2 = predictor.get_new_prediction(&s); - assert(p2 < p1, "First prediction must be larger than second, but they are %f %f", p1, p2); - s.add(1.0); - double p3 = predictor.get_new_prediction(&s); - assert(p3 < p2, "Second prediction must be larger than third, but they are %f %f", p2, p3); - s.add(1.0); - s.add(1.0); // Five elements are now in the sequence. - double p5 = predictor.get_new_prediction(&s); - assert(p5 < p3, "Fifth prediction must be smaller than third, but they are %f %f", p3, p5); - assert(fabs(p5 - 1.0) < epsilon, "Prediction must be 1.0+epsilon, but is %f", p5); - } - - { - // The following tests checks that initially prediction based on the average is - // used, that gets overridden by the stddev prediction at the end. - G1Predictions predictor(0.5); - TruncatedSeq s; - - s.add(0.5); - double p1 = predictor.get_new_prediction(&s); - assert(p1 > 0.5, "First prediction must be larger than average, but avg is %f and prediction %f", s.davg(), p1); - s.add(0.2); - double p2 = predictor.get_new_prediction(&s); - assert(p2 < p1, "First prediction must be larger than second, but they are %f %f", p1, p2); - s.add(0.5); - double p3 = predictor.get_new_prediction(&s); - assert(p3 < p2, "Second prediction must be larger than third, but they are %f %f", p2, p3); - s.add(0.2); - s.add(2.0); - double p5 = predictor.get_new_prediction(&s); - assert(p5 > p3, "Fifth prediction must be bigger than third, but they are %f %f", p3, p5); - } -} - -void TestPredictions_test() { - G1Predictions::test(); -} - -#endif diff --git a/hotspot/src/share/vm/gc/g1/g1Predictions.hpp b/hotspot/src/share/vm/gc/g1/g1Predictions.hpp index 6dad458e546..bcd430e7385 100644 --- a/hotspot/src/share/vm/gc/g1/g1Predictions.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Predictions.hpp @@ -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 @@ -57,10 +57,6 @@ class G1Predictions VALUE_OBJ_CLASS_SPEC { double get_new_prediction(TruncatedSeq const* seq) const { return seq->davg() + _sigma * stddev_estimate(seq); } - -#ifndef PRODUCT - static void test(); -#endif }; #endif // SHARE_VM_GC_G1_G1PREDICTIONS_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp index 80b794153ed..efcd5ce7e92 100644 --- a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp @@ -66,8 +66,12 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity"); } - virtual void commit_regions(uint start_idx, size_t num_regions) { - bool zero_filled = _storage.commit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); + virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) { + size_t const start_page = (size_t)start_idx * _pages_per_region; + bool zero_filled = _storage.commit(start_page, num_regions * _pages_per_region); + if (AlwaysPreTouch) { + _storage.pretouch(start_page, num_regions * _pages_per_region, pretouch_gang); + } _commit_map.set_range(start_idx, start_idx + num_regions); fire_on_commit(start_idx, num_regions, zero_filled); } @@ -110,19 +114,38 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_size_up(rs.size(), page_size)), page_size); } - virtual void commit_regions(uint start_idx, size_t num_regions) { + virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) { + size_t const NoPage = ~(size_t)0; + + size_t first_committed = NoPage; + size_t num_committed = 0; + + bool all_zero_filled = true; + for (uint i = start_idx; i < start_idx + num_regions; i++) { assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i); size_t idx = region_idx_to_page_idx(i); uint old_refcount = _refcounts.get_by_index(idx); + bool zero_filled = false; if (old_refcount == 0) { + if (first_committed == NoPage) { + first_committed = idx; + num_committed = 1; + } else { + num_committed++; + } zero_filled = _storage.commit(idx, 1); } + all_zero_filled &= zero_filled; + _refcounts.set_by_index(idx, old_refcount + 1); _commit_map.set_bit(i); - fire_on_commit(i, 1, zero_filled); } + if (AlwaysPreTouch && num_committed > 0) { + _storage.pretouch(first_committed, num_committed, pretouch_gang); + } + fire_on_commit(start_idx, num_regions, all_zero_filled); } virtual void uncommit_regions(uint start_idx, size_t num_regions) { diff --git a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp index 218ae1550ae..bcde9a5aa04 100644 --- a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp @@ -29,6 +29,8 @@ #include "memory/allocation.hpp" #include "utilities/debug.hpp" +class WorkGang; + class G1MappingChangedListener VALUE_OBJ_CLASS_SPEC { public: // Fired after commit of the memory, i.e. the memory this listener is registered @@ -68,7 +70,7 @@ class G1RegionToSpaceMapper : public CHeapObj { return _commit_map.at(idx); } - virtual void commit_regions(uint start_idx, size_t num_regions = 1) = 0; + virtual void commit_regions(uint start_idx, size_t num_regions = 1, WorkGang* pretouch_workers = NULL) = 0; virtual void uncommit_regions(uint start_idx, size_t num_regions = 1) = 0; // Creates an appropriate G1RegionToSpaceMapper for the given parameters. 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/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp index 33d8268855d..6944bcf0c44 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp @@ -352,35 +352,6 @@ void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark, _prev_marked_bytes = marked_bytes; } -HeapWord* -HeapRegion::object_iterate_mem_careful(MemRegion mr, - ObjectClosure* cl) { - G1CollectedHeap* g1h = G1CollectedHeap::heap(); - // We used to use "block_start_careful" here. But we're actually happy - // to update the BOT while we do this... - HeapWord* cur = block_start(mr.start()); - mr = mr.intersection(used_region()); - if (mr.is_empty()) return NULL; - // Otherwise, find the obj that extends onto mr.start(). - - assert(cur <= mr.start() - && (oop(cur)->klass_or_null() == NULL || - cur + oop(cur)->size() > mr.start()), - "postcondition of block_start"); - oop obj; - while (cur < mr.end()) { - obj = oop(cur); - if (obj->klass_or_null() == NULL) { - // Ran into an unparseable point. - return cur; - } else if (!g1h->is_obj_dead(obj)) { - cl->do_object(obj); - } - cur += block_size(cur); - } - return NULL; -} - HeapWord* HeapRegion:: oops_on_card_seq_iterate_careful(MemRegion mr, diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.hpp b/hotspot/src/share/vm/gc/g1/heapRegion.hpp index f4bf95e055b..9542b9ffb11 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp @@ -653,17 +653,6 @@ class HeapRegion: public G1ContiguousSpace { } } - // Requires that "mr" be entirely within the region. - // Apply "cl->do_object" to all objects that intersect with "mr". - // If the iteration encounters an unparseable portion of the region, - // or if "cl->abort()" is true after a closure application, - // terminate the iteration and return the address of the start of the - // subregion that isn't done. (The two can be distinguished by querying - // "cl->abort()".) Return of "NULL" indicates that the iteration - // completed. - HeapWord* - object_iterate_mem_careful(MemRegion mr, ObjectClosure* cl); - // filter_young: if true and the region is a young region then we // skip the iteration. // card_ptr: if not NULL, and we decide that the card is not young diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp index 06b04eeefea..f0887f93688 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, 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 @@ -72,22 +72,22 @@ HeapRegion* HeapRegionManager::new_heap_region(uint hrm_index) { return g1h->new_heap_region(hrm_index, mr); } -void HeapRegionManager::commit_regions(uint index, size_t num_regions) { +void HeapRegionManager::commit_regions(uint index, size_t num_regions, WorkGang* pretouch_gang) { guarantee(num_regions > 0, "Must commit more than zero regions"); guarantee(_num_committed + num_regions <= max_length(), "Cannot commit more than the maximum amount of regions"); _num_committed += (uint)num_regions; - _heap_mapper->commit_regions(index, num_regions); + _heap_mapper->commit_regions(index, num_regions, pretouch_gang); // Also commit auxiliary data - _prev_bitmap_mapper->commit_regions(index, num_regions); - _next_bitmap_mapper->commit_regions(index, num_regions); + _prev_bitmap_mapper->commit_regions(index, num_regions, pretouch_gang); + _next_bitmap_mapper->commit_regions(index, num_regions, pretouch_gang); - _bot_mapper->commit_regions(index, num_regions); - _cardtable_mapper->commit_regions(index, num_regions); + _bot_mapper->commit_regions(index, num_regions, pretouch_gang); + _cardtable_mapper->commit_regions(index, num_regions, pretouch_gang); - _card_counts_mapper->commit_regions(index, num_regions); + _card_counts_mapper->commit_regions(index, num_regions, pretouch_gang); } void HeapRegionManager::uncommit_regions(uint start, size_t num_regions) { @@ -117,12 +117,13 @@ void HeapRegionManager::uncommit_regions(uint start, size_t num_regions) { _card_counts_mapper->uncommit_regions(start, num_regions); } -void HeapRegionManager::make_regions_available(uint start, uint num_regions) { +void HeapRegionManager::make_regions_available(uint start, uint num_regions, WorkGang* pretouch_gang) { guarantee(num_regions > 0, "No point in calling this for zero regions"); - commit_regions(start, num_regions); + commit_regions(start, num_regions, pretouch_gang); 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); } @@ -162,11 +163,11 @@ MemoryUsage HeapRegionManager::get_auxiliary_data_memory_usage() const { return MemoryUsage(0, used_sz, committed_sz, committed_sz); } -uint HeapRegionManager::expand_by(uint num_regions) { - return expand_at(0, num_regions); +uint HeapRegionManager::expand_by(uint num_regions, WorkGang* pretouch_workers) { + return expand_at(0, num_regions, pretouch_workers); } -uint HeapRegionManager::expand_at(uint start, uint num_regions) { +uint HeapRegionManager::expand_at(uint start, uint num_regions, WorkGang* pretouch_workers) { if (num_regions == 0) { return 0; } @@ -180,7 +181,7 @@ uint HeapRegionManager::expand_at(uint start, uint num_regions) { while (expanded < num_regions && (num_last_found = find_unavailable_from_idx(cur, &idx_last_found)) > 0) { uint to_expand = MIN2(num_regions - expanded, num_last_found); - make_regions_available(idx_last_found, to_expand); + make_regions_available(idx_last_found, to_expand, pretouch_workers); expanded += to_expand; cur = idx_last_found + num_last_found + 1; } diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp index 8644d3e56e6..07c84da348b 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, 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 @@ -34,6 +34,7 @@ class HeapRegion; class HeapRegionClosure; class HeapRegionClaimer; class FreeRegionList; +class WorkGang; class G1HeapRegionTable : public G1BiasedMappedArray { protected: @@ -94,10 +95,10 @@ class HeapRegionManager: public CHeapObj { HeapWord* heap_bottom() const { return _regions.bottom_address_mapped(); } HeapWord* heap_end() const {return _regions.end_address_mapped(); } - void make_regions_available(uint index, uint num_regions = 1); + void make_regions_available(uint index, uint num_regions = 1, WorkGang* pretouch_gang = NULL); // Pass down commit calls to the VirtualSpace. - void commit_regions(uint index, size_t num_regions = 1); + void commit_regions(uint index, size_t num_regions = 1, WorkGang* pretouch_gang = NULL); void uncommit_regions(uint index, size_t num_regions = 1); // Notify other data structures about change in the heap layout. @@ -209,12 +210,12 @@ public: // HeapRegions, or re-use existing ones. Returns the number of regions the // sequence was expanded by. If a HeapRegion allocation fails, the resulting // number of regions might be smaller than what's desired. - uint expand_by(uint num_regions); + uint expand_by(uint num_regions, WorkGang* pretouch_workers = NULL); // Makes sure that the regions from start to start+num_regions-1 are available // for allocation. Returns the number of regions that were committed to achieve // this. - uint expand_at(uint start, uint num_regions); + uint expand_at(uint start, uint num_regions, WorkGang* pretouch_workers = NULL); // Find a contiguous set of empty regions of length num. Returns the start index of // that set, or G1_NO_HRM_INDEX. diff --git a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp index 333499a0a97..148fe80e3ef 100644 --- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp +++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp @@ -204,14 +204,6 @@ void VM_G1IncCollectionPause::doit_epilogue() { } } -void VM_CGC_Operation::acquire_pending_list_lock() { - _pending_list_locker.lock(); -} - -void VM_CGC_Operation::release_and_notify_pending_list_lock() { - _pending_list_locker.unlock(); -} - void VM_CGC_Operation::doit() { GCIdMark gc_id_mark(_gc_id); GCTraceCPUTime tcpu; @@ -222,20 +214,13 @@ void VM_CGC_Operation::doit() { } bool VM_CGC_Operation::doit_prologue() { - // Note the relative order of the locks must match that in - // VM_GC_Operation::doit_prologue() or deadlocks can occur - if (_needs_pending_list_lock) { - acquire_pending_list_lock(); - } Heap_lock->lock(); return true; } void VM_CGC_Operation::doit_epilogue() { - // Note the relative order of the unlocks must match that in - // VM_GC_Operation::doit_epilogue() - Heap_lock->unlock(); - if (_needs_pending_list_lock) { - release_and_notify_pending_list_lock(); + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); } + Heap_lock->unlock(); } diff --git a/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp b/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp index 5aab7096586..94844f72881 100644 --- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp +++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.hpp @@ -27,7 +27,6 @@ #include "gc/g1/g1AllocationContext.hpp" #include "gc/shared/gcId.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/vmGCOperations.hpp" // VM_operations for the G1 collector. @@ -103,20 +102,13 @@ public: // Concurrent GC stop-the-world operations such as remark and cleanup; // consider sharing these with CMS's counterparts. class VM_CGC_Operation: public VM_Operation { - VoidClosure* _cl; - const char* _printGCMessage; - bool _needs_pending_list_lock; - ReferencePendingListLocker _pending_list_locker; - uint _gc_id; - -protected: - // java.lang.ref.Reference support - void acquire_pending_list_lock(); - void release_and_notify_pending_list_lock(); + VoidClosure* _cl; + const char* _printGCMessage; + uint _gc_id; public: - VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg, bool needs_pending_list_lock) - : _cl(cl), _printGCMessage(printGCMsg), _needs_pending_list_lock(needs_pending_list_lock), _gc_id(GCId::current()) {} + VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg) + : _cl(cl), _printGCMessage(printGCMsg), _gc_id(GCId::current()) {} virtual VMOp_Type type() const { return VMOp_CGC_Operation; } virtual void doit(); virtual bool doit_prologue(); diff --git a/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp index c8554287512..8f27dd13729 100644 --- a/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp @@ -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 @@ -1133,18 +1133,3 @@ bool PSAdaptiveSizePolicy::print() const { return false; } - -#ifndef PRODUCT - -void TestOldFreeSpaceCalculation_test() { - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 20) == 25, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 50) == 100, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 60) == 150, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 75) == 300, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 20) == 100, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 50) == 400, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 60) == 600, "Calculation of free memory failed"); - assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 75) == 1200, "Calculation of free memory failed"); -} - -#endif /* !PRODUCT */ diff --git a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp index 147bc06d305..e7f96a22228 100644 --- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp @@ -564,9 +564,18 @@ HeapWord* DefNewGeneration::expand_and_allocate(size_t size, void DefNewGeneration::adjust_desired_tenuring_threshold() { // Set the desired survivor size to half the real survivor space - GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters(); - _tenuring_threshold = - age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters); + size_t const survivor_capacity = to()->capacity() / HeapWordSize; + size_t const desired_survivor_size = (size_t)((((double)survivor_capacity) * TargetSurvivorRatio) / 100); + + _tenuring_threshold = age_table()->compute_tenuring_threshold(desired_survivor_size); + + if (UsePerfData) { + GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters(); + gc_counters->tenuring_threshold()->set_value(_tenuring_threshold); + gc_counters->desired_survivor_size()->set_value(desired_survivor_size * oopSize); + } + + age_table()->print_age_table(_tenuring_threshold); } void DefNewGeneration::collect(bool full, diff --git a/hotspot/src/share/vm/gc/shared/ageTable.cpp b/hotspot/src/share/vm/gc/shared/ageTable.cpp index 48ddfa1e492..d2a76cff1d0 100644 --- a/hotspot/src/share/vm/gc/shared/ageTable.cpp +++ b/hotspot/src/share/vm/gc/shared/ageTable.cpp @@ -27,7 +27,6 @@ #include "gc/shared/ageTableTracer.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectorPolicy.hpp" -#include "gc/shared/gcPolicyCounters.hpp" #include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "oops/oop.inline.hpp" @@ -75,8 +74,7 @@ void AgeTable::merge(AgeTable* subTable) { } } -uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters) { - size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); +uint AgeTable::compute_tenuring_threshold(size_t desired_survivor_size) { uint result; if (AlwaysTenure || NeverTenure) { @@ -99,9 +97,16 @@ uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCoun log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")", - desired_survivor_size*oopSize, (uintx) result, MaxTenuringThreshold); + desired_survivor_size * oopSize, (uintx) result, MaxTenuringThreshold); + return result; +} + +void AgeTable::print_age_table(uint tenuring_threshold) { if (log_is_enabled(Trace, gc, age) || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) { + log_trace(gc, age)("Age table with threshold %u (max threshold " UINTX_FORMAT ")", + tenuring_threshold, MaxTenuringThreshold); + size_t total = 0; uint age = 1; while (age < table_size) { @@ -109,20 +114,14 @@ uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCoun total += wordSize; if (wordSize > 0) { log_trace(gc, age)("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total", - age, wordSize*oopSize, total*oopSize); + age, wordSize * oopSize, total * oopSize); } - AgeTableTracer::send_tenuring_distribution_event(age, wordSize*oopSize); + AgeTableTracer::send_tenuring_distribution_event(age, wordSize * oopSize); if (UsePerfData) { - _perf_sizes[age]->set_value(wordSize*oopSize); + _perf_sizes[age]->set_value(wordSize * oopSize); } age++; } - if (UsePerfData) { - gc_counters->tenuring_threshold()->set_value(result); - gc_counters->desired_survivor_size()->set_value( - desired_survivor_size*oopSize); - } } - - return result; } + diff --git a/hotspot/src/share/vm/gc/shared/ageTable.hpp b/hotspot/src/share/vm/gc/shared/ageTable.hpp index 4af836f8acd..858ae0ae5dd 100644 --- a/hotspot/src/share/vm/gc/shared/ageTable.hpp +++ b/hotspot/src/share/vm/gc/shared/ageTable.hpp @@ -29,8 +29,6 @@ #include "oops/oop.hpp" #include "runtime/perfData.hpp" -class GCPolicyCounters; - /* Copyright (c) 1992, 2016, Oracle and/or its affiliates, and Stanford University. See the LICENSE file for license information. */ @@ -67,10 +65,12 @@ class AgeTable VALUE_OBJ_CLASS_SPEC { // for parallel young generation gc. void merge(AgeTable* subTable); - // calculate new tenuring threshold based on age information - uint compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters); + // Calculate new tenuring threshold based on age information. + uint compute_tenuring_threshold(size_t desired_survivor_size); + void print_age_table(uint tenuring_threshold); private: + PerfVariable* _perf_sizes[table_size]; }; diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp index 303252369e4..d5ae7733114 100644 --- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp @@ -304,9 +304,6 @@ class CollectedHeap : public CHeapObj { inline static oop array_allocate_nozero(KlassHandle klass, int size, int length, TRAPS); inline static oop class_allocate(KlassHandle klass, int size, TRAPS); - inline static void post_allocation_install_obj_klass(KlassHandle klass, - oop obj); - // Raw memory allocation facilities // The obj and array allocate methods are covers for these methods. // mem_allocate() should never be @@ -441,12 +438,6 @@ class CollectedHeap : public CHeapObj { // remembered set. virtual void flush_deferred_store_barrier(JavaThread* thread); - // Should return true if the reference pending list lock is - // acquired from non-Java threads, such as a concurrent GC thread. - virtual bool needs_reference_pending_list_locker_thread() const { - return false; - } - // Perform a collection of the heap; intended for use in implementing // "System.gc". This probably implies as full a collection as the // "CollectedHeap" supports. diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp b/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp index 36ef86f98c9..cd54e1fdc5b 100644 --- a/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp @@ -41,14 +41,22 @@ // Inline allocation implementations. void CollectedHeap::post_allocation_setup_common(KlassHandle klass, - HeapWord* obj) { - post_allocation_setup_no_klass_install(klass, obj); - post_allocation_install_obj_klass(klass, oop(obj)); + HeapWord* obj_ptr) { + post_allocation_setup_no_klass_install(klass, obj_ptr); + oop obj = (oop)obj_ptr; +#if ! INCLUDE_ALL_GCS + obj->set_klass(klass()); +#else + // Need a release store to ensure array/class length, mark word, and + // object zeroing are visible before setting the klass non-NULL, for + // concurrent collectors. + obj->release_set_klass(klass()); +#endif } void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, - HeapWord* objPtr) { - oop obj = (oop)objPtr; + HeapWord* obj_ptr) { + oop obj = (oop)obj_ptr; assert(obj != NULL, "NULL object pointer"); if (UseBiasedLocking && (klass() != NULL)) { @@ -59,18 +67,6 @@ void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, } } -void CollectedHeap::post_allocation_install_obj_klass(KlassHandle klass, - oop obj) { - // These asserts are kind of complicated because of klassKlass - // and the beginning of the world. - assert(klass() != NULL || !Universe::is_fully_initialized(), "NULL klass"); - assert(klass() == NULL || klass()->is_klass(), "not a klass"); - assert(obj != NULL, "NULL object pointer"); - obj->set_klass(klass()); - assert(!Universe::is_fully_initialized() || obj->klass() != NULL, - "missing klass"); -} - // Support for jvmti and dtrace inline void post_allocation_notify(KlassHandle klass, oop obj, int size) { // support low memory notifications (no-op if not enabled) @@ -88,25 +84,26 @@ inline void post_allocation_notify(KlassHandle klass, oop obj, int size) { } void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, - HeapWord* obj, + HeapWord* obj_ptr, int size) { - post_allocation_setup_common(klass, obj); + post_allocation_setup_common(klass, obj_ptr); + oop obj = (oop)obj_ptr; assert(Universe::is_bootstrapping() || - !((oop)obj)->is_array(), "must not be an array"); + !obj->is_array(), "must not be an array"); // notify jvmti and dtrace - post_allocation_notify(klass, (oop)obj, size); + post_allocation_notify(klass, obj, size); } void CollectedHeap::post_allocation_setup_class(KlassHandle klass, - HeapWord* obj, + HeapWord* obj_ptr, int size) { - // Set oop_size field before setting the _klass field - // in post_allocation_setup_common() because the klass field - // indicates that the object is parsable by concurrent GC. - oop new_cls = (oop)obj; + // Set oop_size field before setting the _klass field because a + // non-NULL _klass field indicates that the object is parsable by + // concurrent GC. + oop new_cls = (oop)obj_ptr; assert(size > 0, "oop_size must be positive."); java_lang_Class::set_oop_size(new_cls, size); - post_allocation_setup_common(klass, obj); + post_allocation_setup_common(klass, obj_ptr); assert(Universe::is_bootstrapping() || !new_cls->is_array(), "must not be an array"); // notify jvmti and dtrace @@ -114,15 +111,15 @@ void CollectedHeap::post_allocation_setup_class(KlassHandle klass, } void CollectedHeap::post_allocation_setup_array(KlassHandle klass, - HeapWord* obj, + HeapWord* obj_ptr, int length) { - // Set array length before setting the _klass field - // in post_allocation_setup_common() because the klass field - // indicates that the object is parsable by concurrent GC. + // Set array length before setting the _klass field because a + // non-NULL klass field indicates that the object is parsable by + // concurrent GC. assert(length >= 0, "length should be non-negative"); - ((arrayOop)obj)->set_length(length); - post_allocation_setup_common(klass, obj); - oop new_obj = (oop)obj; + ((arrayOop)obj_ptr)->set_length(length); + post_allocation_setup_common(klass, obj_ptr); + oop new_obj = (oop)obj_ptr; assert(new_obj->is_array(), "must be an array"); // notify jvmti and dtrace (must be after length is set for dtrace) post_allocation_notify(klass, new_obj, new_obj->size()); 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/gc/shared/genCollectedHeap.hpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp index f4a7e252942..9a469d14f7d 100644 --- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp @@ -281,10 +281,6 @@ public: return UseConcMarkSweepGC; } - virtual bool needs_reference_pending_list_locker_thread() const { - return UseConcMarkSweepGC; - } - // We don't need barriers for stores to objects in the // young gen and, a fortiori, for initializing stores to // objects therein. This applies to DefNew+Tenured and ParNew+CMS diff --git a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp b/hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp deleted file mode 100644 index 0c35d65aeee..00000000000 --- a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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 "precompiled.hpp" -#include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/referencePendingListLocker.hpp" -#include "memory/universe.hpp" -#include "runtime/javaCalls.hpp" -#include "utilities/preserveException.hpp" - -ReferencePendingListLockerThread::ReferencePendingListLockerThread() : - JavaThread(&start), - _monitor(Monitor::nonleaf, "ReferencePendingListLocker", false, Monitor::_safepoint_check_sometimes), - _message(NONE) {} - -ReferencePendingListLockerThread* ReferencePendingListLockerThread::create(TRAPS) { - // Create Java thread objects - instanceKlassHandle thread_klass = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL); - instanceHandle thread_object = thread_klass->allocate_instance_handle(CHECK_NULL); - Handle thread_name = java_lang_String::create_from_str("Reference Pending List Locker", CHECK_NULL); - Handle thread_group = Universe::system_thread_group(); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, - thread_object, - thread_klass, - vmSymbols::object_initializer_name(), - vmSymbols::threadgroup_string_void_signature(), - thread_group, - thread_name, - CHECK_NULL); - - { - MutexLocker ml(Threads_lock); - - // Allocate thread - ReferencePendingListLockerThread* thread = new ReferencePendingListLockerThread(); - if (thread == NULL || thread->osthread() == NULL) { - vm_exit_during_initialization("java.lang.OutOfMemoryError", - os::native_thread_creation_failed_msg()); - } - - // Initialize thread - java_lang_Thread::set_thread(thread_object(), thread); - java_lang_Thread::set_priority(thread_object(), NearMaxPriority); - java_lang_Thread::set_daemon(thread_object()); - thread->set_threadObj(thread_object()); - - // Start thread - Threads::add(thread); - Thread::start(thread); - - return thread; - } -} - -void ReferencePendingListLockerThread::start(JavaThread* thread, TRAPS) { - ReferencePendingListLockerThread* locker_thread = static_cast(thread); - locker_thread->receive_and_handle_messages(); -} - -bool ReferencePendingListLockerThread::is_hidden_from_external_view() const { - return true; -} - -void ReferencePendingListLockerThread::send_message(Message message) { - assert(message != NONE, "Should not be none"); - MonitorLockerEx ml(&_monitor, Monitor::_no_safepoint_check_flag); - - // Wait for completion of current message - while (_message != NONE) { - ml.wait(Monitor::_no_safepoint_check_flag); - } - - // Send new message - _message = message; - ml.notify_all(); - - // Wait for completion of new message - while (_message != NONE) { - ml.wait(Monitor::_no_safepoint_check_flag); - } -} - -void ReferencePendingListLockerThread::receive_and_handle_messages() { - ReferencePendingListLocker pending_list_locker; - MonitorLockerEx ml(&_monitor); - - // Main loop, never terminates - for (;;) { - // Wait for message - while (_message == NONE) { - ml.wait(); - } - - // Handle message - if (_message == LOCK) { - pending_list_locker.lock(); - } else if (_message == UNLOCK) { - pending_list_locker.unlock(); - } else { - ShouldNotReachHere(); - } - - // Clear message - _message = NONE; - ml.notify_all(); - } -} - -void ReferencePendingListLockerThread::lock() { - send_message(LOCK); -} - -void ReferencePendingListLockerThread::unlock() { - send_message(UNLOCK); -} - -bool ReferencePendingListLocker::_is_initialized = false; -ReferencePendingListLockerThread* ReferencePendingListLocker::_locker_thread = NULL; - -void ReferencePendingListLocker::initialize(bool needs_locker_thread, TRAPS) { - if (needs_locker_thread) { - _locker_thread = ReferencePendingListLockerThread::create(CHECK); - } - - _is_initialized = true; -} - -bool ReferencePendingListLocker::is_initialized() { - return _is_initialized; -} - -bool ReferencePendingListLocker::is_locked_by_self() { - oop pending_list_lock = java_lang_ref_Reference::pending_list_lock(); - if (pending_list_lock == NULL) { - return false; - } - - JavaThread* thread = JavaThread::current(); - Handle handle(thread, pending_list_lock); - return ObjectSynchronizer::current_thread_holds_lock(thread, handle); -} - -void ReferencePendingListLocker::lock() { - assert(!Heap_lock->owned_by_self(), "Heap_lock must not be owned by requesting thread"); - - if (Thread::current()->is_Java_thread()) { - assert(java_lang_ref_Reference::pending_list_lock() != NULL, "Not initialized"); - - // We may enter this with a pending exception - PRESERVE_EXCEPTION_MARK; - - HandleMark hm; - Handle handle(THREAD, java_lang_ref_Reference::pending_list_lock()); - - // Lock - ObjectSynchronizer::fast_enter(handle, &_basic_lock, false, THREAD); - - assert(is_locked_by_self(), "Locking failed"); - - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - } - } else { - // Delegate operation to locker thread - assert(_locker_thread != NULL, "Locker thread not created"); - _locker_thread->lock(); - } -} - -void ReferencePendingListLocker::unlock() { - if (Thread::current()->is_Java_thread()) { - assert(java_lang_ref_Reference::pending_list_lock() != NULL, "Not initialized"); - - // We may enter this with a pending exception - PRESERVE_EXCEPTION_MARK; - - HandleMark hm; - Handle handle(THREAD, java_lang_ref_Reference::pending_list_lock()); - - assert(is_locked_by_self(), "Should be locked by self"); - - // Notify waiters if the pending list is non-empty - if (java_lang_ref_Reference::pending_list() != NULL) { - ObjectSynchronizer::notifyall(handle, THREAD); - } - - // Unlock - ObjectSynchronizer::fast_exit(handle(), &_basic_lock, THREAD); - - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - } - } else { - // Delegate operation to locker thread - assert(_locker_thread != NULL, "Locker thread not created"); - _locker_thread->unlock(); - } -} diff --git a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp b/hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp deleted file mode 100644 index 62cf7eed995..00000000000 --- a/hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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. - * - */ - -#ifndef SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP -#define SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP - -#include "memory/allocation.hpp" -#include "runtime/basicLock.hpp" -#include "runtime/mutex.hpp" -#include "runtime/thread.hpp" -#include "utilities/exceptions.hpp" - -// -// The ReferencePendingListLockerThread locks and unlocks the reference -// pending list lock on behalf a non-Java thread, typically a concurrent -// GC thread. This interface should not be directly accessed. All uses -// should instead go through the ReferencePendingListLocker, which calls -// this thread if needed. -// -class ReferencePendingListLockerThread : public JavaThread { -private: - enum Message { - NONE, - LOCK, - UNLOCK - }; - - Monitor _monitor; - Message _message; - - ReferencePendingListLockerThread(); - - static void start(JavaThread* thread, TRAPS); - - void send_message(Message message); - void receive_and_handle_messages(); - -public: - static ReferencePendingListLockerThread* create(TRAPS); - - virtual bool is_hidden_from_external_view() const; - - void lock(); - void unlock(); -}; - -// -// The ReferencePendingListLocker is the main interface for locking and -// unlocking the reference pending list lock, which needs to be held by -// the GC when adding references to the pending list. Since this is a -// Java-level monitor it can only be locked/unlocked by a Java thread. -// For this reason there is an option to spawn a helper thread, the -// ReferencePendingListLockerThread, during initialization. If a helper -// thread is spawned all lock operations from non-Java threads will be -// delegated to the helper thread. The helper thread is typically needed -// by concurrent GCs. -// -class ReferencePendingListLocker VALUE_OBJ_CLASS_SPEC { -private: - static bool _is_initialized; - static ReferencePendingListLockerThread* _locker_thread; - BasicLock _basic_lock; - -public: - static void initialize(bool needs_locker_thread, TRAPS); - static bool is_initialized(); - - static bool is_locked_by_self(); - - void lock(); - void unlock(); -}; - -#endif // SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP diff --git a/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp b/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp index 2200e7620a4..38df96ddd4c 100644 --- a/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp +++ b/hotspot/src/share/vm/gc/shared/referenceProcessor.cpp @@ -289,39 +289,16 @@ void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive, complete_gc->do_void(); } - -template -bool enqueue_discovered_ref_helper(ReferenceProcessor* ref, - AbstractRefProcTaskExecutor* task_executor) { - - // Remember old value of pending references list - T* pending_list_addr = (T*)java_lang_ref_Reference::pending_list_addr(); - T old_pending_list_value = *pending_list_addr; - +void ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor) { // Enqueue references that are not made active again, and // clear the decks for the next collection (cycle). - ref->enqueue_discovered_reflists((HeapWord*)pending_list_addr, task_executor); - // Do the post-barrier on pending_list_addr missed in - // enqueue_discovered_reflist. - oopDesc::bs()->write_ref_field(pending_list_addr, oopDesc::load_decode_heap_oop(pending_list_addr)); + enqueue_discovered_reflists(task_executor); // Stop treating discovered references specially. - ref->disable_discovery(); - - // Return true if new pending references were added - return old_pending_list_value != *pending_list_addr; + disable_discovery(); } -bool ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor) { - if (UseCompressedOops) { - return enqueue_discovered_ref_helper(this, task_executor); - } else { - return enqueue_discovered_ref_helper(this, task_executor); - } -} - -void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list, - HeapWord* pending_list_addr) { +void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list) { // Given a list of refs linked through the "discovered" field // (java.lang.ref.Reference.discovered), self-loop their "next" field // thus distinguishing them from active References, then @@ -354,10 +331,9 @@ void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list, oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), next_d); } else { // This is the last object. - // Swap refs_list into pending_list_addr and - // set obj's discovered to what we read from pending_list_addr. - oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr); - // Need post-barrier on pending_list_addr. See enqueue_discovered_ref_helper() above. + // Swap refs_list into pending list and set obj's + // discovered to what we read from the pending list. + oop old = Universe::swap_reference_pending_list(refs_list.head()); java_lang_ref_Reference::set_discovered_raw(obj, old); // old may be NULL oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), old); } @@ -369,10 +345,8 @@ class RefProcEnqueueTask: public AbstractRefProcTaskExecutor::EnqueueTask { public: RefProcEnqueueTask(ReferenceProcessor& ref_processor, DiscoveredList discovered_refs[], - HeapWord* pending_list_addr, int n_queues) - : EnqueueTask(ref_processor, discovered_refs, - pending_list_addr, n_queues) + : EnqueueTask(ref_processor, discovered_refs, n_queues) { } virtual void work(unsigned int work_id) { @@ -387,8 +361,7 @@ public: for (int j = 0; j < ReferenceProcessor::number_of_subclasses_of_ref(); j++, index += _n_queues) { - _ref_processor.enqueue_discovered_reflist( - _refs_lists[index], _pending_list_addr); + _ref_processor.enqueue_discovered_reflist(_refs_lists[index]); _refs_lists[index].set_head(NULL); _refs_lists[index].set_length(0); } @@ -396,17 +369,15 @@ public: }; // Enqueue references that are not made active again -void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr, - AbstractRefProcTaskExecutor* task_executor) { +void ReferenceProcessor::enqueue_discovered_reflists(AbstractRefProcTaskExecutor* task_executor) { if (_processing_is_mt && task_executor != NULL) { // Parallel code - RefProcEnqueueTask tsk(*this, _discovered_refs, - pending_list_addr, _max_num_q); + RefProcEnqueueTask tsk(*this, _discovered_refs, _max_num_q); task_executor->execute(tsk); } else { // Serial code: call the parent class's implementation for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { - enqueue_discovered_reflist(_discovered_refs[i], pending_list_addr); + enqueue_discovered_reflist(_discovered_refs[i]); _discovered_refs[i].set_head(NULL); _discovered_refs[i].set_length(0); } diff --git a/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp b/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp index c5d0f5f8321..393029642b4 100644 --- a/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp +++ b/hotspot/src/share/vm/gc/shared/referenceProcessor.hpp @@ -290,7 +290,7 @@ class ReferenceProcessor : public CHeapObj { VoidClosure* complete_gc); // Enqueue references with a certain reachability level - void enqueue_discovered_reflist(DiscoveredList& refs_list, HeapWord* pending_list_addr); + void enqueue_discovered_reflist(DiscoveredList& refs_list); // "Preclean" all the discovered reference lists // by removing references with strongly reachable referents. @@ -311,7 +311,7 @@ class ReferenceProcessor : public CHeapObj { // occupying the i / _num_q slot. const char* list_name(uint i); - void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor); + void enqueue_discovered_reflists(AbstractRefProcTaskExecutor* task_executor); protected: // "Preclean" the given discovered reference list @@ -424,7 +424,7 @@ class ReferenceProcessor : public CHeapObj { GCTimer *gc_timer); // Enqueue references at end of GC (called by the garbage collector) - bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL); + void enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL); // If a discovery is in process that is being superceded, abandon it: all // the discovered lists will be empty, and all the objects on them will @@ -613,11 +613,9 @@ class AbstractRefProcTaskExecutor::EnqueueTask { protected: EnqueueTask(ReferenceProcessor& ref_processor, DiscoveredList refs_lists[], - HeapWord* pending_list_addr, int n_queues) : _ref_processor(ref_processor), _refs_lists(refs_lists), - _pending_list_addr(pending_list_addr), _n_queues(n_queues) { } @@ -627,7 +625,6 @@ public: protected: ReferenceProcessor& _ref_processor; DiscoveredList* _refs_lists; - HeapWord* _pending_list_addr; int _n_queues; }; diff --git a/hotspot/src/share/vm/gc/shared/space.inline.hpp b/hotspot/src/share/vm/gc/shared/space.inline.hpp index 3943a6da5dc..77b6f4ceb5a 100644 --- a/hotspot/src/share/vm/gc/shared/space.inline.hpp +++ b/hotspot/src/share/vm/gc/shared/space.inline.hpp @@ -293,10 +293,11 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) { verify_up_to_first_dead(space); + HeapWord* const bottom = space->bottom(); HeapWord* const end_of_live = space->_end_of_live; assert(space->_first_dead <= end_of_live, "Invariant. _first_dead: " PTR_FORMAT " <= end_of_live: " PTR_FORMAT, p2i(space->_first_dead), p2i(end_of_live)); - if (space->_first_dead == end_of_live && !oop(space->bottom())->is_gc_marked()) { + if (space->_first_dead == end_of_live && (bottom == end_of_live || !oop(bottom)->is_gc_marked())) { // Nothing to compact. The space is either empty or all live object should be left in place. clear_empty_region(space); return; @@ -305,8 +306,8 @@ inline void CompactibleSpace::scan_and_compact(SpaceType* space) { const intx scan_interval = PrefetchScanIntervalInBytes; const intx copy_interval = PrefetchCopyIntervalInBytes; - assert(space->bottom() < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(space->bottom()), p2i(end_of_live)); - HeapWord* cur_obj = space->bottom(); + assert(bottom < end_of_live, "bottom: " PTR_FORMAT " should be < end_of_live: " PTR_FORMAT, p2i(bottom), p2i(end_of_live)); + HeapWord* cur_obj = bottom; if (space->_first_dead > cur_obj && !oop(cur_obj)->is_gc_marked()) { // All object before _first_dead can be skipped. They should not be moved. // A pointer to the first live object is stored at the memory location for _first_dead. diff --git a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp index 9ac7d42e0a0..ce73880ba2a 100644 --- a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp @@ -62,14 +62,6 @@ void VM_GC_Operation::notify_gc_end() { HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); } -void VM_GC_Operation::acquire_pending_list_lock() { - _pending_list_locker.lock(); -} - -void VM_GC_Operation::release_and_notify_pending_list_lock() { - _pending_list_locker.unlock(); -} - // Allocations may fail in several threads at about the same time, // resulting in multiple gc requests. We only want to do one of them. // In case a GC locker is active and the need for a GC is already signaled, @@ -102,16 +94,13 @@ bool VM_GC_Operation::doit_prologue() { proper_unit_for_byte_size(NewSize))); } - acquire_pending_list_lock(); // If the GC count has changed someone beat us to the collection - // Get the Heap_lock after the pending_list_lock. Heap_lock->lock(); // Check invocations if (skip_operation()) { // skip collection Heap_lock->unlock(); - release_and_notify_pending_list_lock(); _prologue_succeeded = false; } else { _prologue_succeeded = true; @@ -122,9 +111,10 @@ bool VM_GC_Operation::doit_prologue() { void VM_GC_Operation::doit_epilogue() { assert(Thread::current()->is_Java_thread(), "just checking"); - // Release the Heap_lock first. + if (Universe::has_reference_pending_list()) { + Heap_lock->notify_all(); + } Heap_lock->unlock(); - release_and_notify_pending_list_lock(); } bool VM_GC_HeapInspection::skip_operation() const { diff --git a/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp b/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp index fe742964b56..80e652e1029 100644 --- a/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp +++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.hpp @@ -27,7 +27,6 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/genCollectedHeap.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "memory/heapInspection.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/handles.hpp" @@ -70,9 +69,6 @@ // class VM_GC_Operation: public VM_Operation { - private: - ReferencePendingListLocker _pending_list_locker; - protected: uint _gc_count_before; // gc count before acquiring PLL uint _full_gc_count_before; // full gc count before acquiring PLL @@ -83,10 +79,6 @@ class VM_GC_Operation: public VM_Operation { virtual bool skip_operation() const; - // java.lang.ref.Reference support - void acquire_pending_list_lock(); - void release_and_notify_pending_list_lock(); - public: VM_GC_Operation(uint gc_count_before, GCCause::Cause _cause, diff --git a/hotspot/src/share/vm/gc/shared/workerManager.hpp b/hotspot/src/share/vm/gc/shared/workerManager.hpp index 6758c08c741..e12002739ac 100644 --- a/hotspot/src/share/vm/gc/shared/workerManager.hpp +++ b/hotspot/src/share/vm/gc/shared/workerManager.hpp @@ -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/hotspot/src/share/vm/gc/shared/workgroup.hpp b/hotspot/src/share/vm/gc/shared/workgroup.hpp index 00eb705f683..b71b3e0e23a 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.hpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp @@ -62,7 +62,12 @@ class AbstractGangTask VALUE_OBJ_CLASS_SPEC { AbstractGangTask(const char* name) : _name(name), _gc_id(GCId::current_raw()) - {} + {} + + AbstractGangTask(const char* name, const uint gc_id) : + _name(name), + _gc_id(gc_id) + {} // The abstract work method. // The argument tells you which member of the gang you are. @@ -162,7 +167,7 @@ class AbstractWorkGang : public CHeapObj { _active_workers = MIN2(v, _total_workers); add_workers(false /* exit_on_failure */); assert(v != 0, "Trying to set active workers to 0"); - log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers); + log_trace(gc, task)("%s: using %d out of %d workers", name(), _active_workers, _total_workers); return _active_workers; } diff --git a/hotspot/src/share/vm/logging/log.cpp b/hotspot/src/share/vm/logging/log.cpp index 8796c1794e4..3f63d143f27 100644 --- a/hotspot/src/share/vm/logging/log.cpp +++ b/hotspot/src/share/vm/logging/log.cpp @@ -1161,7 +1161,7 @@ void Test_invalid_log_file() { // Attempt to log to a directory (existing log not a regular file) create_directory(target_name); - LogFileOutput bad_file("tmplogdir"); + LogFileOutput bad_file("file=tmplogdir"); assert(bad_file.initialize("", &ss) == false, "file was initialized " "when there was an existing directory with the same name"); assert(strstr(ss.as_string(), "tmplogdir is not a regular file") != NULL, diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 3081fe93432..7842cbb34e2 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -44,6 +44,9 @@ size_t LogConfiguration::_n_outputs = 0; LogConfiguration::UpdateListenerFunction* LogConfiguration::_listener_callbacks = NULL; size_t LogConfiguration::_n_listener_callbacks = 0; +// LogFileOutput is the default type of output, its type prefix should be used if no type was specified +static const char* implicit_output_prefix = LogFileOutput::Prefix; + // Stack object to take the lock for configuring the logging. // Should only be held during the critical parts of the configuration // (when calling configure_output or reading/modifying the outputs array). @@ -107,6 +110,55 @@ void LogConfiguration::finalize() { FREE_C_HEAP_ARRAY(LogOutput*, _outputs); } +// Normalizes the given LogOutput name to type=name form. +// For example, foo, "foo", file="foo", will all be normalized to file=foo (no quotes, prefixed). +static bool normalize_output_name(const char* full_name, char* buffer, size_t len, outputStream* errstream) { + const char* start_quote = strchr(full_name, '"'); + const char* equals = strchr(full_name, '='); + const bool quoted = start_quote != NULL; + const bool is_stdout_or_stderr = (strcmp(full_name, "stdout") == 0 || strcmp(full_name, "stderr") == 0); + + // ignore equals sign within quotes + if (quoted && equals > start_quote) { + equals = NULL; + } + + const char* prefix = ""; + size_t prefix_len = 0; + const char* name = full_name; + if (equals != NULL) { + // split on equals sign + name = equals + 1; + prefix = full_name; + prefix_len = equals - full_name + 1; + } else if (!is_stdout_or_stderr) { + prefix = implicit_output_prefix; + prefix_len = strlen(prefix); + } + size_t name_len = strlen(name); + + if (quoted) { + const char* end_quote = strchr(start_quote + 1, '"'); + if (end_quote == NULL) { + errstream->print_cr("Output name has opening quote but is missing a terminating quote."); + return false; + } + if (start_quote != name || end_quote[1] != '\0') { + errstream->print_cr("Output name can not be partially quoted." + " Either surround the whole name with quotation marks," + " or do not use quotation marks at all."); + return false; + } + // strip start and end quote + name++; + name_len -= 2; + } + + int ret = jio_snprintf(buffer, len, "%.*s%.*s", prefix_len, prefix, name_len, name); + assert(ret > 0, "buffer issue"); + return true; +} + size_t LogConfiguration::find_output(const char* name) { for (size_t i = 0; i < _n_outputs; i++) { if (strcmp(_outputs[i]->name(), name) == 0) { @@ -116,39 +168,14 @@ size_t LogConfiguration::find_output(const char* name) { return SIZE_MAX; } -LogOutput* LogConfiguration::new_output(char* name, const char* options, outputStream* errstream) { - const char* type; - char* equals_pos = strchr(name, '='); - if (equals_pos == NULL) { - type = "file"; - } else { - *equals_pos = '\0'; - type = name; - name = equals_pos + 1; - } - - // Check if name is quoted, and if so, strip the quotes - char* quote = strchr(name, '"'); - if (quote != NULL) { - char* end_quote = strchr(name + 1, '"'); - if (end_quote == NULL) { - errstream->print_cr("Output name has opening quote but is missing a terminating quote."); - return NULL; - } else if (quote != name || end_quote[1] != '\0') { - errstream->print_cr("Output name can not be partially quoted." - " Either surround the whole name with quotation marks," - " or do not use quotation marks at all."); - return NULL; - } - name++; - *end_quote = '\0'; - } - +LogOutput* LogConfiguration::new_output(const char* name, + const char* options, + outputStream* errstream) { LogOutput* output; - if (strcmp(type, "file") == 0) { + if (strncmp(name, LogFileOutput::Prefix, strlen(LogFileOutput::Prefix)) == 0) { output = new LogFileOutput(name); } else { - errstream->print_cr("Unsupported log output type."); + errstream->print_cr("Unsupported log output type: %s", name); return NULL; } @@ -243,6 +270,7 @@ void LogConfiguration::configure_output(size_t idx, const LogTagLevelExpression& } void LogConfiguration::disable_output(size_t idx) { + assert(idx < _n_outputs, "invalid index: " SIZE_FORMAT " (_n_outputs: " SIZE_FORMAT ")", idx, _n_outputs); LogOutput* out = _outputs[idx]; // Remove the output from all tagsets. @@ -253,7 +281,7 @@ void LogConfiguration::disable_output(size_t idx) { // Delete the output unless stdout/stderr if (out != LogOutput::Stderr && out != LogOutput::Stdout) { - delete_output(find_output(out->name())); + delete_output(idx); } else { out->set_config_string("all=off"); } @@ -261,8 +289,8 @@ void LogConfiguration::disable_output(size_t idx) { void LogConfiguration::disable_logging() { ConfigurationLock cl; - for (size_t i = 0; i < _n_outputs; i++) { - disable_output(i); + for (size_t i = _n_outputs; i > 0; i--) { + disable_output(i - 1); } notify_update_listeners(); } @@ -289,6 +317,8 @@ void LogConfiguration::configure_stdout(LogLevelType level, bool exact_match, .. } expr.set_level(level); expr.new_combination(); + assert(expr.verify_tagsets(), + "configure_stdout() called with invalid/non-existing tag set"); // Apply configuration to stdout (output #0), with the same decorators as before. ConfigurationLock cl; @@ -334,9 +364,16 @@ bool LogConfiguration::parse_command_line_arguments(const char* opts) { char errbuf[512]; stringStream ss(errbuf, sizeof(errbuf)); bool success = parse_log_arguments(output, what, decorators, output_options, &ss); - if (!success) { - errbuf[strlen(errbuf) - 1] = '\0'; // Strip trailing newline. - log_error(logging)("%s", errbuf); + + if (ss.size() > 0) { + errbuf[strlen(errbuf) - 1] = '\0'; // Strip trailing newline + // If it failed, log the error. If it didn't fail, but something was written + // to the stream, log it as a warning. + if (!success) { + log_error(logging)("%s", ss.base()); + } else { + log_warning(logging)("%s", ss.base()); + } } os::free(copy); @@ -348,6 +385,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, const char* decoratorstr, const char* output_options, outputStream* errstream) { + assert(errstream != NULL, "errstream can not be NULL"); if (outputstr == NULL || strlen(outputstr) == 0) { outputstr = "stdout"; } @@ -364,28 +402,39 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, ConfigurationLock cl; size_t idx; - if (outputstr[0] == '#') { - int ret = sscanf(outputstr+1, SIZE_FORMAT, &idx); + if (outputstr[0] == '#') { // Output specified using index + int ret = sscanf(outputstr + 1, SIZE_FORMAT, &idx); if (ret != 1 || idx >= _n_outputs) { errstream->print_cr("Invalid output index '%s'", outputstr); return false; } - } else { - idx = find_output(outputstr); + } else { // Output specified using name + // Normalize the name, stripping quotes and ensures it includes type prefix + size_t len = strlen(outputstr) + strlen(implicit_output_prefix) + 1; + char* normalized = NEW_C_HEAP_ARRAY(char, len, mtLogging); + if (!normalize_output_name(outputstr, normalized, len, errstream)) { + return false; + } + + idx = find_output(normalized); if (idx == SIZE_MAX) { - char* tmp = os::strdup_check_oom(outputstr, mtLogging); - LogOutput* output = new_output(tmp, output_options, errstream); - os::free(tmp); - if (output == NULL) { - return false; + // Attempt to create and add the output + LogOutput* output = new_output(normalized, output_options, errstream); + if (output != NULL) { + idx = add_output(output); } - idx = add_output(output); } else if (output_options != NULL && strlen(output_options) > 0) { errstream->print_cr("Output options for existing outputs are ignored."); } + + FREE_C_HEAP_ARRAY(char, normalized); + if (idx == SIZE_MAX) { + return false; + } } configure_output(idx, expr, decorators); notify_update_listeners(); + expr.verify_tagsets(errstream); return true; } diff --git a/hotspot/src/share/vm/logging/logConfiguration.hpp b/hotspot/src/share/vm/logging/logConfiguration.hpp index 9efbadddd02..344e66af5e2 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.hpp +++ b/hotspot/src/share/vm/logging/logConfiguration.hpp @@ -59,7 +59,7 @@ class LogConfiguration : public AllStatic { static size_t _n_listener_callbacks; // Create a new output. Returns NULL if failed. - static LogOutput* new_output(char* name, const char* options, outputStream* errstream); + static LogOutput* new_output(const char* name, const char* options, outputStream* errstream); // Add an output to the list of configured outputs. Returns the assigned index. static size_t add_output(LogOutput* out); diff --git a/hotspot/src/share/vm/logging/logFileOutput.cpp b/hotspot/src/share/vm/logging/logFileOutput.cpp index 77cad087a0c..3f431ef3e54 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.cpp +++ b/hotspot/src/share/vm/logging/logFileOutput.cpp @@ -31,6 +31,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/defaultStream.hpp" +const char* LogFileOutput::Prefix = "file="; const char* LogFileOutput::FileOpenMode = "a"; const char* LogFileOutput::PidFilenamePlaceholder = "%p"; const char* LogFileOutput::TimestampFilenamePlaceholder = "%t"; @@ -45,7 +46,8 @@ LogFileOutput::LogFileOutput(const char* name) _file_name(NULL), _archive_name(NULL), _archive_name_len(0), _rotate_size(DefaultFileSize), _file_count(DefaultFileCount), _current_size(0), _current_file(0), _rotation_semaphore(1) { - _file_name = make_file_name(name, _pid_str, _vm_start_time_str); + assert(strstr(name, Prefix) == name, "invalid output name '%s': missing prefix: %s", name, Prefix); + _file_name = make_file_name(name + strlen(Prefix), _pid_str, _vm_start_time_str); } void LogFileOutput::set_file_name_parameters(jlong vm_start_time) { diff --git a/hotspot/src/share/vm/logging/logFileOutput.hpp b/hotspot/src/share/vm/logging/logFileOutput.hpp index 3ec3a771985..7808ab33f81 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.hpp +++ b/hotspot/src/share/vm/logging/logFileOutput.hpp @@ -91,6 +91,7 @@ class LogFileOutput : public LogFileStreamOutput { return _name; } + static const char* Prefix; static void set_file_name_parameters(jlong start_time); }; diff --git a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp index 0770c38ba8d..6b53ab563a9 100644 --- a/hotspot/src/share/vm/logging/logTagLevelExpression.cpp +++ b/hotspot/src/share/vm/logging/logTagLevelExpression.cpp @@ -29,6 +29,65 @@ const char* LogTagLevelExpression::DefaultExpressionString = "all"; +static bool matches_tagset(const LogTagType tags[], + bool allow_other_tags, + const LogTagSet& ts) { + bool contains_all = true; + size_t tag_idx; + for (tag_idx = 0; tag_idx < LogTag::MaxTags && tags[tag_idx] != LogTag::__NO_TAG; tag_idx++) { + if (!ts.contains(tags[tag_idx])) { + contains_all = false; + break; + } + } + // All tags in the expression must be part of the tagset, + // and either the expression allows other tags (has a wildcard), + // or the number of tags in the expression and tagset must match. + return contains_all && (allow_other_tags || tag_idx == ts.ntags()); +} + +bool LogTagLevelExpression::verify_tagsets(outputStream* out) const { + bool valid = true; + + for (size_t i = 0; i < _ncombinations; i++) { + bool matched = false; + for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + if (matches_tagset(_tags[i], _allow_other_tags[i], *ts)) { + matched = true; + break; + } + } + + if (!matched) { + // If this was the first invalid combination, write the message header + if (valid && out != NULL) { + out->print("No tag set matches selection(s): "); + } + valid = false; + + // Break as soon as possible unless listing all invalid combinations + if (out == NULL) { + break; + } + + // List the combination on the outputStream + for (size_t t = 0; t < LogTag::MaxTags && _tags[i][t] != LogTag::__NO_TAG; t++) { + out->print("%s%s", (t == 0 ? "" : "+"), LogTag::name(_tags[i][t])); + } + if (_allow_other_tags[i]) { + out->print("*"); + } + out->print(" "); + } + } + + if (!valid && out != NULL) { + out->cr(); + } + + return valid; +} + bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) { bool success = true; if (str == NULL || strcmp(str, "") == 0) { @@ -105,7 +164,14 @@ bool LogTagLevelExpression::parse(const char* str, outputStream* errstream) { success = false; break; } - add_tag(tag); + if (!add_tag(tag)) { + if (errstream != NULL) { + errstream->print_cr("Tag combination have duplicate tag '%s' in what-expression.", + cur_tag); + } + success = false; + break; + } cur_tag = plus_pos + 1; } while (plus_pos != NULL); @@ -120,20 +186,10 @@ LogLevelType LogTagLevelExpression::level_for(const LogTagSet& ts) const { // Return NotMentioned if the given tagset isn't covered by this expression. LogLevelType level = LogLevel::NotMentioned; for (size_t combination = 0; combination < _ncombinations; combination++) { - bool contains_all = true; - size_t tag_idx; - for (tag_idx = 0; tag_idx < LogTag::MaxTags && _tags[combination][tag_idx] != LogTag::__NO_TAG; tag_idx++) { - if (!ts.contains(_tags[combination][tag_idx])) { - contains_all = false; - break; - } - } - // All tags in the expression must be part of the tagset, - // and either the expression allows other tags (has a wildcard), - // or the number of tags in the expression and tagset must match. - if (contains_all && (_allow_other_tags[combination] || tag_idx == ts.ntags())) { + if (matches_tagset(_tags[combination], _allow_other_tags[combination], ts)) { level = _level[combination]; } } return level; } + diff --git a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp index 9a0d7c9cd79..278f265a0d0 100644 --- a/hotspot/src/share/vm/logging/logTagLevelExpression.hpp +++ b/hotspot/src/share/vm/logging/logTagLevelExpression.hpp @@ -59,9 +59,15 @@ class LogTagLevelExpression : public StackObj { _ntags = 0; } - void add_tag(LogTagType tag) { + bool add_tag(LogTagType tag) { assert(_ntags < LogTag::MaxTags, "Can't have more tags than MaxTags!"); + for (size_t i = 0; i < _ntags; i++) { + if (_tags[_ncombinations][i] == tag) { + return false; + } + } _tags[_ncombinations][_ntags++] = tag; + return true; } void set_level(LogLevelType level) { @@ -83,6 +89,11 @@ class LogTagLevelExpression : public StackObj { bool parse(const char* str, outputStream* errstream = NULL); LogLevelType level_for(const LogTagSet& ts) const; + + // Verify the tagsets/selections mentioned in this expression. + // Returns false if some invalid tagset was found. If given an outputstream, + // this function will list all the invalid selections on the stream. + bool verify_tagsets(outputStream* out = NULL) const; }; #endif // SHARE_VM_LOGGING_LOGTAGLEVELEXPRESSION_HPP diff --git a/hotspot/src/share/vm/logging/logTagSet.hpp b/hotspot/src/share/vm/logging/logTagSet.hpp index a40ed5175bc..e6281565ee5 100644 --- a/hotspot/src/share/vm/logging/logTagSet.hpp +++ b/hotspot/src/share/vm/logging/logTagSet.hpp @@ -86,7 +86,7 @@ class LogTagSet VALUE_OBJ_CLASS_SPEC { } bool contains(LogTagType tag) const { - for (size_t i = 0; _tag[i] != LogTag::__NO_TAG; i++) { + for (size_t i = 0; i < LogTag::MaxTags && _tag[i] != LogTag::__NO_TAG; i++) { if (tag == _tag[i]) { return true; } diff --git a/hotspot/src/share/vm/memory/allocation.hpp b/hotspot/src/share/vm/memory/allocation.hpp index 5d9e7c830f6..c9a5f28405c 100644 --- a/hotspot/src/share/vm/memory/allocation.hpp +++ b/hotspot/src/share/vm/memory/allocation.hpp @@ -738,6 +738,7 @@ class MmapArrayAllocator : public AllStatic { static size_t size_for(size_t length); public: + static E* allocate_or_null(size_t length); static E* allocate(size_t length); static void free(E* addr, size_t length); }; diff --git a/hotspot/src/share/vm/memory/allocation.inline.hpp b/hotspot/src/share/vm/memory/allocation.inline.hpp index db09c0cfb0e..f1035490163 100644 --- a/hotspot/src/share/vm/memory/allocation.inline.hpp +++ b/hotspot/src/share/vm/memory/allocation.inline.hpp @@ -152,6 +152,24 @@ size_t MmapArrayAllocator::size_for(size_t length) { return align_size_up(size, alignment); } +template +E* MmapArrayAllocator::allocate_or_null(size_t length) { + size_t size = size_for(length); + int alignment = os::vm_allocation_granularity(); + + char* addr = os::reserve_memory(size, NULL, alignment, F); + if (addr == NULL) { + return NULL; + } + + if (os::commit_memory(addr, size, !ExecMem, "Allocator (commit)")) { + return (E*)addr; + } else { + os::release_memory(addr, size); + return NULL; + } +} + template E* MmapArrayAllocator::allocate(size_t length) { size_t size = size_for(length); diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp index 6dc7d1fb1c6..08a79f11f3b 100644 --- a/hotspot/src/share/vm/memory/filemap.cpp +++ b/hotspot/src/share/vm/memory/filemap.cpp @@ -649,7 +649,7 @@ ReservedSpace FileMapInfo::reserve_shared_memory() { // Memory map a region in the address space. static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode", - "String1", "String2" }; + "String1", "String2", "OptionalData" }; char* FileMapInfo::map_region(int i) { assert(!MetaspaceShared::is_string_region(i), "sanity"); diff --git a/hotspot/src/share/vm/memory/filemap.hpp b/hotspot/src/share/vm/memory/filemap.hpp index 2c02b427f0b..baffd299436 100644 --- a/hotspot/src/share/vm/memory/filemap.hpp +++ b/hotspot/src/share/vm/memory/filemap.hpp @@ -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 @@ -252,10 +252,27 @@ public: bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false); void print_shared_spaces() NOT_CDS_RETURN; + // The ro+rw+md+mc spaces size + static size_t core_spaces_size() { + return align_size_up((SharedReadOnlySize + SharedReadWriteSize + + SharedMiscDataSize + SharedMiscCodeSize), + os::vm_allocation_granularity()); + } + + // The estimated optional space size. + // + // Currently the optional space only has archived class bytes. + // The core_spaces_size is the size of all class metadata, which is a good + // estimate of the total class bytes to be archived. Only the portion + // containing data is written out to the archive and mapped at runtime. + // There is no memory waste due to unused portion in optional space. + static size_t optional_space_size() { + return core_spaces_size(); + } + + // Total shared_spaces size includes the ro, rw, md, mc and od spaces static size_t shared_spaces_size() { - return align_size_up(SharedReadOnlySize + SharedReadWriteSize + - SharedMiscDataSize + SharedMiscCodeSize, - os::vm_allocation_granularity()); + return core_spaces_size() + optional_space_size(); } // Stop CDS sharing and unmap CDS regions. diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index 1801a7c21cf..4ba897e7ab9 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -3172,36 +3172,28 @@ void Metaspace::global_initialize() { address cds_address = NULL; FileMapInfo* mapinfo = new FileMapInfo(); - if (JvmtiExport::should_post_class_file_load_hook()) { - // Currently CDS does not support JVMTI CFLH when loading shared class. - // If JvmtiExport::should_post_class_file_load_hook is already enabled, - // just disable UseSharedSpaces. - FileMapInfo::fail_continue("Tool agent requires sharing to be disabled."); - delete mapinfo; - } else { - // Open the shared archive file, read and validate the header. If - // initialization fails, shared spaces [UseSharedSpaces] are - // disabled and the file is closed. - // Map in spaces now also - if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) { - cds_total = FileMapInfo::shared_spaces_size(); - cds_address = (address)mapinfo->header()->region_addr(0); + // Open the shared archive file, read and validate the header. If + // initialization fails, shared spaces [UseSharedSpaces] are + // disabled and the file is closed. + // Map in spaces now also + if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) { + cds_total = FileMapInfo::shared_spaces_size(); + cds_address = (address)mapinfo->header()->region_addr(0); #ifdef _LP64 - if (using_class_space()) { - char* cds_end = (char*)(cds_address + cds_total); - cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment); - // If UseCompressedClassPointers is set then allocate the metaspace area - // above the heap and above the CDS area (if it exists). - allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address); - // Map the shared string space after compressed pointers - // because it relies on compressed class pointers setting to work - mapinfo->map_string_regions(); - } -#endif // _LP64 - } else { - assert(!mapinfo->is_open() && !UseSharedSpaces, - "archive file not closed or shared spaces not disabled."); + if (using_class_space()) { + char* cds_end = (char*)(cds_address + cds_total); + cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment); + // If UseCompressedClassPointers is set then allocate the metaspace area + // above the heap and above the CDS area (if it exists). + allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address); + // Map the shared string space after compressed pointers + // because it relies on compressed class pointers setting to work + mapinfo->map_string_regions(); } +#endif // _LP64 + } else { + assert(!mapinfo->is_open() && !UseSharedSpaces, + "archive file not closed or shared spaces not disabled."); } } #endif // INCLUDE_CDS diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp index 66366273f19..61d6fa37b41 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.cpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp @@ -65,6 +65,7 @@ address MetaspaceShared::_cds_i2i_entry_code_buffers = NULL; size_t MetaspaceShared::_cds_i2i_entry_code_buffers_size = 0; SharedMiscRegion MetaspaceShared::_mc; SharedMiscRegion MetaspaceShared::_md; +SharedMiscRegion MetaspaceShared::_od; void SharedMiscRegion::initialize(ReservedSpace rs, size_t committed_byte_size, SharedSpaceType space_type) { _vs.initialize(rs, committed_byte_size); @@ -93,16 +94,24 @@ void MetaspaceShared::initialize_shared_rs(ReservedSpace* rs) { assert(DumpSharedSpaces, "dump time only"); _shared_rs = rs; - // Split up and initialize the misc code and data spaces + size_t core_spaces_size = FileMapInfo::core_spaces_size(); size_t metadata_size = SharedReadOnlySize + SharedReadWriteSize; - ReservedSpace shared_ro_rw = _shared_rs->first_part(metadata_size); - ReservedSpace misc_section = _shared_rs->last_part(metadata_size); - // Now split into misc sections. + // Split into the core and optional sections + ReservedSpace core_data = _shared_rs->first_part(core_spaces_size); + ReservedSpace optional_data = _shared_rs->last_part(core_spaces_size); + + // The RO/RW and the misc sections + ReservedSpace shared_ro_rw = core_data.first_part(metadata_size); + ReservedSpace misc_section = core_data.last_part(metadata_size); + + // Now split the misc code and misc data sections. ReservedSpace md_rs = misc_section.first_part(SharedMiscDataSize); ReservedSpace mc_rs = misc_section.last_part(SharedMiscDataSize); + _md.initialize(md_rs, SharedMiscDataSize, SharedMiscData); - _mc.initialize(mc_rs, SharedMiscCodeSize, SharedMiscData); + _mc.initialize(mc_rs, SharedMiscCodeSize, SharedMiscCode); + _od.initialize(optional_data, metadata_size, SharedOptional); } // Read/write a data stream for restoring/preserving metadata pointers and @@ -521,6 +530,7 @@ private: GrowableArray *_class_promote_order; VirtualSpace _md_vs; VirtualSpace _mc_vs; + VirtualSpace _od_vs; GrowableArray *_string_regions; public: @@ -598,15 +608,19 @@ void VM_PopulateDumpSharedSpace::doit() { remove_unshareable_in_classes(); tty->print_cr("done. "); - // Set up the share data and shared code segments. + // Set up the misc data, misc code and optional data segments. _md_vs = *MetaspaceShared::misc_data_region()->virtual_space(); _mc_vs = *MetaspaceShared::misc_code_region()->virtual_space(); + _od_vs = *MetaspaceShared::optional_data_region()->virtual_space(); char* md_low = _md_vs.low(); char* md_top = MetaspaceShared::misc_data_region()->alloc_top(); char* md_end = _md_vs.high(); char* mc_low = _mc_vs.low(); char* mc_top = MetaspaceShared::misc_code_region()->alloc_top(); char* mc_end = _mc_vs.high(); + char* od_low = _od_vs.low(); + char* od_top = MetaspaceShared::optional_data_region()->alloc_top(); + char* od_end = _od_vs.high(); // Reserve space for the list of Klass*s whose vtables are used // for patching others as needed. @@ -661,28 +675,32 @@ void VM_PopulateDumpSharedSpace::doit() { const size_t rw_alloced = rw_space->capacity_bytes_slow(Metaspace::NonClassType); const size_t md_alloced = md_end-md_low; const size_t mc_alloced = mc_end-mc_low; + const size_t od_alloced = od_end-od_low; const size_t total_alloced = ro_alloced + rw_alloced + md_alloced + mc_alloced - + ss_bytes; + + ss_bytes + od_alloced; // Occupied size of each space. const size_t ro_bytes = ro_space->used_bytes_slow(Metaspace::NonClassType); const size_t rw_bytes = rw_space->used_bytes_slow(Metaspace::NonClassType); const size_t md_bytes = size_t(md_top - md_low); const size_t mc_bytes = size_t(mc_top - mc_low); + const size_t od_bytes = size_t(od_top - od_low); // Percent of total size - const size_t total_bytes = ro_bytes + rw_bytes + md_bytes + mc_bytes + ss_bytes; + const size_t total_bytes = ro_bytes + rw_bytes + md_bytes + mc_bytes + ss_bytes + od_bytes; const double ro_t_perc = ro_bytes / double(total_bytes) * 100.0; const double rw_t_perc = rw_bytes / double(total_bytes) * 100.0; const double md_t_perc = md_bytes / double(total_bytes) * 100.0; const double mc_t_perc = mc_bytes / double(total_bytes) * 100.0; const double ss_t_perc = ss_bytes / double(total_bytes) * 100.0; + const double od_t_perc = od_bytes / double(total_bytes) * 100.0; // Percent of fullness of each space const double ro_u_perc = ro_bytes / double(ro_alloced) * 100.0; const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0; const double md_u_perc = md_bytes / double(md_alloced) * 100.0; const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; + const double od_u_perc = od_bytes / double(od_alloced) * 100.0; const double total_u_perc = total_bytes / double(total_alloced) * 100.0; #define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT @@ -691,6 +709,7 @@ void VM_PopulateDumpSharedSpace::doit() { tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, p2i(md_low)); tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, p2i(mc_low)); tty->print_cr(fmt_space, "st", ss_bytes, ss_t_perc, ss_bytes, 100.0, p2i(ss_low)); + tty->print_cr(fmt_space, "od", od_bytes, od_t_perc, od_alloced, od_u_perc, p2i(od_low)); tty->print_cr("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]", total_bytes, total_alloced, total_u_perc); @@ -734,6 +753,10 @@ void VM_PopulateDumpSharedSpace::doit() { SharedMiscCodeSize, true, true); mapinfo->write_string_regions(_string_regions); + mapinfo->write_region(MetaspaceShared::od, _od_vs.low(), + pointer_delta(od_top, _od_vs.low(), sizeof(char)), + pointer_delta(od_end, _od_vs.low(), sizeof(char)), + true, false); } mapinfo->close(); @@ -1049,8 +1072,6 @@ void MetaspaceShared::print_shared_spaces() { // Map shared spaces at requested addresses and return if succeeded. -// Need to keep the bounds of the ro and rw space for the Metaspace::contains -// call, or is_in_shared_space. bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { size_t image_alignment = mapinfo->alignment(); @@ -1068,6 +1089,7 @@ bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { char* _rw_base = NULL; char* _md_base = NULL; char* _mc_base = NULL; + char* _od_base = NULL; // Map each shared region if ((_ro_base = mapinfo->map_region(ro)) != NULL && @@ -1078,6 +1100,8 @@ bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { mapinfo->verify_region_checksum(md) && (_mc_base = mapinfo->map_region(mc)) != NULL && mapinfo->verify_region_checksum(mc) && + (_od_base = mapinfo->map_region(od)) != NULL && + mapinfo->verify_region_checksum(od) && (image_alignment == (size_t)max_alignment()) && mapinfo->validate_classpath_entry_table()) { // Success (no need to do anything) @@ -1089,6 +1113,7 @@ bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { if (_rw_base != NULL) mapinfo->unmap_region(rw); if (_md_base != NULL) mapinfo->unmap_region(md); if (_mc_base != NULL) mapinfo->unmap_region(mc); + if (_od_base != NULL) mapinfo->unmap_region(od); #ifndef _WINDOWS // Release the entire mapped region shared_rs.release(); diff --git a/hotspot/src/share/vm/memory/metaspaceShared.hpp b/hotspot/src/share/vm/memory/metaspaceShared.hpp index c60e8207328..cb96021af66 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.hpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.hpp @@ -132,6 +132,7 @@ class MetaspaceShared : AllStatic { // Used only during dumping. static SharedMiscRegion _md; static SharedMiscRegion _mc; + static SharedMiscRegion _od; public: enum { vtbl_list_size = DEFAULT_VTBL_LIST_SIZE, @@ -148,7 +149,10 @@ class MetaspaceShared : AllStatic { max_strings = 2, // max number of string regions in string space num_non_strings = 4, // number of non-string regions first_string = num_non_strings, // index of first string region - n_regions = max_strings + num_non_strings // total number of regions + // The optional data region is the last region. + // Currently it only contains class file data. + od = max_strings + num_non_strings, + n_regions = od + 1 // total number of regions }; // Accessor functions to save shared space created for metadata, which has @@ -222,9 +226,10 @@ class MetaspaceShared : AllStatic { static int count_class(const char* classlist_file); static void estimate_regions_size() NOT_CDS_RETURN; - // Allocate a block of memory from the "mc" or "md" regions. + // Allocate a block of memory from the "mc", "md", or "od" regions. static char* misc_code_space_alloc(size_t num_bytes) { return _mc.alloc(num_bytes); } static char* misc_data_space_alloc(size_t num_bytes) { return _md.alloc(num_bytes); } + static char* optional_data_space_alloc(size_t num_bytes) { return _od.alloc(num_bytes); } static address cds_i2i_entry_code_buffers(size_t total_size); @@ -243,5 +248,9 @@ class MetaspaceShared : AllStatic { assert(DumpSharedSpaces, "used during dumping only"); return &_md; } + static SharedMiscRegion* optional_data_region() { + assert(DumpSharedSpaces, "used during dumping only"); + return &_od; + } }; #endif // SHARE_VM_MEMORY_METASPACESHARED_HPP diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 1e434d1b79a..97cd396b340 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -135,6 +135,7 @@ oop Universe::_arithmetic_exception_instance = NULL; oop Universe::_virtual_machine_error_instance = NULL; oop Universe::_vm_exception = NULL; oop Universe::_allocation_context_notification_obj = NULL; +oop Universe::_reference_pending_list = NULL; Array* Universe::_the_empty_int_array = NULL; Array* Universe::_the_empty_short_array = NULL; @@ -212,6 +213,7 @@ void Universe::oops_do(OopClosure* f, bool do_all) { f->do_oop((oop*)&_system_thread_group); f->do_oop((oop*)&_vm_exception); f->do_oop((oop*)&_allocation_context_notification_obj); + f->do_oop((oop*)&_reference_pending_list); debug_only(f->do_oop((oop*)&_fullgc_alot_dummy_array);) } @@ -488,6 +490,35 @@ void Universe::fixup_mirrors(TRAPS) { java_lang_Class::set_fixup_mirror_list(NULL); } +#define assert_pll_locked(test) \ + assert(Heap_lock->test(), "Reference pending list access requires lock") + +#define assert_pll_ownership() assert_pll_locked(owned_by_self) + +oop Universe::reference_pending_list() { + assert_pll_ownership(); + return _reference_pending_list; +} + +void Universe::set_reference_pending_list(oop list) { + assert_pll_ownership(); + _reference_pending_list = list; +} + +bool Universe::has_reference_pending_list() { + assert_pll_ownership(); + return _reference_pending_list != NULL; +} + +oop Universe::swap_reference_pending_list(oop list) { + assert_pll_locked(is_locked); + return (oop)Atomic::xchg_ptr(list, &_reference_pending_list); +} + +#undef assert_pll_locked +#undef assert_pll_ownership + + static bool has_run_finalizers_on_exit = false; void Universe::run_finalizers_on_exit() { @@ -565,12 +596,14 @@ bool Universe::should_fill_in_stack_trace(Handle throwable) { oop Universe::gen_out_of_memory_error(oop default_err) { // generate an out of memory error: - // - if there is a preallocated error with backtrace available then return it wth - // a filled in stack trace. - // - if there are no preallocated errors with backtrace available then return - // an error without backtrace. + // - if there is a preallocated error and stack traces are available + // (j.l.Throwable is initialized), then return the preallocated + // error with a filled in stack trace, and with the message + // provided by the default error. + // - otherwise, return the default error, without a stack trace. int next; - if (_preallocated_out_of_memory_error_avail_count > 0) { + if ((_preallocated_out_of_memory_error_avail_count > 0) && + SystemDictionary::Throwable_klass()->is_initialized()) { next = (int)Atomic::add(-1, &_preallocated_out_of_memory_error_avail_count); assert(next < (int)PreallocatedOutOfMemoryErrorCount, "avail count is corrupt"); } else { diff --git a/hotspot/src/share/vm/memory/universe.hpp b/hotspot/src/share/vm/memory/universe.hpp index 054b11aa873..2ded08fc801 100644 --- a/hotspot/src/share/vm/memory/universe.hpp +++ b/hotspot/src/share/vm/memory/universe.hpp @@ -185,6 +185,9 @@ class Universe: AllStatic { static oop _allocation_context_notification_obj; + // References waiting to be transferred to the ReferenceHandler + static oop _reference_pending_list; + // The particular choice of collected heap. static CollectedHeap* _collectedHeap; @@ -334,6 +337,17 @@ class Universe: AllStatic { static inline oop allocation_context_notification_obj(); static inline void set_allocation_context_notification_obj(oop obj); + // Reference pending list manipulation. Access is protected by + // Heap_lock. The getter, setter and predicate require the caller + // owns the lock. Swap is used by parallel non-concurrent reference + // processing threads, where some higher level controller owns + // Heap_lock, so requires the lock is locked, but not necessarily by + // the current thread. + static oop reference_pending_list(); + static void set_reference_pending_list(oop list); + static bool has_reference_pending_list(); + static oop swap_reference_pending_list(oop list); + static Array* the_empty_int_array() { return _the_empty_int_array; } static Array* the_empty_short_array() { return _the_empty_short_array; } static Array* the_empty_method_array() { return _the_empty_method_array; } diff --git a/hotspot/src/share/vm/oops/arrayKlass.hpp b/hotspot/src/share/vm/oops/arrayKlass.hpp index 3761229a1ce..c7dcd1f8657 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.hpp +++ b/hotspot/src/share/vm/oops/arrayKlass.hpp @@ -56,7 +56,9 @@ class ArrayKlass: public Klass { void set_dimension(int dimension) { _dimension = dimension; } Klass* higher_dimension() const { return _higher_dimension; } + inline Klass* higher_dimension_acquire() const; // load with acquire semantics void set_higher_dimension(Klass* k) { _higher_dimension = k; } + inline void release_set_higher_dimension(Klass* k); // store with release semantics Klass** adr_higher_dimension() { return (Klass**)&this->_higher_dimension;} Klass* lower_dimension() const { return _lower_dimension; } diff --git a/hotspot/src/share/vm/oops/arrayKlass.inline.hpp b/hotspot/src/share/vm/oops/arrayKlass.inline.hpp new file mode 100644 index 00000000000..43f62915f34 --- /dev/null +++ b/hotspot/src/share/vm/oops/arrayKlass.inline.hpp @@ -0,0 +1,39 @@ +/* + * 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. + * + */ + +#ifndef SHARE_VM_OOPS_ARRAYKLASS_INLINE_HPP +#define SHARE_VM_OOPS_ARRAYKLASS_INLINE_HPP + +#include "runtime/orderAccess.inline.hpp" +#include "oops/arrayKlass.hpp" + +inline Klass* ArrayKlass::higher_dimension_acquire() const { + return (Klass*) OrderAccess::load_ptr_acquire(&_higher_dimension); +} + +inline void ArrayKlass::release_set_higher_dimension(Klass* k) { + OrderAccess::release_store_ptr(&_higher_dimension, k); +} + +#endif // SHARE_VM_OOPS_ARRAYKLASS_INLINE_HPP diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index d6b2323af28..ea49b1baf85 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -41,6 +41,7 @@ #include "memory/heapInspection.hpp" #include "memory/iterator.inline.hpp" #include "memory/metadataFactory.hpp" +#include "memory/metaspaceShared.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" #include "oops/fieldStreams.hpp" @@ -1041,7 +1042,8 @@ Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { } Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null, int n, TRAPS) { - if (this_k->array_klasses() == NULL) { + // Need load-acquire for lock-free read + if (this_k->array_klasses_acquire() == NULL) { if (or_null) return NULL; ResourceMark rm; @@ -1054,7 +1056,8 @@ Klass* InstanceKlass::array_klass_impl(instanceKlassHandle this_k, bool or_null, // Check if update has already taken place if (this_k->array_klasses() == NULL) { Klass* k = ObjArrayKlass::allocate_objArray_klass(this_k->class_loader_data(), 1, this_k, CHECK_NULL); - this_k->set_array_klasses(k); + // use 'release' to pair with lock-free load + this_k->release_set_array_klasses(k); } } } @@ -1970,11 +1973,6 @@ void InstanceKlass::remove_unshareable_info() { m->remove_unshareable_info(); } - // cached_class_file might be pointing to a malloc'ed buffer allocated by - // event-based tracing code at CDS dump time. It's not usable at runtime - // so let's clear it. - set_cached_class_file(NULL); - // do array classes also. array_klasses_do(remove_unshareable_in_class); } @@ -2068,6 +2066,7 @@ void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) { } void InstanceKlass::release_C_heap_structures() { + assert(!this->is_shared(), "should not be called for a shared class"); // Can't release the constant pool here because the constant pool can be // deallocated separately from the InstanceKlass for default methods and @@ -2248,8 +2247,8 @@ void InstanceKlass::set_package(ClassLoaderData* loader_data, TRAPS) { // the java.base module. If a non-java.base package is erroneously placed // in the java.base module it will be caught later when java.base // is defined by ModuleEntryTable::verify_javabase_packages check. - assert(ModuleEntryTable::javabase_module() != NULL, "java.base module is NULL"); - _package_entry = loader_data->packages()->lookup(pkg_name, ModuleEntryTable::javabase_module()); + assert(ModuleEntryTable::javabase_moduleEntry() != NULL, "java.base module is NULL"); + _package_entry = loader_data->packages()->lookup(pkg_name, ModuleEntryTable::javabase_moduleEntry()); } else { assert(loader_data->modules()->unnamed_module() != NULL, "unnamed module is NULL"); _package_entry = loader_data->packages()->lookup(pkg_name, @@ -3363,88 +3362,119 @@ void InstanceKlass::set_init_state(ClassState state) { #if INCLUDE_JVMTI -// RedefineClasses() support for previous versions: -int InstanceKlass::_previous_version_count = 0; +// RedefineClasses() support for previous versions -// Purge previous versions before adding new previous versions of the class. -void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { - if (ik->previous_versions() != NULL) { - // This klass has previous versions so see what we can cleanup - // while it is safe to do so. +// Globally, there is at least one previous version of a class to walk +// during class unloading, which is saved because old methods in the class +// are still running. Otherwise the previous version list is cleaned up. +bool InstanceKlass::_has_previous_versions = false; - int deleted_count = 0; // leave debugging breadcrumbs - int live_count = 0; - ClassLoaderData* loader_data = ik->class_loader_data(); - assert(loader_data != NULL, "should never be null"); +// Returns true if there are previous versions of a class for class +// unloading only. Also resets the flag to false. purge_previous_version +// will set the flag to true if there are any left, i.e., if there's any +// work to do for next time. This is to avoid the expensive code cache +// walk in CLDG::do_unloading(). +bool InstanceKlass::has_previous_versions_and_reset() { + bool ret = _has_previous_versions; + log_trace(redefine, class, iklass, purge)("Class unloading: has_previous_versions = %s", + ret ? "true" : "false"); + _has_previous_versions = false; + return ret; +} - ResourceMark rm; - log_trace(redefine, class, iklass, purge)("%s: previous versions", ik->external_name()); +// Purge previous versions before adding new previous versions of the class and +// during class unloading. +void InstanceKlass::purge_previous_version_list() { + assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); + assert(has_been_redefined(), "Should only be called for main class"); - // previous versions are linked together through the InstanceKlass - InstanceKlass* pv_node = ik->previous_versions(); - InstanceKlass* last = ik; - int version = 0; + // Quick exit. + if (previous_versions() == NULL) { + return; + } - // check the previous versions list - for (; pv_node != NULL; ) { + // This klass has previous versions so see what we can cleanup + // while it is safe to do so. - ConstantPool* pvcp = pv_node->constants(); - assert(pvcp != NULL, "cp ref was unexpectedly cleared"); + int deleted_count = 0; // leave debugging breadcrumbs + int live_count = 0; + ClassLoaderData* loader_data = class_loader_data(); + assert(loader_data != NULL, "should never be null"); - if (!pvcp->on_stack()) { - // If the constant pool isn't on stack, none of the methods - // are executing. Unlink this previous_version. - // The previous version InstanceKlass is on the ClassLoaderData deallocate list - // so will be deallocated during the next phase of class unloading. - log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is dead", p2i(pv_node)); - // For debugging purposes. - pv_node->set_is_scratch_class(); - pv_node->class_loader_data()->add_to_deallocate_list(pv_node); - pv_node = pv_node->previous_versions(); - last->link_previous_versions(pv_node); - deleted_count++; - version++; - continue; - } else { - log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node)); - assert(pvcp->pool_holder() != NULL, "Constant pool with no holder"); - guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack"); - live_count++; - } + ResourceMark rm; + log_trace(redefine, class, iklass, purge)("%s: previous versions", external_name()); - // At least one method is live in this previous version. - // Reset dead EMCP methods not to get breakpoints. - // All methods are deallocated when all of the methods for this class are no - // longer running. - Array* method_refs = pv_node->methods(); - if (method_refs != NULL) { - log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length()); - for (int j = 0; j < method_refs->length(); j++) { - Method* method = method_refs->at(j); + // previous versions are linked together through the InstanceKlass + InstanceKlass* pv_node = previous_versions(); + InstanceKlass* last = this; + int version = 0; - if (!method->on_stack()) { - // no breakpoints for non-running methods - if (method->is_running_emcp()) { - method->set_running_emcp(false); - } - } else { - assert (method->is_obsolete() || method->is_running_emcp(), - "emcp method cannot run after emcp bit is cleared"); - log_trace(redefine, class, iklass, purge) - ("purge: %s(%s): prev method @%d in version @%d is alive", - method->name()->as_C_string(), method->signature()->as_C_string(), j, version); + // check the previous versions list + for (; pv_node != NULL; ) { + + ConstantPool* pvcp = pv_node->constants(); + assert(pvcp != NULL, "cp ref was unexpectedly cleared"); + + if (!pvcp->on_stack()) { + // If the constant pool isn't on stack, none of the methods + // are executing. Unlink this previous_version. + // The previous version InstanceKlass is on the ClassLoaderData deallocate list + // so will be deallocated during the next phase of class unloading. + log_trace(redefine, class, iklass, purge) + ("previous version " INTPTR_FORMAT " is dead.", p2i(pv_node)); + // For debugging purposes. + pv_node->set_is_scratch_class(); + // Unlink from previous version list. + assert(pv_node->class_loader_data() == loader_data, "wrong loader_data"); + InstanceKlass* next = pv_node->previous_versions(); + pv_node->link_previous_versions(NULL); // point next to NULL + last->link_previous_versions(next); + // Add to the deallocate list after unlinking + loader_data->add_to_deallocate_list(pv_node); + pv_node = next; + deleted_count++; + version++; + continue; + } else { + log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node)); + assert(pvcp->pool_holder() != NULL, "Constant pool with no holder"); + guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack"); + live_count++; + // found a previous version for next time we do class unloading + _has_previous_versions = true; + } + + // At least one method is live in this previous version. + // Reset dead EMCP methods not to get breakpoints. + // All methods are deallocated when all of the methods for this class are no + // longer running. + Array* method_refs = pv_node->methods(); + if (method_refs != NULL) { + log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length()); + for (int j = 0; j < method_refs->length(); j++) { + Method* method = method_refs->at(j); + + if (!method->on_stack()) { + // no breakpoints for non-running methods + if (method->is_running_emcp()) { + method->set_running_emcp(false); } + } else { + assert (method->is_obsolete() || method->is_running_emcp(), + "emcp method cannot run after emcp bit is cleared"); + log_trace(redefine, class, iklass, purge) + ("purge: %s(%s): prev method @%d in version @%d is alive", + method->name()->as_C_string(), method->signature()->as_C_string(), j, version); } } - // next previous version - last = pv_node; - pv_node = pv_node->previous_versions(); - version++; } - log_trace(redefine, class, iklass, purge) - ("previous version stats: live=%d, deleted=%d", - live_count, deleted_count); + // next previous version + last = pv_node; + pv_node = pv_node->previous_versions(); + version++; } + log_trace(redefine, class, iklass, purge) + ("previous version stats: live=%d, deleted=%d", live_count, deleted_count); } void InstanceKlass::mark_newly_obsolete_methods(Array* old_methods, @@ -3516,8 +3546,8 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, log_trace(redefine, class, iklass, add) ("adding previous version ref for %s, EMCP_cnt=%d", scratch_class->external_name(), emcp_method_count); - // Clean out old previous versions - purge_previous_versions(this); + // Clean out old previous versions for this class + purge_previous_version_list(); // Mark newly obsolete methods in remaining previous versions. An EMCP method from // a previous redefinition may be made obsolete by this redefinition. @@ -3534,8 +3564,6 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, // For debugging purposes. scratch_class->set_is_scratch_class(); scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class()); - // Update count for class unloading. - _previous_version_count--; return; } @@ -3563,12 +3591,12 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, } // Add previous version if any methods are still running. - log_trace(redefine, class, iklass, add)("scratch class added; one of its methods is on_stack"); + // Set has_previous_version flag for processing during class unloading. + _has_previous_versions = true; + log_trace(redefine, class, iklass, add) ("scratch class added; one of its methods is on_stack."); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version"); scratch_class->link_previous_versions(previous_versions()); link_previous_versions(scratch_class()); - // Update count for class unloading. - _previous_version_count++; } // end add_previous_version() #endif // INCLUDE_JVMTI @@ -3622,6 +3650,15 @@ Method* InstanceKlass::method_with_orig_idnum(int idnum, int version) { } #if INCLUDE_JVMTI +JvmtiCachedClassFileData* InstanceKlass::get_cached_class_file() { + if (MetaspaceShared::is_in_shared_space(_cached_class_file)) { + // Ignore the archived class stream data + return NULL; + } else { + return _cached_class_file; + } +} + jint InstanceKlass::get_cached_class_file_len() { return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file); } @@ -3629,4 +3666,15 @@ jint InstanceKlass::get_cached_class_file_len() { unsigned char * InstanceKlass::get_cached_class_file_bytes() { return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file); } + +#if INCLUDE_CDS +JvmtiCachedClassFileData* InstanceKlass::get_archived_class_data() { + assert(this->is_shared(), "class should be shared"); + if (MetaspaceShared::is_in_shared_space(_cached_class_file)) { + return _cached_class_file; + } else { + return NULL; + } +} +#endif #endif diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 24da1868237..cdba02b1119 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -148,7 +148,7 @@ class InstanceKlass: public Klass { // Package this class is defined in PackageEntry* _package_entry; // Array classes holding elements of this class. - Klass* _array_klasses; + Klass* volatile _array_klasses; // Constant pool for this class. ConstantPool* _constants; // The InnerClasses attribute and EnclosingMethod attribute. The @@ -230,7 +230,7 @@ class InstanceKlass: public Klass { OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily) MemberNameTable* _member_names; // Member names JNIid* _jni_ids; // First JNI identifier for static fields in this class - jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none + jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none intptr_t _dep_context; // packed DependencyContext structure nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class #if INCLUDE_JVMTI @@ -368,7 +368,9 @@ class InstanceKlass: public Klass { // array klasses Klass* array_klasses() const { return _array_klasses; } + inline Klass* array_klasses_acquire() const; // load with acquire semantics void set_array_klasses(Klass* k) { _array_klasses = k; } + inline void release_set_array_klasses(Klass* k); // store with release semantics // methods Array* methods() const { return _methods; } @@ -617,8 +619,8 @@ class InstanceKlass: public Klass { objArrayOop signers() const; // host class - Klass* host_klass() const { - Klass** hk = (Klass**)adr_host_klass(); + InstanceKlass* host_klass() const { + InstanceKlass** hk = adr_host_klass(); if (hk == NULL) { return NULL; } else { @@ -626,9 +628,9 @@ class InstanceKlass: public Klass { return *hk; } } - void set_host_klass(const Klass* host) { + void set_host_klass(const InstanceKlass* host) { assert(is_anonymous(), "not anonymous"); - const Klass** addr = (const Klass**)adr_host_klass(); + const InstanceKlass** addr = (const InstanceKlass **)adr_host_klass(); assert(addr != NULL, "no reversed space"); if (addr != NULL) { *addr = host; @@ -707,6 +709,7 @@ class InstanceKlass: public Klass { // RedefineClasses() support for previous versions: void add_previous_version(instanceKlassHandle ikh, int emcp_method_count); + void purge_previous_version_list(); InstanceKlass* previous_versions() const { return _previous_versions; } #else @@ -766,16 +769,21 @@ public: } private: - static int _previous_version_count; + static bool _has_previous_versions; public: - static void purge_previous_versions(InstanceKlass* ik); - static bool has_previous_versions() { return _previous_version_count > 0; } + static void purge_previous_versions(InstanceKlass* ik) { + if (ik->has_been_redefined()) { + ik->purge_previous_version_list(); + } + } + + static bool has_previous_versions_and_reset(); // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation void set_cached_class_file(JvmtiCachedClassFileData *data) { _cached_class_file = data; } - JvmtiCachedClassFileData * get_cached_class_file() { return _cached_class_file; } + JvmtiCachedClassFileData * get_cached_class_file(); jint get_cached_class_file_len(); unsigned char * get_cached_class_file_bytes(); @@ -787,10 +795,17 @@ public: return _jvmti_cached_class_field_map; } +#if INCLUDE_CDS + void set_archived_class_data(JvmtiCachedClassFileData* data) { + _cached_class_file = data; + } + + JvmtiCachedClassFileData * get_archived_class_data(); +#endif // INCLUDE_CDS #else // INCLUDE_JVMTI static void purge_previous_versions(InstanceKlass* ik) { return; }; - static bool has_previous_versions() { return false; } + static bool has_previous_versions_and_reset() { return false; } void set_cached_class_file(JvmtiCachedClassFileData *data) { assert(data == NULL, "unexpected call with JVMTI disabled"); @@ -1055,13 +1070,13 @@ public: } }; - Klass** adr_host_klass() const { + InstanceKlass** adr_host_klass() const { if (is_anonymous()) { - Klass** adr_impl = adr_implementor(); + InstanceKlass** adr_impl = (InstanceKlass **)adr_implementor(); if (adr_impl != NULL) { return adr_impl + 1; } else { - return end_of_nonstatic_oop_maps(); + return (InstanceKlass **)end_of_nonstatic_oop_maps(); } } else { return NULL; @@ -1238,10 +1253,8 @@ private: // cache management logic if the caches can grow instead of just // going from NULL to non-NULL. bool idnum_can_increment() const { return has_been_redefined(); } - jmethodID* methods_jmethod_ids_acquire() const - { return (jmethodID*)OrderAccess::load_ptr_acquire(&_methods_jmethod_ids); } - void release_set_methods_jmethod_ids(jmethodID* jmeths) - { OrderAccess::release_store_ptr(&_methods_jmethod_ids, jmeths); } + inline jmethodID* methods_jmethod_ids_acquire() const; + inline void release_set_methods_jmethod_ids(jmethodID* jmeths); // Lock during initialization public: diff --git a/hotspot/src/share/vm/oops/instanceKlass.inline.hpp b/hotspot/src/share/vm/oops/instanceKlass.inline.hpp index 3fe04808df4..a213272a9e5 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.inline.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.inline.hpp @@ -29,10 +29,27 @@ #include "oops/instanceKlass.hpp" #include "oops/klass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/orderAccess.inline.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" +inline Klass* InstanceKlass::array_klasses_acquire() const { + return (Klass*) OrderAccess::load_ptr_acquire(&_array_klasses); +} + +inline void InstanceKlass::release_set_array_klasses(Klass* k) { + OrderAccess::release_store_ptr(&_array_klasses, k); +} + +inline jmethodID* InstanceKlass::methods_jmethod_ids_acquire() const { + return (jmethodID*)OrderAccess::load_ptr_acquire(&_methods_jmethod_ids); +} + +inline void InstanceKlass::release_set_methods_jmethod_ids(jmethodID* jmeths) { + OrderAccess::release_store_ptr(&_methods_jmethod_ids, jmeths); +} + // The iteration over the oops in objects is a hot path in the GC code. // By force inlining the following functions, we get similar GC performance // as the previous macro based implementation. diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 804d02d0b08..4953f383120 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -530,7 +530,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec InstanceKlass* ik = (InstanceKlass*) k; module_entry = ik->module(); } else { - module_entry = ModuleEntryTable::javabase_module(); + module_entry = ModuleEntryTable::javabase_moduleEntry(); } // Obtain java.lang.reflect.Module, if available Handle module_handle(THREAD, ((module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL)); diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index f890d1d1e9b..95e38717dc5 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -30,7 +30,6 @@ #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/gcLocker.hpp" #include "gc/shared/generation.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/bytecodeTracer.hpp" #include "interpreter/bytecodes.hpp" @@ -400,12 +399,6 @@ void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) { return; } - // Do not profile method if current thread holds the pending list lock, - // which avoids deadlock for acquiring the MethodData_lock. - if (ReferencePendingListLocker::is_locked_by_self()) { - return; - } - // Grab a lock here to prevent multiple // MethodData*s from being created. MutexLocker ml(MethodData_lock, THREAD); diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 1abcc152fc6..bf2672daa78 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -34,6 +34,7 @@ #include "memory/metadataFactory.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" +#include "oops/arrayKlass.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.inline.hpp" @@ -42,7 +43,6 @@ #include "oops/symbol.hpp" #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" -#include "runtime/orderAccess.inline.hpp" #include "utilities/copy.hpp" #include "utilities/macros.hpp" @@ -321,7 +321,8 @@ Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { int dim = dimension(); if (dim == n) return this; - if (higher_dimension() == NULL) { + // lock-free read needs acquire semantics + if (higher_dimension_acquire() == NULL) { if (or_null) return NULL; ResourceMark rm; @@ -339,8 +340,8 @@ Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, CHECK_NULL); ObjArrayKlass* ak = ObjArrayKlass::cast(k); ak->set_lower_dimension(this); - OrderAccess::storestore(); - set_higher_dimension(ak); + // use 'release' to pair with lock-free load + release_set_higher_dimension(ak); assert(ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass"); } } diff --git a/hotspot/src/share/vm/oops/oop.hpp b/hotspot/src/share/vm/oops/oop.hpp index 23d73067178..647cec8c83a 100644 --- a/hotspot/src/share/vm/oops/oop.hpp +++ b/hotspot/src/share/vm/oops/oop.hpp @@ -87,6 +87,7 @@ class oopDesc { inline narrowKlass* compressed_klass_addr(); inline void set_klass(Klass* k); + inline void release_set_klass(Klass* k); // For klass field compression inline int klass_gap() const; diff --git a/hotspot/src/share/vm/oops/oop.inline.hpp b/hotspot/src/share/vm/oops/oop.inline.hpp index 578bcc4e520..9a981e05c19 100644 --- a/hotspot/src/share/vm/oops/oop.inline.hpp +++ b/hotspot/src/share/vm/oops/oop.inline.hpp @@ -129,10 +129,14 @@ narrowKlass* oopDesc::compressed_klass_addr() { return &_metadata._compressed_klass; } +#define CHECK_SET_KLASS(k) \ + do { \ + assert(Universe::is_bootstrapping() || k != NULL, "NULL Klass"); \ + assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass"); \ + } while (0) + void oopDesc::set_klass(Klass* k) { - // since klasses are promoted no store check is needed - assert(Universe::is_bootstrapping() || k != NULL, "must be a real Klass*"); - assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass*"); + CHECK_SET_KLASS(k); if (UseCompressedClassPointers) { *compressed_klass_addr() = Klass::encode_klass_not_null(k); } else { @@ -140,6 +144,18 @@ void oopDesc::set_klass(Klass* k) { } } +void oopDesc::release_set_klass(Klass* k) { + CHECK_SET_KLASS(k); + if (UseCompressedClassPointers) { + OrderAccess::release_store(compressed_klass_addr(), + Klass::encode_klass_not_null(k)); + } else { + OrderAccess::release_store_ptr(klass_addr(), k); + } +} + +#undef CHECK_SET_KLASS + int oopDesc::klass_gap() const { return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()); } diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.cpp b/hotspot/src/share/vm/oops/typeArrayKlass.cpp index 76b2bb8e6b9..5ce156026a9 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp @@ -34,6 +34,7 @@ #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "memory/universe.inline.hpp" +#include "oops/arrayKlass.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.hpp" @@ -41,7 +42,6 @@ #include "oops/typeArrayKlass.inline.hpp" #include "oops/typeArrayOop.inline.hpp" #include "runtime/handles.inline.hpp" -#include "runtime/orderAccess.inline.hpp" #include "utilities/macros.hpp" bool TypeArrayKlass::compute_is_subtype_of(Klass* k) { @@ -72,7 +72,7 @@ TypeArrayKlass* TypeArrayKlass::create_klass(BasicType type, null_loader_data->add_class(ak); // Call complete_create_array_klass after all instance variables have been initialized. - complete_create_array_klass(ak, ak->super(), ModuleEntryTable::javabase_module(), CHECK_NULL); + complete_create_array_klass(ak, ak->super(), ModuleEntryTable::javabase_moduleEntry(), CHECK_NULL); return ak; } @@ -166,7 +166,8 @@ Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { if (dim == n) return this; - if (higher_dimension() == NULL) { + // lock-free read needs acquire semantics + if (higher_dimension_acquire() == NULL) { if (or_null) return NULL; ResourceMark rm; @@ -181,8 +182,8 @@ Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { class_loader_data(), dim + 1, this, CHECK_NULL); ObjArrayKlass* h_ak = ObjArrayKlass::cast(oak); h_ak->set_lower_dimension(this); - OrderAccess::storestore(); - set_higher_dimension(h_ak); + // use 'release' to pair with lock-free load + release_set_higher_dimension(h_ak); assert(h_ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass"); } } @@ -346,7 +347,7 @@ const char* TypeArrayKlass::internal_name() const { // A TypeArrayKlass is an array of a primitive type, its defining module is java.base ModuleEntry* TypeArrayKlass::module() const { - return ModuleEntryTable::javabase_module(); + return ModuleEntryTable::javabase_moduleEntry(); } PackageEntry* TypeArrayKlass::package() const { diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index 848d1d504a5..32393fc03e2 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -536,6 +536,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt case vmIntrinsics::_isInterrupted: #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: + case vmIntrinsics::_getClassId: #endif case vmIntrinsics::_currentTimeMillis: case vmIntrinsics::_nanoTime: diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 0dc8e49f611..17ef1bc8c80 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -254,6 +254,9 @@ class LibraryCallKit : public GraphKit { bool inline_native_currentThread(); bool inline_native_time_funcs(address method, const char* funcName); +#ifdef TRACE_HAVE_INTRINSICS + bool inline_native_classID(); +#endif bool inline_native_isInterrupted(); bool inline_native_Class_query(vmIntrinsics::ID id); bool inline_native_subtype_check(); @@ -709,6 +712,7 @@ bool LibraryCallKit::try_to_inline(int predicate) { #ifdef TRACE_HAVE_INTRINSICS case vmIntrinsics::_counterTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime"); + case vmIntrinsics::_getClassId: return inline_native_classID(); #endif case vmIntrinsics::_currentTimeMillis: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis"); case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); @@ -3159,6 +3163,43 @@ bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* func return true; } +#ifdef TRACE_HAVE_INTRINSICS + +/* +* oop -> myklass +* myklass->trace_id |= USED +* return myklass->trace_id & ~0x3 +*/ +bool LibraryCallKit::inline_native_classID() { + Node* cls = null_check(argument(0), T_OBJECT); + Node* kls = load_klass_from_mirror(cls, false, NULL, 0); + kls = null_check(kls, T_OBJECT); + + ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET; + Node* insp = basic_plus_adr(kls, in_bytes(offset)); + Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered); + + Node* clsused = longcon(0x01l); // set the class bit + Node* orl = _gvn.transform(new OrLNode(tvalue, clsused)); + const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); + store_to_memory(control(), insp, orl, T_LONG, adr_type, MemNode::unordered); + +#ifdef TRACE_ID_META_BITS + Node* mbits = longcon(~TRACE_ID_META_BITS); + tvalue = _gvn.transform(new AndLNode(tvalue, mbits)); +#endif +#ifdef TRACE_ID_CLASS_SHIFT + Node* cbits = intcon(TRACE_ID_CLASS_SHIFT); + tvalue = _gvn.transform(new URShiftLNode(tvalue, cbits)); +#endif + + set_result(tvalue); + return true; + +} + +#endif + //------------------------inline_native_currentThread------------------ bool LibraryCallKit::inline_native_currentThread() { Node* junk = NULL; diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index b66c22bf74e..549e9f47109 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -3352,6 +3352,35 @@ JVM_ENTRY(jobjectArray, JVM_GetSystemPackages(JNIEnv *env)) JVM_END +// java.lang.ref.Reference /////////////////////////////////////////////////////////////// + + +JVM_ENTRY(jobject, JVM_GetAndClearReferencePendingList(JNIEnv* env)) + JVMWrapper("JVM_GetAndClearReferencePendingList"); + + MonitorLockerEx ml(Heap_lock); + oop ref = Universe::reference_pending_list(); + if (ref != NULL) { + Universe::set_reference_pending_list(NULL); + } + return JNIHandles::make_local(env, ref); +JVM_END + +JVM_ENTRY(jboolean, JVM_HasReferencePendingList(JNIEnv* env)) + JVMWrapper("JVM_HasReferencePendingList"); + MonitorLockerEx ml(Heap_lock); + return Universe::has_reference_pending_list(); +JVM_END + +JVM_ENTRY(void, JVM_WaitForReferencePendingList(JNIEnv* env)) + JVMWrapper("JVM_WaitForReferencePendingList"); + MonitorLockerEx ml(Heap_lock); + while (!Universe::has_reference_pending_list()) { + ml.wait(); + } +JVM_END + + // ObjectInputStream /////////////////////////////////////////////////////////////// bool force_verify_field_access(Klass* current_class, Klass* field_class, AccessFlags access, bool classloader_only) { diff --git a/hotspot/src/share/vm/prims/jvm.h b/hotspot/src/share/vm/prims/jvm.h index 58a8fbfeb75..5c7aefb7c0a 100644 --- a/hotspot/src/share/vm/prims/jvm.h +++ b/hotspot/src/share/vm/prims/jvm.h @@ -196,7 +196,8 @@ JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements) * java.lang.StackWalker */ enum { - JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x2, + JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x02, + JVM_STACKWALK_GET_CALLER_CLASS = 0x04, JVM_STACKWALK_SHOW_HIDDEN_FRAMES = 0x20, JVM_STACKWALK_FILL_LIVE_STACK_FRAMES = 0x100 }; @@ -296,6 +297,18 @@ JVM_GetSystemPackage(JNIEnv *env, jstring name); JNIEXPORT jobjectArray JNICALL JVM_GetSystemPackages(JNIEnv *env); +/* + * java.lang.ref.Reference + */ +JNIEXPORT jobject JNICALL +JVM_GetAndClearReferencePendingList(JNIEnv *env); + +JNIEXPORT jboolean JNICALL +JVM_HasReferencePendingList(JNIEnv *env); + +JNIEXPORT void JNICALL +JVM_WaitForReferencePendingList(JNIEnv *env); + /* * java.io.ObjectInputStream */ diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index f1c5f962b17..25ad11871fe 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -649,18 +649,14 @@ JvmtiEnv::GetErrorName(jvmtiError error, char** name_ptr) { jvmtiError JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) { + LogLevelType level = value == 0 ? LogLevel::Off : LogLevel::Info; switch (flag) { case JVMTI_VERBOSE_OTHER: // ignore break; case JVMTI_VERBOSE_CLASS: - if (value == 0) { - LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL); - LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL); - } else { - LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL); - LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL); - } + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, unload)); + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load)); break; case JVMTI_VERBOSE_GC: if (value == 0) { diff --git a/hotspot/src/share/vm/prims/jvmtiEventController.cpp b/hotspot/src/share/vm/prims/jvmtiEventController.cpp index 006feeab4c0..0f4d4913dbb 100644 --- a/hotspot/src/share/vm/prims/jvmtiEventController.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEventController.cpp @@ -96,7 +96,7 @@ static const jlong INTERP_EVENT_BITS = SINGLE_STEP_BIT | METHOD_ENTRY_BIT | ME static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS | BREAKPOINT_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | THREAD_END_BIT; static const jlong NEED_THREAD_LIFE_EVENTS = THREAD_FILTERED_EVENT_BITS | THREAD_START_BIT; -static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT | +static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | VM_START_BIT | VM_INIT_BIT | VM_DEATH_BIT | NATIVE_METHOD_BIND_BIT | THREAD_START_BIT | THREAD_END_BIT | COMPILED_METHOD_LOAD_BIT | COMPILED_METHOD_UNLOAD_BIT | diff --git a/hotspot/src/share/vm/prims/stackwalk.cpp b/hotspot/src/share/vm/prims/stackwalk.cpp index 3cce63b69bd..62a0a663cad 100644 --- a/hotspot/src/share/vm/prims/stackwalk.cpp +++ b/hotspot/src/share/vm/prims/stackwalk.cpp @@ -113,7 +113,10 @@ int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, int bci = stream.bci(); if (method == NULL) continue; - if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) { + + // skip hidden frames for default StackWalker option (i.e. SHOW_HIDDEN_FRAMES + // not set) and when StackWalker::getCallerClass is called + if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) { if (method->is_hidden()) { if (TraceStackWalk) { tty->print(" hidden method: "); method->print_short_name(); @@ -139,7 +142,14 @@ int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, Handle stackFrame(frames_array->obj_at(index)); fill_stackframe(stackFrame, method, bci); } else { - assert (use_frames_array(mode) == false, "Bad mode for get caller class"); + assert (use_frames_array(mode) == false, "Bad mode for filling in Class object"); + if (get_caller_class(mode) && index == start_index && method->caller_sensitive()) { + ResourceMark rm(THREAD); + THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), + err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method", + method->name_and_sig_as_C_string())); + } + frames_array->obj_at_put(index, method->method_holder()->java_mirror()); } if (++frames_decoded >= max_nframes) break; diff --git a/hotspot/src/share/vm/prims/stackwalk.hpp b/hotspot/src/share/vm/prims/stackwalk.hpp index cbc4405df81..580c953b197 100644 --- a/hotspot/src/share/vm/prims/stackwalk.hpp +++ b/hotspot/src/share/vm/prims/stackwalk.hpp @@ -82,6 +82,9 @@ private: static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci, javaVFrame* jvf, TRAPS); + static inline bool get_caller_class(int mode) { + return (mode & JVM_STACKWALK_GET_CALLER_CLASS) != 0; + } static inline bool skip_hidden_frames(int mode) { return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0; } diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 8b3acd836c3..1c98add775b 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -272,6 +272,31 @@ public: // Get/PutObject must be special-cased, since it works with handles. +// We could be accessing the referent field in a reference +// object. If G1 is enabled then we need to register non-null +// referent with the SATB barrier. + +#if INCLUDE_ALL_GCS +static bool is_java_lang_ref_Reference_access(oop o, jlong offset) { + if (offset == java_lang_ref_Reference::referent_offset && o != NULL) { + Klass* k = o->klass(); + if (InstanceKlass::cast(k)->reference_type() != REF_NONE) { + assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); + return true; + } + } + return false; +} +#endif + +static void ensure_satb_referent_alive(oop o, jlong offset, oop v) { +#if INCLUDE_ALL_GCS + if (UseG1GC && v != NULL && is_java_lang_ref_Reference_access(o, offset)) { + G1SATBCardTableModRefBS::enqueue(v); + } +#endif +} + // These functions allow a null base pointer with an arbitrary address. // But if the base pointer is non-null, the offset should make some sense. // That is, it should be in the range [0, MAX_OBJECT_SIZE]. @@ -286,34 +311,9 @@ UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, v = *(oop*)index_oop_from_field_offset_long(p, offset); } - jobject ret = JNIHandles::make_local(env, v); + ensure_satb_referent_alive(p, offset, v); -#if INCLUDE_ALL_GCS - // We could be accessing the referent field in a reference - // object. If G1 is enabled then we need to register non-null - // referent with the SATB barrier. - if (UseG1GC) { - bool needs_barrier = false; - - if (ret != NULL) { - if (offset == java_lang_ref_Reference::referent_offset && obj != NULL) { - oop o = JNIHandles::resolve(obj); - Klass* k = o->klass(); - if (InstanceKlass::cast(k)->reference_type() != REF_NONE) { - assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); - needs_barrier = true; - } - } - } - - if (needs_barrier) { - oop referent = JNIHandles::resolve(ret); - G1SATBCardTableModRefBS::enqueue(referent); - } - } -#endif // INCLUDE_ALL_GCS - - return ret; + return JNIHandles::make_local(env, v); } UNSAFE_END UNSAFE_ENTRY(void, Unsafe_PutObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) { @@ -333,6 +333,10 @@ UNSAFE_ENTRY(jobject, Unsafe_GetObjectVolatile(JNIEnv *env, jobject unsafe, jobj volatile oop v; + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + OrderAccess::fence(); + } + if (UseCompressedOops) { volatile narrowOop n = *(volatile narrowOop*) addr; (void)const_cast(v = oopDesc::decode_heap_oop(n)); @@ -340,6 +344,8 @@ UNSAFE_ENTRY(jobject, Unsafe_GetObjectVolatile(JNIEnv *env, jobject unsafe, jobj (void)const_cast(v = *(volatile oop*) addr); } + ensure_satb_referent_alive(p, offset, v); + OrderAccess::acquire(); return JNIHandles::make_local(env, v); } UNSAFE_END @@ -788,6 +794,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na // define a class but do not make it known to the class loader or system dictionary // - host_class: supplies context for linkage, access control, protection domain, and class loader +// if host_class is itself anonymous then it is replaced with its host class. // - data: bytes of a class file, a raw memory address (length gives the number of bytes) // - cp_patches: where non-null entries exist, they replace corresponding CP entries in data @@ -796,8 +803,12 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na // link to any member of U. Just after U is loaded, the only way to use it is reflectively, // through java.lang.Class methods like Class.newInstance. +// The package of an anonymous class must either match its host's class's package or be in the +// unnamed package. If it is in the unnamed package then it will be put in its host class's +// package. +// + // Access checks for linkage sites within U continue to follow the same rules as for named classes. -// The package of an anonymous class is given by the package qualifier on the name under which it was loaded. // An anonymous class also has special privileges to access any member of its host class. // This is the main reason why this loading operation is unsafe. The purpose of this is to // allow language implementations to simulate "open classes"; a host class in effect gets @@ -879,9 +890,11 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env, // Primitive types have NULL Klass* fields in their java.lang.Class instances. if (host_klass == NULL) { - THROW_0(vmSymbols::java_lang_IllegalArgumentException()); + THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Host class is null"); } + assert(host_klass->is_instance_klass(), "Host class must be an instance class"); + const char* host_source = host_klass->external_name(); Handle host_loader(THREAD, host_klass->class_loader()); Handle host_domain(THREAD, host_klass->protection_domain()); @@ -912,7 +925,7 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env, host_loader, host_domain, &st, - host_klass, + InstanceKlass::cast(host_klass), cp_patches, CHECK_NULL); if (anonk == NULL) { 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 a4decf9c983..e7e45e9fcd1 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -33,8 +33,9 @@ #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/taskqueue.hpp" #include "logging/log.hpp" -#include "logging/logTag.hpp" #include "logging/logConfiguration.hpp" +#include "logging/logStream.hpp" +#include "logging/logTag.hpp" #include "memory/allocation.inline.hpp" #include "memory/universe.inline.hpp" #include "oops/oop.inline.hpp" @@ -163,26 +164,47 @@ static void logOption(const char* opt) { bool needs_module_property_warning = false; -#define MODULE_PROPERTY_PREFIX "jdk.module" -#define MODULE_PROPERTY_PREFIX_LEN 10 -#define MODULE_MAIN_PROPERTY "jdk.module.main" -#define MODULE_MAIN_PROPERTY_LEN 15 +#define MODULE_PROPERTY_PREFIX "jdk.module." +#define MODULE_PROPERTY_PREFIX_LEN 11 +#define ADDEXPORTS "addexports" +#define ADDEXPORTS_LEN 10 +#define ADDREADS "addreads" +#define ADDREADS_LEN 8 +#define PATCH "patch" +#define PATCH_LEN 5 +#define ADDMODS "addmods" +#define ADDMODS_LEN 7 +#define LIMITMODS "limitmods" +#define LIMITMODS_LEN 9 +#define PATH "path" +#define PATH_LEN 4 +#define UPGRADE_PATH "upgrade.path" +#define UPGRADE_PATH_LEN 12 -// Return TRUE if option matches property, or property=, or property.. -static bool matches_property_prefix(const char* option, const char* property, size_t len) { - return (strncmp(option, property, len) == 0) && - (option[len] == '=' || option[len] == '.' || option[len] == '\0'); +// Return TRUE if option matches 'property', or 'property=', or 'property.'. +static bool matches_property_suffix(const char* option, const char* property, size_t len) { + return ((strncmp(option, property, len) == 0) && + (option[len] == '=' || option[len] == '.' || option[len] == '\0')); } -// Return true if the property is either "jdk.module" or starts with "jdk.module.", -// but does not start with "jdk.module.main". -// Return false if jdk.module.main because jdk.module.main and jdk.module.main.class -// are valid non-internal system properties. -// "property" should be passed without the leading "-D". +// Return true if property starts with "jdk.module." and its ensuing chars match +// any of the reserved module properties. +// property should be passed without the leading "-D". bool Arguments::is_internal_module_property(const char* property) { assert((strncmp(property, "-D", 2) != 0), "Unexpected leading -D"); - return (matches_property_prefix(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) && - !matches_property_prefix(property, MODULE_MAIN_PROPERTY, MODULE_MAIN_PROPERTY_LEN)); + if (strncmp(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) == 0) { + const char* property_suffix = property + MODULE_PROPERTY_PREFIX_LEN; + if (matches_property_suffix(property_suffix, ADDEXPORTS, ADDEXPORTS_LEN) || + matches_property_suffix(property_suffix, ADDREADS, ADDREADS_LEN) || + matches_property_suffix(property_suffix, PATCH, PATCH_LEN) || + matches_property_suffix(property_suffix, ADDMODS, ADDMODS_LEN) || + matches_property_suffix(property_suffix, LIMITMODS, LIMITMODS_LEN) || + matches_property_suffix(property_suffix, PATH, PATH_LEN) || + matches_property_suffix(property_suffix, UPGRADE_PATH, UPGRADE_PATH_LEN)) { + return true; + } + } + return false; } // Process java launcher properties. @@ -1286,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", @@ -1665,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 @@ -1997,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 } @@ -2544,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; @@ -2799,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; @@ -2851,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; } } @@ -3127,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 @@ -3538,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()) { @@ -3595,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 @@ -4155,7 +4151,10 @@ bool Arguments::handle_deprecated_print_gc_flags() { if (_gc_log_filename != NULL) { // -Xloggc was used to specify a filename const char* gc_conf = PrintGCDetails ? "gc*" : "gc"; - return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, NULL); + + LogTarget(Error, logging) target; + LogStreamCHeap errstream(target); + return LogConfiguration::parse_log_arguments(_gc_log_filename, gc_conf, NULL, NULL, &errstream); } else if (PrintGC || PrintGCDetails) { LogConfiguration::configure_stdout(LogLevel::Info, !PrintGCDetails, LOG_TAGS(gc)); } @@ -4287,8 +4286,8 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { } if (needs_module_property_warning) { - warning("Ignoring system property options whose names start with '-Djdk.module'." - " They are reserved for internal use."); + warning("Ignoring system property options whose names match the '-Djdk.module.*'." + " names that are reserved for internal use."); } #if defined(_ALLBSD_SOURCE) || defined(AIX) // UseLargePages is not yet supported on BSD and AIX. 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/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index a6c7a5370c5..ec1c15f7184 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1599,6 +1599,10 @@ public: product(bool, AlwaysPreTouch, false, \ "Force all freshly committed pages to be pre-touched") \ \ + product(size_t, PreTouchParallelChunkSize, 1 * G, \ + "Per-thread chunk size for parallel memory pre-touch.") \ + range(1, SIZE_MAX / 2) \ + \ product_pd(size_t, CMSYoungGenPerWorker, \ "The maximum size of young gen chosen by default per GC worker " \ "thread available") \ diff --git a/hotspot/src/share/vm/runtime/interfaceSupport.hpp b/hotspot/src/share/vm/runtime/interfaceSupport.hpp index 4d4d51b26a0..7b7d01fa9d3 100644 --- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp +++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp @@ -219,6 +219,9 @@ class ThreadInVMfromJava : public ThreadStateTransition { trans_from_java(_thread_in_vm); } ~ThreadInVMfromJava() { + if (_thread->stack_yellow_reserved_zone_disabled()) { + _thread->enable_stack_yellow_reserved_zone(); + } trans(_thread_in_vm, _thread_in_Java); // Check for pending. async. exceptions or suspends. if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(); @@ -277,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 } }; @@ -306,6 +310,9 @@ class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition { trans_from_java(_thread_in_vm); } ~ThreadInVMfromJavaNoAsyncException() { + if (_thread->stack_yellow_reserved_zone_disabled()) { + _thread->enable_stack_yellow_reserved_zone(); + } trans(_thread_in_vm, _thread_in_Java); // NOTE: We do not check for pending. async. exceptions. // If we did and moved the pending async exception over into the @@ -314,6 +321,7 @@ class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition { // to the _thread_in_vm state. Instead we postpone the handling of // the async exception. + // Check for pending. suspends only. if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false); diff --git a/hotspot/src/share/vm/runtime/mutexLocker.cpp b/hotspot/src/share/vm/runtime/mutexLocker.cpp index a01b4888500..88f5ab04457 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.cpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp @@ -77,6 +77,8 @@ Mutex* Shared_SATB_Q_lock = NULL; Mutex* DirtyCardQ_FL_lock = NULL; Monitor* DirtyCardQ_CBL_mon = NULL; Mutex* Shared_DirtyCardQ_lock = NULL; +Mutex* MarkStackFreeList_lock = NULL; +Mutex* MarkStackChunkList_lock = NULL; Mutex* ParGCRareEvent_lock = NULL; Mutex* DerivedPointerTableGC_lock = NULL; Mutex* Compile_lock = NULL; @@ -194,6 +196,9 @@ void mutex_init() { def(StringDedupQueue_lock , Monitor, leaf, true, Monitor::_safepoint_check_never); def(StringDedupTable_lock , Mutex , leaf, true, Monitor::_safepoint_check_never); + + def(MarkStackFreeList_lock , Mutex , leaf , true, Monitor::_safepoint_check_never); + def(MarkStackChunkList_lock , Mutex , leaf , true, Monitor::_safepoint_check_never); } def(ParGCRareEvent_lock , Mutex , leaf , true, Monitor::_safepoint_check_sometimes); def(DerivedPointerTableGC_lock , Mutex, leaf, true, Monitor::_safepoint_check_never); diff --git a/hotspot/src/share/vm/runtime/mutexLocker.hpp b/hotspot/src/share/vm/runtime/mutexLocker.hpp index ae4c79954ea..c0db4e9f4e6 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.hpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.hpp @@ -81,7 +81,8 @@ extern Monitor* DirtyCardQ_CBL_mon; // Protects dirty card Q extern Mutex* Shared_DirtyCardQ_lock; // Lock protecting dirty card // queue shared by // non-Java threads. - // (see option ExplicitGCInvokesConcurrent) +extern Mutex* MarkStackFreeList_lock; // Protects access to the global mark stack free list. +extern Mutex* MarkStackChunkList_lock; // Protects access to the global mark stack chunk list. extern Mutex* ParGCRareEvent_lock; // Synchronizes various (rare) parallel GC ops. extern Mutex* Compile_lock; // a lock held when Compilation is updating code (used to block CodeCache traversal, CHA updates, etc) extern Monitor* MethodCompileQueue_lock; // a lock held when method compilations are enqueued, dequeued diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 7089f6a6629..b73a4fa612d 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -1705,8 +1705,8 @@ bool os::release_memory(char* addr, size_t bytes) { return res; } -void os::pretouch_memory(void* start, void* end) { - for (volatile char *p = (char*)start; p < (char*)end; p += os::vm_page_size()) { +void os::pretouch_memory(void* start, void* end, size_t page_size) { + for (volatile char *p = (char*)start; p < (char*)end; p += page_size) { *p = 0; } } diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 431e7b2a985..0077b36d345 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -324,7 +324,7 @@ class os: AllStatic { // to make the OS back the memory range with actual memory. // Current implementation may not touch the last page if unaligned addresses // are passed. - static void pretouch_memory(void* start, void* end); + static void pretouch_memory(void* start, void* end, size_t page_size = vm_page_size()); enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX }; static bool protect_memory(char* addr, size_t bytes, ProtType prot, @@ -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/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index ae574a4edbf..b2fc1018828 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -412,13 +412,13 @@ oop Reflection::array_component_type(oop mirror, TRAPS) { return result; } -static bool under_host_klass(const InstanceKlass* ik, const Klass* host_klass) { +static bool under_host_klass(const InstanceKlass* ik, const InstanceKlass* host_klass) { DEBUG_ONLY(int inf_loop_check = 1000 * 1000 * 1000); for (;;) { - const Klass* hc = (const Klass*)ik->host_klass(); + const InstanceKlass* hc = ik->host_klass(); if (hc == NULL) return false; if (hc == host_klass) return true; - ik = InstanceKlass::cast(hc); + ik = hc; // There's no way to make a host class loop short of patching memory. // Therefore there cannot be a loop here unless there's another bug. @@ -436,8 +436,8 @@ static bool can_relax_access_check_for(const Klass* accessor, // If either is on the other's host_klass chain, access is OK, // because one is inside the other. - if (under_host_klass(accessor_ik, accessee) || - under_host_klass(accessee_ik, accessor)) + if (under_host_klass(accessor_ik, accessee_ik) || + under_host_klass(accessee_ik, accessor_ik)) return true; if ((RelaxAccessControlCheck && diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index f3481dad820..aa17ff69641 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -35,7 +35,6 @@ #include "compiler/compileTask.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/gcLocker.inline.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/workgroup.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" @@ -3718,14 +3717,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { Management::record_vm_init_completed(); #endif // INCLUDE_MANAGEMENT - // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and - // set_init_completed has just been called, causing exceptions not to be shortcut - // anymore. We call vm_exit_during_initialization directly instead. - - // Initialize reference pending list locker - bool needs_locker_thread = Universe::heap()->needs_reference_pending_list_locker_thread(); - ReferencePendingListLocker::initialize(needs_locker_thread, CHECK_JNI_ERR); - // Signal Dispatcher needs to be started before VMInit event is posted os::signal_init(); 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/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 6ea83ce0d3f..687dd22a902 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -54,7 +54,6 @@ #include "gc/shared/genCollectedHeap.hpp" #include "gc/shared/generation.hpp" #include "gc/shared/generationSpec.hpp" -#include "gc/shared/referencePendingListLocker.hpp" #include "gc/shared/space.hpp" #include "interpreter/bytecodeInterpreter.hpp" #include "interpreter/bytecodes.hpp" @@ -242,7 +241,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(ConstantPool, _reference_map, Array*) \ nonstatic_field(ConstantPoolCache, _length, int) \ nonstatic_field(ConstantPoolCache, _constant_pool, ConstantPool*) \ - nonstatic_field(InstanceKlass, _array_klasses, Klass*) \ + volatile_nonstatic_field(InstanceKlass, _array_klasses, Klass*) \ nonstatic_field(InstanceKlass, _methods, Array*) \ nonstatic_field(InstanceKlass, _default_methods, Array*) \ nonstatic_field(InstanceKlass, _local_interfaces, Array*) \ @@ -271,7 +270,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(InstanceKlass, _osr_nmethods_head, nmethod*) \ JVMTI_ONLY(nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*)) \ nonstatic_field(InstanceKlass, _generic_signature_index, u2) \ - nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ + volatile_nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \ nonstatic_field(InstanceKlass, _annotations, Annotations*) \ nonstatic_field(InstanceKlass, _method_ordering, Array*) \ @@ -1637,7 +1636,6 @@ typedef CompactHashtable SymbolCompactHashTable; declare_type(JavaThread, Thread) \ declare_type(JvmtiAgentThread, JavaThread) \ declare_type(ServiceThread, JavaThread) \ - declare_type(ReferencePendingListLockerThread, JavaThread) \ declare_type(CompilerThread, JavaThread) \ declare_type(CodeCacheSweeperThread, JavaThread) \ declare_toplevel_type(OSThread) \ @@ -2630,6 +2628,11 @@ typedef CompactHashtable SymbolCompactHashTable; declare_constant(Deoptimization::Reason_rtm_state_change) \ declare_constant(Deoptimization::Reason_unstable_if) \ declare_constant(Deoptimization::Reason_unstable_fused_if) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_aliasing))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_transfer_to_interpreter))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_not_compiled_exception_handler))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_unresolved))) \ + NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_jsr_mismatch))) \ declare_constant(Deoptimization::Reason_tenured) \ declare_constant(Deoptimization::Reason_LIMIT) \ declare_constant(Deoptimization::Reason_RECORDED_LIMIT) \ @@ -2754,7 +2757,13 @@ typedef CompactHashtable SymbolCompactHashTable; declare_constant(ConcreteRegisterImpl::number_of_registers) \ declare_preprocessor_constant("REG_COUNT", REG_COUNT) \ declare_c2_preprocessor_constant("SAVED_ON_ENTRY_REG_COUNT", SAVED_ON_ENTRY_REG_COUNT) \ - declare_c2_preprocessor_constant("C_SAVED_ON_ENTRY_REG_COUNT", C_SAVED_ON_ENTRY_REG_COUNT) + declare_c2_preprocessor_constant("C_SAVED_ON_ENTRY_REG_COUNT", C_SAVED_ON_ENTRY_REG_COUNT) \ + \ + /****************/ \ + /* JVMCI */ \ + /****************/ \ + \ + declare_preprocessor_constant("INCLUDE_JVMCI", INCLUDE_JVMCI) //-------------------------------------------------------------------------------- diff --git a/hotspot/src/share/vm/services/classLoadingService.cpp b/hotspot/src/share/vm/services/classLoadingService.cpp index 6d1f0cdb36f..185c04eeafa 100644 --- a/hotspot/src/share/vm/services/classLoadingService.cpp +++ b/hotspot/src/share/vm/services/classLoadingService.cpp @@ -183,11 +183,8 @@ size_t ClassLoadingService::compute_class_size(InstanceKlass* k) { bool ClassLoadingService::set_verbose(bool verbose) { MutexLocker m(Management_lock); // verbose will be set to the previous value - if (verbose) { - LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL); - } else { - LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL); - } + LogLevelType level = verbose ? LogLevel::Info : LogLevel::Off; + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load)); reset_trace_class_unloading(); return verbose; } @@ -196,11 +193,8 @@ bool ClassLoadingService::set_verbose(bool verbose) { void ClassLoadingService::reset_trace_class_unloading() { assert(Management_lock->owned_by_self(), "Must own the Management_lock"); bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); - if (value) { - LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL); - } else { - LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL); - } + LogLevelType level = value ? LogLevel::Info : LogLevel::Off; + LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, unload)); } GrowableArray* LoadedClassesEnumerator::_loaded_classes = NULL; 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/debug.cpp b/hotspot/src/share/vm/utilities/debug.cpp index d48479c303d..a6fd15bdaf1 100644 --- a/hotspot/src/share/vm/utilities/debug.cpp +++ b/hotspot/src/share/vm/utilities/debug.cpp @@ -282,6 +282,12 @@ void report_untested(const char* file, int line, const char* message) { } void report_out_of_shared_space(SharedSpaceType shared_space) { + if (shared_space == SharedOptional) { + // The estimated shared_optional_space size is large enough + // for all class bytes. It should not run out of space. + ShouldNotReachHere(); + } + static const char* name[] = { "shared read only space", "shared read write space", diff --git a/hotspot/src/share/vm/utilities/debug.hpp b/hotspot/src/share/vm/utilities/debug.hpp index d5da6db4cab..3a4483e681e 100644 --- a/hotspot/src/share/vm/utilities/debug.hpp +++ b/hotspot/src/share/vm/utilities/debug.hpp @@ -271,7 +271,8 @@ enum SharedSpaceType { SharedReadOnly, SharedReadWrite, SharedMiscData, - SharedMiscCode + SharedMiscCode, + SharedOptional }; void report_out_of_shared_space(SharedSpaceType space_type); 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/src/share/vm/utilities/globalDefinitions_xlc.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp index 68e204d45f0..ff97f116a77 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp @@ -186,6 +186,6 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } // Inlining support #define NOINLINE -#define ALWAYSINLINE __attribute__((always_inline)) +#define ALWAYSINLINE inline __attribute__((always_inline)) #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP diff --git a/hotspot/src/share/vm/utilities/hashtable.inline.hpp b/hotspot/src/share/vm/utilities/hashtable.inline.hpp index 8497193bdc4..e6d7c61d4d5 100644 --- a/hotspot/src/share/vm/utilities/hashtable.inline.hpp +++ b/hotspot/src/share/vm/utilities/hashtable.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, 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 @@ -79,8 +79,8 @@ template inline BasicHashtableEntry* BasicHashtable::bucket(i template inline void HashtableBucket::set_entry(BasicHashtableEntry* l) { - // Warning: Preserve store ordering. The SystemDictionary is read - // without locks. The new SystemDictionaryEntry must be + // Warning: Preserve store ordering. The PackageEntryTable, ModuleEntryTable and + // SystemDictionary are read without locks. The new entry must be // complete before other threads can be allowed to see it // via a store to _buckets[index]. OrderAccess::release_store_ptr(&_entry, l); @@ -88,8 +88,8 @@ template inline void HashtableBucket::set_entry(BasicHashtableEn template inline BasicHashtableEntry* HashtableBucket::get_entry() const { - // Warning: Preserve load ordering. The SystemDictionary is read - // without locks. The new SystemDictionaryEntry must be + // Warning: Preserve load ordering. The PackageEntryTable, ModuleEntryTable and + // SystemDictionary are read without locks. The new entry must be // complete before other threads can be allowed to see it // via a store to _buckets[index]. return (BasicHashtableEntry*) OrderAccess::load_ptr_acquire(&_entry); diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index c6543b71cab..76087d52bfe 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -56,12 +56,10 @@ void InternalVMTests::run() { run_unit_test(CollectedHeap_test); run_unit_test(QuickSort_test); run_unit_test(GuardedMemory_test); - run_unit_test(AltHashing_test); run_unit_test(TestNewSize_test); run_unit_test(TestOldSize_test); run_unit_test(TestKlass_test); run_unit_test(TestBitMap_test); - run_unit_test(TestAsUtf8); run_unit_test(TestResourcehash_test); run_unit_test(ObjectMonitor_test); run_unit_test(Test_linked_list); @@ -89,16 +87,12 @@ void InternalVMTests::run() { run_unit_test(VMStructs_test); #endif #if INCLUDE_ALL_GCS - run_unit_test(TestOldFreeSpaceCalculation_test); run_unit_test(TestG1BiasedArray_test); run_unit_test(TestBufferingOopClosure_test); - run_unit_test(TestCodeCacheRemSet_test); if (UseG1GC) { run_unit_test(FreeRegionList_test); run_unit_test(IHOP_test); } - run_unit_test(test_memset_with_concurrent_readers); - run_unit_test(TestPredictions_test); run_unit_test(WorkerDataArray_test); run_unit_test(ParallelCompact_test); #endif diff --git a/hotspot/src/share/vm/utilities/utf8.cpp b/hotspot/src/share/vm/utilities/utf8.cpp index 93ad3e23d89..0f479bad8dd 100644 --- a/hotspot/src/share/vm/utilities/utf8.cpp +++ b/hotspot/src/share/vm/utilities/utf8.cpp @@ -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 @@ -547,30 +547,3 @@ template int UNICODE::quoted_ascii_length(jbyte* base, int length); template int UNICODE::quoted_ascii_length(jchar* base, int length); template void UNICODE::as_quoted_ascii(const jbyte* base, int length, char* buf, int buflen); template void UNICODE::as_quoted_ascii(const jchar* base, int length, char* buf, int buflen); - - -#ifndef PRODUCT -void TestAsUtf8() { - char res[60]; - jchar str[20]; - - for (int i = 0; i < 20; i++) { - str[i] = 0x0800; // char that is 2B in UTF-16 but 3B in UTF-8 - } - str[19] = (jchar)'\0'; - - // The resulting string in UTF-8 is 3*19 bytes long, but should be truncated - UNICODE::as_utf8(str, 19, res, 10); - assert(strlen(res) == 9, "string should be truncated here"); - - UNICODE::as_utf8(str, 19, res, 18); - assert(strlen(res) == 15, "string should be truncated here"); - - UNICODE::as_utf8(str, 19, res, 20); - assert(strlen(res) == 18, "string should be truncated here"); - - // Test with an "unbounded" buffer - UNICODE::as_utf8(str, 19, res, INT_MAX); - assert(strlen(res) == 3*19, "string should end here"); -} -#endif diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 2fdda388eea..fc1eae68feb 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -168,7 +168,6 @@ needs_compact3 = \ runtime/InternalApi/ThreadCpuTimesDeadlock.java \ runtime/NMT/JcmdSummaryDiff.java \ runtime/RedefineTests/RedefineAnnotations.java \ - serviceability/sa/jmap-hashcode/Test8028623.java \ serviceability/threads/TestFalseDeadLock.java \ compiler/codecache/jmx \ compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java \ diff --git a/hotspot/test/compiler/c2/Test6968348.java b/hotspot/test/compiler/c2/Test6968348.java index be609bfbb8f..29da68e4af2 100644 --- a/hotspot/test/compiler/c2/Test6968348.java +++ b/hotspot/test/compiler/c2/Test6968348.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 @@ -38,15 +38,11 @@ import jdk.internal.misc.Unsafe; import java.lang.reflect.Field; public class Test6968348 { - static Unsafe unsafe; + static Unsafe unsafe = Unsafe.getUnsafe(); static final long[] buffer = new long[4096]; static int array_long_base_offset; public static void main(String[] args) throws Exception { - Class c = Test6968348.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe)f.get(c); array_long_base_offset = unsafe.arrayBaseOffset(long[].class); for (int n = 0; n < 100000; n++) { diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java index 4499ed5b981..ec953664cc2 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.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 @@ -50,14 +50,10 @@ public class TestIntUnsafeCAS { private static final int ALIGN_OFF = 8; private static final int UNALIGN_OFF = 5; - private static final Unsafe unsafe; + private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final int BASE; static { try { - Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe)f.get(c); BASE = unsafe.arrayBaseOffset(int[].class); } catch (Exception e) { InternalError err = new InternalError(); diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java index 3298e1ba94d..4625fcce04d 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.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 @@ -50,14 +50,10 @@ public class TestIntUnsafeOrdered { private static final int ALIGN_OFF = 8; private static final int UNALIGN_OFF = 5; - private static final Unsafe unsafe; + private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final int BASE; static { try { - Class c = Unsafe.class; - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(c); BASE = unsafe.arrayBaseOffset(int[].class); } catch (Exception e) { InternalError err = new InternalError(); diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java index 6bcd3983a7f..f0272b4faaf 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.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 @@ -50,14 +50,10 @@ public class TestIntUnsafeVolatile { private static final int ALIGN_OFF = 8; private static final int UNALIGN_OFF = 5; - private static final Unsafe unsafe; + private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final int BASE; static { try { - Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe)f.get(c); BASE = unsafe.arrayBaseOffset(int[].class); } catch (Exception e) { InternalError err = new InternalError(); 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/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java index b56d1b4e5bf..30e7ab0526d 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java +++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java @@ -27,7 +27,6 @@ * @bug 8142386 * @summary Unsafe access to an array is wrongly marked as mismatched * @modules java.base/jdk.internal.misc - * @library /test/lib * * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation * compiler.intrinsics.unsafe.TestUnsafeMismatchedArrayFieldAccess @@ -36,11 +35,10 @@ package compiler.intrinsics.unsafe; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; public class TestUnsafeMismatchedArrayFieldAccess { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); static { try { diff --git a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java index 80650b97136..cc672bc124d 100644 --- a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java +++ b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java @@ -62,7 +62,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.IRETURN; public class CallSiteDepContextTest { static final Unsafe UNSAFE = Unsafe.getUnsafe(); static final MethodHandles.Lookup LOOKUP = MethodHandleHelper.IMPL_LOOKUP; - static final String CLASS_NAME = "java/lang/invoke/Test"; + static final String CLASS_NAME = "compiler/jsr292/Test"; static final String METHOD_NAME = "m"; static final MethodType TYPE = MethodType.methodType(int.class); @@ -129,8 +129,8 @@ public class CallSiteDepContextTest { } public static void testSharedCallSite() throws Throwable { - Class cls1 = UNSAFE.defineAnonymousClass(Object.class, getClassFile("CS_1"), null); - Class cls2 = UNSAFE.defineAnonymousClass(Object.class, getClassFile("CS_2"), null); + Class cls1 = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("CS_1"), null); + Class cls2 = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("CS_2"), null); MethodHandle[] mhs = new MethodHandle[] { LOOKUP.findStatic(cls1, METHOD_NAME, TYPE), @@ -151,7 +151,7 @@ public class CallSiteDepContextTest { execute(1, mh); // mcs.context == cls1 - Class cls1 = UNSAFE.defineAnonymousClass(Object.class, getClassFile("NonBound_1"), null); + Class cls1 = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("NonBound_1"), null); MethodHandle mh1 = LOOKUP.findStatic(cls1, METHOD_NAME, TYPE); execute(1, mh1); @@ -170,8 +170,8 @@ public class CallSiteDepContextTest { mcs = new MutableCallSite(LOOKUP.findStatic(T.class, "f1", TYPE)); Class[] cls = new Class[] { - UNSAFE.defineAnonymousClass(Object.class, getClassFile("GC_1" + id), null), - UNSAFE.defineAnonymousClass(Object.class, getClassFile("GC_2" + id), null), + UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("GC_1" + id), null), + UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("GC_2" + id), null), }; MethodHandle[] mhs = new MethodHandle[] { @@ -185,7 +185,7 @@ public class CallSiteDepContextTest { execute(1, mhs); ref = new PhantomReference<>(cls[0], rq); - cls[0] = UNSAFE.defineAnonymousClass(Object.class, getClassFile("GC_3" + id), null); + cls[0] = UNSAFE.defineAnonymousClass(CallSiteDepContextTest.class, getClassFile("GC_3" + id), null); mhs[0] = LOOKUP.findStatic(cls[0], METHOD_NAME, TYPE); do { diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java index d1f8faaca66..24a60d4992e 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java @@ -45,7 +45,6 @@ package compiler.jvmci.compilerToVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; @@ -109,7 +108,7 @@ public class GetResolvedJavaMethodTest { abstract HotSpotResolvedJavaMethod getResolvedJavaMethod(); } - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final Field METASPACE_METHOD_FIELD; private static final Class TEST_CLASS = GetResolvedJavaMethodTest.class; diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java index 80021f8e79b..38adf2fc720 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java @@ -53,7 +53,6 @@ package compiler.jvmci.compilerToVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; @@ -154,7 +153,7 @@ public class GetResolvedJavaTypeTest { abstract HotSpotResolvedObjectType getResolvedJavaType(); } - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class; /* a compressed parameter for tested method is set to false because diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java index 4985773a831..202eaa003c0 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java @@ -53,7 +53,6 @@ import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; import jdk.internal.misc.Unsafe; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.test.lib.Asserts; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.meta.ConstantPool; @@ -69,7 +68,7 @@ import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CON */ public class ResolveFieldInPoolTest { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public static void main(String[] args) throws Exception { Map typeTests = new HashMap<>(); diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java index e6416fdbab6..f3fd052a5ae 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java @@ -52,7 +52,6 @@ import compiler.jvmci.common.testcases.SingleSubclassedClass; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; @@ -61,7 +60,7 @@ import java.util.HashSet; import java.util.Set; public class ResolveMethodTest { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public static void main(String args[]) { ResolveMethodTest test = new ResolveMethodTest(); diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java index 9caed4279dd..4a9532809c7 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java index ccbc9d981a3..0800e7bea10 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java @@ -23,7 +23,7 @@ /** * @test - * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" + * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9") & os.arch != "aarch64" * @library /test/lib / * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code diff --git a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java index 686e2f465e2..cdc7254df22 100644 --- a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java +++ b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java @@ -34,7 +34,6 @@ package compiler.loopopts.superword; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; public class TestVectorizationWithInvariant { @@ -43,7 +42,7 @@ public class TestVectorizationWithInvariant { private static final long CHAR_ARRAY_OFFSET; static { - unsafe = UnsafeHelper.getUnsafe(); + unsafe = Unsafe.getUnsafe(); BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class); CHAR_ARRAY_OFFSET = unsafe.arrayBaseOffset(char[].class); } diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java index 163e0020f59..c99a20274a3 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java @@ -50,7 +50,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -126,7 +125,7 @@ public class TestRTMAbortRatio extends CommandLineOptionTest { public static class Test implements CompilableTest { private static final int TOTAL_ITERATIONS = 10000; private static final int WARMUP_ITERATIONS = 1000; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java index 0a0f4ec32d5..1c8d3d53727 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java @@ -52,7 +52,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -159,7 +158,7 @@ public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest { private static int field = 0; private static final int ITERATIONS = 10000; private static final int RANGE_CHECK_AT = ITERATIONS / 2; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); @Override diff --git a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java index afe07c656be..6330ed272de 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java @@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -134,7 +133,7 @@ public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest { } public static class Test implements CompilableTest { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); @Override diff --git a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java index b6a1b664721..d8bbda017ec 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java @@ -50,7 +50,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -143,7 +142,7 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest { @SuppressWarnings("UnsuedDeclaration") private static int field = 0; private static final int TOTAL_ITERATIONS = 10000; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); diff --git a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java index 7a4a4aef091..df98916596d 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java @@ -50,7 +50,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -114,7 +113,7 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest { public static class Test implements CompilableTest { private static final long TOTAL_ITERATIONS = 10000L; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") diff --git a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java index ab476b311c2..c62f7043f83 100644 --- a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java +++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.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 @@ -25,7 +25,6 @@ package compiler.testlibrary.rtm; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; /** * Current RTM locking implementation force transaction abort @@ -35,7 +34,7 @@ class XAbortProvoker extends AbortProvoker { // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") private static int field = 0; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public XAbortProvoker() { this(new Object()); diff --git a/hotspot/test/compiler/unsafe/UnsafeRaw.java b/hotspot/test/compiler/unsafe/UnsafeRaw.java index 3bf38ca941d..82795e98b0a 100644 --- a/hotspot/test/compiler/unsafe/UnsafeRaw.java +++ b/hotspot/test/compiler/unsafe/UnsafeRaw.java @@ -35,7 +35,6 @@ package compiler.unsafe; import jdk.internal.misc.Unsafe; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import java.util.Random; @@ -82,7 +81,7 @@ public class UnsafeRaw { } public static void main(String[] args) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); final int array_size = 128; final int element_size = 4; final int magic = 0x12345678; diff --git a/hotspot/test/gc/TestAgeOutput.java b/hotspot/test/gc/TestAgeOutput.java new file mode 100644 index 00000000000..6be8c14e0e0 --- /dev/null +++ b/hotspot/test/gc/TestAgeOutput.java @@ -0,0 +1,103 @@ +/* + * 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 TestAgeOutput + * @bug 8164936 + * @summary Check that collectors using age table based aging print an age table even for the first garbage collection + * @key gc + * @requires vm.gc=="null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -XX:+UseSerialGC TestAgeOutput UseSerialGC + * @run main/othervm -XX:+UseConcMarkSweepGC TestAgeOutput UseConcMarkSweepGC + * @run main/othervm -XX:+UseG1GC TestAgeOutput UseG1GC + */ + +import sun.hotspot.WhiteBox; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import static jdk.test.lib.Asserts.*; + +public class TestAgeOutput { + + public static void checkPattern(String pattern, String what) throws Exception { + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(what); + + if (!m.find()) { + throw new RuntimeException("Could not find pattern " + pattern + " in output"); + } + } + + public static void runTest(String gcArg) throws Exception { + final String[] arguments = { + "-Xbootclasspath/a:.", + "-XX:+UnlockExperimentalVMOptions", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:+" + gcArg, + "-Xmx10M", + "-Xlog:gc+age=trace", + GCTest.class.getName() + }; + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + System.out.println(output.getStdout()); + + String stdout = output.getStdout(); + + checkPattern(".*GC\\(0\\) .*Desired survivor size.*", stdout); + checkPattern(".*GC\\(0\\) .*Age table with threshold.*", stdout); + checkPattern(".*GC\\(0\\) .*- age 1:.*", stdout); + } + + public static void main(String[] args) throws Exception { + runTest(args[0]); + } + + static class GCTest { + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static Object holder; + + public static void main(String [] args) { + holder = new byte[100]; + WB.youngGC(); + System.out.println(holder); + } + } +} + diff --git a/hotspot/test/gc/TestCardTablePageCommits.java b/hotspot/test/gc/TestCardTablePageCommits.java index fe50587d95a..e3d70b38533 100644 --- a/hotspot/test/gc/TestCardTablePageCommits.java +++ b/hotspot/test/gc/TestCardTablePageCommits.java @@ -34,7 +34,6 @@ import jdk.test.lib.Platform; * @requires vm.gc.Parallel * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @run driver TestCardTablePageCommits */ public class TestCardTablePageCommits { diff --git a/hotspot/test/gc/TestNumWorkerOutput.java b/hotspot/test/gc/TestNumWorkerOutput.java new file mode 100644 index 00000000000..0f69bd7fd81 --- /dev/null +++ b/hotspot/test/gc/TestNumWorkerOutput.java @@ -0,0 +1,103 @@ +/* + * 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 TestNumWorkerOutput + * @bug 8165292 + * @summary Check that when PrintGCDetails is enabled, gc,task output is printed only once per collection. + * @key gc + * @requires vm.gc=="null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -XX:+UseConcMarkSweepGC TestNumWorkerOutput UseConcMarkSweepGC + * @run main/othervm -XX:+UseG1GC TestNumWorkerOutput UseG1GC + */ + +import sun.hotspot.WhiteBox; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import static jdk.test.lib.Asserts.*; + +public class TestNumWorkerOutput { + + public static void checkPatternOnce(String pattern, String what) throws Exception { + Pattern r = Pattern.compile(pattern); + Matcher m = r.matcher(what); + + if (!m.find()) { + throw new RuntimeException("Could not find pattern " + pattern + " in output"); + } + if (m.find()) { + throw new RuntimeException("Could find pattern " + pattern + " in output more than once"); + } + } + + public static void runTest(String gcArg) throws Exception { + final String[] arguments = { + "-Xbootclasspath/a:.", + "-XX:+UnlockExperimentalVMOptions", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:+" + gcArg, + "-Xmx10M", + "-XX:+PrintGCDetails", + GCTest.class.getName() + }; + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + System.out.println(output.getStdout()); + + String stdout = output.getStdout(); + + checkPatternOnce(".*[info.*].*[gc,task.*].*GC\\(0\\) .*Using \\d+ workers of \\d+ for evacuation.*", stdout); + } + + public static void main(String[] args) throws Exception { + runTest(args[0]); + } + + static class GCTest { + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static Object holder; + + public static void main(String [] args) { + holder = new byte[100]; + WB.youngGC(); + System.out.println(holder); + } + } +} + diff --git a/hotspot/test/gc/TestObjectAlignment.java b/hotspot/test/gc/TestObjectAlignment.java index 9c6be10bd3f..ac4c1e267e7 100644 --- a/hotspot/test/gc/TestObjectAlignment.java +++ b/hotspot/test/gc/TestObjectAlignment.java @@ -28,7 +28,6 @@ * @summary G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16 * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 diff --git a/hotspot/test/gc/TestSmallHeap.java b/hotspot/test/gc/TestSmallHeap.java index f604a4c5a06..9fb8f36a851 100644 --- a/hotspot/test/gc/TestSmallHeap.java +++ b/hotspot/test/gc/TestSmallHeap.java @@ -28,7 +28,6 @@ * @summary Verify that starting the VM with a small heap works * @library /test/lib * @modules java.base/jdk.internal.misc - * @modules java.management/sun.management * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallHeap diff --git a/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java b/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java index 6ea205757e7..79afdfb6bff 100644 --- a/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java +++ b/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java @@ -27,7 +27,6 @@ * @summary Tests that all SoftReferences has been cleared at time of OOM. * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 512 2k * @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 128k 256k * @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 2k 32k diff --git a/hotspot/test/gc/TestVerifyDuringStartup.java b/hotspot/test/gc/TestVerifyDuringStartup.java index 7439e40c04e..744b52be360 100644 --- a/hotspot/test/gc/TestVerifyDuringStartup.java +++ b/hotspot/test/gc/TestVerifyDuringStartup.java @@ -27,7 +27,6 @@ * @summary Simple test run with -XX:+VerifyDuringStartup -XX:-UseTLAB to verify 8010463 * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management */ import jdk.test.lib.JDKToolFinder; diff --git a/hotspot/test/gc/TestVerifySilently.java b/hotspot/test/gc/TestVerifySilently.java index 7d11c44c7c3..5b811cfdc6d 100644 --- a/hotspot/test/gc/TestVerifySilently.java +++ b/hotspot/test/gc/TestVerifySilently.java @@ -27,7 +27,6 @@ * @summary Test silent verification. * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management */ import jdk.test.lib.process.ProcessTools; diff --git a/hotspot/test/gc/TestVerifySubSet.java b/hotspot/test/gc/TestVerifySubSet.java index c43079475bc..b8ac248541d 100644 --- a/hotspot/test/gc/TestVerifySubSet.java +++ b/hotspot/test/gc/TestVerifySubSet.java @@ -27,7 +27,6 @@ * @summary Test VerifySubSet option * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management */ import jdk.test.lib.process.ProcessTools; diff --git a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java index 51cc5550559..714674b853d 100644 --- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java +++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java @@ -37,7 +37,6 @@ import java.util.Collections; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class TestMaxMinHeapFreeRatioFlags { @@ -134,7 +133,7 @@ public class TestMaxMinHeapFreeRatioFlags { */ public static class RatioVerifier { - private static final Unsafe unsafe = UnsafeHelper.getUnsafe(); + private static final Unsafe unsafe = Unsafe.getUnsafe(); // Size of byte array that will be allocated public static final int CHUNK_SIZE = 1024; diff --git a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java index 2f980e5f325..60eef56287c 100644 --- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -46,7 +46,6 @@ import jdk.internal.misc.Unsafe; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import sun.hotspot.WhiteBox; /* In order to test that TargetSurvivorRatio affects survivor space occupancy @@ -249,7 +248,7 @@ public class TestTargetSurvivorRatioFlag { public static class TargetSurvivorRatioVerifier { static final WhiteBox wb = WhiteBox.getWhiteBox(); - static final Unsafe unsafe = UnsafeHelper.getUnsafe(); + static final Unsafe unsafe = Unsafe.getUnsafe(); // Desired size of memory allocated at once public static final int CHUNK_SIZE = 1024; 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/gc/g1/TestEagerReclaimHumongousRegions.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java index 71ec43de6ff..1a7945b4791 100644 --- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java @@ -27,6 +27,7 @@ * @summary Test to make sure that eager reclaim of humongous objects work. We simply try to fill * up the heap with humongous objects that should be eagerly reclaimable to avoid Full GC. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java index a516e02185a..d36782936d5 100644 --- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java @@ -27,6 +27,7 @@ * @summary Test to make sure that eager reclaim of humongous objects correctly clears * mark bitmaps at reclaim. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java index 6bfa89b00bf..8643564236a 100644 --- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java @@ -30,6 +30,7 @@ * referencing that we know is in the old gen. After changing this reference, the object * should still be eagerly reclaimable to avoid Full GC. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java b/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java index 2c27eb276ab..aafc5aa3dfb 100644 --- a/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java +++ b/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java @@ -27,6 +27,7 @@ * @summary Ensure that the output for a G1TraceEagerReclaimHumongousObjects * includes the expected necessary messages. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestGCLogMessages.java b/hotspot/test/gc/g1/TestGCLogMessages.java index 776ef7d826a..6b2ac94d699 100644 --- a/hotspot/test/gc/g1/TestGCLogMessages.java +++ b/hotspot/test/gc/g1/TestGCLogMessages.java @@ -27,6 +27,7 @@ * @summary Ensure the output for a minor GC with G1 * includes the expected necessary messages. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java b/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java index c760c36db48..01fe107c725 100644 --- a/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java +++ b/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java @@ -25,6 +25,7 @@ * @test TestHumongousAllocInitialMark * @bug 7168848 * @summary G1: humongous object allocations should initiate marking cycles when necessary + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java index 7c0d7a170c3..ce01acd68a3 100644 --- a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java +++ b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java @@ -26,6 +26,7 @@ * @bug 8143587 * @summary G1: humongous object allocations should work even when there is * not enough space in the heapRegion to fit a filler object. + * @requires vm.gc.G1 * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver TestHumongousAllocNearlyFullRegion diff --git a/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java b/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java index 955474c99e6..8acd37ca497 100644 --- a/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java +++ b/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java @@ -26,6 +26,7 @@ * @key regression * @key gc * @bug 8027756 + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java b/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java index 79b797b4286..873851c3805 100644 --- a/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java +++ b/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java @@ -26,6 +26,7 @@ * @key gc * @bug 8014240 * @summary Test output of G1PrintRegionRememberedSetInfo + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java b/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java index 25e6a12ff5e..aa5192d843e 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java @@ -26,6 +26,7 @@ * @summary Test string deduplication age threshold * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java b/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java index 1c2ab7389c4..be88c99cdd1 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java @@ -26,6 +26,7 @@ * @summary Test string deduplication during full GC * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationInterned.java b/hotspot/test/gc/g1/TestStringDeduplicationInterned.java index 766c9f821b0..48f4b598d31 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationInterned.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationInterned.java @@ -26,6 +26,7 @@ * @summary Test string deduplication of interned strings * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java b/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java index 43940962f9b..bb47eb52c7f 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java @@ -26,6 +26,7 @@ * @summary Test string deduplication print options * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java b/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java index 5f466f3681d..7c52c36612c 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java @@ -26,6 +26,7 @@ * @summary Test string deduplication table rehash * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java b/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java index 1259869e4e5..2a72f4042e2 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java @@ -26,6 +26,7 @@ * @summary Test string deduplication table resize * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java b/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java index a65e4ab3ce2..4cbc744a6f6 100644 --- a/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java +++ b/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java @@ -26,6 +26,7 @@ * @summary Test string deduplication during young GC * @bug 8029075 * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/g1/TestStringSymbolTableStats.java b/hotspot/test/gc/g1/TestStringSymbolTableStats.java index 62994fa2d55..d0c3d312e91 100644 --- a/hotspot/test/gc/g1/TestStringSymbolTableStats.java +++ b/hotspot/test/gc/g1/TestStringSymbolTableStats.java @@ -26,6 +26,7 @@ * @bug 8027476 8027455 * @summary Ensure that the G1TraceStringSymbolTableScrubbing prints the expected message. * @key gc + * @requires vm.gc.G1 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/hotspot/test/gc/serial/HeapChangeLogging.java b/hotspot/test/gc/serial/HeapChangeLogging.java index a8ef6f64464..ffc646d5d46 100644 --- a/hotspot/test/gc/serial/HeapChangeLogging.java +++ b/hotspot/test/gc/serial/HeapChangeLogging.java @@ -24,9 +24,9 @@ /* * @test HeapChangeLogging.java * @bug 8027440 + * @requires vm.gc.Serial * @library /test/lib * @modules java.base/jdk.internal.misc - * java.management * @summary Allocate to get a promotion failure and verify that that heap change logging is present. * @run main HeapChangeLogging */ diff --git a/hotspot/test/gc/testlibrary/Helpers.java b/hotspot/test/gc/testlibrary/Helpers.java index e97d4a03ea9..e326308e5d1 100644 --- a/hotspot/test/gc/testlibrary/Helpers.java +++ b/hotspot/test/gc/testlibrary/Helpers.java @@ -32,7 +32,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; public class Helpers { @@ -124,20 +123,13 @@ public class Helpers { */ public static String generate(String className, String superClass, String constructor, long fieldCount) { - StringBuilder builder = new StringBuilder(); - builder.append(String.format("public class %s%s {\n", className, superClass == null ? "" - : " extends " + superClass)); - - if (constructor != null) { - builder.append(constructor); - } - - for (int i = 0; i < fieldCount; ++i) { - builder.append(String.format("long f%d;\n", i)); - } - - builder.append("}\n"); - return builder.toString(); + return new StringBuilder() + .append(String.format("public class %s%s {\n", className, superClass == null ? "" + : " extends " + superClass)) + .append(constructor == null ? "" : constructor) + .append(fieldsGenerator(fieldCount)) + .append("}\n") + .toString(); } /** @@ -212,50 +204,9 @@ public class Helpers { Path workDir, String prefix) throws IOException, ClassNotFoundException { - if (instanceSize % SIZE_OF_LONG != 0L) { - throw new Error(String.format("Test bug: only sizes aligned by 8 bytes are supported and %d was specified", - instanceSize)); - } + generateByTemplateAndCompile(className, null, "public class ${ClassName} extends ${BaseClass} {\n${Fields}}\n", + "", instanceSize, workDir, prefix); - long instanceSizeWithoutObjectHeader = instanceSize - WhiteBox.getWhiteBox().getObjectSize(new Object()); - - int generatedClassesCount; - int fieldsInLastClassCount; - - int sizeOfLastFile = (int) (instanceSizeWithoutObjectHeader - % (MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS * SIZE_OF_LONG)); - - if (sizeOfLastFile != 0) { - generatedClassesCount = (int) instanceSizeWithoutObjectHeader - / (MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS * SIZE_OF_LONG) + 1; - fieldsInLastClassCount = sizeOfLastFile / SIZE_OF_LONG; - } else { - generatedClassesCount = (int) instanceSizeWithoutObjectHeader - / (MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS * SIZE_OF_LONG); - fieldsInLastClassCount = MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS; - } - - for (int i = 0; i < generatedClassesCount; i++) { - // for the last generated class we use specified class name - String clsName = (i == generatedClassesCount - 1) ? className : prefix + i; - - // If we already have a file with the same name we do not create it again - if (Files.notExists(Paths.get(clsName + ".java"))) { - Helpers.compileClass(clsName, workDir, - Helpers.generate( - clsName, - // for first generated class we don't have 'extends' - (i == 0 ? null : prefix + (i - 1)), - null, - // for the last generated class we use different field count - (i == generatedClassesCount - 1) ? fieldsInLastClassCount - : MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS)); - } else { - System.out.println("Class " + clsName + - ".java already exists, skipping class' generation and compilation"); - } - - } return classLoader.loadClass(className); } diff --git a/hotspot/test/native/classfile/test_AltHashing.cpp b/hotspot/test/native/classfile/test_AltHashing.cpp new file mode 100644 index 00000000000..4718bdd97b2 --- /dev/null +++ b/hotspot/test/native/classfile/test_AltHashing.cpp @@ -0,0 +1,107 @@ +/* + * 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 "precompiled.hpp" +#include "classfile/altHashing.hpp" +#include "unittest.hpp" + +// Internal test for alternate hashing. Translated from JDK version +// test/sun/misc/Hashing.java +static const jbyte ONE_BYTE[] = {(jbyte) 0x80}; +static const jbyte TWO_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81}; +static const jchar ONE_CHAR[] = {(jchar) 0x8180}; +static const jbyte THREE_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82}; +static const jbyte FOUR_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83}; +static const jchar TWO_CHAR[] = {(jchar) 0x8180, (jchar) 0x8382}; +static const jint ONE_INT[] = {(jint) 0x83828180}; +static const jbyte SIX_BYTE[] = {(jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85}; +static const jchar THREE_CHAR[] = {(jchar) 0x8180, (jchar) 0x8382, (jchar) 0x8584}; +static const jbyte EIGHT_BYTE[] = { + (jbyte) 0x80, (jbyte) 0x81, (jbyte) 0x82, + (jbyte) 0x83, (jbyte) 0x84, (jbyte) 0x85, + (jbyte) 0x86, (jbyte) 0x87 +}; +static const jchar FOUR_CHAR[] = { + (jchar) 0x8180, (jchar) 0x8382, + (jchar) 0x8584, (jchar) 0x8786 +}; + +static const jint TWO_INT[] = {(jint) 0x83828180, (jint) 0x87868584}; +static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; + +class AltHashingTest : public ::testing::Test { + public: + + static juint murmur3_32(const int* data, int len) { + return AltHashing::murmur3_32(data, len); + } +}; + +TEST_F(AltHashingTest, murmur3_32_byte_array_test) { + jbyte vector[256]; + jbyte hashes[4 * 256]; + + for (int i = 0; i < 256; i++) { + vector[i] = (jbyte) i; + } + + // Hash subranges {}, {0}, {0,1}, {0,1,2}, ..., {0,...,255} + for (int i = 0; i < 256; i++) { + juint hash = AltHashing::murmur3_32(256 - i, vector, i); + hashes[i * 4] = (jbyte) hash; + hashes[i * 4 + 1] = (jbyte) (hash >> 8); + hashes[i * 4 + 2] = (jbyte) (hash >> 16); + hashes[i * 4 + 3] = (jbyte) (hash >> 24); + } + + // hash to get const result. + juint final_hash = AltHashing::murmur3_32(0, hashes, 4 * 256); + + ASSERT_EQ(MURMUR3_32_X86_CHECK_VALUE, final_hash) + << "Calculated hash result not as expected."; +} + +TEST_F(AltHashingTest, equivalent_hashes_test) { + juint jbytes, jchars, ints; + + jbytes = AltHashing::murmur3_32(0, TWO_BYTE, 2); + jchars = AltHashing::murmur3_32(0, ONE_CHAR, 1); + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + + jbytes = AltHashing::murmur3_32(0, FOUR_BYTE, 4); + jchars = AltHashing::murmur3_32(0, TWO_CHAR, 2); + ints = AltHashingTest::murmur3_32(ONE_INT, 1); + + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + ASSERT_EQ(jbytes, ints) << "Hashes did not match."; + + jbytes = AltHashing::murmur3_32(0, SIX_BYTE, 6); + jchars = AltHashing::murmur3_32(0, THREE_CHAR, 3); + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + + jbytes = AltHashing::murmur3_32(0, EIGHT_BYTE, 8); + jchars = AltHashing::murmur3_32(0, FOUR_CHAR, 4); + ints = AltHashingTest::murmur3_32(TWO_INT, 2); + + ASSERT_EQ(jbytes, jchars) << "Hashes did not match."; + ASSERT_EQ(jbytes, ints) << "Hashes did not match."; +} diff --git a/hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp b/hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp new file mode 100644 index 00000000000..4365e9929a8 --- /dev/null +++ b/hotspot/test/native/gc/g1/test_g1CodeCacheRemSet.cpp @@ -0,0 +1,94 @@ +/* + * 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. + */ + +#include "precompiled.hpp" +#include "gc/g1/g1CodeRootSetTable.hpp" +#include "gc/g1/g1CodeCacheRemSet.hpp" +#include "unittest.hpp" + +class G1CodeRootSetTest : public ::testing::Test { + public: + + size_t threshold() { + return G1CodeRootSet::Threshold; + } + + G1CodeRootSetTable* purge_list() { + return G1CodeRootSetTable::_purge_list; + } +}; + +TEST_VM_F(G1CodeRootSetTest, g1_code_cache_rem_set) { + G1CodeRootSet root_set; + + ASSERT_TRUE(root_set.is_empty()) << "Code root set must be initially empty " + "but is not."; + + ASSERT_EQ(G1CodeRootSet::static_mem_size(), sizeof (void*)) << + "The code root set's static memory usage is incorrect, " + << G1CodeRootSet::static_mem_size() << " bytes"; + + root_set.add((nmethod*) 1); + ASSERT_EQ(root_set.length(), (size_t) 1) << "Added exactly one element, but" + " set contains " << root_set.length() << " elements"; + + const size_t num_to_add = (size_t) threshold() + 1; + + for (size_t i = 1; i <= num_to_add; i++) { + root_set.add((nmethod*) 1); + } + ASSERT_EQ(root_set.length(), (size_t) 1) + << "Duplicate detection should not have increased the set size but " + << "is " << root_set.length(); + + for (size_t i = 2; i <= num_to_add; i++) { + root_set.add((nmethod*) (uintptr_t) (i)); + } + + ASSERT_EQ(root_set.length(), num_to_add) + << "After adding in total " << num_to_add << " distinct code roots, " + "they need to be in the set, but there are only " << root_set.length(); + + ASSERT_NE(purge_list(), (G1CodeRootSetTable*) NULL) + << "should have grown to large hashtable"; + + size_t num_popped = 0; + for (size_t i = 1; i <= num_to_add; i++) { + bool removed = root_set.remove((nmethod*) i); + if (removed) { + num_popped += 1; + } else { + break; + } + } + ASSERT_EQ(num_popped, num_to_add) + << "Managed to pop " << num_popped << " code roots, but only " + << num_to_add << " were added"; + ASSERT_NE(purge_list(), (G1CodeRootSetTable*) NULL) + << "should have grown to large hashtable"; + + G1CodeRootSet::purge(); + + ASSERT_EQ(purge_list(), (G1CodeRootSetTable*) NULL) + << "should have purged old small tables"; +} diff --git a/hotspot/test/native/gc/g1/test_g1Predictions.cpp b/hotspot/test/native/gc/g1/test_g1Predictions.cpp new file mode 100644 index 00000000000..6b08390d1f6 --- /dev/null +++ b/hotspot/test/native/gc/g1/test_g1Predictions.cpp @@ -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 "precompiled.hpp" +#include "gc/g1/g1Predictions.hpp" +#include "unittest.hpp" + +static const double epsilon = 1e-6; + +// Some basic formula tests with confidence = 0.0 +TEST_VM(G1Predictions, basic_predictions) { + G1Predictions predictor(0.0); + TruncatedSeq s; + + double p0 = predictor.get_new_prediction(&s); + ASSERT_LT(p0, epsilon) << "Initial prediction of empty sequence must be 0.0"; + + s.add(5.0); + double p1 = predictor.get_new_prediction(&s); + ASSERT_NEAR(p1, 5.0, epsilon); + + for (int i = 0; i < 40; i++) { + s.add(5.0); + } + double p2 = predictor.get_new_prediction(&s); + ASSERT_NEAR(p2, 5.0, epsilon); +} + +// The following tests checks that the initial predictions are based on +// the average of the sequence and not on the stddev (which is 0). +TEST_VM(G1Predictions, average_not_stdev_predictions) { + G1Predictions predictor(0.5); + TruncatedSeq s; + + s.add(1.0); + double p1 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, s.davg()) << "First prediction must be greater than average"; + + s.add(1.0); + double p2 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, p2) << "First prediction must be greater than second"; + + s.add(1.0); + double p3 = predictor.get_new_prediction(&s); + ASSERT_GT(p2, p3) << "Second prediction must be greater than third"; + + s.add(1.0); + s.add(1.0); // Five elements are now in the sequence. + double p4 = predictor.get_new_prediction(&s); + ASSERT_LT(p4, p3) << "Fourth prediction must be smaller than third"; + ASSERT_NEAR(p4, 1.0, epsilon); +} + +// The following tests checks that initially prediction based on +// the average is used, that gets overridden by the stddev prediction at +// the end. +TEST_VM(G1Predictions, average_stdev_predictions) { + G1Predictions predictor(0.5); + TruncatedSeq s; + + s.add(0.5); + double p1 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, s.davg()) << "First prediction must be greater than average"; + + s.add(0.2); + double p2 = predictor.get_new_prediction(&s); + ASSERT_GT(p1, p2) << "First prediction must be greater than second"; + + s.add(0.5); + double p3 = predictor.get_new_prediction(&s); + ASSERT_GT(p2, p3) << "Second prediction must be greater than third"; + + s.add(0.2); + s.add(2.0); + double p4 = predictor.get_new_prediction(&s); + ASSERT_GT(p4, p3) << "Fourth prediction must be greater than third"; +} diff --git a/hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp b/hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp new file mode 100644 index 00000000000..a3971c69257 --- /dev/null +++ b/hotspot/test/native/gc/parallel/test_psAdaptiveSizePolicy.cpp @@ -0,0 +1,61 @@ +/* + * 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 "precompiled.hpp" +#include "utilities/macros.hpp" +#include "gc/parallel/psAdaptiveSizePolicy.hpp" +#include "unittest.hpp" + +#if INCLUDE_ALL_GCS + + TEST_VM(gc, oldFreeSpaceCalculation) { + + struct TestCase { + size_t live; + uintx ratio; + size_t expectedResult; + }; + + TestCase test_cases[] = { + {100, 20, 25}, + {100, 50, 100}, + {100, 60, 150}, + {100, 75, 300}, + {400, 20, 100}, + {400, 50, 400}, + {400, 60, 600}, + {400, 75, 1200}, + }; + + size_t array_len = sizeof(test_cases) / sizeof(TestCase); + for (size_t i = 0; i < array_len; ++i) { + ASSERT_EQ(PSAdaptiveSizePolicy::calculate_free_based_on_live( + test_cases[i].live, test_cases[i].ratio), + test_cases[i].expectedResult) + << " Calculation of free memory failed" + << " - Test case " << i << ": live = " << test_cases[i].live + << "; ratio = " << test_cases[i].ratio; + } + } +#endif diff --git a/hotspot/src/share/vm/gc/shared/memset_with_concurrent_readers.cpp b/hotspot/test/native/gc/shared/test_memset_with_concurrent_readers.cpp similarity index 69% rename from hotspot/src/share/vm/gc/shared/memset_with_concurrent_readers.cpp rename to hotspot/test/native/gc/shared/test_memset_with_concurrent_readers.cpp index 27625a30dfd..7af5b232ad6 100644 --- a/hotspot/src/share/vm/gc/shared/memset_with_concurrent_readers.cpp +++ b/hotspot/test/native/gc/shared/test_memset_with_concurrent_readers.cpp @@ -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 @@ -19,30 +19,22 @@ * 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 "precompiled.hpp" - #include -#include "gc/shared/memset_with_concurrent_readers.hpp" -#include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" -#include "utilities/ostream.hpp" +#include +#include "gc/shared/memset_with_concurrent_readers.hpp" +#include "unittest.hpp" #if INCLUDE_ALL_GCS -// Unit test -#ifndef PRODUCT - static unsigned line_byte(const char* line, size_t i) { return unsigned(line[i]) & 0xFF; } -// Verify memset_with_concurrent_readers mimics memset. -// We don't attempt to verify the concurrent reader case. -void test_memset_with_concurrent_readers() { +TEST(gc, memset_with_concurrent_readers) { const size_t chunk_size = 8 * BytesPerWord; const unsigned chunk_count = 4; const size_t block_size = (chunk_count + 4) * chunk_size; @@ -76,29 +68,32 @@ void test_memset_with_concurrent_readers() { bool middle_set = !memcmp(set_block, block + set_start, set_size); bool tail_clear = !memcmp(clear_block, block + set_end, block_size - set_end); if (!(head_clear && middle_set && tail_clear)) { - tty->print_cr("*** memset_with_concurrent_readers failed: " - "set start " SIZE_FORMAT ", set end " SIZE_FORMAT, - set_start, set_end); + std::ostringstream err_stream; + err_stream << "*** memset_with_concurrent_readers failed: set start " + << set_start << ", set end " << set_end << std::endl; for (unsigned chunk = 0; chunk < (block_size / chunk_size); ++chunk) { for (unsigned line = 0; line < (chunk_size / BytesPerWord); ++line) { + const char* lp = &block[chunk * chunk_size + line * BytesPerWord]; - tty->print_cr("%d,%d: %2x %2x %2x %2x %2x %2x %2x %2x", - chunk, line, - line_byte(lp, 0), line_byte(lp, 1), - line_byte(lp, 2), line_byte(lp, 3), - line_byte(lp, 4), line_byte(lp, 5), - line_byte(lp, 6), line_byte(lp, 7)); + + err_stream << std::dec << chunk << "," << line << ": " << std::hex + << std::setw(2) << line_byte(lp, 0) << " " + << std::setw(2) << line_byte(lp, 1) << " " + << std::setw(2) << line_byte(lp, 2) << " " + << std::setw(2) << line_byte(lp, 3) << " " + << std::setw(2) << line_byte(lp, 4) << " " + << std::setw(2) << line_byte(lp, 5) << " " + << std::setw(2) << line_byte(lp, 6) << " " + << std::setw(2) << line_byte(lp, 7) << std::endl; } } - assert(head_clear, "leading byte not clear"); - assert(middle_set, "memset byte not set"); - assert(tail_clear, "trailing bye not clear"); + EXPECT_TRUE(head_clear) << "leading byte not clear"; + EXPECT_TRUE(middle_set) << "memset byte not set"; + EXPECT_TRUE(tail_clear) << "trailing bye not clear"; + ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.str(); } } } } } - -#endif // end unit test - -#endif // INCLUDE_ALL_GCS +#endif diff --git a/hotspot/test/native/logging/test_logConfiguration.cpp b/hotspot/test/native/logging/test_logConfiguration.cpp index 528111ef31b..a5e52ca80ca 100644 --- a/hotspot/test/native/logging/test_logConfiguration.cpp +++ b/hotspot/test/native/logging/test_logConfiguration.cpp @@ -164,10 +164,17 @@ TEST_F(LogConfigurationTest, disable_logging) { // Add TestLogFileName as an output set_log_config(TestLogFileName, "logging=info"); + // Add a second file output + char other_file_name[2 * K]; + jio_snprintf(other_file_name, sizeof(other_file_name), "%s-other", TestLogFileName); + set_log_config(other_file_name, "logging=info"); + LogConfiguration::disable_logging(); - // Verify TestLogFileName was disabled + // Verify that both file outputs were disabled EXPECT_FALSE(is_described(TestLogFileName)); + EXPECT_FALSE(is_described(other_file_name)); + delete_file(other_file_name); // Verify that no tagset has logging enabled for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { @@ -287,5 +294,44 @@ TEST_F(LogConfigurationTest, parse_log_arguments) { const LogDecorators::Decorator decorator = static_cast(d); EXPECT_TRUE(LogConfiguration::parse_log_arguments("#0", "", LogDecorators::name(decorator), "", &ss)); } - EXPECT_STREQ("", ss.as_string()) << "Error reported while parsing: " << ss.as_string(); +} + +TEST_F(LogConfigurationTest, parse_invalid_tagset) { + static const char* invalid_tagset = "logging+start+exit+safepoint+gc"; // Must not exist for test to function. + + // Make sure warning is produced if one or more configured tagsets are invalid + ResourceMark rm; + stringStream ss; + bool success = LogConfiguration::parse_log_arguments("stdout", invalid_tagset, NULL, NULL, &ss); + const char* msg = ss.as_string(); + EXPECT_TRUE(success) << "Should only cause a warning, not an error"; + EXPECT_TRUE(string_contains_substring(msg, "No tag set matches selection(s):")); + EXPECT_TRUE(string_contains_substring(msg, invalid_tagset)); +} + +TEST_F(LogConfigurationTest, output_name_normalization) { + const char* patterns[] = { "%s", "file=%s", "\"%s\"", "file=\"%s\"" }; + char buf[1 * K]; + for (size_t i = 0; i < ARRAY_SIZE(patterns); i++) { + int ret = jio_snprintf(buf, sizeof(buf), patterns[i], TestLogFileName); + ASSERT_NE(-1, ret); + set_log_config(buf, "logging=trace"); + EXPECT_TRUE(is_described("#2: ")); + EXPECT_TRUE(is_described(TestLogFileName)); + EXPECT_FALSE(is_described("#3: ")) + << "duplicate file output due to incorrect normalization for pattern: " << patterns[i]; + } + + // Make sure prefixes are ignored when used within quotes + // (this should create a log with "file=" in its filename) + int ret = jio_snprintf(buf, sizeof(buf), "\"file=%s\"", TestLogFileName); + ASSERT_NE(-1, ret); + set_log_config(buf, "logging=trace"); + EXPECT_TRUE(is_described("#3: ")) << "prefix within quotes not ignored as it should be"; + set_log_config(buf, "all=off"); + + // Remove the extra log file created + ret = jio_snprintf(buf, sizeof(buf), "file=%s", TestLogFileName); + ASSERT_NE(-1, ret); + delete_file(buf); } diff --git a/hotspot/test/native/logging/test_logDecorations.cpp b/hotspot/test/native/logging/test_logDecorations.cpp index 324792b24b8..c23fb1b8227 100644 --- a/hotspot/test/native/logging/test_logDecorations.cpp +++ b/hotspot/test/native/logging/test_logDecorations.cpp @@ -144,7 +144,7 @@ TEST(LogDecorations, iso8601_time) { reported_time.tm_hour = h; reported_time.tm_min = m; reported_time.tm_sec = s; - reported_time.tm_isdst = daylight; + reported_time.tm_isdst = -1; // let mktime deduce DST settings time_t reported_ts = mktime(&reported_time); expected_ts = mktime(localtime(&expected_ts)); time_t diff = reported_ts - expected_ts; diff --git a/hotspot/test/native/logging/test_logFileOutput.cpp b/hotspot/test/native/logging/test_logFileOutput.cpp index da13e539412..b561048e7a5 100644 --- a/hotspot/test/native/logging/test_logFileOutput.cpp +++ b/hotspot/test/native/logging/test_logFileOutput.cpp @@ -29,7 +29,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/ostream.hpp" -static const char* name = "testlog.pid%p.%t.log"; +static const char* name = "file=testlog.pid%p.%t.log"; // Test parsing a bunch of valid file output options TEST(LogFileOutput, parse_valid) { diff --git a/hotspot/test/native/logging/test_logTagLevelExpression.cpp b/hotspot/test/native/logging/test_logTagLevelExpression.cpp index 72bd244a5ca..870c6af42db 100644 --- a/hotspot/test/native/logging/test_logTagLevelExpression.cpp +++ b/hotspot/test/native/logging/test_logTagLevelExpression.cpp @@ -33,7 +33,7 @@ TEST(LogTagLevelExpression, parse) { const char* invalid_substr[] = { "=", "+", " ", "+=", "+=*", "*+", " +", "**", "++", ".", ",", ",," ",+", " *", "all+", "all*", "+all", "+all=Warning", "==Info", "=InfoWarning", - "BadTag+", "logging++", "logging*+", ",=", "gc+gc+gc+gc+gc+gc" + "BadTag+", "logging++", "logging*+", ",=", "gc+gc+" }; const char* valid_expression[] = { "all", "gc", "gc,logging", "gc+logging", "logging+gc", "logging+gc,gc", "logging+gc*", "gc=trace", diff --git a/hotspot/test/native/utilities/test_utf8.cpp b/hotspot/test/native/utilities/test_utf8.cpp new file mode 100644 index 00000000000..a36f016ecd0 --- /dev/null +++ b/hotspot/test/native/utilities/test_utf8.cpp @@ -0,0 +1,50 @@ +/* + * 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 "precompiled.hpp" +#include "utilities/utf8.hpp" +#include "unittest.hpp" + +TEST(utf8, length) { + char res[60]; + jchar str[20]; + + for (int i = 0; i < 20; i++) { + str[i] = 0x0800; // char that is 2B in UTF-16 but 3B in UTF-8 + } + str[19] = (jchar) '\0'; + + // The resulting string in UTF-8 is 3*19 bytes long, but should be truncated + UNICODE::as_utf8(str, 19, res, 10); + ASSERT_EQ(strlen(res), (size_t) 9) << "string should be truncated here"; + + UNICODE::as_utf8(str, 19, res, 18); + ASSERT_EQ(strlen(res), (size_t) 15) << "string should be truncated here"; + + UNICODE::as_utf8(str, 19, res, 20); + ASSERT_EQ(strlen(res), (size_t) 18) << "string should be truncated here"; + + // Test with an "unbounded" buffer + UNICODE::as_utf8(str, 19, res, INT_MAX); + ASSERT_EQ(strlen(res), (size_t) 3 * 19) << "string should end here"; +} diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index 303912d4e20..fa3b79909c7 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,8 +110,6 @@ public class TestOptionsWithRanges { excludeTestMaxRange("OldSize"); excludeTestMaxRange("ParallelGCThreads"); - excludeTestMaxRange("VMThreadStackSize"); - /* * Remove parameters controlling the code cache. As these * parameters have implications on the physical memory diff --git a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java index a5a19fed1df..60226a33e42 100644 --- a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java +++ b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java @@ -34,13 +34,12 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class CreateCoredumpOnCrash { private static class Crasher { public static void main(String[] args) { - UnsafeHelper.getUnsafe().putInt(0L, 0); + Unsafe.getUnsafe().putInt(0L, 0); } } diff --git a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java index e3b88c29673..2aa02bf7c49 100644 --- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java @@ -35,14 +35,13 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class ProblematicFrameTest { private static class Crasher { public static void main(String[] args) { - UnsafeHelper.getUnsafe().getInt(0); + Unsafe.getUnsafe().getInt(0); } } 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/NMT/CheckForProperDetailStackTrace.java b/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java index c053f660e9e..8caa81686f8 100644 --- a/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java +++ b/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java @@ -57,11 +57,6 @@ public class CheckForProperDetailStackTrace { private static String expectedSymbol = "locked_create_entry_or_null"; - private static final String jdkDebug = System.getProperty("jdk.debug"); - private static boolean isSlowDebugBuild() { - return (jdkDebug.toLowerCase().equals("slowdebug")); - } - public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", @@ -76,11 +71,12 @@ public class CheckForProperDetailStackTrace { output.shouldNotContain("NativeCallStack::NativeCallStack"); output.shouldNotContain("os::get_native_stack"); - // AllocateHeap shouldn't be in the output because it is suppose to always be inlined. - // We check for that here, but allow it for Windows and Solaris slowdebug builds because - // the compiler ends up not inlining AllocateHeap. + // AllocateHeap shouldn't be in the output because it is supposed to always be inlined. + // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds + // because the compiler ends up not inlining AllocateHeap. Boolean okToHaveAllocateHeap = - isSlowDebugBuild() && (Platform.isSolaris() || Platform.isWindows()); + Platform.isSlowDebugBuild() && + (Platform.isAix() || Platform.isSolaris() || Platform.isWindows()); if (!okToHaveAllocateHeap) { output.shouldNotContain("AllocateHeap"); } diff --git a/hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java b/hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java new file mode 100644 index 00000000000..45555dcf4ab --- /dev/null +++ b/hotspot/test/runtime/RedefineTests/RedefinePreviousVersions.java @@ -0,0 +1,120 @@ +/* + * 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 8165246 + * @summary Test has_previous_versions flag and processing during class unloading. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @modules java.compiler + * java.instrument + * jdk.jartool/sun.tools.jar + * @run main RedefineClassHelper + * @run main/othervm RedefinePreviousVersions test + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class RedefinePreviousVersions { + + public static String newB = + "class RedefinePreviousVersions$B {" + + "}"; + + static class B { } + + public static String newRunning = + "class RedefinePreviousVersions$Running {" + + " public static volatile boolean stop = true;" + + " static void localSleep() { }" + + " public static void infinite() { }" + + "}"; + + static class Running { + public static volatile boolean stop = false; + static void localSleep() { + try{ + Thread.currentThread().sleep(10);//sleep for 10 ms + } catch(InterruptedException ie) { + } + } + + public static void infinite() { + while (!stop) { localSleep(); } + } + } + + public static void main(String[] args) throws Exception { + + if (args.length > 0) { + + String jarFile = System.getProperty("test.src") + "/testcase.jar"; + + // java -javaagent:redefineagent.jar -Xlog:stuff RedefinePreviousVersions + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-javaagent:redefineagent.jar", + "-Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace", + "RedefinePreviousVersions"); + new OutputAnalyzer(pb.start()) + .shouldContain("Class unloading: has_previous_versions = false") + .shouldContain("Class unloading: has_previous_versions = true") + .shouldHaveExitValue(0); + return; + } + + // Redefine a class and create some garbage + // Since there are no methods running, the previous version is never added to the + // previous_version_list and the flag _has_previous_versions should stay false + RedefineClassHelper.redefineClass(B.class, newB); + + for (int i = 0; i < 10 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + + // Start a class that has a method running + new Thread() { + public void run() { + Running.infinite(); + } + }.start(); + + // Since a method of newRunning is running, this class should be added to the previous_version_list + // of Running, and _has_previous_versions should return true at class unloading. + RedefineClassHelper.redefineClass(Running.class, newRunning); + + for (int i = 0; i < 10 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + + // purge should clean everything up, except Xcomp it might not. + Running.stop = true; + + for (int i = 0; i < 10 ; i++) { + String s = new String("some garbage"); + System.gc(); + } + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/CDSTestUtils.java b/hotspot/test/runtime/SharedArchiveFile/CDSTestUtils.java new file mode 100644 index 00000000000..8392b756eab --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/CDSTestUtils.java @@ -0,0 +1,115 @@ +/* + * 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.File; +import java.io.FileOutputStream; +import java.io.PrintStream; +import jdk.test.lib.process.OutputAnalyzer; + + +// This class contains common test utilities for CDS testing +public class CDSTestUtils { + + // check result of 'dump' operation + public static void checkDump(OutputAnalyzer output, String... extraMatches) + throws Exception { + + output.shouldContain("Loading classes to share"); + output.shouldHaveExitValue(0); + + for (String match : extraMatches) { + output.shouldContain(match); + } + } + + + // check the output for indication that mapping of the archive failed + public static boolean isUnableToMap(OutputAnalyzer output) { + String outStr = output.getOutput(); + if ((output.getExitValue() == 1) && ( + outStr.contains("Unable to reserve shared space at required address") || + outStr.contains("Unable to map ReadOnly shared space at required address") || + outStr.contains("Unable to map ReadWrite shared space at required address") || + outStr.contains("Unable to map MiscData shared space at required address") || + outStr.contains("Unable to map MiscCode shared space at required address") || + outStr.contains("Unable to map shared string space at required address") || + outStr.contains("Could not allocate metaspace at a compatible address") || + outStr.contains("Unable to allocate shared string space: range is not within java heap") )) + { + return true; + } + + return false; + } + + // check result of 'exec' operation, that is when JVM is run using the archive + public static void checkExec(OutputAnalyzer output, String... extraMatches) throws Exception { + if (isUnableToMap(output)) { + System.out.println("Unable to map shared archive: test did not complete; assumed PASS"); + return; + } + output.shouldContain("sharing"); + output.shouldHaveExitValue(0); + + for (String match : extraMatches) { + output.shouldContain(match); + } + } + + + // get the file object for the test artifact + private static File getTestArtifactFile(String prefix, String name) { + File dir = new File(System.getProperty("test.classes", ".")); + return new File(dir, prefix + name); + } + + + // create file containing the specified class list + public static File makeClassList(String testCaseName, String classes[]) + throws Exception { + + File classList = getTestArtifactFile(testCaseName, "test.classlist"); + FileOutputStream fos = new FileOutputStream(classList); + PrintStream ps = new PrintStream(fos); + + addToClassList(ps, classes); + + ps.close(); + fos.close(); + + return classList; + } + + + private static void addToClassList(PrintStream ps, String classes[]) + throws IOException + { + if (classes != null) { + for (String s : classes) { + ps.println(s); + } + } + } + +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/Implementor.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/Implementor.java new file mode 100644 index 00000000000..96320a39468 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/Implementor.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +public class Implementor implements Interface { + public static void main(String[] args) { + System.out.println("Implementor: entering main()"); + test(); + } + + public static void test() { + // from interface + (new Implementor()).printString(); + // from implementor + System.out.println(TransformUtil.ChildCheckPattern + + TransformUtil.BeforePattern); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/Interface.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/Interface.java new file mode 100644 index 00000000000..1510915ca26 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/Interface.java @@ -0,0 +1,31 @@ +/* + * 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. + */ + +public interface Interface { + public static final String stringToBeTransformed = + TransformUtil.ParentCheckPattern + TransformUtil.BeforePattern; + + default void printString() { + System.out.println(stringToBeTransformed); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/SubClass.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/SubClass.java new file mode 100644 index 00000000000..e9205918b0b --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/SubClass.java @@ -0,0 +1,40 @@ +/* + * 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. + */ + +public class SubClass extends SuperClazz { + public static void main(String[] args) { + System.out.println("SubClass: entering main()"); + test(); + } + + public static void test() { + // The line below will be used to check for successful class transformation + System.out.println(TransformUtil.ChildCheckPattern + + TransformUtil.BeforePattern); + (new SubClass()).callParent(); + } + + private void callParent() { + super.testParent(); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/SuperClazz.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/SuperClazz.java new file mode 100644 index 00000000000..a3224c7f91e --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/SuperClazz.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + + +public class SuperClazz { + public static void testParent() { + System.out.println("SuperClazz: entering testParent()"); + + // The line below will be used to check for successful class transformation + System.out.println(TransformUtil.ParentCheckPattern + TransformUtil.BeforePattern); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TestEntry.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TestEntry.java new file mode 100644 index 00000000000..b388af2a15c --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TestEntry.java @@ -0,0 +1,45 @@ +/* + * 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 Entry - a single entry in a test table +// that defines a test case +// See TransformRelatedClasses.java for more details +public class TestEntry { + int testCaseId; + boolean transformParent; + boolean transformChild; + boolean isParentExpectedShared; + boolean isChildExpectedShared; + + public TestEntry(int testCaseId, + boolean transformParent, boolean transformChild, + boolean isParentExpectedShared, boolean isChildExpectedShared) { + this.testCaseId = testCaseId; + this.transformParent = transformParent; + this.transformChild = transformChild; + this.isParentExpectedShared = isParentExpectedShared; + this.isChildExpectedShared = isChildExpectedShared; + } +} + diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java new file mode 100644 index 00000000000..7cf738baae1 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java @@ -0,0 +1,50 @@ +/* + * 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 + * @summary Exercise initial transformation (ClassFileLoadHook) + * with CDS with Interface/Implementor pair + * @library /test/lib /runtime/SharedArchiveFile /testlibrary/jvmti + * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) + * @requires vm.flavor != "minimal" + * @modules java.base/jdk.internal.misc + * jdk.jartool/sun.tools.jar + * java.management + * java.instrument + * @build TransformUtil TransformerAgent Interface Implementor + * @run main/othervm TransformRelatedClasses Interface Implementor + */ + +// Clarification on @requires declarations: +// CDS is not supported w/o the use of Compressed OOPs +// JVMTI's ClassFileLoadHook is not supported under minimal VM + +// This test class uses TransformRelatedClasses to do its work. +// The goal of this test is to exercise transformation of related interface +// and its implementor in combination with CDS. +// The transformation is done via ClassFileLoadHook mechanism. +// Both superclass and subclass reside in the shared archive. +// The test consists of 4 test cases where transformation is applied +// to an interface and an implementor in a combinatorial manner. +// Please see TransformRelatedClasses.java for details. diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformRelatedClasses.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformRelatedClasses.java new file mode 100644 index 00000000000..25cc42dfd82 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformRelatedClasses.java @@ -0,0 +1,179 @@ +/* + * 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. + */ + + +// This is the main test class for testing transformation of related classes +// in combination with CDS, to ensure these features work well together. +// The relationships that can be tested using this test class are: +// superclass/subclass, and interface/implementor relationships. +// +// The test uses combinatorial approach. +// For details on test table and test cases see main() method in this class. +// +// This test consists of multiple classes for better flexibility and reuse, +// and also relies on certain common utility code. +// Here are the details on the structure of the test +// +// Structure of the test: +// TransformRelatedClasses -- common main test driver +// The TransformRelatedClasses is invoked from test driver classes: +// TransformInterfaceAndImplementor, TransformSuperAndSubClasses +// It is responsible for preparing test artifacts (test jar, agent jar +// and the shared archive), running test cases and checking the results. +// The following test classes below are launched in a sub-process with use +// of shared archive: +// SuperClazz, SubClass -- super/sub class pair under test +// Interface, Implementor -- classes under test +// This test will transform these classes, based on the test case data, +// by changing a predefined unique string in each class. +// For more details, see the test classes' code and comments. +// +// Other related classes: +// TestEntry - a class representing a single test case, as test entry in the table +// TransformTestCommon - common methods for transformation test cases +// +// Other utility/helper classes and files used in this test: +// TransformerAgent - an agent that is used when JVM-under-test is executed +// to transform specific strings inside specified classes +// TransformerAgent.mf - accompanies transformer agent +// CDSTestUtils - Test Utilities common to all CDS tests + +import java.io.File; +import java.util.ArrayList; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + + +public class TransformRelatedClasses { + static final String archiveName = "./TransformRelatedClasses.jsa"; + static String agentClasses[] = { + "TransformerAgent", + "TransformerAgent$SimpleTransformer", + "TransformUtil" + }; + + String parent; + String child; + String[] testClasses = new String[2]; + String[] testNames = new String[2]; + String testJar; + String agentJar; + + + private static void log(String msg) { + System.out.println("TransformRelatedClasses: " + msg); + } + + + // This class is intended to test 2 parent-child relationships: + // 1. Base Class (parent) and Derived Class (child) + // 2. Interface (parent) and Implementor (child) + // Parameters to main(): parent, child + public static void main(String args[]) throws Exception { + TransformRelatedClasses test = new TransformRelatedClasses(args[0], args[1]); + test.prepare(); + + // Test Table + // TestEntry: (testCaseId, transformParent, tranformChild, + // isParentExpectedShared, isChildExpectedShared) + ArrayList testTable = new ArrayList<>(); + + // base case - no tranformation - all expected to be shared + testTable.add(new TestEntry(0, false, false, true, true)); + + // transform parent only - both parent and child should not be shared + testTable.add(new TestEntry(1, true, false, false, false)); + + // transform parent and child - both parent and child should not be shared + testTable.add(new TestEntry(2, true, true, false, false)); + + // transform child only - parent should still be shared, but not child + testTable.add(new TestEntry(3, false, true, true, false)); + + // run the tests + for (TestEntry entry : testTable) { + test.runTest(entry); + } + } + + + public TransformRelatedClasses(String parent, String child) { + log("Constructor: parent = " + parent + ", child = " + child); + this.parent = parent; + this.child = child; + testClasses[0] = parent; + testClasses[1] = child; + testNames[0] = parent.replace('.', '/'); + testNames[1] = child.replace('.', '/'); + } + + + // same test jar and archive can be used for all test cases + private void prepare() throws Exception { + // create agent jar + // Agent is the same for all test cases + String pathToManifest = "../../../../testlibrary/jvmti/TransformerAgent.mf"; + agentJar = ClassFileInstaller.writeJar("TransformerAgent.jar", + ClassFileInstaller.Manifest.fromSourceFile(pathToManifest), + agentClasses); + + // create a test jar + testJar = + ClassFileInstaller.writeJar(parent + "-" + child + ".jar", + testClasses); + + // create an archive + File classList = CDSTestUtils.makeClassList("transform-" + parent, + testNames); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + "-Xbootclasspath/a:" + testJar, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:ExtraSharedClassListFile=" + + classList.getPath(), + "-XX:SharedArchiveFile=" + archiveName, + "-XX:+PrintSharedSpaces", + "-Xshare:dump"); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + CDSTestUtils.checkDump(out); + } + + + private void runTest(TestEntry entry) throws Exception { + log("runTest(): testCaseId = " + entry.testCaseId); + + // execute with archive + String agentParam = "-javaagent:" + agentJar + "=" + + TransformTestCommon.getAgentParams(entry, parent, child); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + "-Xbootclasspath/a:" + testJar, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=" + archiveName, + "-Xlog:class+load=info", + "-Xshare:on", "-showversion", + agentParam, child); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + + TransformTestCommon.checkResults(entry, out, parent, child); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java new file mode 100644 index 00000000000..1309c1b4a35 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java @@ -0,0 +1,51 @@ +/* + * 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 + * @summary Exercise initial transformation (ClassFileLoadHook) + * with CDS with SubClass and SuperClass + * @library /test/lib /runtime/SharedArchiveFile /testlibrary/jvmti + * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) + * @requires vm.flavor != "minimal" + * @modules java.base/jdk.internal.misc + * jdk.jartool/sun.tools.jar + * java.management + * java.instrument + * @build TransformUtil TransformerAgent SubClass SuperClazz + * @run main/othervm TransformRelatedClasses SuperClazz SubClass +*/ + +// Clarification on @requires declarations: +// CDS is not supported w/o the use of Compressed OOPs +// JVMTI's ClassFileLoadHook is not supported under minimal VM + +// This test class uses TransformRelatedClasses to do its work. +// The goal of this test is to exercise transformation of related superclass +// and subclass in combination with CDS. +// The transformation is done via ClassFileLoadHook mechanism. +// Both superclass and subclass reside in the shared archive. +// The test consists of 4 test cases where transformation is applied +// to a parent and child in combinatorial manner. +// Please see TransformRelatedClasses.java for details. diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java new file mode 100644 index 00000000000..da35b7e0336 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java @@ -0,0 +1,52 @@ +/* + * 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 + * @summary Exercise initial transformation (ClassFileLoadHook) + * with CDS with SubClass and SuperClass, each lives in own separate package + * @library /test/lib /runtime/SharedArchiveFile /testlibrary/jvmti + * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) + * @requires vm.flavor != "minimal" + * @modules java.base/jdk.internal.misc + * jdk.jartool/sun.tools.jar + * java.management + * java.instrument + * @build TransformUtil TransformerAgent SubClass SuperClazz + * @compile myPkg2/SubClass.java myPkg1/SuperClazz.java + * @run main/othervm TransformRelatedClasses myPkg1.SuperClazz myPkg2.SubClass +*/ + +// Clarification on @requires declarations: +// CDS is not supported w/o the use of Compressed OOPs +// JVMTI's ClassFileLoadHook is not supported under minimal VM + +// This test class uses TransformRelatedClasses to do its work. +// The goal of this test is to exercise transformation of related superclass +// and subclass in combination with CDS; each class lives in its own package. +// The transformation is done via ClassFileLoadHook mechanism. +// Both superclass and subclass reside in the shared archive. +// The test consists of 4 test cases where transformation is applied +// to a parent and child in combinatorial manner. +// Please see TransformRelatedClasses.java for details. diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java new file mode 100644 index 00000000000..00e25bce83c --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java @@ -0,0 +1,114 @@ +/* + * 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 jdk.test.lib.process.OutputAnalyzer; + + +// This class contains methods common to all transformation test cases +public class TransformTestCommon { + + // get parameters to an agent depending on the test case + // these parameters will instruct the agent which classes should be + // transformed + public static String getAgentParams(TestEntry entry, + String parent, String child) { + + if (entry.transformParent && entry.transformChild) + return parent + "," + child; + if (entry.transformParent) + return parent; + if (entry.transformChild) + return child; + + return ""; + } + + + private static void checkTransformationResults(TestEntry entry, + OutputAnalyzer out) + throws Exception { + + if (entry.transformParent) + out.shouldContain(TransformUtil.ParentCheckPattern + + TransformUtil.AfterPattern); + + if (entry.transformChild) + out.shouldContain(TransformUtil.ChildCheckPattern + + TransformUtil.AfterPattern); + } + + + private static void checkSharingByClass(TestEntry entry, OutputAnalyzer out, + String parent, String child) + throws Exception { + + String parentSharedMatch = parent + " source: shared objects file"; + String childSharedMatch = child + " source: shared objects file"; + + if (entry.isParentExpectedShared) + out.shouldContain(parentSharedMatch); + else + out.shouldNotContain(parentSharedMatch); + + if (entry.isChildExpectedShared) + out.shouldContain(childSharedMatch); + else + out.shouldNotContain(childSharedMatch); + } + + + // Both parent and child classes should be passed to ClassFileTransformer.transform() + // exactly once. + private static void checkTransformationCounts(TestEntry entry, OutputAnalyzer out, + String parent, String child) + throws Exception { + + String patternBase = "TransformerAgent: SimpleTransformer called for: "; + + out.shouldContain(patternBase + child + "@1"); + out.shouldContain(patternBase + parent + "@1"); + + out.shouldNotContain(patternBase + child + "@2"); + out.shouldNotContain(patternBase + parent + "@2"); + } + + + public static void checkResults(TestEntry entry, OutputAnalyzer out, + String parent, String child) + throws Exception { + + // If we were not able to map an archive, + // then do not perform other checks, since + // there was no sharing at all + if (CDSTestUtils.isUnableToMap(out)) + return; + + String childVmName = child.replace('.', '/'); + String parentVmName = parent.replace('.', '/'); + + CDSTestUtils.checkExec(out); + checkTransformationCounts(entry, out, parentVmName, childVmName); + checkTransformationResults(entry, out); + checkSharingByClass(entry, out, parent, child); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/myPkg1/SuperClazz.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/myPkg1/SuperClazz.java new file mode 100644 index 00000000000..c04770dbc3c --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/myPkg1/SuperClazz.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +package myPkg1; + +public class SuperClazz { + public static void testParent() { + System.out.println("SuperClazz: entering testParent()"); + + // The line below will be used to check for successful class transformation + System.out.println("parent-transform-check: this-should-be-transformed"); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/myPkg2/SubClass.java b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/myPkg2/SubClass.java new file mode 100644 index 00000000000..ab67b3a6bfd --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/myPkg2/SubClass.java @@ -0,0 +1,56 @@ +/* + * 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. + */ + +package myPkg2; + +import myPkg1.SuperClazz; + +public class SubClass extends SuperClazz { + public static void main(String[] args) { + System.out.println("SubClass: entering main()"); + test(); + } + + public static void test() { + // The line below will be used to check for successful class transformation + System.out.println("child-transform-check: this-should-be-transformed"); + (new SubClass()).callParent(); + + // Get the system packages, which should contain myPkg1 and myPkag2 + Package[] pkgs = Package.getPackages(); + for (int i = 0; i < pkgs.length; i++) { + if (pkgs[i].getName().equals("myPkg1")) { + for (int j = 0; j < pkgs.length; j++) { + if (pkgs[j].getName().equals("myPkg2")) { + return; // found myPkg1 & myPkg1 + } + } + } + } + throw new RuntimeException("Missing system package"); + } + + private void callParent() { + super.testParent(); + } +} 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/Unsafe/AllocateInstance.java b/hotspot/test/runtime/Unsafe/AllocateInstance.java index ca2d56dd749..ac684f84144 100644 --- a/hotspot/test/runtime/Unsafe/AllocateInstance.java +++ b/hotspot/test/runtime/Unsafe/AllocateInstance.java @@ -30,12 +30,11 @@ * @run main AllocateInstance */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class AllocateInstance { - static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + static final Unsafe UNSAFE = Unsafe.getUnsafe(); class TestClass { public boolean calledConstructor = false; diff --git a/hotspot/test/runtime/Unsafe/AllocateMemory.java b/hotspot/test/runtime/Unsafe/AllocateMemory.java index afb48c24488..6c67427fe58 100644 --- a/hotspot/test/runtime/Unsafe/AllocateMemory.java +++ b/hotspot/test/runtime/Unsafe/AllocateMemory.java @@ -31,13 +31,12 @@ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class AllocateMemory { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // Allocate a byte, write to the location and read back the value long address = unsafe.allocateMemory(1); diff --git a/hotspot/test/runtime/Unsafe/CopyMemory.java b/hotspot/test/runtime/Unsafe/CopyMemory.java index 0b832c3ee67..447d1c89702 100644 --- a/hotspot/test/runtime/Unsafe/CopyMemory.java +++ b/hotspot/test/runtime/Unsafe/CopyMemory.java @@ -30,14 +30,13 @@ * @run main CopyMemory */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class CopyMemory { final static int LENGTH = 8; public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); long src = unsafe.allocateMemory(LENGTH); long dst = unsafe.allocateMemory(LENGTH); assertNotEquals(src, 0L); diff --git a/hotspot/test/runtime/Unsafe/DefineClass.java b/hotspot/test/runtime/Unsafe/DefineClass.java index 613e9afef6f..5973f666122 100644 --- a/hotspot/test/runtime/Unsafe/DefineClass.java +++ b/hotspot/test/runtime/Unsafe/DefineClass.java @@ -34,13 +34,12 @@ import java.security.ProtectionDomain; import java.io.InputStream; import jdk.test.lib.InMemoryJavaCompiler; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class DefineClass { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); TestClassLoader classloader = new TestClassLoader(); ProtectionDomain pd = new ProtectionDomain(null, null); diff --git a/hotspot/test/runtime/Unsafe/FieldOffset.java b/hotspot/test/runtime/Unsafe/FieldOffset.java index b4d425b8421..546e71cec5b 100644 --- a/hotspot/test/runtime/Unsafe/FieldOffset.java +++ b/hotspot/test/runtime/Unsafe/FieldOffset.java @@ -31,14 +31,13 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import java.lang.reflect.*; import static jdk.test.lib.Asserts.*; public class FieldOffset { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Field[] fields = Test.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { diff --git a/hotspot/test/runtime/Unsafe/GetField.java b/hotspot/test/runtime/Unsafe/GetField.java index 48533068f31..3772fa6e8db 100644 --- a/hotspot/test/runtime/Unsafe/GetField.java +++ b/hotspot/test/runtime/Unsafe/GetField.java @@ -30,14 +30,13 @@ * @run main GetField */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import java.lang.reflect.*; import static jdk.test.lib.Asserts.*; public class GetField { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // Unsafe.INVALID_FIELD_OFFSET is a static final int field, // make sure getField returns the correct field Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET"); diff --git a/hotspot/test/runtime/Unsafe/GetPutAddress.java b/hotspot/test/runtime/Unsafe/GetPutAddress.java index 07fa4afa429..5fdb964037f 100644 --- a/hotspot/test/runtime/Unsafe/GetPutAddress.java +++ b/hotspot/test/runtime/Unsafe/GetPutAddress.java @@ -31,13 +31,12 @@ */ import jdk.test.lib.Platform; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutAddress { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); int addressSize = unsafe.addressSize(); // Ensure the size returned from Unsafe.addressSize is correct assertEquals(unsafe.addressSize(), Platform.is32bit() ? 4 : 8); diff --git a/hotspot/test/runtime/Unsafe/GetPutBoolean.java b/hotspot/test/runtime/Unsafe/GetPutBoolean.java index fe53ad4f911..b5d8b7217ae 100644 --- a/hotspot/test/runtime/Unsafe/GetPutBoolean.java +++ b/hotspot/test/runtime/Unsafe/GetPutBoolean.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutBoolean { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("b1"); diff --git a/hotspot/test/runtime/Unsafe/GetPutByte.java b/hotspot/test/runtime/Unsafe/GetPutByte.java index 9e2909e4e7d..89bf84a546c 100644 --- a/hotspot/test/runtime/Unsafe/GetPutByte.java +++ b/hotspot/test/runtime/Unsafe/GetPutByte.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutByte { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("b"); diff --git a/hotspot/test/runtime/Unsafe/GetPutChar.java b/hotspot/test/runtime/Unsafe/GetPutChar.java index 7fcfeea8c26..5e3c930d1d2 100644 --- a/hotspot/test/runtime/Unsafe/GetPutChar.java +++ b/hotspot/test/runtime/Unsafe/GetPutChar.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutChar { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("c"); diff --git a/hotspot/test/runtime/Unsafe/GetPutDouble.java b/hotspot/test/runtime/Unsafe/GetPutDouble.java index fb7210ae2ff..101b4d76c63 100644 --- a/hotspot/test/runtime/Unsafe/GetPutDouble.java +++ b/hotspot/test/runtime/Unsafe/GetPutDouble.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutDouble { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("d"); diff --git a/hotspot/test/runtime/Unsafe/GetPutFloat.java b/hotspot/test/runtime/Unsafe/GetPutFloat.java index 26821864435..40a35ee5200 100644 --- a/hotspot/test/runtime/Unsafe/GetPutFloat.java +++ b/hotspot/test/runtime/Unsafe/GetPutFloat.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutFloat { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("f"); diff --git a/hotspot/test/runtime/Unsafe/GetPutInt.java b/hotspot/test/runtime/Unsafe/GetPutInt.java index 56b4d762974..8dfa401fee2 100644 --- a/hotspot/test/runtime/Unsafe/GetPutInt.java +++ b/hotspot/test/runtime/Unsafe/GetPutInt.java @@ -30,13 +30,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutInt { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("i"); diff --git a/hotspot/test/runtime/Unsafe/GetPutLong.java b/hotspot/test/runtime/Unsafe/GetPutLong.java index d039e2275aa..e0720e6f317 100644 --- a/hotspot/test/runtime/Unsafe/GetPutLong.java +++ b/hotspot/test/runtime/Unsafe/GetPutLong.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutLong { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("l"); diff --git a/hotspot/test/runtime/Unsafe/GetPutObject.java b/hotspot/test/runtime/Unsafe/GetPutObject.java index 1ffc7b4d756..2ee272e22ec 100644 --- a/hotspot/test/runtime/Unsafe/GetPutObject.java +++ b/hotspot/test/runtime/Unsafe/GetPutObject.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutObject { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Object o = new Object(); Field field = Test.class.getField("o"); diff --git a/hotspot/test/runtime/Unsafe/GetPutShort.java b/hotspot/test/runtime/Unsafe/GetPutShort.java index ae1cb97d9ad..7618e931a48 100644 --- a/hotspot/test/runtime/Unsafe/GetPutShort.java +++ b/hotspot/test/runtime/Unsafe/GetPutShort.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutShort { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("s"); diff --git a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java index 380ab8438aa..001d11a4355 100644 --- a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java +++ b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java @@ -30,13 +30,12 @@ import static jdk.test.lib.Asserts.*; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class GetUncompressedObject { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // Allocate some memory and fill it with non-zero values. final int size = 32; diff --git a/hotspot/test/runtime/Unsafe/NestedUnsafe.java b/hotspot/test/runtime/Unsafe/NestedUnsafe.java index 32d9bb74fbd..a1a995ab636 100644 --- a/hotspot/test/runtime/Unsafe/NestedUnsafe.java +++ b/hotspot/test/runtime/Unsafe/NestedUnsafe.java @@ -35,7 +35,6 @@ import java.security.ProtectionDomain; import java.io.InputStream; import java.lang.*; import jdk.test.lib.InMemoryJavaCompiler; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; @@ -50,7 +49,7 @@ public class NestedUnsafe { " } } "); public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Class klass = unsafe.defineAnonymousClass(NestedUnsafe.class, klassbuf, new Object[0]); unsafe.ensureClassInitialized(klass); @@ -80,7 +79,7 @@ public class NestedUnsafe { " throw new RuntimeException(\"Exception: \" + ex.toString()); " + " } " + "} } ", - "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED"); + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); Class klass2 = unsafe.defineAnonymousClass(NestedUnsafe.class, klassbuf2, new Object[0]); try { klass2.getMethod("doit").invoke(null); diff --git a/hotspot/test/runtime/Unsafe/PageSize.java b/hotspot/test/runtime/Unsafe/PageSize.java index a0b487a4dff..009412fd18a 100644 --- a/hotspot/test/runtime/Unsafe/PageSize.java +++ b/hotspot/test/runtime/Unsafe/PageSize.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class PageSize { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); int pageSize = unsafe.pageSize(); for (int n = 1; n != 0; n <<= 1) { diff --git a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java index ffe95401556..689c2c1d6fe 100644 --- a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java +++ b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java @@ -39,16 +39,7 @@ import jdk.internal.misc.Unsafe; public class PrimitiveHostClass { - static final Unsafe U; - static { - try { - Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); - theUnsafe.setAccessible(true); - U = (Unsafe) theUnsafe.get(null); - } catch (Exception e) { - throw new AssertionError(e); - } - } + static final Unsafe U = Unsafe.getUnsafe(); public static void testVMAnonymousClass(Class hostClass) { diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java index e9e9f224a29..8b885bfb3ba 100644 --- a/hotspot/test/runtime/Unsafe/RangeCheck.java +++ b/hotspot/test/runtime/Unsafe/RangeCheck.java @@ -33,7 +33,6 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; @@ -60,7 +59,7 @@ public class RangeCheck { public static class DummyClassWithMainRangeCheck { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE); } } diff --git a/hotspot/test/runtime/Unsafe/Reallocate.java b/hotspot/test/runtime/Unsafe/Reallocate.java index 837e587fc28..4381fa124bc 100644 --- a/hotspot/test/runtime/Unsafe/Reallocate.java +++ b/hotspot/test/runtime/Unsafe/Reallocate.java @@ -31,13 +31,12 @@ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class Reallocate { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); long address = unsafe.allocateMemory(1); assertNotEquals(address, 0L); diff --git a/hotspot/test/runtime/Unsafe/SetMemory.java b/hotspot/test/runtime/Unsafe/SetMemory.java index 77eed63f60a..8dd3a84c74a 100644 --- a/hotspot/test/runtime/Unsafe/SetMemory.java +++ b/hotspot/test/runtime/Unsafe/SetMemory.java @@ -30,13 +30,12 @@ * @run main SetMemory */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class SetMemory { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); long address = unsafe.allocateMemory(1); assertNotEquals(address, 0L); unsafe.setMemory(address, 1, (byte)17); diff --git a/hotspot/test/runtime/Unsafe/ThrowException.java b/hotspot/test/runtime/Unsafe/ThrowException.java index 465618c3cff..03df26c935c 100644 --- a/hotspot/test/runtime/Unsafe/ThrowException.java +++ b/hotspot/test/runtime/Unsafe/ThrowException.java @@ -30,13 +30,12 @@ * @run main ThrowException */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class ThrowException { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); try { unsafe.throwException(new TestException()); } catch (Throwable t) { diff --git a/hotspot/test/runtime/contended/Basic.java b/hotspot/test/runtime/contended/Basic.java index 5ffba1aa920..6b181aa5aa9 100644 --- a/hotspot/test/runtime/contended/Basic.java +++ b/hotspot/test/runtime/contended/Basic.java @@ -48,20 +48,11 @@ import jdk.internal.vm.annotation.Contended; */ public class Basic { - private static final Unsafe U; + private static final Unsafe U = Unsafe.getUnsafe(); private static int ADDRESS_SIZE; private static int HEADER_SIZE; static { - // steal Unsafe - try { - Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); - unsafe.setAccessible(true); - U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - // When running with CompressedOops on 64-bit platform, the address size // reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // Try to guess the reference field size with this naive trick. diff --git a/hotspot/test/runtime/contended/DefaultValue.java b/hotspot/test/runtime/contended/DefaultValue.java index b61ab3d4502..28aacd5d88c 100644 --- a/hotspot/test/runtime/contended/DefaultValue.java +++ b/hotspot/test/runtime/contended/DefaultValue.java @@ -49,20 +49,11 @@ import jdk.internal.vm.annotation.Contended; */ public class DefaultValue { - private static final Unsafe U; + private static final Unsafe U = Unsafe.getUnsafe(); private static int ADDRESS_SIZE; private static int HEADER_SIZE; static { - // steal Unsafe - try { - Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); - unsafe.setAccessible(true); - U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - // When running with CompressedOops on 64-bit platform, the address size // reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // Try to guess the reference field size with this naive trick. diff --git a/hotspot/test/runtime/contended/Inheritance1.java b/hotspot/test/runtime/contended/Inheritance1.java index 57dec49b3ae..fe253c0db2c 100644 --- a/hotspot/test/runtime/contended/Inheritance1.java +++ b/hotspot/test/runtime/contended/Inheritance1.java @@ -49,20 +49,11 @@ import jdk.internal.vm.annotation.Contended; */ public class Inheritance1 { - private static final Unsafe U; + private static final Unsafe U = Unsafe.getUnsafe(); private static int ADDRESS_SIZE; private static int HEADER_SIZE; static { - // steal Unsafe - try { - Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); - unsafe.setAccessible(true); - U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - // When running with CompressedOops on 64-bit platform, the address size // reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // Try to guess the reference field size with this naive trick. diff --git a/hotspot/test/runtime/defineAnonClass/DefineAnon.java b/hotspot/test/runtime/defineAnonClass/DefineAnon.java new file mode 100644 index 00000000000..f73b20dfc5f --- /dev/null +++ b/hotspot/test/runtime/defineAnonClass/DefineAnon.java @@ -0,0 +1,134 @@ +/* + * 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 DefineAnon + * @bug 8058575 + * @library /testlibrary + * @modules java.base/jdk.internal.org.objectweb.asm + * java.management + * @compile -XDignore.symbol.file=true DefineAnon.java + * @run main/othervm p1.DefineAnon + */ + +package p1; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import sun.misc.Unsafe; + + +class T { + static protected void test0() { System.out.println("test0 (public)"); } + static protected void test1() { System.out.println("test1 (protected)"); } + static /*package-private*/ void test2() { System.out.println("test2 (package)"); } + static private void test3() { System.out.println("test3 (private)"); } +} + +public class DefineAnon { + + private static Unsafe getUnsafe() { + try { + java.lang.reflect.Field singleoneInstanceField = Unsafe.class.getDeclaredField("theUnsafe"); + singleoneInstanceField.setAccessible(true); + return (Unsafe) singleoneInstanceField.get(null); + } catch (Throwable ex) { + throw new RuntimeException("Was unable to get Unsafe instance."); + } + } + + static Unsafe UNSAFE = DefineAnon.getUnsafe(); + + static Class getAnonClass(Class hostClass, final String className) { + final String superName = "java/lang/Object"; + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES); + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null); + + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC, "test", "()V", null, null); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test0", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test1", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test2", "()V", false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "p1/T", "test3", "()V", false); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + + final byte[] classBytes = cw.toByteArray(); + Class invokerClass = UNSAFE.defineAnonymousClass(hostClass, classBytes, new Object[0]); + UNSAFE.ensureClassInitialized(invokerClass); + return invokerClass; + } + + public static void main(String[] args) throws Throwable { + Throwable fail = null; + + // Anonymous class has the privileges of its host class, so test[0123] should all work. + System.out.println("Injecting from the same package (p1):"); + Class p1cls = getAnonClass(T.class, "p1/AnonClass"); + try { + p1cls.getMethod("test").invoke(null); + } catch (Throwable ex) { + ex.printStackTrace(); + fail = ex; // throw this to make test fail, since subtest failed + } + + // Anonymous class has different package name from host class. Should throw + // IllegalArgumentException. + System.out.println("Injecting from the wrong package (p2):"); + try { + Class p2cls = getAnonClass(DefineAnon.class, "p2/AnonClass"); + p2cls.getMethod("test").invoke(null); + System.out.println("Failed, did not get expected IllegalArgumentException"); + } catch (java.lang.IllegalArgumentException e) { + if (e.getMessage().contains("Host class p1/DefineAnon and anonymous class p2/AnonClass")) { + System.out.println("Got expected IllegalArgumentException: " + e.getMessage()); + } else { + throw new RuntimeException("Unexpected message: " + e.getMessage()); + } + } catch (Throwable ex) { + ex.printStackTrace(); + fail = ex; // throw this to make test fail, since subtest failed + } + + // Inject a class in the unnamed package into p1.T. It should be able + // to access all methods in p1.T. + System.out.println("Injecting unnamed package into correct host class:"); + try { + Class p3cls = getAnonClass(T.class, "AnonClass"); + p3cls.getMethod("test").invoke(null); + } catch (Throwable ex) { + ex.printStackTrace(); + fail = ex; // throw this to make test fail, since subtest failed + } + + // Try using an array class as the host class. This should throw IllegalArgumentException. + try { + Class p3cls = getAnonClass(String[].class, "AnonClass"); + throw new RuntimeException("Expected IllegalArgumentException not thrown"); + } catch (IllegalArgumentException ex) { + } + + if (fail != null) throw fail; // make test fail, since subtest failed + } +} diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java new file mode 100644 index 00000000000..f4a80a61a59 --- /dev/null +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.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. + */ + +/* + * @test + * @bug 8058575 + * @summary Creates an anonymous class inside of an anonymous class. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.compiler + * java.management + * @run main p.NestedUnsafe + */ + +package p; + +import java.security.ProtectionDomain; +import java.io.InputStream; +import java.lang.*; +import jdk.test.lib.*; +import jdk.internal.misc.Unsafe; + + +// Test that an anonymous class in package 'p' cannot define its own anonymous class +// in another package. +public class NestedUnsafe { + // The String concatenation should create the nested anonymous class. + static byte klassbuf[] = InMemoryJavaCompiler.compile("q.TestClass", + "package q; " + + "public class TestClass { " + + " public static void concat(String one, String two) throws Throwable { " + + " System.out.println(one + two);" + + " } } "); + + public static void main(String args[]) throws Exception { + Unsafe unsafe = Unsafe.getUnsafe(); + + // The anonymous class calls defineAnonymousClass creating a nested anonymous class. + byte klassbuf2[] = InMemoryJavaCompiler.compile("p.TestClass2", + "package p; " + + "import jdk.internal.misc.Unsafe; " + + "public class TestClass2 { " + + " public static void doit() throws Throwable { " + + " Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); " + + " Class klass2 = unsafe.defineAnonymousClass(TestClass2.class, p.NestedUnsafe.klassbuf, new Object[0]); " + + " unsafe.ensureClassInitialized(klass2); " + + " Class[] dArgs = new Class[2]; " + + " dArgs[0] = String.class; " + + " dArgs[1] = String.class; " + + " try { " + + " klass2.getMethod(\"concat\", dArgs).invoke(null, \"CC\", \"DD\"); " + + " } catch (Throwable ex) { " + + " throw new RuntimeException(\"Exception: \" + ex.toString()); " + + " } " + + "} } ", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + + Class klass2 = unsafe.defineAnonymousClass(p.NestedUnsafe.class, klassbuf2, new Object[0]); + try { + klass2.getMethod("doit").invoke(null); + throw new RuntimeException("Expected exception not thrown"); + } catch (Throwable ex) { + Throwable iae = ex.getCause(); + if (!iae.toString().contains( + "IllegalArgumentException: Host class p/NestedUnsafe and anonymous class q/TestClass")) { + throw new RuntimeException("Exception: " + iae.toString()); + } + } + } +} diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java new file mode 100644 index 00000000000..0d773a56feb --- /dev/null +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java @@ -0,0 +1,89 @@ +/* + * 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 8058575 + * @summary Creates an anonymous class inside of an anonymous class. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.compiler + * java.management + * @run main p.NestedUnsafe2 + */ + +package p; + +import java.security.ProtectionDomain; +import java.io.InputStream; +import java.lang.*; +import jdk.test.lib.*; +import jdk.internal.misc.Unsafe; + + +// Test that an anonymous class that gets put in its host's package cannot define +// an anonymous class in another package. +public class NestedUnsafe2 { + // The String concatenation should create the nested anonymous class. + public static byte klassbuf[] = InMemoryJavaCompiler.compile("q.TestClass", + "package q; " + + "public class TestClass { " + + " public static void concat(String one, String two) throws Throwable { " + + " System.out.println(one + two);" + + " } } "); + + public static void main(String args[]) throws Exception { + Unsafe unsafe = Unsafe.getUnsafe(); + + // The anonymous class calls defineAnonymousClass creating a nested anonymous class. + byte klassbuf2[] = InMemoryJavaCompiler.compile("TestClass2", + "import jdk.internal.misc.Unsafe; " + + "public class TestClass2 { " + + " public static void doit() throws Throwable { " + + " Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); " + + " Class klass2 = unsafe.defineAnonymousClass(TestClass2.class, p.NestedUnsafe2.klassbuf, new Object[0]); " + + " unsafe.ensureClassInitialized(klass2); " + + " Class[] dArgs = new Class[2]; " + + " dArgs[0] = String.class; " + + " dArgs[1] = String.class; " + + " try { " + + " klass2.getMethod(\"concat\", dArgs).invoke(null, \"CC\", \"DD\"); " + + " } catch (Throwable ex) { " + + " throw new RuntimeException(\"Exception: \" + ex.toString()); " + + " } " + + "} } ", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + + Class klass2 = unsafe.defineAnonymousClass(p.NestedUnsafe2.class, klassbuf2, new Object[0]); + try { + klass2.getMethod("doit").invoke(null); + throw new RuntimeException("Expected exception not thrown"); + } catch (Throwable ex) { + Throwable iae = ex.getCause(); + if (!iae.toString().contains( + "IllegalArgumentException: Host class p/NestedUnsafe2 and anonymous class q/TestClass")) { + throw new RuntimeException("Exception: " + iae.toString()); + } + } + } +} 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/hotspot/test/runtime/modules/ModuleOptionsWarn.java b/hotspot/test/runtime/modules/ModuleOptionsWarn.java index 7ad1f9b2ca9..6446e0ae5fd 100644 --- a/hotspot/test/runtime/modules/ModuleOptionsWarn.java +++ b/hotspot/test/runtime/modules/ModuleOptionsWarn.java @@ -29,6 +29,7 @@ * @library /test/lib */ +import java.util.Map; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -37,16 +38,65 @@ public class ModuleOptionsWarn { public static void main(String[] args) throws Exception { - // Test that a warning is issued for module related properties that get ignored. + // Test that a warning is not issued for extraneous jdk.module properties. ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.ignored", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property. + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.addmods", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in '.'. + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.limitmods.", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in '='. + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.addexports=", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in ".stuff" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.addreads.stuff", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in "=stuff" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.path=stuff", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in ".=" + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.upgrade.path.=xx", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); + + // Test that a warning is issued for a reserved jdk.module property ending in "." + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+PrintWarnings", "-Djdk.module.patch.3=xx", "-version"); + output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning can be suppressed for module related properties that get ignored. pb = ProcessTools.createJavaProcessBuilder( - "-Djdk.module.ignored", "-XX:-PrintWarnings", "-version"); + "-Djdk.module.addmods", "-XX:-PrintWarnings", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); @@ -57,5 +107,13 @@ public class ModuleOptionsWarn { output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); + + // Test that a warning is issued for module related properties specified using _JAVA_OPTIONS. + pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintWarnings", "-version"); + Map env = pb.environment(); + env.put("_JAVA_OPTIONS", "-Djdk.module.addreads"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring system property option"); + output.shouldHaveExitValue(0); } } diff --git a/hotspot/test/runtime/verifier/popTopTests/PopDupTop.java b/hotspot/test/runtime/verifier/popTopTests/PopDupTop.java new file mode 100644 index 00000000000..fe72c923a41 --- /dev/null +++ b/hotspot/test/runtime/verifier/popTopTests/PopDupTop.java @@ -0,0 +1,64 @@ +/* + * 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 8149607 + * @summary Throw VerifyError when popping a stack element of TOP + * @compile popDupSwapTests.jasm + * @run main/othervm -Xverify:all PopDupTop + */ + +public class PopDupTop { + + public static void testClass(String class_name, String msg) throws Throwable { + try { + Class newClass = Class.forName(class_name); + throw new RuntimeException("Expected VerifyError exception not thrown for " + msg); + } catch (java.lang.VerifyError e) { + if (!e.getMessage().contains("Bad type on operand stack")) { + throw new RuntimeException( + "Unexpected VerifyError message for " + msg + ": " + e.getMessage()); + } + } + } + + public static void main(String args[]) throws Throwable { + System.out.println("Regression test for bug 8149607"); + + testClass("dup_x1", "dup_x1 of long,ref"); + testClass("dup2toptop", "dup2 of top,top"); + testClass("dup2longtop", "dup2 of long,top"); + testClass("dup2_x1", "dup2_x1 long,ref,ref"); + testClass("dup2_x2", "dup2_x2 top"); + testClass("dup2_x2_long_refs", "dup2_x2 long,ref,ref,ref"); + testClass("poptop", "pop of top"); + testClass("poptoptop", "pop of top,top"); + testClass("pop2toptop", "pop2 of top,top"); + testClass("pop2longtop", "pop2 of long,top"); + testClass("swaptoptop", "swap of top,top"); + testClass("swapinttop", "swap of int,top"); + testClass("swaptopint", "swap of top,int"); + } +} diff --git a/hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm b/hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm new file mode 100644 index 00000000000..6d42b1cd76f --- /dev/null +++ b/hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm @@ -0,0 +1,244 @@ +/* + * 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 that VerifyError is thrown if dup2_x1 tries to replace the filler slot +// of a category 2 value. +// The stack map is long,top,null,null. The verifier should reject dup2_x1's +// (form1) attempt to turn the stack map into long,top,null,null,null,null +public class dup2_x1 version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + lconst_0; + aconst_null; + aconst_null; + dup2_x1; + return; + } +} + + +public class dup2_x2 version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + iconst_0; + lconst_0; + aconst_null; + + stack_frame_type full; + stack_map int, bogus, bogus, null; + locals_map; + + dup2_x2; + return; + } +} + + +// Test that VerifyError is thrown if dup2_x2 tries to replace the filler slot +// of a category 2 value. +// The stack map is long,top,null,null,null. The verifier should reject dup2_x2's +// (form 1) attempt to turn the stack map into long,top,null,null,null,top,null. +public class dup2_x2_long_refs version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + lconst_0; + aconst_null; + aconst_null; + aconst_null; + dup2_x2; + return; + } +} + + +// Test that VerifyError is thrown when dup2 is used to remove the upper +// half of a category 2 type. +public class dup2longtop version 51:0 { + public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 { + lconst_0; + iconst_0; + dup2; + return; + } +} + + +// Test that VerifyError is thrown when dup2 is used to remove top +// because top may be the upper half of a category 2 type. +public class dup2toptop version 51:0 { + public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 { + // here we have {long, top, null} + // EXECUTION: we have {long, null} + lconst_0; + aconst_null; + + stack_frame_type full; + stack_map bogus, bogus, null; + locals_map bogus; + + // VERIFIER: use form1 of dup2 - {top, top, null} -> {top, top, null, top, null} + // EXECUTION: have {long, null} - no applicable form of dup2 for such type state by JVMS ch. 6 + dup2; + + return; + } +} + + +// Test that VerifyError is thrown if dup_x1 tries to replace the filler slot +// of a category 2 value. +public class dup_x1 version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + lconst_0; + aconst_null; + dup_x1; + return; + } +} + + +// Test that VerifyError is thrown when pop2 is used to remove top +// because top may be the upper half of a category 2 type. +public class pop2longtop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + lconst_0; + iconst_0; + stack_frame_type full; + stack_map long, bogus; + locals_map; + pop2; + return; + } +} // end Class pop2longtop + + + +// Test that VerifyError is thrown when pop2 is used to remove top, top +// because either top may be the upper half of a category 2 type. +public class pop2toptop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, bogus; + locals_map; + pop2; + return; + } +} // end Class pop2toptop + + + +// Test that VerifyError is thrown when pop is used to remove top +// because top may be the upper half of a category 2 type. +public class poptop version 51:0 +{ + + public Method regular:"()V" stack 2 locals 1 + { + iconst_0; + stack_frame_type full; + stack_map bogus; + pop; + return; + } +} // end Class poptop + + + +// Test that VerifyError is thrown when pop is used to remove top, top +// because either top may be the upper half of a category 2 type. +public class poptoptop version 51:0 +{ + + public Method regular:"()V" stack 2 locals 1 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, bogus; + pop; + return; + } +} // end Class poptoptop + + + +// Test that VerifyError is thrown when swap is used to swap int, top +// because top may be the lower half of a category 2 type. +public class swapinttop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map int, bogus; + locals_map; + swap; + return; + } +} // end Class swapinttop + + + +// Test that VerifyError is thrown when swap is used to swap top, int +// because top may be the upper half of a category 2 type. +public class swaptopint version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, int; + locals_map; + swap; + return; + } +} // end Class swaptopint + + + +// Test that VerifyError is thrown when swap is used to swap top, top +// because either top may be the upper half of a category 2 type. +public class swaptoptop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, bogus; + locals_map; + swap; + return; + } +} // end Class swaptoptop diff --git a/hotspot/test/serviceability/jdwp/AllModulesCommandTest.java b/hotspot/test/serviceability/jdwp/AllModulesCommandTest.java new file mode 100644 index 00000000000..33bb583c59d --- /dev/null +++ b/hotspot/test/serviceability/jdwp/AllModulesCommandTest.java @@ -0,0 +1,149 @@ +/* + * 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.util.Arrays; +import java.util.concurrent.CountDownLatch; +import java.util.Set; +import java.util.HashSet; +import static jdk.test.lib.Asserts.assertTrue; + +/** + * @test + * @summary Tests AllModules JDWP command + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @compile AllModulesCommandTestDebuggee.java + * @run main/othervm AllModulesCommandTest + */ +public class AllModulesCommandTest implements DebuggeeLauncher.Listener { + + private DebuggeeLauncher launcher; + private JdwpChannel channel; + private CountDownLatch jdwpLatch = new CountDownLatch(1); + private Set jdwpModuleNames = new HashSet<>(); + private Set javaModuleNames = new HashSet<>(); + + public static void main(String[] args) throws Throwable { + new AllModulesCommandTest().doTest(); + } + + private void doTest() throws Throwable { + launcher = new DebuggeeLauncher(this); + launcher.launchDebuggee(); + // Await till the debuggee sends all the necessary modules info to check against + // then start the JDWP session + jdwpLatch.await(); + doJdwp(); + } + + @Override + public void onDebuggeeModuleInfo(String modName) { + // The debuggee has sent out info about a loaded module + javaModuleNames.add(modName); + } + + @Override + public void onDebuggeeSendingCompleted() { + // The debuggee has completed sending all the info + // We can start the JDWP session + jdwpLatch.countDown(); + } + + @Override + public void onDebuggeeError(String message) { + System.err.println("Debuggee error: '" + message + "'"); + System.exit(1); + } + + private void doJdwp() throws Exception { + try { + // Establish JDWP socket connection + channel = new JdwpChannel(); + channel.connect(); + // Send out ALLMODULES JDWP command + // and verify the reply + JdwpAllModulesReply reply = new JdwpAllModulesCmd().send(channel); + assertReply(reply); + for (int i = 0; i < reply.getModulesCount(); ++i) { + long modId = reply.getModuleId(i); + // For each module reported by JDWP get its name using the JDWP NAME command + getModuleName(modId); + // Assert the JDWP CANREAD and CLASSLOADER commands + assertCanRead(modId); + assertClassLoader(modId); + } + + System.out.println("Module names reported by JDWP: " + Arrays.toString(jdwpModuleNames.toArray())); + System.out.println("Module names reported by Java: " + Arrays.toString(javaModuleNames.toArray())); + + // Modules reported by the JDWP should be the same as reported by the Java API + if (!jdwpModuleNames.equals(javaModuleNames)) { + throw new RuntimeException("Modules info reported by Java API differs from that reported by JDWP."); + } else { + System.out.println("Test passed!"); + } + + } finally { + launcher.terminateDebuggee(); + try { + new JdwpExitCmd(0).send(channel); + channel.disconnect(); + } catch (Exception x) { + } + } + } + + private void getModuleName(long modId) throws IOException { + // Send out the JDWP NAME command and store the reply + JdwpModNameReply reply = new JdwpModNameCmd(modId).send(channel); + assertReply(reply); + String modName = reply.getModuleName(); + if (modName != null) { // JDWP reports unnamed modules, ignore them + jdwpModuleNames.add(modName); + } + } + + private void assertReply(JdwpReply reply) { + // Simple assert for any JDWP reply + if (reply.getErrorCode() != 0) { + throw new RuntimeException("Unexpected reply error code " + reply.getErrorCode() + " for reply " + reply); + } + } + + private void assertCanRead(long modId) throws IOException { + // Simple assert for the CANREAD command + JdwpCanReadReply reply = new JdwpCanReadCmd(modId, modId).send(channel); + assertReply(reply); + assertTrue(reply.canRead(), "canRead() reports false for reading from the same module"); + } + + private void assertClassLoader(long modId) throws IOException { + // Simple assert for the CLASSLOADER command + JdwpClassLoaderReply reply = new JdwpClassLoaderCmd(modId).send(channel); + assertReply(reply); + long clId = reply.getClassLoaderId(); + assertTrue(clId >= 0, "bad classloader refId " + clId + " for module id " + modId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java b/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.java new file mode 100644 index 00000000000..1b686ec9ae4 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/AllModulesCommandTestDebuggee.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.lang.reflect.Module; +import java.lang.reflect.Layer; +import java.util.Set; +import java.util.HashSet; + +/** + * The debuggee to be launched by the test + * Sends out the info about the loaded modules + * then stays to respond to the JDWP commands + */ +public class AllModulesCommandTestDebuggee { + + public static void main(String[] args) throws InterruptedException { + + int modCount = Layer.boot().modules().size(); + + // Send all modules names via the process output + for (Module mod : Layer.boot().modules()) { + String info = String.format("module %s", mod.getName()); + write(info); + } + // Signal that the sending is done + write("ready"); + Thread.sleep(Long.MAX_VALUE); + } + + private static void write(String s) { + System.out.println(s); + System.out.flush(); + } + +} diff --git a/hotspot/test/serviceability/jdwp/DebuggeeLauncher.java b/hotspot/test/serviceability/jdwp/DebuggeeLauncher.java new file mode 100644 index 00000000000..259c9ac0f6c --- /dev/null +++ b/hotspot/test/serviceability/jdwp/DebuggeeLauncher.java @@ -0,0 +1,166 @@ +/* + * 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.net.ServerSocket; +import java.util.StringTokenizer; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; +import static jdk.test.lib.Asserts.assertFalse; + +/** + * Launches the debuggee with the necessary JDWP options and handles the output + */ +public class DebuggeeLauncher implements StreamHandler.Listener { + + public interface Listener { + + /** + * Callback to use when a module name is received from the debuggee + * + * @param modName module name reported by the debuggee + */ + void onDebuggeeModuleInfo(String modName); + + /** + * Callback to use when the debuggee completes sending out the info + */ + void onDebuggeeSendingCompleted(); + + /** + * Callback to handle any debuggee error + * + * @param line line from the debuggee's stderr + */ + void onDebuggeeError(String line); + } + + private static int jdwpPort = -1; + private static final String CLS_DIR = System.getProperty("test.classes", "").trim(); + private static final String DEBUGGEE = "AllModulesCommandTestDebuggee"; + private Process p; + private final Listener listener; + private StreamHandler inputHandler; + private StreamHandler errorHandler; + + /** + * @param listener the listener we report the debuggee events to + */ + public DebuggeeLauncher(Listener listener) { + this.listener = listener; + } + + /** + * Starts the debuggee with the necessary JDWP options and handles the + * debuggee's stdout and stderr outputs + * + * @throws Throwable + */ + public void launchDebuggee() throws Throwable { + + ProcessBuilder pb = new ProcessBuilder(getCommand()); + p = pb.start(); + inputHandler = new StreamHandler(p.getInputStream(), this); + errorHandler = new StreamHandler(p.getErrorStream(), this); + inputHandler.start(); + errorHandler.start(); + } + + /** + * Command to start the debuggee with the JDWP options and using the JDK + * under test + * + * @return the command + */ + private String[] getCommand() { + return new String[]{ + JDKToolFinder.getTestJDKTool("java"), + getJdwpOptions(), + "-cp", + CLS_DIR, + DEBUGGEE + }; + } + + /** + * Terminates the debuggee + */ + public void terminateDebuggee() { + if (p.isAlive()) { + p.destroyForcibly(); + } + } + + /** + * Debuggee JDWP options + * + * @return the JDWP options to start the debuggee with + */ + private static String getJdwpOptions() { + return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + getJdwpPort(); + } + + /** + * Find an available port for the JDWP session + * + * @return JDWP port + */ + public static int getJdwpPort() { + if (jdwpPort == -1) { + jdwpPort = findFreePort(); + assertFalse(jdwpPort == -1, "Can not find vailbale port for JDWP"); + } + return jdwpPort; + } + + private static int findFreePort() { + try (ServerSocket socket = new ServerSocket(0)) { + return socket.getLocalPort(); + } catch (IOException e) { + } + return -1; + } + + @Override + public void onStringRead(StreamHandler handler, String line) { + if (handler.equals(errorHandler)) { + terminateDebuggee(); + listener.onDebuggeeError(line); + } else { + processDebuggeeOutput(line); + } + } + + private void processDebuggeeOutput(String line) { + StringTokenizer st = new StringTokenizer(line); + String token = st.nextToken(); + switch (token) { + case "module": + listener.onDebuggeeModuleInfo(st.nextToken()); + break; + case "ready": + listener.onDebuggeeSendingCompleted(); + break; + } + } +} diff --git a/hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java b/hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java new file mode 100644 index 00000000000..020b95f9962 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpAllModulesCmd.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +/** + * The JDWP ALLMODULES command + */ +public class JdwpAllModulesCmd extends JdwpCmd { + + public JdwpAllModulesCmd() { + super(22, 1, JdwpAllModulesReply.class, 0); + } +} diff --git a/hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java b/hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java new file mode 100644 index 00000000000..53d3de1f11f --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpAllModulesReply.java @@ -0,0 +1,61 @@ +/* + * 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.IOException; + +/** + * The JDWP reply to the ALLMODULES command + */ +public class JdwpAllModulesReply extends JdwpReply { + + private int modulesCount; + private long[] modulesId; + + protected void parseData(DataInputStream ds) throws IOException { + modulesCount = ds.readInt(); + modulesId = new long[modulesCount]; + for (int nmod = 0; nmod < modulesCount; ++nmod) { + modulesId[nmod] = readRefId(ds); + } + } + + /** + * Number of modules reported + * + * @return modules count + */ + public int getModulesCount() { + return modulesCount; + } + + /** + * The id of a module reported + * + * @param ndx module index in the array of the reported ids + * @return module id + */ + public long getModuleId(int ndx) { + return modulesId[ndx]; + } +} diff --git a/hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java b/hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java new file mode 100644 index 00000000000..81cb5a9983c --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpCanReadCmd.java @@ -0,0 +1,35 @@ +/* + * 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. + */ + +/** + * The JDWP CANREAD command + */ +public class JdwpCanReadCmd extends JdwpCmd { + + public JdwpCanReadCmd(long modId, long srcModId) { + super(3, 18, JdwpCanReadReply.class, 2 * refLen()); + putRefId(modId); + putRefId(srcModId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpCanReadReply.java b/hotspot/test/serviceability/jdwp/JdwpCanReadReply.java new file mode 100644 index 00000000000..f838baf89b6 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpCanReadReply.java @@ -0,0 +1,41 @@ +/* + * 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.IOException; + +/** + * The reply to the JDWP CANREAD command + */ +public class JdwpCanReadReply extends JdwpReply { + + private boolean canRead; + + protected void parseData(DataInputStream ds) throws IOException { + canRead = ds.read() == 1; + } + + public boolean canRead() { + return canRead; + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpChannel.java b/hotspot/test/serviceability/jdwp/JdwpChannel.java new file mode 100644 index 00000000000..d2e780c802f --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpChannel.java @@ -0,0 +1,71 @@ +/* + * 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.InputStream; +import java.net.Socket; +import java.util.Arrays; + +/** + * JDWP socket transport + */ +public class JdwpChannel { + + private Socket sock; + + public void connect() throws IOException { + sock = new Socket("localhost", DebuggeeLauncher.getJdwpPort()); + handshake(); + } + + /** + * Sends JDWP handshake and verifies the reply + * @throws IOException + */ + private void handshake() throws IOException { + final byte[] HANDSHAKE = "JDWP-Handshake".getBytes(); + sock.getOutputStream().write(HANDSHAKE, 0, HANDSHAKE.length); + + byte[] reply = new byte[14]; + sock.getInputStream().read(reply, 0, 14); + if (!Arrays.equals(HANDSHAKE, reply)) { + throw new RuntimeException("Error during handshake. Reply was: " + new String(reply) + " expected " + new String(HANDSHAKE)); + } + } + + public void disconnect() { + try { + sock.close(); + } catch (IOException x) { + } + } + + public void write(byte[] data, int length) throws IOException { + sock.getOutputStream().write(data, 0, length); + } + + public InputStream getInputStream() throws IOException { + return sock.getInputStream(); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.java b/hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.java new file mode 100644 index 00000000000..14ffb615f73 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpClassLoaderCmd.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. + */ + +/** + * The JDWP CLASSLOADER command + */ +public class JdwpClassLoaderCmd extends JdwpCmd { + + public JdwpClassLoaderCmd(long modId) { + super(2, 18, JdwpClassLoaderReply.class, refLen()); + putRefId(modId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java b/hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java new file mode 100644 index 00000000000..bb1cbcd6ace --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpClassLoaderReply.java @@ -0,0 +1,42 @@ +/* + * 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.IOException; + +/** + * The JDWP CLASSLOADER reply + */ +public class JdwpClassLoaderReply extends JdwpReply { + + private long refId; + + protected void parseData(DataInputStream ds) throws IOException { + refId = readRefId(ds); + } + + public long getClassLoaderId() { + return refId; + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpCmd.java b/hotspot/test/serviceability/jdwp/JdwpCmd.java new file mode 100644 index 00000000000..fe7f28707a8 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpCmd.java @@ -0,0 +1,93 @@ +/* + * 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.nio.ByteBuffer; + +/** + * Generic JDWP command + * @param the corresponding JDWP reply class, to construct a reply object + */ +public abstract class JdwpCmd { + + private ByteBuffer data; + private static int id = 1; + private final byte FLAGS = 0; + private T reply; + private final int dataLen; + private final int HEADER_LEN = 11; + + /** + * JDWWp command + * @param cmd command code + * @param cmdSet command set + * @param replyClz command reply class + * @param dataLen length of additional data for the command + */ + JdwpCmd(int cmd, int cmdSet, Class replyClz, int dataLen) { + this.dataLen = dataLen; + data = ByteBuffer.allocate(HEADER_LEN + dataLen); + data.putInt(HEADER_LEN + dataLen); + data.putInt(id++); + data.put(FLAGS); + data.put((byte) cmdSet); + data.put((byte) cmd); + if (replyClz != null) { + try { + reply = replyClz.newInstance(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + JdwpCmd(int cmd, int cmdSet, Class replyClz) { + this(cmd, cmdSet, replyClz, 0); + } + + int getDataLength() { + return dataLen; + } + + public final T send(JdwpChannel channel) throws IOException { + System.err.println("Sending command: " + this); + channel.write(data.array(), HEADER_LEN + getDataLength()); + if (reply != null) { + reply.initFromStream(channel.getInputStream()); + } + return (T) reply; + } + + protected void putRefId(long refId) { + data.putLong(refId); + } + + protected void putInt(int val) { + data.putInt(val); + } + + protected static int refLen() { + return 8; + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpExitCmd.java b/hotspot/test/serviceability/jdwp/JdwpExitCmd.java new file mode 100644 index 00000000000..e63031a57ca --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpExitCmd.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. + */ + +/** + * The JDWP EXIT command to terminate the debuggee + */ +public class JdwpExitCmd extends JdwpCmd { + + public JdwpExitCmd(int exitCode) { + super(10, 1, null, 4); + putInt(exitCode); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpModNameCmd.java b/hotspot/test/serviceability/jdwp/JdwpModNameCmd.java new file mode 100644 index 00000000000..2fe4b12aec2 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpModNameCmd.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. + */ + +/** + * The JDWP NAME command + */ +public class JdwpModNameCmd extends JdwpCmd { + + public JdwpModNameCmd(long modId) { + super(1, 18, JdwpModNameReply.class, refLen()); + putRefId(modId); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpModNameReply.java b/hotspot/test/serviceability/jdwp/JdwpModNameReply.java new file mode 100644 index 00000000000..c6db98e6614 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpModNameReply.java @@ -0,0 +1,42 @@ +/* + * 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.IOException; + +/** + * JDWP reply to the NAME command + */ +public class JdwpModNameReply extends JdwpReply { + + private byte[] name; + + protected void parseData(DataInputStream ds) throws IOException { + name = readJdwpString(ds); + } + + public String getModuleName() { + return name == null ? null : new String(name); + } + +} diff --git a/hotspot/test/serviceability/jdwp/JdwpReply.java b/hotspot/test/serviceability/jdwp/JdwpReply.java new file mode 100644 index 00000000000..a3f95a5d509 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/JdwpReply.java @@ -0,0 +1,75 @@ +/* + * 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.DataInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Generic JDWP reply + */ +public abstract class JdwpReply { + + protected final static int HEADER_LEN = 11; + private byte[] errCode = new byte[2]; + private byte[] data; + + public final void initFromStream(InputStream is) throws IOException { + DataInputStream ds = new DataInputStream(is); + + int length = ds.readInt(); + int id = ds.readInt(); + byte flags = (byte) ds.read(); + + ds.read(errCode, 0, 2); + + int dataLength = length - HEADER_LEN; + if (dataLength > 0) { + data = new byte[dataLength]; + ds.read(data, 0, dataLength); + parseData(new DataInputStream(new ByteArrayInputStream(data))); + } + } + + protected void parseData(DataInputStream ds) throws IOException { + } + + protected byte[] readJdwpString(DataInputStream ds) throws IOException { + byte[] str = null; + int len = ds.readInt(); + if (len > 0) { + str = new byte[len]; + ds.read(str, 0, len); + } + return str; + } + + protected long readRefId(DataInputStream ds) throws IOException { + return ds.readLong(); + } + + public int getErrorCode() { + return (((errCode[0] & 0xFF) << 8) | (errCode[1] & 0xFF)); + } +} diff --git a/hotspot/test/serviceability/jdwp/StreamHandler.java b/hotspot/test/serviceability/jdwp/StreamHandler.java new file mode 100644 index 00000000000..257f66a66a9 --- /dev/null +++ b/hotspot/test/serviceability/jdwp/StreamHandler.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.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Handles the process output (either stdin or stdout) + * passing the lines to a listener + */ +public class StreamHandler implements Runnable { + + public interface Listener { + /** + * Called when a line has been read from the process output stream + * @param handler this StreamHandler + * @param s the line + */ + void onStringRead(StreamHandler handler, String s); + } + + private final ExecutorService executor; + private final InputStream is; + private final Listener listener; + + /** + * @param is input stream to read from + * @param listener listener to pass the read lines to + * @throws IOException + */ + public StreamHandler(InputStream is, Listener listener) throws IOException { + this.is = is; + this.listener = listener; + executor = Executors.newSingleThreadExecutor(); + } + + /** + * Starts asynchronous reading + */ + public void start() { + executor.submit(this); + } + + @Override + public void run() { + try { + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line; + while ((line = br.readLine()) != null) { + listener.onStringRead(this, line); + } + } catch (Exception x) { + throw new RuntimeException(x); + } + } + +} diff --git a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java index db1ed0f180f..dd8deda1612 100644 --- a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java +++ b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java @@ -23,6 +23,7 @@ import sun.jvm.hotspot.HotSpotAgent; import sun.jvm.hotspot.utilities.SystemDictionaryHelper; +import sun.jvm.hotspot.oops.InstanceKlass; import sun.jvm.hotspot.debugger.*; import java.util.ArrayList; @@ -44,15 +45,19 @@ import java.util.*; * @test * @library /test/lib * @modules java.base/jdk.internal.misc - * @modules jdk.hotspot.agent - * @modules jdk.hotspot.agent/sun.jvm.hotspot - * @modules jdk.hotspot.agent/sun.jvm.hotspot.utilities - * @modules jdk.hotspot.agent/sun.jvm.hotspot.oops - * @compile -XDignore.symbol.file=true -Xmodule:jdk.hotspot.agent - * -XaddExports:java.base/jdk.internal.misc=jdk.hotspot.agent - * -XaddExports:java.management/java.lang.management=jdk.hotspot.agent + * @compile -XDignore.symbol.file=true + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED * TestInstanceKlassSize.java - * @run main/othervm TestInstanceKlassSize + * @run main/othervm + * --add-modules=jdk.hotspot.agent + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED + * TestInstanceKlassSize */ public class TestInstanceKlassSize { @@ -112,11 +117,11 @@ public class TestInstanceKlassSize { " java.lang.Byte", }; String[] toolArgs = { - "-XX:+UnlockDiagnosticVMOptions", "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", "TestInstanceKlassSize", Long.toString(app.getPid()) }; @@ -136,6 +141,8 @@ public class TestInstanceKlassSize { String jcmdInstanceKlassSize = getJcmdInstanceKlassSize( jcmdOutput, instanceKlassName); + Asserts.assertNotNull(jcmdInstanceKlassSize, + "Could not get the instance klass size from the jcmd output"); for (String s : output.asLines()) { if (s.contains(instanceKlassName)) { Asserts.assertTrue( @@ -165,10 +172,12 @@ public class TestInstanceKlassSize { } for (String SAInstanceKlassName : SAInstanceKlassNames) { - Long size = SystemDictionaryHelper.findInstanceKlass( - SAInstanceKlassName).getSize(); + InstanceKlass ik = SystemDictionaryHelper.findInstanceKlass( + SAInstanceKlassName); + Asserts.assertNotNull(ik, + String.format("Unable to find instance klass for %s", ik)); System.out.println("SA: The size of " + SAInstanceKlassName + - " is " + size); + " is " + ik.getSize()); } agent.detach(); } diff --git a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java index 0c23373e6e3..0bd8bc38b23 100644 --- a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -38,15 +38,20 @@ import jdk.test.lib.Asserts; * @test * @library /test/lib * @modules java.base/jdk.internal.misc - * @modules jdk.hotspot.agent - * @modules jdk.hotspot.agent/sun.jvm.hotspot - * @modules jdk.hotspot.agent/sun.jvm.hotspot.utilities - * @modules jdk.hotspot.agent/sun.jvm.hotspot.oops - * @compile -XDignore.symbol.file=true -Xmodule:jdk.hotspot.agent - * -XaddExports:java.base/jdk.internal.misc=jdk.hotspot.agent - * -XaddExports:java.management/java.lang.management=jdk.hotspot.agent + * @compile -XDignore.symbol.file=true + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED * TestInstanceKlassSizeForInterface.java - * @run main/othervm TestInstanceKlassSizeForInterface + * @run main/othervm + * -XX:+UnlockDiagnosticVMOptions + * --add-modules=jdk.hotspot.agent + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED + * --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED + * TestInstanceKlassSizeForInterface */ interface Language { @@ -80,6 +85,8 @@ public class TestInstanceKlassSizeForInterface { for (String instanceKlassName : instanceKlassNames) { InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass( instanceKlassName); + Asserts.assertNotNull(iKlass, + String.format("Unable to find instance klass for %s", instanceKlassName)); System.out.println("SA: The size of " + instanceKlassName + " is " + iKlass.getSize()); } @@ -106,11 +113,11 @@ public class TestInstanceKlassSizeForInterface { // Grab the pid from the current java process and pass it String[] toolArgs = { - "-XX:+UnlockDiagnosticVMOptions", "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", "TestInstanceKlassSizeForInterface", Long.toString(ProcessTools.getProcessId()) }; @@ -138,6 +145,8 @@ public class TestInstanceKlassSizeForInterface { String jcmdInstanceKlassSize = getJcmdInstanceKlassSize( jcmdOutput, instanceKlassName); + Asserts.assertNotNull(jcmdInstanceKlassSize, + "Could not get the instance klass size from the jcmd output"); for (String s : SAOutput.asLines()) { if (s.contains(instanceKlassName)) { Asserts.assertTrue( @@ -162,7 +171,7 @@ public class TestInstanceKlassSizeForInterface { return; } - if ( args == null || args.length == 0 ) { + if (args == null || args.length == 0) { ParselTongue lang = new ParselTongue(); Language ventro = new Language() { diff --git a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java index a86010c84ae..36e6ddea8be 100644 --- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java +++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java @@ -39,7 +39,7 @@ import java.util.regex.Pattern; * Concrete subclasses should implement method {@link #process()}. */ public abstract class PathHandler { - private static final Unsafe UNSAFE = jdk.test.lib.unsafe.UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private static final AtomicLong CLASS_COUNT = new AtomicLong(0L); private static volatile boolean CLASSES_LIMIT_REACHED = false; private static final Pattern JAR_IN_DIR_PATTERN diff --git a/hotspot/test/testlibrary/jvmti/TransformUtil.java b/hotspot/test/testlibrary/jvmti/TransformUtil.java new file mode 100644 index 00000000000..dfaf61a42a3 --- /dev/null +++ b/hotspot/test/testlibrary/jvmti/TransformUtil.java @@ -0,0 +1,75 @@ +/* + * 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. + */ + + +public class TransformUtil { + public static final String BeforePattern = "this-should-be-transformed"; + public static final String AfterPattern = "this-has-been--transformed"; + public static final String ParentCheckPattern = "parent-transform-check: "; + public static final String ChildCheckPattern = "child-transform-check: "; + + /** + * @return the number of occurrences of the from string that + * have been replaced. + */ + public static int replace(byte buff[], String from, String to) { + if (to.length() != from.length()) { + throw new RuntimeException("bad strings"); + } + byte f[] = asciibytes(from); + byte t[] = asciibytes(to); + byte f0 = f[0]; + + int numReplaced = 0; + int max = buff.length - f.length; + for (int i = 0; i < max; ) { + if (buff[i] == f0 && replace(buff, f, t, i)) { + i += f.length; + numReplaced++; + } else { + i++; + } + } + return numReplaced; + } + + public static boolean replace(byte buff[], byte f[], byte t[], int i) { + for (int x = 0; x < f.length; x++) { + if (buff[x+i] != f[x]) { + return false; + } + } + for (int x = 0; x < f.length; x++) { + buff[x+i] = t[x]; + } + return true; + } + + static byte[] asciibytes(String s) { + byte b[] = new byte[s.length()]; + for (int i = 0; i < b.length; i++) { + b[i] = (byte)s.charAt(i); + } + return b; + } +} diff --git a/hotspot/test/testlibrary/jvmti/TransformerAgent.java b/hotspot/test/testlibrary/jvmti/TransformerAgent.java new file mode 100644 index 00000000000..7f520050487 --- /dev/null +++ b/hotspot/test/testlibrary/jvmti/TransformerAgent.java @@ -0,0 +1,100 @@ +/* + * 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.instrument.ClassFileTransformer; +import java.lang.instrument.IllegalClassFormatException; +import java.lang.instrument.Instrumentation; +import java.security.ProtectionDomain; +import java.util.HashMap; + +// This is a test utility class used to transform +// specified classes via initial transformation (ClassFileLoadHook). +// Names of classes to be transformed are supplied as arguments, +// the phrase to be transformed is a hard-coded predefined +// fairly unique phrase. + +public class TransformerAgent { + private static String[] classesToTransform; + + + private static void log(String msg) { + System.out.println("TransformerAgent: " + msg); + } + + + // arguments are comma-separated list of classes to transform + public static void premain(String agentArguments, Instrumentation instrumentation) { + log("premain() is called, arguments = " + agentArguments); + classesToTransform = agentArguments.split(","); + instrumentation.addTransformer(new SimpleTransformer(), /*canRetransform=*/true); + } + + + public static void agentmain(String args, Instrumentation inst) throws Exception { + log("agentmain() is called"); + premain(args, inst); + } + + + static class SimpleTransformer implements ClassFileTransformer { + public byte[] transform(ClassLoader loader, String name, Class classBeingRedefined, + ProtectionDomain pd, byte[] buffer) throws IllegalClassFormatException { + + log("SimpleTransformer called for: " + name + "@" + incrCounter(name)); + if (!shouldTransform(name)) + return null; + + log("transforming: class name = " + name); + int nrOfReplacements = TransformUtil.replace(buffer, TransformUtil.BeforePattern, + TransformUtil.AfterPattern); + log("replaced the string, nrOfReplacements = " + nrOfReplacements); + return buffer; + } + + // Check class name pattern, since test should only transform certain classes + private static boolean shouldTransform(String name) { + for (String match : classesToTransform) { + if (name.matches(match)) { + log("shouldTransform: match-found, match = " + match); + return true; + } + } + + return false; + } + } + + + static HashMap counterMap = new HashMap<>(); + + static Integer incrCounter(String className) { + Integer i = counterMap.get(className); + if (i == null) { + i = new Integer(1); + } else { + i = new Integer(i.intValue() + 1); + } + counterMap.put(className, i); + return i; + } +} diff --git a/hotspot/test/testlibrary/jvmti/TransformerAgent.mf b/hotspot/test/testlibrary/jvmti/TransformerAgent.mf new file mode 100644 index 00000000000..9f59980a5c2 --- /dev/null +++ b/hotspot/test/testlibrary/jvmti/TransformerAgent.mf @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Premain-Class: TransformerAgent +Agent-Class: TransformerAgent +Can-Retransform-Classes: true +Can-Redefine-Classes: false diff --git a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java index 399535944f6..0d38e160684 100644 --- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java +++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java @@ -50,8 +50,9 @@ public class TestMutuallyExclusivePlatformPredicates { OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"), VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"), MODE("isInt", "isMixed", "isComp"), - IGNORED("isDebugBuild", "shouldSAAttach", - "canPtraceAttachLinux", "canAttachOSX", "isTieredSupported"); + IGNORED("isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild", + "shouldSAAttach", "canPtraceAttachLinux", "canAttachOSX", + "isTieredSupported"); public final List methodNames; diff --git a/jaxp/.hgtags b/jaxp/.hgtags index e81f2084cef..fa7e108ef76 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -376,3 +376,6 @@ e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130 874082a9b565a7092a40bfa934a6e3e3c3455a60 jdk-9+131 907445d85e680ea410fe2c83c0ec64b5508e4f3e jdk-9+132 9490ba2e5e41685c858a0ca2a6ec87611eb011c6 jdk-9+133 +1c6c21d87aa459d82425e1fddc9ce8647aebde34 jdk-9+134 +f695240370c77a25fed88225a392e7d530cb4d78 jdk-9+135 +f1eafcb0eb7182b937bc93f214d8cabd01ec4d59 jdk-9+136 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/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java index 627cbf47003..c488a9fa63e 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java @@ -61,9 +61,19 @@ import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader; * catalog resolution outside of a parsing context. It may be shared * between several parsers and the application.

* + * @deprecated This class and the JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API should + * migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. + * * @author Michael Glavassevich, IBM * */ +@Deprecated(since="9", forRemoval=true) public class XMLCatalogResolver implements XMLEntityResolver, EntityResolver2, LSResourceResolver { diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java index 337dc96fe64..574049f45e2 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java @@ -178,6 +178,14 @@ import javax.xml.parsers.SAXParserFactory; * * @see CatalogReader * @see CatalogEntry + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM @@ -187,6 +195,7 @@ import javax.xml.parsers.SAXParserFactory; *

Derived from public domain code originally published by Arbortext, * Inc.

*/ +@Deprecated(since="9", forRemoval=true) public class Catalog { /** The BASE Catalog Entry type. */ public static final int BASE = CatalogEntry.addEntryType("BASE", 1); diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java index b5fccbf04aa..605735cf1a9 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java @@ -110,13 +110,21 @@ import sun.reflect.misc.ReflectUtil; * * * @see Catalog + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM * * @version 1.0 */ - +@Deprecated(since="9", forRemoval=true) public class CatalogManager { private static final String pFiles = "xml.catalog.files"; private static final String pVerbosity = "xml.catalog.verbosity"; diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java index d566895ccce..d50a4c262b2 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java @@ -37,12 +37,21 @@ import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader; * suffix-based matching and an external RFC2483 resolver. * * @see Catalog + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM * * @version 1.0 */ +@Deprecated(since="9", forRemoval=true) public class Resolver extends Catalog { /** * The URISUFFIX Catalog Entry type. diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java index bf82547188b..10e49e7f247 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java @@ -52,12 +52,21 @@ import com.sun.org.apache.xml.internal.resolver.helpers.FileURL; * @see Catalog * @see org.xml.sax.EntityResolver * @see javax.xml.transform.URIResolver + * @deprecated The JDK internal Catalog API in package + * {@code com.sun.org.apache.xml.internal.resolver} + * is encapsulated in JDK 9. The entire implementation under the package is now + * deprecated and subject to removal in a future release. Users of the API + * should migrate to the {@linkplain javax.xml.catalog new public API}. + *

+ * The new Catalog API is supported throughout the JDK XML Processors, which allows + * the use of Catalog by simply setting a path to a Catalog file as a property. * * @author Norman Walsh * Norman.Walsh@Sun.COM * * @version 1.0 */ +@Deprecated(since="9", forRemoval=true) public class CatalogResolver implements EntityResolver, URIResolver { /** Make the parser Namespace aware? */ public boolean namespaceAware = true; 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/CatalogSupport.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java index 1078d7cd2c0..792cb13ee89 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java @@ -25,7 +25,7 @@ package catalog; import java.io.File; import java.io.StringReader; - +import javax.xml.stream.XMLResolver; import javax.xml.transform.Source; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; @@ -42,7 +42,7 @@ import org.xml.sax.InputSource; /** * @test - * @bug 8158084 8162438 8162442 + * @bug 8158084 8162438 8162442 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport * @run testng/othervm catalog.CatalogSupport @@ -113,6 +113,15 @@ public class CatalogSupport extends CatalogSupportBase { testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); } + /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXA") + public void testStAXA(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -212,6 +221,20 @@ public class CatalogSupport extends CatalogSupportBase { }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXA") + public Object[][] getDataStAX() { + + return new Object[][]{ + {false, true, xml_catalog, xml_system, null, expectedWCatalog}, + {false, true, xml_catalog, xml_system, null, expectedWResolver}, + {true, true, xml_catalog, xml_system, null, expectedWResolver} + }; + } + MyEntityHandler getMyEntityHandler(String elementName, String[] systemIds, InputSource... returnValues) { return new MyEntityHandler(systemIds, returnValues, elementName); } @@ -262,8 +285,8 @@ public class CatalogSupport extends CatalogSupportBase { SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); @@ -271,8 +294,7 @@ public class CatalogSupport extends CatalogSupportBase { XmlInput[] returnValues = {new XmlInput(null, dtd_system, null), new XmlInput(null, xsd_val_test, null)}; LSResourceResolver resolver = new SourceResolver(null, systemIds, returnValues); - StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax3 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); return new Object[][]{ // use catalog diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java index 251a65fc779..03a54ef82be 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java @@ -30,6 +30,7 @@ import java.io.File; import java.io.StringReader; import javax.xml.catalog.CatalogFeatures.Feature; +import javax.xml.stream.XMLResolver; import javax.xml.transform.Source; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; @@ -47,7 +48,7 @@ import org.xml.sax.InputSource; /* * @test - * @bug 8158084 8162438 8162442 + * @bug 8158084 8162438 8162442 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport1 * @run testng/othervm catalog.CatalogSupport1 @@ -109,6 +110,15 @@ public class CatalogSupport1 extends CatalogSupportBase { testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); } + /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC") + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -189,6 +199,18 @@ public class CatalogSupport1 extends CatalogSupportBase { }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + + return new Object[][]{ + {false, true, null, xml_system, null, expectedWCatalog}, + }; + } + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver @@ -218,8 +240,8 @@ public class CatalogSupport1 extends CatalogSupportBase { SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); @@ -227,8 +249,7 @@ public class CatalogSupport1 extends CatalogSupportBase { XmlInput[] returnValues = {new XmlInput(null, dtd_system, null), new XmlInput(null, xsd_val_test, null)}; LSResourceResolver resolver = new SourceResolver(null, systemIds, returnValues); - StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax3 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); return new Object[][]{ // use catalog diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java index 8332596e329..79e8809f329 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java @@ -30,6 +30,8 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty; import java.io.File; import java.io.IOException; import java.io.StringReader; +import javax.xml.stream.XMLResolver; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; @@ -50,7 +52,7 @@ import org.xml.sax.SAXParseException; /* * @test - * @bug 8158084 8162438 8162442 8163535 + * @bug 8158084 8162438 8162442 8163535 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport2 * @run testng/othervm catalog.CatalogSupport2 @@ -128,6 +130,15 @@ public class CatalogSupport2 extends CatalogSupportBase { testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); } + /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC") + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAXNegative(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -204,6 +215,17 @@ public class CatalogSupport2 extends CatalogSupportBase { }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + return new Object[][]{ + {false, true, xml_catalog, xml_system, null, "null"}, + }; + } + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver @@ -233,8 +255,8 @@ public class CatalogSupport2 extends CatalogSupportBase { SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java index 473ca119c90..8868b50b055 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java @@ -29,6 +29,8 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty; import java.io.File; import java.io.IOException; import java.io.StringReader; +import javax.xml.stream.XMLResolver; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; @@ -49,7 +51,7 @@ import org.xml.sax.SAXParseException; /* * @test - * @bug 8158084 8162438 8162442 8163535 + * @bug 8158084 8162438 8162442 8163535 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport3 * @run testng/othervm catalog.CatalogSupport3 @@ -124,6 +126,15 @@ public class CatalogSupport3 extends CatalogSupportBase { testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); } + /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC") + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAXNegative(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -205,6 +216,17 @@ public class CatalogSupport3 extends CatalogSupportBase { }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + return new Object[][]{ + {true, false, xml_catalog, xml_system, null, "null"}, + }; + } + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver @@ -234,8 +256,8 @@ public class CatalogSupport3 extends CatalogSupportBase { SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java index b565cf30853..2549b64c072 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java @@ -28,7 +28,7 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty; import java.io.File; import java.io.StringReader; - +import javax.xml.stream.XMLResolver; import javax.xml.transform.Source; import javax.xml.transform.URIResolver; import javax.xml.transform.dom.DOMSource; @@ -46,7 +46,7 @@ import org.xml.sax.InputSource; /** * @test - * @bug 8158084 8162438 8162442 + * @bug 8158084 8162438 8162442 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport4 * @run testng/othervm catalog.CatalogSupport4 @@ -117,6 +117,15 @@ public class CatalogSupport4 extends CatalogSupportBase { testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); } + /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXA") + public void testStAXA(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -199,6 +208,18 @@ public class CatalogSupport4 extends CatalogSupportBase { }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXA") + public Object[][] getDataStAX() { + + return new Object[][]{ + {true, true, xml_catalog, xml_system, null, expectedWCatalog}, + }; + } + MyEntityHandler getMyEntityHandler(String elementName, String[] systemIds, InputSource... returnValues) { return new MyEntityHandler(systemIds, returnValues, elementName); } @@ -230,8 +251,8 @@ public class CatalogSupport4 extends CatalogSupportBase { SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, true, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, true, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); @@ -241,8 +262,8 @@ public class CatalogSupport4 extends CatalogSupportBase { {false, true, true, ds, null, null, null, xml_catalog}, {true, false, true, ss, null, null, xml_catalog, null}, {false, true, true, ss, null, null, null, xml_catalog}, - {true, false, true, stax, null, null, xml_catalog, null}, - {false, true, true, stax1, null, null, null, xml_catalog}, + {true, false, true, stax, null, null, xml_catalog, xml_catalog}, + {false, true, true, stax1, null, null, xml_catalog, xml_catalog}, {true, false, true, source, null, null, xml_catalog, null}, {false, true, true, source, null, null, null, xml_catalog}, }; diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java index 884f34ddb88..81da1749944 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java @@ -25,6 +25,8 @@ package catalog; import java.io.File; import java.io.StringReader; +import javax.xml.stream.XMLResolver; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; @@ -43,7 +45,7 @@ import org.xml.sax.SAXException; /* * @test - * @bug 8158084 8163232 + * @bug 8158084 8163232 8166220 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport5 * @run testng/othervm catalog.CatalogSupport5 @@ -106,6 +108,15 @@ public class CatalogSupport5 extends CatalogSupportBase { testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); } + /* + Verifies the Catalog support on XMLStreamReader. + */ + @Test(dataProvider = "data_StAXC", expectedExceptions = XMLStreamException.class) + public void testStAXC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + testStAX(setUseCatalog, useCatalog, catalog, xml, resolver, expected); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -182,6 +193,18 @@ public class CatalogSupport5 extends CatalogSupportBase { }; } + /* + DataProvider: for testing the StAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_StAXC") + public Object[][] getDataStAX() { + + return new Object[][]{ + {false, true, xml_bogus_catalog, xml_system, null, expectedWCatalog}, + }; + } + /* DataProvider: for testing Schema validation Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver @@ -211,8 +234,8 @@ public class CatalogSupport5 extends CatalogSupportBase { SAXSource ss = new SAXSource(new InputSource(xml_val_test)); ss.setSystemId(xml_val_test_id); - StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); - StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog); StreamSource source = new StreamSource(new File(xml_val_test)); diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java index 87735104855..27bf6b4b661 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java @@ -318,6 +318,31 @@ public class CatalogSupportBase { assertEquals(expected, result.trim(), "Catalog support for DOM"); } + /* + Verifies the Catalog support on StAX parser. + */ + public void testStAX(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + + XMLStreamReader streamReader = getStreamReader( + setUseCatalog, useCatalog, catalog, xml, resolver); + String text = getText(streamReader, XMLStreamConstants.CHARACTERS); + assertEquals(expected, text.trim(), "Catalog support for StAX"); + } + + /* + Verifies that the Catalog support for StAX parser is disabled when + USE_CATALOG == false. + */ + public void testStAXNegative(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, XMLResolver resolver, String expected) throws Exception { + + XMLStreamReader streamReader = getStreamReader( + setUseCatalog, useCatalog, catalog, xml, resolver); + String text = getText(streamReader, XMLStreamConstants.ENTITY_REFERENCE); + assertEquals(expected, text.trim(), "Catalog support for StAX"); + } + /* Verifies the Catalog support on resolving DTD, xsd import and include in Schema files. @@ -514,15 +539,24 @@ public class CatalogSupportBase { * * @param xmlFile the XML source file * @param xmlFileId the systemId of the source + * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set + * through the factory + * @param useCatalog the value of USE_CATALOG + * @param catalog a catalog * @return a StAXSource * @throws XMLStreamException * @throws FileNotFoundException */ - StAXSource getStaxSource(String xmlFile, String xmlFileId) { + StAXSource getStaxSource(String xmlFile, String xmlFileId, boolean setUseCatalog, + boolean useCatalog, String catalog) { StAXSource ss = null; try { - ss = new StAXSource( - XMLInputFactory.newFactory().createXMLEventReader( + XMLInputFactory xif = XMLInputFactory.newFactory(); + if (setUseCatalog) { + xif.setProperty(XMLConstants.USE_CATALOG, useCatalog); + } + xif.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); + ss = new StAXSource(xif.createXMLEventReader( xmlFileId, new FileInputStream(xmlFile))); } catch (Exception e) {} @@ -531,6 +565,10 @@ public class CatalogSupportBase { /** * Creates an XMLStreamReader. + * + * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set + * through the factory + * @param useCatalog the value of USE_CATALOG * @param catalog the path to a catalog * @param xml the xml to be parsed * @param resolver a resolver to be set on the reader @@ -542,9 +580,17 @@ public class CatalogSupportBase { String catalog, String xml, XMLResolver resolver) throws FileNotFoundException, XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); - factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); + if (catalog != null) { + factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); + } + + factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true); factory.setProperty(XMLInputFactory.IS_COALESCING, true); - factory.setProperty(XMLInputFactory.RESOLVER, resolver); + + if (resolver != null) { + factory.setProperty(XMLInputFactory.RESOLVER, resolver); + } + if (setUseCatalog) { factory.setProperty(XMLConstants.USE_CATALOG, useCatalog); } @@ -560,17 +606,28 @@ public class CatalogSupportBase { * @return the text of the first element * @throws XMLStreamException */ - String getText(XMLStreamReader streamReader) throws XMLStreamException { + String getText(XMLStreamReader streamReader, int type) throws XMLStreamException { + StringBuilder text = new StringBuilder(); + StringBuilder entityRef = new StringBuilder(); + while(streamReader.hasNext()){ - int eventType = streamReader.next() ; - if(eventType == XMLStreamConstants.START_ELEMENT){ - eventType = streamReader.next() ; - if(eventType == XMLStreamConstants.CHARACTERS){ - return streamReader.getText() ; - } + int eventType = streamReader.next(); + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + break; + case XMLStreamConstants.CHARACTERS: + text.append(streamReader.getText()); + break; + case XMLStreamConstants.ENTITY_REFERENCE: + entityRef.append(streamReader.getText()); + break; } } - return null; + if (type == XMLStreamConstants.CHARACTERS) { + return text.toString(); + } else { + return entityRef.toString(); + } } /** 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..8fceda6eb06 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -379,3 +379,6 @@ fe4e11bd2423635dc0f5f5cb9a64eb2f2cce7f4c jdk-9+128 783e7e2c587f2c7e1b9998a46d90ec196ab2a195 jdk-9+131 9fff2477a4cadf2a9618a76f1f4fe0f20bb5ff3b jdk-9+132 05e99eefda2b58d1ed176e411302d9d6b35dca16 jdk-9+133 +ab1d78d395d4cb8be426ff181211da1a4085cf01 jdk-9+134 +22631824f55128a7ab6605493b3001a37af6a168 jdk-9+135 +09ec13a99f50a4a346180d1e3b0fd8bc1ee399ce jdk-9+136 diff --git a/jdk/.hgtags b/jdk/.hgtags index 4639f93e55b..d92b0709299 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -376,3 +376,6 @@ c40c8739bcdc88892ff58ebee3fd8a3f287be94d jdk-9+123 8c57f4c293bbc5609928308a6d91ba765760b5f9 jdk-9+131 d5c70818cd8a82e76632c8c815bdb4f75f53aeaf jdk-9+132 3cdae27c90b5e41afe75eab904fda19fac076330 jdk-9+133 +803adcd526d74ae0b64948d1f8260c2dbe514779 jdk-9+134 +021369229cfd0b5feb76834b2ea498f47f43c0f3 jdk-9+135 +54c5931849a33a363e03fdffa141503f5cc4779d jdk-9+136 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/data/currency/CurrencyData.properties b/jdk/make/data/currency/CurrencyData.properties index 0288b04390b..2d25c95fee5 100644 --- a/jdk/make/data/currency/CurrencyData.properties +++ b/jdk/make/data/currency/CurrencyData.properties @@ -32,14 +32,14 @@ formatVersion=3 # Version of the currency code information in this class. # It is a serial number that accompanies with each amendment. -dataVersion=160 +dataVersion=162 # List of all valid ISO 4217 currency codes. # To ensure compatibility, do not remove codes. all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036-\ AWG533-AYM945-AZM031-AZN944-BAM977-BBD052-BDT050-BEF056-BGL100-BGN975-BHD048-BIF108-\ - BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-\ + BMD060-BND096-BOB068-BOV984-BRL986-BSD044-BTN064-BWP072-BYB112-BYR974-BYN933-\ BZD084-CAD124-CDF976-CHE947-CHF756-CHW948-CLF990-CLP152-CNY156-COP170-COU970-CRC188-CSD891-CUP192-CUC931-\ CVE132-CYP196-CZK203-DEM276-DJF262-DKK208-DOP214-DZD012-EEK233-EGP818-\ ERN232-ESP724-ETB230-EUR978-FIM246-FJD242-FKP238-FRF250-GBP826-GEL981-\ @@ -119,7 +119,7 @@ BD=BDT # BARBADOS BB=BBD # BELARUS -BY=BYR +BY=BYN # BELGIUM BE=EUR # BELIZE 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/libattach/mapfile-linux b/jdk/make/mapfiles/libattach/mapfile-linux index b569ae5e637..1ffc29329a0 100644 --- a/jdk/make/mapfiles/libattach/mapfile-linux +++ b/jdk/make/mapfiles/libattach/mapfile-linux @@ -30,8 +30,6 @@ SUNWprivate_1.1 { Java_sun_tools_attach_VirtualMachineImpl_checkPermissions; Java_sun_tools_attach_VirtualMachineImpl_close; Java_sun_tools_attach_VirtualMachineImpl_connect; - Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager; - Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads; Java_sun_tools_attach_VirtualMachineImpl_open; Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo; Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf; 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/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index c34ba2f709d..20ea7c916b8 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -176,6 +176,9 @@ SUNWprivate_1.1 { Java_java_lang_ProcessHandleImpl_00024Info_info0; Java_java_lang_ProcessImpl_init; Java_java_lang_ProcessImpl_forkAndExec; + Java_java_lang_ref_Reference_getAndClearReferencePendingList; + Java_java_lang_ref_Reference_hasReferencePendingList; + Java_java_lang_ref_Reference_waitForReferencePendingList; Java_java_lang_reflect_Array_get; Java_java_lang_reflect_Array_getBoolean; Java_java_lang_reflect_Array_getByte; 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..22c132fbd72 100644 --- a/jdk/make/mapfiles/libjpeg/mapfile-vers +++ b/jdk/make/mapfiles/libjpeg/mapfile-vers @@ -26,30 +26,31 @@ # 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_JPEGImageReader_clearNativeReadAbortFlag; + 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/aix/native/libnet/aix_close.c b/jdk/src/java.base/aix/native/libnet/aix_close.c index 77b5daecf60..1588d485640 100644 --- a/jdk/src/java.base/aix/native/libnet/aix_close.c +++ b/jdk/src/java.base/aix/native/libnet/aix_close.c @@ -410,6 +410,10 @@ int NET_Read(int s, void* buf, size_t len) { BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK)); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -503,8 +507,8 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout, long currentTime) { + long prevtime = currentTime, newtime; struct timeval t; fdEntry_t *fdEntry = getFdEntry(s); @@ -516,14 +520,6 @@ int NET_Timeout(int s, long timeout) { return -1; } - /* - * Pick up current time as may need to adjust timeout - */ - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; - } - for(;;) { struct pollfd pfd; int rv; diff --git a/jdk/src/java.base/linux/native/libnet/linux_close.c b/jdk/src/java.base/linux/native/libnet/linux_close.c index 45ab7b4dc1b..2bf7cc72283 100644 --- a/jdk/src/java.base/linux/native/libnet/linux_close.c +++ b/jdk/src/java.base/linux/native/libnet/linux_close.c @@ -367,6 +367,10 @@ int NET_Read(int s, void* buf, size_t len) { BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) ); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -406,8 +410,8 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout, long currentTime) { + long prevtime = currentTime, newtime; struct timeval t; fdEntry_t *fdEntry = getFdEntry(s); @@ -419,14 +423,6 @@ int NET_Timeout(int s, long timeout) { return -1; } - /* - * Pick up current time as may need to adjust timeout - */ - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; - } - for(;;) { struct pollfd pfd; int rv; diff --git a/jdk/src/java.base/macosx/native/libnet/bsd_close.c b/jdk/src/java.base/macosx/native/libnet/bsd_close.c index 728ea8bf1d7..14739b12caf 100644 --- a/jdk/src/java.base/macosx/native/libnet/bsd_close.c +++ b/jdk/src/java.base/macosx/native/libnet/bsd_close.c @@ -371,6 +371,10 @@ int NET_Read(int s, void* buf, size_t len) { BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT)); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -410,8 +414,8 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout, long currentTime) { + long prevtime = currentTime, newtime; struct timeval t, *tp = &t; fd_set fds; fd_set* fdsp = NULL; @@ -432,9 +436,6 @@ int NET_Timeout(int s, long timeout) { */ if (timeout > 0) { /* Timed */ - struct timeval now; - gettimeofday(&now, NULL); - prevtime = now.tv_sec * 1000 + now.tv_usec / 1000; t.tv_sec = timeout / 1000; t.tv_usec = (timeout % 1000) * 1000; } else if (timeout < 0) { 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/Reference.java b/jdk/src/java.base/share/classes/java/lang/ref/Reference.java index 0a6728d007e..cd4bd8065bc 100644 --- a/jdk/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/jdk/src/java.base/share/classes/java/lang/ref/Reference.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 @@ -110,22 +110,6 @@ public abstract class Reference { private transient Reference discovered; /* used by VM */ - /* Object used to synchronize with the garbage collector. The collector - * must acquire this lock at the beginning of each collection cycle. It is - * therefore critical that any code holding this lock complete as quickly - * as possible, allocate no new objects, and avoid calling user code. - */ - private static class Lock { } - private static Lock lock = new Lock(); - - - /* List of References waiting to be enqueued. The collector adds - * References to this list, while the Reference-handler thread removes - * them. This list is protected by the above lock object. The - * list uses the discovered field to link its elements. - */ - private static Reference pending = null; - /* High-priority thread to enqueue pending References */ private static class ReferenceHandler extends Thread { @@ -139,10 +123,9 @@ public abstract class Reference { } static { - // pre-load and initialize InterruptedException and Cleaner classes - // so that we don't get into trouble later in the run loop if there's - // memory shortage while loading/initializing them lazily. - ensureClassInitialized(InterruptedException.class); + // pre-load and initialize Cleaner class so that we don't + // get into trouble later in the run loop if there's + // memory shortage while loading/initializing it lazily. ensureClassInitialized(Cleaner.class); } @@ -152,72 +135,80 @@ public abstract class Reference { public void run() { while (true) { - tryHandlePending(true); + processPendingReferences(); } } } - /** - * Try handle pending {@link Reference} if there is one.

    - * Return {@code true} as a hint that there might be another - * {@link Reference} pending or {@code false} when there are no more pending - * {@link Reference}s at the moment and the program can do some other - * useful work instead of looping. - * - * @param waitForNotify if {@code true} and there was no pending - * {@link Reference}, wait until notified from VM - * or interrupted; if {@code false}, return immediately - * when there is no pending {@link Reference}. - * @return {@code true} if there was a {@link Reference} pending and it - * was processed, or we waited for notification and either got it - * or thread was interrupted before being notified; - * {@code false} otherwise. + /* Atomically get and clear (set to null) the VM's pending list. */ - static boolean tryHandlePending(boolean waitForNotify) { - Reference r; - Cleaner c; - try { - synchronized (lock) { - if (pending != null) { - r = pending; - // 'instanceof' might throw OutOfMemoryError sometimes - // so do this before un-linking 'r' from the 'pending' chain... - c = r instanceof Cleaner ? (Cleaner) r : null; - // unlink 'r' from 'pending' chain - pending = r.discovered; - r.discovered = null; - } else { - // The waiting on the lock may cause an OutOfMemoryError - // because it may try to allocate exception objects. - if (waitForNotify) { - lock.wait(); - } - // retry if waited - return waitForNotify; + private static native Reference getAndClearReferencePendingList(); + + /* Test whether the VM's pending list contains any entries. + */ + private static native boolean hasReferencePendingList(); + + /* Wait until the VM's pending list may be non-null. + */ + private static native void waitForReferencePendingList(); + + private static final Object processPendingLock = new Object(); + private static boolean processPendingActive = false; + + private static void processPendingReferences() { + // Only the singleton reference processing thread calls + // waitForReferencePendingList() and getAndClearReferencePendingList(). + // These are separate operations to avoid a race with other threads + // that are calling waitForReferenceProcessing(). + waitForReferencePendingList(); + Reference pendingList; + synchronized (processPendingLock) { + pendingList = getAndClearReferencePendingList(); + processPendingActive = true; + } + while (pendingList != null) { + Reference ref = pendingList; + pendingList = ref.discovered; + ref.discovered = null; + + if (ref instanceof Cleaner) { + ((Cleaner)ref).clean(); + // Notify any waiters that progress has been made. + // This improves latency for nio.Bits waiters, which + // are the only important ones. + synchronized (processPendingLock) { + processPendingLock.notifyAll(); } + } else { + ReferenceQueue q = ref.queue; + if (q != ReferenceQueue.NULL) q.enqueue(ref); } - } catch (OutOfMemoryError x) { - // Give other threads CPU time so they hopefully drop some live references - // and GC reclaims some space. - // Also prevent CPU intensive spinning in case 'r instanceof Cleaner' above - // persistently throws OOME for some time... - Thread.yield(); - // retry - return true; - } catch (InterruptedException x) { - // retry - return true; } - - // Fast path for cleaners - if (c != null) { - c.clean(); - return true; + // Notify any waiters of completion of current round. + synchronized (processPendingLock) { + processPendingActive = false; + processPendingLock.notifyAll(); } + } - ReferenceQueue q = r.queue; - if (q != ReferenceQueue.NULL) q.enqueue(r); - return true; + // Wait for progress in reference processing. + // + // Returns true after waiting (for notification from the reference + // processing thread) if either (1) the VM has any pending + // references, or (2) the reference processing thread is + // processing references. Otherwise, returns false immediately. + private static boolean waitForReferenceProcessing() + throws InterruptedException + { + synchronized (processPendingLock) { + if (processPendingActive || hasReferencePendingList()) { + // Wait for progress, not necessarily completion. + processPendingLock.wait(); + return true; + } else { + return false; + } + } } static { @@ -236,8 +227,10 @@ public abstract class Reference { // provide access in SharedSecrets SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() { @Override - public boolean tryHandlePendingReference() { - return tryHandlePending(false); + public boolean waitForReferenceProcessing() + throws InterruptedException + { + return Reference.waitForReferenceProcessing(); } }); } 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/nio/Bits.java b/jdk/src/java.base/share/classes/java/nio/Bits.java index 8a7dcf77253..dfe6a8f13a7 100644 --- a/jdk/src/java.base/share/classes/java/nio/Bits.java +++ b/jdk/src/java.base/share/classes/java/nio/Bits.java @@ -131,23 +131,38 @@ class Bits { // package-private } final JavaLangRefAccess jlra = SharedSecrets.getJavaLangRefAccess(); - - // retry while helping enqueue pending Reference objects - // which includes executing pending Cleaner(s) which includes - // Cleaner(s) that free direct buffer memory - while (jlra.tryHandlePendingReference()) { - if (tryReserveMemory(size, cap)) { - return; - } - } - - // trigger VM's Reference processing - System.gc(); - - // a retry loop with exponential back-off delays - // (this gives VM some time to do it's job) boolean interrupted = false; try { + + // Retry allocation until success or there are no more + // references (including Cleaners that might free direct + // buffer memory) to process and allocation still fails. + boolean refprocActive; + do { + try { + refprocActive = jlra.waitForReferenceProcessing(); + } catch (InterruptedException e) { + // Defer interrupts and keep trying. + interrupted = true; + refprocActive = true; + } + if (tryReserveMemory(size, cap)) { + return; + } + } while (refprocActive); + + // trigger VM's Reference processing + System.gc(); + + // A retry loop with exponential back-off delays. + // Sometimes it would suffice to give up once reference + // processing is complete. But if there are many threads + // competing for memory, this gives more opportunities for + // any given thread to make progress. In particular, this + // seems to be enough for a stress test like + // DirectBufferAllocTest to (usually) succeed, while + // without it that test likely fails. Since failure here + // ends in OOME, there's no need to hurry. long sleepTime = 1; int sleeps = 0; while (true) { @@ -157,14 +172,14 @@ class Bits { // package-private if (sleeps >= MAX_SLEEPS) { break; } - if (!jlra.tryHandlePendingReference()) { - try { + try { + if (!jlra.waitForReferenceProcessing()) { Thread.sleep(sleepTime); sleepTime <<= 1; sleeps++; - } catch (InterruptedException e) { - interrupted = true; } + } catch (InterruptedException e) { + interrupted = true; } } 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/ListResourceBundle.java b/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java index 860953fc271..4c4498e1b6b 100644 --- a/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/ListResourceBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, 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 @@ -206,5 +206,5 @@ public abstract class ListResourceBundle extends ResourceBundle { lookup = temp; } - private Map lookup = null; + private volatile Map lookup = null; } 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/PropertyResourceBundle.java b/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java index 3a481035c92..502b6a4bc79 100644 --- a/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java +++ b/jdk/src/java.base/share/classes/java/util/PropertyResourceBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, 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 @@ -46,8 +46,6 @@ import java.io.IOException; import java.nio.charset.MalformedInputException; import java.nio.charset.StandardCharsets; import java.nio.charset.UnmappableCharacterException; -import java.security.AccessController; -import java.util.Locale; import sun.security.action.GetPropertyAction; import sun.util.PropertyResourceBundleCharset; import sun.util.ResourceBundleEnumeration; @@ -236,5 +234,5 @@ public class PropertyResourceBundle extends ResourceBundle { // ==================privates==================== - private Map lookup; + private final Map lookup; } 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..6b3abf50d78 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 @@ -536,19 +536,6 @@ class JarFile extends ZipFile { * @return an ordered {@code Stream} of entries in this jar file * @throws IllegalStateException if the jar file has been closed * @since 1.8 - * - * @apiNote A versioned view of the stream obtained from a {@code JarFile} - * configured to process a multi-release jar file can be created with code - * similar to the following: - *

            -     * {@code
            -     *     Stream versionedStream(JarFile jf) {
            -     *         return jf.stream().map(JarEntry::getName)
            -     *                  .filter(name -> !name.startsWith("META-INF/versions/"))
            -     *                  .map(jf::getJarEntry);
            -     *     }
            -     * }
            -     * 
            */ public Stream stream() { return StreamSupport.stream(Spliterators.spliterator( @@ -571,7 +558,7 @@ class JarFile extends ZipFile { private ZipEntry getVersionedEntry(ZipEntry ze) { ZipEntry vze = null; - if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) { + if (BASE_VERSION_MAJOR < versionMajor) { String name = ze.getName(); if (!name.startsWith(META_INF)) { vze = searchForVersionedEntry(versionMajor, name); @@ -836,18 +823,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 +852,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 +871,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 +917,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 +930,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 +961,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/jdk/internal/misc/JavaLangRefAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java index 374ca55c847..81c72bcbe91 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangRefAccess.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 @@ -28,12 +28,12 @@ package jdk.internal.misc; public interface JavaLangRefAccess { /** - * Help ReferenceHandler thread process next pending - * {@link java.lang.ref.Reference} + * Wait for progress in {@link java.lang.ref.Reference} + * processing. If there aren't any pending {@link + * java.lang.ref.Reference}s, return immediately. * - * @return {@code true} if there was a pending reference and it - * was enqueue-ed or {@code false} if there was no - * pending reference + * @return {@code true} if there were any pending + * {@link java.lang.ref.Reference}s, {@code false} otherwise. */ - boolean tryHandlePendingReference(); + boolean waitForReferenceProcessing() throws InterruptedException; } 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..a5f3126c16f 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 @@ -1197,6 +1197,9 @@ public final class Unsafe { if (hostClass == null || data == null) { throw new NullPointerException(); } + if (hostClass.isArray() || hostClass.isPrimitive()) { + throw new IllegalArgumentException(); + } return defineAnonymousClass0(hostClass, data, cpPatches); } @@ -2278,6 +2281,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 +2319,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 +2346,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 +2373,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 +2421,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 +2466,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 +2516,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 +2554,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 +2592,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 +2619,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 +2661,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 stream(JarFile jf) { + if (jf.isMultiRelease()) { + int version = jf.getVersion().major(); + return jf.stream() + .map(je -> getBaseSuffix(je, version)) + .filter(Objects::nonNull) + .distinct() + .map(jf::getJarEntry); + } + return jf.stream(); + } + + private static String getBaseSuffix(JarEntry je, int version) { + String name = je.getName(); + if (name.startsWith(META_INF_VERSIONS)) { + int len = META_INF_VERSIONS.length(); + int index = name.indexOf('/', len); + if (index == -1 || index == (name.length() - 1)) { + // filter out META-INF/versions/* and META-INF/versions/*/ + return null; + } + try { + if (Integer.parseInt(name, len, index, 10) > version) { + // not an integer + return null; + } + } catch (NumberFormatException x) { + // silently remove malformed entries + return null; + } + // We know name looks like META-INF/versions/*/* + return name.substring(index + 1); + } + return name; + } +} diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index ae5ebbbb070..f49111be646 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -143,7 +143,8 @@ module java.base { exports jdk.internal.org.objectweb.asm.signature to jdk.scripting.nashorn; exports jdk.internal.loader to - java.instrument; + java.instrument, + java.logging; exports jdk.internal.math to java.desktop; exports jdk.internal.module to diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 23fcac28865..b68e6a6a448 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -103,34 +103,42 @@ See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m # Translators please note do not translate the options themselves java.launcher.X.usage=\ -\ -Xmixed mixed mode execution (default)\n\ -\ -Xint interpreted mode execution only\n\ +\ -Xbatch disable background compilation\n\ \ -Xbootclasspath/a:\n\ \ append to end of bootstrap class path\n\ +\ -Xcheck:jni perform additional checks for JNI functions\n\ +\ -Xcomp forces compilation of methods on first invocation\n\ +\ -Xdebug provided for backward compatibility\n\ \ -Xdiag show additional diagnostic messages\n\ \ -Xdiag:resolver show resolver diagnostic messages\n\ -\ -Xnoclassgc disable class garbage collection\n\ +\ -Xdisable-@files disable further argument file expansion\n\ +\ -Xfuture enable strictest checks, anticipating future default\n\ +\ -Xint interpreted mode execution only\n\ +\ -Xinternalversion\n\ +\ displays more detailed JVM version information than the\n\ +\ -version option\n\ \ -Xloggc: log GC status to a file with time stamps\n\ -\ -Xbatch disable background compilation\n\ +\ -Xmixed mixed mode execution (default)\n\ +\ -Xmn sets the initial and maximum size (in bytes) of the heap\n\ +\ for the young generation (nursery)\n\ \ -Xms set initial Java heap size\n\ \ -Xmx set maximum Java heap size\n\ -\ -Xss set java thread stack size\n\ +\ -Xnoclassgc disable class garbage collection\n\ \ -Xprof output cpu profiling data\n\ -\ -Xfuture enable strictest checks, anticipating future default\n\ \ -Xrs reduce use of OS signals by Java/VM (see documentation)\n\ -\ -Xcheck:jni perform additional checks for JNI functions\n\ -\ -Xshare:off do not attempt to use shared class data\n\ \ -Xshare:auto use shared class data if possible (default)\n\ +\ -Xshare:off do not attempt to use shared class data\n\ \ -Xshare:on require using shared class data, otherwise fail.\n\ \ -XshowSettings show all settings and continue\n\ \ -XshowSettings:all\n\ \ show all settings and continue\n\ -\ -XshowSettings:vm show all vm related settings and continue\n\ -\ -XshowSettings:properties\n\ -\ show all property settings and continue\n\ \ -XshowSettings:locale\n\ \ show all locale related settings and continue\n\ -\ -Xdisable-@files disable further argument file expansion\n\ +\ -XshowSettings:properties\n\ +\ show all property settings and continue\n\ +\ -XshowSettings:vm show all vm related settings and continue\n\ +\ -Xss set java thread stack size\n\ +\ -Xverify sets the mode of the bytecode verifier\n\ \ --add-reads =(,)*\n\ \ updates to read , regardless\n\ \ of module declaration. \n\ diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 923fbe4d66c..35a3fa5da66 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -1074,7 +1074,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { * 1) if (instProxy != null) * connect to instProxy; raise exception if failed * 2) else use system default ProxySelector - * 3) is 2) fails, make direct connection + * 3) else make a direct connection if ProxySelector is not present */ if (instProxy == null) { // no instance Proxy is set @@ -1117,10 +1117,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { if (p != Proxy.NO_PROXY) { sel.connectFailed(uri, p.address(), ioex); if (!it.hasNext()) { - // fallback to direct connection - http = getNewHttpClient(url, null, connectTimeout, false); - http.setReadTimeout(readTimeout); - break; + throw ioex; } } else { throw ioex; diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java index daa56325e2f..fb12cf77626 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java @@ -125,7 +125,9 @@ public class JarURLConnection extends java.net.JarURLConnection { * to get the jarFile, and set it as our permission. */ if (getUseCaches()) { + boolean oldUseCaches = jarFileURLConnection.getUseCaches(); jarFileURLConnection = factory.getConnection(jarFile); + jarFileURLConnection.setUseCaches(oldUseCaches); } if ((entryName != null)) { diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java index 2d917d0604e..ad805e60b41 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSP.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 @@ -125,7 +125,7 @@ public final class OCSP { ("Exception while encoding OCSPRequest", e); } OCSPResponse ocspResponse = check(Collections.singletonList(certId), - responderURI, issuerCert, null, null, + responderURI, new OCSPResponse.IssuerInfo(issuerCert), null, null, Collections.emptyList()); return (RevocationStatus)ocspResponse.getSingleResponse(certId); } @@ -173,7 +173,8 @@ public final class OCSP { ("Exception while encoding OCSPRequest", e); } OCSPResponse ocspResponse = check(Collections.singletonList(certId), - responderURI, issuerCert, responderCert, date, extensions); + responderURI, new OCSPResponse.IssuerInfo(issuerCert), + responderCert, date, extensions); return (RevocationStatus) ocspResponse.getSingleResponse(certId); } @@ -182,7 +183,7 @@ public final class OCSP { * * @param certIds the CertIds to be checked * @param responderURI the URI of the OCSP responder - * @param issuerCert the issuer's certificate + * @param issuerInfo the issuer's certificate and/or subject and public key * @param responderCert the OCSP responder's certificate * @param date the time the validity of the OCSP responder's certificate * should be checked against. If null, the current time is used. @@ -195,8 +196,8 @@ public final class OCSP { * @throws CertPathValidatorException if an exception occurs while * encoding the OCSP Request or validating the OCSP Response */ - static OCSPResponse check(List certIds, URI responderURI, - X509Certificate issuerCert, + static OCSPResponse check(List certIds, URI responderURI, + OCSPResponse.IssuerInfo issuerInfo, X509Certificate responderCert, Date date, List extensions) throws IOException, CertPathValidatorException @@ -214,7 +215,7 @@ public final class OCSP { ocspResponse = new OCSPResponse(response); // verify the response - ocspResponse.verify(certIds, issuerCert, responderCert, date, + ocspResponse.verify(certIds, issuerInfo, responderCert, date, nonce); } catch (IOException ioe) { throw new CertPathValidatorException( diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java index 0ef14abc68a..a2b74d1bdeb 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.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 @@ -41,6 +41,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import javax.security.auth.x500.X500Principal; @@ -373,8 +374,8 @@ public final class OCSPResponse { } } - void verify(List certIds, X509Certificate issuerCert, - X509Certificate responderCert, Date date, byte[] nonce) + void verify(List certIds, IssuerInfo issuerInfo, + X509Certificate responderCert, Date date, byte[] nonce) throws CertPathValidatorException { switch (responseStatus) { @@ -414,7 +415,9 @@ public final class OCSPResponse { // Add the Issuing CA cert and/or Trusted Responder cert to the list // of certs from the OCSP response try { - certs.add(X509CertImpl.toImpl(issuerCert)); + if (issuerInfo.getCertificate() != null) { + certs.add(X509CertImpl.toImpl(issuerInfo.getCertificate())); + } if (responderCert != null) { certs.add(X509CertImpl.toImpl(responderCert)); } @@ -464,7 +467,10 @@ public final class OCSPResponse { // Check whether the signer cert returned by the responder is trusted if (signerCert != null) { // Check if the response is signed by the issuing CA - if (signerCert.equals(issuerCert)) { + if (signerCert.getSubjectX500Principal().equals( + issuerInfo.getName()) && + signerCert.getPublicKey().equals( + issuerInfo.getPublicKey())) { if (debug != null) { debug.println("OCSP response is signed by the target's " + "Issuing CA"); @@ -481,7 +487,7 @@ public final class OCSPResponse { // Check if the response is signed by an authorized responder } else if (signerCert.getIssuerX500Principal().equals( - issuerCert.getSubjectX500Principal())) { + issuerInfo.getName())) { // Check for the OCSPSigning key purpose try { @@ -502,7 +508,8 @@ public final class OCSPResponse { // Check algorithm constraints specified in security property // "jdk.certpath.disabledAlgorithms". AlgorithmChecker algChecker = new AlgorithmChecker( - new TrustAnchor(issuerCert, null)); + new TrustAnchor(issuerInfo.getName(), + issuerInfo.getPublicKey(), null)); algChecker.init(false); algChecker.check(signerCert, Collections.emptySet()); @@ -540,7 +547,7 @@ public final class OCSPResponse { // verify the signature try { - signerCert.verify(issuerCert.getPublicKey()); + signerCert.verify(issuerInfo.getPublicKey()); if (debug != null) { debug.println("OCSP response is signed by an " + "Authorized Responder"); @@ -971,4 +978,86 @@ public final class OCSPResponse { return sb.toString(); } } + + /** + * Helper class that allows consumers to pass in issuer information. This + * will always consist of the issuer's name and public key, but may also + * contain a certificate if the originating data is in that form. + */ + static final class IssuerInfo { + private final X509Certificate certificate; + private final X500Principal name; + private final PublicKey pubKey; + + IssuerInfo(X509Certificate issuerCert) { + certificate = Objects.requireNonNull(issuerCert, + "Constructor requires non-null certificate"); + name = certificate.getSubjectX500Principal(); + pubKey = certificate.getPublicKey(); + } + + IssuerInfo(X500Principal subjectName, PublicKey key) { + certificate = null; + name = Objects.requireNonNull(subjectName, + "Constructor requires non-null subject"); + pubKey = Objects.requireNonNull(key, + "Constructor requires non-null public key"); + } + + IssuerInfo(TrustAnchor anchor) { + certificate = anchor.getTrustedCert(); + if (certificate != null) { + name = certificate.getSubjectX500Principal(); + pubKey = certificate.getPublicKey(); + } else { + name = anchor.getCA(); + pubKey = anchor.getCAPublicKey(); + } + } + + /** + * Get the certificate in this IssuerInfo if present. + * + * @return the {@code X509Certificate} used to create this IssuerInfo + * object, or {@code null} if a certificate was not used in its + * creation. + */ + X509Certificate getCertificate() { + return certificate; + } + + /** + * Get the name of this issuer. + * + * @return an {@code X500Principal} corresponding to this issuer's + * name. If derived from an issuer's {@code X509Certificate} this + * would be equivalent to the certificate subject name. + */ + X500Principal getName() { + return name; + } + + /** + * Get the public key for this issuer. + * + * @return a {@code PublicKey} for this issuer. + */ + PublicKey getPublicKey() { + return pubKey; + } + + /** + * Create a string representation of this IssuerInfo. + * + * @return a {@code String} form of this IssuerInfo object. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Issuer Info:\n"); + sb.append("Name: ").append(name.toString()).append("\n"); + sb.append("Public Key:\n").append(pubKey.toString()).append("\n"); + return sb.toString(); + } + } } diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java index 002a6c37776..e3de6a959e7 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, 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 @@ -61,12 +61,12 @@ class RevocationChecker extends PKIXRevocationChecker { private List certStores; private Map ocspResponses; private List ocspExtensions; - private boolean legacy; + private final boolean legacy; private LinkedList softFailExceptions = new LinkedList<>(); // state variables - private X509Certificate issuerCert; + private OCSPResponse.IssuerInfo issuerInfo; private PublicKey prevPubKey; private boolean crlSignFlag; private int certIndex; @@ -301,9 +301,9 @@ class RevocationChecker extends PKIXRevocationChecker { CertPathValidatorException("forward checking not supported"); } if (anchor != null) { - issuerCert = anchor.getTrustedCert(); - prevPubKey = (issuerCert != null) ? issuerCert.getPublicKey() - : anchor.getCAPublicKey(); + issuerInfo = new OCSPResponse.IssuerInfo(anchor); + prevPubKey = issuerInfo.getPublicKey(); + } crlSignFlag = true; if (params != null && params.certPath() != null) { @@ -437,7 +437,7 @@ class RevocationChecker extends PKIXRevocationChecker { private void updateState(X509Certificate cert) throws CertPathValidatorException { - issuerCert = cert; + issuerInfo = new OCSPResponse.IssuerInfo(cert); // Make new public key if parameters are missing PublicKey pubKey = cert.getPublicKey(); @@ -708,14 +708,8 @@ class RevocationChecker extends PKIXRevocationChecker { OCSPResponse response = null; CertId certId = null; try { - if (issuerCert != null) { - certId = new CertId(issuerCert, - currCert.getSerialNumberObject()); - } else { - // must be an anchor name and key - certId = new CertId(anchor.getCA(), anchor.getCAPublicKey(), - currCert.getSerialNumberObject()); - } + certId = new CertId(issuerInfo.getName(), issuerInfo.getPublicKey(), + currCert.getSerialNumberObject()); // check if there is a cached OCSP response available byte[] responseBytes = ocspResponses.get(cert); @@ -732,8 +726,8 @@ class RevocationChecker extends PKIXRevocationChecker { nonce = ext.getValue(); } } - response.verify(Collections.singletonList(certId), issuerCert, - responderCert, params.date(), nonce); + response.verify(Collections.singletonList(certId), issuerInfo, + responderCert, params.date(), nonce); } else { URI responderURI = (this.responderURI != null) @@ -746,8 +740,8 @@ class RevocationChecker extends PKIXRevocationChecker { } response = OCSP.check(Collections.singletonList(certId), - responderURI, issuerCert, responderCert, - null, ocspExtensions); + responderURI, issuerInfo, + responderCert, null, ocspExtensions); } } catch (IOException e) { throw new CertPathValidatorException( diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java index 6119be94727..1f155a6bf2a 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java @@ -1185,7 +1185,7 @@ final class ClientHandshaker extends Handshaker { /* * FOURTH, if we sent a Certificate, we need to send a signed * CertificateVerify (unless the key in the client's certificate - * was a Diffie-Hellman key).). + * was a Diffie-Hellman key). * * This uses a hash of the previous handshake messages ... either * a nonfinal one (if the particular implementation supports it) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 764f04cd545..86727b91997 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -1496,7 +1496,7 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager } } catch (CertPathValidatorException cpve) { throw new CertificateException( - "Certificates does not conform to algorithm constraints"); + "Certificates do not conform to algorithm constraints", cpve); } } } diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java index ddb4bb53f2c..4be1363b58f 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java @@ -149,7 +149,10 @@ class BreakDictionary { BufferedInputStream in; try { PrivilegedExceptionAction 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/classes/sun/util/resources/CurrencyNames.properties b/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties index b002202875b..c62d518e4b5 100644 --- a/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties +++ b/jdk/src/java.base/share/classes/sun/util/resources/CurrencyNames.properties @@ -92,6 +92,7 @@ BSD=BSD BTN=BTN BWP=BWP BYB=BYB +BYN=BYN BYR=BYR BZD=BZD CAD=CAD @@ -310,8 +311,9 @@ brl=Brazilian Real bsd=Bahamian Dollar btn=Bhutanese Ngultrum bwp=Botswanan Pula -byb=Belarusian New Ruble (1994-1999) -byr=Belarusian Ruble +byb=Belarusian Ruble (1994-1999) +byn=Belarusian Ruble +byr=Belarusian Ruble (2000-2016) bzd=Belize Dollar cad=Canadian Dollar cdf=Congolese Franc @@ -399,7 +401,7 @@ mro=Mauritanian Ouguiya mtl=Maltese Lira mur=Mauritian Rupee mvr=Maldivian Rufiyaa -mwk=Malawian Kwacha +mwk=Malawian Malawi Kwacha mxn=Mexican Peso mxv=Mexican Investment Unit myr=Malaysian Ringgit @@ -414,7 +416,7 @@ npr=Nepalese Rupee nzd=New Zealand Dollar omr=Omani Rial pab=Panamanian Balboa -pen=Peruvian Nuevo Sol +pen=Peruvian Sol pgk=Papua New Guinean Kina php=Philippine Peso pkr=Pakistani Rupee diff --git a/jdk/src/java.base/share/native/include/jvm.h b/jdk/src/java.base/share/native/include/jvm.h index 2011e58352a..bf60a857beb 100644 --- a/jdk/src/java.base/share/native/include/jvm.h +++ b/jdk/src/java.base/share/native/include/jvm.h @@ -281,6 +281,18 @@ JVM_GetSystemPackage(JNIEnv *env, jstring name); JNIEXPORT jobjectArray JNICALL JVM_GetSystemPackages(JNIEnv *env); +/* + * java.lang.ref.Reference + */ +JNIEXPORT jobject JNICALL +JVM_GetAndClearReferencePendingList(JNIEnv *env); + +JNIEXPORT jboolean JNICALL +JVM_HasReferencePendingList(JNIEnv *env); + +JNIEXPORT void JNICALL +JVM_WaitForReferencePendingList(JNIEnv *env); + /* * java.io.ObjectInputStream */ diff --git a/jdk/src/java.base/share/native/libjava/Reference.c b/jdk/src/java.base/share/native/libjava/Reference.c new file mode 100644 index 00000000000..92c518c5d90 --- /dev/null +++ b/jdk/src/java.base/share/native/libjava/Reference.c @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#include "jvm.h" +#include "java_lang_ref_Reference.h" + +JNIEXPORT jobject JNICALL +Java_java_lang_ref_Reference_getAndClearReferencePendingList(JNIEnv *env, jclass ignore) +{ + return JVM_GetAndClearReferencePendingList(env); +} + +JNIEXPORT jboolean JNICALL +Java_java_lang_ref_Reference_hasReferencePendingList(JNIEnv *env, jclass ignore) +{ + return JVM_HasReferencePendingList(env); +} + +JNIEXPORT void JNICALL +Java_java_lang_ref_Reference_waitForReferencePendingList(JNIEnv *env, jclass ignore) +{ + JVM_WaitForReferencePendingList(env); +} 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..b5056de84a9 100644 --- a/jdk/src/java.base/share/native/libjli/java.h +++ b/jdk/src/java.base/share/native/libjli/java.h @@ -112,6 +112,9 @@ GetXUsagePath(char *buf, jint bufsize); jboolean GetApplicationHome(char *buf, jint bufsize); +jboolean +GetApplicationHomeFromDll(char *buf, jint bufsize); + #define GetArch() GetArchPath(CURRENT_DATA_MODEL) /* @@ -253,6 +256,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/solaris/native/libnet/solaris_close.c b/jdk/src/java.base/solaris/native/libnet/solaris_close.c index 0cf7b5c96fc..091dc00d251 100644 --- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c +++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c @@ -35,7 +35,7 @@ if (1) { \ do { \ _result = _cmd; \ - } while((_result == -1) && (errno == EINTR)); \ + } while((_result == -1) && (errno == EINTR)); \ return _result; \ } \ } while(0) @@ -44,6 +44,10 @@ int NET_Read(int s, void* buf, size_t len) { RESTARTABLE_RETURN_INT(recv(s, buf, len, 0)); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + RESTARTABLE_RETURN_INT(recv(s, buf, len, MSG_DONTWAIT)); +} + int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen)); @@ -86,19 +90,14 @@ int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout)); } -int NET_Timeout(int s, long timeout) { +int NET_Timeout0(int s, long timeout, long currentTime) { int result; struct timeval t; - long prevtime, newtime; + long prevtime = currentTime, newtime; struct pollfd pfd; pfd.fd = s; pfd.events = POLLIN; - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = (t.tv_sec * 1000) + t.tv_usec / 1000; - } - for(;;) { result = poll(&pfd, 1, timeout); if (result < 0 && errno == EINTR) { 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/libjava/TimeZone_md.c b/jdk/src/java.base/unix/native/libjava/TimeZone_md.c index 8b09a53be82..f0bb362afc5 100644 --- a/jdk/src/java.base/unix/native/libjava/TimeZone_md.c +++ b/jdk/src/java.base/unix/native/libjava/TimeZone_md.c @@ -128,13 +128,20 @@ findZoneinfoFile(char *buf, size_t size, const char *dir) char *dbuf = NULL; char *tz = NULL; int res; + long name_max = 0; dirp = opendir(dir); if (dirp == NULL) { return NULL; } - entry = (struct dirent64 *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); + name_max = pathconf(dir, _PC_NAME_MAX); + // If pathconf did not work, fall back to a mimimum buffer size. + if (name_max < 1024) { + name_max = 1024; + } + + entry = (struct dirent64 *)malloc(offsetof(struct dirent64, d_name) + name_max + 1); if (entry == NULL) { (void) closedir(dirp); return NULL; diff --git a/jdk/src/java.base/unix/native/libjli/java_md_common.c b/jdk/src/java.base/unix/native/libjli/java_md_common.c index 48c0d8b377e..3c3c4bda969 100644 --- a/jdk/src/java.base/unix/native/libjli/java_md_common.c +++ b/jdk/src/java.base/unix/native/libjli/java_md_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, 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,8 +25,49 @@ #include "java.h" /* - * If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put - * "/foo" into buf. + * Find the last occurrence of a string + */ +char* findLastPathComponent(char *buffer, const char *comp) { + char* t = buffer; + char* p = NULL; + size_t l = JLI_StrLen(comp); + t = JLI_StrStr(t, comp); + + while (t != NULL) { + p = t; + t += l; + t = JLI_StrStr(t, comp); + } + return p; +} + +/* + * Removes the trailing file name and any intermediate platform + * directories, if any, and its enclosing directory. + * Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the + * truncated resulting buffer will contain "/foo". + */ +jboolean +TruncatePath(char *buf) +{ + // try bin directory, maybe an executable + char *p = findLastPathComponent(buf, "/bin/"); + if (p != NULL) { + *p = '\0'; + return JNI_TRUE; + } + // try lib directory, maybe a library + p = findLastPathComponent(buf, "/lib/"); + if (p != NULL) { + *p = '\0'; + return JNI_TRUE; + } + return JNI_FALSE; +} + +/* + * Retrieves the path to the JRE home by locating the executable file + * of the current process and then truncating the path to the executable */ jboolean GetApplicationHome(char *buf, jint bufsize) @@ -38,26 +79,27 @@ GetApplicationHome(char *buf, jint bufsize) } else { return JNI_FALSE; } - - if (JLI_StrRChr(buf, '/') == 0) { - buf[0] = '\0'; - return JNI_FALSE; - } - *(JLI_StrRChr(buf, '/')) = '\0'; /* executable file */ - if (JLI_StrLen(buf) < 4 || JLI_StrRChr(buf, '/') == 0) { - buf[0] = '\0'; - return JNI_FALSE; - } - if (JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0) - *(JLI_StrRChr(buf, '/')) = '\0'; /* sparcv9 or amd64 */ - if (JLI_StrLen(buf) < 4 || JLI_StrCmp("/bin", buf + JLI_StrLen(buf) - 4) != 0) { - buf[0] = '\0'; - return JNI_FALSE; - } - *(JLI_StrRChr(buf, '/')) = '\0'; /* bin */ - - return JNI_TRUE; + return TruncatePath(buf); } + +/* + * Retrieves the path to the JRE home by locating the + * shared library and then truncating the path to it. + */ +jboolean +GetApplicationHomeFromDll(char *buf, jint bufsize) +{ + /* try to find ourselves instead */ + Dl_info info; + if (dladdr((void*)&GetApplicationHomeFromDll, &info) != 0) { + char *path = realpath(info.dli_fname, buf); + if (path == buf) { + return TruncatePath(buf); + } + } + return JNI_FALSE; +} + /* * Return true if the named program exists */ diff --git a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c index 38d8834a932..b9091aaead3 100644 --- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c +++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c @@ -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 @@ -666,6 +666,7 @@ static jboolean GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative) { char libjava[MAXPATHLEN]; + struct stat s; if (GetApplicationHome(path, pathsize)) { /* Is JRE co-located with the application? */ @@ -688,6 +689,14 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative) } } + if (GetApplicationHomeFromDll(path, pathsize)) { + JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch); + if (stat(libjava, &s) == 0) { + JLI_TraceLauncher("JRE path is %s\n", path); + return JNI_TRUE; + } + } + if (!speculative) JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); return JNI_FALSE; 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/libnet/SocketInputStream.c b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c index 08d8508b154..380c03bfeaa 100644 --- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c +++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c @@ -35,7 +35,6 @@ #include "java_net_SocketInputStream.h" - /************************************************************************ * SocketInputStream */ @@ -52,6 +51,40 @@ Java_java_net_SocketInputStream_init(JNIEnv *env, jclass cls) { IO_fd_fdID = NET_GetFileDescriptorID(env); } +static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) { + int result = 0; + long prevtime = NET_GetCurrentTime(), newtime; + while (timeout > 0) { + result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime); + if (result <= 0) { + if (result == 0) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", "Read timed out"); + } else if (result == -1) { + if (errno == EBADF) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); + } else if (errno == ENOMEM) { + JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed"); + } else { + JNU_ThrowByNameWithMessageAndLastError + (env, JNU_JAVANETPKG "SocketException", "select/poll failed"); + } + } + return -1; + } + result = NET_NonBlockingRead(fd, bufP, len); + if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { + newtime = NET_GetCurrentTime(); + timeout -= newtime - prevtime; + if (timeout > 0) { + prevtime = newtime; + } + } else { + break; + } + } + return result; +} + /* * Class: java_net_SocketInputStream * Method: socketRead0 @@ -98,32 +131,18 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this, } else { bufP = BUF; } - if (timeout) { - nread = NET_Timeout(fd, timeout); - if (nread <= 0) { - if (nread == 0) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", - "Read timed out"); - } else if (nread == -1) { - if (errno == EBADF) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); - } else if (errno == ENOMEM) { - JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed"); - } else { - JNU_ThrowByNameWithMessageAndLastError - (env, JNU_JAVANETPKG "SocketException", "select/poll failed"); - } - } + nread = NET_ReadWithTimeout(env, fd, bufP, len, timeout); + if ((*env)->ExceptionCheck(env)) { if (bufP != BUF) { free(bufP); } - return -1; + return nread; } + } else { + nread = NET_Read(fd, bufP, len); } - nread = NET_Read(fd, bufP, len); - if (nread <= 0) { if (nread < 0) { @@ -143,7 +162,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this, JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException", "Operation interrupted"); break; - default: JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "Read failed"); diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c index c801a824bc3..66670f900cc 100644 --- a/jdk/src/java.base/unix/native/libnet/net_util_md.c +++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifndef _ALLBSD_SOURCE #include @@ -1669,3 +1670,18 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout) return timeout; } + +long NET_GetCurrentTime() { + struct timeval time; + gettimeofday(&time, NULL); + return (time.tv_sec * 1000 + time.tv_usec / 1000); +} + +int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) { + return NET_Timeout0(s, timeout, currentTime); +} + +int NET_Timeout(int s, long timeout) { + long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0; + return NET_Timeout0(s, timeout, currentTime); +} diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.h b/jdk/src/java.base/unix/native/libnet/net_util_md.h index 3a8c9f4d48e..1f5b6f60eca 100644 --- a/jdk/src/java.base/unix/native/libnet/net_util_md.h +++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h @@ -35,7 +35,11 @@ #include int NET_Timeout(int s, long timeout); +int NET_Timeout0(int s, long timeout, long currentTime); int NET_Read(int s, void* buf, size_t len); +int NET_NonBlockingRead(int s, void* buf, size_t len); +int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime); +long NET_GetCurrentTime(); int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); int NET_ReadV(int s, const struct iovec * vector, int count); 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.base/windows/native/libjli/java_md.c b/jdk/src/java.base/windows/native/libjli/java_md.c index 3b031d59dcc..3d29357542b 100644 --- a/jdk/src/java.base/windows/native/libjli/java_md.c +++ b/jdk/src/java.base/windows/native/libjli/java_md.c @@ -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 @@ -348,7 +348,6 @@ GetJREPath(char *path, jint pathsize) JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); return JNI_FALSE; - } /* @@ -423,11 +422,11 @@ TruncatePath(char *buf) *JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */ if ((cp = JLI_StrRChr(buf, '\\')) == 0) { /* This happens if the application is in a drive root, and - * there is no bin directory. */ + * there is no bin directory. */ buf[0] = '\0'; return JNI_FALSE; } - *cp = '\0'; /* remove the bin\ part */ + *cp = '\0'; /* remove the bin\ part */ return JNI_TRUE; } @@ -449,16 +448,16 @@ GetApplicationHome(char *buf, jint bufsize) jboolean GetApplicationHomeFromDll(char *buf, jint bufsize) { - HMODULE hModule; - DWORD dwFlags = - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; + HMODULE module; + DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; - if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) { - return JNI_FALSE; - }; - GetModuleFileName(hModule, buf, bufsize); - return TruncatePath(buf); + if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) { + if (GetModuleFileName(module, buf, bufsize) != 0) { + return TruncatePath(buf); + } + } + return JNI_FALSE; } /* diff --git a/jdk/src/java.base/windows/native/libjli/java_md.h b/jdk/src/java.base/windows/native/libjli/java_md.h index ec3131f6b61..a2392eba8fc 100644 --- a/jdk/src/java.base/windows/native/libjli/java_md.h +++ b/jdk/src/java.base/windows/native/libjli/java_md.h @@ -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 @@ -54,7 +54,4 @@ extern jlong Counter2Micros(jlong counts); int UnsetEnv(char *name); -jboolean -GetApplicationHomeFromDll(char *buf, jint bufsize); - #endif /* JAVA_MD_H */ 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/LWWindowPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java index 658be0638bb..12f9747d82c 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -187,6 +187,7 @@ public class LWWindowPeer updateAlwaysOnTopState(); updateMinimumSize(); + updateFocusableWindowState(); final Shape shape = getTarget().getShape(); if (shape != null) { 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/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 2842e02fd1e..cbbf3b193e9 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -63,6 +63,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename); private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled); private static native void nativeSynthesizeMouseEnteredExitedEvents(); + private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType); private static native void nativeDispose(long nsWindowPtr); private static native void nativeEnterFullScreenMode(long nsWindowPtr); private static native void nativeExitFullScreenMode(long nsWindowPtr); @@ -825,6 +826,13 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo return; } + if (blocked) { + // We are going to show a modal window. Previously displayed window will be + // blocked/disabled. So we have to send mouse exited event to it now, since + // all mouse events are discarded for blocked/disabled windows. + nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited); + } + nativeSetEnabled(getNSWindowPtr(), !blocked); checkBlockingAndOrder(); } diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index 682769ac2d2..211be30d895 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -1333,9 +1333,9 @@ JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnde /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSynthesizeMouseEnteredExitedEvents - * Signature: (J)V + * Signature: ()V */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__ (JNIEnv *env, jclass clazz) { JNF_COCOA_ENTER(env); @@ -1347,6 +1347,29 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou JNF_COCOA_EXIT(env); } +/* + * Class: sun_lwawt_macosx_CPlatformWindow + * Method: nativeSynthesizeMouseEnteredExitedEvents + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__JI +(JNIEnv *env, jclass clazz, jlong windowPtr, jint eventType) +{ +JNF_COCOA_ENTER(env); + + if (eventType == NSMouseEntered || eventType == NSMouseExited) { + NSWindow *nsWindow = OBJC(windowPtr); + + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ + [AWTWindow synthesizeMouseEnteredExitedEvents:nsWindow withType:eventType]; + }]; + } else { + [JNFException raise:env as:kIllegalArgumentException reason:"unknown event type"]; + } + +JNF_COCOA_EXIT(env); +} + /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: _toggleFullScreenMode 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/awt/AWTUtilities.java b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java index 1957fba5b8e..1ba10acd72f 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java +++ b/jdk/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java @@ -447,6 +447,7 @@ public final class AWTUtilities { * @param shape the new 'mixing-cutout' shape * @throws NullPointerException if the component argument is {@code null} */ + @Deprecated(since = "9") public static void setComponentMixingCutoutShape(Component component, Shape shape) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java index 2134f4b888d..67d1b5307ae 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, 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 @@ -749,6 +749,10 @@ public class BMPImageReader extends ImageReader implements BMPConstants { checkIndex(imageIndex); clearAbortRequest(); processImageStarted(imageIndex); + if (abortRequested()) { + processReadAborted(); + return bi; + } if (param == null) param = getDefaultReadParam(); @@ -1005,9 +1009,6 @@ public class BMPImageReader extends ImageReader implements BMPConstants { int j = isBottomUp ? (height -1)*bytesPerScanline : 0; for (int i=0; i() { - 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..228e14c93d2 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; /** @@ -844,32 +843,7 @@ public abstract class Component implements ImageObserver, MenuContainer, return new Rectangle(comp.x, comp.y, comp.width, comp.height); } public void setMixingCutoutShape(Component comp, Shape shape) { - Region region = shape == null ? null : - Region.getInstance(shape, null); - - synchronized (comp.getTreeLock()) { - boolean needShowing = false; - boolean needHiding = false; - - if (!comp.isNonOpaqueForMixing()) { - needHiding = true; - } - - comp.mixingCutoutRegion = region; - - if (!comp.isNonOpaqueForMixing()) { - needShowing = true; - } - - if (comp.isMixingNeeded()) { - if (needHiding) { - comp.mixOnHiding(comp.isLightweight()); - } - if (needShowing) { - comp.mixOnShowing(); - } - } - } + comp.setMixingCutoutShape(shape); } public void setGraphicsConfiguration(Component comp, @@ -8695,6 +8669,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 +8684,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; } } } @@ -10262,6 +10213,71 @@ public abstract class Component implements ImageObserver, MenuContainer, return true; } + /** + * Sets a 'mixing-cutout' shape for the given component. + * + * By default a lightweight component is treated as an opaque rectangle for + * the purposes of the Heavyweight/Lightweight Components Mixing feature. + * This method enables developers to set an arbitrary shape to be cut out + * from heavyweight components positioned underneath the lightweight + * component in the z-order. + *

            + * The {@code shape} argument may have the following values: + *

            + *

            + * The most common example when the 'mixing-cutout' shape is needed is a + * glass pane component. The {@link JRootPane#setGlassPane()} method + * automatically sets the empty-shape as the 'mixing-cutout' shape + * for the given glass pane component. If a developer needs some other + * 'mixing-cutout' shape for the glass pane (which is rare), this must be + * changed manually after installing the glass pane to the root pane. + *

            + * Note that the 'mixing-cutout' shape neither affects painting, nor the + * mouse events handling for the given component. It is used exclusively + * for the purposes of the Heavyweight/Lightweight Components Mixing + * feature. + * + * @param shape the new 'mixing-cutout' shape + * @since 9 + */ + void setMixingCutoutShape(Shape shape) { + Region region = shape == null ? null : Region.getInstance(shape, null); + + synchronized (getTreeLock()) { + boolean needShowing = false; + boolean needHiding = false; + + if (!isNonOpaqueForMixing()) { + needHiding = true; + } + + mixingCutoutRegion = region; + + if (!isNonOpaqueForMixing()) { + needShowing = true; + } + + if (isMixingNeeded()) { + if (needHiding) { + mixOnHiding(isLightweight()); + } + if (needShowing) { + mixOnShowing(); + } + } + } + } + // ****************** END OF MIXING CODE ******************************** // Note that the method is overriden in the Window class, 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/Taskbar.java b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java index 393d8a32ba2..22710085e83 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java @@ -273,9 +273,7 @@ public class Taskbar { } /** - * Requests user attention to the specified window until it is activated. - * - * On an already active window requesting attention does nothing. + * Requests user attention to the specified window. * * @param w window * @throws SecurityException if a security manager exists and it denies the diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java index 76db7f06a30..9d00222ed2c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -208,7 +208,7 @@ public abstract class Toolkit { /** * Returns whether dynamic layout of Containers on resize is currently - * enabled on the underlying operating system and/or window manager). If the + * enabled on the underlying operating system and/or window manager. If the * platform supports it, {@code setDynamicLayout(boolean)} may be used to * programmatically enable or disable platform dynamic layout. Regardless of * whether that toggling is supported, or whether {@code true} or {@code 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/java/awt/peer/TaskbarPeer.java b/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java index 934a1c01538..bf31082fe92 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java +++ b/jdk/src/java.desktop/share/classes/java/awt/peer/TaskbarPeer.java @@ -49,9 +49,7 @@ public interface TaskbarPeer { default void requestUserAttention(boolean enabled, final boolean critical) {} /** - * Requests user attention to the specified window until it is activated. - * - * On an already active window requesting attention does nothing. + * Requests user attention to the specified window. * * @param w window */ 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/SortingFocusTraversalPolicy.java b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java index 9057e80faad..d7f1ebcf034 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 @@ -26,15 +26,11 @@ package javax.swing; import java.awt.Component; import java.awt.Container; -import java.awt.Window; import java.util.*; import java.awt.FocusTraversalPolicy; import sun.util.logging.PlatformLogger; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import sun.security.action.GetPropertyAction; import java.security.AccessController; -import java.security.PrivilegedAction; /** * A FocusTraversalPolicy that determines traversal order by sorting the @@ -100,27 +96,10 @@ public class SortingFocusTraversalPolicy * See: JDK-8048887 */ private static final boolean legacySortingFTPEnabled; - private static final Method legacyMergeSortMethod; static { legacySortingFTPEnabled = "true".equals(AccessController.doPrivileged( new GetPropertyAction("swing.legacySortingFTPEnabled", "true"))); - legacyMergeSortMethod = legacySortingFTPEnabled ? - AccessController.doPrivileged(new PrivilegedAction() { - public Method run() { - try { - Method m = java.util.Arrays.class.getDeclaredMethod("legacyMergeSort", - new Class[]{Object[].class, - Comparator.class}); - m.setAccessible(true); - return m; - } catch (NoSuchMethodException e) { - // using default sorting algo - return null; - } - } - }) : - null; } /** @@ -169,30 +148,25 @@ public class SortingFocusTraversalPolicy private void enumerateAndSortCycle(Container focusCycleRoot, List cycle) { if (focusCycleRoot.isShowing()) { enumerateCycle(focusCycleRoot, cycle); - if (!legacySortingFTPEnabled || - !legacySort(cycle, comparator)) - { - Collections.sort(cycle, comparator); + if (legacySortingFTPEnabled) { + legacySort(cycle, comparator); + } else { + cycle.sort(comparator); } } } - private boolean legacySort(List l, Comparator c) { - if (legacyMergeSortMethod == null) - return false; - - Object[] a = l.toArray(); - try { - legacyMergeSortMethod.invoke(null, a, c); - } catch (IllegalAccessException | InvocationTargetException e) { - return false; + private void legacySort(List l, + Comparator c) { + if (c != null && l.size() > 1) { + Component[] a = l.toArray(new Component[l.size()]); + mergeSort(a.clone(), a, 0, a.length, 0, c); + ListIterator i = l.listIterator(); + for (Component e : a) { + i.next(); + i.set(e); + } } - ListIterator i = l.listIterator(); - for (Object e : a) { - i.next(); - i.set((Component)e); - } - return true; } @SuppressWarnings("deprecation") @@ -665,6 +639,48 @@ public class SortingFocusTraversalPolicy protected boolean accept(Component aComponent) { return fitnessTestPolicy.accept(aComponent); } + + // merge sort implementation copied from java.utils.Arrays + private void mergeSort(T[] src, T[] dest, + int low, int high, int off, + Comparator c) { + int length = high - low; + + // Insertion sort on smallest arrays + if (length < 7) { + for (int i=low; ilow && c.compare(dest[j-1], dest[j])>0; j--) { + T t = dest[j]; + dest[j] = dest[j-1]; + dest[j-1] = t; + } + return; + } + + // Recursively sort halves of dest into src + int destLow = low; + int destHigh = high; + low += off; + high += off; + int mid = (low + high) >>> 1; + mergeSort(dest, src, low, mid, -off, c); + mergeSort(dest, src, mid, high, -off, c); + + // If list is already sorted, just copy from src to dest. This is an + // optimization that results in faster sorts for nearly ordered lists. + if (c.compare(src[mid-1], src[mid]) <= 0) { + System.arraycopy(src, low, dest, destLow, length); + return; + } + + // Merge sorted halves (now in src) into dest + for(int i = destLow, p = low, q = mid; i < destHigh; i++) { + if (q >= high || p < mid && c.compare(src[p], src[q]) <= 0) + dest[i] = src[p++]; + else + dest[i] = src[q++]; + } + } } // Create our own subclass and change accept to public so that we can call diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java index 8dc00a15e6f..445483a1073 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.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 @@ -1603,13 +1603,18 @@ public class BasicSliderUI extends SliderUI{ blockIncrement = 1; } + int tickSpacing = getTickSpacing(); if (slider.getSnapToTicks()) { - int tickSpacing = getTickSpacing(); if (blockIncrement < tickSpacing) { blockIncrement = tickSpacing; } } + else { + if (tickSpacing > 0) { + blockIncrement = tickSpacing; + } + } int delta = blockIncrement * ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL); slider.setValue(slider.getValue() + delta); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java index 379bcd9a10a..07ee542ac16 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java @@ -391,21 +391,8 @@ public class SynthButtonUI extends BasicButtonUI implements } private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) { - ButtonModel model = b.getModel(); - Icon icon = null; - if (model.isSelected()) { - icon = getIcon(b, b.getRolloverSelectedIcon(), null, - SynthConstants.MOUSE_OVER | SynthConstants.SELECTED); - if (icon == null) { - icon = getIcon(b, b.getSelectedIcon(), null, - SynthConstants.SELECTED); - } - } - if (icon == null) { - icon = getIcon(b, b.getRolloverIcon(), defaultIcon, - SynthConstants.MOUSE_OVER); - } - return icon; + return getSpecificIcon(b, b.getRolloverSelectedIcon(), b.getRolloverIcon(), + defaultIcon, SynthConstants.MOUSE_OVER); } private Icon getPressedIcon(AbstractButton b, Icon defaultIcon) { @@ -414,21 +401,44 @@ public class SynthButtonUI extends BasicButtonUI implements } private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) { - ButtonModel model = b.getModel(); + return getSpecificIcon(b, b.getDisabledSelectedIcon(), b.getDisabledIcon(), + defaultIcon, SynthConstants.DISABLED); + } + + private Icon getSpecificIcon(AbstractButton b, Icon specificSelectedIcon, + Icon specificIcon, Icon defaultIcon, + int state) { + boolean selected = b.getModel().isSelected(); Icon icon = null; - if (model.isSelected()) { - icon = getIcon(b, b.getDisabledSelectedIcon(), null, - SynthConstants.DISABLED | SynthConstants.SELECTED); + + if (selected) { + icon = specificSelectedIcon; if (icon == null) { - icon = getIcon(b, b.getSelectedIcon(), null, - SynthConstants.SELECTED); + icon = b.getSelectedIcon(); } } + if (icon == null) { - icon = getIcon(b, b.getDisabledIcon(), defaultIcon, - SynthConstants.DISABLED); + icon = specificIcon; } - return icon; + + if (icon != null) { + return icon; + } + + if (defaultIcon == null || defaultIcon instanceof UIResource) { + if (selected) { + icon = getSynthIcon(b, state | SynthConstants.SELECTED); + if (icon == null) { + icon = getSynthIcon(b, SynthConstants.SELECTED); + } + } + if (icon == null) { + icon = getSynthIcon(b, state); + } + } + + return icon != null ? icon : defaultIcon; } /** 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/font/ExtendedTextSourceLabel.java b/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java index 54c5382129c..67aee9e18db 100644 --- a/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java +++ b/jdk/src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java @@ -550,13 +550,16 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La return charinfo; } + private static final boolean DEBUG = FontUtilities.debugFonts(); /* * This takes the glyph info record obtained from the glyph vector and converts it into a similar record * adjusted to represent character data instead. For economy we don't use glyph info records in this processing. * * Here are some constraints: * - there can be more glyphs than characters (glyph insertion, perhaps based on normalization, has taken place) -* - there can not be fewer glyphs than characters (0xffff glyphs are inserted for characters ligaturized away) +* - there can be fewer glyphs than characters +* Some layout engines may insert 0xffff glyphs for characters ligaturized away, but +* not all do, and it cannot be relied upon. * - each glyph maps to a single character, when multiple glyphs exist for a character they all map to it, but * no two characters map to the same glyph * - multiple glyphs mapping to the same character need not be in sequence (thai, tamil have split characters) @@ -578,7 +581,8 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La * * The algorithm works in the following way: * 1) we scan the glyphs ltr or rtl based on the bidi run direction -* 2) we can work in place, since we always consume a glyph for each char we write +* 2) Since the may be fewer glyphs than chars we cannot work in place. +* A new array is allocated for output. * a) if the line is ltr, we start writing at position 0 until we finish, there may be leftver space * b) if the line is rtl and 1-1, we start writing at position numChars/glyphs - 1 until we finish at 0 * c) otherwise if we don't finish at 0, we have to copy the data down @@ -594,7 +598,7 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La * iii) the x advance is the distance to the maximum x + adv of all glyphs whose advance is not zero * iv) the y advance is the baseline * v) vis x,y,w,h tightly encloses the vis x,y,w,h of all the glyphs with nonzero w and h -* 4) we can make some simple optimizations if we know some things: +* 4) In the future, we can make some simple optimizations to avoid copying if we know some things: * a) if the mapping is 1-1, unidirectional, and there are no zero-adv glyphs, we just return the glyphinfo * b) if the mapping is 1-1, unidirectional, we just adjust the remaining glyphs to originate at right/left of the base * c) if the mapping is 1-1, we compute the base position and advance as we go, then go back to adjust the remaining glyphs @@ -625,23 +629,20 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La System.out.println(source); } - /* - if ((gv.getDescriptionFlags() & 0x7) == 0) { - return glyphinfo; - } - */ - int numGlyphs = gv.getNumGlyphs(); if (numGlyphs == 0) { return glyphinfo; } int[] indices = gv.getGlyphCharIndices(0, numGlyphs, null); + float[] charInfo = new float[source.getLength() * numvals]; - boolean DEBUG = false; if (DEBUG) { System.err.println("number of glyphs: " + numGlyphs); + System.err.println("glyphinfo.len: " + glyphinfo.length); + System.err.println("indices.len: " + indices.length); for (int i = 0; i < numGlyphs; ++i) { System.err.println("g: " + i + + " v: " + gv.getGlyphCode(i) + ", x: " + glyphinfo[i*numvals+posx] + ", a: " + glyphinfo[i*numvals+advx] + ", n: " + indices[i]); @@ -650,22 +651,19 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La int minIndex = indices[0]; // smallest index seen this cluster int maxIndex = minIndex; // largest index seen this cluster - int nextMin = 0; // expected smallest index for this cluster int cp = 0; // character position - int cx = 0; // character index (logical) + int cc = 0; int gp = 0; // glyph position int gx = 0; // glyph index (visual) int gxlimit = numGlyphs; // limit of gx, when we reach this we're done int pdelta = numvals; // delta for incrementing positions int xdelta = 1; // delta for incrementing indices - boolean ltr = (source.getLayoutFlags() & 0x1) == 0; - if (!ltr) { + boolean rtl = (source.getLayoutFlags() & 0x1) == 1; + if (rtl) { minIndex = indices[numGlyphs - 1]; maxIndex = minIndex; - nextMin = 0; // still logical - cp = glyphinfo.length - numvals; - cx = 0; // still logical + cp = charInfo.length - numvals; gp = glyphinfo.length - numvals; gx = numGlyphs - 1; gxlimit = -1; @@ -693,47 +691,36 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La float cposl = 0, cposr = 0, cvisl = 0, cvist = 0, cvisr = 0, cvisb = 0; float baseline = 0; - // record if we have to copy data even when no cluster - boolean mustCopy = false; - while (gx != gxlimit) { // start of new cluster - boolean haveCopy = false; int clusterExtraGlyphs = 0; minIndex = indices[gx]; maxIndex = minIndex; + cposl = glyphinfo[gp + posx]; + cposr = cposl + glyphinfo[gp + advx]; + cvisl = glyphinfo[gp + visx]; + cvist = glyphinfo[gp + visy]; + cvisr = cvisl + glyphinfo[gp + visw]; + cvisb = cvist + glyphinfo[gp + vish]; + // advance to next glyph gx += xdelta; gp += pdelta; - /* - while (gx != gxlimit && (glyphinfo[gp + advx] == 0 || - minIndex != nextMin || indices[gx] <= maxIndex)) { - */ while (gx != gxlimit && ((glyphinfo[gp + advx] == 0) || - (minIndex != nextMin) || (indices[gx] <= maxIndex) || (maxIndex - minIndex > clusterExtraGlyphs))) { - // initialize base data first time through, using base glyph - if (!haveCopy) { - int gps = gp - pdelta; - cposl = glyphinfo[gps + posx]; - cposr = cposl + glyphinfo[gps + advx]; - cvisl = glyphinfo[gps + visx]; - cvist = glyphinfo[gps + visy]; - cvisr = cvisl + glyphinfo[gps + visw]; - cvisb = cvist + glyphinfo[gps + vish]; - - haveCopy = true; + ++clusterExtraGlyphs; // have an extra glyph in this cluster + if (DEBUG) { + System.err.println("gp=" +gp +" adv=" + glyphinfo[gp + advx] + + " gx="+ gx+ " i[gx]="+indices[gx] + + " clusterExtraGlyphs="+clusterExtraGlyphs); } - // have an extra glyph in this cluster - ++clusterExtraGlyphs; - // adjust advance only if new glyph has non-zero advance float radvx = glyphinfo[gp + advx]; if (radvx != 0) { @@ -764,110 +751,90 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La // done with cluster, gx and gp are set for next glyph if (DEBUG) { - System.out.println("minIndex = " + minIndex + ", maxIndex = " + maxIndex); + System.err.println("minIndex = " + minIndex + ", maxIndex = " + maxIndex); } - nextMin = maxIndex + 1; + // save adjustments to the base character and do common adjustments. + charInfo[cp + posx] = cposl; + charInfo[cp + posy] = baseline; + charInfo[cp + advx] = cposr - cposl; + charInfo[cp + advy] = 0; + charInfo[cp + visx] = cvisl; + charInfo[cp + visy] = cvist; + charInfo[cp + visw] = cvisr - cvisl; + charInfo[cp + vish] = cvisb - cvist; + cc++; - // do common character adjustments - glyphinfo[cp + posy] = baseline; - glyphinfo[cp + advy] = 0; - - if (haveCopy) { - // save adjustments to the base character - glyphinfo[cp + posx] = cposl; - glyphinfo[cp + advx] = cposr - cposl; - glyphinfo[cp + visx] = cvisl; - glyphinfo[cp + visy] = cvist; - glyphinfo[cp + visw] = cvisr - cvisl; - glyphinfo[cp + vish] = cvisb - cvist; - - // compare number of chars read with number of glyphs read. - // if more glyphs than chars, set mustCopy to true, as we'll always have - // to copy the data from here on out. - if (maxIndex - minIndex < clusterExtraGlyphs) { - mustCopy = true; - } - - // Fix the characters that follow the base character. - // New values are all the same. Note we fix the number of characters - // we saw, not the number of glyphs we saw. - if (minIndex < maxIndex) { - if (!ltr) { - // if rtl, characters to left of base, else to right. reuse cposr. - cposr = cposl; - } - cvisr -= cvisl; // reuse, convert to deltas. - cvisb -= cvist; - - int iMinIndex = minIndex, icp = cp / 8; - - while (minIndex < maxIndex) { - ++minIndex; - cx += xdelta; - cp += pdelta; - - if (cp < 0 || cp >= glyphinfo.length) { - if (DEBUG) System.out.println("minIndex = " + iMinIndex + ", maxIndex = " + maxIndex + ", cp = " + icp); - } - - glyphinfo[cp + posx] = cposr; - glyphinfo[cp + posy] = baseline; - glyphinfo[cp + advx] = 0; - glyphinfo[cp + advy] = 0; - glyphinfo[cp + visx] = cvisl; - glyphinfo[cp + visy] = cvist; - glyphinfo[cp + visw] = cvisr; - glyphinfo[cp + vish] = cvisb; - } - } - - // no longer using this copy - haveCopy = false; - } else if (mustCopy) { - // out of synch, so we have to copy all the time now - int gpr = gp - pdelta; - - glyphinfo[cp + posx] = glyphinfo[gpr + posx]; - glyphinfo[cp + advx] = glyphinfo[gpr + advx]; - glyphinfo[cp + visx] = glyphinfo[gpr + visx]; - glyphinfo[cp + visy] = glyphinfo[gpr + visy]; - glyphinfo[cp + visw] = glyphinfo[gpr + visw]; - glyphinfo[cp + vish] = glyphinfo[gpr + vish]; + /* We may have consumed multiple glyphs for this char position. + * Map those extra consumed glyphs to char positions that would follow + * up to the index prior to that which begins the next cluster. + * If we have reached the last glyph (reached gxlimit) then we need to + * map remaining unmapped chars to the same location as the last one. + */ + int tgt; + if (gx == gxlimit) { + tgt = charInfo.length / numvals; + } else { + tgt = indices[gx]-1; } - // else glyphinfo is already at the correct character position, and is unchanged, so just leave it + if (DEBUG) { + System.err.println("gx=" + gx + " gxlimit=" + gxlimit + + " charInfo.len=" + charInfo.length + + " tgt=" + tgt + " cc=" + cc + " cp=" + cp); + } + while (cc < tgt) { + if (rtl) { + // if rtl, characters to left of base, else to right. reuse cposr. + cposr = cposl; + } + cvisr -= cvisl; // reuse, convert to deltas. + cvisb -= cvist; - // reset for new cluster - cp += pdelta; - cx += xdelta; - } + cp += pdelta; - if (mustCopy && !ltr) { - // data written to wrong end of array, need to shift down + if (cp < 0 || cp >= charInfo.length) { + if (DEBUG) { + System.err.println("Error : cp=" + cp + + " charInfo.length=" + charInfo.length); + } + break; + } - cp -= pdelta; // undo last increment, get start of valid character data in array - System.arraycopy(glyphinfo, cp, glyphinfo, 0, glyphinfo.length - cp); + if (DEBUG) { + System.err.println("Insert charIndex " + cc + " at pos="+cp); + } + charInfo[cp + posx] = cposr; + charInfo[cp + posy] = baseline; + charInfo[cp + advx] = 0; + charInfo[cp + advy] = 0; + charInfo[cp + visx] = cvisl; + charInfo[cp + visy] = cvist; + charInfo[cp + visw] = cvisr; + charInfo[cp + vish] = cvisb; + cc++; + } + cp += pdelta; // reset for new cluster } if (DEBUG) { - char[] chars = source.getChars(); - int start = source.getStart(); - int length = source.getLength(); - System.out.println("char info for " + length + " characters"); - for(int i = 0; i < length * numvals;) { - System.out.println(" ch: " + Integer.toHexString(chars[start + v2l(i / numvals)]) + - " x: " + glyphinfo[i++] + - " y: " + glyphinfo[i++] + - " xa: " + glyphinfo[i++] + - " ya: " + glyphinfo[i++] + - " l: " + glyphinfo[i++] + - " t: " + glyphinfo[i++] + - " w: " + glyphinfo[i++] + - " h: " + glyphinfo[i++]); + char[] chars = source.getChars(); + int start = source.getStart(); + int length = source.getLength(); + System.err.println("char info for " + length + " characters"); + + for (int i = 0; i < length * numvals;) { + System.err.println(" ch: " + Integer.toHexString(chars[start + v2l(i / numvals)]) + + " x: " + charInfo[i++] + + " y: " + charInfo[i++] + + " xa: " + charInfo[i++] + + " ya: " + charInfo[i++] + + " l: " + charInfo[i++] + + " t: " + charInfo[i++] + + " w: " + charInfo[i++] + + " h: " + charInfo[i++]); } } - - return glyphinfo; + return charInfo; } /** diff --git a/jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java b/jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java index 3b29183e2f4..f3f50391754 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java +++ b/jdk/src/java.desktop/share/classes/sun/print/DialogOwner.java @@ -25,9 +25,11 @@ package sun.print; +import java.awt.Dialog; import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttribute; import java.awt.Frame; +import java.awt.Window; /** * Class DialogOwner is a printing attribute class that identifies @@ -42,7 +44,7 @@ import java.awt.Frame; public final class DialogOwner implements PrintRequestAttribute { - private Frame dlgOwner; + private Window dlgOwner; /** * Construct a new dialog owner attribute with the given frame. @@ -53,11 +55,19 @@ public final class DialogOwner dlgOwner = frame; } + /** + * Construct a new dialog owner attribute with the given dialog. + * + * @param dialog the dialog that owns the print dialog + */ + public DialogOwner(Dialog dialog) { + dlgOwner = dialog; + } /** * Returns the string table for class DialogOwner. */ - public Frame getOwner() { + public Window getOwner() { return dlgOwner; } 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/RasterPrinterJob.java b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index e2813a59544..0a5e99c0bd5 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -30,7 +30,6 @@ import java.io.FilePermission; import java.awt.Color; import java.awt.Dialog; import java.awt.Frame; -import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; @@ -39,7 +38,6 @@ import java.awt.KeyboardFocusManager; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; -import java.awt.geom.Area; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -55,7 +53,6 @@ import java.awt.Window; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import sun.awt.image.ByteInterleavedRaster; @@ -74,7 +71,6 @@ import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.ResolutionSyntax; import javax.print.attribute.Size2DSyntax; -import javax.print.attribute.standard.Chromaticity; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; @@ -96,11 +92,6 @@ import javax.print.attribute.standard.RequestingUserName; import javax.print.attribute.standard.SheetCollate; import javax.print.attribute.standard.Sides; -import sun.print.PageableDoc; -import sun.print.ServiceDialog; -import sun.print.SunPrinterJobService; -import sun.print.SunPageSelection; - /** * A class which rasterizes a printer job. * @@ -836,9 +827,16 @@ public abstract class RasterPrinterJob extends PrinterJob { Rectangle gcBounds = gc.getBounds(); int x = gcBounds.x+50; int y = gcBounds.y+50; - ServiceDialog pageDialog = new ServiceDialog(gc, x, y, service, - DocFlavor.SERVICE_FORMATTED.PAGEABLE, - attributes, (Frame)null); + ServiceDialog pageDialog; + if (w instanceof Frame) { + pageDialog = new ServiceDialog(gc, x, y, service, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + attributes,(Frame)w); + } else { + pageDialog = new ServiceDialog(gc, x, y, service, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + attributes, (Dialog)w); + } Rectangle dlgBounds = pageDialog.getBounds(); // if portion of dialog is not within the gc boundary @@ -944,6 +942,14 @@ public abstract class RasterPrinterJob extends PrinterJob { Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); if (w != null) { grCfg = w.getGraphicsConfiguration(); + /* Add DialogOwner attribute to set the owner of this print dialog + * only if it is not set already + * (it might be set in java.awt.PrintJob.printDialog) + */ + if (attributes.get(DialogOwner.class) == null) { + attributes.add(w instanceof Frame ? new DialogOwner((Frame)w) : + new DialogOwner((Dialog)w)); + } } else { grCfg = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); @@ -1001,6 +1007,10 @@ public abstract class RasterPrinterJob extends PrinterJob { // temporarily add an attribute pointing back to this job. PrinterJobWrapper jobWrapper = new PrinterJobWrapper(this); attributes.add(jobWrapper); + PageRanges pgRng = (PageRanges)attributes.get(PageRanges.class); + if (pgRng == null && mDocument.getNumberOfPages() > 1) { + attributes.add(new PageRanges(1, mDocument.getNumberOfPages())); + } try { newService = ServiceUI.printDialog(gc, x, y, @@ -1014,6 +1024,7 @@ public abstract class RasterPrinterJob extends PrinterJob { attributes); } attributes.remove(PrinterJobWrapper.class); + attributes.remove(DialogOwner.class); if (newService == null) { return false; 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/CachedPainter.java b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java index 818e20dbdd3..92c0e3bad8e 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/CachedPainter.java @@ -107,13 +107,16 @@ public abstract class CachedPainter { ImageCache cache = getCache(key); Image image = cache.getImage(key, config, w, h, args); int attempts = 0; + VolatileImage volatileImage = (image instanceof VolatileImage) + ? (VolatileImage) image + : null; do { boolean draw = false; - if (image instanceof VolatileImage) { + if (volatileImage != null) { // See if we need to recreate the image - switch (((VolatileImage)image).validate(config)) { + switch (volatileImage.validate(config)) { case VolatileImage.IMAGE_INCOMPATIBLE: - ((VolatileImage)image).flush(); + volatileImage.flush(); image = null; break; case VolatileImage.IMAGE_RESTORED: @@ -126,11 +129,14 @@ public abstract class CachedPainter { image = createImage(c, w, h, config, args); cache.setImage(key, config, w, h, args, image); draw = true; + volatileImage = (image instanceof VolatileImage) + ? (VolatileImage) image + : null; } if (draw) { // Render to the Image Graphics2D g2 = (Graphics2D) image.getGraphics(); - if (w != baseWidth || h != baseHeight) { + if (volatileImage == null && (w != baseWidth || h != baseHeight)) { g2.scale((double) w / baseWidth, (double) h / baseHeight); } paintToImage(c, image, g2, baseWidth, baseHeight, args); @@ -140,8 +146,8 @@ public abstract class CachedPainter { // If we did this 3 times and the contents are still lost // assume we're painting to a VolatileImage that is bogus and // give up. Presumably we'll be called again to paint. - } while ((image instanceof VolatileImage) && - ((VolatileImage)image).contentsLost() && ++attempts < 3); + } while ((volatileImage != null) && + volatileImage.contentsLost() && ++attempts < 3); return image; } 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..95a92f221ad 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -40,6 +40,7 @@ static jfieldID gvdFlagsFID = 0; static jfieldID gvdGlyphsFID = 0; static jfieldID gvdPositionsFID = 0; static jfieldID gvdIndicesFID = 0; +static jmethodID gvdGrowMID = 0; static int jniInited = 0; static void getFloat(JNIEnv* env, jobject pt, jfloat *x, jfloat *y) { @@ -63,72 +64,88 @@ static int init_JNI_IDs(JNIEnv *env) { CHECK_NULL_RETURN(gvdGlyphsFID = (*env)->GetFieldID(env, gvdClass, "_glyphs", "[I"), 0); CHECK_NULL_RETURN(gvdPositionsFID = (*env)->GetFieldID(env, gvdClass, "_positions", "[F"), 0); CHECK_NULL_RETURN(gvdIndicesFID = (*env)->GetFieldID(env, gvdClass, "_indices", "[I"), 0); + CHECK_NULL_RETURN(gvdGrowMID = (*env)->GetMethodID(env, gvdClass, "grow", "()V"), 0); jniInited = 1; return jniInited; } // gmask is the composite font slot mask // baseindex is to be added to the character (code point) index. -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) { +jboolean storeGVData(JNIEnv* env, + jobject gvdata, jint slot, + jint baseIndex, int offset, jobject startPt, + int charCount, int glyphCount, hb_glyph_info_t *glyphInfo, + hb_glyph_position_t *glyphPos, float devScale) { - int i; + int i, needToGrow; float x=0, y=0; - float startX, startY; - float scale = 1.0f/64.0f; + float startX, startY, advX, advY; + float scale = 1.0f / HBFloatToFixedScale / devScale; unsigned int* glyphs; float* positions; - int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; + int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv, maxStore; unsigned int* indices; jarray glyphArray, posArray, inxArray; if (!init_JNI_IDs(env)) { - return 0; + return JNI_FALSE; } initialCount = (*env)->GetIntField(env, gvdata, gvdCountFID); - glyphArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID); - posArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID); - - if (glyphArray == NULL || posArray == NULL) - { - JNU_ThrowArrayIndexOutOfBoundsException(env, ""); - return 0; - } - - // The Java code catches the IIOBE and expands the storage - // and re-invokes layout. I suppose this is expected to be rare - // because at least in a single threaded case there should be - // re-use of the same container, but it is a little wasteful/distateful. - glyphArrayLen = (*env)->GetArrayLength(env, glyphArray); - posArrayLen = (*env)->GetArrayLength(env, posArray); - maxGlyphs = glyphCount + initialCount; - if ((maxGlyphs > glyphArrayLen) || - (maxGlyphs * 2 + 2 > posArrayLen)) - { - JNU_ThrowArrayIndexOutOfBoundsException(env, ""); - return 0; - } + do { + glyphArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdGlyphsFID); + posArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdPositionsFID); + inxArray = (jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID); + if (glyphArray == NULL || posArray == NULL || inxArray == NULL) { + JNU_ThrowArrayIndexOutOfBoundsException(env, ""); + return JNI_FALSE; + } + glyphArrayLen = (*env)->GetArrayLength(env, glyphArray); + posArrayLen = (*env)->GetArrayLength(env, posArray); + maxGlyphs = (charCount > glyphCount) ? charCount : glyphCount; + maxStore = maxGlyphs + initialCount; + needToGrow = (maxStore > glyphArrayLen) || + (maxStore * 2 + 2 > posArrayLen); + if (needToGrow) { + (*env)->CallVoidMethod(env, gvdata, gvdGrowMID); + if ((*env)->ExceptionCheck(env)) { + return JNI_FALSE; + } + } + } while (needToGrow); getFloat(env, startPt, &startX, &startY); glyphs = (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, glyphArray, NULL); + if (glyphs == NULL) { + return JNI_FALSE; + } positions = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, posArray, NULL); + if (positions == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); + return JNI_FALSE; + } + indices = + (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL); + if (indices == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); + (*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0); + return JNI_FALSE; + } + for (i = 0; i < glyphCount; i++) { int storei = i + initialCount; - int index = glyphInfo[i].codepoint | slot; - if (iReleasePrimitiveArrayCritical(env, glyphArray, glyphs, 0); (*env)->ReleasePrimitiveArrayCritical(env, posArray, positions, 0); - putFloat(env, startPt,positions[(storeadv*2)],positions[(storeadv*2)+1] ); - inxArray = - (jarray)(*env)->GetObjectField(env, gvdata, gvdIndicesFID); - indices = - (unsigned int*)(*env)->GetPrimitiveArrayCritical(env, inxArray, NULL); - for (i = 0; i < glyphCount; i++) { - int cluster = glyphInfo[i].cluster; - if (direction == HB_DIRECTION_LTR) { - // I need to understand what hb does when processing a substring - // I expected the cluster index to be from the start of the text - // to process. - // Instead it appears to be from the start of the whole thing. - indices[i+initialCount] = cluster; - } else { - indices[i+initialCount] = baseIndex + glyphCount -1 -i; - } - } (*env)->ReleasePrimitiveArrayCritical(env, inxArray, indices, 0); - (*env)->SetIntField(env, gvdata, gvdCountFID, initialCount+glyphCount); - return initialCount+glyphCount; + putFloat(env, startPt, advX, advY); + (*env)->SetIntField(env, gvdata, gvdCountFID, storeadv); + + return JNI_TRUE; } static float euclidianDistance(float a, float b) @@ -216,12 +220,18 @@ 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; } -#define TYPO_RTL 0x80000000 +#define TYPO_KERN 0x00000001 +#define TYPO_LIGA 0x00000002 +#define TYPO_RTL 0x80000000 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape (JNIEnv *env, jclass cls, @@ -250,10 +260,11 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape hb_glyph_info_t *glyphInfo; hb_glyph_position_t *glyphPos; hb_direction_t direction = HB_DIRECTION_LTR; - hb_feature_t *features = NULL; + hb_feature_t *features = NULL; int featureCount = 0; - - int i; + char* kern = (flags & TYPO_KERN) ? "kern" : "-kern"; + char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga"; + jboolean ret; unsigned int buflen; JDKFontInfo *jdkFontInfo = @@ -276,6 +287,8 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape direction = HB_DIRECTION_RTL; } hb_buffer_set_direction(buffer, direction); + hb_buffer_set_cluster_level(buffer, + HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS); chars = (*env)->GetCharArrayElements(env, text, NULL); if ((*env)->ExceptionCheck(env)) { @@ -288,35 +301,26 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape hb_buffer_add_utf16(buffer, chars, len, offset, limit-offset); + features = calloc(2, sizeof(hb_feature_t)); + if (features) { + hb_feature_from_string(kern, -1, &features[featureCount++]); + hb_feature_from_string(liga, -1, &features[featureCount++]); + } + hb_shape_full(hbfont, buffer, features, featureCount, 0); glyphCount = hb_buffer_get_length(buffer); glyphInfo = hb_buffer_get_glyph_infos(buffer, 0); glyphPos = hb_buffer_get_glyph_positions(buffer, &buflen); - for (i = 0; i < glyphCount; i++) { - int index = glyphInfo[i].codepoint; - int xadv = (glyphPos[i].x_advance); - int yadv = (glyphPos[i].y_advance); - } - // On "input" HB assigns a cluster index to each character in UTF-16. - // On output where a sequence of characters have been mapped to - // a glyph they are all mapped to the cluster index of the first character. - // The next cluster index will be that of the first character in the - // next cluster. So cluster indexes may 'skip' on output. - // This can also happen if there are supplementary code-points - // such that two UTF-16 characters are needed to make one codepoint. - // In RTL text you need to count down. - // So the following code tries to build the reverse map as expected - // by calling code. - storeGVData(env, gvdata, slot, baseIndex, startPt, - glyphCount, glyphInfo, glyphPos, direction); + ret = storeGVData(env, gvdata, slot, baseIndex, offset, startPt, + limit - offset, glyphCount, glyphInfo, glyphPos, + jdkFontInfo->devScale); hb_buffer_destroy (buffer); hb_font_destroy(hbfont); free((void*)jdkFontInfo); if (features != NULL) free(features); (*env)->ReleaseCharArrayElements(env, text, chars, JNI_ABORT); - - return JNI_TRUE; + return ret; } 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..2e41293a08f 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 @@ -55,10 +55,6 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, return (*glyph != 0); } -// This is also define in freetypescaler.c and similar macros are -// in fontscalerdefs.h. Consider tidying this up. -#define FloatToF26Dot6(x) ((unsigned int) ((x)*64)) - static hb_position_t hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, void *font_data, @@ -81,9 +77,10 @@ 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 ? + return HBFloatToFixed(fadv); } static hb_position_t @@ -110,7 +107,7 @@ hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, fadv = env->GetFloatField(pt, sunFontIDs.yFID); env->DeleteLocalRef(pt); - return FloatToF26Dot6(fadv); // should this round ? + return HBFloatToFixed(fadv); } @@ -204,8 +201,8 @@ hb_jdk_get_glyph_contour_point (hb_font_t *font HB_UNUSED, *x = 0; *y = 0; return true; } - *x = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.xFID)); - *y = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.yFID)); + *x = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID)); + *y = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID)); env->DeleteLocalRef(pt); return true; @@ -324,8 +321,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)); + HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale), + HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } @@ -342,8 +339,8 @@ static hb_font_t* _hb_jdk_ct_font_create(JDKFontInfo *jdkFontInfo) { hb_face_destroy(face); hb_font_set_scale(font, - FloatToF26Dot6(jdkFontInfo->ptSize), - FloatToF26Dot6(jdkFontInfo->ptSize)); + HBFloatToFixed(jdkFontInfo->ptSize), + HBFloatToFixed(jdkFontInfo->ptSize)); return font; } #endif 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..b62c8b1553b 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h @@ -43,10 +43,15 @@ 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; +// Use 16.16 for better precision than 26.6 +#define HBFloatToFixedScale ((float)(1 << 16)) +#define HBFloatToFixed(f) ((unsigned int)((f) * HBFloatToFixedScale)) + /* * Note: * diff --git a/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c b/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c index c872c523b62..b54ad836f69 100644 --- a/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c +++ b/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c @@ -2161,6 +2161,25 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage return data->abortFlag; } +JNIEXPORT void JNICALL +Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_clearNativeReadAbortFlag + (JNIEnv *env, + jobject this, + jlong ptr) { + + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); + + if (data == NULL) { + JNU_ThrowByName(env, + "java/lang/IllegalStateException", + "Attempting to use reader after dispose()"); + return; + } + + data->abortFlag = JNI_FALSE; + +} + JNIEXPORT void JNICALL Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead (JNIEnv *env, 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/XToolkit.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java index be362ae0781..77514760937 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java @@ -1570,6 +1570,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable { Integer.valueOf(getMultiClickTime())); desktopProperties.put("awt.mouse.numButtons", Integer.valueOf(getNumberOfButtons())); + if(SunGraphicsEnvironment.isUIScaleEnabled()) { + addPropertyChangeListener("gnome.Xft/DPI", evt -> + localEnv.displayChanged()); + } } } 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/awt/X11GraphicsDevice.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index 0f81f4e911f..346622e9e09 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -63,7 +63,7 @@ public final class X11GraphicsDevice extends GraphicsDevice private SunDisplayChanger topLevels = new SunDisplayChanger(); private DisplayMode origDisplayMode; private boolean shutdownHookRegistered; - private final int scale; + private int scale; public X11GraphicsDevice(int screennum) { this.screen = screennum; @@ -488,6 +488,7 @@ public final class X11GraphicsDevice extends GraphicsDevice * X11GraphicsEnvironment when the display mode has been changed. */ public synchronized void displayChanged() { + scale = initScaleFactor(); // On X11 the visuals do not change, and therefore we don't need // to reset the defaultConfig, config, doubleBufferVisuals, // neither do we need to reset the native data. 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/common/awt/systemscale/systemScale.c b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c index c8a5810370f..f7bea414e63 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c +++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c @@ -148,7 +148,7 @@ static double getDesktopScale(char *output_name) { void *scale = fp_g_variant_get_child_value(entry, 1); if (screen && scale) { char *name = fp_g_variant_get_string(screen, NULL); - if (name && strcmp(name, output_name)) { + if (name && !strcmp(name, output_name)) { result = fp_g_variant_get_int32(scale) / 8.; } fp_g_variant_unref(screen); 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/libawt_xawt/awt/awt_GraphicsEnv.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index 8339a195828..c1895cd29d7 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -2181,7 +2181,8 @@ static char *get_output_screen_name(JNIEnv *env, int screen) { JNIEXPORT jdouble JNICALL Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor (JNIEnv *env, jobject this, jint screen) { - char *name = get_output_screen_name(env, screen); + // in case of Xinerama individual screen scales are not supported + char *name = get_output_screen_name(env, usingXinerama ? 0 : screen); double scale = getNativeScaleFactor(name); if (name) { free(name); 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/classes/sun/awt/windows/TranslucentWindowPainter.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java index e57ce205a74..05043bd7525 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, 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 @@ -303,10 +303,10 @@ abstract class TranslucentWindowPainter { if (bb instanceof DestSurfaceProvider) { Surface s = ((DestSurfaceProvider)bb).getDestSurface(); if (s instanceof AccelSurface) { - final int w = bb.getWidth(null); - final int h = bb.getHeight(null); final boolean arr[] = { false }; final AccelSurface as = (AccelSurface)s; + final int w = as.getBounds().width; + final int h = as.getBounds().height; RenderQueue rq = as.getContext().getRenderQueue(); rq.lock(); try { diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java index 457393aeb5d..cfef03b9286 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java @@ -478,9 +478,12 @@ public final class WPrinterJob extends RasterPrinterJob } DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); - Frame ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null; + Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null; + + WPrintDialog dialog = (owner instanceof Frame) ? + new WPrintDialog((Frame)owner, this) : + new WPrintDialog((Dialog)owner, this); - WPrintDialog dialog = new WPrintDialog(ownerFrame, this); dialog.setRetVal(false); dialog.setVisible(true); boolean prv = dialog.getRetVal(); @@ -498,8 +501,9 @@ public final class WPrinterJob extends RasterPrinterJob title = rb.getString("dialog.printtofile"); } catch (MissingResourceException e) { } - FileDialog fileDialog = new FileDialog(ownerFrame, title, - FileDialog.SAVE); + FileDialog fileDialog = (owner instanceof Frame) ? + new FileDialog((Frame)owner, title, FileDialog.SAVE) : + new FileDialog((Dialog)owner, title, FileDialog.SAVE); URI destURI = dest.getURI(); // Old code destURI.getPath() would return null for "file:out.prn" @@ -531,10 +535,17 @@ public final class WPrinterJob extends RasterPrinterJob ((pFile != null) && (!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) { - (new PrintToFileErrorDialog(ownerFrame, + if (owner instanceof Frame) { + (new PrintToFileErrorDialog((Frame)owner, ServiceDialog.getMsg("dialog.owtitle"), ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, ServiceDialog.getMsg("button.ok"))).setVisible(true); + } else { + (new PrintToFileErrorDialog((Dialog)owner, + ServiceDialog.getMsg("dialog.owtitle"), + ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, + ServiceDialog.getMsg("button.ok"))).setVisible(true); + } fileDialog.setVisible(true); fileName = fileDialog.getFile(); diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp index b3d3e09ed65..c48ae8fbe31 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp @@ -753,10 +753,15 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPosition } void rescale(SIZE *size) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + static int dpiX = -1; + static int dpiY = -1; + if (dpiX == -1 || dpiY == -1) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); + dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + ::ReleaseDC(hWnd, hDC); + } if (dpiX !=0 && dpiX != 96) { float invScaleX = 96.0f / dpiX; @@ -766,7 +771,6 @@ void rescale(SIZE *size) { float invScaleY = 96.0f / dpiY; size->cy = ROUND_TO_INT(size->cy * invScaleY); } - ::ReleaseDC(hWnd, hDC); } /* diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp index 497d35dc350..608138fb2eb 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp @@ -88,11 +88,16 @@ void AwtDesktopProperties::GetWindowsParameters() { } void getInvScale(float &invScaleX, float &invScaleY) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); - ::ReleaseDC(hWnd, hDC); + static int dpiX = -1; + static int dpiY = -1; + if (dpiX == -1 || dpiY == -1) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); + dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); + ::ReleaseDC(hWnd, hDC); + } + invScaleX = (dpiX == 0.0f) ? 1.0f : 96.0f / dpiX; invScaleY = (dpiY == 0.0f) ? 1.0f : 96.0f / dpiY; } 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/libawt/windows/awt_Taskbar.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp index 50c1ba85c2a..ebb07187322 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Taskbar.cpp @@ -108,7 +108,7 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_setProgressState JNIEXPORT void JNICALL Java_sun_awt_windows_WTaskbarPeer_flashWindow (JNIEnv *, jobject, jlong window) { - AwtWindow::FlashWindowEx((HWND) window, 3, 0, FLASHW_TIMERNOFG); + ::FlashWindow((HWND) window, TRUE); } /* 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.logging/share/classes/java/util/logging/Level.java b/jdk/src/java.logging/share/classes/java/util/logging/Level.java index fa0da4c1306..f7f7a4380be 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/Level.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/Level.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, 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 @@ -24,13 +24,22 @@ */ package java.util.logging; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; import java.lang.reflect.Module; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.ResourceBundle; +import java.util.function.Function; +import jdk.internal.loader.ClassLoaderValue; /** * The Level class defines a set of standard logging levels that @@ -177,6 +186,10 @@ public class Level implements java.io.Serializable { */ public static final Level ALL = new Level("ALL", Integer.MIN_VALUE, defaultBundle); + private static final Level[] standardLevels = { + OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL + }; + /** * Create a named Level with a given integer value. *

            @@ -267,7 +280,8 @@ public class Level implements java.io.Serializable { // or its defining class loader, if it's unnamed module, // of this Level instance that can be a custom Level subclass; Module module = this.getClass().getModule(); - ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, newLocale, module); + ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName, + newLocale, module); final String localizedName = rb.getString(name); final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName); @@ -350,12 +364,12 @@ public class Level implements java.io.Serializable { throw new NullPointerException(); } - KnownLevel level; + Optional level; // Look for a known Level with the given non-localized name. - level = KnownLevel.findByName(name); - if (level != null) { - return level.mirroredLevel; + level = KnownLevel.findByName(name, KnownLevel::mirrored); + if (level.isPresent()) { + return level.get(); } // Now, check if the given name is an integer. If so, @@ -363,21 +377,24 @@ public class Level implements java.io.Serializable { // if necessary create one. try { int x = Integer.parseInt(name); - level = KnownLevel.findByValue(x); - if (level == null) { + level = KnownLevel.findByValue(x, KnownLevel::mirrored); + if (!level.isPresent()) { // add new Level Level levelObject = new Level(name, x); - level = KnownLevel.findByValue(x); + // There's no need to use a reachability fence here because + // KnownLevel keeps a strong reference on the level when + // level.getClass() == Level.class. + return KnownLevel.findByValue(x, KnownLevel::mirrored).get(); } - return level.mirroredLevel; } catch (NumberFormatException ex) { // Not an integer. // Drop through. } - level = KnownLevel.findByLocalizedLevelName(name); - if (level != null) { - return level.mirroredLevel; + level = KnownLevel.findByLocalizedLevelName(name, + KnownLevel::mirrored); + if (level.isPresent()) { + return level.get(); } return null; @@ -408,15 +425,13 @@ public class Level implements java.io.Serializable { // Serialization magic to prevent "doppelgangers". // This is a performance optimization. private Object readResolve() { - KnownLevel o = KnownLevel.matches(this); - if (o != null) { - return o.levelObject; + Optional level = KnownLevel.matches(this); + if (level.isPresent()) { + return level.get(); } - // Woops. Whoever sent us this object knows // about a new log level. Add it to our list. - Level level = new Level(this.name, this.value, this.resourceBundleName); - return level; + return new Level(this.name, this.value, this.resourceBundleName); } /** @@ -450,12 +465,12 @@ public class Level implements java.io.Serializable { // Check that name is not null. name.length(); - KnownLevel level; + Optional level; // Look for a known Level with the given non-localized name. - level = KnownLevel.findByName(name); - if (level != null) { - return level.levelObject; + level = KnownLevel.findByName(name, KnownLevel::referent); + if (level.isPresent()) { + return level.get(); } // Now, check if the given name is an integer. If so, @@ -463,13 +478,16 @@ public class Level implements java.io.Serializable { // if necessary create one. try { int x = Integer.parseInt(name); - level = KnownLevel.findByValue(x); - if (level == null) { - // add new Level - Level levelObject = new Level(name, x); - level = KnownLevel.findByValue(x); + level = KnownLevel.findByValue(x, KnownLevel::referent); + if (level.isPresent()) { + return level.get(); } - return level.levelObject; + // add new Level. + Level levelObject = new Level(name, x); + // There's no need to use a reachability fence here because + // KnownLevel keeps a strong reference on the level when + // level.getClass() == Level.class. + return KnownLevel.findByValue(x, KnownLevel::referent).get(); } catch (NumberFormatException ex) { // Not an integer. // Drop through. @@ -478,9 +496,9 @@ public class Level implements java.io.Serializable { // Finally, look for a known level with the given localized name, // in the current default locale. // This is relatively expensive, but not excessively so. - level = KnownLevel.findByLocalizedLevelName(name); - if (level != null) { - return level.levelObject; + level = KnownLevel.findByLocalizedLevelName(name, KnownLevel::referent); + if (level .isPresent()) { + return level.get(); } // OK, we've tried everything and failed @@ -530,22 +548,67 @@ public class Level implements java.io.Serializable { // If Level.getName, Level.getLocalizedName, Level.getResourceBundleName methods // were final, the following KnownLevel implementation can be removed. // Future API change should take this into consideration. - static final class KnownLevel { + static final class KnownLevel extends WeakReference { private static Map> nameToLevels = new HashMap<>(); private static Map> intToLevels = new HashMap<>(); - final Level levelObject; // instance of Level class or Level subclass + private static final ReferenceQueue QUEUE = new ReferenceQueue<>(); + + // CUSTOM_LEVEL_CLV is used to register custom level instances with + // their defining class loader, so that they are garbage collected + // if and only if their class loader is no longer strongly + // referenced. + private static final ClassLoaderValue> CUSTOM_LEVEL_CLV = + new ClassLoaderValue<>(); + final Level mirroredLevel; // mirror of the custom Level KnownLevel(Level l) { - this.levelObject = l; + super(l, QUEUE); if (l.getClass() == Level.class) { this.mirroredLevel = l; } else { // this mirrored level object is hidden - this.mirroredLevel = new Level(l.name, l.value, l.resourceBundleName, false); + this.mirroredLevel = new Level(l.name, l.value, + l.resourceBundleName, false); } } + Optional mirrored() { + return Optional.of(mirroredLevel); + } + + Optional referent() { + return Optional.ofNullable(get()); + } + + private void remove() { + Optional.ofNullable(nameToLevels.get(mirroredLevel.name)) + .ifPresent((x) -> x.remove(this)); + Optional.ofNullable(intToLevels.get(mirroredLevel.value)) + .ifPresent((x) -> x.remove(this)); + } + + // Remove all stale KnownLevel instances + static synchronized void purge() { + Reference ref; + while ((ref = QUEUE.poll()) != null) { + if (ref instanceof KnownLevel) { + ((KnownLevel)ref).remove(); + } + } + } + + private static void registerWithClassLoader(Level customLevel) { + PrivilegedAction pa = + () -> customLevel.getClass().getClassLoader(); + PrivilegedAction pn = customLevel.getClass()::getName; + final String name = AccessController.doPrivileged(pn); + final ClassLoader cl = AccessController.doPrivileged(pa); + CUSTOM_LEVEL_CLV.computeIfAbsent(cl, (c, v) -> new ArrayList<>()) + .add(customLevel); + } + static synchronized void add(Level l) { + purge(); // the mirroredLevel object is always added to the list // before the custom Level instance KnownLevel o = new KnownLevel(l); @@ -562,24 +625,36 @@ public class Level implements java.io.Serializable { intToLevels.put(l.value, list); } list.add(o); + + // keep the custom level reachable from its class loader + // This will ensure that custom level values are not GC'ed + // until there class loader is GC'ed. + if (o.mirroredLevel != l) { + registerWithClassLoader(l); + } + } // Returns a KnownLevel with the given non-localized name. - static synchronized KnownLevel findByName(String name) { - List list = nameToLevels.get(name); - if (list != null) { - return list.get(0); - } - return null; + static synchronized Optional findByName(String name, + Function> selector) { + purge(); + return nameToLevels.getOrDefault(name, Collections.emptyList()) + .stream() + .map(selector) + .flatMap(Optional::stream) + .findFirst(); } // Returns a KnownLevel with the given value. - static synchronized KnownLevel findByValue(int value) { - List list = intToLevels.get(value); - if (list != null) { - return list.get(0); - } - return null; + static synchronized Optional findByValue(int value, + Function> selector) { + purge(); + return intToLevels.getOrDefault(value, Collections.emptyList()) + .stream() + .map(selector) + .flatMap(Optional::stream) + .findFirst(); } // Returns a KnownLevel with the given localized name matching @@ -587,32 +662,34 @@ public class Level implements java.io.Serializable { // from the resourceBundle associated with the Level object). // This method does not call Level.getLocalizedName() that may // be overridden in a subclass implementation - static synchronized KnownLevel findByLocalizedLevelName(String name) { - for (List levels : nameToLevels.values()) { - for (KnownLevel l : levels) { - String lname = l.levelObject.getLocalizedLevelName(); - if (name.equals(lname)) { - return l; - } - } - } - return null; + static synchronized Optional findByLocalizedLevelName(String name, + Function> selector) { + purge(); + return nameToLevels.values().stream() + .flatMap(List::stream) + .map(selector) + .flatMap(Optional::stream) + .filter(l -> name.equals(l.getLocalizedLevelName())) + .findFirst(); } - static synchronized KnownLevel matches(Level l) { + static synchronized Optional matches(Level l) { + purge(); List list = nameToLevels.get(l.name); if (list != null) { - for (KnownLevel level : list) { - Level other = level.mirroredLevel; + for (KnownLevel ref : list) { + Level levelObject = ref.get(); + if (levelObject == null) continue; + Level other = ref.mirroredLevel; if (l.value == other.value && (l.resourceBundleName == other.resourceBundleName || (l.resourceBundleName != null && l.resourceBundleName.equals(other.resourceBundleName)))) { - return level; + return Optional.of(levelObject); } } } - return null; + return Optional.empty(); } } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java index a0589f72b05..350eb0218a0 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 @@ -1707,25 +1707,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { throw new UnsupportedOperationException("Not supported yet."); } - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, - OperationsException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, - ReflectionException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("deprecation") - public ObjectInputStream deserialize(String className, ObjectName loaderName, - byte[] data) throws InstanceNotFoundException, OperationsException, - ReflectionException { - throw new UnsupportedOperationException("Not supported yet."); - } - public ClassLoaderRepository getClassLoaderRepository() { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java index 8f0f9b66a5a..bbb1340d141 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, 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 @@ -94,32 +94,6 @@ public interface MBeanServerInterceptor extends MBeanServer { throws ReflectionException, MBeanException, InstanceNotFoundException; - /** - * This method should never be called. - * Usually throws UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(ObjectName name, byte[] data) - throws InstanceNotFoundException, OperationsException; - - /** - * This method should never be called. - * Usually throws UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(String className, byte[] data) - throws OperationsException, ReflectionException; - - /** - * This method should never be called. - * Usually hrows UnsupportedOperationException. - */ - @Deprecated - public ObjectInputStream deserialize(String className, - ObjectName loaderName, byte[] data) - throws InstanceNotFoundException, OperationsException, - ReflectionException; - /** * This method should never be called. * Usually throws UnsupportedOperationException. diff --git a/jdk/src/java.management/share/classes/javax/management/MBeanServer.java b/jdk/src/java.management/share/classes/javax/management/MBeanServer.java index 1526d818013..316fa0bf3c1 100644 --- a/jdk/src/java.management/share/classes/javax/management/MBeanServer.java +++ b/jdk/src/java.management/share/classes/javax/management/MBeanServer.java @@ -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 @@ -655,6 +655,8 @@ public interface MBeanServer extends MBeanServerConnection { * used for the de-serialization. * @param data The byte array to be de-sererialized. * + * @implSpec This method throws {@link UnsupportedOperationException} by default. + * * @return The de-serialized object stream. * * @exception InstanceNotFoundException The MBean specified is not @@ -665,10 +667,11 @@ public interface MBeanServer extends MBeanServerConnection { * @deprecated Use {@link #getClassLoaderFor getClassLoaderFor} to * obtain the appropriate class loader for deserialization. */ - @Deprecated - public ObjectInputStream deserialize(ObjectName name, byte[] data) - throws InstanceNotFoundException, OperationsException; - + @Deprecated(since="1.5") + default public ObjectInputStream deserialize(ObjectName name, byte[] data) + throws InstanceNotFoundException, OperationsException { + throw new UnsupportedOperationException("Not supported."); + } /** *

            De-serializes a byte array in the context of a given MBean @@ -682,6 +685,8 @@ public interface MBeanServer extends MBeanServerConnection { * used for the de-serialization. * @param data The byte array to be de-sererialized. * + * @implSpec This method throws {@link UnsupportedOperationException} by default. + * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output @@ -692,9 +697,11 @@ public interface MBeanServer extends MBeanServerConnection { * @deprecated Use {@link #getClassLoaderRepository} to obtain the * class loader repository and use it to deserialize. */ - @Deprecated - public ObjectInputStream deserialize(String className, byte[] data) - throws OperationsException, ReflectionException; + @Deprecated(since="1.5") + default public ObjectInputStream deserialize(String className, byte[] data) + throws OperationsException, ReflectionException { + throw new UnsupportedOperationException("Not supported."); + } /** @@ -711,6 +718,8 @@ public interface MBeanServer extends MBeanServerConnection { * loading the specified class. If null, the MBean Server's class * loader will be used. * + * @implSpec This method throws {@link UnsupportedOperationException} by default. + * * @return The de-serialized object stream. * * @exception InstanceNotFoundException The specified class loader @@ -723,12 +732,14 @@ public interface MBeanServer extends MBeanServerConnection { * @deprecated Use {@link #getClassLoader getClassLoader} to obtain * the class loader for deserialization. */ - @Deprecated - public ObjectInputStream deserialize(String className, + @Deprecated(since="1.5") + default public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, - ReflectionException; + ReflectionException { + throw new UnsupportedOperationException("Not supported."); + } /** *

            Return the {@link java.lang.ClassLoader} that was used for 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..edb0c0ba640 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 @@ -318,10 +308,6 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { //-- native methods - static native boolean isLinuxThreads(); - - static native int getLinuxThreadsManager(int pid) throws IOException; - static native void sendQuitToChildrenOf(int pid) throws IOException; static native void sendQuitTo(int pid) throws IOException; @@ -340,6 +326,5 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { static { System.loadLibrary("attach"); - isLinuxThreads = isLinuxThreads(); } } diff --git a/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c b/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c index 08ca4c481ea..85d355a1e6a 100644 --- a/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c +++ b/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c @@ -194,113 +194,6 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_connect } } -/* - * Class: sun_tools_attach_VirtualMachineImpl - * Method: isLinuxThreads - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads - (JNIEnv *env, jclass cls) -{ -# ifndef _CS_GNU_LIBPTHREAD_VERSION -# define _CS_GNU_LIBPTHREAD_VERSION 3 -# endif - size_t n; - char* s; - jboolean res; - - n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0); - if (n <= 0) { - /* glibc before 2.3.2 only has LinuxThreads */ - return JNI_TRUE; - } - - s = (char *)malloc(n); - if (s == NULL) { - JNU_ThrowOutOfMemoryError(env, "malloc failed"); - return JNI_TRUE; - } - confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n); - - /* - * If the LIBPTHREAD version include "NPTL" then we know we - * have the new threads library and not LinuxThreads - */ - res = (jboolean)(strstr(s, "NPTL") == NULL); - free(s); - return res; -} - -/* - * Structure and callback function used to count the children of - * a given process, and record the pid of the "manager thread". - */ -typedef struct { - pid_t ppid; - int count; - pid_t mpid; -} ChildCountContext; - -static void ChildCountCallback(const pid_t pid, void* user_data) { - ChildCountContext* context = (ChildCountContext*)user_data; - if (getParent(pid) == context->ppid) { - context->count++; - /* - * Remember the pid of the first child. If the final count is - * one then this is the pid of the LinuxThreads manager. - */ - if (context->count == 1) { - context->mpid = pid; - } - } -} - -/* - * Class: sun_tools_attach_VirtualMachineImpl - * Method: getLinuxThreadsManager - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager - (JNIEnv *env, jclass cls, jint pid) -{ - ChildCountContext context; - - /* - * Iterate over all processes to find how many children 'pid' has - */ - context.ppid = pid; - context.count = 0; - context.mpid = (pid_t)0; - forEachProcess(ChildCountCallback, (void*)&context); - - /* - * If there's no children then this is likely the pid of the primordial - * created by the launcher - in that case the LinuxThreads manager is the - * parent of this process. - */ - if (context.count == 0) { - pid_t parent = getParent(pid); - if ((int)parent > 0) { - return (jint)parent; - } - } - - /* - * There's one child so this is likely the embedded VM case where the - * the primordial thread == LinuxThreads initial thread. The LinuxThreads - * manager in that case is the child. - */ - if (context.count == 1) { - return (jint)context.mpid; - } - - /* - * If we get here it's most likely we were given the wrong pid - */ - JNU_ThrowIOException(env, "Unable to get pid of LinuxThreads manager thread"); - return -1; -} - /* * Structure and callback function used to send a QUIT signal to all * children of a given process 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.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java index 32255343367..66f867ad4bc 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java @@ -993,32 +993,39 @@ implements ReferenceType { return minorVersion; } - private void getConstantPoolInfo() { + private byte[] getConstantPoolInfo() { JDWP.ReferenceType.ConstantPool jdwpCPool; if (!vm.canGetConstantPool()) { throw new UnsupportedOperationException(); } if (constantPoolInfoGotten) { - return; - } else { - try { - jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this); - } catch (JDWPException exc) { - if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) { - constanPoolCount = 0; - constantPoolBytesRef = null; - constantPoolInfoGotten = true; - return; - } else { - throw exc.toJDIException(); - } + if (constantPoolBytesRef == null) { + return null; + } + byte[] cpbytes = constantPoolBytesRef.get(); + if (cpbytes != null) { + return cpbytes; } - byte[] cpbytes; - constanPoolCount = jdwpCPool.count; - cpbytes = jdwpCPool.bytes; - constantPoolBytesRef = new SoftReference(cpbytes); - constantPoolInfoGotten = true; } + + try { + jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this); + } catch (JDWPException exc) { + if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) { + constanPoolCount = 0; + constantPoolBytesRef = null; + constantPoolInfoGotten = true; + return null; + } else { + throw exc.toJDIException(); + } + } + byte[] cpbytes; + constanPoolCount = jdwpCPool.count; + cpbytes = jdwpCPool.bytes; + constantPoolBytesRef = new SoftReference(cpbytes); + constantPoolInfoGotten = true; + return cpbytes; } public int constantPoolCount() { @@ -1031,13 +1038,13 @@ implements ReferenceType { } public byte[] constantPool() { + byte[] cpbytes; try { - getConstantPoolInfo(); + cpbytes = getConstantPoolInfo(); } catch (RuntimeException exc) { throw exc; } - if (constantPoolBytesRef != null) { - byte[] cpbytes = constantPoolBytesRef.get(); + if (cpbytes != null) { /* * Arrays are always modifiable, so it is a little unsafe * to return the cached bytecodes directly; instead, we diff --git a/jdk/src/jdk.jdi/share/classes/module-info.java b/jdk/src/jdk.jdi/share/classes/module-info.java index 668c5b57c7e..14e621c108b 100644 --- a/jdk/src/jdk.jdi/share/classes/module-info.java +++ b/jdk/src/jdk.jdi/share/classes/module-info.java @@ -25,6 +25,7 @@ module jdk.jdi { requires jdk.attach; + requires jdk.jdwp.agent; exports com.sun.jdi; exports com.sun.jdi.connect; 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..405ba61a57b 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 @@ -55,6 +55,7 @@ import java.util.Objects; import java.util.Optional; import java.util.Properties; import java.util.Set; +import java.util.stream.Collectors; import jdk.tools.jlink.internal.BasicImageWriter; import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile; import jdk.tools.jlink.internal.ExecutableImage; @@ -159,7 +160,7 @@ public final class DefaultImageBuilder implements ImageBuilder { } i++; } - props.setProperty("MODULES", builder.toString()); + props.setProperty("MODULES", quote(builder.toString())); } @Override @@ -188,13 +189,14 @@ public final class DefaultImageBuilder implements ImageBuilder { storeFiles(modules, release); - if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) { - // launchers in the bin directory need execute permission + if (root.getFileSystem().supportedFileAttributeViews() + .contains("posix")) { + // 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/ @@ -217,19 +219,38 @@ public final class DefaultImageBuilder implements ImageBuilder { } } + // Parse version string and return a string that includes only version part + // leaving "pre", "build" information. See also: java.lang.Runtime.Version. + private static String parseVersion(String str) { + return Runtime.Version.parse(str). + version(). + stream(). + map(Object::toString). + collect(Collectors.joining(".")); + } + + private static String quote(String str) { + return "\"" + str + "\""; + } + private Properties releaseProperties(ResourcePool pool) throws IOException { Properties props = new Properties(); Optional javaBase = pool.moduleView().findModule("java.base"); javaBase.ifPresent(mod -> { // fill release information available from transformed "java.base" module! ModuleDescriptor desc = mod.descriptor(); - desc.osName().ifPresent(s -> props.setProperty("OS_NAME", s)); - desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", s)); - desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", s)); - props.setProperty("JAVA_VERSION", System.getProperty("java.version")); + desc.osName().ifPresent(s -> { + props.setProperty("OS_NAME", quote(s)); + this.targetOsName = s; + }); + desc.osVersion().ifPresent(s -> props.setProperty("OS_VERSION", quote(s))); + desc.osArch().ifPresent(s -> props.setProperty("OS_ARCH", quote(s))); + desc.version().ifPresent(s -> props.setProperty("JAVA_VERSION", + quote(parseVersion(s.toString())))); + desc.version().ifPresent(s -> props.setProperty("JAVA_FULL_VERSION", + quote(s.toString()))); }); - this.targetOsName = props.getProperty("OS_NAME"); if (this.targetOsName == null) { throw new PluginException("TargetPlatform attribute is missing for java.base module"); } @@ -282,8 +303,8 @@ public final class DefaultImageBuilder implements ImageBuilder { StandardOpenOption.CREATE_NEW)) { writer.write(sb.toString()); } - if (Files.getFileStore(root.resolve("bin")) - .supportsFileAttributeView(PosixFileAttributeView.class)) { + if (root.resolve("bin").getFileSystem() + .supportedFileAttributeViews().contains("posix")) { setExecutable(cmd); } // generate .bat file for Windows 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.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties index 4651ad1c097..54cc2a62072 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ext/CurrencyNames_be_BY.properties @@ -35,4 +35,5 @@ # This notice and attribution to Taligent may not be removed. # Taligent is a registered trademark of Taligent, Inc. +BYN=\u0420\u0443\u0431 BYR=\u0420\u0443\u0431 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/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties index 2caf03fd1ea..5b754bb5d74 100644 --- a/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties +++ b/jdk/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties @@ -265,8 +265,6 @@ javac.err.unmatched.constr=\ No constructor matching {0} found in {1}. javac.err.wrong.number.args=\ Wrong number of arguments in {0}. -javac.err.wrong.number.args=\ - Wrong number of arguments in {0}. javac.err.forward.ref=\ Can''t make forward reference to {0} in {1}. javac.err.array.dim.missing=\ diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2165bef4aba..f2e96cacf20 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -159,7 +159,6 @@ javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215 # jdk_net - java/net/MulticastSocket/NoLoopbackPackets.java 7122846 macosx-all java/net/MulticastSocket/SetLoopbackMode.java 7122846 macosx-all @@ -213,72 +212,10 @@ 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 -sun/security/pkcs11/Cipher/ReinitCipher.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestRSACipher.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestRSACipherWrap.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestRawRSACipher.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestSymmCiphers.java 8077138,8023434 windows-all -sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/TestDH.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/TestInterop.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/TestShort.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 8077138 windows-all -sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 8077138 windows-all -sun/security/pkcs11/KeyGenerator/DESParity.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 8077138,8023434 windows-all -sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8077138,8023434 windows-all -sun/security/pkcs11/Mac/MacKAT.java 8077138,8023434 windows-all -sun/security/pkcs11/Mac/MacSameTest.java 8077138,8023434 windows-all -sun/security/pkcs11/Mac/ReinitMac.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/ByteBuffers.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/DigestKAT.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/ReinitDigest.java 8077138,8023434 windows-all -sun/security/pkcs11/MessageDigest/TestCloning.java 8077138,8023434 windows-all -sun/security/pkcs11/Provider/ConfigQuotedString.sh 8077138,8023434 windows-all -sun/security/pkcs11/Provider/Login.sh 8077138,8023434 windows-all -sun/security/pkcs11/SampleTest.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/AddPrivateKey.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/AddTrustedCert.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/Crypto.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/GetPrivateKey.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/JksSetPrivateKey.java 8077138,8023434 windows-all -sun/security/pkcs11/Secmod/LoadKeystore.java 8077138,8023434 windows-all -sun/security/pkcs11/SecureRandom/Basic.java 8077138,8023434 windows-all -sun/security/pkcs11/SecureRandom/TestDeserialization.java 8077138,8023434 windows-all -sun/security/pkcs11/Serialize/SerializeProvider.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/ByteBuffers.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/ReinitSignature.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/TestDSA.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/TestDSAKeyLength.java 8077138,8023434 windows-all -sun/security/pkcs11/Signature/TestRSAKeyLength.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/ReadCertificates.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/ReadPKCS12.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestCurves.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDH.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDH2.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDSA.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECDSA2.java 8077138,8023434 windows-all -sun/security/pkcs11/ec/TestECGenSpec.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/KeyWrap.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestCACerts.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestKeyFactory.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8077138,8023434 windows-all -sun/security/pkcs11/rsa/TestSignatures.java 8077138,8023434 windows-all -sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestKeyMaterial.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestLeadingZeroesP11.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all -sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all - sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-all @@ -312,12 +249,8 @@ 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 - ############################################################################ # jdk_jdi @@ -332,9 +265,6 @@ com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows- com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-all -com/sun/jdi/ClassesByName2Test.java 8160833 generic-all -com/sun/jdi/RedefineCrossEvent.java 8160833 generic-all - ############################################################################ # jdk_time @@ -361,9 +291,11 @@ sun/tools/jcmd/TestJcmdSanity.java 8031482 windows- sun/tools/jhsdb/BasicLauncherTest.java 8160376 macosx-all +sun/tools/jhsdb/HeapDumpTest.java 8160376 macosx-all + sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all -sun/tools/jps/TestJpsJar.java 8160923 generic-all +sun/tools/jps/TestJpsJar.java 8165500 generic-all sun/tools/jps/TestJpsJarRelative.java 6456333 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/ConstantPoolInfoGC.java b/jdk/test/com/sun/jdi/ConstantPoolInfoGC.java new file mode 100644 index 00000000000..307d9fa3504 --- /dev/null +++ b/jdk/test/com/sun/jdi/ConstantPoolInfoGC.java @@ -0,0 +1,104 @@ +/* + * 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 6822627 + * @summary Test that ReferenceType.constantPool does not produce an NPE + * + * @author Egor Ushakov + * + * @modules jdk.jdi/com.sun.tools.jdi + * @run build TestScaffold VMConnection + * @run compile -g ConstantPoolInfoGC.java + * @run main/othervm ConstantPoolInfoGC + */ + +import com.sun.jdi.ReferenceType; +import com.sun.tools.jdi.ReferenceTypeImpl; + +import java.lang.ref.Reference; +import java.lang.reflect.Field; +import java.util.Arrays; + + /********** target program **********/ + +class ConstantPoolGCTarg { + public static void main(String[] args){ + System.out.println("Anything"); + } +} + + /********** test program **********/ + +public class ConstantPoolInfoGC extends TestScaffold { + ReferenceType targetClass; + + ConstantPoolInfoGC(String args[]) { + super(args); + } + + public static void main(String[] args) throws Exception { + new ConstantPoolInfoGC(args).startTests(); + } + + /********** test core **********/ + + protected void runTests() throws Exception { + targetClass = startToMain("ConstantPoolGCTarg").location().declaringType(); + + if (vm().canGetConstantPool()) { + byte[] cpbytes = targetClass.constantPool(); + + // imitate SoftReference cleared + Field constantPoolBytesRef = ReferenceTypeImpl.class.getDeclaredField("constantPoolBytesRef"); + constantPoolBytesRef.setAccessible(true); + Reference softRef = (Reference) constantPoolBytesRef.get(targetClass); + softRef.clear(); + + byte[] cpbytes2 = targetClass.constantPool(); + if (!Arrays.equals(cpbytes, cpbytes2)) { + failure("Consequent constantPool results vary, first was : " + cpbytes + ", now: " + cpbytes2); + }; + + } else { + System.out.println("can get constant pool version not supported"); + } + + + /* + * resume until end + */ + listenUntilVMDisconnect(); + + /* + * deal with results of test + * if anything has called failure("foo") testFailed will be true + */ + if (!testFailed) { + println("ConstantPoolInfoGC: passed"); + } else { + throw new Exception("ConstantPoolInfoGC: failed"); + } + } +} 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/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java b/jdk/test/java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java new file mode 100644 index 00000000000..deff8ee33a4 --- /dev/null +++ b/jdk/test/java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java @@ -0,0 +1,96 @@ +/* + * 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. + */ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/* + @test + @bug 8160570 + @summary Tests that a modal dialog receives WINDOW_ACTIVATED & WINDOW_GAINED_FOCUS on first show. +*/ +public class ModalDialogActivationTest { + static final Object lock = new Object(); + static volatile boolean activated; + static volatile boolean focused; + + public static void main(String[] args) throws InterruptedException { + EventQueue.invokeLater(() -> runGUI()); + + long time = System.currentTimeMillis(); + synchronized (lock) { + while (!activated || !focused) { + lock.wait(5000); + if (System.currentTimeMillis() - time >= 5000) break; + } + } + if (!activated || !focused) { + throw new RuntimeException("Test FAILED: activated: " + activated + ", focused: " + focused); + } + System.out.println("Test PASSED"); + } + + static void runGUI() { + JFrame f = new JFrame("frame"); + final JDialog d = new MyModalDialog(f, "dialog"); + d.addWindowListener(new WindowAdapter() { + @Override + public void windowActivated(WindowEvent e) { + synchronized (lock) { + activated = true; + lock.notifyAll(); + } + } + }); + d.addWindowFocusListener(new WindowAdapter() { + @Override + public void windowGainedFocus(WindowEvent e) { + synchronized (lock) { + focused = true; + lock.notifyAll(); + } + } + }); + f.setVisible(true); + d.setVisible(true); + } + + static class MyModalDialog extends JDialog { + public MyModalDialog(Frame owner, String title)ª { + super(owner, title, true); + } + + @Override + public boolean getFocusableWindowState() { + try { + // let Toolkit thread go ahead + Thread.sleep(100); + } catch (InterruptedException ignore) { + } + return super.getFocusableWindowState(); + } + } +} diff --git a/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java b/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java index 01287068e8c..2cd3bdcd2ea 100644 --- a/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java +++ b/jdk/test/java/awt/Focus/SortingFPT/JDK8048887.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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,7 +23,7 @@ /* @test - @bug 8048887 + @bug 8048887 8164937 @summary Tests SortingFTP for an exception caused by the tim-sort algo. @author anton.tarasov: area=awt.focus @run main JDK8048887 diff --git a/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java b/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java new file mode 100644 index 00000000000..147818d6db5 --- /dev/null +++ b/jdk/test/java/awt/Mouse/EnterExitEvents/ModalDialogEnterExitEventsTest.java @@ -0,0 +1,129 @@ +/* + * 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 + * @key headful + * @bug 8050478 + * @summary Cursor not updating correctly after closing a modal dialog. + * The root cause of the issue was the lack of a mouse exit event + * during displaying of a modal dialog. + * @author Dmitry Markov + * @library ../../regtesthelpers + * @build Util + * @run main ModalDialogEnterExitEventsTest + */ + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.concurrent.atomic.AtomicInteger; + +import test.java.awt.regtesthelpers.Util; + +public class ModalDialogEnterExitEventsTest { + private static volatile AtomicInteger mouseEnterCount = new AtomicInteger(); + private static volatile AtomicInteger mouseExitCount = new AtomicInteger(); + + private static JFrame frame; + private static JButton openButton; + private static JButton closeButton; + + public static void main(String[] args) { + Robot robot = Util.createRobot(); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + Util.waitForIdle(robot); + + Util.clickOnComp(frame, robot, 500); + Util.waitForIdle(robot); + + mouseEnterCount.set(0); + mouseExitCount.set(0); + + Util.clickOnComp(openButton, robot, 500); + Util.waitForIdle(robot); + if (mouseExitCount.get() != 1) { + throw new RuntimeException("Test FAILED. Wrong number of MouseExited events = " + mouseExitCount.get()); + } + + Util.clickOnComp(closeButton, robot, 500); + Util.waitForIdle(robot); + if (mouseEnterCount.get() != 1) { + throw new RuntimeException("Test FAILED. Wrong number of MouseEntered events = "+ mouseEnterCount.get()); + } + } + + private static void createAndShowGUI() { + frame = new JFrame("ModalDialogEnterExitEventsTest"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new FlowLayout()); + frame.addMouseListener(new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + mouseExitCount.getAndIncrement(); + } + + @Override + public void mouseEntered(MouseEvent e) { + mouseEnterCount.getAndIncrement(); + } + }); + openButton = new JButton("Open Dialog"); + openButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JDialog dialog = new JDialog(frame, "Modal Dialog", true); + dialog.setLayout(new FlowLayout()); + closeButton = new JButton("Close"); + closeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + dialog.add(closeButton); + dialog.setSize(200, 200); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + } + }); + frame.add(openButton); + frame.setExtendedState(Frame.MAXIMIZED_BOTH); + frame.setVisible(true); + } +} + 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/GlyphVector/GetGlyphCharIndexTest.java b/jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.java new file mode 100644 index 00000000000..6ec6a257ae8 --- /dev/null +++ b/jdk/test/java/awt/font/GlyphVector/GetGlyphCharIndexTest.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 + * @summary Test getGlyphCharIndex() results from layout + * @bug 8152680 + */ + +import java.awt.Font; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; + +public class GetGlyphCharIndexTest { + public static void main(String[] args) { + Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12); + FontRenderContext frc = new FontRenderContext(null, false, false); + GlyphVector gv = font.layoutGlyphVector(frc, "abc".toCharArray(), 1, 3, + Font.LAYOUT_LEFT_TO_RIGHT); + int idx0 = gv.getGlyphCharIndex(0); + if (idx0 != 0) { + throw new RuntimeException("Expected 0, got " + idx0); + } + } +} diff --git a/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java b/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java new file mode 100644 index 00000000000..472fca810a5 --- /dev/null +++ b/jdk/test/java/awt/font/LineBreakMeasurer/TestLineBreakWithFontSub.java @@ -0,0 +1,143 @@ +/* + * 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 + * 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 4175418 8158924 + * @author John Raley + * @summary This insures that bug 4175418: Font substitution in TextLayout / + * LineBreakMeasurer is inconsistent has been fixed. The problem was + * that text was measured in one Font, but lines were produced + * in a different font. + */ + +/* + * (C) Copyright IBM Corp. 1999, All Rights Reserved + */ + +import java.text.AttributedString; +import java.awt.font.LineBreakMeasurer; +import java.awt.font.TextLayout; +import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; + +/** + * This insures that bug 4175418: Font substitution in TextLayout / + * LineBreakMeasurer is inconsistent has been fixed. The problem was + * that text was measured in one Font, but lines were produced + * in a different font. One symptom of this problem is that lines are + * either too short or too long. This test line-breaks a paragraph + * and checks the line lengths to make sure breaks were chosen well. + * This can be checked because the paragraph is so simple. + */ +public class TestLineBreakWithFontSub { + + public static void main(String[] args) { + + new TestLineBreakWithFontSub().test(); + System.out.println("Line break / font substitution test PASSED"); + } + + private static final String WORD = "word"; + private static final String SPACING = " "; + // The Hebrew character in this string can trigger font substitution + private static final String MIXED = "A\u05D0"; + + private static final int NUM_WORDS = 12; + + private static final FontRenderContext DEFAULT_FRC = + new FontRenderContext(null, false, false); + + public void test() { + + // construct a paragraph as follows: MIXED + [SPACING + WORD] + ... + StringBuffer text = new StringBuffer(MIXED); + for (int i=0; i < NUM_WORDS; i++) { + text.append(SPACING); + text.append(WORD); + } + + AttributedString attrString = new AttributedString(text.toString()); + attrString.addAttribute(TextAttribute.SIZE, new Float(24.0)); + + LineBreakMeasurer measurer = new LineBreakMeasurer(attrString.getIterator(), + DEFAULT_FRC); + + // get width of a space-word sequence, in context + int sequenceLength = WORD.length()+SPACING.length(); + measurer.setPosition(text.length() - sequenceLength); + + TextLayout layout = measurer.nextLayout(10000.0f); + + if (layout.getCharacterCount() != sequenceLength) { + throw new Error("layout length is incorrect!"); + } + + final float sequenceAdvance = layout.getVisibleAdvance(); + + float wrappingWidth = sequenceAdvance * 2; + + // now run test with a variety of widths + while (wrappingWidth < (sequenceAdvance*NUM_WORDS)) { + measurer.setPosition(0); + checkMeasurer(measurer, + wrappingWidth, + sequenceAdvance, + text.length()); + wrappingWidth += sequenceAdvance / 5; + } + } + + /** + * Iterate through measurer and check that every line is + * not too long and not too short, but just right. + */ + private void checkMeasurer(LineBreakMeasurer measurer, + float wrappingWidth, + float sequenceAdvance, + int endPosition) { + + do { + TextLayout layout = measurer.nextLayout(wrappingWidth); + float visAdvance = layout.getVisibleAdvance(); + + // Check that wrappingWidth-sequenceAdvance < visAdvance + // Also, if we're not at the end of the paragraph, + // check that visAdvance <= wrappingWidth + + if (visAdvance > wrappingWidth) { + // line is too long for given wrapping width + throw new Error("layout is too long"); + } + + if (measurer.getPosition() < endPosition) { + if (visAdvance <= wrappingWidth - sequenceAdvance) { + // line is too short for given wrapping width; + // another word would have fit + throw new Error("room for more words on line. diff=" + + (wrappingWidth - sequenceAdvance - visAdvance)); + } + } + } while (measurer.getPosition() != endPosition); + } +} diff --git a/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java b/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java new file mode 100644 index 00000000000..e59bccac996 --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/LigatureCaretTest.java @@ -0,0 +1,167 @@ +/* + * 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 + * 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 4178145 8144015 +*/ + +/* + * Copyright 1998 IBM Corp. All Rights Reserved. + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.awt.font.TextHitInfo; +import java.awt.font.FontRenderContext; +import java.util.Hashtable; + +/** + * This test ensures that TextLayout will not place a caret within + * an Arabic lam-alef ligature, and will correctly caret through + * bidirectional text with numbers. + */ + +public class LigatureCaretTest { + + public static void main(String[] args) { + + //testBidiWithNumbers(); + testLamAlef(); + System.out.println("LigatureCaretTest PASSED"); + } + + // These values are for TextLayout constructors + private static final Hashtable map = new Hashtable(); + static { + map.put(TextAttribute.FONT, new Font("Lucida Sans", Font.PLAIN, 24)); + } + private static final FontRenderContext frc = + new FontRenderContext(null, false, false); + + /** + * Caret through text mixed-direction text and check the results. + * If the test fails an Error is thrown. + * @exception an Error is thrown if the test fails + */ + public static void testBidiWithNumbers() { + + String bidiWithNumbers = "abc\u05D0\u05D1\u05D2123abc"; + // visual order for the text: + // abc123abc + + int[] carets = { 0, 1, 2, 3, 7, 8, 6, 5, 4, 9, 10, 11, 12 }; + TextLayout layout = new TextLayout(bidiWithNumbers, map, frc); + + // Caret through TextLayout in both directions and check results. + for (int i=0; i < carets.length-1; i++) { + + TextHitInfo hit = layout.getNextRightHit(carets[i]); + if (hit.getInsertionIndex() != carets[i+1]) { + throw new Error("right hit failed within layout"); + } + } + + if (layout.getNextRightHit(carets[carets.length-1]) != null) { + throw new Error("right hit failed at end of layout"); + } + + for (int i=carets.length-1; i > 0; i--) { + + TextHitInfo hit = layout.getNextLeftHit(carets[i]); + if (hit.getInsertionIndex() != carets[i-1]) { + throw new Error("left hit failed within layout"); + } + } + + if (layout.getNextLeftHit(carets[0]) != null) { + throw new Error("left hit failed at end of layout"); + } + } + + /** + * Ensure proper careting and hit-testing behavior with + * a lam-alef ligature. + * If the test fails, an Error is thrown. + * @exception an Error is thrown if the test fails + */ + public static void testLamAlef() { + + // lam-alef form a mandantory ligature. + final String lamAlef = "\u0644\u0627"; + final String ltrText = "abcd"; + + // Create a TextLayout with just a lam-alef sequence. There + // should only be two valid caret positions: one at + // insertion offset 0 and the other at insertion offset 2. + TextLayout layout = new TextLayout(lamAlef, map, frc); + + TextHitInfo hit; + + hit = layout.getNextLeftHit(0); + if (hit.getInsertionIndex() != 2) { + throw new Error("Left hit failed. Hit:" + hit); + } + + hit = layout.getNextRightHit(2); + if (hit.getInsertionIndex() != 0) { + throw new Error("Right hit failed. Hit:" + hit); + } + + hit = layout.hitTestChar(layout.getAdvance()/2, 0); + if (hit.getInsertionIndex() != 0 && hit.getInsertionIndex() != 2) { + throw new Error("Hit-test allowed incorrect caret. Hit:" + hit); + } + + + // Create a TextLayout with some left-to-right text + // before the lam-alef sequence. There should not be + // a caret position between the lam and alef. + layout = new TextLayout(ltrText+lamAlef, map, frc); + + final int ltrLen = ltrText.length(); + final int layoutLen = layout.getCharacterCount(); + + for (int i=0; i < ltrLen; i++) { + hit = layout.getNextRightHit(i); + if (hit.getInsertionIndex() != i+1) { + throw new Error("Right hit failed in ltr text."); + } + } + + hit = layout.getNextRightHit(ltrLen); + if (layoutLen != hit.getInsertionIndex()) { + throw new Error("Right hit failed at direction boundary."); + } + + hit = layout.getNextLeftHit(layoutLen); + if (hit.getInsertionIndex() != ltrLen) { + throw new Error("Left hit failed at end of text."); + } + } +} 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/font/TextLayout/TestJustification.html b/jdk/test/java/awt/font/TextLayout/TestJustification.html new file mode 100644 index 00000000000..c9e79f44cb2 --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/TestJustification.html @@ -0,0 +1,52 @@ + + + + +Test Justification + + + +

            Test Justification

            +
            +

            Five lines of text should appear, all justified to the same width, +followed by a sixth line containing only roman characters and no spaces +which is not justified, and instead is centered. +Carets should appear between all characters. Pass the test if this is +true. +

            + +alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." +Your browser is completely ignoring the <APPLET> tag! + + + + diff --git a/jdk/test/java/awt/font/TextLayout/TestJustification.java b/jdk/test/java/awt/font/TextLayout/TestJustification.java new file mode 100644 index 00000000000..417ddd5adfc --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/TestJustification.java @@ -0,0 +1,249 @@ +/* + * 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 + * 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. + */ + +/* + * + * See TestJustification.html for main test. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.font.*; +import java.awt.geom.*; +import java.text.*; + +public class TestJustification extends Applet { + JustificationPanel panel; + + public void init() { + setLayout(new BorderLayout()); + panel = new JustificationPanel("Bitstream Cyberbit"); + add("Center", panel); + } + + public void destroy() { + remove(panel); + } + + // calls system.exit, not for use in tests. + public static void main(String args[]) { + TestJustification justificationTest = new TestJustification(); + justificationTest.init(); + justificationTest.start(); + + Frame f = new Frame("Test Justification"); + f.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + f.add("Center", justificationTest); + f.setSize(500, 500); + f.show(); + } + + public String getAppletInfo() { + return "Test TextLayout.getJustifiedLayout()"; + } + + static class JustificationPanel extends Panel { + TextLayout[] layouts; + String fontname; + float height; + float oldfsize; + + AttributedCharacterIterator lineText; + TextLayout[] lines; + int linecount; + float oldwidth; + + JustificationPanel(String fontname) { + this.fontname = fontname; + } + + private static final String[] texts = { + "This is an english Highlighting demo.", "Highlighting", + "This is an arabic \u0627\u0628\u062a\u062c \u062e\u0644\u0627\u062e demo.", "arabic \u0627\u0628\u062a\u062c", + "This is a hebrew \u05d0\u05d1\u05d2 \u05d3\u05d4\u05d5 demo.", "hebrew \u05d0\u05d1\u05d2", + "This is a cjk \u4e00\u4e01\u4e02\uac00\uac01\uc4fa\uf900\uf901\uf902 demo.", "cjk", + "NoSpaceCJK:\u4e00\u4e01\u4e02and\uac00\uac01\uc4faand\uf900\uf901\uf902", "No", + "NoSpaceRoman", "Space" + }; + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + + Dimension d = getSize(); + Insets insets = getInsets(); + + float w = d.width - insets.left - insets.right; + float h = d.height - insets.top - insets.bottom; + int fsize = (int)w/25; + + FontRenderContext frc = g2d.getFontRenderContext(); + + if (layouts == null || fsize != oldfsize) { + oldfsize = fsize; + + Font f0 = new Font(fontname, Font.PLAIN, fsize); + Font f1 = new Font(fontname, Font.ITALIC, (int)(fsize * 1.5)); + + if (layouts == null) { + layouts = new TextLayout[texts.length / 2]; + } + + height = 0; + for (int i = 0; i < layouts.length; ++i) { + String text = texts[i*2]; + String target = texts[i*2+1]; + + AttributedString astr = new AttributedString(text); + astr.addAttribute(TextAttribute.FONT, f0, 0, text.length()); + + int start = text.indexOf(target); + int limit = start + target.length(); + astr.addAttribute(TextAttribute.FONT, f1, start, limit); + + TextLayout layout = new TextLayout(astr.getIterator(), frc); + + layout = layout.getJustifiedLayout(w - 20); + + layouts[i] = layout; + + height += layout.getAscent() + layout.getDescent() + layout.getLeading(); + } + } + + g2d.setColor(Color.white); + g2d.fill(new Rectangle.Float(insets.left, insets.top, w, h)); + + float basey = 20; + + for (int i = 0; i < layouts.length; ++i) { + TextLayout layout = layouts[i]; + + float la = layout.getAscent(); + float ld = layout.getDescent(); + float ll = layout.getLeading(); + float lw = layout.getAdvance(); + float lh = la + ld + ll; + float lx = (w - lw) / 2f; + float ly = basey + layout.getAscent(); + + g2d.setColor(Color.black); + g2d.translate(insets.left + lx, insets.top + ly); + + Rectangle2D bounds = new Rectangle2D.Float(0, -la, lw, lh); + g2d.draw(bounds); + + layout.draw(g2d, 0, 0); + + g2d.setColor(Color.red); + for (int j = 0, e = layout.getCharacterCount(); j <= e; ++j) { + Shape[] carets = layout.getCaretShapes(j, bounds); + g2d.draw(carets[0]); + } + + g2d.translate(-insets.left - lx, -insets.top - ly); + basey += layout.getAscent() + layout.getDescent() + layout.getLeading(); + } + + // add LineBreakMeasurer-generated layouts + + if (lineText == null) { + String text = "This is a long line of text that should be broken across multiple " + + "lines and then justified to fit the break width. This test should pass if " + + "these lines are justified to the same width, and fail otherwise. It should " + + "also format the hebrew (\u05d0\u05d1\u05d2 \u05d3\u05d4\u05d5) and arabic " + + "(\u0627\u0628\u062a\u062c \u062e\u0644\u0627\u062e) and CJK " + + "(\u4e00\u4e01\u4e02\uac00\uac01\uc4fa\u67b1\u67b2\u67b3\u67b4\u67b5\u67b6\u67b7" + + "\u67b8\u67b9) text correctly."; + + Float regular = new Float(16.0); + Float big = new Float(24.0); + AttributedString astr = new AttributedString(text); + astr.addAttribute(TextAttribute.SIZE, regular, 0, text.length()); + astr.addAttribute(TextAttribute.FAMILY, fontname, 0, text.length()); + + int ix = text.indexOf("broken"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("hebrew"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("arabic"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 6); + ix = text.indexOf("CJK"); + astr.addAttribute(TextAttribute.SIZE, big, ix, ix + 3); + + lineText = astr.getIterator(); + } + + float width = w - 20; + if (lines == null || width != oldwidth) { + oldwidth = width; + + lines = new TextLayout[10]; + linecount = 0; + + LineBreakMeasurer measurer = new LineBreakMeasurer(lineText, frc); + + for (;;) { + TextLayout layout = measurer.nextLayout(width); + if (layout == null) { + break; + } + + // justify all but last line + if (linecount > 0) { + lines[linecount - 1] = lines[linecount - 1].getJustifiedLayout(width); + } + + if (linecount == lines.length) { + TextLayout[] nlines = new TextLayout[lines.length * 2]; + System.arraycopy(lines, 0, nlines, 0, lines.length); + lines = nlines; + } + + lines[linecount++] = layout; + } + } + + float basex = insets.left + 10; + basey += 10; + g2d.setColor(Color.black); + + for (int i = 0; i < linecount; ++i) { + TextLayout layout = lines[i]; + + basey += layout.getAscent(); + float adv = layout.getAdvance(); + float dx = layout.isLeftToRight() ? 0 : width - adv; + + layout.draw(g2d, basex + dx, basey); + + basey += layout.getDescent() + layout.getLeading(); + } + } + } +} diff --git a/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java b/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java index c0ed438cee1..4598dfd21fa 100644 --- a/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java +++ b/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java @@ -29,7 +29,7 @@ import java.text.*; /* @test * @summary verify TextLine advance - * @bug 6582460 + * @bug 6582460 8164818 */ /* 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/PrintDlgPageable.java b/jdk/test/java/awt/print/PrinterJob/PrintDlgPageable.java new file mode 100644 index 00000000000..f6a74f9f965 --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/PrintDlgPageable.java @@ -0,0 +1,171 @@ +/* + * 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 4885375 + * @summary Verifies if PageRanges To Field is populated based on Pageable + * for COMMON print dialog + * @run main/manual PrintDlgPageable + */ +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.Pageable; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.DialogTypeSelection; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class PrintDlgPageable implements Printable { + + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(PrintDlgPageable::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print Dialog does not " + + "`reflect Copies or Page Ranges"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void printTest() { + PrinterJob pj = PrinterJob.getPrinterJob(); + PageableHandler handler = new PageableHandler(); + pj.setPageable(handler); + + PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); + pSet.add(DialogTypeSelection.COMMON); + pj.printDialog(pSet); + } + + + 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 + = " Visual inspection of print dialog is required.\n" + + " A print dialog will be shown.\n " + + " Please verify Page Range is populated \n" + + " with \"From\" 1 and \"To\" 5.\n" + + " If ok, press PASS else press FAIL"; + + 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(); + } + }); + } + + @Override + public int print(Graphics g, PageFormat pf, int pi) throws PrinterException { + return NO_SUCH_PAGE; + } +} + +class PageableHandler implements Pageable { + + PageFormat pf = new PageFormat(); + + @Override + public int getNumberOfPages() { + return 5; + } + + @Override + public Printable getPrintable(int pageIndex) { + return new PrintDlgPageable(); + } + + @Override + public PageFormat getPageFormat(int pageIndex) { + return pf; + } +} 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..9076c6b08cf --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java @@ -0,0 +1,184 @@ +/* + * 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. + */ +/* + * @bug 6357887 8165146 + * @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/awt/print/PrinterJob/TestPageDlgFrameAssociation.java b/jdk/test/java/awt/print/PrinterJob/TestPageDlgFrameAssociation.java new file mode 100644 index 00000000000..32ee61ad1c6 --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/TestPageDlgFrameAssociation.java @@ -0,0 +1,166 @@ +/* + * 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 7064425 6948907 + * @summary Verifies if owner Frame is associated with page dialog of PrinterJob + * @run main/manual TestPageDlgFrameAssociation + */ +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.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPageDlgFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPageDlgFrameAssociation::frameTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Page dialog not disposed." + + " Page 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("PageDialog"); + print.setActionCommand("PageDialog"); + print.addActionListener((e) -> { + PrinterJob job = PrinterJob.getPrinterJob(); + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + t.start(); + start = true; + PageFormat pf = job.pageDialog(aset); + }); + + 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 PageDialog Button is shown. Press PageDialog.\n" + + " A page dialog will be shown. Do not press any button.\n" + + " After 5 secs the frame along with this page dialog will be disposed.\n" + + " If the page 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/print/PrinterJob/TestPrintDlgFrameAssociation.java b/jdk/test/java/awt/print/PrinterJob/TestPrintDlgFrameAssociation.java new file mode 100644 index 00000000000..d1d54307ab5 --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/TestPrintDlgFrameAssociation.java @@ -0,0 +1,165 @@ +/* + * 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 7064425 6948907 + * @summary Verifies if owner Frame is associated with print dialog of PrinterJob + * @run main/manual TestPrintDlgFrameAssociation + */ +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.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PrinterJob; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPrintDlgFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPrintDlgFrameAssociation::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("PrintDialog"); + print.setActionCommand("PrintDialog"); + print.addActionListener((e) -> { + PrinterJob job = PrinterJob.getPrinterJob(); + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + t.start(); + start = true; + job.printDialog(aset); + }); + + 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 PrintDialog Button is shown. Press PrintDialog.\n" + + " A print dialog will be shown. Do not press any button.\n" + + " After 5 secs 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/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..3feb9985681 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. * @@ -101,11 +101,8 @@ public class GetModuleTest { return new Object[][] { { GetModuleTest.class, null }, - { GetModuleTest[].class, null }, { Object.class, null }, - { Object[].class, null }, { Component.class, null }, - { Component[].class, null }, }; } @@ -117,7 +114,7 @@ public class GetModuleTest { public void testGetModuleOnVMAnonymousClass(Class hostClass, String ignore) { // choose a class name in the same package as the host class - String prefix = packageName(hostClass); + String prefix = hostClass.getPackageName(); if (prefix.length() > 0) prefix = prefix.replace('.', '/') + "/"; String className = prefix + "Anon"; @@ -136,17 +133,6 @@ public class GetModuleTest { assertTrue(anonClass.getModule() == hostClass.getModule()); } - private static String packageName(Class c) { - if (c.isArray()) { - return packageName(c.getComponentType()); - } else { - String name = c.getName(); - int dot = name.lastIndexOf('.'); - if (dot == -1) return ""; - return name.substring(0, dot); - } - } - private static int constantPoolSize(byte[] classFile) { return ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF); } 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/VMAnonymousClass.java b/jdk/test/java/lang/invoke/VMAnonymousClass.java index f686b24c113..300e056477a 100644 --- a/jdk/test/java/lang/invoke/VMAnonymousClass.java +++ b/jdk/test/java/lang/invoke/VMAnonymousClass.java @@ -57,9 +57,9 @@ public class VMAnonymousClass { @Test public void testJavaLangInvoke() throws Throwable { test("java/lang/invoke"); } @Test public void testProhibitedJavaPkg() throws Throwable { try { - test("java/prohibited"); - } catch (SecurityException e) { - return; + test("java/prohibited"); + } catch (IllegalArgumentException e) { + return; } throw new RuntimeException("Expected SecurityException"); } @@ -72,10 +72,17 @@ public class VMAnonymousClass { if (pkg.equals("java/prohibited")) { VMAnonymousClass sampleclass = new VMAnonymousClass(); host_class = (Class)sampleclass.getClass(); + } else if (pkg.equals("java/lang")) { + host_class = Object.class; + } else if (pkg.equals("java/util")) { + host_class = java.util.ArrayList.class; + } else if (pkg.equals("jdk/internal/misc")) { + host_class = jdk.internal.misc.Signal.class; + } else if (pkg.equals("java/lang/invoke")) { + host_class = java.lang.invoke.CallSite.class; } else { - host_class = Object.class; + throw new RuntimeException("Unexpected pkg: " + pkg); } - // Define VM anonymous class Class anonClass = unsafe.defineAnonymousClass(host_class, bytes, null); 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/management/ThreadMXBean/Locks.java b/jdk/test/java/lang/management/ThreadMXBean/Locks.java index 0d40a14dd3c..95fa29d6596 100644 --- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java +++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.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 @@ -26,27 +26,28 @@ * @bug 4530538 * @summary Basic unit test of ThreadInfo.getLockName() * and ThreadInfo.getLockOwnerName() + * @library /lib/testlibrary * @author Mandy Chung * @author Jaroslav Bachorik * - * @library /lib/testlibrary * @modules java.management * @build jdk.testlibrary.* * @run main/othervm Locks */ - import java.lang.management.*; +import java.util.Arrays; +import java.util.Optional; import java.util.concurrent.Phaser; +import java.util.function.Predicate; import jdk.testlibrary.LockFreeLogManager; public class Locks { - private static final Object objA = new Object(); - private static final Object objB = new Object(); - private static final Object objC = new Object(); - private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean(); - private static final LockFreeLogManager logger = new LockFreeLogManager(); - private static boolean testFailed = false; + private static final Object OBJA = new Object(); + private static final Object OBJB = new Object(); + private static final EnhancedWaiter OBJC = new EnhancedWaiter(); + private static final ThreadMXBean TM = ManagementFactory.getThreadMXBean(); + private static final LockFreeLogManager LOGGER = new LockFreeLogManager(); private static String getLockName(Object lock) { if (lock == null) return null; @@ -56,67 +57,103 @@ public class Locks { } private static void assertNoLock(Thread t) { - long tid = t.getId(); - ThreadInfo info = tm.getThreadInfo(tid); - String result = info.getLockName(); - - if (result != null) { - throw new RuntimeException("Thread " + t.getName() + " is not supposed to hold any lock. " + - "Currently owning lock: " + result); + if (t == null) { + return; + } + Optional result = Arrays.asList( + TM.getThreadInfo(TM.getAllThreadIds(), true, true)). + stream(). + filter(tInfo -> (tInfo != null && tInfo.getLockOwnerName() != null) + ? tInfo.getLockOwnerName().equals(t.getName()) : false). + findAny(); + if (result.isPresent()) { + throw new RuntimeException("Thread " + t.getName() + " is not " + + "supposed to be hold any lock. Currently owning lock : " + + result.get().getLockName()); } } - private static void checkBlockedObject(Thread t, Object lock, Thread owner, - Thread.State expectedState) { - long tid = t.getId(); - ThreadInfo info = tm.getThreadInfo(tid); - String result = info.getLockName(); - String expectedLock = (lock != null ? getLockName(lock) : null); - String expectedOwner = (owner != null ? owner.getName() : null); + /* + * Handy debug function to check if error condition is because of test code or not. + */ + private static void printStackTrace(Thread thread) { + if (thread == null) { + return; + } + StackTraceElement[] stackTrace = thread.getStackTrace(); + log("Stack dump : Thread -> " + thread.getName()); + for (StackTraceElement stackTraceEl : stackTrace) { + log("\t" + stackTraceEl.toString()); + } + } - if (lock != null) { - if (expectedState == Thread.State.BLOCKED) { - int retryCount=0; - while(info.getThreadState() != Thread.State.BLOCKED) { - if (retryCount++ > 500) { - throw new RuntimeException("Thread " + t.getName() + - " is expected to block on " + expectedLock + - " but got " + result + - " Thread.State = " + info.getThreadState()); - } - goSleep(100); - info = tm.getThreadInfo(tid); - result = info.getLockName(); + private static void assertThreadState(Thread t, Thread.State expectedState) { + long tid = t.getId(); + if (expectedState == Thread.State.BLOCKED + && TM.getThreadInfo(tid).getThreadState() != Thread.State.BLOCKED) { + int retryCount = 0; + printStackTrace(t); + while (TM.getThreadInfo(tid).getThreadState() != Thread.State.BLOCKED) { + if (retryCount++ > 500) { + printStackTrace(t); + throw new RuntimeException("Thread " + t.getName() + " is at " + + TM.getThreadInfo(tid).getThreadState() + " state but is expected to " + + "be in Thread.State = " + expectedState); } - } - if (expectedState == Thread.State.WAITING && - info.getThreadState() != Thread.State.WAITING) { - throw new RuntimeException("Thread " + t.getName() + - " is expected to wait on " + expectedLock + - " but got " + result + - " Thread.State = " + info.getThreadState()); + goSleep(100); } } - - if ((result != null && !result.equals(expectedLock)) || - (result == null && expectedLock != null)) { - throw new RuntimeException("Thread " + t.getName() + " is blocked on " + - expectedLock + " but got " + result); - } - result = info.getLockOwnerName(); - if ((result != null && !result.equals(expectedOwner)) || - (result == null && expectedOwner != null)) { - throw new RuntimeException("Owner of " + lock + " should be " + - expectedOwner + " but got " + result); + if (!TM.getThreadInfo(tid).getThreadState().equals(expectedState)) { + printStackTrace(t); + throw new RuntimeException("Thread " + t.getName() + " is at " + + TM.getThreadInfo(tid).getThreadState() + " state but is expected to " + + "be in Thread.State = " + expectedState); } } - private static void goSleep(long ms) { + /* + * Do slow check if thread is blocked on a lock. It is possible that last thread + * to come out of Phaser might still be in Phaser call stack (Unsafe.park) and + * hence might eventually acquire expected lock. + */ + private static void checkBlockedObject(Thread t, Object lock, Thread owner) { + long tid = t.getId(); + String result = TM.getThreadInfo(tid).getLockName(); + final String expectedLock = (lock != null ? getLockName(lock) : null); + Predicate p = (res) -> ((res != null && !res.equals(expectedLock)) + || (res == null && expectedLock != null)); + + if (p.test(result)) { + printStackTrace(t); + int retryCount = 0; + while (p.test(result)) { + if (retryCount++ > 500) { + printStackTrace(t); + throw new RuntimeException("Thread " + t.getName() + " is blocked on " + + expectedLock + " but got " + result); + } + goSleep(100); + result = TM.getThreadInfo(tid).getLockName(); + } + } + + result = TM.getThreadInfo(tid).getLockOwnerName(); + final String expectedOwner = (owner != null ? owner.getName() : null); + + p = (res) -> ((res != null && !res.equals(expectedOwner)) + || (res == null && expectedOwner != null)); + if (p.test(result)) { + printStackTrace(t); + throw new RuntimeException("Owner of " + lock + " should be " + + expectedOwner + " but got " + result); + } + } + + private static void goSleep(long ms){ try { Thread.sleep(ms); - } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; + } catch (InterruptedException ex) { + throw new RuntimeException(ex); } } @@ -128,14 +165,15 @@ public class Locks { super("LockAThread"); this.p = p; } + @Override public void run() { - synchronized(objA) { - // stop here for LockBThread to hold objB - log("LockAThread about to block on objB"); + synchronized(OBJA) { + // block here while LockBThread holds OBJB + log("LockAThread about to block on OBJB"); p.arriveAndAwaitAdvance(); // Phase 1 (blocking) - synchronized(objB) { + synchronized(OBJB) { dummyCounter++; - }; + } } p.arriveAndAwaitAdvance(); // Phase 2 (blocking) log("LockAThread about to exit"); @@ -150,14 +188,15 @@ public class Locks { super("LockBThread"); this.p = p; } + @Override public void run() { - synchronized(objB) { - log("LockBThread about to block on objC"); + synchronized(OBJB) { + log("LockBThread about to block on OBJC"); p.arriveAndAwaitAdvance(); // Phase 1 (blocking) - // Signal main thread about to block on objC - synchronized(objC) { + // Signal main thread about to block on OBJC + synchronized(OBJC) { dummyCounter++; - }; + } } p.arriveAndAwaitAdvance(); // Phase 2 (blocking) log("LockBThread about to exit"); @@ -166,9 +205,30 @@ public class Locks { } } + /* + * Must be invoked from within a synchronized context + */ + private static class EnhancedWaiter { + + boolean isNotified = false; + + public void doWait() throws InterruptedException { + while (!isNotified) { + wait(); + } + isNotified = false; + } + + public void doNotify() { + isNotified = true; + notify(); + } + } + private static WaitingThread waiter; private static final Object ready = new Object(); private static CheckerThread checker; + static class WaitingThread extends Thread { private final Phaser p; @@ -180,17 +240,16 @@ public class Locks { } @Override public void run() { - synchronized(objC) { - log("WaitingThread about to wait on objC"); + synchronized(OBJC) { + log("WaitingThread about to wait on OBJC"); try { - // Signal checker thread, about to wait on objC. + // Signal checker thread, about to wait on OBJC. waiting = false; p.arriveAndAwaitAdvance(); // Phase 1 (waiting) waiting = true; - objC.wait(); + OBJC.doWait(); } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; + throw new RuntimeException(e); // Do not continue test } // block until CheckerThread finishes checking @@ -202,19 +261,18 @@ public class Locks { dummyCounter++; } } - synchronized(objC) { + synchronized(OBJC) { try { - // signal checker thread, about to wait on objC + // signal checker thread, about to wait on OBJC waiting = false; p.arriveAndAwaitAdvance(); // Phase 3 (waiting) waiting = true; - objC.wait(); + OBJC.doWait(); } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; + throw new RuntimeException(e); } } - log("WaitingThread about to exit waiting on objC 2"); + log("WaitingThread about to exit waiting on OBJC 2"); } public void waitForWaiting() { @@ -241,85 +299,87 @@ public class Locks { super("CheckerThread"); } + @Override public void run() { - synchronized (ready) { - // wait until WaitingThread about to wait for objC + synchronized(ready) { + // wait until WaitingThread about to wait for OBJC waiter.waitForWaiting(); // Phase 1 (waiting) - checkBlockedObject(waiter, objC, null, Thread.State.WAITING); + assertThreadState(waiter, Thread.State.WAITING); + checkBlockedObject(waiter, OBJC, null); - synchronized (objC) { - objC.notify(); + synchronized(OBJC) { + OBJC.doNotify(); } - // wait for waiter thread to about to enter // synchronized object ready. waiter.waitForBlocked(); // Phase 2 (waiting) - checkBlockedObject(waiter, ready, this, Thread.State.BLOCKED); + assertThreadState(waiter, Thread.State.BLOCKED); + checkBlockedObject(waiter, ready, this); } // wait for signal from waiting thread that it is about - // wait for objC. + // wait for OBJC. waiter.waitForWaiting(); // Phase 3 (waiting) - synchronized(objC) { - checkBlockedObject(waiter, objC, Thread.currentThread(), Thread.State.WAITING); - objC.notify(); + synchronized(OBJC) { + assertThreadState(waiter, Thread.State.WAITING); + checkBlockedObject(waiter, OBJC, Thread.currentThread()); + OBJC.doNotify(); } - } } public static void main(String args[]) throws Exception { - Thread mainThread = Thread.currentThread(); - - // Test uncontested case - LockAThread t1; - LockBThread t2; - - Phaser p = new Phaser(3); - synchronized(objC) { - // Make sure the main thread is not holding any lock - assertNoLock(mainThread); - - // Test deadlock case - // t1 holds lockA and attempts to lock B - // t2 holds lockB and attempts to lock C - - t1 = new LockAThread(p); - t1.start(); - - t2 = new LockBThread(p); - t2.start(); - - p.arriveAndAwaitAdvance(); // Phase 1 (blocking) - checkBlockedObject(t2, objC, mainThread, Thread.State.BLOCKED); - checkBlockedObject(t1, objB, t2, Thread.State.BLOCKED); - - long[] expectedThreads = new long[3]; - expectedThreads[0] = t1.getId(); // blocked on lockB - expectedThreads[1] = t2.getId(); // owner of lockB blocking on lockC - expectedThreads[2] = mainThread.getId(); // owner of lockC - findThreadsBlockedOn(objB, expectedThreads); - } - p.arriveAndAwaitAdvance(); // Phase 2 (blocking) - - p = new Phaser(2); - // Test Object.wait() case - waiter = new WaitingThread(p); - waiter.start(); - - checker = new CheckerThread(); - checker.start(); - try { - waiter.join(); - checker.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - testFailed = true; - } + Thread mainThread = Thread.currentThread(); - if (testFailed) { - throw new RuntimeException("TEST FAILED."); + // Test uncontested case + LockAThread t1; + LockBThread t2; + + Phaser p = new Phaser(3); + synchronized(OBJC) { + // Make sure the main thread is not holding any lock + assertNoLock(mainThread); + + // Test deadlock case + // t1 holds lockA and attempts to lock B + // t2 holds lockB and attempts to lock C + t1 = new LockAThread(p); + t1.start(); + + t2 = new LockBThread(p); + t2.start(); + + p.arriveAndAwaitAdvance(); // Phase 1 (blocking) + assertThreadState(t2, Thread.State.BLOCKED); + checkBlockedObject(t2, OBJC, mainThread); + assertThreadState(t1, Thread.State.BLOCKED); + checkBlockedObject(t1, OBJB, t2); + + long[] expectedThreads = new long[3]; + expectedThreads[0] = t1.getId(); // blocked on lockB + expectedThreads[1] = t2.getId(); // owner of lockB blocking on lockC + expectedThreads[2] = mainThread.getId(); // owner of lockC + findThreadsBlockedOn(OBJB, expectedThreads); + } + p.arriveAndAwaitAdvance(); // Phase 2 (blocking) + + p = new Phaser(2); + // Test Object.wait() case + waiter = new WaitingThread(p); + waiter.start(); + + checker = new CheckerThread(); + checker.start(); + + try { + waiter.join(); + checker.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } finally { // log all the messages to STDOUT + System.out.println(LOGGER.toString()); } System.out.println("Test passed."); } @@ -335,9 +395,9 @@ public class Locks { throw new RuntimeException("TEST FAILED: " + lock + " expected to have owner"); } - for (int j = 0; j < infos.length; j++) { - if (infos[j].getThreadId() == threadId) { - ownerInfo = infos[j]; + for (ThreadInfo info1 : infos) { + if (info1.getThreadId() == threadId) { + ownerInfo = info1; break; } } @@ -349,11 +409,11 @@ public class Locks { throws Exception { String lock = getLockName(o); // Check with ThreadInfo with no stack trace (i.e. no safepoint) - ThreadInfo[] infos = tm.getThreadInfo(tm.getAllThreadIds()); + ThreadInfo[] infos = TM.getThreadInfo(TM.getAllThreadIds()); doCheck(infos, lock, expectedThreads); // Check with ThreadInfo with stack trace - infos = tm.getThreadInfo(tm.getAllThreadIds(), 1); + infos = TM.getThreadInfo(TM.getAllThreadIds(), 1); doCheck(infos, lock, expectedThreads); } @@ -376,7 +436,7 @@ public class Locks { long[] threads = new long[10]; int count = 0; threads[count++] = ownerInfo.getThreadId(); - while (ownerInfo != null && ownerInfo.getThreadState() == Thread.State.BLOCKED) { + while (ownerInfo.getThreadState() == Thread.State.BLOCKED) { ownerInfo = findOwnerInfo(infos, lock); threads[count++] = ownerInfo.getThreadId(); log(" Owner = %s id = %d", @@ -407,6 +467,6 @@ public class Locks { } private static void log(String format, Object ... args) { - logger.log(format + "%n", args); + LOGGER.log(format + "%n", args); } } 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/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java b/jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java new file mode 100644 index 00000000000..29abfb9f551 --- /dev/null +++ b/jdk/test/java/security/cert/CertPathValidator/trustAnchor/ValWithAnchorByName.java @@ -0,0 +1,292 @@ +/* + * 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 + * 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 8132926 + * @summary PKIXParameters built with public key form of TrustAnchor causes + * NPE during cert path building/validation + * @run main ValWithAnchorByName + */ + +import java.io.ByteArrayInputStream; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.CertPath; +import java.security.cert.CertPathValidator; +import java.security.cert.PKIXParameters; +import java.security.cert.PKIXRevocationChecker; +import java.security.cert.TrustAnchor; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +// To get certpath debugging, add -Djava.security.debug=certpath + +public class ValWithAnchorByName { + + // The following certificates and OCSP responses were captured from + // a test run that used certificates and responses generated by + // sun.security.testlibrary.CertificateBuilder and + // sun.security.testlibrary.SimpleOCSPServer. + + // Subject: CN=SSLCertificate, O=SomeCompany + // Issuer: CN=Intermediate CA Cert, O=SomeCompany + // Validity: Tue Aug 30 14:37:19 PDT 2016 to Wed Aug 30 14:37:19 PDT 2017 + private static final String EE_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIIDnTCCAoWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTEUMBIGA1UEChMLU29t\n" + + "ZUNvbXBhbnkxHTAbBgNVBAMTFEludGVybWVkaWF0ZSBDQSBDZXJ0MB4XDTE2MDgz\n" + + "MDIxMzcxOVoXDTE3MDgzMDIxMzcxOVowLzEUMBIGA1UEChMLU29tZUNvbXBhbnkx\n" + + "FzAVBgNVBAMTDlNTTENlcnRpZmljYXRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + + "MIIBCgKCAQEAjgv8KKE4CO0rbCjRLA1hXjRiSq30jeusCJ8frbRG+QOBgQ3j6jgc\n" + + "vk5wG1aTu7R4AFn0/HRDMzP9ZbRlZVIbJUTd8YiaNyZeyWapPnxHWrPCd5e1xopk\n" + + "ElieDdEH5FiLGtIrWy56CGA1hfQb1vUVYegyeY+TTtMFVHt0PrmMk4ZRgj/GtVNp\n" + + "BQQYIzaYAcrcWMeCn30ZrhaGAL1hsdgmEVV1wsTD4JeNMSwLwMYem7fg8ondGZIR\n" + + "kZuGtuSdOHu4Xz+mgDNXTeX/Bp/dQFucxCG+FOOM9Hoz72RY2W8YqgL38RlnwYWp\n" + + "nUNxhXWFH6vyINRQVEu3IgahR6HXjxM7LwIDAQABo4G8MIG5MBQGA1UdEQQNMAuC\n" + + "CWxvY2FsaG9zdDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9s\n" + + "b2NhbGhvc3Q6NDIzMzMwHwYDVR0jBBgwFoAUYT525lwHCI4CmuWs8a7poaeKRJ4w\n" + + "HQYDVR0OBBYEFCaQnOX4L1ovqyfeKuoay+kI+lXgMA4GA1UdDwEB/wQEAwIFoDAd\n" + + "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEB\n" + + "AD8dqQIqFasJcL8lm4mPTsBl0JgNiN8tQcXM7VCvcH+yDvEyh9vudDjuhpSORqPq\n" + + "f1o/EvJ+gfs269mBnYQujYRvmSd6EAcBntv5zn6amOh03o6PqTY9KaUC/mL9hB84\n" + + "Y5/LYioP16sME7egKnlrGUgKh0ZvGzm7c3SYx3Z5YoeFBOkZajc7Jm+cBw/uBQkF\n" + + "a9mLEczIvOgkq1wto8vr2ptH1gEuvFRcorN3muvq34bk40G08+AHlP3fCLFpI3FA\n" + + "IStJLJZRcO+Ib4sOcKuaBGnuMo/QVOCEMDUs6RgiWtSd93OZKFIUOASVp6YIkcSs\n" + + "5/rmc06sICqBjLfPEB68Jjw=\n" + + "-----END CERTIFICATE-----"; + + // Subject: CN=Intermediate CA Cert, O=SomeCompany + // Issuer: CN=Root CA Cert, O=SomeCompany + // Validity: Sun Aug 07 14:37:19 PDT 2016 to Tue Aug 07 14:37:19 PDT 2018 + private static final String INT_CA_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIIDdjCCAl6gAwIBAgIBZDANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + + "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDgwNzIxMzcxOVoX\n" + + "DTE4MDgwNzIxMzcxOVowNTEUMBIGA1UEChMLU29tZUNvbXBhbnkxHTAbBgNVBAMT\n" + + "FEludGVybWVkaWF0ZSBDQSBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + + "CgKCAQEAnJR5CnE7GKlQjigExSJ6hHu302mc0PcA6TDgsIitPYD/r8RBbBuE51OQ\n" + + "7IP7AXmfPUV3/+pO/uxx6mgY5O6XeUl7KadhVPtPcL0BVVevCSOdTMVa3iV4zRpa\n" + + "C6Uy2ouUFnafKnDtlbieggyETUoNgVNJYA9L0XNhtSnENoLHC4Pq0v8OsNtsOWFR\n" + + "NiMTOA49NNDBw85WgPyFAxjqO4z0J0zxdWq3W4rSMB8xrkulv2Rvj3GcfYJK/ab8\n" + + "V1IJ6PMWCpujASY3BzvYPnN7BKuBjbWJPgZdPYfX1cxeG80u0tOuMfWWiNONSMSA\n" + + "7m9y304QA0gKqlrFFn9U4hU89kv1IwIDAQABo4GYMIGVMA8GA1UdEwEB/wQFMAMB\n" + + "Af8wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzABhhZodHRwOi8vbG9jYWxob3N0\n" + + "OjM5MTM0MB8GA1UdIwQYMBaAFJNMsejEyJUB9tiWycVczvpiMVQZMB0GA1UdDgQW\n" + + "BBRhPnbmXAcIjgKa5azxrumhp4pEnjAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN\n" + + "AQELBQADggEBAE4nOFdW9OirPnRvxihQXYL9CXLuGQz5tr0XgN8wSY6Un9b6CRiK\n" + + "7obgIGimVdhvUC1qdRcwJqgOfJ2/jR5/5Qo0TVp+ww4dHNdUoj73tagJ7jTu0ZMz\n" + + "5Zdp0uwd4RD/syvTeVcbPc3m4awtgEvRgzpDMcSeKPZWInlo7fbnowKSAUAfO8de\n" + + "0cDkxEBkzPIzGNu256cdLZOqOK9wLJ9mQ0zKgi/2NsldNc2pl/6jkGpA6uL5lJsm\n" + + "fo9sDusWNHV1YggqjDQ19hrf40VuuC9GFl/qAW3marMuEzY/NiKVUxty1q1s48SO\n" + + "g5LoEPDDkbygOt7ICL3HYG1VufhC1Q2YY9c=\n" + + "-----END CERTIFICATE-----"; + + // Subject: CN=Root CA Cert, O=SomeCompany + // Issuer: CN=Root CA Cert, O=SomeCompany + // Validity: Fri Jul 08 14:37:18 PDT 2016 to Fri Jun 28 14:37:18 PDT 2019 + private static final String ROOT_CA_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + + "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDcwODIxMzcxOFoX\n" + + "DTE5MDYyODIxMzcxOFowLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMT\n" + + "DFJvb3QgQ0EgQ2VydDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIlN\n" + + "M3WYEqkU2elXEZrV9QSDbDKwyaLEHafLFciH8Edoag3q/7jEzFJxI7JZ831tdbWQ\n" + + "Bm6Hgo+8pvetOFW1BckL8eIjyOONP2CKfFaeMaozsWi1cgxa+rjpU/Rekc+zBqvv\n" + + "y4Sr97TwT6nQiLlgjC1nCfR1SVpO51qoDChS7n785rsKEZxw/p+kkVWSZffU7zN9\n" + + "c645cPg//L/kjiyeKMkaquGQOYS68gQgy8YZXQv1E3l/8e8Ci1s1DYA5wpCbaBqg\n" + + "Tw84Rr4zlUEQBgXzQlRt+mPzeaDpdG1EeGkXrcdkZ+0EMELoOVXOEn6VNsz6vT3I\n" + + "KrnvQBSnN06xq/iWwC0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME\n" + + "GDAWgBSTTLHoxMiVAfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUk0yx6MTIlQH22JbJ\n" + + "xVzO+mIxVBkwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAAi+Nl\n" + + "sxP9t2IhiZIHRJGSBZuQlXIjwYIwbq3ZWc/ApZ+0oxtl7DYQi5uRNt8/opcGNCHc\n" + + "IY0fG93SbkDubXbxPYBW6D/RUjbz59ZryaP5ym55p1MjHTOqy+AM8g41xNTJikc3\n" + + "UUFXXnckeFbawijCsb7vf71owzKuxgBXi9n1rmXXtncKoA/LrUVXoUlKefdgDnsU\n" + + "sl3Q29eibE3HSqziMMoAOLm0jjekFGWIgLeTtyRYR1d0dNaUwsHTrQpPjxxUTn1x\n" + + "sAPpXKfzPnsYAZeeiaaE75GwbWlHzrNinvxdZQd0zctpfBJfVqD/+lWANlw+rOaK\n" + + "J2GyCaJINsyaI/I2\n" + + "-----END CERTIFICATE-----"; + + // OCSP Response Status: successful (0x0) + // Response Type: Basic OCSP Response + // Version: 1 (0x0) + // Responder Id: CN=Intermediate CA Cert, O=SomeCompany + // Produced At: Sep 6 21:37:20 2016 GMT + // Responses: + // Certificate ID: + // Hash Algorithm: sha1 + // Issuer Name Hash: 7ED23D4396152EAB7D0C4AD8C1CA1418AA05DD54 + // Issuer Key Hash: 613E76E65C07088E029AE5ACF1AEE9A1A78A449E + // Serial Number: 1000 + // Cert Status: good + // This Update: Sep 6 21:37:20 2016 GMT + // Next Update: Sep 6 22:37:19 2016 GMT + private static final String EE_OCSP_RESP = + "MIIFbAoBAKCCBWUwggVhBgkrBgEFBQcwAQEEggVSMIIFTjCBtaE3MDUxFDASBgNV\n" + + "BAoTC1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydBgP\n" + + "MjAxNjA5MDYyMTM3MjBaMGUwYzA7MAkGBSsOAwIaBQAEFH7SPUOWFS6rfQxK2MHK\n" + + "FBiqBd1UBBRhPnbmXAcIjgKa5azxrumhp4pEngICEACAABgPMjAxNjA5MDYyMTM3\n" + + "MjBaoBEYDzIwMTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAF13\n" + + "cLwxDG8UYPIbzID86vZGOWUuv5c35VnvebMk/ajAUdpItDYshIQVi90Z8BB2TEi/\n" + + "wtx1aNkIv7db0uQ0NnRfvME8vG2PWbty36CNAYr/M5UVzUmELH2sGTyf2fKfNIUK\n" + + "Iya/NRxCqxLAc34NYH0YyGJ9VcDjbEMNSBAHIqDdBNqKUPnjn454yoivU2oEs294\n" + + "cGePMx3QLyPepMwUss8nW74yIF7vxfJ+KFDBGWNuZDRfXScsGIoeM0Vt9B+4fmnV\n" + + "nP4Dw6l3IwmQH4ppjg08qTKvyrXcF2dPDWa98Xw6bA5G085Z/b/6/6GpkvKx/q6i\n" + + "UqKwF7q5hkDcB+N4/5SgggN+MIIDejCCA3YwggJeoAMCAQICAWQwDQYJKoZIhvcN\n" + + "AQELBQAwLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0Eg\n" + + "Q2VydDAeFw0xNjA4MDcyMTM3MTlaFw0xODA4MDcyMTM3MTlaMDUxFDASBgNVBAoT\n" + + "C1NvbWVDb21wYW55MR0wGwYDVQQDExRJbnRlcm1lZGlhdGUgQ0EgQ2VydDCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJyUeQpxOxipUI4oBMUieoR7t9Np\n" + + "nND3AOkw4LCIrT2A/6/EQWwbhOdTkOyD+wF5nz1Fd//qTv7scepoGOTul3lJeymn\n" + + "YVT7T3C9AVVXrwkjnUzFWt4leM0aWgulMtqLlBZ2nypw7ZW4noIMhE1KDYFTSWAP\n" + + "S9FzYbUpxDaCxwuD6tL/DrDbbDlhUTYjEzgOPTTQwcPOVoD8hQMY6juM9CdM8XVq\n" + + "t1uK0jAfMa5Lpb9kb49xnH2CSv2m/FdSCejzFgqbowEmNwc72D5zewSrgY21iT4G\n" + + "XT2H19XMXhvNLtLTrjH1lojTjUjEgO5vct9OEANICqpaxRZ/VOIVPPZL9SMCAwEA\n" + + "AaOBmDCBlTAPBgNVHRMBAf8EBTADAQH/MDIGCCsGAQUFBwEBBCYwJDAiBggrBgEF\n" + + "BQcwAYYWaHR0cDovL2xvY2FsaG9zdDozOTEzNDAfBgNVHSMEGDAWgBSTTLHoxMiV\n" + + "AfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUYT525lwHCI4CmuWs8a7poaeKRJ4wDgYD\n" + + "VR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQBOJzhXVvToqz50b8YoUF2C\n" + + "/Qly7hkM+ba9F4DfMEmOlJ/W+gkYiu6G4CBoplXYb1AtanUXMCaoDnydv40ef+UK\n" + + "NE1afsMOHRzXVKI+97WoCe407tGTM+WXadLsHeEQ/7Mr03lXGz3N5uGsLYBL0YM6\n" + + "QzHEnij2ViJ5aO3256MCkgFAHzvHXtHA5MRAZMzyMxjbtuenHS2TqjivcCyfZkNM\n" + + "yoIv9jbJXTXNqZf+o5BqQOri+ZSbJn6PbA7rFjR1dWIIKow0NfYa3+NFbrgvRhZf\n" + + "6gFt5mqzLhM2PzYilVMbctatbOPEjoOS6BDww5G8oDreyAi9x2BtVbn4QtUNmGPX"; + + // OCSP Response Status: successful (0x0) + // Response Type: Basic OCSP Response + // Version: 1 (0x0) + // Responder Id: O = SomeCompany, CN = Root CA Cert + // Produced At: Sep 6 21:37:20 2016 GMT + // Responses: + // Certificate ID: + // Hash Algorithm: sha1 + // Issuer Name Hash: C8ED9F4E9AC0052A978257C569E6A7C9C45F5CB5 + // Issuer Key Hash: 934CB1E8C4C89501F6D896C9C55CCEFA62315419 + // Serial Number: 64 + // Cert Status: good + // This Update: Sep 6 21:37:20 2016 GMT + // Next Update: Sep 6 22:37:19 2016 GMT + private static final String INT_CA_OCSP_RESP = + "MIIFJQoBAKCCBR4wggUaBgkrBgEFBQcwAQEEggULMIIFBzCBrKEvMC0xFDASBgNV\n" + + "BAoTC1NvbWVDb21wYW55MRUwEwYDVQQDEwxSb290IENBIENlcnQYDzIwMTYwOTA2\n" + + "MjEzNzIwWjBkMGIwOjAJBgUrDgMCGgUABBTI7Z9OmsAFKpeCV8Vp5qfJxF9ctQQU\n" + + "k0yx6MTIlQH22JbJxVzO+mIxVBkCAWSAABgPMjAxNjA5MDYyMTM3MjBaoBEYDzIw\n" + + "MTYwOTA2MjIzNzE5WqECMAAwDQYJKoZIhvcNAQELBQADggEBAAgs8jpuEejPD8qO\n" + + "+xckvqMz/5pItOHaSB0xyPNpIapqjcDkLktJdBVq5XJWernO9DU+P7yr7TDbvo6h\n" + + "P5jBZklLz16Z1aRlEyow2jhelVjNl6nxoiij/6LOGK4tLHa8fK7hTB4Ykw22Bxzt\n" + + "LcbrU5jgUDhdZkTrs+rWM8nw7mVWIQYQfwzCMDZ5a02MxzhdwggJGRzqMrbhY/Q7\n" + + "RRUK3ohSgzHmLjVkvA0KeM/Px7EefzbEbww08fSsLybmBoIEbcckWSHkkXx4cuIR\n" + + "T9FiTz4Ms4r8qzPCo61qeklE2I5lfnfieROADV6sfwbul/0U1HqKhHVaxJ8yYw+T\n" + + "/FMxrUKgggNAMIIDPDCCAzgwggIgoAMCAQICAQEwDQYJKoZIhvcNAQELBQAwLTEU\n" + + "MBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMTDFJvb3QgQ0EgQ2VydDAeFw0x\n" + + "NjA3MDgyMTM3MThaFw0xOTA2MjgyMTM3MThaMC0xFDASBgNVBAoTC1NvbWVDb21w\n" + + "YW55MRUwEwYDVQQDEwxSb290IENBIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" + + "DwAwggEKAoIBAQCJTTN1mBKpFNnpVxGa1fUEg2wysMmixB2nyxXIh/BHaGoN6v+4\n" + + "xMxScSOyWfN9bXW1kAZuh4KPvKb3rThVtQXJC/HiI8jjjT9ginxWnjGqM7FotXIM\n" + + "Wvq46VP0XpHPswar78uEq/e08E+p0Ii5YIwtZwn0dUlaTudaqAwoUu5+/Oa7ChGc\n" + + "cP6fpJFVkmX31O8zfXOuOXD4P/y/5I4snijJGqrhkDmEuvIEIMvGGV0L9RN5f/Hv\n" + + "AotbNQ2AOcKQm2gaoE8POEa+M5VBEAYF80JUbfpj83mg6XRtRHhpF63HZGftBDBC\n" + + "6DlVzhJ+lTbM+r09yCq570AUpzdOsav4lsAtAgMBAAGjYzBhMA8GA1UdEwEB/wQF\n" + + "MAMBAf8wHwYDVR0jBBgwFoAUk0yx6MTIlQH22JbJxVzO+mIxVBkwHQYDVR0OBBYE\n" + + "FJNMsejEyJUB9tiWycVczvpiMVQZMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0B\n" + + "AQsFAAOCAQEAAIvjZbMT/bdiIYmSB0SRkgWbkJVyI8GCMG6t2VnPwKWftKMbZew2\n" + + "EIubkTbfP6KXBjQh3CGNHxvd0m5A7m128T2AVug/0VI28+fWa8mj+cpueadTIx0z\n" + + "qsvgDPIONcTUyYpHN1FBV153JHhW2sIowrG+73+9aMMyrsYAV4vZ9a5l17Z3CqAP\n" + + "y61FV6FJSnn3YA57FLJd0NvXomxNx0qs4jDKADi5tI43pBRliIC3k7ckWEdXdHTW\n" + + "lMLB060KT48cVE59cbAD6Vyn8z57GAGXnommhO+RsG1pR86zYp78XWUHdM3LaXwS\n" + + "X1ag//pVgDZcPqzmiidhsgmiSDbMmiPyNg=="; + + // Do path validation as if it is always Tue, 06 Sep 2016 22:12:21 GMT + // This value is within the lifetimes of all certificates and both OCSP + // responses. + private static final Date EVAL_DATE = new Date(1473199941000L); + + private static final Base64.Decoder DECODER = Base64.getMimeDecoder(); + + public static void main(String[] args) throws Exception { + TrustAnchor anchor; + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + X509Certificate rootCert = generateCertificate(cf, ROOT_CA_CERT); + X509Certificate eeCert = generateCertificate(cf, EE_CERT); + X509Certificate intCaCert = generateCertificate(cf, INT_CA_CERT); + List certList = new ArrayList() {{ + add(eeCert); + add(intCaCert); + }}; + + System.out.println("==== Certificate Path ====="); + for (X509Certificate c : certList) { + System.out.println(c + "\n"); + } + System.out.println("==========================="); + + System.out.println("===== Test 1: TA(X509Certificate) ====="); + anchor = new TrustAnchor(rootCert, null); + runTest(cf, certList, anchor); + + System.out.println("===== Test 2: TA(X500Principal, PublicKey ====="); + anchor = new TrustAnchor(rootCert.getSubjectX500Principal(), + rootCert.getPublicKey(), null); + runTest(cf, certList, anchor); + + System.out.println("===== Test 3: TA(String, PublicKey ====="); + anchor = new TrustAnchor(rootCert.getSubjectX500Principal().getName(), + rootCert.getPublicKey(), null); + runTest(cf, certList, anchor); + } + + private static void runTest(CertificateFactory cf, + List certList, TrustAnchor anchor) + throws Exception { + CertPath path = cf.generateCertPath(certList); + CertPathValidator validator = CertPathValidator.getInstance("PKIX"); + + System.out.println(anchor); + + // Attach the OCSP responses to a PKIXParameters object + PKIXRevocationChecker pkrev = + (PKIXRevocationChecker)validator.getRevocationChecker(); + Map responseMap = new HashMap<>(); + responseMap.put(certList.get(0), DECODER.decode(EE_OCSP_RESP)); + responseMap.put(certList.get(1), DECODER.decode(INT_CA_OCSP_RESP)); + pkrev.setOcspResponses(responseMap); + PKIXParameters params = + new PKIXParameters(Collections.singleton(anchor)); + params.addCertPathChecker(pkrev); + params.setDate(EVAL_DATE); + + validator.validate(path, params); + } + + private static X509Certificate generateCertificate(CertificateFactory cf, + String encoded) throws CertificateException { + ByteArrayInputStream is = new ByteArrayInputStream(encoded.getBytes()); + return (X509Certificate)cf.generateCertificate(is); + } +} diff --git a/jdk/test/java/sql/testng/TEST.properties b/jdk/test/java/sql/testng/TEST.properties index 295505b905a..66b1566374a 100644 --- a/jdk/test/java/sql/testng/TEST.properties +++ b/jdk/test/java/sql/testng/TEST.properties @@ -1,3 +1,4 @@ # JDBC unit tests uses TestNG TestNG.dirs = . +othervm.dirs = test/sql/othervm diff --git a/jdk/test/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java b/jdk/test/java/sql/testng/test/sql/othervm/DriverManagerInitTests.java new file mode 100644 index 00000000000..d2570993533 --- /dev/null +++ b/jdk/test/java/sql/testng/test/sql/othervm/DriverManagerInitTests.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. + */ +package test.sql.othervm; + +import java.io.BufferedReader; +import java.io.CharArrayReader; +import java.io.CharArrayWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.Driver; +import java.sql.DriverManager; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.testng.Assert.*; +import org.testng.annotations.Test; + +public class DriverManagerInitTests { + + /** + * Validate that when DriverManager loads the initial JDBC drivers, that the + * output from DriverManager.println is available by verifying that the + * String "JDBC DriverManager initialized" is found + */ + @Test + public void test() { + + CharArrayWriter cw = new CharArrayWriter(); + PrintWriter pw = new PrintWriter(cw); + DriverManager.setLogWriter(pw); + Enumeration drivers = DriverManager.getDrivers(); + + try (BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()))) { + boolean result + = reader.lines().anyMatch( + line -> line.matches(".*JDBC DriverManager initialized.*")); + assertTrue(result); + + } catch (IOException ex) { + Logger.getLogger(DriverManagerInitTests.class.getName()).log(Level.SEVERE, null, ex); + fail(); + } + + // Check to verify that we are not initializing a 2nd time + cw = new CharArrayWriter(); + pw = new PrintWriter(cw); + DriverManager.setLogWriter(pw); + drivers = DriverManager.getDrivers(); + + try (BufferedReader reader = new BufferedReader(new CharArrayReader(cw.toCharArray()))) { + boolean result + = reader.lines().noneMatch( + line -> line.matches(".*JDBC DriverManager initialized.*")); + assertTrue(result); + + } catch (IOException ex) { + Logger.getLogger(DriverManagerInitTests.class.getName()).log(Level.SEVERE, null, ex); + fail(); + } + + } + +} 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/Bug4322313.java b/jdk/test/java/text/Format/DateFormat/Bug4322313.java index bea772e63e6..b6ddef99a1b 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4322313.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4322313.java @@ -50,110 +50,110 @@ public class Bug4322313 extends IntlTest { Object[][] valids = { /* given ID offset format('z'), ('Z') index */ - {"GMT+03:04", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(9)}, - {"GMT+13:42", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(9)}, - {"GMT+00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, - {"GMT+1:11", new Long(-71 * mpm), "GMT+01:11", "+0111", new Integer(8)}, - {"GMT +13:42", new Long(0), "GMT", "+0000", new Integer(3)}, - {" GMT", new Long(0), "GMT", "+0000", new Integer(4)}, - {"+0304", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(5)}, - {"+1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(5)}, - {"+0000", new Long(0), "GMT+00:00", "+0000", new Integer(5)}, - {" +1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(6)}, + {"GMT+03:04", -184L * mpm, "GMT+03:04", "+0304", 9}, + {"GMT+13:42", -822L * mpm, "GMT+13:42", "+1342", 9}, + {"GMT+00:00", 0L, "GMT+00:00", "+0000", 9}, + {"GMT+1:11", -71L * mpm, "GMT+01:11", "+0111", 8}, + {"GMT +13:42", 0L, "GMT", "+0000", 3}, + {" GMT", 0L, "GMT", "+0000", 4}, + {"+0304", -184L * mpm, "GMT+03:04", "+0304", 5}, + {"+1342", -822L * mpm, "GMT+13:42", "+1342", 5}, + {"+0000", 0L, "GMT+00:00", "+0000", 5}, + {" +1342", -822L * mpm, "GMT+13:42", "+1342", 6}, /* ISO-LATIN-1 digits */ - {"GMT+\u0030\u0031:\u0032\u0033", new Long(-83 * mpm), "GMT+01:23", "+0123", new Integer(9)}, + {"GMT+\u0030\u0031:\u0032\u0033", -83L * mpm, "GMT+01:23", "+0123", 9}, /* In fact, this test case is skipped because TimeZone class can't * recognize TimeZone IDs like "+00234" or "-00234". */ - {"+00234", new Long(-23 * mpm), "GMT+00:23", "+0023", new Integer(5)}, + {"+00234", -23L * mpm, "GMT+00:23", "+0023", 5}, - {"GMT-03:04", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(9)}, - {"GMT-13:42", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(9)}, - {"GMT-00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, - {"GMT-1:11", new Long(71 * mpm), "GMT-01:11", "-0111", new Integer(8)}, - {"GMT -13:42", new Long(0), "GMT", "+0000", new Integer(3)}, - {"-0304", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(5)}, - {"-1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(5)}, - {" -1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(6)}, + {"GMT-03:04", 184L * mpm, "GMT-03:04", "-0304", 9}, + {"GMT-13:42", 822L * mpm, "GMT-13:42", "-1342", 9}, + {"GMT-00:00", 0L, "GMT+00:00", "+0000", 9}, + {"GMT-1:11", 71L * mpm, "GMT-01:11", "-0111", 8}, + {"GMT -13:42", 0L, "GMT", "+0000", 3}, + {"-0304", 184L * mpm, "GMT-03:04", "-0304", 5}, + {"-1342", 822L * mpm, "GMT-13:42", "-1342", 5}, + {" -1342", 822L * mpm, "GMT-13:42", "-1342", 6}, /* ISO-LATIN-1 digits */ - {"GMT-\u0030\u0031:\u0032\u0033", new Long(83 * mpm), "GMT-01:23", "-0123", new Integer(9)}, + {"GMT-\u0030\u0031:\u0032\u0033", 83L * mpm, "GMT-01:23", "-0123", 9}, /* In fact, this test case is skipped because TimeZone class can't * recognize TimeZone IDs like "+00234" or "-00234". */ - {"-00234", new Long(23 * mpm), "GMT+00:23", "-0023", new Integer(5)}, + {"-00234", 23L * mpm, "GMT+00:23", "-0023", 5}, }; Object[][] invalids = { /* given ID error index */ - {"GMT+8", new Integer(5)}, - {"GMT+18", new Integer(6)}, - {"GMT+208", new Integer(6)}, - {"GMT+0304", new Integer(6)}, - {"GMT+42195", new Integer(5)}, - {"GMT+5:8", new Integer(7)}, - {"GMT+23:60", new Integer(8)}, - {"GMT+11:1", new Integer(8)}, - {"GMT+24:13", new Integer(5)}, - {"GMT+421:950", new Integer(5)}, - {"GMT+0a:0A", new Integer(5)}, - {"GMT+ 13:42", new Integer(4)}, - {"GMT+13 :42", new Integer(6)}, - {"GMT+13: 42", new Integer(7)}, - {"GMT+-13:42", new Integer(4)}, - {"G M T", new Integer(0)}, - {"+8", new Integer(2)}, - {"+18", new Integer(3)}, - {"+208", new Integer(4)}, - {"+2360", new Integer(4)}, - {"+2413", new Integer(2)}, - {"+42195", new Integer(2)}, - {"+0AbC", new Integer(2)}, - {"+ 1342", new Integer(1)}, - {"+-1342", new Integer(1)}, - {"1342", new Integer(0)}, + {"GMT+8", 5}, + {"GMT+18", 6}, + {"GMT+208", 6}, + {"GMT+0304", 6}, + {"GMT+42195", 5}, + {"GMT+5:8", 7}, + {"GMT+23:60", 8}, + {"GMT+11:1", 8}, + {"GMT+24:13", 5}, + {"GMT+421:950", 5}, + {"GMT+0a:0A", 5}, + {"GMT+ 13:42", 4}, + {"GMT+13 :42", 6}, + {"GMT+13: 42", 7}, + {"GMT+-13:42", 4}, + {"G M T", 0}, + {"+8", 2}, + {"+18", 3}, + {"+208", 4}, + {"+2360", 4}, + {"+2413", 2}, + {"+42195", 2}, + {"+0AbC", 2}, + {"+ 1342", 1}, + {"+-1342", 1}, + {"1342", 0}, /* Arabic-Indic digits */ - {"GMT+\u0660\u0661:\u0662\u0663", new Integer(4)}, + {"GMT+\u0660\u0661:\u0662\u0663", 4}, /* Extended Arabic-Indic digits */ - {"GMT+\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, + {"GMT+\u06f0\u06f1:\u06f2\u06f3", 4}, /* Devanagari digits */ - {"GMT+\u0966\u0967:\u0968\u0969", new Integer(4)}, + {"GMT+\u0966\u0967:\u0968\u0969", 4}, /* Fullwidth digits */ - {"GMT+\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, + {"GMT+\uFF10\uFF11:\uFF12\uFF13", 4}, - {"GMT-8", new Integer(5)}, - {"GMT-18", new Integer(6)}, - {"GMT-208", new Integer(6)}, - {"GMT-0304", new Integer(6)}, - {"GMT-42195", new Integer(5)}, - {"GMT-5:8", new Integer(7)}, - {"GMT-23:60", new Integer(8)}, - {"GMT-11:1", new Integer(8)}, - {"GMT-24:13", new Integer(5)}, - {"GMT-421:950", new Integer(5)}, - {"GMT-0a:0A", new Integer(5)}, - {"GMT- 13:42", new Integer(4)}, - {"GMT-13 :42", new Integer(6)}, - {"GMT-13: 42", new Integer(7)}, - {"GMT-+13:42", new Integer(4)}, - {"-8", new Integer(2)}, - {"-18", new Integer(3)}, - {"-208", new Integer(4)}, - {"-2360", new Integer(4)}, - {"-2413", new Integer(2)}, - {"-42195", new Integer(2)}, - {"-0AbC", new Integer(2)}, - {"- 1342", new Integer(1)}, - {"--1342", new Integer(1)}, - {"-802", new Integer(2)}, + {"GMT-8", 5}, + {"GMT-18", 6}, + {"GMT-208", 6}, + {"GMT-0304", 6}, + {"GMT-42195", 5}, + {"GMT-5:8", 7}, + {"GMT-23:60", 8}, + {"GMT-11:1", 8}, + {"GMT-24:13", 5}, + {"GMT-421:950", 5}, + {"GMT-0a:0A", 5}, + {"GMT- 13:42", 4}, + {"GMT-13 :42", 6}, + {"GMT-13: 42", 7}, + {"GMT-+13:42", 4}, + {"-8", 2}, + {"-18", 3}, + {"-208", 4}, + {"-2360", 4}, + {"-2413", 2}, + {"-42195", 2}, + {"-0AbC", 2}, + {"- 1342", 1}, + {"--1342", 1}, + {"-802", 2}, /* Arabic-Indic digits */ - {"GMT-\u0660\u0661:\u0662\u0663", new Integer(4)}, + {"GMT-\u0660\u0661:\u0662\u0663", 4}, /* Extended Arabic-Indic digits */ - {"GMT-\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, + {"GMT-\u06f0\u06f1:\u06f2\u06f3", 4}, /* Devanagari digits */ - {"GMT-\u0966\u0967:\u0968\u0969", new Integer(4)}, + {"GMT-\u0966\u0967:\u0968\u0969", 4}, /* Fullwidth digits */ - {"GMT-\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, + {"GMT-\uFF10\uFF11:\uFF12\uFF13", 4}, }; try { diff --git a/jdk/test/java/text/Format/DateFormat/Bug4736959.java b/jdk/test/java/text/Format/DateFormat/Bug4736959.java index cdb9cad20b4..00fa8d0840a 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4736959.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4736959.java @@ -30,6 +30,7 @@ import java.text.*; import java.util.*; +@SuppressWarnings("deprecation") public class Bug4736959 { /** * 4736959: JSpinner won't work for AM/PM field diff --git a/jdk/test/java/text/Format/DateFormat/Bug4823811.java b/jdk/test/java/text/Format/DateFormat/Bug4823811.java index 524f790e1fb..b1f6c9d5b9d 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 */ @@ -684,8 +685,8 @@ public class Bug4823811 { testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG"); System.out.println("*** DecimalFormat.parse test in ar_EG"); - testNumberFormatParsing(nfEG, "123-", new Long(-123), "ar_EG"); - testNumberFormatParsing(nfEG, "123--", new Long(-123), "ar_EG"); + testNumberFormatParsing(nfEG, "123-", -123L, "ar_EG"); + testNumberFormatParsing(nfEG, "123--",-123L, "ar_EG"); testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG"); System.out.println("*** DecimalFormat.format test in en_US"); @@ -693,8 +694,8 @@ public class Bug4823811 { testNumberFormatFormatting(nfUS, -456, "-456", "en_US"); System.out.println("*** DecimalFormat.parse test in en_US"); - testNumberFormatParsing(nfUS, "123-", new Long(123), "en_US"); - testNumberFormatParsing(nfUS, "-123", new Long(-123), "en_US"); + testNumberFormatParsing(nfUS, "123-", 123L, "en_US"); + testNumberFormatParsing(nfUS, "-123",-123L, "en_US"); testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US"); } diff --git a/jdk/test/java/text/Format/DateFormat/Bug4845901.java b/jdk/test/java/text/Format/DateFormat/Bug4845901.java index a88b47a761e..363a3518bf0 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4845901.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4845901.java @@ -55,6 +55,7 @@ public class Bug4845901 { } } + @SuppressWarnings("deprecation") static void testParse(SimpleDateFormat sdf, String str, int expectedHour) { try { Date parsedDate = sdf.parse(str); diff --git a/jdk/test/java/text/Format/DateFormat/Bug6609750.java b/jdk/test/java/text/Format/DateFormat/Bug6609750.java index ccd5d5e814b..5529bc6c812 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug6609750.java +++ b/jdk/test/java/text/Format/DateFormat/Bug6609750.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 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 @@ -37,6 +37,7 @@ public class Bug6609750 { Locale defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); + @SuppressWarnings("deprecation") Date[] dates = { new Date(9-1900, Calendar.JUNE, 12), new Date(99-1900, Calendar.JUNE, 12), diff --git a/jdk/test/java/text/Format/DateFormat/Bug6683975.java b/jdk/test/java/text/Format/DateFormat/Bug6683975.java index e0c8cd75f15..0afdcd74c4a 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.*; @@ -65,6 +66,7 @@ public class Bug6683975 { System.err.println("\tth_TH: " + str_th_TH); } + @SuppressWarnings("deprecation") Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0); str_th = df_th.format(date); if (!expected_th[style].equals(str_th)) { 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/DateFormatRegression.java b/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java index 5c416b0dc53..d4230fb2cb7 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java @@ -41,7 +41,7 @@ public class DateFormatRegression extends IntlTest { } public void Test4029195() { - + @SuppressWarnings("deprecation") Date today = new Date(); logln("today: " + today); @@ -74,19 +74,20 @@ public class DateFormatRegression extends IntlTest { public void Test4052408() { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US); + @SuppressWarnings("deprecation") Date date = new Date(97, Calendar.MAY, 3, 8, 55); String str; logln(str = fmt.format(date)); if (!str.equals("5/3/97 8:55 AM")) errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str); - Hashtable expected = new Hashtable(); - expected.put(new Integer(DateFormat.MONTH_FIELD), "5"); - expected.put(new Integer(DateFormat.DATE_FIELD), "3"); - expected.put(new Integer(DateFormat.YEAR_FIELD), "97"); - expected.put(new Integer(DateFormat.HOUR1_FIELD), "8"); - expected.put(new Integer(DateFormat.MINUTE_FIELD), "55"); - expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM"); + Map expected = new HashMap<>(); + expected.put(DateFormat.MONTH_FIELD, "5"); + expected.put(DateFormat.DATE_FIELD, "3"); + expected.put(DateFormat.YEAR_FIELD, "97"); + expected.put(DateFormat.HOUR1_FIELD, "8"); + expected.put(DateFormat.MINUTE_FIELD, "55"); + expected.put(DateFormat.AM_PM_FIELD, "AM"); StringBuffer buf = new StringBuffer(); String fieldNames[] = { @@ -120,7 +121,7 @@ public class DateFormatRegression extends IntlTest { ", \"" + str + "\", " + pos.getBeginIndex() + ", " + pos.getEndIndex()); - String exp = (String) expected.get(new Integer(i)); + String exp = expected.get(i); if ((exp == null && str.length() == 0) || str.equals(exp)) logln(" ok"); @@ -135,6 +136,7 @@ public class DateFormatRegression extends IntlTest { /** * Verify the function of the [s|g]et2DigitYearStart() API. */ + @SuppressWarnings("deprecation") public void Test4056591() { try { SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US); @@ -255,6 +257,7 @@ public class DateFormatRegression extends IntlTest { if (!ok) errln("Fail: Lenient not working"); } + @SuppressWarnings("deprecation") public void Test4065240() { Date curDate; DateFormat shortdate, fulldate; @@ -297,6 +300,7 @@ public class DateFormatRegression extends IntlTest { Currently this bug breaks MessageFormat.toPattern */ + @SuppressWarnings("deprecation") public void Test4071441() { DateFormat fmtA = DateFormat.getInstance(); DateFormat fmtB = DateFormat.getInstance(); @@ -488,6 +492,7 @@ public class DateFormatRegression extends IntlTest { public void Test4101483() { SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US); FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD); + @SuppressWarnings("deprecation") Date d= new Date(9234567890L); StringBuffer buf = new StringBuffer(""); logln(sdf.format(d, buf, fp).toString()); @@ -508,6 +513,7 @@ public class DateFormatRegression extends IntlTest { public void Test4103340() { // choose a date that is the FIRST of some month // and some arbitrary time + @SuppressWarnings("deprecation") Date d=new Date(97, 3, 1, 1, 1, 1); SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US); @@ -538,6 +544,7 @@ public class DateFormatRegression extends IntlTest { sdf.applyPattern(pattern); logln("pattern: \"" + pattern + "\""); + @SuppressWarnings("deprecation") Object[] DATA = { "time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30), "time 10:x", new ParsePosition(0), null, @@ -698,6 +705,7 @@ public class DateFormatRegression extends IntlTest { String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; logln("pattern=" + pattern); SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); + @SuppressWarnings("deprecation") String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0)); if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) { errln("Fail: result=" + result); @@ -711,6 +719,7 @@ public class DateFormatRegression extends IntlTest { * 'z' at end of date format throws index exception in SimpleDateFormat * CANNOT REPRODUCE THIS BUG ON 1.2FCS */ + @SuppressWarnings("deprecation") public void Test4151706() { SimpleDateFormat fmt = new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US); @@ -755,6 +764,7 @@ public class DateFormatRegression extends IntlTest { * Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US * as "EST" or "CST", not Australian "EST" and "CST". */ + @SuppressWarnings("deprecation") public void Test4406615() { Locale savedLocale = Locale.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault(); @@ -823,6 +833,7 @@ public class DateFormatRegression extends IntlTest { * greater than "99", are treated as literal years. So "1/2/3456" * becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC. */ + @SuppressWarnings("deprecation") Object[] DATA = { "02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29), "01/23/01", new Date(2001-1900, Calendar.JANUARY, 23), @@ -878,6 +889,7 @@ public class DateFormatRegression extends IntlTest { DateFormat fmt = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(Locale.US)); fmt.getCalendar().setLenient(false); + @SuppressWarnings("deprecation") Date d = new Date(2000-1900, Calendar.FEBRUARY, 29); String s = fmt.format(d); logln(d + " x " + pattern + " => " + s); @@ -957,6 +969,7 @@ public class DateFormatRegression extends IntlTest { } } + @SuppressWarnings("deprecation") public void Test4253490() throws ParseException { SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US); @@ -1026,6 +1039,7 @@ public class DateFormatRegression extends IntlTest { public void Test4250359() { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US); + @SuppressWarnings("deprecation") Date d = new Date(1999-1900, Calendar.DECEMBER, 25, 1, 2, 3); String s = df.format(d); @@ -1052,6 +1066,7 @@ public class DateFormatRegression extends IntlTest { // pick up another time zone when L10N is done to that file. TimeZone.setDefault(TimeZone.getTimeZone("PST")); SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN); + @SuppressWarnings("deprecation") String result = fmt.format(new Date(1999, 0, 1)); logln("format()=>" + result); if (!result.endsWith("PST")) { diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java b/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java index 73d023163f1..9bf3ac3835a 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java @@ -104,7 +104,7 @@ public class DateFormatRoundTripTest extends IntlTest { String pat = null; Date date = null; - Vector newArgs = new Vector(); + List newArgs = new ArrayList<>(); for (int i=0; i#.###E00", 'm'); - test(new Double(1234), "

            1.234E03"); - test(new Double(0.1234), "

            1.234Em01"); - test(new Double(-1234), "m

            1.234E03"); - test(new Double(-0.1234), "m

            1.234Em01"); + test(1234D, "

            1.234E03"); + test(0.1234, "

            1.234Em01"); + test(-1234D, "m

            1.234E03"); + test(-0.1234, "m

            1.234Em01"); prepareFormatter("

            #.###E00;#.###E00", 'm'); - test(new Double(1234), "

            1.234E03"); - test(new Double(0.1234), "

            1.234Em01"); - test(new Double(-1234), "1.234E03"); - test(new Double(-0.1234), "1.234Em01"); + test(1234D, "

            1.234E03"); + test(0.1234, "

            1.234Em01"); + test(-1234D, "1.234E03"); + test(-0.1234, "1.234Em01"); prepareFormatter("#.###E00;

            #.###E00", 'm'); - test(new Double(1234), "1.234E03"); - test(new Double(0.1234), "1.234Em01"); - test(new Double(-1234), "

            1.234E03"); - test(new Double(-0.1234), "

            1.234Em01"); + test(1234D, "1.234E03"); + test(0.1234, "1.234Em01"); + test(-1234D, "

            1.234E03"); + test(-0.1234, "

            1.234Em01"); prepareFormatter("

            #.###E00;

            -#.###E00", 'm'); - test(new Double(1234), "

            1.234E03"); - test(new Double(0.1234), "

            1.234Em01"); - test(new Double(-1234), "

            m1.234E03"); - test(new Double(-0.1234), "

            m1.234Em01"); + test(1234D, "

            1.234E03"); + test(0.1234, "

            1.234Em01"); + test(-1234D, "

            m1.234E03"); + test(-0.1234, "

            m1.234Em01"); - test(new Double(Double.POSITIVE_INFINITY), "

            \u221e"); - test(new Double(Double.NEGATIVE_INFINITY), "

            m\u221e"); - test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix - test(new Double(0.0), "

            0E00"); - test(new Double(-0.0), "

            m0E00"); // with the minus sign + test(Double.POSITIVE_INFINITY, "

            \u221e"); + test(Double.NEGATIVE_INFINITY, "

            m\u221e"); + test(Double.NaN, "\ufffd"); // without prefix and suffix + test(0.0, "

            0E00"); + test(-0.0, "

            m0E00"); // with the minus sign } static void test_BigDecimal() { @@ -151,19 +151,19 @@ public class Bug4838107 extends IntlTest { dfs = df.getDecimalFormatSymbols(); /* Test with default pattern */ - test(new Long(123456789), "123,456,789"); - test(new Long(-123456789), "-123,456,789"); + test(123456789L, "123,456,789"); + test(-123456789L, "-123,456,789"); - test(new Long(0), "0"); - test(new Long(-0), "0"); + test(0L, "0"); + test(-0L, "0"); /* Specify a pattern and the minus sign. */ prepareFormatter("

            #,###;

            -#,###", 'm'); - test(new Long(123456789), "

            123,456,789"); - test(new Long(-123456789), "

            m123,456,789"); + test(123456789L, "

            123,456,789"); + test(-123456789L, "

            m123,456,789"); - test(new Long(0), "

            0"); - test(new Long(-0), "

            0"); + test(0L, "

            0"); + test(-0L, "

            0"); } static void test_BigInteger() { diff --git a/jdk/test/java/text/Format/NumberFormat/Bug4944439.java b/jdk/test/java/text/Format/NumberFormat/Bug4944439.java index beb4d77c235..0e85a98119d 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug4944439.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug4944439.java @@ -84,7 +84,7 @@ public class Bug4944439 { } int index = s.indexOf('.'); - Long l = new Long(s.substring(0, index)); + Long l = Long.valueOf(s.substring(0, index)); if (!l.equals(number)) { err = true; System.err.println("Failed: DecimalFormat.parse(" + s + @@ -101,7 +101,7 @@ public class Bug4944439 { number.getClass().getName()); } - Double d = new Double(s); + Double d = Double.valueOf(s); if (!d.equals(number)) { err = true; System.err.println("Failed: DecimalFormat.parse(" + s + diff --git a/jdk/test/java/text/Format/NumberFormat/Bug4990596.java b/jdk/test/java/text/Format/NumberFormat/Bug4990596.java index a8c03b8a035..2b311fb1b5f 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug4990596.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug4990596.java @@ -35,6 +35,7 @@ public class Bug4990596 { new DecimalFormat().format(new MutableInteger(0)); } + @SuppressWarnings("serial") public static class MutableInteger extends Number { public int value; diff --git a/jdk/test/java/text/Format/NumberFormat/Bug6278616.java b/jdk/test/java/text/Format/NumberFormat/Bug6278616.java index 9066a7da02e..b1684b4d177 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug6278616.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug6278616.java @@ -47,7 +47,7 @@ public class Bug6278616 { NumberFormat nf = NumberFormat.getInstance(); for (int j = 0; j < ints.length; j++) { - String s_i = nf.format(new Integer(ints[j])); + String s_i = nf.format(ints[j]); String s_ai = nf.format(new AtomicInteger(ints[j])); if (!s_i.equals(s_ai)) { throw new RuntimeException("format(AtomicInteger " + s_ai + @@ -57,7 +57,7 @@ public class Bug6278616 { } for (int j = 0; j < longs.length; j++) { - String s_l = nf.format(new Long(longs[j])); + String s_l = nf.format(longs[j]); String s_al = nf.format(new AtomicLong(longs[j])); if (!s_l.equals(s_al)) { throw new RuntimeException("format(AtomicLong " + s_al + 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..48147f35d2a 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 */ @@ -288,7 +289,7 @@ public class NumberRegression extends IntlTest { DecimalFormat df = new DecimalFormat(); Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0)); if (!d.toString().equals("123.55456")) { - errln("Result -> " + d.doubleValue()); + errln("Result -> " + d); } Locale.setDefault(savedLocale); } @@ -394,11 +395,11 @@ public class NumberRegression extends IntlTest { Locale.setDefault(Locale.US); DecimalFormat df = new DecimalFormat(); String str = "0.1234"; - Double d1 = new Double(str); + Double d1 = 0.1234; Double d2 = (Double) df.parse(str, new ParsePosition(0)); logln(d1.toString()); if (d2.doubleValue() != d1.doubleValue()) - errln("Bug 4095713 test failed, new double value : " + d2.doubleValue()); + errln("Bug 4095713 test failed, new double value : " + d2); Locale.setDefault(savedLocale); } @@ -869,7 +870,7 @@ public class NumberRegression extends IntlTest { DecimalFormat fmt = new DecimalFormat("#,##0.00"); StringBuffer formatted = new StringBuffer(); FieldPosition field = new FieldPosition(0); - Double num = new Double(1234.5); + Double num = 1234.5; fmt.format(num, formatted, field); if (field.getBeginIndex() != 0 && field.getEndIndex() != 5) errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex()); @@ -1415,7 +1416,7 @@ public class NumberRegression extends IntlTest { DecimalFormat fmt = new DecimalFormat("#", DecimalFormatSymbols.getInstance(Locale.US)); for (int i=0; i 0 != DATA[i] > 0) { errln("\"" + str + "\" parse(x " + fmt.getMultiplier() + ") => " + n); @@ -1636,15 +1637,15 @@ public class NumberRegression extends IntlTest { */ public void Test4217661() { Object[] DATA = { - new Double(0.001), "0", - new Double(1.001), "1", - new Double(0.006), "0.01", - new Double(1.006), "1.01", + 0.001, "0", + 1.001, "1", + 0.006, "0.01", + 1.006, "1.01", }; NumberFormat fmt = NumberFormat.getInstance(Locale.US); fmt.setMaximumFractionDigits(2); for (int i=0; i contents = parser.parse(new BufferedReader( new FileReader(file))); - Vector test = (Vector)contents.get("tests"); + List test = (List)contents.get("tests"); for (int counter = 0; counter < test.size(); counter++) { logln("creating: " + (counter / 2)); AttributedCharacterIterator iterator = - create((Hashtable)test.get(counter)); + create((Map)test.get(counter)); logln("verifying: " + (counter / 2)); - verify(iterator, (Hashtable)test.get(++counter)); + verify(iterator, (Map)test.get(++counter)); } } catch (IOException ioe) { errln("Error reading: " + ioe); } } - public void verify(AttributedCharacterIterator iterator,Hashtable table) { + @SuppressWarnings("unchecked") + public void verify(AttributedCharacterIterator iterator,Map table) { int length = Integer.parseInt((String)table.get("length")); // Verify the text @@ -185,10 +186,10 @@ public class FormatIteratorTest extends IntlTest { for (int counter = 0; counter < length; counter++) { iterator.setIndex(counter); if (!verifyAttributes(iterator.getAttributes().keySet(), - makeAttributes((Vector)table.get(Integer. + makeAttributes((List)table.get(Integer. toString(counter))))) { errln("Attributes don't match at " + counter + " expecting " + - makeAttributes((Vector)table.get(Integer.toString + makeAttributes((List)table.get(Integer.toString (counter))) + " got " + iterator.getAttributes().keySet()); } @@ -196,10 +197,10 @@ public class FormatIteratorTest extends IntlTest { for (int counter = length - 1; counter >= 0; counter--) { iterator.setIndex(counter); if (!verifyAttributes(iterator.getAttributes().keySet(), - makeAttributes((Vector)table.get(Integer. + makeAttributes((List)table.get(Integer. toString(counter))))) { errln("Attributes don't match at " + counter + " expecting " + - makeAttributes((Vector)table.get(Integer.toString + makeAttributes((List)table.get(Integer.toString (counter))) + " got " + iterator.getAttributes().keySet()); } @@ -207,31 +208,33 @@ public class FormatIteratorTest extends IntlTest { verifyLimits(iterator, table); text = escapeIfNecessary((String)table.get("text")); - Vector fps = (Vector)table.get("fieldPositions"); + List fps = (List)table.get("fieldPositions"); if (fps != null) { for (int counter = 0; counter < fps.size(); counter++) { - verifyFieldPosition(counter, (Hashtable)fps.get(counter)); + verifyFieldPosition(counter,(Map)fps.get(counter)); } } } + @SuppressWarnings("unchecked") private void verifyLimits(AttributedCharacterIterator iterator, - Hashtable table) { - Vector limits = (Vector)table.get("limits"); + Map table) { + List limits = (List)table.get("limits"); if (limits != null) { for (int counter = 0; counter < limits.size(); counter++) { - verifyLimit(iterator, (Hashtable)limits.get(counter)); + verifyLimit(iterator, (Map)limits.get(counter)); } } } private void verifyLimit(AttributedCharacterIterator iterator, - Hashtable table) { + Map table) { int begin = Integer.parseInt((String)table.get("begin")); int end = Integer.parseInt((String)table.get("end")); - Set attrs = makeAttributes((Vector)table.get("attributes")); + @SuppressWarnings("unchecked") + Set attrs = makeAttributes((List)table.get("attributes")); String begin2S = (String)table.get("begin2"); int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin; String end2S = (String)table.get("end2"); @@ -262,9 +265,9 @@ public class FormatIteratorTest extends IntlTest { } } - private boolean verifyAttributes(Set a, Set b) { - boolean aEmpty = (a.size() == 0); - boolean bEmpty = (b.size() == 0); + private boolean verifyAttributes(Set a, Set b) { + boolean aEmpty = a.isEmpty(); + boolean bEmpty = b.isEmpty(); if (aEmpty && bEmpty) { return true; @@ -284,14 +287,14 @@ public class FormatIteratorTest extends IntlTest { return buffer.toString(); } - private void verifyFieldPosition(int index, Hashtable table) { + private void verifyFieldPosition(int index, Map table) { Object o = table.get("field"); int begin = Integer.parseInt((String)table.get("begin")); int end = Integer.parseInt((String)table.get("end")); if (o != null) { FieldPosition fp = new FieldPosition(((Integer) - lookupField((String)o)).intValue()); + lookupField((String)o))); verifyFieldPosition(fp, begin, end, index); } @@ -322,11 +325,11 @@ public class FormatIteratorTest extends IntlTest { } } - public AttributedCharacterIterator create(Hashtable table) { + public AttributedCharacterIterator create(Map table) { format = (Format)createInstance((String)table.get("class"), - ((Vector)table.get("args")).toArray()); + ((List)table.get("args")).toArray()); value = createInstance((String)table.get("valueClass"), - ((Vector)table.get("valueArgs")).toArray()); + ((List)table.get("valueArgs")).toArray()); logln("Created format: " + format + " value " + value); AttributedCharacterIterator aci = format. @@ -343,11 +346,12 @@ public class FormatIteratorTest extends IntlTest { private Object createInstance(String className, Object[] args) { if (className.equals("java.lang.reflect.Array")) { for (int counter = 0; counter < args.length; counter++) { - if (args[counter] instanceof Vector) { - Vector v = (Vector)args[counter]; + if (args[counter] instanceof List) { + @SuppressWarnings("unchecked") + List v = (List)args[counter]; args[counter] = createInstance((String)v.get(0), - ((Vector)v.get(1)).toArray()); + ((List)v.get(1)).toArray()); } } return args; @@ -361,9 +365,9 @@ public class FormatIteratorTest extends IntlTest { } else if (className.equals("java.util.concurrent.atomic.AtomicLong")) { return new AtomicLong(Long.valueOf((String)args[0])); } else { - Class klass = lookupClass(className); - Constructor cons = klass.getConstructor( - new Class[] { String.class }); + Class klass = lookupClass(className); + Constructor cons = klass.getConstructor( + new Class[] { String.class }); Object value = cons.newInstance(args); return value; @@ -374,20 +378,20 @@ public class FormatIteratorTest extends IntlTest { } } - private Class lookupClass(String name) throws ClassNotFoundException { + private Class lookupClass(String name) throws ClassNotFoundException { try { - Class klass = Class.forName(name); + Class klass = Class.forName(name); return klass; } catch (ClassNotFoundException e1) {} try { - Class klass = Class.forName("java.lang." + name); + Class klass = Class.forName("java.lang." + name); return klass; } catch (ClassNotFoundException e1) {} - Class klass = Class.forName("java.text." + name); + Class klass = Class.forName("java.text." + name); return klass; } @@ -397,7 +401,7 @@ public class FormatIteratorTest extends IntlTest { try { int dotIndex = name.indexOf('.'); - Class klass = lookupClass(name.substring(0, dotIndex)); + Class klass = lookupClass(name.substring(0, dotIndex)); String fieldName = name.substring(dotIndex + 1); Field[] fields = klass.getFields(); @@ -429,8 +433,8 @@ public class FormatIteratorTest extends IntlTest { return string; } - public Set makeAttributes(Vector names) { - HashSet set = new HashSet(Math.max(1, names.size())); + public Set makeAttributes(List names) { + Set set = new HashSet<>(Math.max(1, names.size())); for (int counter = 0; counter < names.size(); counter++) { set.add(makeAttribute((String)names.get(counter))); diff --git a/jdk/test/java/text/Format/common/PParser.java b/jdk/test/java/text/Format/common/PParser.java index 6ada76b1059..eb7ccd11315 100644 --- a/jdk/test/java/text/Format/common/PParser.java +++ b/jdk/test/java/text/Format/common/PParser.java @@ -58,7 +58,7 @@ public class PParser { public PParser() { } - public Hashtable parse(Reader r) throws IOException { + public Map parse(Reader r) throws IOException { this.reader = r; bufferedToken = false; lineNumber = 0; @@ -91,23 +91,23 @@ public class PParser { } protected Object parseArray() throws IOException { - Vector array = new Vector(); - int token; + List array = new ArrayList<>(); + int token; while ((token = getToken()) != CLOSE_ARRAY) { if (token == MORE) { token = getToken(); } if (token != CLOSE_ARRAY) { - array.addElement(parseValue(token)); + array.add(parseValue(token)); } } return array; } - protected Hashtable parsePair() throws IOException { - Hashtable ht = new Hashtable(11); - int token; + protected Map parsePair() throws IOException { + Map ht = new HashMap<>(11); + int token; while ((token = getToken()) != CLOSE_PAIR) { if (token != STRING) { @@ -133,11 +133,12 @@ public class PParser { } protected int getToken() throws IOException { - int token = getToken(false, false); + int token = getToken(false, false); return token; } + @SuppressWarnings("fallthrough") protected int getToken(boolean wantsWS, boolean inString) throws IOException { if (bufferedToken) { @@ -225,31 +226,26 @@ public class PParser { throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column); } + @SuppressWarnings("unchecked") public static void dump(Object o) { if (o instanceof String) { System.out.print(o); - } else if(o instanceof Vector) { - Enumeration e = ((Vector)o).elements(); - + } else if(o instanceof List) { dump(" ("); - while (e.hasMoreElements()) { - dump(e.nextElement()); + ((List)o).forEach((l) -> { + dump(l); dump(" -- "); - } + }); dump(" )"); } else { - Hashtable ht = (Hashtable)o; - Enumeration e = ht.keys(); - + Map ht = (Map)o; dump(" {"); - while (e.hasMoreElements()) { - Object key = e.nextElement(); - - dump(key); + ht.keySet().forEach(l -> { + dump(l); dump(" = "); - dump(ht.get(key)); + dump(ht.get(l)); dump(";"); - } + }); dump(" }"); } } @@ -259,9 +255,9 @@ public class PParser { System.out.println("need filename"); } else { try { - FileReader fr = new FileReader(args[0]); - PParser parser = new PParser(); - Hashtable ht = parser.parse(fr); + FileReader fr = new FileReader(args[0]); + PParser parser = new PParser(); + Map ht = parser.parse(fr); dump(ht); System.out.println(); 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/Currency/ValidateISO4217.java b/jdk/test/java/util/Currency/ValidateISO4217.java index 98fc0a00d8a..f482cfd66c8 100644 --- a/jdk/test/java/util/Currency/ValidateISO4217.java +++ b/jdk/test/java/util/Currency/ValidateISO4217.java @@ -23,7 +23,7 @@ /* * @test * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759 - * 8039317 8074350 8074351 + * 8039317 8074350 8074351 8145952 * @summary Validate ISO 4217 data for Currency class. */ @@ -93,7 +93,7 @@ public class ValidateISO4217 { /* Codes that are obsolete, do not have related country */ static final String otherCodes = - "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR"; + "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZMK-ZWD-ZWN-ZWR"; static boolean err = false; diff --git a/jdk/test/java/util/Currency/tablea1.txt b/jdk/test/java/util/Currency/tablea1.txt index dacc0fb5210..0ef755a7a87 100644 --- a/jdk/test/java/util/Currency/tablea1.txt +++ b/jdk/test/java/util/Currency/tablea1.txt @@ -1,12 +1,12 @@ # # -# Amendments up until ISO 4217 AMENDMENT NUMBER 160 -# (As of 19 June 2015) +# Amendments up until ISO 4217 AMENDMENT NUMBER 162 +# (As of 30 Auguest 2016) # # Version FILEVERSION=3 -DATAVERSION=160 +DATAVERSION=162 # ISO 4217 currency data AF AFN 971 2 @@ -28,7 +28,7 @@ BS BSD 44 2 BH BHD 48 3 BD BDT 50 2 BB BBD 52 2 -BY BYR 974 0 +BY BYN 933 2 BE EUR 978 2 BZ BZD 84 2 BJ XOF 952 0 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/Level/CustomLevel.java b/jdk/test/java/util/logging/Level/CustomLevel.java index a3c452a1e09..8045831d33c 100644 --- a/jdk/test/java/util/logging/Level/CustomLevel.java +++ b/jdk/test/java/util/logging/Level/CustomLevel.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 @@ -22,12 +22,20 @@ */ import java.io.*; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; import java.util.*; import java.util.logging.*; /* * @test - * @bug 8026027 + * @bug 8026027 6543126 * @summary Test Level.parse to look up custom levels by name and its * localized name * @@ -41,23 +49,168 @@ public class CustomLevel extends Level { private static final List levels = new ArrayList<>(); private static final String RB_NAME = "myresource"; + private static final String OTHERRB_NAME = "myresource2"; + + private static class CustomLevelReference extends WeakReference { + final String name; + final int value; + final String resourceBundleName; + public CustomLevelReference(Level level, ReferenceQueue queue) { + super(level, queue); + name = level.getName(); + value = level.intValue(); + resourceBundleName = level.getResourceBundleName(); + } + + @Override + public String toString() { + return "CustomLevelReference(\"" + name + "\", " + value + ", \"" + + resourceBundleName + "\")"; + } + + } + public static void main(String[] args) throws Exception { setupCustomLevels(); + setUpCustomLevelsOtherLoader(); // Level.parse will return the custom Level instance - ResourceBundle rb = ResourceBundle.getBundle(RB_NAME); for (Level level : levels) { + final ResourceBundle rb = getResourceBundle(level); String name = level.getName(); - if (!name.equals("WARNING") && !name.equals("INFO")) { + Level l = Level.parse(name); + if (!name.equals("WARNING") && !name.equals("INFO") + && !name.equals("SEVERE")) { // custom level whose name doesn't conflict with any standard one - checkCustomLevel(Level.parse(name), level); + checkCustomLevel(l, level); + } else if (l != Level.WARNING && l != Level.INFO && l != Level.SEVERE + || !name.equals(l.getName())) { + throw new RuntimeException("Unexpected level " + formatLevel(l)); } + System.out.println("Level.parse found expected level: " + + formatLevel(l)); String localizedName = rb.getString(level.getName()); - Level l = Level.parse(localizedName); + l = Level.parse(localizedName); if (l != level) { - throw new RuntimeException("Unexpected level " + l + " " + l.getClass()); + throw new RuntimeException("Unexpected level " + l + " " + + l.getClass() + " for " + localizedName + + " in " + rb.getBaseBundleName()); } } + + final long otherLevelCount = levels.stream() + .filter(CustomLevel::isCustomLoader) + .count(); + + // Now verify that custom level instances are correctly + // garbage collected when no longer referenced + ReferenceQueue queue = new ReferenceQueue<>(); + List refs = new ArrayList<>(); + List customRefs = new ArrayList<>(); + int otherLevels = 0; + while (!levels.isEmpty()) { + Level l = levels.stream().findAny().get(); + boolean isCustomLoader = isCustomLoader(l); + if (isCustomLoader) otherLevels++; + + CustomLevelReference ref = new CustomLevelReference(l, queue); + if (isCustomLoader) { + customRefs.add(ref); + } else { + refs.add(ref); + } + + // remove strong references to l + levels.remove(l); + l = null; + + // Run gc and wait for garbage collection + if (otherLevels == otherLevelCount) { + if (customRefs.size() != otherLevelCount) { + throw new RuntimeException("Test bug: customRefs.size() != " + + otherLevelCount); + } + waitForGC(customRefs, queue); + } + } + if (otherLevelCount != otherLevels || otherLevelCount == 0) { + throw new RuntimeException("Test bug: " + + "no or wrong count of levels loaded from custom loader"); + } + if (!customRefs.isEmpty()) { + throw new RuntimeException( + "Test bug: customRefs.size() should be empty!"); + } + while (!refs.isEmpty()) { + final Reference ref = refs.remove(0); + if (ref.get() == null) { + throw new RuntimeException("Unexpected garbage collection for " + + ref); + } + } + } + + private static void waitForGC(List customRefs, + ReferenceQueue queue) + throws InterruptedException + { + while (!customRefs.isEmpty()) { + Reference ref2; + do { + System.gc(); + Thread.sleep(100); + } while ((ref2 = queue.poll()) == null); + + // Check garbage collected reference + if (!customRefs.contains(ref2)) { + throw new RuntimeException("Unexpected reference: " + ref2); + } + CustomLevelReference ref = customRefs.remove(customRefs.indexOf(ref2)); + System.out.println(ref2 + " garbage collected"); + final String name = ref.name; + Level l; + try { + l = Level.parse(name); + if (!name.equals("SEVERE") + && !name.equals("INFO") + || !name.equals(l.getName())) { + throw new RuntimeException("Unexpected level " + + formatLevel(l)); + } else { + if (l == Level.WARNING || l == Level.INFO + || l == Level.SEVERE) { + System.out.println("Level.parse found expected level: " + + formatLevel(l)); + } else { + throw new RuntimeException("Unexpected level " + + formatLevel(l)); + } + } + } catch (IllegalArgumentException iae) { + if (!name.equals("WARNING") + && !name.equals("INFO") + && !name.equals("SEVERE")) { + System.out.println("Level.parse fired expected exception: " + + iae); + } else { + throw iae; + } + } + } + } + + private static boolean isCustomLoader(Level level) { + final ClassLoader cl = level.getClass().getClassLoader(); + return cl != null + && cl != ClassLoader.getPlatformClassLoader() + && cl != ClassLoader.getSystemClassLoader(); + } + + static ResourceBundle getResourceBundle(Level level) { + return isCustomLoader(level) + ? ResourceBundle.getBundle(OTHERRB_NAME, Locale.getDefault(), + level.getClass().getClassLoader()) + : ResourceBundle.getBundle(RB_NAME); } private static void setupCustomLevels() throws IOException { @@ -67,22 +220,53 @@ public class CustomLevel extends Level { levels.add(new CustomLevel("WARNING", 1010, RB_NAME)); levels.add(new CustomLevel("INFO", 1000, RB_NAME)); } + + static void setUpCustomLevelsOtherLoader() + throws MalformedURLException, + ClassNotFoundException, NoSuchMethodException, + IllegalAccessException, InvocationTargetException + { + final String classes = System.getProperty("test.classes", + "build/classes"); + final String sources = System.getProperty("test.src", + "src"); + final URL curl = new File(classes).toURI().toURL(); + final URL surl = new File(sources).toURI().toURL(); + URLClassLoader loader = new URLClassLoader(new URL[] {curl, surl}, + ClassLoader.getPlatformClassLoader()); + Class customLevelClass = Class.forName("CustomLevel", false, loader); + Method m = customLevelClass.getMethod("setUpCustomLevelsOtherLoader", + List.class); + m.invoke(null, levels); + } + + public static void setUpCustomLevelsOtherLoader(List levels) { + levels.add(new CustomLevel("OTHEREMERGENCY", 1091, OTHERRB_NAME)); + levels.add(new CustomLevel("OTHERALERT", 1061, OTHERRB_NAME)); + levels.add(new CustomLevel("OTHERCRITICAL", 1031, OTHERRB_NAME)); + levels.add(new CustomLevel("SEVERE", 1011, OTHERRB_NAME)); + levels.add(new CustomLevel("INFO", 1000, OTHERRB_NAME)); + } + static void checkCustomLevel(Level level, Level expected) { // Level value must be the same if (!level.equals(expected)) { - throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + throw new RuntimeException(formatLevel(level) + " != " + + formatLevel(expected)); } if (!level.getName().equals(expected.getName())) { - throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + throw new RuntimeException(formatLevel(level) + " != " + + formatLevel(expected)); } // Level.parse is expected to return the custom Level if (level != expected) { - throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + throw new RuntimeException(formatLevel(level) + " != " + + formatLevel(expected)); } - ResourceBundle rb = ResourceBundle.getBundle(RB_NAME); + final ResourceBundle rb = getResourceBundle(level); String name = rb.getString(level.getName()); if (!level.getLocalizedName().equals(name)) { // must have the same localized name diff --git a/jdk/test/java/util/logging/Level/myresource2.properties b/jdk/test/java/util/logging/Level/myresource2.properties new file mode 100644 index 00000000000..b7e68d4673a --- /dev/null +++ b/jdk/test/java/util/logging/Level/myresource2.properties @@ -0,0 +1,5 @@ +OTHEREMERGENCY=localized.otheremergency +OTHERALERT=localized.otheralert +OTHERCRITICAL=localized.othercritical +SEVERE=localized.severe +INFO=localized.info.2 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/ReadAbortTest.java b/jdk/test/javax/imageio/ReadAbortTest.java new file mode 100644 index 00000000000..7476dbe0de8 --- /dev/null +++ b/jdk/test/javax/imageio/ReadAbortTest.java @@ -0,0 +1,181 @@ +/* + * 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 4924727 + * @summary Test verifies that if we call ImageReader.abort() in + * IIOReadProgressListener.imageStarted() or + * IIOReadProgressListener.imageProgress() are we + * calling IIOReadProgressListener.readAborted() for all readers. + * @run main ReadAbortTest + */ +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Iterator; +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.event.IIOReadProgressListener; +import javax.imageio.stream.ImageInputStream; +import java.awt.Color; +import java.awt.Graphics2D; +import java.nio.file.Files; + +public class ReadAbortTest implements IIOReadProgressListener { + + ImageReader reader = null; + ImageInputStream iis = null; + BufferedImage bimg = null; + File file; + boolean startAbort = false; + boolean startAborted = false; + boolean progressAbort = false; + boolean progressAborted = false; + Color srccolor = Color.red; + int width = 100; + int heght = 100; + + public ReadAbortTest(String format) throws Exception { + try { + System.out.println("Test for format " + format); + bimg = new BufferedImage(width, heght, + BufferedImage.TYPE_INT_RGB); + + Graphics2D g = bimg.createGraphics(); + g.setColor(srccolor); + g.fillRect(0, 0, width, heght); + g.dispose(); + + file = File.createTempFile("src_", "." + format, new File(".")); + ImageIO.write(bimg, format, file); + ImageInputStream iis = ImageIO.createImageInputStream(file); + + Iterator iter = ImageIO.getImageReaders(iis); + while (iter.hasNext()) { + reader = (ImageReader) iter.next(); + break; + } + reader.setInput(iis); + reader.addIIOReadProgressListener(this); + + // Abort reading in IIOReadProgressListener.imageStarted(). + startAbort = true; + bimg = reader.read(0); + startAbort = false; + + // Abort reading in IIOReadProgressListener.imageProgress(). + progressAbort = true; + bimg = reader.read(0); + progressAbort = false; + + iis.close(); + /* + * All abort requests from imageStarted,imageProgress and + * imageComplete from IIOReadProgressListener should be reached + * otherwise throw RuntimeException. + */ + if (!(startAborted + && progressAborted)) { + throw new RuntimeException("All IIOReadProgressListener abort" + + " requests are not processed for format " + + format); + } + } catch (Exception e) { + throw e; + } finally { + Files.delete(file.toPath()); + } + } + + /* + * Abstract methods that we need to implement from + * IIOReadProgressListener, and relevant for this test case. + */ + @Override + public void imageStarted(ImageReader source, int imageIndex) { + System.out.println("imageStarted called"); + if (startAbort) { + source.abort(); + } + } + + @Override + public void imageProgress(ImageReader source, float percentageDone) { + System.out.println("imageProgress called"); + if (progressAbort) { + source.abort(); + } + } + + @Override + public void readAborted(ImageReader source) { + System.out.println("readAborted called"); + // Verify IIOReadProgressListener.imageStarted() abort request. + if (startAbort) { + System.out.println("imageStarted aborted "); + startAborted = true; + } + + // Verify IIOReadProgressListener.imageProgress() abort request. + if (progressAbort) { + System.out.println("imageProgress aborted "); + progressAborted = true; + } + } + + public static void main(String args[]) throws Exception { + final String[] formats = {"bmp", "png", "gif", "jpg", "tif"}; + for (String format : formats) { + new ReadAbortTest(format); + } + } + + /* + * Remaining abstract methods that we need to implement from + * IIOReadProgressListener, but not relevant for this test case. + */ + @Override + public void imageComplete(ImageReader source) { + } + + @Override + public void sequenceStarted(ImageReader reader, int i) { + } + + @Override + public void sequenceComplete(ImageReader reader) { + } + + @Override + public void thumbnailStarted(ImageReader reader, int i, int i1) { + } + + @Override + public void thumbnailProgress(ImageReader reader, float f) { + } + + @Override + public void thumbnailComplete(ImageReader reader) { + } +} + 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/net/ssl/DTLS/CipherSuite.java b/jdk/test/javax/net/ssl/DTLS/CipherSuite.java index 259b09c8e17..cfca351e1cb 100644 --- a/jdk/test/javax/net/ssl/DTLS/CipherSuite.java +++ b/jdk/test/javax/net/ssl/DTLS/CipherSuite.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 @@ -30,6 +30,7 @@ * @key intermittent * @summary Datagram Transport Layer Security (DTLS) * @modules java.base/sun.security.util + * jdk.crypto.ec * @build DTLSOverDatagram * @run main/othervm CipherSuite TLS_RSA_WITH_AES_128_CBC_SHA * @run main/othervm CipherSuite TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.java index 82d66a9e538..8ebbc44e461 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSBufferOverflowUnderflowTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS buffer overflow and underflow status when dealing with * application data. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.base/sun.security.util + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSBufferOverflowUnderflowTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.java index 4a2b5ad08e7..94f3a1ba170 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSDataExchangeTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java index d9441e48233..fc987a3e5c1 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSEnginesClosureTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.java index 6841053869c..aaf155d5444 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSHandshakeTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.java index c345e82be94..b3b26bc75cc 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSHandshakeWithReplicatedPacketsTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites with replicated packets check. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSHandshakeWithReplicatedPacketsTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java index 1e0c6b6e629..9bc2b10a725 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS incorrect app data packages unwrapping. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSIncorrectAppDataTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.java index d9e038cc9c2..e44246fc3a6 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSMFLNTest.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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSMFLNTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java b/jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java index fa26b5261ae..3b5bee35e95 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSNotEnabledRC4Test.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,13 @@ * @bug 8043758 * @summary Testing DTLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS DTLSNotEnabledRC4Test */ diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.java index 2952dfcbdeb..2e1c9d56cc4 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java index 55cb62294bb..ff7bac90ea3 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * DTLSRehandshakeWithCipherChangeTest */ diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.java index de0f500e3de..dff5a8a0c1f 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithDataExTest.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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java index b9291a189e4..7eb019d95df 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.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 @@ -28,6 +28,14 @@ * data exchange. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS * -Dtest.mode=norm DTLSSequenceNumberTest * @run main/othervm -Dtest.security.protocol=DTLS diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java index 15569a7dd9d..e7c51741e69 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSUnsupportedCiphersTest.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 @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLS DTLSUnsupportedCiphersTest */ diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.java index 96d762fb398..bcbdd753389 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10BufferOverflowUnderflowTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS buffer overflow and underflow status when dealing with * application data. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10BufferOverflowUnderflowTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java index 66acc50d68b..0a73dbf61b9 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10DataExchangeTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10DataExchangeTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java index db8b660ce4a..c84c364af48 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10EnginesClosureTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10EnginesClosureTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.java index 79976dfb9f9..9ed88f685af 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10HandshakeTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.java index 14bf25b94fd..92b5dab1880 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10HandshakeWithReplicatedPacketsTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines handshake using each of the supported * cipher suites with replicated packets check. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10HandshakeWithReplicatedPacketsTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java index 6e3035f6aec..43567e5c0d9 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS incorrect app data packages unwrapping. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSIncorrectAppDataTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.java index 0fa34feb850..61a38889c06 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10MFLNTest.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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10MFLNTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.java index bc72a159d8c..a4d4f4394f3 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10NotEnabledRC4Test.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,13 @@ * @bug 8043758 * @summary Testing DTLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 DTLSv10NotEnabledRC4Test */ diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.java index be2c990e7cf..4af0fc0e0af 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing DTLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10RehandshakeTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java index 0fedfea2d05..7677baa76c5 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * DTLSv10RehandshakeWithCipherChangeTest */ diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.java index 24a4d81e4a4..560e924d322 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithDataExTest.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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10RehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.java index 7a1fa07d7c9..edf14364002 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10SequenceNumberTest.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 @@ -28,6 +28,14 @@ * data exchange. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * -Dtest.mode=norm DTLSv10SequenceNumberTest * @run main/othervm -Dtest.security.protocol=DTLSv1.0 diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.java index 0e656eaad90..2d10634c71e 100644 --- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.java +++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10UnsupportedCiphersTest.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 @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=DTLSv1.0 * DTLSv10UnsupportedCiphersTest */ diff --git a/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java b/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java index 8d7c1b2a716..0f51afd3959 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.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 @@ -21,18 +21,19 @@ * questions. */ -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.List; -import javax.net.ssl.SSLContext; - /* * @test * @bug 8049432 8069038 * @summary New tests for TLS property jdk.tls.client.protocols * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be * updated for JDK-8061210 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm TLSClientPropertyTest NoProperty * @run main/othervm TLSClientPropertyTest SSLv3 * @run main/othervm TLSClientPropertyTest TLSv1 @@ -41,6 +42,12 @@ import javax.net.ssl.SSLContext; * @run main/othervm TLSClientPropertyTest WrongProperty */ +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.List; +import javax.net.ssl.SSLContext; + /** * Sets the property jdk.tls.client.protocols to one of this protocols: * SSLv3,TLSv1,TLSv1.1,TLSv1.2 and TLSV(invalid) or removes this diff --git a/jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.java b/jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.java index 1d3e49efc42..8a2957b2f5d 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSDataExchangeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSDataExchangeTest diff --git a/jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.java b/jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.java index 4c9dea4a427..65d8d6c4990 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSEnginesClosureTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSEnginesClosureTest diff --git a/jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.java b/jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.java index 0ae33347a2e..9b09fe2a928 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSHandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSHandshakeTest diff --git a/jdk/test/javax/net/ssl/TLS/TLSMFLNTest.java b/jdk/test/javax/net/ssl/TLS/TLSMFLNTest.java index cde859e891b..edd8898f4a5 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSMFLNTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSMFLNTest.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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSMFLNTest diff --git a/jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.java b/jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.java index 37dd90efc1a..38b7116f71c 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.java +++ b/jdk/test/javax/net/ssl/TLS/TLSNotEnabledRC4Test.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,13 @@ * @bug 8085979 * @summary Testing TLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS TLSNotEnabledRC4Test */ diff --git a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.java b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.java index 09d93ccb761..36be822b53e 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSRehandshakeTest diff --git a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java index c16b673dbed..cc8fc79d994 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS TLSRehandshakeWithCipherChangeTest */ diff --git a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.java b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.java index a84cd914e72..0b277b2432a 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithDataExTest.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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=norm_sni TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLS -Dtest.mode=krb TLSRehandshakeWithDataExTest diff --git a/jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.java b/jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.java index 300ab9b84e6..843f9678574 100644 --- a/jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.java +++ b/jdk/test/javax/net/ssl/TLS/TLSUnsupportedCiphersTest.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 @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ktab + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLS TLSUnsupportedCiphersTest */ diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.java index 47748467a09..4e357e5755d 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSDataExchangeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSDataExchangeTest diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.java index fa875962256..e0418c495d0 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSEnginesClosureTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSEnginesClosureTest diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.java index f48666a40eb..bddcc189a39 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSHandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSHandshakeTest diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.java index 6df9debe003..8b213eb1e2a 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSMFLNTest.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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSMFLNTest diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.java b/jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.java index d00b09dd382..1a8f544ab84 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSNotEnabledRC4Test.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,13 @@ * @bug 8085979 * @summary Testing TLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 TLSNotEnabledRC4Test */ diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.java index acb69f0ad61..8208b6bf255 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSRehandshakeTest diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java index cf634faabb6..3eb59d07cfe 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 TLSRehandshakeWithCipherChangeTest */ diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.java index 601ed311a40..17cce20c001 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithDataExTest.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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=norm_sni TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1 -Dtest.mode=krb TLSRehandshakeWithDataExTest diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.java index 7cea3e5c2bd..357b9e4dab8 100644 --- a/jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.java +++ b/jdk/test/javax/net/ssl/TLSv1/TLSUnsupportedCiphersTest.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 @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1 TLSUnsupportedCiphersTest */ diff --git a/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java b/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java index 97383271dae..3e86849470c 100644 --- a/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.java +++ b/jdk/test/javax/net/ssl/TLSv11/EmptyCertificateAuthorities.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 @@ -33,14 +33,33 @@ * @bug 4873188 * @summary Support TLS 1.1 * @run main/othervm EmptyCertificateAuthorities + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import java.security.*; -import java.security.cert.*; -import javax.net.ssl.*; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.KeyStore; +import java.security.Security; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; public class EmptyCertificateAuthorities { diff --git a/jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java b/jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java index 1a2c1801ea6..a8f944084a6 100644 --- a/jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java +++ b/jdk/test/javax/net/ssl/TLSv11/ExportableBlockCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 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 @@ -33,12 +33,25 @@ * @bug 4873188 * @summary Support TLS 1.1 * @run main/othervm ExportableBlockCipher + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import javax.net.ssl.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class ExportableBlockCipher { diff --git a/jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java b/jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java index 6686c4c3837..47939ecdd76 100644 --- a/jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java +++ b/jdk/test/javax/net/ssl/TLSv11/ExportableStreamCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 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 @@ -32,13 +32,26 @@ * @test * @bug 4873188 * @summary Support TLS 1.1 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm ExportableStreamCipher * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import javax.net.ssl.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class ExportableStreamCipher { diff --git a/jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java b/jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java index 5f851843ffb..067da2ab322 100644 --- a/jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java +++ b/jdk/test/javax/net/ssl/TLSv11/GenericBlockCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 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 @@ -27,6 +27,13 @@ * @test * @bug 4873188 * @summary Support TLS 1.1 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm GenericBlockCipher * * SunJSSE does not support dynamic system properties, no way to re-use @@ -35,9 +42,12 @@ * @author Xuelei Fan */ -import java.io.*; -import java.net.*; -import javax.net.ssl.*; +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class GenericBlockCipher { diff --git a/jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java b/jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java index 38dbaf2a9f5..e84f0149982 100644 --- a/jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.java +++ b/jdk/test/javax/net/ssl/TLSv11/GenericStreamCipher.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 @@ -27,6 +27,13 @@ * @test * @bug 4873188 * @summary Support TLS 1.1 + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm GenericStreamCipher * * SunJSSE does not support dynamic system properties, no way to re-use @@ -35,9 +42,13 @@ * @author Xuelei Fan */ -import java.io.*; +import java.io.InputStream; +import java.io.OutputStream; import java.security.Security; -import javax.net.ssl.*; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; public class GenericStreamCipher { diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.java index a07a303176c..fa3051fcb1b 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSDataExchangeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS application data exchange using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSDataExchangeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSDataExchangeTest diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.java index 4a591be9912..d56b2c79656 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSEnginesClosureTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines closing using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSEnginesClosureTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSEnginesClosureTest diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.java index 516a46b9877..437181e0d0a 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSHandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines handshake using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSHandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSHandshakeTest diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.java index 6c6073f190d..1a0abbbca2c 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSMFLNTest.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 @@ -28,6 +28,14 @@ * cipher suites with different maximum fragment length. Testing of * MFLN extension. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSMFLNTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSMFLNTest diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.java b/jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.java index c97b1d0ce7f..629edfab22f 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSNotEnabledRC4Test.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,13 @@ * @bug 8085979 * @summary Testing TLS engines do not enable RC4 ciphers by default. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 TLSNotEnabledRC4Test */ diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.java index a81868c31e6..b4b2b784521 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeTest.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 @@ -27,6 +27,14 @@ * @summary Testing TLS engines re-handshaking using each of the supported * cipher suites. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSRehandshakeTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSRehandshakeTest diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java index 1537676eafc..bd537156fe8 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.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 @@ -28,6 +28,13 @@ * is taken randomly from the supporetd ciphers list. * @key randomness * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 TLSRehandshakeWithCipherChangeTest */ diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.java index 00f3acc207c..43df7e98184 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithDataExTest.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 @@ -28,6 +28,14 @@ * cipher suites with application data exchange before and after * re-handshake and closing of the engines. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * jdk.security.auth + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=norm_sni TLSRehandshakeWithDataExTest * @run main/othervm -Dtest.security.protocol=TLSv1.1 -Dtest.mode=krb TLSRehandshakeWithDataExTest diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.java index 357e93d4ad2..afab2fda060 100644 --- a/jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.java +++ b/jdk/test/javax/net/ssl/TLSv11/TLSUnsupportedCiphersTest.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 @@ -27,6 +27,13 @@ * @summary Testing that try to enable unsupported ciphers * causes IllegalArgumentException. * @library /sun/security/krb5/auto /javax/net/ssl/TLSCommon + * @modules java.security.jgss + * java.security.jgss/sun.security.krb5 + * java.security.jgss/sun.security.krb5.internal.crypto + * java.security.jgss/sun.security.krb5.internal.ccache + * java.security.jgss/sun.security.krb5.internal + * java.security.jgss/sun.security.krb5.internal.ktab + * java.base/sun.security.util * @run main/othervm -Dtest.security.protocol=TLSv1.1 TLSUnsupportedCiphersTest */ diff --git a/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java b/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java index f1fd67d9b38..e42c9915f79 100644 --- a/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java +++ b/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.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 @@ -21,6 +21,15 @@ * questions. */ +/* + * @test + * @bug 8076221 + * @summary Check if weak cipher suites are disabled + * @modules jdk.crypto.ec + * @run main/othervm DisabledAlgorithms default + * @run main/othervm DisabledAlgorithms empty + */ + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; @@ -36,13 +45,6 @@ import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -/** - * @test - * @bug 8076221 - * @summary Check if weak cipher suites are disabled - * @run main/othervm DisabledAlgorithms default - * @run main/othervm DisabledAlgorithms empty - */ public class DisabledAlgorithms { private static final String pathToStores = "../etc"; diff --git a/jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java b/jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java index 9e7e692455a..742f71192dd 100644 --- a/jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java +++ b/jdk/test/javax/net/ssl/ciphersuites/ECCurvesconstraints.java @@ -32,24 +32,29 @@ * @test * @bug 8148516 * @summary Improve the default strength of EC in JDK + * @modules jdk.crypyo.ec * @run main/othervm ECCurvesconstraints PKIX * @run main/othervm ECCurvesconstraints SunX509 */ -import java.net.*; -import java.util.*; -import java.io.*; -import javax.net.ssl.*; -import java.security.Security; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; import java.security.KeyStore; import java.security.KeyFactory; import java.security.cert.Certificate; -import java.security.cert.X509Certificate; import java.security.cert.CertificateFactory; -import java.security.spec.*; -import java.security.interfaces.*; +import java.security.interfaces.ECPrivateKey; +import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; - +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManagerFactory; public class ECCurvesconstraints { 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/script/ExceptionTest.java b/jdk/test/javax/script/ExceptionTest.java index ccfcc73130f..02c86e304d2 100644 --- a/jdk/test/javax/script/ExceptionTest.java +++ b/jdk/test/javax/script/ExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, 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 @@ -26,10 +26,14 @@ * @bug 6474943 6705893 * @summary Test that script engine exception messages are * available from ScriptException. + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import javax.script.Compilable; +import javax.script.CompiledScript; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; public class ExceptionTest { private static final String ERROR_MSG = "error from JavaScript"; diff --git a/jdk/test/javax/script/JavaScriptScopeTest.java b/jdk/test/javax/script/JavaScriptScopeTest.java index 248fdb7c108..b1ed27e36a1 100644 --- a/jdk/test/javax/script/JavaScriptScopeTest.java +++ b/jdk/test/javax/script/JavaScriptScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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 @@ -28,9 +28,13 @@ * get affected by default scope assignments. Also, verify * that script globals can be created and accessed from Java * as well as JavaScript. + * @modules jdk.scripting.nashorn */ -import javax.script.*; +import javax.script.Bindings; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + public class JavaScriptScopeTest { diff --git a/jdk/test/javax/script/NullUndefinedVarTest.java b/jdk/test/javax/script/NullUndefinedVarTest.java index a02656f895d..e9ad24705a4 100644 --- a/jdk/test/javax/script/NullUndefinedVarTest.java +++ b/jdk/test/javax/script/NullUndefinedVarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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,9 +26,11 @@ * @bug 6346732 6705893 * @summary should be able to assign null and undefined * value to JavaScript global variables. + * @modules jdk.scripting.nashorn */ -import javax.script.*; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class NullUndefinedVarTest { diff --git a/jdk/test/javax/script/PluggableContextTest.java b/jdk/test/javax/script/PluggableContextTest.java index 9f68090c159..07a32125740 100644 --- a/jdk/test/javax/script/PluggableContextTest.java +++ b/jdk/test/javax/script/PluggableContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 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 @@ -26,9 +26,12 @@ * @bug 6398614 6705893 * @summary Create a user defined ScriptContext and check * that script can access variables from non-standard scopes + * @modules jdk.scripting.nashorn */ -import javax.script.*; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class PluggableContextTest { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test1.java b/jdk/test/javax/script/Test1.java index 9d5bebbebda..3c45b938f1e 100644 --- a/jdk/test/javax/script/Test1.java +++ b/jdk/test/javax/script/Test1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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,10 +26,13 @@ * @bug 6249843 6705893 * @summary Create JavaScript engine and execute a simple script. * Tests script engine discovery mechanism. + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test1 { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test2.java b/jdk/test/javax/script/Test2.java index ea93ca5918c..318aae09d8e 100644 --- a/jdk/test/javax/script/Test2.java +++ b/jdk/test/javax/script/Test2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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 @@ -25,10 +25,13 @@ * @test * @bug 6249843 * @summary Test exposing a Java object to script + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test2 { public static class Testobj { diff --git a/jdk/test/javax/script/Test3.java b/jdk/test/javax/script/Test3.java index 83237193e52..0c28bf35437 100644 --- a/jdk/test/javax/script/Test3.java +++ b/jdk/test/javax/script/Test3.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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 @@ -25,11 +25,17 @@ * @test * @bug 6249843 6705893 * @summary Test engine and global scopes + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.SimpleBindings; public class Test3 { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test4.java b/jdk/test/javax/script/Test4.java index a92c99c22ed..106de4fd59a 100644 --- a/jdk/test/javax/script/Test4.java +++ b/jdk/test/javax/script/Test4.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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 @@ -25,10 +25,14 @@ * @test * @bug 6249843 6705893 * @summary Test script functions implementing Java interface + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test4 { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test5.java b/jdk/test/javax/script/Test5.java index 2159647c6c4..1bcb7239b8d 100644 --- a/jdk/test/javax/script/Test5.java +++ b/jdk/test/javax/script/Test5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, 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 @@ -25,10 +25,18 @@ * @test * @bug 6249843 6705893 * @summary Tests engine, global scopes and scope hiding. + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.SimpleBindings; +import javax.script.SimpleScriptContext; public class Test5 { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test6.java b/jdk/test/javax/script/Test6.java index fadff34bc08..949b3af67a3 100644 --- a/jdk/test/javax/script/Test6.java +++ b/jdk/test/javax/script/Test6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, 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,10 +26,16 @@ * @bug 6249843 6705893 * @summary Test basic script compilation. Value eval'ed from * compiled and interpreted scripts should be same. + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.Compilable; +import javax.script.CompiledScript; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test6 { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test7.java b/jdk/test/javax/script/Test7.java index dbe1890df5c..fd7402fbb66 100644 --- a/jdk/test/javax/script/Test7.java +++ b/jdk/test/javax/script/Test7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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 @@ -25,10 +25,14 @@ * @test * @bug 6249843 6705893 * @summary Tests importPackage and java access in script + * @modules jdk.scripting.nashorn */ -import java.io.*; -import javax.script.*; +import java.io.File; +import java.io.FileReader; +import java.io.Reader; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test7 { public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/script/Test8.java b/jdk/test/javax/script/Test8.java index f83cd1c3a0f..3848e434750 100644 --- a/jdk/test/javax/script/Test8.java +++ b/jdk/test/javax/script/Test8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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 @@ -25,10 +25,14 @@ * @test * @bug 6249843 6705893 * @summary Test invoking script function or method from Java + * @modules jdk.scripting.nashorn */ -import javax.script.*; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; public class Test8 { public static void main(String[] args) throws Exception { 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/JColorChooser/Test7194184.java b/jdk/test/javax/swing/JColorChooser/Test7194184.java index 460aefaf3b5..1c6dbbb4b37 100644 --- a/jdk/test/javax/swing/JColorChooser/Test7194184.java +++ b/jdk/test/javax/swing/JColorChooser/Test7194184.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 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 @@ -25,19 +25,15 @@ * Portions Copyright (c) 2012 IBM Corporation */ -/* - * @test - * @key headful - * @bug 7194184 +/* @test + @key headful + * @bug 7194184 8163274 * @summary Tests JColorChooser Swatch keyboard accessibility. - * @author Sean Chou * @library ../regtesthelpers * @build Util - * @run main Test7194184 + * @run main/timeout=500 Test7194184 */ - import java.awt.Component; -import java.awt.AWTException; import java.awt.Color; import java.awt.Robot; import java.awt.event.KeyEvent; @@ -46,66 +42,81 @@ import javax.swing.JColorChooser; import javax.swing.JFrame; import javax.swing.SwingUtilities; -import java.util.concurrent.Callable; +public class Test7194184 { -public class Test7194184 implements Runnable { private static JFrame frame; private static JColorChooser colorChooser; - private static Color selectedColor; + private static Color testColor; + private static Color newColor; + + private static Robot robot; public static void main(String[] args) throws Exception { - testKeyBoardAccess(); + robot = new Robot(); + robot.setAutoWaitForIdle(true); + createUI(); + accessRecentSwatch(); + runRobot(); + testColorChooser(); + cleanUpUI(); } - private static void testKeyBoardAccess() throws Exception { - Robot robot = new Robot(); - - SwingUtilities.invokeLater(new Test7194184()); - robot.waitForIdle(); - + private static void createUI() throws Exception { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - selectedColor = colorChooser.getColor(); + String title = getClass().getName(); + frame = new JFrame(title); + colorChooser = new JColorChooser(); + frame.add(colorChooser); + frame.pack(); + frame.setVisible(true); + } + }); + } + private static void accessRecentSwatch() throws Exception { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { Component recentSwatchPanel = Util.findSubComponent(colorChooser, "RecentSwatchPanel"); if (recentSwatchPanel == null) { throw new RuntimeException("RecentSwatchPanel not found"); } recentSwatchPanel.requestFocusInWindow(); + testColor = colorChooser.getColor(); + } }); + } - robot.waitForIdle(); - + private static void runRobot() { // Tab to move the focus to MainSwatch Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); - // Select the color on right Util.hitKeys(robot, KeyEvent.VK_RIGHT); Util.hitKeys(robot, KeyEvent.VK_RIGHT); Util.hitKeys(robot, KeyEvent.VK_SPACE); - robot.waitForIdle(); + } + private static void testColorChooser() throws Exception { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { - frame.dispose(); - if (selectedColor == colorChooser.getColor()) { + newColor = colorChooser.getColor(); + if (newColor == testColor) { throw new RuntimeException("JColorChooser misses keyboard accessibility"); } } }); } - public void run() { - String title = getClass().getName(); - frame = new JFrame(title); - colorChooser = new JColorChooser(); - - frame.add(colorChooser); - frame.pack(); - frame.setVisible(true); + private static void cleanUpUI() throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.dispose(); + } + }); } - } 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/JSlider/SliderTick/SliderTickTest.java b/jdk/test/javax/swing/JSlider/SliderTick/SliderTickTest.java new file mode 100644 index 00000000000..6832cf5832e --- /dev/null +++ b/jdk/test/javax/swing/JSlider/SliderTick/SliderTickTest.java @@ -0,0 +1,181 @@ +/* + * 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 8009477 + * @summary Verify PageUp/PageDown key moves slider to Next/Previous minor tick. + * @run main/manual SliderTickTest + */ +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.concurrent.CountDownLatch; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.JButton; +import javax.swing.JFrame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.concurrent.TimeUnit; +import javax.swing.JSlider; + +public class SliderTickTest { + + public static void main(String args[]) throws Exception { + final CountDownLatch latch = new CountDownLatch(1); + TestUI test = new TestUI(latch); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + test.createUI(); + } catch (Exception ex) { + throw new RuntimeException("Exception while creating UI"); + } + } + }); + + boolean status = latch.await(5, TimeUnit.MINUTES); + + if (!status) { + System.out.println("Test timed out."); + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + test.disposeUI(); + } catch (Exception ex) { + throw new RuntimeException("Exception while disposing UI"); + } + } + }); + + if (test.testResult == false) { + throw new RuntimeException("Test Failed."); + } + } +} + +class TestUI { + + private static JFrame mainFrame; + private static JPanel mainControlPanel; + + private static JTextArea instructionTextArea; + + private static JPanel resultButtonPanel; + private static JButton passButton; + private static JButton failButton; + + private static GridBagLayout layout; + private final CountDownLatch latch; + public boolean testResult = false; + + public TestUI(CountDownLatch latch) throws Exception { + this.latch = latch; + } + + public final void createUI() throws Exception { + + mainFrame = new JFrame("SliderTickTest"); + + layout = new GridBagLayout(); + mainControlPanel = new JPanel(layout); + resultButtonPanel = new JPanel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + + // Create Test instructions + String instructions + = "INSTRUCTIONS:" + + "\n Click PageUp/PageDown key. If the slider indicator" + + "\n moves to Next/Previous immediate minor tick, then " + + "\n test passes else failed."; + + instructionTextArea = new JTextArea(); + instructionTextArea.setText(instructions); + instructionTextArea.setEnabled(false); + instructionTextArea.setDisabledTextColor(Color.black); + instructionTextArea.setBackground(Color.white); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionTextArea, gbc); + + JSlider slider = new JSlider(0, 50); + slider.setMajorTickSpacing(10); + slider.setMinorTickSpacing(2); + slider.setPaintTicks(true); + slider.setPaintLabels(true); + slider.setValue(30); + slider.setBorder(BorderFactory.createTitledBorder("Ticks")); + gbc.gridx = 0; + gbc.gridy = 1; + mainControlPanel.add(slider, gbc); + + passButton = new JButton("Pass"); + passButton.setActionCommand("Pass"); + passButton.addActionListener((ActionEvent e) -> { + testResult = true; + mainFrame.dispose(); + latch.countDown(); + + }); + failButton = new JButton("Fail"); + failButton.setActionCommand("Fail"); + failButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + testResult = false; + mainFrame.dispose(); + latch.countDown(); + } + }); + 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 = 2; + mainControlPanel.add(resultButtonPanel, gbc); + + mainFrame.add(mainControlPanel); + mainFrame.pack(); + mainFrame.setVisible(true); + } + + public void disposeUI() { + mainFrame.setVisible(false); + mainFrame.dispose(); + } +} diff --git a/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java index 2137217b142..8022e8fff0b 100644 --- a/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java +++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java @@ -25,6 +25,7 @@ import java.awt.*; /* * @test + * @bug 8144735 * @key headful * @summary Check if a per-pixel translucent and translucent window is dragged * and resized by mouse correctly diff --git a/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java new file mode 100644 index 00000000000..8860d768a0d --- /dev/null +++ b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java @@ -0,0 +1,134 @@ +/* + * 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.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.util.List; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.plaf.metal.MetalLookAndFeel; + +/* + * @test + * @bug 8163193 + * @key headful + * @summary Metal L&F gradient is lighter on HiDPI display + * @run main/othervm -Dsun.java2d.uiScale=2 ButtonGradientTest + */ +public class ButtonGradientTest { + + private static JFrame frame; + private static JButton button; + + public static void main(String[] args) throws Exception { + try { + testGradient(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void testGradient() throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(ButtonGradientTest::createAndShowGUI); + robot.waitForIdle(); + + Rectangle rect = getButtonBounds(); + List gradient = (List) UIManager.get("Button.gradient"); + float ratio = ((Number) gradient.get(0)).floatValue(); + Color c1 = (Color) gradient.get(2); + Color c2 = (Color) gradient.get(3); + int mid = (int) (ratio * rect.height); + + Color gradientColor = getGradientColor(rect.width, mid, c1, c2); + int x = rect.x + rect.width / 2; + int y = rect.y + mid / 2; + Color buttonColor = robot.getPixelColor(x, y); + + if (!similarColors(buttonColor, gradientColor)) { + throw new RuntimeException("Button gradient is changed!"); + } + } + + private static void createAndShowGUI() { + + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame = new JFrame(); + frame.setSize(300, 300); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + button = new JButton(""); + panel.add(button); + frame.getContentPane().add(panel); + frame.setVisible(true); + } + + private static Rectangle getButtonBounds() throws Exception { + Rectangle[] rectangles = new Rectangle[1]; + SwingUtilities.invokeAndWait(() -> { + rectangles[0] = button.getBounds(); + rectangles[0].setLocation(button.getLocationOnScreen()); + }); + return rectangles[0]; + } + + private static Color getGradientColor(int w, int h, Color c1, Color c2) { + GradientPaint gradient = new GradientPaint(0, 0, c1, 0, h, c2, true); + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = img.createGraphics(); + g.setPaint(gradient); + g.fillRect(0, 0, w, h); + g.dispose(); + return new Color(img.getRGB(w / 2, h / 2)); + } + + private static boolean similarColors(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 i1, int i2) { + return Math.abs(i2 - i1) < 7; + } +} 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/javax/swing/text/DevanagariEditor.java b/jdk/test/javax/swing/text/DevanagariEditor.java new file mode 100644 index 00000000000..3781a1beae7 --- /dev/null +++ b/jdk/test/javax/swing/text/DevanagariEditor.java @@ -0,0 +1,36 @@ +/* + * 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 8151725 + * @summary Tests no exception creating a JEditorPane with Devanagari + */ + +import javax.swing.JEditorPane; + +public class DevanagariEditor { + public static void main(String[] args) { + new JEditorPane().setText("\u0930\u093E\u0915\u094D\u0937\u0938"); + } +} diff --git a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java new file mode 100644 index 00000000000..cc32aeb7690 --- /dev/null +++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java @@ -0,0 +1,153 @@ +/* + * 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 + * 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 6427244 8144240 + @summary Test that pressing HOME correctly moves caret in I18N document. + @author Sergey Groznyh + @library ../../../regtesthelpers + @build JRobot Util TestCase + @run main bug6427244 +*/ + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Shape; +import java.awt.event.KeyEvent; +import javax.swing.JFrame; +import javax.swing.JTextPane; +import javax.swing.SwingUtilities; +import javax.swing.text.Position; + +public class bug6427244 extends TestCase { + private static final JRobot ROBOT = JRobot.getRobot(); + + final static int TP_SIZE = 200; + final static String[] SPACES = new String[] { + "\u0020", // ASCII space + "\u2002", // EN space + "\u2003", // EM space + "\u2004", // THREE-PER-EM space + "\u2005", // ... etc. + "\u2006", + //"\u2007", + "\u2008", + "\u2009", + "\u200a", + "\u200b", + "\u205f", + "\u3000", + }; + final static String[] WORDS = new String[] { + "It", "is", "a", "long", "paragraph", "for", "testing", "GlyphPainter2\n\n", + }; + + public static void main(String[] args) { + bug6427244 t = new bug6427244(); + for (String space: SPACES) { + t.init(space); + t.runAllTests(); + } + + System.out.println("OK"); + } + + void init(final String space) { + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + String text = null; + for (String word: WORDS) { + if (text == null) { + text = ""; + } else { + text += space; + } + text += word; + } + tp = new JTextPane(); + tp.setText(text + + "Some arabic: \u062a\u0641\u0627\u062d and some not."); + if (jf == null) { + jf = new JFrame(); + jf.setTitle("bug6427244"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jf.setSize(TP_SIZE, TP_SIZE); + jf.setVisible(true); + } + Container c = jf.getContentPane(); + c.removeAll(); + c.add(tp); + c.invalidate(); + c.validate(); + dim = c.getSize(); + } + }); + Util.blockTillDisplayed(tp); + ROBOT.waitForIdle(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public void testCaretPosition() { + Point p = tp.getLocationOnScreen(); + // the right-top corner position + p.x += (dim.width - 5); + p.y += 5; + ROBOT.mouseMove(p.x, p.y); + ROBOT.clickMouse(); + ROBOT.hitKey(KeyEvent.VK_HOME); + ROBOT.waitForIdle(); + // this will fail if caret moves out of the 1st line. + assertEquals(0, getCaretOrdinate()); + } + + int getCaretOrdinate() { + final int[] y = new int[1]; + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Shape s; + try { + s = tp.getUI().getRootView(tp).modelToView( + tp.getCaretPosition(), tp.getBounds(), + Position.Bias.Forward); + } catch (Exception e) { + throw new RuntimeException(e); + } + y[0] = s.getBounds().y; + } + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + return y[0]; + } + + JFrame jf; + JTextPane tp; + Dimension dim; +} diff --git a/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java b/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java new file mode 100644 index 00000000000..1dd55404a6c --- /dev/null +++ b/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java @@ -0,0 +1,111 @@ +/* + * 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 8058575 + * @summary Test that bad host classes cause exceptions to get thrown. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.base/jdk.internal.org.objectweb.asm + * @run main TestBadHostClass + */ + + +import java.lang.*; +import java.lang.reflect.Field; +import jdk.internal.misc.Unsafe; +import jdk.test.lib.unsafe.UnsafeHelper; +import jdk.internal.org.objectweb.asm.ClassWriter; +import static jdk.internal.org.objectweb.asm.Opcodes.*; + +// Test that bad host classes cause exceptions. +public class TestBadHostClass { + + private static final Unsafe unsafe = Unsafe.getUnsafe(); + + private static String packageName(Class c) { + if (c.isArray()) { + return packageName(c.getComponentType()); + } else { + String name = c.getName(); + int dot = name.lastIndexOf('.'); + if (dot == -1) return ""; + return name.substring(0, dot); + } + } + + private static int constantPoolSize(byte[] classFile) { + return ((classFile[8] & 0xFF) << 8) | (classFile[9] & 0xFF); + } + + static public void badHostClass(Class hostClass) { + // choose a class name in the same package as the host class + String className; + if (hostClass != null) { + String prefix = packageName(hostClass); + if (prefix.length() > 0) + prefix = prefix.replace('.', '/') + "/"; + className = prefix + "Anon"; + } else { + className = "Anon"; + } + + // create the class + String superName = "java/lang/Object"; + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + + ClassWriter.COMPUTE_FRAMES); + cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, + className, null, superName, null); + byte[] classBytes = cw.toByteArray(); + int cpPoolSize = constantPoolSize(classBytes); + Class anonClass + = unsafe.defineAnonymousClass(hostClass, classBytes, new Object[cpPoolSize]); + } + + public static void main(String args[]) throws Exception { + // host class is an array of java.lang.Objects. + try { + badHostClass(Object[].class); + } catch (IllegalArgumentException ex) { + } + + // host class is an array of objects of this class. + try { + badHostClass(TestBadHostClass[].class); + } catch (IllegalArgumentException ex) { + } + + // host class is null. + try { + badHostClass(null); + } catch (NullPointerException ex) { + } + + // host class is a primitive array class. + try { + badHostClass(int[].class); + } catch (IllegalArgumentException ex) { + } + } +} 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/jdk/internal/util/jar/TestVersionedStream.java b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java new file mode 100644 index 00000000000..12e45f03b77 --- /dev/null +++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java @@ -0,0 +1,214 @@ +/* + * 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 8163798 + * @summary basic tests for multi-release jar versioned streams + * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar + * @run testng TestVersionedStream + */ + +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.net.URI; +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.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.zip.ZipFile; + +public class TestVersionedStream { + private String userdir; + + @BeforeClass + public void initialize() { + userdir = System.getProperty("user.dir", "."); + + // These are not real class files even though they end with .class. + // They are resource files so jar tool validation won't reject them. + // But they are what we want to test, especially q/Bar.class that + // could be in a concealed package if this was a modular multi-release + // jar. + createFiles( + "base/p/Foo.class", + "base/p/Main.class", + "v9/p/Foo.class", + "v10/p/Foo.class", + "v10/q/Bar.class", + "v11/p/Foo.class" + ); + + jar("cf mmr.jar -C base . --release 9 -C v9 . --release 10 -C v10 . --release 11 -C v11 ."); + + System.out.println("Contents of mmr.jar\n======="); + jar("tf mmr.jar"); + System.out.println("======="); + } + + @AfterClass + public void close() throws IOException { + Path root = Paths.get(userdir); + Files.walkFileTree(root, new SimpleFileVisitor<>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + if (!dir.equals(root)) { + Files.delete(dir); + } + return FileVisitResult.CONTINUE; + } + }); + } + + @DataProvider + public Object[][] data() { + List p = List.of( + "META-INF/", + "META-INF/MANIFEST.MF", + "p/", + "p/Foo.class", + "p/Main.class" + ); + List q = List.of( + "META-INF/", + "META-INF/MANIFEST.MF", + "p/", + "p/Foo.class", + "p/Main.class", + "q/", + "q/Bar.class" + ); + Runtime.Version rt = JarFile.runtimeVersion(); + return new Object[][] { + {Runtime.Version.parse("8"), p}, + {Runtime.Version.parse("9"), p}, + {Runtime.Version.parse("10"), q}, + {Runtime.Version.parse("11"), q}, + {JarFile.baseVersion(), p}, + {rt, rt.major() > 9 ? q : p} + }; + } + + @Test(dataProvider="data") + public void test(Runtime.Version version, List names) throws Exception { + try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version); + Stream jes = jdk.internal.util.jar.VersionedStream.stream(jf)) + { + Assert.assertNotNull(jes); + + List entries = jes.collect(Collectors.toList()); + + // verify the correct order + List enames = entries.stream() + .map(je -> je.getName()) + .collect(Collectors.toList()); + Assert.assertEquals(enames, names); + + // verify the contents + Map contents = new HashMap<>(); + contents.put("p/Main.class", "base/p/Main.class\n"); + if (version.major() > 9) { + contents.put("q/Bar.class", "v10/q/Bar.class\n"); + } + switch (version.major()) { + case 8: + contents.put("p/Foo.class", "base/p/Foo.class\n"); + break; + case 9: + contents.put("p/Foo.class", "v9/p/Foo.class\n"); + break; + case 10: + contents.put("p/Foo.class", "v10/p/Foo.class\n"); + break; + case 11: + contents.put("p/Foo.class", "v11/p/Foo.class\n"); + break; + default: + Assert.fail("Test out of date, please add more cases"); + } + + contents.entrySet().stream().forEach(e -> { + String name = e.getKey(); + int i = enames.indexOf(name); + Assert.assertTrue(i != -1, name + " not in enames"); + JarEntry je = entries.get(i); + try (InputStream is = jf.getInputStream(je)) { + String s = new String(is.readAllBytes()); + Assert.assertTrue(s.endsWith(e.getValue()), s); + } catch (IOException x) { + throw new UncheckedIOException(x); + } + }); + } + } + + private void createFiles(String... files) { + ArrayList list = new ArrayList(); + Arrays.stream(files) + .map(f -> "file:///" + userdir + "/" + f) + .map(f -> URI.create(f)) + .filter(u -> u != null) + .map(u -> Paths.get(u)) + .forEach(p -> { + try { + Files.createDirectories(p.getParent()); + Files.createFile(p); + list.clear(); + list.add(p.toString()); + Files.write(p, list); + } catch (IOException x) { + throw new UncheckedIOException(x); + }}); + } + + private void jar(String args) { + new sun.tools.jar.Main(System.out, System.err, "jar") + .run(args.split(" +")); + } + +} diff --git a/jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java b/jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java index 881e27dbd4f..78a663f7a7f 100644 --- a/jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java +++ b/jdk/test/jdk/nio/zipfs/jarfs/JFSTester.java @@ -26,6 +26,7 @@ * @bug 8164389 * @summary walk entries in a jdk.nio.zipfs.JarFileSystem * @modules jdk.jartool/sun.tools.jar + * jdk.zipfs * @run testng JFSTester */ 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/net/www/protocol/jar/JarURLConnectionUseCaches.java b/jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java new file mode 100644 index 00000000000..433a72cc55b --- /dev/null +++ b/jdk/test/sun/net/www/protocol/jar/JarURLConnectionUseCaches.java @@ -0,0 +1,63 @@ +/* + * 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 6947916 + * @summary JarURLConnection does not handle useCaches correctly + * @run main/othervm JarURLConnectionUseCaches + */ + +import java.io.*; +import java.net.JarURLConnection; +import java.net.URL; +import java.util.jar.*; + +public class JarURLConnectionUseCaches { + public static void main( String[] args ) throws IOException { + JarOutputStream out = new JarOutputStream( + new FileOutputStream("usecache.jar")); + out.putNextEntry(new JarEntry("test.txt")); + out.write("Test txt file".getBytes()); + out.closeEntry(); + out.close(); + + URL url = new URL("jar:" + + new File(".").toURI().toString() + + "/usecache.jar!/test.txt"); + + JarURLConnection c1 = (JarURLConnection)url.openConnection(); + c1.setDefaultUseCaches( false ); + c1.setUseCaches( true ); + c1.connect(); + + JarURLConnection c2 = (JarURLConnection)url.openConnection(); + c2.setDefaultUseCaches( false ); + c2.setUseCaches( true ); + c2.connect(); + + c1.getInputStream().close(); + c2.getInputStream().read(); + c2.getInputStream().close(); + } +} diff --git a/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java b/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java index 58a81065746..cca4e77befb 100644 --- a/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java +++ b/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.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 @@ -31,6 +31,7 @@ import java.util.List; * OID and algorithm transformation string should match. * Both could be able to be used to generate the algorithm instance. * @compile ../../TestSignatureOidHelper.java + * @modules jdk.crypto.ec * @run main TestSHAwithECDSASignatureOids */ public class TestSHAwithECDSASignatureOids { diff --git a/jdk/test/sun/security/krb5/IPv6.java b/jdk/test/sun/security/krb5/IPv6.java index 20085c0f9e0..5f541035528 100644 --- a/jdk/test/sun/security/krb5/IPv6.java +++ b/jdk/test/sun/security/krb5/IPv6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, 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,11 +25,16 @@ * @test * @bug 6877357 6885166 * @run main/othervm IPv6 + * @modules jdk.security.auth * @summary IPv6 address does not work */ import com.sun.security.auth.module.Krb5LoginModule; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.io.StringReader; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; diff --git a/jdk/test/sun/security/krb5/auto/MaxRetries.java b/jdk/test/sun/security/krb5/auto/MaxRetries.java index b732becd169..973873a6524 100644 --- a/jdk/test/sun/security/krb5/auto/MaxRetries.java +++ b/jdk/test/sun/security/krb5/auto/MaxRetries.java @@ -24,7 +24,6 @@ /* * @test * @bug 6844193 - * @key intermittent * @compile -XDignore.symbol.file MaxRetries.java * @run main/othervm/timeout=300 MaxRetries * @summary support max_retries in krb5.conf diff --git a/jdk/test/sun/security/krb5/auto/Unreachable.java b/jdk/test/sun/security/krb5/auto/Unreachable.java index b010b54837e..fddf040d517 100644 --- a/jdk/test/sun/security/krb5/auto/Unreachable.java +++ b/jdk/test/sun/security/krb5/auto/Unreachable.java @@ -23,31 +23,107 @@ /* * @test - * @bug 7162687 - * @key intermittent + * @bug 7162687 8015595 * @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/pkcs11/Cipher/ReinitCipher.java b/jdk/test/sun/security/pkcs11/Cipher/ReinitCipher.java index db7098e5fdf..72dbb728687 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/ReinitCipher.java +++ b/jdk/test/sun/security/pkcs11/Cipher/ReinitCipher.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReinitCipher * @run main/othervm ReinitCipher sm */ diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java b/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java index 5fa94cbfc54..49880d3706e 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java +++ b/jdk/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6687725 * @summary Test internal PKCS5Padding impl with various error conditions. * @author Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestPKCS5PaddingError * @run main/othervm TestPKCS5PaddingError sm */ diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java index b9656a54086..160ce1cb5a1 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java +++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898468 6994008 * @summary basic test for RSA cipher * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRSACipher * @run main/othervm TestRSACipher sm */ diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java index 8637302b547..4e4fb600852 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java +++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6572331 6994008 * @summary basic test for RSA cipher key wrapping functionality * @author Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRSACipherWrap * @run main/othervm TestRSACipherWrap sm */ diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java b/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java index cebe4224129..ed85f315a75 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java +++ b/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6994008 * @summary basic test for RSA/ECB/NoPadding cipher * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRawRSACipher * @run main/othervm TestRawRSACipher sm */ diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java index 018edc7417a..e94c61d2938 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java +++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898461 6604496 * @summary basic test for symmetric ciphers with padding * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestSymmCiphers * @run main/othervm TestSymmCiphers sm */ diff --git a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java index 2359e77bf03..4fc7d7b9553 100644 --- a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java +++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898484 6604496 8001284 * @summary basic test for symmetric ciphers with no padding * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestSymmCiphersNoPad * @run main/othervm TestSymmCiphersNoPad sm */ diff --git a/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java b/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java index 50154df7c77..52b69892dae 100644 --- a/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java @@ -21,21 +21,23 @@ * questions. */ -/** +/* * @test * @bug 8072452 * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm SupportedDHKeys * @run main/othervm SupportedDHKeys sm */ import java.math.BigInteger; - -import java.security.*; -import javax.crypto.*; -import javax.crypto.interfaces.*; -import javax.crypto.spec.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.Provider; +import javax.crypto.interfaces.DHPrivateKey; +import javax.crypto.interfaces.DHPublicKey; +import javax.crypto.spec.DHParameterSpec; public class SupportedDHKeys extends PKCS11Test { diff --git a/jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java b/jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java index 45e03897359..c43dc081878 100644 --- a/jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/TestDH.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4921804 6324825 * @summary Verify that DH works properly * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDH * @run main/othervm TestDH sm */ diff --git a/jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java b/jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java index 15a96b9b19e..4834b761f89 100644 --- a/jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/TestInterop.java @@ -21,11 +21,12 @@ * questions. */ -/** +/* * @test * @bug 7146728 * @summary Interop test for DH with secret that has a leading 0x00 byte * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestInterop * @run main/othervm TestInterop sm */ diff --git a/jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java b/jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java index aec6c0c7c16..f082fee09ac 100644 --- a/jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/TestShort.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4942494 7146728 * @summary KAT test for DH (normal and with secret that has leading a 0x00 byte) * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestShort * @run main/othervm TestShort sm */ diff --git a/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java b/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java index 0725171cb53..cdfa887de0a 100644 --- a/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java @@ -21,21 +21,19 @@ * questions. */ -/** +/* * @test * @bug 8072452 * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm UnsupportedDHKeys * @run main/othervm UnsupportedDHKeys sm */ -import java.math.BigInteger; - -import java.security.*; -import javax.crypto.*; -import javax.crypto.interfaces.*; -import javax.crypto.spec.*; +import java.security.InvalidParameterException; +import java.security.KeyPairGenerator; +import java.security.Provider; public class UnsupportedDHKeys extends PKCS11Test { diff --git a/jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java b/jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java index 3c8b3a52283..9e2b6da7b43 100644 --- a/jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java +++ b/jdk/test/sun/security/pkcs11/KeyGenerator/DESParity.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4898479 * @summary Verify that the parity bits are set correctly * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm DESParity * @run main/othervm DESParity sm */ diff --git a/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java b/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java index e0f669f58e3..f5297390348 100644 --- a/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java +++ b/jdk/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4917233 6461727 6490213 6720456 * @summary test the KeyGenerator * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestKeyGenerator * @run main/othervm TestKeyGenerator sm */ diff --git a/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java b/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java index 4655678c31e..f5a0a105fe8 100644 --- a/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java +++ b/jdk/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 7196382 8072452 * @summary Ensure that DH key pairs can be generated for 512 - 8192 bits * @author Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDH2048 * @run main/othervm TestDH2048 sm */ diff --git a/jdk/test/sun/security/pkcs11/Mac/MacKAT.java b/jdk/test/sun/security/pkcs11/Mac/MacKAT.java index d7679f91ffd..c068ac0e3c1 100644 --- a/jdk/test/sun/security/pkcs11/Mac/MacKAT.java +++ b/jdk/test/sun/security/pkcs11/Mac/MacKAT.java @@ -21,6 +21,17 @@ * questions. */ +/* + * @test + * @bug 4846410 6313661 4963723 + * @summary Basic known-answer-test for Hmac algorithms + * @author Andreas Sterbenz + * @library .. + * @modules jdk.crypto.pkcs11 + * @run main/othervm MacKAT + * @run main/othervm MacKAT sm + */ + import java.io.UnsupportedEncodingException; import java.security.Provider; import java.util.Arrays; @@ -30,15 +41,6 @@ import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; -/** - * @test - * @bug 4846410 6313661 4963723 - * @summary Basic known-answer-test for Hmac algorithms - * @author Andreas Sterbenz - * @library .. - * @run main/othervm MacKAT - * @run main/othervm MacKAT sm - */ public class MacKAT extends PKCS11Test { private final static byte[] ALONG, BLONG, BKEY, BKEY_20, DDDATA_50, diff --git a/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java b/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java index 8d6689721fc..c1ee2ec4a67 100644 --- a/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java +++ b/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java @@ -21,6 +21,18 @@ * questions. */ +/* + * @test + * @bug 8048603 + * @summary Check if doFinal and update operation result in same Mac + * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin + * @library .. + * @modules jdk.crypto.pkcs11 + * @run main/othervm MacSameTest + * @run main/othervm MacSameTest sm + * @key randomness + */ + import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; @@ -30,16 +42,6 @@ import java.util.List; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -/** - * @test - * @bug 8048603 - * @summary Check if doFinal and update operation result in same Mac - * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin - * @library .. - * @run main/othervm MacSameTest - * @run main/othervm MacSameTest sm - * @key randomness - */ public class MacSameTest extends PKCS11Test { private static final int MESSAGE_SIZE = 25; diff --git a/jdk/test/sun/security/pkcs11/Mac/ReinitMac.java b/jdk/test/sun/security/pkcs11/Mac/ReinitMac.java index 39970d8df00..97dcb7305b4 100644 --- a/jdk/test/sun/security/pkcs11/Mac/ReinitMac.java +++ b/jdk/test/sun/security/pkcs11/Mac/ReinitMac.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReinitMac * @run main/othervm ReinitMac sm */ diff --git a/jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java b/jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java index eca0485c8a9..64d7ff5ba65 100644 --- a/jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java +++ b/jdk/test/sun/security/pkcs11/MessageDigest/ByteBuffers.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test the MessageDigest.update(ByteBuffer) method * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ByteBuffers * @run main/othervm ByteBuffers sm */ diff --git a/jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java b/jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java index 0f48f28c859..4a3b71f7deb 100644 --- a/jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java +++ b/jdk/test/sun/security/pkcs11/MessageDigest/DigestKAT.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Basic known-answer-test for all our MessageDigest algorithms * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm DigestKAT * @run main/othervm DigestKAT sm */ diff --git a/jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java b/jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java index 9d8250c9ab0..3414a579754 100644 --- a/jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java +++ b/jdk/test/sun/security/pkcs11/MessageDigest/ReinitDigest.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReinitDigest * @run main/othervm ReinitDigest sm */ diff --git a/jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java b/jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java index 0aca8fbf791..4bac0794227 100644 --- a/jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java +++ b/jdk/test/sun/security/pkcs11/MessageDigest/TestCloning.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6414899 * @summary Ensure the cloning functionality works. * @author Valerie Peng * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestCloning * @run main/othervm TestCloning sm */ diff --git a/jdk/test/sun/security/pkcs11/PKCS11Test.java b/jdk/test/sun/security/pkcs11/PKCS11Test.java index f3e14c7d213..3752baba8da 100644 --- a/jdk/test/sun/security/pkcs11/PKCS11Test.java +++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java @@ -82,8 +82,6 @@ public abstract class PKCS11Test { System.setProperty("closed.base", CLOSED_BASE); } - static String NSPR_PREFIX = ""; - // NSS version info public static enum ECCState { None, Basic, Extended }; static double nss_version = -1; @@ -294,7 +292,6 @@ public abstract class PKCS11Test { String osName = props.getProperty("os.name"); if (osName.startsWith("Win")) { osName = "Windows"; - NSPR_PREFIX = "lib"; } else if (osName.equals("Mac OS X")) { osName = "MacOSX"; } @@ -342,9 +339,9 @@ public abstract class PKCS11Test { static boolean loadNSPR(String libdir) throws Exception { // load NSS softoken dependencies in advance to avoid resolver issues - safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4")); - safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4")); - safeReload(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4")); + safeReload(libdir + System.mapLibraryName("nspr4")); + safeReload(libdir + System.mapLibraryName("plc4")); + safeReload(libdir + System.mapLibraryName("plds4")); safeReload(libdir + System.mapLibraryName("sqlite3")); safeReload(libdir + System.mapLibraryName("nssutil3")); return true; diff --git a/jdk/test/sun/security/pkcs11/Provider/Absolute.java b/jdk/test/sun/security/pkcs11/Provider/Absolute.java index 85bbd216ba1..7906ac129c5 100644 --- a/jdk/test/sun/security/pkcs11/Provider/Absolute.java +++ b/jdk/test/sun/security/pkcs11/Provider/Absolute.java @@ -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 @@ -20,13 +20,16 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/** +/* * @test * @bug 7003952 7191662 * @library .. + * @modules jdk.crypto.pkcs11 * @summary load DLLs and launch executables using fully qualified path */ -import java.security.*; + +import java.security.InvalidParameterException; +import java.security.Provider; public class Absolute { diff --git a/jdk/test/sun/security/pkcs11/SampleTest.java b/jdk/test/sun/security/pkcs11/SampleTest.java index 43cd13ae333..5d5c68414f0 100644 --- a/jdk/test/sun/security/pkcs11/SampleTest.java +++ b/jdk/test/sun/security/pkcs11/SampleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 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 @@ -21,20 +21,16 @@ * questions. */ -/** +/* * @test * @bug 4000000 * @summary XXX todo * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 */ -import java.io.*; -import java.util.*; - -import java.security.*; - -import javax.crypto.*; +import java.security.Provider; public class SampleTest extends PKCS11Test { diff --git a/jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java b/jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java index 67c691a3bc2..82fc4ab5f74 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java +++ b/jdk/test/sun/security/pkcs11/Secmod/AddPrivateKey.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6414980 * @summary Test that the PKCS#11 KeyStore handles RSA, DSA, and EC keys * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm AddPrivateKey * @run main/othervm AddPrivateKey sm policy */ diff --git a/jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java b/jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java index 2eedf3cd506..1e085c33a24 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java +++ b/jdk/test/sun/security/pkcs11/Secmod/AddTrustedCert.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6298106 * @summary make sure we can add a trusted cert to the NSS KeyStore module * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm AddTrustedCert * @run main/othervm AddTrustedCert sm policy */ diff --git a/jdk/test/sun/security/pkcs11/Secmod/Crypto.java b/jdk/test/sun/security/pkcs11/Secmod/Crypto.java index 2e571051cbd..b1b4372a49b 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/Crypto.java +++ b/jdk/test/sun/security/pkcs11/Secmod/Crypto.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6329006 * @summary verify that NSS no-db mode works correctly * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm Crypto * @run main/othervm Crypto sm policy */ diff --git a/jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java b/jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java index b3170597b5d..9dd1fe0aaba 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java +++ b/jdk/test/sun/security/pkcs11/Secmod/GetPrivateKey.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6273877 6322208 6275523 * @summary make sure we can access the NSS softtoken KeyStore * and use a private key * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm GetPrivateKey * @run main/othervm GetPrivateKey sm policy */ diff --git a/jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java b/jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java index 7613fce9ba5..360e5d1e684 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java +++ b/jdk/test/sun/security/pkcs11/Secmod/JksSetPrivateKey.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6269847 * @summary store a NSS PKCS11 PrivateKeyEntry to JKS KeyStore throws confusing NPE * @author Wang Weijun * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm JksSetPrivateKey * @run main/othervm JksSetPrivateKey sm policy */ diff --git a/jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java b/jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java index c08fe8446aa..2e1d85ce58f 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java +++ b/jdk/test/sun/security/pkcs11/Secmod/LoadKeystore.java @@ -21,6 +21,16 @@ * questions. */ +/* + * @test + * @bug 8048622 8134232 + * @summary Checks that PKCS#11 keystore can't be loaded with wrong password + * @library ../ + * @modules jdk.crypto.pkcs11 + * @run main/othervm LoadKeystore + * @run main/othervm LoadKeystore sm policy + */ + import java.io.File; import java.io.IOException; import java.security.KeyStore; @@ -30,14 +40,6 @@ import java.security.Security; import java.security.UnrecoverableKeyException; import java.util.Collections; -/* - * @test - * @bug 8048622 8134232 - * @summary Checks that PKCS#11 keystore can't be loaded with wrong password - * @library ../ - * @run main/othervm LoadKeystore - * @run main/othervm LoadKeystore sm policy - */ public class LoadKeystore extends SecmodTest { public static void main(String[] args) throws Exception { diff --git a/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java b/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java index 277a51ec4c2..a26a5862d59 100644 --- a/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java +++ b/jdk/test/sun/security/pkcs11/Secmod/TrustAnchors.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6298106 6275523 6420252 8059627 * @summary make sure we can access the NSS trust anchor module * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TrustAnchors * @run main/othervm TrustAnchors sm policy */ diff --git a/jdk/test/sun/security/pkcs11/SecureRandom/Basic.java b/jdk/test/sun/security/pkcs11/SecureRandom/Basic.java index 8c2c1686f73..3145431b867 100644 --- a/jdk/test/sun/security/pkcs11/SecureRandom/Basic.java +++ b/jdk/test/sun/security/pkcs11/SecureRandom/Basic.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6246411 * @summary basic test for PKCS#11 SecureRandom * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm Basic * @run main/othervm Basic sm */ diff --git a/jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java b/jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java index 117fb62d900..37985dd96e7 100644 --- a/jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java +++ b/jdk/test/sun/security/pkcs11/SecureRandom/TestDeserialization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -21,15 +21,22 @@ * questions. */ -/** +/* * @test * @bug 6837847 * @summary Ensure a deserialized PKCS#11 SecureRandom is functional. * @library .. + * @modules jdk.crypto.pkcs11 */ -import java.security.*; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.security.SecureRandom; +import java.security.Security; public class TestDeserialization extends PKCS11Test { diff --git a/jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java b/jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java index 35f13bb16a0..a3deb72c974 100644 --- a/jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java +++ b/jdk/test/sun/security/pkcs11/Serialize/SerializeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 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 @@ -21,18 +21,22 @@ * questions. */ -/** +/* * @test * @bug 4921802 * @summary Test that the SunPKCS11 provider can be serialized * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 */ -import java.io.*; -import java.util.*; - -import java.security.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.Provider; +import java.security.Security; public class SerializeProvider extends PKCS11Test { diff --git a/jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java b/jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java index 39e4424af35..3d1afa3bcb0 100644 --- a/jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java +++ b/jdk/test/sun/security/pkcs11/Signature/ByteBuffers.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test the Signature.update(ByteBuffer) method * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ByteBuffers * @run main/othervm ByteBuffers sm */ diff --git a/jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java b/jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java index 0f51ffaa096..30f1d7f4f17 100644 --- a/jdk/test/sun/security/pkcs11/Signature/ReinitSignature.java +++ b/jdk/test/sun/security/pkcs11/Signature/ReinitSignature.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 @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary test that reinitializing Signatures works correctly * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main ReinitSignature * @run main ReinitSignature * @run main ReinitSignature @@ -330,9 +331,13 @@ * @run main ReinitSignature */ -import java.util.*; - -import java.security.*; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.Provider; +import java.security.PublicKey; +import java.security.Signature; +import java.util.Random; public class ReinitSignature extends PKCS11Test { diff --git a/jdk/test/sun/security/pkcs11/Signature/TestDSA.java b/jdk/test/sun/security/pkcs11/Signature/TestDSA.java index c4fcf5d5956..b707d98ee20 100644 --- a/jdk/test/sun/security/pkcs11/Signature/TestDSA.java +++ b/jdk/test/sun/security/pkcs11/Signature/TestDSA.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary basic test of SHA1withDSA and RawDSA signing/verifying * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDSA * @run main/othervm TestDSA sm */ diff --git a/jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java b/jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java index f671bba3bd7..c1a0dc1bc57 100644 --- a/jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java +++ b/jdk/test/sun/security/pkcs11/Signature/TestDSAKeyLength.java @@ -28,6 +28,7 @@ * with unsupported key sizes * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestDSAKeyLength * @run main/othervm TestDSAKeyLength sm */ diff --git a/jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java b/jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java index 43341472e99..7618851bc2a 100644 --- a/jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java +++ b/jdk/test/sun/security/pkcs11/Signature/TestRSAKeyLength.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test %W% %E% * @bug 6695485 * @summary Make sure initSign/initVerify() check RSA key lengths * @author Yu-Ching Valerie Peng * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestRSAKeyLength * @run main/othervm TestRSAKeyLength sm */ diff --git a/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java b/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java index 4c0bbfba8f6..3117c983402 100644 --- a/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java +++ b/jdk/test/sun/security/pkcs11/ec/ReadCertificates.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 6414980 8051972 * @summary Make sure that we can parse certificates using various named curves @@ -29,6 +29,7 @@ * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm ReadCertificates * @run main/othervm ReadCertificates sm policy */ diff --git a/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java b/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java index 3252b08d195..57af80441f8 100644 --- a/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java +++ b/jdk/test/sun/security/pkcs11/ec/ReadPKCS12.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Verify that we can parse ECPrivateKeys from PKCS#12 and use them @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm ReadPKCS12 * @run main/othervm ReadPKCS12 sm policy */ diff --git a/jdk/test/sun/security/pkcs11/ec/TestECDH.java b/jdk/test/sun/security/pkcs11/ec/TestECDH.java index 421f46ccfc2..d5432b03968 100644 --- a/jdk/test/sun/security/pkcs11/ec/TestECDH.java +++ b/jdk/test/sun/security/pkcs11/ec/TestECDH.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Basic known answer test for ECDH * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm TestECDH * @run main/othervm TestECDH sm policy */ diff --git a/jdk/test/sun/security/pkcs11/ec/TestECDH2.java b/jdk/test/sun/security/pkcs11/ec/TestECDH2.java index dee7a706ce7..d064e5263c3 100644 --- a/jdk/test/sun/security/pkcs11/ec/TestECDH2.java +++ b/jdk/test/sun/security/pkcs11/ec/TestECDH2.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary basic test of ECDSA signatures for P-256 and P-384 from the @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @modules java.base/sun.security.util + * jdk.crypto.pkcs11 * @compile -XDignore.symbol.file TestECDH2.java * @run main/othervm TestECDH2 * @run main/othervm TestECDH2 sm diff --git a/jdk/test/sun/security/pkcs11/ec/TestECDSA.java b/jdk/test/sun/security/pkcs11/ec/TestECDSA.java index 9e0b8401aa9..fd5de680064 100644 --- a/jdk/test/sun/security/pkcs11/ec/TestECDSA.java +++ b/jdk/test/sun/security/pkcs11/ec/TestECDSA.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 8042967 * @summary basic test of SHA1withECDSA and NONEwithECDSA signing/verifying @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestECDSA * @run main/othervm TestECDSA sm policy */ diff --git a/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java b/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java index c2cd7188a03..fa0c5fc26b8 100644 --- a/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java +++ b/jdk/test/sun/security/pkcs11/ec/TestECDSA2.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary basic test of ECDSA signatures for P-256 and P-384 from the @@ -29,6 +29,7 @@ * @library .. * @library ../../../../java/security/testlibrary * @modules java.base/sun.security.util + * jdk.crypto.pkcs11 * @compile -XDignore.symbol.file TestECDSA2.java * @run main/othervm TestECDSA2 * @run main/othervm TestECDSA2 sm diff --git a/jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java b/jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java index 829b44ee7d9..4ce105030da 100644 --- a/jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java +++ b/jdk/test/sun/security/pkcs11/ec/TestECGenSpec.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Verify that we can use ECGenParameterSpec * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestECGenSpec * @run main/othervm TestECGenSpec sm */ diff --git a/jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java b/jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java index 519c861ce3d..827af91ed9e 100644 --- a/jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java +++ b/jdk/test/sun/security/pkcs11/ec/TestKeyFactory.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 6405536 * @summary Test the P11ECKeyFactory * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestKeyFactory * @run main/othervm TestKeyFactory sm */ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk index 7ea34d02d97..60c46169a6b 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.chk differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll index 6c03f7d54e5..bb662ad9e82 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/freebl3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll deleted file mode 100644 index fc573be7d36..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.dll and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib deleted file mode 100644 index 64aa29695e1..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libnspr4.lib and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll deleted file mode 100644 index 519c80e3e09..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.dll and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib deleted file mode 100644 index 1df6f28c331..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplc4.lib and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll deleted file mode 100644 index dc56672cb02..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.dll and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib deleted file mode 100644 index b424eefcce1..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/libplds4.lib and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll new file mode 100644 index 00000000000..5b65fc625f2 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib new file mode 100644 index 00000000000..f6026ecc84e Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nspr4.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll index 67f06d47bd1..18248a2b928 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib index c73d3efa1ad..278fd95ed9d 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nss3.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll index 28c84743adb..20b011561fe 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssckbi.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk index e8e9b94fb10..797ec741495 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.chk differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll index f1a722cd983..8eb93e01e6d 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssdbm3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll index 3eeca26f262..80f3ad0ad88 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib index 9f6ea2dee6c..819ade0768c 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/nssutil3.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll new file mode 100644 index 00000000000..94da505ad6a Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib new file mode 100644 index 00000000000..e319cd3873d Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plc4.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll new file mode 100644 index 00000000000..be9c1cf1691 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib new file mode 100644 index 00000000000..7a93bec3cb9 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/plds4.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk index f002c3468fe..85e7b4a5f64 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.chk differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll index 6293c7d1f20..7fb079f61ea 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/softokn3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll index 18c8fca90cb..288025baf05 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/sqlite3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll index 5e06d337e68..c00687e37b2 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib index 21e83def697..e96c9185843 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-amd64/ssl3.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk index 7f4e14757a5..a716ed40f75 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.chk differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll index eea9e978e04..e5934cf33d1 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/freebl3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll deleted file mode 100644 index f073dc911bd..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.dll and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib deleted file mode 100644 index 7351a9ebceb..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libnspr4.lib and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll deleted file mode 100644 index 0e74aec020e..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.dll and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib deleted file mode 100644 index cff555e3826..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplc4.lib and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll deleted file mode 100644 index 3247b929767..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.dll and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib deleted file mode 100644 index 876979f6473..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/libplds4.lib and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll new file mode 100644 index 00000000000..4ec833a7e35 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib new file mode 100644 index 00000000000..e6195bdae33 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nspr4.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll index 0411891b692..053aaa3ad93 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib index 1d8272ff195..a07111d38d4 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nss3.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll index 123a8bf6536..9013e5cf072 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssckbi.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk index bc51e406988..cf0c1048d57 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.chk differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll index 0572b4ecfdf..eedb562e31d 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssdbm3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll index f4dba08eeaf..a679872b0b7 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib index 7cd24f33feb..088c3960372 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/nssutil3.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll new file mode 100644 index 00000000000..d9b31663f3d Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib new file mode 100644 index 00000000000..7f2ad9b9298 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plc4.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll new file mode 100644 index 00000000000..07c08735491 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib new file mode 100644 index 00000000000..0f8854e72a2 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/plds4.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk index 84ea2e2d5ac..7f18d4830f1 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.chk differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll index 615e7c0a100..16eb7cc8227 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/softokn3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll index 9a130aa5606..08f0d702380 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/sqlite3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll index 41f962ae861..73d69a3512f 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.dll differ diff --git a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib index 72400591d64..99e29e2baec 100644 Binary files a/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib and b/jdk/test/sun/security/pkcs11/nss/lib/windows-i586/ssl3.lib differ diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz new file mode 100644 index 00000000000..63fa5feb510 Binary files /dev/null and b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz differ diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256 b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256 new file mode 100644 index 00000000000..e4802dc7dea --- /dev/null +++ b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16-with-nspr-4.10.4.tar.gz.sha256 @@ -0,0 +1 @@ +9d23633683ab3cea14519a22a997bc7f5d8d9664b6342df492c194966184ce0d nss-3.16-with-nspr-4.10.4.tar.gz diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz deleted file mode 100644 index 09273547484..00000000000 Binary files a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz and /dev/null differ diff --git a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256 b/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256 deleted file mode 100644 index 6ea9a98fef8..00000000000 --- a/jdk/test/sun/security/pkcs11/nss/src/nss-3.16_nspr-4.10_src.tar.gz.sha256 +++ /dev/null @@ -1 +0,0 @@ -d2374795528f9cf36de07bf7c77d8c8414bb5b4da12ee7c78a57ec90d68e3706 nss-3.16_nspr-4.10_src.tar.gz diff --git a/jdk/test/sun/security/pkcs11/rsa/KeyWrap.java b/jdk/test/sun/security/pkcs11/rsa/KeyWrap.java index e0bad7cd2d4..311a9b7f5aa 100644 --- a/jdk/test/sun/security/pkcs11/rsa/KeyWrap.java +++ b/jdk/test/sun/security/pkcs11/rsa/KeyWrap.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6231216 * @summary Verify key wrapping (of extractable keys) works for RSA/PKCS1 * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm KeyWrap * @run main/othervm KeyWrap sm */ diff --git a/jdk/test/sun/security/pkcs11/rsa/TestCACerts.java b/jdk/test/sun/security/pkcs11/rsa/TestCACerts.java index 24c16243585..a79330b8fcb 100644 --- a/jdk/test/sun/security/pkcs11/rsa/TestCACerts.java +++ b/jdk/test/sun/security/pkcs11/rsa/TestCACerts.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test the new RSA provider can verify all the RSA certs in the cacerts file * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm TestCACerts * @run main/othervm TestCACerts sm TestCACerts.policy */ diff --git a/jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java b/jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java index 802774285c3..d8292bcbad3 100644 --- a/jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java +++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyFactory.java @@ -21,12 +21,13 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test KeyFactory of the new RSA provider * @author Andreas Sterbenz * @library .. + * @modules jdk.crypto.pkcs11 * @run main/othervm TestKeyFactory * @run main/othervm TestKeyFactory sm rsakeys.ks.policy */ diff --git a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java index dd60d406fa6..84bbb60ab53 100644 --- a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java +++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Verify that the RSA KeyPairGenerator works (use -Dseed=X to set PRNG seed) @@ -29,6 +29,7 @@ * @library .. * @library /lib/testlibrary * @build jdk.testlibrary.* + * @modules jdk.crypto.pkcs11 * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator * sm TestKeyPairGenerator.policy diff --git a/jdk/test/sun/security/pkcs11/rsa/TestSignatures.java b/jdk/test/sun/security/pkcs11/rsa/TestSignatures.java index ae4718f4f56..84283b81ef8 100644 --- a/jdk/test/sun/security/pkcs11/rsa/TestSignatures.java +++ b/jdk/test/sun/security/pkcs11/rsa/TestSignatures.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 4856966 * @summary Test signing/verifying using all the signature algorithms * @author Andreas Sterbenz * @library .. * @key randomness + * @modules jdk.crypto.pkcs11 * @run main/othervm TestSignatures * @run main/othervm TestSignatures sm rsakeys.ks.policy */ diff --git a/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java b/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java index 1fab350dc9d..11fcaacaf79 100644 --- a/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java +++ b/jdk/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java @@ -33,6 +33,7 @@ * @author Andreas Sterbenz * @library .. * @library ../../../../java/security/testlibrary + * @modules jdk.crypto.pkcs11 * @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" * ClientJSSEServerJSSE * @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" diff --git a/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java b/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java index 1511dff4d4b..27944e92f89 100644 --- a/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java +++ b/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6316539 * @summary Known-answer-test for TlsKeyMaterial generator * @author Andreas Sterbenz * @library .. * @modules java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestKeyMaterial * @run main/othervm TestKeyMaterial sm policy */ diff --git a/jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java b/jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java index a8d8f72a299..2d9dc2890aa 100644 --- a/jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java +++ b/jdk/test/sun/security/pkcs11/tls/TestLeadingZeroesP11.java @@ -27,6 +27,7 @@ * @summary Need to strip leading zeros in TlsPremasterSecret of DHKeyAgreement * @library .. * @author Pasi Eronen + * @modules jdk.crypto.pkcs11 * @run main/othervm TestLeadingZeroesP11 * @run main/othervm TestLeadingZeroesP11 sm */ diff --git a/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java b/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java index 855b8c21f13..67ee6e708bd 100644 --- a/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java +++ b/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @bug 6316539 * @summary Known-answer-test for TlsMasterSecret generator @@ -29,6 +29,7 @@ * @library .. * @modules java.base/sun.security.internal.interfaces * java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestMasterSecret * @run main/othervm TestMasterSecret sm TestMasterSecret.policy */ diff --git a/jdk/test/sun/security/pkcs11/tls/TestPRF.java b/jdk/test/sun/security/pkcs11/tls/TestPRF.java index 6e05ea64f90..47b49e9a634 100644 --- a/jdk/test/sun/security/pkcs11/tls/TestPRF.java +++ b/jdk/test/sun/security/pkcs11/tls/TestPRF.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6316539 6345251 * @summary Basic known-answer-test for TlsPrf * @author Andreas Sterbenz * @library .. * @modules java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestPRF * @run main/othervm TestPRF sm policy */ diff --git a/jdk/test/sun/security/pkcs11/tls/TestPremaster.java b/jdk/test/sun/security/pkcs11/tls/TestPremaster.java index bbbbf2c376d..a179bb81c2a 100644 --- a/jdk/test/sun/security/pkcs11/tls/TestPremaster.java +++ b/jdk/test/sun/security/pkcs11/tls/TestPremaster.java @@ -21,13 +21,14 @@ * questions. */ -/** +/* * @test * @bug 6316539 * @summary Basic tests for TlsRsaPremasterSecret generator * @author Andreas Sterbenz * @library .. * @modules java.base/sun.security.internal.spec + * jdk.crypto.pkcs11 * @run main/othervm TestPremaster * @run main/othervm TestPremaster sm policy */ diff --git a/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java b/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java index 63d5fce25ba..55811ddaf53 100644 --- a/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.java +++ b/jdk/test/sun/security/provider/FileInputStreamPool/FileInputStreamPoolTest.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 @@ -69,7 +69,7 @@ public class FileInputStreamPoolTest { // make JVM process References System.gc(); // help ReferenceHandler thread enqueue References - while (TestProxy.Reference_tryHandlePending(false)) {} + while (TestProxy.Reference_waitForReferenceProcessing()) { } // help run Finalizers System.runFinalization(); } @@ -103,11 +103,11 @@ public class FileInputStreamPoolTest { /** * A proxy for (package)private static methods: * sun.security.provider.FileInputStreamPool.getInputStream - * java.lang.ref.Reference.tryHandlePending + * java.lang.ref.Reference.waitForReferenceProcessing */ static class TestProxy { private static final Method getInputStreamMethod; - private static final Method tryHandlePendingMethod; + private static final Method waitForReferenceProcessingMethod; static { try { @@ -118,9 +118,9 @@ public class FileInputStreamPoolTest { "getInputStream", File.class); getInputStreamMethod.setAccessible(true); - tryHandlePendingMethod = Reference.class.getDeclaredMethod( - "tryHandlePending", boolean.class); - tryHandlePendingMethod.setAccessible(true); + waitForReferenceProcessingMethod = + Reference.class.getDeclaredMethod("waitForReferenceProcessing"); + waitForReferenceProcessingMethod.setAccessible(true); } catch (Exception e) { throw new Error(e); } @@ -146,13 +146,14 @@ public class FileInputStreamPoolTest { } } - static boolean Reference_tryHandlePending(boolean waitForNotify) { + static boolean Reference_waitForReferenceProcessing() { try { - return (boolean) tryHandlePendingMethod - .invoke(null, waitForNotify); + return (boolean) waitForReferenceProcessingMethod.invoke(null); } catch (InvocationTargetException e) { Throwable te = e.getTargetException(); - if (te instanceof RuntimeException) { + if (te instanceof InterruptedException) { + return true; + } else if (te instanceof RuntimeException) { throw (RuntimeException) te; } else if (te instanceof Error) { throw (Error) te; 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/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java b/jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java index 38d513632dc..35cbf3a3b09 100644 --- a/jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java +++ b/jdk/test/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, 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 @@ -83,6 +83,8 @@ import java.io.*; import java.net.*; import java.security.*; import java.nio.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class SSLEngineBadBufferArrayAccess { @@ -103,9 +105,6 @@ public class SSLEngineBadBufferArrayAccess { private static boolean debug = false; private SSLContext sslc; private SSLEngine serverEngine; // server-side SSLEngine - private SSLSocket sslSocket; // client-side socket - private ServerSocket serverSocket; // server-side Socket, generates the... - private Socket socket; // server-side socket that will read private final byte[] serverMsg = "Hi there Client, I'm a Server".getBytes(); private final byte[] clientMsg = "Hello Server, I'm a Client".getBytes(); @@ -136,6 +135,21 @@ public class SSLEngineBadBufferArrayAccess { System.getProperty("test.src", ".") + "/" + pathToStores + "/" + trustStoreFile; + /* + * Is the server ready to serve? + */ + private static final CountDownLatch serverCondition = new CountDownLatch(1); + + /* + * Is the client ready to handshake? + */ + private static final CountDownLatch clientCondition = new CountDownLatch(1); + + /* + * What's the server port? Use any free port by default + */ + private volatile int serverPort = 0; + /* * Main entry point for this test. */ @@ -171,8 +185,13 @@ public class SSLEngineBadBufferArrayAccess { char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); - ts.load(new FileInputStream(trustFilename), passphrase); + try (FileInputStream fis = new FileInputStream(keyFilename)) { + ks.load(fis, passphrase); + } + + try (FileInputStream fis = new FileInputStream(trustFilename)) { + ts.load(fis, passphrase); + } KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); @@ -207,127 +226,177 @@ public class SSLEngineBadBufferArrayAccess { private void runTest(boolean direct) throws Exception { boolean serverClose = direct; - serverSocket = new ServerSocket(0); - int port = serverSocket.getLocalPort(); - Thread thread = createClientThread(port, serverClose); + ServerSocket serverSocket = new ServerSocket(0); + serverPort = serverSocket.getLocalPort(); + + // Signal the client, the server is ready to accept connection. + serverCondition.countDown(); + + Thread clientThread = runClient(serverClose); + + // Try to accept a connection in 30 seconds. + Socket socket; + try { + serverSocket.setSoTimeout(30000); + socket = (Socket) serverSocket.accept(); + } catch (SocketTimeoutException ste) { + serverSocket.close(); + + // Ignore the test case if no connection within 30 seconds. + System.out.println( + "No incoming client connection in 30 seconds. " + + "Ignore in server side."); + return; + } + + // handle the connection + try { + // Is it the expected client connection? + // + // Naughty test cases or third party routines may try to + // connection to this server port unintentionally. In + // order to mitigate the impact of unexpected client + // connections and avoid intermittent failure, it should + // be checked that the accepted connection is really linked + // to the expected client. + boolean clientIsReady = + clientCondition.await(30L, TimeUnit.SECONDS); + + if (clientIsReady) { + // Run the application in server side. + runServerApplication(socket, direct, serverClose); + } else { // Otherwise, ignore + // We don't actually care about plain socket connections + // for TLS communication testing generally. Just ignore + // the test if the accepted connection is not linked to + // the expected client or the client connection timeout + // in 30 seconds. + System.out.println( + "The client is not the expected one or timeout. " + + "Ignore in server side."); + } + } catch (Exception e) { + System.out.println("Server died ..."); + e.printStackTrace(System.out); + serverException = e; + } finally { + socket.close(); + serverSocket.close(); + } + + clientThread.join(); + + if (clientException != null || serverException != null) { + throw new RuntimeException("Test failed"); + } + } + + /* + * Define the server side application of the test for the specified socket. + */ + void runServerApplication(Socket socket, boolean direct, + boolean serverClose) throws Exception { - socket = serverSocket.accept(); socket.setSoTimeout(500); - serverSocket.close(); createSSLEngine(); createBuffers(direct); - try { - boolean closed = false; + boolean closed = false; - InputStream is = socket.getInputStream(); - OutputStream os = socket.getOutputStream(); + InputStream is = socket.getInputStream(); + OutputStream os = socket.getOutputStream(); - SSLEngineResult serverResult; // results from last operation + SSLEngineResult serverResult; // results from last operation - /* - * Examining the SSLEngineResults could be much more involved, - * and may alter the overall flow of the application. - * - * For example, if we received a BUFFER_OVERFLOW when trying - * to write to the output pipe, we could reallocate a larger - * pipe, but instead we wait for the peer to drain it. - */ - byte[] inbound = new byte[8192]; - byte[] outbound = new byte[8192]; + /* + * Examining the SSLEngineResults could be much more involved, + * and may alter the overall flow of the application. + * + * For example, if we received a BUFFER_OVERFLOW when trying + * to write to the output pipe, we could reallocate a larger + * pipe, but instead we wait for the peer to drain it. + */ + byte[] inbound = new byte[8192]; + byte[] outbound = new byte[8192]; - while (!isEngineClosed(serverEngine)) { - int len = 0; + while (!isEngineClosed(serverEngine)) { + int len = 0; - // Inbound data - log("================"); + // Inbound data + log("================"); - // Read from the Client side. - try { - len = is.read(inbound); - if (len == -1) { - throw new Exception("Unexpected EOF"); - } - cTOs.put(inbound, 0, len); - } catch (SocketTimeoutException ste) { - // swallow. Nothing yet, probably waiting on us. + // Read from the Client side. + try { + len = is.read(inbound); + if (len == -1) { + throw new Exception("Unexpected EOF"); } + cTOs.put(inbound, 0, len); + } catch (SocketTimeoutException ste) { + // swallow. Nothing yet, probably waiting on us. + System.out.println("Warning: " + ste); + } - cTOs.flip(); + cTOs.flip(); - serverResult = serverEngine.unwrap(cTOs, serverIn); - log("server unwrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - cTOs.compact(); + serverResult = serverEngine.unwrap(cTOs, serverIn); + log("server unwrap: ", serverResult); + runDelegatedTasks(serverResult, serverEngine); + cTOs.compact(); - // Outbound data - log("----"); + // Outbound data + log("----"); - serverResult = serverEngine.wrap(serverOut, sTOc); - log("server wrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); + serverResult = serverEngine.wrap(serverOut, sTOc); + log("server wrap: ", serverResult); + runDelegatedTasks(serverResult, serverEngine); - sTOc.flip(); + sTOc.flip(); - if ((len = sTOc.remaining()) != 0) { - sTOc.get(outbound, 0, len); - os.write(outbound, 0, len); - // Give the other side a chance to process - } + if ((len = sTOc.remaining()) != 0) { + sTOc.get(outbound, 0, len); + os.write(outbound, 0, len); + // Give the other side a chance to process + } - sTOc.compact(); + sTOc.compact(); - if (!closed && (serverOut.remaining() == 0)) { - closed = true; + if (!closed && (serverOut.remaining() == 0)) { + closed = true; - /* - * We'll alternate initiatating the shutdown. - * When the server initiates, it will take one more - * loop, but tests the orderly shutdown. - */ - if (serverClose) { - serverEngine.closeOutbound(); - } - } - - if (closed && isEngineClosed(serverEngine)) { - serverIn.flip(); - - /* - * A sanity check to ensure we got what was sent. - */ - if (serverIn.remaining() != clientMsg.length) { - throw new Exception("Client: Data length error -" + - " IF THIS FAILS, PLEASE REPORT THIS TO THE" + - " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + - " RELIABLY DUPLICATE."); - } - - for (int i = 0; i < clientMsg.length; i++) { - if (clientMsg[i] != serverIn.get()) { - throw new Exception("Client: Data content error -" + - " IF THIS FAILS, PLEASE REPORT THIS TO THE" + - " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + - " RELIABLY DUPLICATE."); - } - } - serverIn.compact(); + /* + * We'll alternate initiatating the shutdown. + * When the server initiates, it will take one more + * loop, but tests the orderly shutdown. + */ + if (serverClose) { + serverEngine.closeOutbound(); } } - return; - } catch (Exception e) { - serverException = e; - } finally { - socket.close(); - // Wait for the client to join up with us. - thread.join(); - if (serverException != null) { - throw serverException; - } - if (clientException != null) { - throw clientException; + if (closed && isEngineClosed(serverEngine)) { + serverIn.flip(); + + /* + * A sanity check to ensure we got what was sent. + */ + if (serverIn.remaining() != clientMsg.length) { + throw new Exception("Client: Data length error -" + + " IF THIS FAILS, PLEASE REPORT THIS TO THE" + + " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + + " RELIABLY DUPLICATE."); + } + + for (int i = 0; i < clientMsg.length; i++) { + if (clientMsg[i] != serverIn.get()) { + throw new Exception("Client: Data content error -" + + " IF THIS FAILS, PLEASE REPORT THIS TO THE" + + " SECURITY TEAM. WE HAVE BEEN UNABLE TO" + + " RELIABLY DUPLICATE."); + } + } + serverIn.compact(); } } } @@ -336,56 +405,113 @@ public class SSLEngineBadBufferArrayAccess { * Create a client thread which does simple SSLSocket operations. * We'll write and read one data packet. */ - private Thread createClientThread(final int port, - final boolean serverClose) throws Exception { + private Thread runClient(final boolean serverClose) + throws Exception { Thread t = new Thread("ClientThread") { @Override public void run() { try { - Thread.sleep(1000); // Give server time to finish setup. - - sslSocket = (SSLSocket) sslc.getSocketFactory(). - createSocket("localhost", port); - OutputStream os = sslSocket.getOutputStream(); - InputStream is = sslSocket.getInputStream(); - - // write(byte[]) goes in one shot. - os.write(clientMsg); - - byte[] inbound = new byte[2048]; - int pos = 0; - - int len; -done: - while ((len = is.read(inbound, pos, 2048 - pos)) != -1) { - pos += len; - // Let the client do the closing. - if ((pos == serverMsg.length) && !serverClose) { - sslSocket.close(); - break done; - } - } - - if (pos != serverMsg.length) { - throw new Exception("Client: Data length error"); - } - - for (int i = 0; i < serverMsg.length; i++) { - if (inbound[i] != serverMsg[i]) { - throw new Exception("Client: Data content error"); - } - } + doClientSide(serverClose); } catch (Exception e) { + System.out.println("Client died ..."); + e.printStackTrace(System.out); clientException = e; } } }; + t.start(); return t; } + /* + * Define the client side of the test. + */ + void doClientSide(boolean serverClose) throws Exception { + // Wait for server to get started. + // + // The server side takes care of the issue if the server cannot + // get started in 90 seconds. The client side would just ignore + // the test case if the serer is not ready. + boolean serverIsReady = + serverCondition.await(90L, TimeUnit.SECONDS); + if (!serverIsReady) { + System.out.println( + "The server is not ready yet in 90 seconds. " + + "Ignore in client side."); + return; + } + + SSLSocketFactory sslsf = sslc.getSocketFactory(); + try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) { + try { + sslSocket.connect( + new InetSocketAddress("localhost", serverPort), 15000); + } catch (IOException ioe) { + // The server side may be impacted by naughty test cases or + // third party routines, and cannot accept connections. + // + // Just ignore the test if the connection cannot be + // established. + System.out.println( + "Cannot make a connection in 15 seconds. " + + "Ignore in client side."); + return; + } + + // OK, here the client and server get connected. + + // Signal the server, the client is ready to communicate. + clientCondition.countDown(); + + // There is still a chance in theory that the server thread may + // wait client-ready timeout and then quit. The chance should + // be really rare so we don't consider it until it becomes a + // real problem. + + // Run the application in client side. + runClientApplication(sslSocket, serverClose); + } + } + + /* + * Define the server side application of the test for the specified socket. + */ + void runClientApplication(SSLSocket sslSocket, boolean serverClose) + throws Exception { + + OutputStream os = sslSocket.getOutputStream(); + InputStream is = sslSocket.getInputStream(); + + // write(byte[]) goes in one shot. + os.write(clientMsg); + + byte[] inbound = new byte[2048]; + int pos = 0; + + int len; + while ((len = is.read(inbound, pos, 2048 - pos)) != -1) { + pos += len; + // Let the client do the closing. + if ((pos == serverMsg.length) && !serverClose) { + sslSocket.close(); + break; + } + } + + if (pos != serverMsg.length) { + throw new Exception("Client: Data length error"); + } + + for (int i = 0; i < serverMsg.length; i++) { + if (inbound[i] != serverMsg[i]) { + throw new Exception("Client: Data content error"); + } + } + } + /* * Using the SSLContext created during object creation, * create/configure the SSLEngines we'll use for this test. 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/security/tools/keytool/DefaultSignatureAlgorithm.java b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java index 90cfad8898c..0c718db925e 100644 --- a/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java +++ b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java @@ -26,6 +26,7 @@ * @bug 8138766 * @summary New default -sigalg for keytool * @modules java.base/sun.security.tools.keytool + * @modules jdk.crypto.ec * @run main/othervm DefaultSignatureAlgorithm RSA 1024 SHA256withRSA * @run main/othervm DefaultSignatureAlgorithm RSA 3072 SHA256withRSA * @run main/othervm DefaultSignatureAlgorithm RSA 3073 SHA384withRSA diff --git a/jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java b/jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java index 17e2e7caa53..0b5bdf7900a 100644 --- a/jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java +++ b/jdk/test/sun/security/x509/URICertStore/ExtensionsWithLDAP.java @@ -23,6 +23,15 @@ * questions. */ +/* + * @test + * @bug 8134708 + * @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded + * @run main/othervm ExtensionsWithLDAP CRLDP ldap.host.for.crldp + * @modules jdk.security.auth + * @run main/othervm ExtensionsWithLDAP AIA ldap.host.for.aia + */ + import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -45,13 +54,6 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; -/* - * @test - * @bug 8134708 - * @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded - * @run main/othervm ExtensionsWithLDAP CRLDP ldap.host.for.crldp - * @run main/othervm ExtensionsWithLDAP AIA ldap.host.for.aia - */ public class ExtensionsWithLDAP { /* diff --git a/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java b/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java index 479cbc10621..6fde08c73c9 100644 --- a/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java +++ b/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.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 @@ -21,6 +21,17 @@ * questions. */ +/* + * @test + * @bug 8049237 + * @modules java.base/sun.security.x509 + * java.base/sun.security.util + * jdk.crypto.ec + * @summary This test generates V3 certificate with all the supported + * extensions. Writes back the generated certificate in to a file and checks for + * equality with the original certificate. + */ + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -28,7 +39,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; -import static java.lang.System.out; import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -50,15 +60,8 @@ import sun.security.util.BitArray; import sun.security.util.ObjectIdentifier; import sun.security.x509.*; -/** - * @test - * @bug 8049237 - * @modules java.base/sun.security.x509 - * java.base/sun.security.util - * @summary This test generates V3 certificate with all the supported - * extensions. Writes back the generated certificate in to a file and checks for - * equality with the original certificate. - */ +import static java.lang.System.out; + public class V3Certificate { public static final String V3_FILE = "certV3"; 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/LocaleData b/jdk/test/sun/text/resources/LocaleData index 53516a7ead4..a4bae5a9c21 100644 --- a/jdk/test/sun/text/resources/LocaleData +++ b/jdk/test/sun/text/resources/LocaleData @@ -6403,8 +6403,8 @@ CurrencyNames//bgn=Bulgarian Lev CurrencyNames//bif=Burundian Franc CurrencyNames//bob=Bolivian Boliviano CurrencyNames//btn=Bhutanese Ngultrum -CurrencyNames//byb=Belarusian New Ruble (1994-1999) -CurrencyNames//byr=Belarusian Ruble +CurrencyNames//byb=Belarusian Ruble (1994-1999) +CurrencyNames//byr=Belarusian Ruble (2000-2016) CurrencyNames//cdf=Congolese Franc CurrencyNames//clf=Chilean Unit of Account (UF) CurrencyNames//cny=Chinese Yuan @@ -6436,7 +6436,6 @@ CurrencyNames//mop=Macanese Pataca CurrencyNames//mro=Mauritanian Ouguiya CurrencyNames//mur=Mauritian Rupee CurrencyNames//mvr=Maldivian Rufiyaa -CurrencyNames//mwk=Malawian Kwacha CurrencyNames//mxv=Mexican Investment Unit CurrencyNames//mzm=Mozambican Metical (1980-2006) CurrencyNames//mzn=Mozambican Metical @@ -6444,7 +6443,6 @@ CurrencyNames//nad=Namibian Dollar CurrencyNames//nio=Nicaraguan C\u00f3rdoba CurrencyNames//nlg=Dutch Guilder CurrencyNames//omr=Omani Rial -CurrencyNames//pen=Peruvian Nuevo Sol CurrencyNames//pgk=Papua New Guinean Kina CurrencyNames//pkr=Pakistani Rupee CurrencyNames//pyg=Paraguayan Guarani @@ -8287,3 +8285,11 @@ FormatData/de/standalone.MonthAbbreviations/2=M\u00e4r # bug #8129361 CurrencyNames//hrk=Kuna + +# bug #8164784 +CurrencyNames//mwk=Malawian Malawi Kwacha +CurrencyNames//pen=Peruvian Sol + +# bug #8145952 +CurrencyNames//byn=Belarusian Ruble +CurrencyNames/be_BY/BYN=\u0420\u0443\u0431 diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java index 6f1dca3e0d0..c8631e63875 100644 --- a/jdk/test/sun/text/resources/LocaleDataTest.java +++ b/jdk/test/sun/text/resources/LocaleDataTest.java @@ -37,9 +37,10 @@ * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 * 8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916 - * 8145136 + * 8145136 8145952 8164784 * @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..998e1b2eed2 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -24,19 +24,17 @@ /* * @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.* * @run main BasicLauncherTest */ -import static jdk.testlibrary.Asserts.assertTrue; - import java.io.BufferedReader; import java.io.IOException; +import java.io.OutputStream; import java.io.InputStreamReader; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Arrays; @@ -84,15 +82,56 @@ public class BasicLauncherTest { ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process toolProcess = processBuilder.start(); - toolProcess.getOutputStream().write("quit\n".getBytes()); - toolProcess.getOutputStream().close(); + + try (OutputStream out = toolProcess.getOutputStream()) { + out.write("universe\n".getBytes()); + out.write("printmdo -a\n".getBytes()); + out.write("quit\n".getBytes()); + } // By default child process output stream redirected to pipe, so we are reading it in foreground. - BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream())); + Exception unexpected = null; + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { + String line; + String unexpectedMsg = + "One or more of 'VirtualCallData', 'CounterData', " + + "'ReceiverTypeData', 'bci', 'MethodData' " + + "or 'java/lang/Object' not found"; + boolean knownClassFound = false; + boolean knownProfileDataTypeFound = false; + boolean knownTokensFound = false; - String line; - while ((line = reader.readLine()) != null) { - System.out.println(line.trim()); + while ((line = reader.readLine()) != null) { + line = line.trim(); + System.out.println(line); + + if (line.contains("unknown subtype of CollectedHeap")) { + unexpected = new RuntimeException("CollectedHeap type should be known."); + break; + } + else if (line.contains("missing reason for ")) { + unexpected = new RuntimeException("missing reason for "); + break; + } + if (line.contains("VirtualCallData") || + line.contains("CounterData") || + line.contains("ReceiverTypeData")) { + knownProfileDataTypeFound = true; + } + if (line.contains("bci") || + line.contains("MethodData")) { + knownTokensFound = true; + } + if (line.contains("java/lang/Object")) { + knownClassFound = true; + } + } + if ((knownClassFound == false) || + (knownTokensFound == false) || + (knownProfileDataTypeFound == false)) { + unexpected = new RuntimeException(unexpectedMsg); + } } toolProcess.waitFor(); @@ -100,6 +139,14 @@ public class BasicLauncherTest { if (toolProcess.exitValue() != 0) { throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue()); } + + if (unexpected != null) { + throw unexpected; + } + + if (unexpected != null) { + throw unexpected; + } } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { @@ -183,21 +230,6 @@ public class BasicLauncherTest { Arrays.asList(toolArgs)); } - public static void testHeapDump() throws IOException { - File dump = new File("jhsdb.jmap.dump." + - System.currentTimeMillis() + ".hprof"); - if (dump.exists()) { - dump.delete(); - } - dump.deleteOnExit(); - - launch("heap written to", null, "jmap", - "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); - - assertTrue(dump.exists() && dump.isFile(), - "Could not create dump file " + dump.getAbsolutePath()); - } - public static void main(String[] args) throws IOException { @@ -216,8 +248,6 @@ public class BasicLauncherTest { "System Properties info not available", "jinfo"); launch("java.threads", null, "jsnap"); - testHeapDump(); - // The test throws RuntimeException on error. // IOException is thrown if LingeredApp can't start because of some bad // environment condition diff --git a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java new file mode 100644 index 00000000000..59772a3c421 --- /dev/null +++ b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java @@ -0,0 +1,129 @@ +/* + * 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 8163346 + * @summary Test hashing of extended characters in Serviceability Agent. + * @library /test/lib + * @library /lib/testlibrary + * @compile -encoding utf8 HeapDumpTest.java + * @run main/timeout=240 HeapDumpTest + */ + +import static jdk.testlibrary.Asserts.assertTrue; + +import java.io.IOException; +import java.io.File; +import java.util.List; +import java.util.Arrays; +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; +import jdk.test.lib.apps.LingeredApp; +import jdk.testlibrary.Platform; + +public class HeapDumpTest { + + private static LingeredAppWithExtendedChars theApp = null; + + /** + * + * @param vmArgs - tool arguments to launch jhsdb + * @return exit code of tool + */ + public static void launch(String expectedMessage, List toolArgs) + throws IOException { + + System.out.println("Starting LingeredApp"); + try { + theApp = new LingeredAppWithExtendedChars(); + LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp); + + System.out.println(theApp.\u00CB); + System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid()); + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); + + for (String cmd : toolArgs) { + launcher.addToolArg(cmd); + } + + launcher.addToolArg("--pid=" + Long.toString(theApp.getPid())); + + ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); + processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println("stdout:"); + System.out.println(output.getStdout()); + System.out.println("stderr:"); + System.out.println(output.getStderr()); + output.shouldContain(expectedMessage); + output.shouldHaveExitValue(0); + + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } finally { + LingeredApp.stopApp(theApp); + } + } + + public static void launch(String expectedMessage, String... toolArgs) + throws IOException { + + launch(expectedMessage, Arrays.asList(toolArgs)); + } + + public static void testHeapDump() throws IOException { + File dump = new File("jhsdb.jmap.heap." + + System.currentTimeMillis() + ".hprof"); + if (dump.exists()) { + dump.delete(); + } + + launch("heap written to", "jmap", + "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); + + assertTrue(dump.exists() && dump.isFile(), + "Could not create dump file " + dump.getAbsolutePath()); + + dump.delete(); + } + + public static void main(String[] args) + throws IOException { + + if (!Platform.shouldSAAttach()) { + // Silently skip the test if we don't have enough permissions to attach + System.err.println("Error! Insufficient permissions to attach - test skipped."); + return; + } + + + testHeapDump(); + + // The test throws RuntimeException on error. + // IOException is thrown if LingeredApp can't start because of some bad + // environment condition + System.out.println("Test PASSED"); + } +} diff --git a/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java b/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java new file mode 100644 index 00000000000..90431d25ab9 --- /dev/null +++ b/jdk/test/sun/tools/jhsdb/LingeredAppWithExtendedChars.java @@ -0,0 +1,32 @@ +/* + * 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 jdk.test.lib.apps.LingeredApp; + +public class LingeredAppWithExtendedChars extends LingeredApp { + + public static int \u00CB = 1; + + public static void main(String args[]) { + LingeredApp.main(args); + } + } 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/TestJpsJar.java b/jdk/test/sun/tools/jps/TestJpsJar.java index 00cc5423018..97d744ec85f 100644 --- a/jdk/test/sun/tools/jps/TestJpsJar.java +++ b/jdk/test/sun/tools/jps/TestJpsJar.java @@ -38,7 +38,7 @@ import jdk.testlibrary.ProcessTools; * @library /lib/testlibrary * @modules jdk.jartool/sun.tools.jar * java.management - * @build jdk.testlibrary.* JpsHelper JpsBase + * @build JpsHelper JpsBase * @run main/othervm TestJpsJar */ public class TestJpsJar { 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/IntegrationTest.java b/jdk/test/tools/jlink/IntegrationTest.java index ad0a01bd541..970e1371131 100644 --- a/jdk/test/tools/jlink/IntegrationTest.java +++ b/jdk/test/tools/jlink/IntegrationTest.java @@ -210,25 +210,29 @@ public class IntegrationTest { props.load(reader); } - if (props.getProperty("JAVA_VERSION") == null) { - throw new AssertionError("release file does not contain JAVA_VERSION"); - } - - if (props.getProperty("OS_NAME") == null) { - throw new AssertionError("release file does not contain OS_NAME"); - } - - if (props.getProperty("OS_ARCH") == null) { - throw new AssertionError("release file does not contain OS_ARCH"); - } - - if (props.getProperty("OS_VERSION") == null) { - throw new AssertionError("release file does not contain OS_VERSION"); - } + checkReleaseProperty(props, "JAVA_VERSION"); + checkReleaseProperty(props, "JAVA_FULL_VERSION"); + checkReleaseProperty(props, "OS_NAME"); + checkReleaseProperty(props, "OS_ARCH"); + checkReleaseProperty(props, "OS_VERSION"); if (!Files.exists(output.resolve("toto.txt"))) { throw new AssertionError("Post processing not called"); } } + + static void checkReleaseProperty(Properties props, String name) { + if (! props.containsKey(name)) { + throw new AssertionError("release file does not contain property : " + name); + } + + // property value is of min. length 3 and double quoted at the ends. + String value = props.getProperty(name); + if (value.length() < 3 || + value.charAt(0) != '"' || + value.charAt(value.length() - 1) != '"') { + throw new AssertionError("release property " + name + " is not quoted property"); + } + } } 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..c5fe36cee08 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -376,3 +376,6 @@ e181909291981038b041ed4d22714c4760e049cd jdk-9+129 aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131 2c17b65a37a8d7afdb9f96d5f11b28a3f21c78f2 jdk-9+132 7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133 +f08683786207a48b652266b3b7b908e6c863c3fc jdk-9+134 +af5eb8f3ffd21288305a54ea177ffad75021a741 jdk-9+135 +c8f02f0ecbd7cd6700f47416e4b7e9d5ec20ad77 jdk-9+136 diff --git a/langtools/make/tools/crules/MutableFieldsAnalyzer.java b/langtools/make/tools/crules/MutableFieldsAnalyzer.java index 538f7827dfa..0b082aca0ba 100644 --- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java +++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java @@ -105,12 +105,12 @@ public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer { "configurationClass", "resolveRequiresAndUsesMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Layer", "layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod"); + ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$Module", + "addExportsMethod", "addUsesMethod", "getModuleMethod", "getUnnamedModuleMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ServiceLoaderHelper", "loadMethod"); ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper", "vmClass", "getRuntimeArgumentsMethod"); - ignoreFields("com.sun.tools.javac.util.ModuleHelper", - "addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod"); } } 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/Annotate.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java index e3d97b68752..bf43a6e5ad4 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -92,6 +92,7 @@ public class Annotate { private final Attribute theUnfinishedDefaultValue; private final boolean allowRepeatedAnnos; + private final String sourceName; protected Annotate(Context context) { context.put(annotateKey, this); @@ -114,6 +115,7 @@ public class Annotate { Source source = Source.instance(context); allowRepeatedAnnos = source.allowRepeatedAnnotations(); + sourceName = source.name; } /** Semaphore to delay annotation processing */ @@ -322,7 +324,7 @@ public class Annotate { if (annotated.containsKey(a.type.tsym)) { if (!allowRepeatedAnnos) { - log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), "repeatable.annotations.not.supported.in.source"); + log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), "repeatable.annotations.not.supported.in.source", sourceName); } ListBuffer l = annotated.get(a.type.tsym); l = l.append(c); 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/LambdaToMethod.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 9e691e3039b..b491f69019a 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -2256,6 +2256,12 @@ public class LambdaToMethod extends TreeTranslator { types.erasure(owner.enclClass().asType())); } + boolean isProtectedInSuperClassOfEnclosingClassInOtherPackage() { + return ((tree.sym.flags() & PROTECTED) != 0 && + tree.sym.packge() != owner.packge() && + !owner.enclClass().isSubClass(tree.sym.owner, types)); + } + /** * Signature polymorphic methods need special handling. * e.g. MethodHandle.invoke() MethodHandle.invokeExact() @@ -2293,6 +2299,7 @@ public class LambdaToMethod extends TreeTranslator { needsVarArgsConversion() || isArrayOp() || isPrivateInOtherClass() || + isProtectedInSuperClassOfEnclosingClassInOtherPackage() || !receiverAccessible() || (tree.getMode() == ReferenceMode.NEW && tree.kind != ReferenceKind.ARRAY_CTOR && 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/JavacFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java index 4e3f4d78126..6a667bc7f3d 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -78,6 +78,7 @@ import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.JDK9Wrappers.Configuration; import com.sun.tools.javac.util.JDK9Wrappers.Layer; import com.sun.tools.javac.util.JDK9Wrappers.ModuleFinder; +import com.sun.tools.javac.util.JDK9Wrappers.Module; import com.sun.tools.javac.util.JDK9Wrappers.ServiceLoaderHelper; import static java.nio.file.FileVisitOption.FOLLOW_LINKS; @@ -957,6 +958,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil public ServiceLoader getServiceLoader(Location location, Class service) throws IOException { nullCheck(location); nullCheck(service); + Module.getModule(getClass()).addUses(service); if (location.isModuleLocation()) { Collection paths = locations.getLocation(location); ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[paths.size()])); 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/jvm/Gen.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java index 6f479f26a8c..216f141873c 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -1232,7 +1232,7 @@ public class Gen extends JCTree.Visitor { Chain exit = switchEnv.info.exit; if (exit != null) { code.resolve(exit); - exit.state.defined.excludeFrom(code.nextreg); + exit.state.defined.excludeFrom(limit); } // If we have not set the default offset, we do so now. 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/processing/JavacProcessingEnvironment.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 431d5b09ec6..ce066f83a39 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -79,6 +79,7 @@ import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Iterators; import com.sun.tools.javac.util.JCDiagnostic; +import com.sun.tools.javac.util.JDK9Wrappers.Module; import com.sun.tools.javac.util.JavacMessages; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Log; @@ -119,7 +120,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea private final JavacTypes typeUtils; private final JavaCompiler compiler; private final Modules modules; - private final ModuleHelper moduleHelper; private final Types types; /** @@ -227,7 +227,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea enter = Enter.instance(context); initialCompleter = ClassFinder.instance(context).getCompleter(); chk = Check.instance(context); - moduleHelper = ModuleHelper.instance(context); initProcessorLoader(); defaultModule = source.allowModules() && options.isUnset("noModules") @@ -265,7 +264,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) : fileManager.getClassLoader(CLASS_PATH); - moduleHelper.addExports(processorClassLoader); + if (options.isSet("accessInternalAPI")) + ModuleHelper.addExports(Module.getModule(getClass()), Module.getUnnamedModule(processorClassLoader)); if (processorClassLoader != null && processorClassLoader instanceof Closeable) { compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader); 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/JDK9Wrappers.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java index b933ee4b33a..8f3875ae63c 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java @@ -129,6 +129,85 @@ public class JDK9Wrappers { } } + /** + * Wrapper class for java.lang.reflect.Module. To materialize a handle use the static factory + * methods Module#getModule(Class) or Module#getUnnamedModule(ClassLoader). + */ + public static class Module { + + private final Object theRealModule; + + private Module(Object module) { + this.theRealModule = module; + init(); + } + + public static Module getModule(Class clazz) { + try { + init(); + Object result = getModuleMethod.invoke(clazz, new Object[0]); + return new Module(result); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | SecurityException ex) { + throw new Abort(ex); + } + } + + public static Module getUnnamedModule(ClassLoader classLoader) { + try { + init(); + Object result = getUnnamedModuleMethod.invoke(classLoader, new Object[0]); + return new Module(result); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | SecurityException ex) { + throw new Abort(ex); + } + } + + public Module addExports(String pn, Module other) { + try { + addExportsMethod.invoke(theRealModule, new Object[] { pn, other.theRealModule}); + } catch (IllegalAccessException | InvocationTargetException ex) { + throw new Abort(ex); + } + return this; + } + + public Module addUses(Class st) { + try { + addUsesMethod.invoke(theRealModule, new Object[] { st }); + } catch (IllegalAccessException | InvocationTargetException ex) { + throw new Abort(ex); + } + return this; + } + + // ----------------------------------------------------------------------------------------- + // on java.lang.reflect.Module + private static Method addExportsMethod = null; + // on java.lang.reflect.Module + private static Method addUsesMethod = null; + // on java.lang.Class + private static Method getModuleMethod; + // on java.lang.ClassLoader + private static Method getUnnamedModuleMethod; + + private static void init() { + if (addExportsMethod == null) { + try { + Class moduleClass = Class.forName("java.lang.reflect.Module", false, null); + addUsesMethod = moduleClass.getDeclaredMethod("addUses", new Class[] { Class.class }); + addExportsMethod = moduleClass.getDeclaredMethod("addExports", + new Class[] { String.class, moduleClass }); + getModuleMethod = Class.class.getDeclaredMethod("getModule", new Class[0]); + getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule", new Class[0]); + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) { + throw new Abort(ex); + } + } + } + } + /** * Wrapper class for java.lang.module.Configuration. */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java index 2b34d095d02..dd0315e837c 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleHelper.java @@ -25,88 +25,30 @@ package com.sun.tools.javac.util; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import com.sun.tools.javac.util.JDK9Wrappers.Module; public class ModuleHelper { - /** The context key for the module helper. */ - protected static final Context.Key moduleHelperKey = new Context.Key<>(); - /** Get the JavaCompiler instance for this context. */ - public static ModuleHelper instance(Context context) { - ModuleHelper instance = context.get(moduleHelperKey); - if (instance == null) - instance = new ModuleHelper(context); - return instance; - } + private static final String[] javacInternalPackages = new String[] { + "com.sun.tools.javac.api", + "com.sun.tools.javac.code", + "com.sun.tools.javac.comp", + "com.sun.tools.javac.file", + "com.sun.tools.javac.jvm", + "com.sun.tools.javac.main", + "com.sun.tools.javac.model", + "com.sun.tools.javac.parser", + "com.sun.tools.javac.platform", + "com.sun.tools.javac.processing", + "com.sun.tools.javac.tree", + "com.sun.tools.javac.util", - public ModuleHelper(Context context) { - context.put(moduleHelperKey, this); - Options options = Options.instance(context); - allowAccessToInternalAPI = options.isSet("accessInternalAPI"); - } - - final boolean allowAccessToInternalAPI; - - private void exportPackageToModule(String packageName, Object target) - throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, - InvocationTargetException, IllegalAccessException { - if (addExportsMethod == null) { - Class moduleClass = Class.forName("java.lang.reflect.Module"); - addExportsMethod = moduleClass.getDeclaredMethod("addExports", - new Class[] { String.class, moduleClass }); - } - addExportsMethod.invoke(from, new Object[] { packageName, target }); - } - - static final String[] javacInternalPackages = new String[] { - "com.sun.tools.javac.api", - "com.sun.tools.javac.code", - "com.sun.tools.javac.comp", - "com.sun.tools.javac.file", - "com.sun.tools.javac.jvm", - "com.sun.tools.javac.main", - "com.sun.tools.javac.model", - "com.sun.tools.javac.parser", - "com.sun.tools.javac.platform", - "com.sun.tools.javac.processing", - "com.sun.tools.javac.tree", - "com.sun.tools.javac.util", - - "com.sun.tools.doclint", + "com.sun.tools.doclint", }; - public void addExports(ClassLoader classLoader) { - try { - if (allowAccessToInternalAPI) { - if (from == null) { - if (getModuleMethod == null) { - getModuleMethod = Class.class.getDeclaredMethod("getModule", new Class[0]); - } - from = getModuleMethod.invoke(getClass(), new Object[0]); - } - if (getUnnamedModuleMethod == null) { - getUnnamedModuleMethod = ClassLoader.class.getDeclaredMethod("getUnnamedModule", new Class[0]); - } - Object target = getUnnamedModuleMethod.invoke(classLoader, new Object[0]); - for (String pack: javacInternalPackages) { - exportPackageToModule(pack, target); - } - } - } catch (Exception e) { - // do nothing + public static void addExports(Module from, Module to) { + for (String pack: javacInternalPackages) { + from.addExports(pack, to); } } - - // a module instance - private Object from = null; - - // on java.lang.reflect.Module - private static Method addExportsMethod = null; - - // on java.lang.ClassLoader - private static Method getUnnamedModuleMethod = null; - - // on java.lang.Class - private static Method getModuleMethod = null; -} +} \ No newline at end of file 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/doclets/formats/html/resources/search.js b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js index 965a9914055..ada2c64cba2 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js @@ -263,18 +263,18 @@ $(function() { if (ui.item.l !== noResult.l) { var url = ""; if (ui.item.category === catModules) { - url = "/" + ui.item.l + "-summary.html"; + url = ui.item.l + "-summary.html"; } else if (ui.item.category === catPackages) { url = ui.item.l.replace(/\./g, '/') + "/package-summary.html"; } else if (ui.item.category === catTypes) { if (ui.item.p === "") { - url = "/" + ui.item.l + ".html"; + url = ui.item.l + ".html"; } else { url = ui.item.p.replace(/\./g, '/') + "/" + ui.item.l + ".html"; } } else if (ui.item.category === catMembers) { if (ui.item.p === "") { - url = "/" + ui.item.c + ".html" + "#"; + url = ui.item.c + ".html" + "#"; } else { url = ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#"; } 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/SwitchExitStateTest.java b/langtools/test/tools/javac/SwitchExitStateTest.java new file mode 100644 index 00000000000..4b9e0d61e07 --- /dev/null +++ b/langtools/test/tools/javac/SwitchExitStateTest.java @@ -0,0 +1,49 @@ +/* + * 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 8160699 + * @summary Verify that having finished executing a switch statement live locals are exactly the same as it was upon entry of the switch. + * @run main SwitchExitStateTest + */ + +public class SwitchExitStateTest { + public static void main(String[] args) throws Exception { + switch (0) { + case 0: + String a = ""; + break; + default: + throw new Exception("Unknown "); + } + + switch (0) { + case 0: + String b = ""; + break; + default: + throw new Exception("Unknown "); + } + } +} \ No newline at end of file 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/T8003967/DetectMutableStaticFields.java b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java index a80877ed10d..82cff7badab 100644 --- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java +++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java @@ -106,12 +106,12 @@ public class DetectMutableStaticFields { // The following static fields are used for caches of information obtained // by reflective lookup, to avoid explicit references that are not available // when running javac on JDK 8. - ignore("com/sun/tools/javac/util/ModuleHelper", - "addExportsMethod", "getModuleMethod", "getUnnamedModuleMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$Configuration", "resolveRequiresAndUsesMethod", "configurationClass"); ignore("com/sun/tools/javac/util/JDK9Wrappers$Layer", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod", "layerClass"); + ignore("com/sun/tools/javac/util/JDK9Wrappers$Module", + "addExportsMethod", "addUsesMethod", "getModuleMethod", "getUnnamedModuleMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$ModuleFinder", "moduleFinderClass", "ofMethod"); ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper", 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/repeatingAnnotations/WrongVersion.java b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java new file mode 100644 index 00000000000..8b6efaade02 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8138822 + * @summary test that only Java 8+ allows repeating annotations + * @compile WrongVersion.java + * @compile -Xlint:-options -source 8 WrongVersion.java + * @compile/fail/ref=WrongVersion7.out -XDrawDiagnostics -Xlint:-options -source 7 WrongVersion.java + * @compile/fail/ref=WrongVersion6.out -XDrawDiagnostics -Xlint:-options -source 6 WrongVersion.java + */ +import java.lang.annotation.Repeatable; + +@Ann(1) @Ann(2) +class C { +} + +@Repeatable(AnnContainer.class) +@interface Ann { + int value(); +} + +@interface AnnContainer { + Ann[] value(); +} diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out new file mode 100644 index 00000000000..6b6237b9d39 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out @@ -0,0 +1,2 @@ +WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.6 +1 error diff --git a/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out new file mode 100644 index 00000000000..fd649e00067 --- /dev/null +++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out @@ -0,0 +1,2 @@ +WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.7 +1 error 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() { + @Override + public Void call() throws Exception { + final Runnable r = ProtectedInaccessibleMethodRefTest.this::myDo; + r.run(); + return null; + } + }.call(); + + new Callable() { + @Override + public Void call() throws Exception { + final Runnable r = ProtectedInaccessibleMethodRefTest::myStaticDo; + r.run(); + return null; + } + }.call(); + } + + public void message(String s) { + message = s; + } + + public static void main(String[] args) throws Exception { + new ProtectedInaccessibleMethodRefTest().doTest(); + if (!message.equals("OK!")) + throw new AssertionError("Unexpected output"); + if (!sMessage.equals("OK!")) + throw new AssertionError("Unexpected output"); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/pack/SuperClass.java b/langtools/test/tools/javac/lambda/methodReference/pack/SuperClass.java new file mode 100644 index 00000000000..5d2551daeb3 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/pack/SuperClass.java @@ -0,0 +1,40 @@ +/* + * 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. + */ + +package pack; + +public class SuperClass { + + public static String sMessage = "Not OK"; + + protected final void myDo() { + message("OK!"); + } + + protected static final void myStaticDo() { + sMessage = "OK!"; + } + + public void message(String s) { + } +} diff --git a/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java b/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java index 272cdd5d7d9..f589c276be0 100644 --- a/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java +++ b/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java @@ -210,7 +210,7 @@ public class StructuralMostSpecificTest extends ComboInstance loader = fm.getServiceLoader(StandardLocation.CLASS_PATH, + FileManagerGetServiceLoaderTest.class); + if (loader == null) { + throw new AssertionError("Could not obtain service loader"); + } + } +} diff --git a/langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java b/langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java new file mode 100644 index 00000000000..a2538834943 --- /dev/null +++ b/langtools/test/tools/javac/modules/T8160454/NPEGetDirectivesTest.java @@ -0,0 +1,70 @@ +/* + * 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 8160454 + * @summary JSR269 jigsaw update: javax.lang.model.element.ModuleElement.getDirectives() causes NPE on unnamed modules + * @modules + * jdk.compiler/com.sun.tools.javac.code + * jdk.compiler/com.sun.tools.javac.util + * @compile NPEGetDirectivesTest.java + * @compile -processor NPEGetDirectivesTest NPEGetDirectivesTest.java + */ + +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.*; + +import java.util.Set; + +import com.sun.tools.javac.code.Directive.RequiresDirective; +import com.sun.tools.javac.code.Symbol.ModuleSymbol; +import com.sun.tools.javac.util.Assert; + +import static com.sun.tools.javac.code.Directive.RequiresFlag.MANDATED; + +@SupportedAnnotationTypes("*") +public class NPEGetDirectivesTest extends AbstractProcessor { + @Override + public boolean process(Set 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..a8967cc9f52 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -75,11 +75,6 @@ endef # Param 1 - The file containing the MODULES list define create-info-file - $(call info-file-item, "JAVA_VERSION", "$(VERSION_NUMBER)") - $(call info-file-item, "JAVA_FULL_VERSION", "$(VERSION_STRING)") - $(call info-file-item, "OS_NAME", "$(REQUIRED_OS_NAME)") - $(call info-file-item, "OS_VERSION", "$(REQUIRED_OS_VERSION)") - $(call info-file-item, "OS_ARCH", "$(OPENJDK_TARGET_CPU_LEGACY)") $(if $(JDK_ARCH_ABI_PROP_NAME), \ $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)")) $(call info-file-item, "SOURCE", "$(strip $(ALL_SOURCE_TIPS))") @@ -116,8 +111,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 +128,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..26b80a32770 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -367,3 +367,6 @@ ff07be6106fa56b72c163244f45a3ecb4c995564 jdk-9+127 ee77c6b3713ab293e027ac3ea1cc16f86dac535f jdk-9+131 55a75af751dfe44039baef2b762ee7347021025b jdk-9+132 3a924b820d02b108cf57b51e145b5150d1eedcca jdk-9+133 +e05400ba935753c77697af936db24657eb811022 jdk-9+134 +cb00d5ef023a18a66fcb4311ed4474d4145c66e9 jdk-9+135 +f11b8f5c4ccbf9c87d283815abac6c0117fba3c0 jdk-9+136 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 90% rename from test/lib/share/classes/jdk/test/lib/Utils.java rename to test/lib/jdk/test/lib/Utils.java index 95e2bbab48a..6f83759666f 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 @@ -25,7 +25,6 @@ package jdk.test.lib; import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.ServerSocket; @@ -40,7 +39,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; @@ -48,10 +50,10 @@ import java.util.function.Consumer; import java.util.function.Function; 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. @@ -83,8 +85,15 @@ public final class Utils { */ public static final String TEST_SRC = System.getProperty("test.src", "").trim(); - private static Unsafe unsafe = null; + /* + * Returns the value of 'test.jdk' system property + */ + public static final String TEST_JDK = System.getProperty("test.jdk"); + /** + * Returns the value of 'test.classes' system property + */ + public static final String TEST_CLASSES = System.getProperty("test.classes", "."); /** * Defines property name for seed value. */ @@ -369,21 +378,6 @@ public final class Utils { return new String(Files.readAllBytes(filePath)); } - /** - * @return Unsafe instance. - */ - public static synchronized Unsafe getUnsafe() { - if (unsafe == null) { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException("Unable to get Unsafe instance.", e); - } - } - return unsafe; - } private static final char[] hexArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; /** @@ -446,6 +440,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 +647,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/unsafe/UnsafeHelper.java b/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java new file mode 100644 index 00000000000..4a6c92644a6 --- /dev/null +++ b/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java @@ -0,0 +1,52 @@ +/* + * 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. + */ + +package jdk.test.lib.unsafe; + +import jdk.internal.misc.Unsafe; +import java.lang.reflect.Field; + + +/** + * Helper class for accessing the jdk.internal.misc.Unsafe functionality + */ +public final class UnsafeHelper { + private static Unsafe unsafe = null; + + /** + * @return Unsafe instance. + */ + public static synchronized Unsafe getUnsafe() { + if (unsafe == null) { + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe) f.get(null); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException("Unable to get Unsafe instance.", e); + } + } + return unsafe; + } +} + 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; + } + +}