# HG changeset patch # User herrick # Date 1573571380 18000 # Node ID af9779f2d6bfdfd89c35753f5fb99c77233253e0 # Parent 74e44250e3a7d423195723a91a96941c903c3657# Parent 4dbdb7a8fa758c210467d8524d50c9c48cfb9fb5 Merge diff -r 74e44250e3a7 -r af9779f2d6bf make/autoconf/hotspot.m4 --- a/make/autoconf/hotspot.m4 Fri Nov 08 20:41:14 2019 -0500 +++ b/make/autoconf/hotspot.m4 Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -351,7 +351,8 @@ # Only enable ZGC on supported platforms AC_MSG_CHECKING([if zgc can be built]) if (test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xx86_64") || \ - (test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64"); then + (test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64") || + (test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"); then AC_MSG_RESULT([yes]) else DISABLED_JVM_FEATURES="$DISABLED_JVM_FEATURES zgc" diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp --- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -322,7 +322,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { // copy original code here assert(NativeGeneralJump::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF, - "not enough room for call"); + "not enough room for call, need %d", _bytes_to_copy); assert((_bytes_to_copy & 0x3) == 0, "must copy a multiple of four bytes"); Label call_patch; @@ -340,7 +340,7 @@ __ load_const(_obj, addrlit, R0); DEBUG_ONLY( compare_with_patch_site(__ code_section()->start() + being_initialized_entry, _pc_start, _bytes_to_copy); ) } else { - // Make a copy the code which is going to be patched. + // Make a copy of the code which is going to be patched. for (int i = 0; i < _bytes_to_copy; i++) { address ptr = (address)(_pc_start + i); int a_byte = (*ptr) & 0xFF; diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp --- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -743,10 +743,11 @@ if (UseCompressedOops && !wide) { // Encoding done in caller __ stw(from_reg->as_register(), offset, base); + __ verify_coop(from_reg->as_register(), FILE_AND_LINE); } else { __ std(from_reg->as_register(), offset, base); + __ verify_oop(from_reg->as_register(), FILE_AND_LINE); } - __ verify_oop(from_reg->as_register()); break; } case T_FLOAT : __ stfs(from_reg->as_float_reg(), offset, base); break; @@ -783,10 +784,11 @@ if (UseCompressedOops && !wide) { // Encoding done in caller. __ stwx(from_reg->as_register(), base, disp); + __ verify_coop(from_reg->as_register(), FILE_AND_LINE); // kills R0 } else { __ stdx(from_reg->as_register(), base, disp); + __ verify_oop(from_reg->as_register(), FILE_AND_LINE); // kills R0 } - __ verify_oop(from_reg->as_register()); // kills R0 break; } case T_FLOAT : __ stfsx(from_reg->as_float_reg(), base, disp); break; @@ -831,7 +833,7 @@ } else { __ ld(to_reg->as_register(), offset, base); } - __ verify_oop(to_reg->as_register()); + __ verify_oop(to_reg->as_register(), FILE_AND_LINE); break; } case T_FLOAT: __ lfs(to_reg->as_float_reg(), offset, base); break; @@ -862,7 +864,7 @@ } else { __ ldx(to_reg->as_register(), base, disp); } - __ verify_oop(to_reg->as_register()); + __ verify_oop(to_reg->as_register(), FILE_AND_LINE); break; } case T_FLOAT: __ lfsx(to_reg->as_float_reg() , base, disp); break; @@ -1141,7 +1143,7 @@ } if (addr->base()->type() == T_OBJECT) { - __ verify_oop(src); + __ verify_oop(src, FILE_AND_LINE); } PatchingStub* patch = NULL; @@ -1238,7 +1240,7 @@ ShouldNotReachHere(); } if (is_reference_type(to_reg->type())) { - __ verify_oop(to_reg->as_register()); + __ verify_oop(to_reg->as_register(), FILE_AND_LINE); } } @@ -1265,7 +1267,7 @@ } if (addr->base()->is_oop_register()) { - __ verify_oop(src); + __ verify_oop(src, FILE_AND_LINE); } PatchingStub* patch = NULL; @@ -2321,7 +2323,7 @@ *op->stub()->entry()); __ bind(*op->stub()->continuation()); - __ verify_oop(op->obj()->as_register()); + __ verify_oop(op->obj()->as_register(), FILE_AND_LINE); } @@ -2546,7 +2548,7 @@ Register Rtmp1 = op->tmp3()->as_register(); bool should_profile = op->should_profile(); - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); CodeStub* stub = op->stub(); // Check if it needs to be profiled. ciMethodData* md = NULL; @@ -3099,7 +3101,7 @@ assert(do_null || do_update, "why are we here?"); assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?"); - __ verify_oop(obj); + __ verify_oop(obj, FILE_AND_LINE); if (do_null) { if (!TypeEntries::was_null_seen(current_klass)) { diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -44,7 +44,7 @@ const Register temp_reg = R12_scratch2; Label Lmiss; - verify_oop(receiver); + verify_oop(receiver, FILE_AND_LINE); MacroAssembler::null_check(receiver, oopDesc::klass_offset_in_bytes(), &Lmiss); load_klass(temp_reg, receiver); @@ -100,7 +100,7 @@ // Load object header. ld(Rmark, oopDesc::mark_offset_in_bytes(), Roop); - verify_oop(Roop); + verify_oop(Roop, FILE_AND_LINE); // Save object being locked into the BasicObjectLock... std(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox); @@ -157,7 +157,7 @@ if (UseBiasedLocking) { // Load the object out of the BasicObjectLock. ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox); - verify_oop(Roop); + verify_oop(Roop, FILE_AND_LINE); biased_locking_exit(CCR0, Roop, R0, done); } // Test first it it is a fast recursive unlock. @@ -167,7 +167,7 @@ if (!UseBiasedLocking) { // Load object. ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox); - verify_oop(Roop); + verify_oop(Roop, FILE_AND_LINE); } // Check if it is still a light weight lock, this is is true if we see @@ -316,7 +316,7 @@ // relocInfo::runtime_call_type); } - verify_oop(obj); + verify_oop(obj, FILE_AND_LINE); } @@ -383,7 +383,7 @@ // relocInfo::runtime_call_type); } - verify_oop(obj); + verify_oop(obj, FILE_AND_LINE); } @@ -399,8 +399,7 @@ bne(CCR0, not_null); stop("non-null oop required"); bind(not_null); - if (!VerifyOops) return; - verify_oop(r); + verify_oop(r, FILE_AND_LINE); } #endif // PRODUCT diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -335,12 +335,12 @@ __ ld(value, 0, tmp1); // Resolve (untagged) jobject. __ beq(CCR0, not_weak); // Test for jweak tag. - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); g1_write_barrier_pre(masm, IN_NATIVE | ON_PHANTOM_OOP_REF, noreg, noreg, value, tmp1, tmp2, needs_frame); __ bind(not_weak); - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); __ bind(done); } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -113,7 +113,7 @@ __ clrrdi(tmp1, value, JNIHandles::weak_tag_size); __ ld(value, 0, tmp1); // Resolve (untagged) jobject. - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); __ bind(done); } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp --- a/src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -30,6 +30,10 @@ #error "CC_INTERP is no longer supported. Removed in change 8145117." #endif +#ifndef FILE_AND_LINE +#define FILE_AND_LINE __FILE__ ":" XSTR(__LINE__) +#endif + // Size of PPC Instructions const int BytesPerInstWord = 4; diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -2313,7 +2313,7 @@ } void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { - if (state == atos) { MacroAssembler::verify_oop(reg); } + if (state == atos) { MacroAssembler::verify_oop(reg, FILE_AND_LINE); } } // Local helper function for the verify_oop_or_return_address macro. diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/macroAssembler_ppc.cpp --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -3120,7 +3120,7 @@ li(R0, 0); std(R0, in_bytes(JavaThread::vm_result_offset()), R16_thread); - verify_oop(oop_result); + verify_oop(oop_result, FILE_AND_LINE); } void MacroAssembler::get_vm_result_2(Register metadata_result) { @@ -4917,6 +4917,13 @@ } } +void MacroAssembler::verify_coop(Register coop, const char* msg) { + if (!VerifyOops) { return; } + if (UseCompressedOops) { decode_heap_oop(coop); } + verify_oop(coop, msg); + if (UseCompressedOops) { encode_heap_oop(coop, coop); } +} + // READ: oop. KILL: R0. Volatile floats perhaps. void MacroAssembler::verify_oop(Register oop, const char* msg) { if (!VerifyOops) { @@ -4926,6 +4933,9 @@ address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address(); const Register tmp = R11; // Will be preserved. const int nbytes_save = MacroAssembler::num_volatile_regs * 8; + + BLOCK_COMMENT("verify_oop {"); + save_volatile_gprs(R1_SP, -nbytes_save); // except R0 mr_if_needed(R4_ARG2, oop); @@ -4942,6 +4952,8 @@ pop_frame(); restore_LR_CR(tmp); restore_volatile_gprs(R1_SP, -nbytes_save); // except R0 + + BLOCK_COMMENT("} verify_oop"); } void MacroAssembler::verify_oop_addr(RegisterOrConstant offs, Register base, const char* msg) { diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/macroAssembler_ppc.hpp --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -914,6 +914,9 @@ // Verify R16_thread contents. void verify_thread(); + // Calls verify_oop. If UseCompressedOops is on, decodes the oop. + // Preserves reg. + void verify_coop(Register reg, const char*); // Emit code to verify that reg contains a valid oop if +VerifyOops is set. void verify_oop(Register reg, const char* s = "broken oop"); void verify_oop_addr(RegisterOrConstant offs, Register base, const char* s = "contains broken oop"); diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/methodHandles_ppc.cpp --- a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -77,7 +77,7 @@ Klass* klass = SystemDictionary::well_known_klass(klass_id); Label L_ok, L_bad; BLOCK_COMMENT("verify_klass {"); - __ verify_oop(obj_reg); + __ verify_oop(obj_reg, FILE_AND_LINE); __ cmpdi(CCR0, obj_reg, 0); __ beq(CCR0, L_bad); __ load_klass(temp_reg, obj_reg); @@ -172,16 +172,16 @@ assert(method_temp == R19_method, "required register for loading method"); // Load the invoker, as MH -> MH.form -> LF.vmentry - __ verify_oop(recv); + __ verify_oop(recv, FILE_AND_LINE); __ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes()), recv, temp2, noreg, false, IS_NOT_NULL); - __ verify_oop(method_temp); + __ verify_oop(method_temp, FILE_AND_LINE); __ load_heap_oop(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes()), method_temp, temp2, noreg, false, IS_NOT_NULL); - __ verify_oop(method_temp); + __ verify_oop(method_temp, FILE_AND_LINE); __ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes()), method_temp, temp2, noreg, false, IS_NOT_NULL); - __ verify_oop(method_temp); + __ verify_oop(method_temp, FILE_AND_LINE); __ ld(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()), method_temp); if (VerifyMethodHandles && !for_compiler_entry) { @@ -318,7 +318,7 @@ Register temp1_recv_klass = temp1; if (iid != vmIntrinsics::_linkToStatic) { - __ verify_oop(receiver_reg); + __ verify_oop(receiver_reg, FILE_AND_LINE); if (iid == vmIntrinsics::_linkToSpecial) { // Don't actually load the klass; just null-check the receiver. __ null_check_throw(receiver_reg, -1, temp1, diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -1742,9 +1742,9 @@ assert(r->is_valid(), "bad oop arg"); if (r->is_stack()) { __ ld(temp_reg, reg2offset(r), R1_SP); - __ verify_oop(temp_reg); + __ verify_oop(temp_reg, FILE_AND_LINE); } else { - __ verify_oop(r->as_Register()); + __ verify_oop(r->as_Register(), FILE_AND_LINE); } } } @@ -2107,7 +2107,7 @@ __ cmpdi(CCR0, R3_ARG1, 0); __ beq(CCR0, ic_miss); - __ verify_oop(R3_ARG1); + __ verify_oop(R3_ARG1, FILE_AND_LINE); __ load_klass(receiver_klass, R3_ARG1); __ cmpd(CCR0, receiver_klass, ic); diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/ppc/stubGenerator_ppc.cpp --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -440,7 +440,6 @@ StubCodeMark mark(this, "StubRoutines", "forward_exception"); address start = __ pc(); -#if !defined(PRODUCT) if (VerifyOops) { // Get pending exception oop. __ ld(R3_ARG1, @@ -456,7 +455,6 @@ } __ verify_oop(R3_ARG1, "StubRoutines::forward exception: not an oop"); } -#endif // Save LR/CR and copy exception pc (LR) into R4_ARG2. __ save_LR_CR(R4_ARG2); @@ -702,9 +700,9 @@ #if !defined(PRODUCT) // Wrapper which calls oopDesc::is_oop_or_null() // Only called by MacroAssembler::verify_oop - static void verify_oop_helper(const char* message, oop o) { + static void verify_oop_helper(const char* message, oopDesc* o) { if (!oopDesc::is_oop_or_null(o)) { - fatal("%s", message); + fatal("%s. oop: " PTR_FORMAT, message, p2i(o)); } ++ StubRoutines::_verify_oop_count; } @@ -725,7 +723,6 @@ return start; } - // -XX:+OptimizeFill : convert fill/copy loops into intrinsic // // The code is implemented(ported from sparc) as we believe it benefits JVM98, however diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/sparc/c1_MacroAssembler_sparc.cpp --- a/src/hotspot/cpu/sparc/c1_MacroAssembler_sparc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/sparc/c1_MacroAssembler_sparc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -66,9 +66,9 @@ void C1_MacroAssembler::verified_entry() { - if (C1Breakpoint) breakpoint_trap(); - // build frame - verify_FPU(0, "method_entry"); + if (C1Breakpoint) { + breakpoint_trap(); + } } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/sparc/interp_masm_sparc.cpp --- a/src/hotspot/cpu/sparc/interp_masm_sparc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/sparc/interp_masm_sparc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -91,7 +91,6 @@ // dispatch. void InterpreterMacroAssembler::dispatch_epilog(TosState state, int bcp_incr) { assert_not_delayed(); - verify_FPU(1, state); interp_verify_oop(Otos_i, state, __FILE__, __LINE__); jmp( IdispatchAddress, 0 ); if (bcp_incr != 0) delayed()->inc(Lbcp, bcp_incr); @@ -264,7 +263,6 @@ // dispatch value in Lbyte_code and increment Lbcp void InterpreterMacroAssembler::dispatch_Lbyte_code(TosState state, address* table, int bcp_incr, bool verify, bool generate_poll) { - verify_FPU(1, state); // %%%%% maybe implement +VerifyActivationFrameSize here //verify_thread(); //too slow; we will just verify on method entry & exit if (verify) interp_verify_oop(Otos_i, state, __FILE__, __LINE__); @@ -2545,11 +2543,6 @@ } -void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) { - if (state == ftos || state == dtos) MacroAssembler::verify_FPU(stack_depth); -} - - // Jump if ((*counter_addr += increment) & mask) satisfies the condition. void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr, int increment, Address mask_addr, diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/sparc/interp_masm_sparc.hpp --- a/src/hotspot/cpu/sparc/interp_masm_sparc.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/sparc/interp_masm_sparc.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -321,7 +321,7 @@ // Debugging void interp_verify_oop(Register reg, TosState state, const char * file, int line); // only if +VerifyOops && state == atos void verify_oop_or_return_address(Register reg, Register rtmp); // for astore - void verify_FPU(int stack_depth, TosState state = ftos); // only if +VerifyFPU && (state == ftos || state == dtos) + void verify_FPU(int stack_depth, TosState state = ftos) {} // No-op. // support for JVMTI/Dtrace typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode; diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/sparc/macroAssembler_sparc.cpp --- a/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -1130,21 +1130,6 @@ } } - -// pushes double TOS element of FPU stack on CPU stack; pops from FPU stack -void MacroAssembler::push_fTOS() { - // %%%%%% need to implement this -} - -// pops double TOS element from CPU stack and pushes on FPU stack -void MacroAssembler::pop_fTOS() { - // %%%%%% need to implement this -} - -void MacroAssembler::empty_FPU_stack() { - // %%%%%% need to implement this -} - void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * file, int line) { // plausibility check for oops if (!VerifyOops) return; @@ -2826,47 +2811,6 @@ bind(done); } - - -void MacroAssembler::print_CPU_state() { - // %%%%% need to implement this -} - -void MacroAssembler::verify_FPU(int stack_depth, const char* s) { - // %%%%% need to implement this -} - -void MacroAssembler::push_IU_state() { - // %%%%% need to implement this -} - - -void MacroAssembler::pop_IU_state() { - // %%%%% need to implement this -} - - -void MacroAssembler::push_FPU_state() { - // %%%%% need to implement this -} - - -void MacroAssembler::pop_FPU_state() { - // %%%%% need to implement this -} - - -void MacroAssembler::push_CPU_state() { - // %%%%% need to implement this -} - - -void MacroAssembler::pop_CPU_state() { - // %%%%% need to implement this -} - - - void MacroAssembler::verify_tlab() { #ifdef ASSERT if (UseTLAB && VerifyOops) { diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/sparc/macroAssembler_sparc.hpp --- a/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -649,10 +649,6 @@ inline void callr( Register s1, Register s2 ); inline void callr( Register s1, int simm13a, RelocationHolder const& rspec = RelocationHolder() ); - // Emits nothing on V8 - inline void iprefetch( address d, relocInfo::relocType rt = relocInfo::none ); - inline void iprefetch( Label& L); - inline void tst( Register s ); inline void ret( bool trace = false ); @@ -1056,23 +1052,6 @@ // check_and_forward_exception to handle exceptions when it is safe void check_and_forward_exception(Register scratch_reg); - // pushes double TOS element of FPU stack on CPU stack; pops from FPU stack - void push_fTOS(); - - // pops double TOS element from CPU stack and pushes on FPU stack - void pop_fTOS(); - - void empty_FPU_stack(); - - void push_IU_state(); - void pop_IU_state(); - - void push_FPU_state(); - void pop_FPU_state(); - - void push_CPU_state(); - void pop_CPU_state(); - // Returns the byte size of the instructions generated by decode_klass_not_null(). static int instr_size_for_decode_klass_not_null(); @@ -1092,15 +1071,11 @@ #define verify_method_ptr(reg) _verify_method_ptr(reg, "broken method " #reg, __FILE__, __LINE__) #define verify_klass_ptr(reg) _verify_klass_ptr(reg, "broken klass " #reg, __FILE__, __LINE__) - // only if +VerifyOops - void verify_FPU(int stack_depth, const char* s = "illegal FPU state"); - // only if +VerifyFPU void stop(const char* msg); // prints msg, dumps registers and stops execution void warn(const char* msg); // prints msg, but don't stop void untested(const char* what = ""); void unimplemented(const char* what = ""); void should_not_reach_here() { stop("should not reach here"); } - void print_CPU_state(); // oops in code AddressLiteral allocate_oop_address(jobject obj); // allocate_index diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp --- a/src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -278,13 +278,6 @@ inline void MacroAssembler::callr( Register s1, Register s2 ) { jmpl( s1, s2, O7 ); } inline void MacroAssembler::callr( Register s1, int simm13a, RelocationHolder const& rspec ) { jmpl( s1, simm13a, O7, rspec); } -// prefetch instruction -inline void MacroAssembler::iprefetch( address d, relocInfo::relocType rt ) { - Assembler::bp( never, true, xcc, pt, d, rt ); - Assembler::bp( never, true, xcc, pt, d, rt ); -} -inline void MacroAssembler::iprefetch( Label& L) { iprefetch( target(L) ); } - inline void MacroAssembler::tst( Register s ) { orcc( G0, s, G0 ); } inline void MacroAssembler::ret( bool trace ) { diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/gc/z/zBackingFile_bsd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/os/bsd/gc/z/zBackingFile_bsd.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "precompiled.hpp" +#include "gc/z/zBackingFile_bsd.hpp" +#include "gc/z/zErrno.hpp" +#include "gc/z/zGlobals.hpp" +#include "gc/z/zLargePages.inline.hpp" +#include "gc/z/zPhysicalMemory.inline.hpp" +#include "logging/log.hpp" +#include "runtime/globals.hpp" +#include "runtime/os.hpp" +#include "utilities/align.hpp" +#include "utilities/debug.hpp" + +#include +#include +#include +#include + +static int vm_flags_superpage() { + if (!ZLargePages::is_explicit()) { + return 0; + } + + const int page_size_in_megabytes = ZGranuleSize >> 20; + return page_size_in_megabytes << VM_FLAGS_SUPERPAGE_SHIFT; +} + +static ZErrno mremap(uintptr_t from_addr, uintptr_t to_addr, size_t size) { + mach_vm_address_t remap_addr = to_addr; + vm_prot_t remap_cur_prot; + vm_prot_t remap_max_prot; + + // Remap memory to an additional location + const kern_return_t res = mach_vm_remap(mach_task_self(), + &remap_addr, + size, + 0 /* mask */, + VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE | vm_flags_superpage(), + mach_task_self(), + from_addr, + FALSE /* copy */, + &remap_cur_prot, + &remap_max_prot, + VM_INHERIT_COPY); + + return (res == KERN_SUCCESS) ? ZErrno(0) : ZErrno(EINVAL); +} + +ZBackingFile::ZBackingFile() : + _base(0), + _size(0), + _initialized(false) { + + // Reserve address space for virtual backing file + _base = (uintptr_t)os::reserve_memory(MaxHeapSize); + if (_base == 0) { + // Failed + log_error(gc)("Failed to reserve address space for virtual backing file"); + return; + } + + // Successfully initialized + _initialized = true; +} + +bool ZBackingFile::is_initialized() const { + return _initialized; +} + +size_t ZBackingFile::size() const { + return _size; +} + +bool ZBackingFile::commit_inner(size_t offset, size_t length) { + assert(is_aligned(offset, os::vm_page_size()), "Invalid offset"); + assert(is_aligned(length, os::vm_page_size()), "Invalid length"); + + log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + offset / M, (offset + length) / M, length / M); + + const uintptr_t addr = _base + offset; + const void* const res = mmap((void*)addr, length, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (res == MAP_FAILED) { + ZErrno err; + log_error(gc)("Failed to commit memory (%s)", err.to_string()); + return false; + } + + const size_t end = offset + length; + if (end > _size) { + // Record new virtual file size + _size = end; + } + + // Success + return true; +} + +size_t ZBackingFile::commit(size_t offset, size_t length) { + // Try to commit the whole region + if (commit_inner(offset, length)) { + // Success + return length; + } + + // Failed, try to commit as much as possible + size_t start = offset; + size_t end = offset + length; + + for (;;) { + length = align_down((end - start) / 2, ZGranuleSize); + if (length == 0) { + // Done, don't commit more + return start - offset; + } + + if (commit_inner(start, length)) { + // Success, try commit more + start += length; + } else { + // Failed, try commit less + end -= length; + } + } +} + +size_t ZBackingFile::uncommit(size_t offset, size_t length) { + assert(is_aligned(offset, os::vm_page_size()), "Invalid offset"); + assert(is_aligned(length, os::vm_page_size()), "Invalid length"); + + log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + offset / M, (offset + length) / M, length / M); + + const uintptr_t start = _base + offset; + const void* const res = mmap((void*)start, length, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); + if (res == MAP_FAILED) { + ZErrno err; + log_error(gc)("Failed to uncommit memory (%s)", err.to_string()); + return 0; + } + + return length; +} + +void ZBackingFile::map(uintptr_t addr, size_t size, uintptr_t offset) const { + const ZErrno err = mremap(_base + offset, addr, size); + if (err) { + fatal("Failed to remap memory (%s)", err.to_string()); + } +} + +void ZBackingFile::unmap(uintptr_t addr, size_t size) const { + // Note that we must keep the address space reservation intact and just detach + // the backing memory. For this reason we map a new anonymous, non-accessible + // and non-reserved page over the mapping instead of actually unmapping. + const void* const res = mmap((void*)addr, size, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); + if (res == MAP_FAILED) { + ZErrno err; + fatal("Failed to map memory (%s)", err.to_string()); + } +} diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/gc/z/zBackingFile_bsd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/os/bsd/gc/z/zBackingFile_bsd.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef OS_BSD_GC_Z_ZBACKINGFILE_BSD_HPP +#define OS_BSD_GC_Z_ZBACKINGFILE_BSD_HPP + +#include "memory/allocation.hpp" + +class ZPhysicalMemory; + +// On macOS, we use a virtual backing file. It is represented by a reserved virtual +// address space, in which we commit physical memory using the mach_vm_map() API. +// The multi-mapping API simply remaps these addresses using mach_vm_remap() into +// the different heap views. This works as-if there was a backing file, it's just +// that the file is represented with memory mappings instead. + +class ZBackingFile { +private: + uintptr_t _base; + size_t _size; + bool _initialized; + + bool commit_inner(size_t offset, size_t length); + +public: + ZBackingFile(); + + bool is_initialized() const; + + size_t size() const; + + size_t commit(size_t offset, size_t length); + size_t uncommit(size_t offset, size_t length); + + void map(uintptr_t addr, size_t size, uintptr_t offset) const; + void unmap(uintptr_t addr, size_t size) const; +}; + +#endif // OS_BSD_GC_Z_ZBACKINGFILE_BSD_HPP diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/gc/z/zLargePages_bsd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/os/bsd/gc/z/zLargePages_bsd.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "precompiled.hpp" +#include "gc/z/zLargePages.hpp" +#include "runtime/globals.hpp" + +void ZLargePages::initialize_platform() { + if (UseLargePages) { + _state = Explicit; + } else { + _state = Disabled; + } +} diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "precompiled.hpp" +#include "gc/z/zNUMA.hpp" + +void ZNUMA::initialize_platform() { + _enabled = false; +} + +uint32_t ZNUMA::count() { + return 1; +} + +uint32_t ZNUMA::id() { + return 0; +} + +uint32_t ZNUMA::memory_id(uintptr_t addr) { + // NUMA support not enabled, assume everything belongs to node zero + return 0; +} diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "precompiled.hpp" +#include "gc/z/zAddress.inline.hpp" +#include "gc/z/zGlobals.hpp" +#include "gc/z/zLargePages.inline.hpp" +#include "gc/z/zPhysicalMemory.inline.hpp" +#include "gc/z/zPhysicalMemoryBacking_bsd.hpp" +#include "runtime/globals.hpp" +#include "runtime/init.hpp" +#include "runtime/os.hpp" +#include "utilities/align.hpp" +#include "utilities/debug.hpp" + +bool ZPhysicalMemoryBacking::is_initialized() const { + return _file.is_initialized(); +} + +void ZPhysicalMemoryBacking::warn_commit_limits(size_t max) const { + // Does nothing +} + +bool ZPhysicalMemoryBacking::supports_uncommit() { + assert(!is_init_completed(), "Invalid state"); + assert(_file.size() >= ZGranuleSize, "Invalid size"); + + // Test if uncommit is supported by uncommitting and then re-committing a granule + return commit(uncommit(ZGranuleSize)) == ZGranuleSize; +} + +size_t ZPhysicalMemoryBacking::commit(size_t size) { + size_t committed = 0; + + // Fill holes in the backing file + while (committed < size) { + size_t allocated = 0; + const size_t remaining = size - committed; + const uintptr_t start = _uncommitted.alloc_from_front_at_most(remaining, &allocated); + if (start == UINTPTR_MAX) { + // No holes to commit + break; + } + + // Try commit hole + const size_t filled = _file.commit(start, allocated); + if (filled > 0) { + // Successful or partialy successful + _committed.free(start, filled); + committed += filled; + } + if (filled < allocated) { + // Failed or partialy failed + _uncommitted.free(start + filled, allocated - filled); + return committed; + } + } + + // Expand backing file + if (committed < size) { + const size_t remaining = size - committed; + const uintptr_t start = _file.size(); + const size_t expanded = _file.commit(start, remaining); + if (expanded > 0) { + // Successful or partialy successful + _committed.free(start, expanded); + committed += expanded; + } + } + + return committed; +} + +size_t ZPhysicalMemoryBacking::uncommit(size_t size) { + size_t uncommitted = 0; + + // Punch holes in backing file + while (uncommitted < size) { + size_t allocated = 0; + const size_t remaining = size - uncommitted; + const uintptr_t start = _committed.alloc_from_back_at_most(remaining, &allocated); + assert(start != UINTPTR_MAX, "Allocation should never fail"); + + // Try punch hole + const size_t punched = _file.uncommit(start, allocated); + if (punched > 0) { + // Successful or partialy successful + _uncommitted.free(start, punched); + uncommitted += punched; + } + if (punched < allocated) { + // Failed or partialy failed + _committed.free(start + punched, allocated - punched); + return uncommitted; + } + } + + return uncommitted; +} + +ZPhysicalMemory ZPhysicalMemoryBacking::alloc(size_t size) { + assert(is_aligned(size, ZGranuleSize), "Invalid size"); + + ZPhysicalMemory pmem; + + // Allocate segments + for (size_t allocated = 0; allocated < size; allocated += ZGranuleSize) { + const uintptr_t start = _committed.alloc_from_front(ZGranuleSize); + assert(start != UINTPTR_MAX, "Allocation should never fail"); + pmem.add_segment(ZPhysicalMemorySegment(start, ZGranuleSize)); + } + + return pmem; +} + +void ZPhysicalMemoryBacking::free(const ZPhysicalMemory& pmem) { + const size_t nsegments = pmem.nsegments(); + + // Free segments + for (size_t i = 0; i < nsegments; i++) { + const ZPhysicalMemorySegment& segment = pmem.segment(i); + _committed.free(segment.start(), segment.size()); + } +} + +void ZPhysicalMemoryBacking::pretouch_view(uintptr_t addr, size_t size) const { + const size_t page_size = ZLargePages::is_explicit() ? ZGranuleSize : os::vm_page_size(); + os::pretouch_memory((void*)addr, (void*)(addr + size), page_size); +} + +void ZPhysicalMemoryBacking::map_view(const ZPhysicalMemory& pmem, uintptr_t addr, bool pretouch) const { + const size_t nsegments = pmem.nsegments(); + size_t size = 0; + + // Map segments + for (size_t i = 0; i < nsegments; i++) { + const ZPhysicalMemorySegment& segment = pmem.segment(i); + const uintptr_t segment_addr = addr + size; + _file.map(segment_addr, segment.size(), segment.start()); + size += segment.size(); + } + + // Pre-touch memory + if (pretouch) { + pretouch_view(addr, size); + } +} + +void ZPhysicalMemoryBacking::unmap_view(const ZPhysicalMemory& pmem, uintptr_t addr) const { + _file.unmap(addr, pmem.size()); +} + +uintptr_t ZPhysicalMemoryBacking::nmt_address(uintptr_t offset) const { + // From an NMT point of view we treat the first heap view (marked0) as committed + return ZAddress::marked0(offset); +} + +void ZPhysicalMemoryBacking::map(const ZPhysicalMemory& pmem, uintptr_t offset) const { + if (ZVerifyViews) { + // Map good view + map_view(pmem, ZAddress::good(offset), AlwaysPreTouch); + } else { + // Map all views + map_view(pmem, ZAddress::marked0(offset), AlwaysPreTouch); + map_view(pmem, ZAddress::marked1(offset), AlwaysPreTouch); + map_view(pmem, ZAddress::remapped(offset), AlwaysPreTouch); + } +} + +void ZPhysicalMemoryBacking::unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const { + if (ZVerifyViews) { + // Unmap good view + unmap_view(pmem, ZAddress::good(offset)); + } else { + // Unmap all views + unmap_view(pmem, ZAddress::marked0(offset)); + unmap_view(pmem, ZAddress::marked1(offset)); + unmap_view(pmem, ZAddress::remapped(offset)); + } +} + +void ZPhysicalMemoryBacking::debug_map(const ZPhysicalMemory& pmem, uintptr_t offset) const { + // Map good view + assert(ZVerifyViews, "Should be enabled"); + map_view(pmem, ZAddress::good(offset), false /* pretouch */); +} + +void ZPhysicalMemoryBacking::debug_unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const { + // Unmap good view + assert(ZVerifyViews, "Should be enabled"); + unmap_view(pmem, ZAddress::good(offset)); +} diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef OS_BSD_GC_Z_ZPHYSICALMEMORYBACKING_BSD_HPP +#define OS_BSD_GC_Z_ZPHYSICALMEMORYBACKING_BSD_HPP + +#include "gc/z/zBackingFile_bsd.hpp" +#include "gc/z/zMemory.hpp" + +class ZPhysicalMemory; + +class ZPhysicalMemoryBacking { +private: + ZBackingFile _file; + ZMemoryManager _committed; + ZMemoryManager _uncommitted; + + void pretouch_view(uintptr_t addr, size_t size) const; + void map_view(const ZPhysicalMemory& pmem, uintptr_t addr, bool pretouch) const; + void unmap_view(const ZPhysicalMemory& pmem, uintptr_t addr) const; + +public: + bool is_initialized() const; + + void warn_commit_limits(size_t max) const; + bool supports_uncommit(); + + size_t commit(size_t size); + size_t uncommit(size_t size); + + ZPhysicalMemory alloc(size_t size); + void free(const ZPhysicalMemory& pmem); + + uintptr_t nmt_address(uintptr_t offset) const; + + void map(const ZPhysicalMemory& pmem, uintptr_t offset) const; + void unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; + + void debug_map(const ZPhysicalMemory& pmem, uintptr_t offset) const; + void debug_unmap(const ZPhysicalMemory& pmem, uintptr_t offset) const; +}; + +#endif // OS_BSD_GC_Z_ZPHYSICALMEMORYBACKING_BSD_HPP diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/bsd/os_bsd.cpp --- a/src/hotspot/os/bsd/os_bsd.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/os/bsd/os_bsd.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -2845,15 +2845,11 @@ // and if UserSignalHandler is installed all bets are off if (CheckJNICalls) { if (libjsig_is_loaded) { - if (PrintJNIResolving) { - tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); - } + log_debug(jni, resolve)("Info: libjsig is activated, all active signal checking is disabled"); check_signals = false; } if (AllowUserSignalHandlers) { - if (PrintJNIResolving) { - tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); - } + log_debug(jni, resolve)("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); check_signals = false; } } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/os/linux/os_linux.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -4789,15 +4789,11 @@ // Log that signal checking is off only if -verbose:jni is specified. if (CheckJNICalls) { if (libjsig_is_loaded) { - if (PrintJNIResolving) { - tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); - } + log_debug(jni, resolve)("Info: libjsig is activated, all active signal checking is disabled"); check_signals = false; } if (AllowUserSignalHandlers) { - if (PrintJNIResolving) { - tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); - } + log_debug(jni, resolve)("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); check_signals = false; } } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/os/solaris/os_solaris.cpp --- a/src/hotspot/os/solaris/os_solaris.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/os/solaris/os_solaris.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -3684,15 +3684,11 @@ // Log that signal checking is off only if -verbose:jni is specified. if (CheckJNICalls) { if (libjsig_is_loaded) { - if (PrintJNIResolving) { - tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); - } + log_debug(jni, resolve)("Info: libjsig is activated, all active signal checking is disabled"); check_signals = false; } if (AllowUserSignalHandlers) { - if (PrintJNIResolving) { - tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); - } + log_debug(jni, resolve)("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); check_signals = false; } } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/adlc/output_h.cpp --- a/src/hotspot/share/adlc/output_h.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/adlc/output_h.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -758,10 +758,6 @@ fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask1, uint mask2) : _mask((((uint64_t)mask1) << 32) | mask2) {}\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint64_t mask) : _mask(mask) {}\n\n"); } - fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n"); - fprintf(fp_hpp, " _mask = in._mask;\n"); - fprintf(fp_hpp, " return *this;\n"); - fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n"); fprintf(fp_hpp, " return ((_mask & in2._mask) != 0);\n"); fprintf(fp_hpp, " }\n\n"); @@ -792,11 +788,6 @@ for (l = 1; l <= masklen; l++) fprintf(fp_hpp, "_mask%d(mask%d)%s", l, l, l < masklen ? ", " : " {}\n\n"); - fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n"); - for (l = 1; l <= masklen; l++) - fprintf(fp_hpp, " _mask%d = in._mask%d;\n", l, l); - fprintf(fp_hpp, " return *this;\n"); - fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask intersect(const Pipeline_Use_Cycle_Mask &in2) {\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask out;\n"); for (l = 1; l <= masklen; l++) diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/compiler/compilerDefinitions.cpp --- a/src/hotspot/share/compiler/compilerDefinitions.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -54,10 +54,13 @@ } else if (strcmp(CompilationMode, "high-only-quick-internal") == 0) { _high_only_quick_internal = true; } else { - jio_fprintf(defaultStream::error_stream(), "Unsupported compilation mode '%s', supported modes are: quick-only, high-only, high-only-quick-internal\n", CompilationMode); - return false; - } + jio_fprintf(defaultStream::error_stream(), "Unsupported compilation mode '%s', supported modes are: quick-only, high-only, high-only-quick-internal\n", CompilationMode); + return false; } + if (disable_intermediate()) { + CompLevel_initial_compile = CompLevel_full_optimization; + } + } return true; } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/gc/parallel/psParallelCompact.cpp --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -3201,46 +3201,6 @@ } } -void -PSParallelCompact::move_and_update(ParCompactionManager* cm, SpaceId space_id) { - const MutableSpace* sp = space(space_id); - if (sp->is_empty()) { - return; - } - - ParallelCompactData& sd = PSParallelCompact::summary_data(); - ParMarkBitMap* const bitmap = mark_bitmap(); - HeapWord* const dp_addr = dense_prefix(space_id); - HeapWord* beg_addr = sp->bottom(); - HeapWord* end_addr = sp->top(); - - assert(beg_addr <= dp_addr && dp_addr <= end_addr, "bad dense prefix"); - - const size_t beg_region = sd.addr_to_region_idx(beg_addr); - const size_t dp_region = sd.addr_to_region_idx(dp_addr); - if (beg_region < dp_region) { - update_and_deadwood_in_dense_prefix(cm, space_id, beg_region, dp_region); - } - - // The destination of the first live object that starts in the region is one - // past the end of the partial object entering the region (if any). - HeapWord* const dest_addr = sd.partial_obj_end(dp_region); - HeapWord* const new_top = _space_info[space_id].new_top(); - assert(new_top >= dest_addr, "bad new_top value"); - const size_t words = pointer_delta(new_top, dest_addr); - - if (words > 0) { - ObjectStartArray* start_array = _space_info[space_id].start_array(); - MoveAndUpdateClosure closure(bitmap, cm, start_array, dest_addr, words); - - ParMarkBitMap::IterationStatus status; - status = bitmap->iterate(&closure, dest_addr, end_addr); - assert(status == ParMarkBitMap::full, "iteration not complete"); - assert(bitmap->find_obj_beg(closure.source(), end_addr) == end_addr, - "live objects skipped because closure is full"); - } -} - jlong PSParallelCompact::millis_since_last_gc() { // We need a monotonically non-decreasing time in ms but // os::javaTimeMillis() does not guarantee monotonicity. diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/gc/parallel/psParallelCompact.hpp --- a/src/hotspot/share/gc/parallel/psParallelCompact.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/gc/parallel/psParallelCompact.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -1130,9 +1130,6 @@ static inline HeapWord* dense_prefix(SpaceId space_id); static inline ObjectStartArray* start_array(SpaceId space_id); - // Move and update the live objects in the specified space. - static void move_and_update(ParCompactionManager* cm, SpaceId space_id); - // Process the end of the given region range in the dense prefix. // This includes saving any object not updated. static void dense_prefix_regions_epilogue(ParCompactionManager* cm, diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/gc/shared/c2/barrierSetC2.cpp --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -149,10 +149,13 @@ Node* control = control_dependent ? kit->control() : NULL; if (in_native) { - load = kit->make_load(control, adr, val_type, access.type(), mo); + load = kit->make_load(control, adr, val_type, access.type(), mo, dep, + requires_atomic_access, unaligned, + mismatched, unsafe, access.barrier_data()); } else { load = kit->make_load(control, adr, val_type, access.type(), adr_type, mo, - dep, requires_atomic_access, unaligned, mismatched, unsafe); + dep, requires_atomic_access, unaligned, mismatched, unsafe, + access.barrier_data()); } } else { assert(!requires_atomic_access, "not yet supported"); @@ -162,7 +165,8 @@ MergeMemNode* mm = opt_access.mem(); PhaseGVN& gvn = opt_access.gvn(); Node* mem = mm->memory_at(gvn.C->get_alias_index(adr_type)); - load = LoadNode::make(gvn, control, mem, adr, adr_type, val_type, access.type(), mo, dep, unaligned, mismatched); + load = LoadNode::make(gvn, control, mem, adr, adr_type, val_type, access.type(), mo, + dep, unaligned, mismatched, unsafe, access.barrier_data()); load = gvn.transform(load); } access.set_raw_access(load); @@ -409,28 +413,28 @@ if (adr->bottom_type()->is_ptr_to_narrowoop()) { Node *newval_enc = kit->gvn().transform(new EncodePNode(new_val, new_val->bottom_type()->make_narrowoop())); Node *oldval_enc = kit->gvn().transform(new EncodePNode(expected_val, expected_val->bottom_type()->make_narrowoop())); - load_store = kit->gvn().transform(new CompareAndExchangeNNode(kit->control(), mem, adr, newval_enc, oldval_enc, adr_type, value_type->make_narrowoop(), mo)); + load_store = new CompareAndExchangeNNode(kit->control(), mem, adr, newval_enc, oldval_enc, adr_type, value_type->make_narrowoop(), mo); } else #endif { - load_store = kit->gvn().transform(new CompareAndExchangePNode(kit->control(), mem, adr, new_val, expected_val, adr_type, value_type->is_oopptr(), mo)); + load_store = new CompareAndExchangePNode(kit->control(), mem, adr, new_val, expected_val, adr_type, value_type->is_oopptr(), mo); } } else { switch (access.type()) { case T_BYTE: { - load_store = kit->gvn().transform(new CompareAndExchangeBNode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo)); + load_store = new CompareAndExchangeBNode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo); break; } case T_SHORT: { - load_store = kit->gvn().transform(new CompareAndExchangeSNode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo)); + load_store = new CompareAndExchangeSNode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo); break; } case T_INT: { - load_store = kit->gvn().transform(new CompareAndExchangeINode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo)); + load_store = new CompareAndExchangeINode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo); break; } case T_LONG: { - load_store = kit->gvn().transform(new CompareAndExchangeLNode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo)); + load_store = new CompareAndExchangeLNode(kit->control(), mem, adr, new_val, expected_val, adr_type, mo); break; } default: @@ -438,6 +442,9 @@ } } + load_store->as_LoadStore()->set_barrier_data(access.barrier_data()); + load_store = kit->gvn().transform(load_store); + access.set_raw_access(load_store); pin_atomic_op(access); @@ -466,50 +473,50 @@ Node *newval_enc = kit->gvn().transform(new EncodePNode(new_val, new_val->bottom_type()->make_narrowoop())); Node *oldval_enc = kit->gvn().transform(new EncodePNode(expected_val, expected_val->bottom_type()->make_narrowoop())); if (is_weak_cas) { - load_store = kit->gvn().transform(new WeakCompareAndSwapNNode(kit->control(), mem, adr, newval_enc, oldval_enc, mo)); + load_store = new WeakCompareAndSwapNNode(kit->control(), mem, adr, newval_enc, oldval_enc, mo); } else { - load_store = kit->gvn().transform(new CompareAndSwapNNode(kit->control(), mem, adr, newval_enc, oldval_enc, mo)); + load_store = new CompareAndSwapNNode(kit->control(), mem, adr, newval_enc, oldval_enc, mo); } } else #endif { if (is_weak_cas) { - load_store = kit->gvn().transform(new WeakCompareAndSwapPNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new WeakCompareAndSwapPNode(kit->control(), mem, adr, new_val, expected_val, mo); } else { - load_store = kit->gvn().transform(new CompareAndSwapPNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new CompareAndSwapPNode(kit->control(), mem, adr, new_val, expected_val, mo); } } } else { switch(access.type()) { case T_BYTE: { if (is_weak_cas) { - load_store = kit->gvn().transform(new WeakCompareAndSwapBNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new WeakCompareAndSwapBNode(kit->control(), mem, adr, new_val, expected_val, mo); } else { - load_store = kit->gvn().transform(new CompareAndSwapBNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new CompareAndSwapBNode(kit->control(), mem, adr, new_val, expected_val, mo); } break; } case T_SHORT: { if (is_weak_cas) { - load_store = kit->gvn().transform(new WeakCompareAndSwapSNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new WeakCompareAndSwapSNode(kit->control(), mem, adr, new_val, expected_val, mo); } else { - load_store = kit->gvn().transform(new CompareAndSwapSNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new CompareAndSwapSNode(kit->control(), mem, adr, new_val, expected_val, mo); } break; } case T_INT: { if (is_weak_cas) { - load_store = kit->gvn().transform(new WeakCompareAndSwapINode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new WeakCompareAndSwapINode(kit->control(), mem, adr, new_val, expected_val, mo); } else { - load_store = kit->gvn().transform(new CompareAndSwapINode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new CompareAndSwapINode(kit->control(), mem, adr, new_val, expected_val, mo); } break; } case T_LONG: { if (is_weak_cas) { - load_store = kit->gvn().transform(new WeakCompareAndSwapLNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new WeakCompareAndSwapLNode(kit->control(), mem, adr, new_val, expected_val, mo); } else { - load_store = kit->gvn().transform(new CompareAndSwapLNode(kit->control(), mem, adr, new_val, expected_val, mo)); + load_store = new CompareAndSwapLNode(kit->control(), mem, adr, new_val, expected_val, mo); } break; } @@ -518,6 +525,9 @@ } } + load_store->as_LoadStore()->set_barrier_data(access.barrier_data()); + load_store = kit->gvn().transform(load_store); + access.set_raw_access(load_store); pin_atomic_op(access); @@ -539,27 +549,30 @@ } else #endif { - load_store = kit->gvn().transform(new GetAndSetPNode(kit->control(), mem, adr, new_val, adr_type, value_type->is_oopptr())); + load_store = new GetAndSetPNode(kit->control(), mem, adr, new_val, adr_type, value_type->is_oopptr()); } } else { switch (access.type()) { case T_BYTE: - load_store = kit->gvn().transform(new GetAndSetBNode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndSetBNode(kit->control(), mem, adr, new_val, adr_type); break; case T_SHORT: - load_store = kit->gvn().transform(new GetAndSetSNode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndSetSNode(kit->control(), mem, adr, new_val, adr_type); break; case T_INT: - load_store = kit->gvn().transform(new GetAndSetINode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndSetINode(kit->control(), mem, adr, new_val, adr_type); break; case T_LONG: - load_store = kit->gvn().transform(new GetAndSetLNode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndSetLNode(kit->control(), mem, adr, new_val, adr_type); break; default: ShouldNotReachHere(); } } + load_store->as_LoadStore()->set_barrier_data(access.barrier_data()); + load_store = kit->gvn().transform(load_store); + access.set_raw_access(load_store); pin_atomic_op(access); @@ -581,21 +594,24 @@ switch(access.type()) { case T_BYTE: - load_store = kit->gvn().transform(new GetAndAddBNode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndAddBNode(kit->control(), mem, adr, new_val, adr_type); break; case T_SHORT: - load_store = kit->gvn().transform(new GetAndAddSNode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndAddSNode(kit->control(), mem, adr, new_val, adr_type); break; case T_INT: - load_store = kit->gvn().transform(new GetAndAddINode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndAddINode(kit->control(), mem, adr, new_val, adr_type); break; case T_LONG: - load_store = kit->gvn().transform(new GetAndAddLNode(kit->control(), mem, adr, new_val, adr_type)); + load_store = new GetAndAddLNode(kit->control(), mem, adr, new_val, adr_type); break; default: ShouldNotReachHere(); } + load_store->as_LoadStore()->set_barrier_data(access.barrier_data()); + load_store = kit->gvn().transform(load_store); + access.set_raw_access(load_store); pin_atomic_op(access); diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/gc/shared/c2/barrierSetC2.hpp --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -103,6 +103,7 @@ Node* _base; C2AccessValuePtr& _addr; Node* _raw_access; + uint8_t _barrier_data; void fixup_decorators(); @@ -113,7 +114,8 @@ _type(type), _base(base), _addr(addr), - _raw_access(NULL) + _raw_access(NULL), + _barrier_data(0) {} DecoratorSet decorators() const { return _decorators; } @@ -124,6 +126,9 @@ bool is_raw() const { return (_decorators & AS_RAW) != 0; } Node* raw_access() const { return _raw_access; } + uint8_t barrier_data() const { return _barrier_data; } + void set_barrier_data(uint8_t data) { _barrier_data = data; } + void set_raw_access(Node* raw_access) { _raw_access = raw_access; } virtual void set_memory() {} // no-op for normal accesses, but not for atomic accesses. diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -178,47 +178,36 @@ return size; } -static bool barrier_needed(C2Access& access) { - return ZBarrierSet::barrier_needed(access.decorators(), access.type()); +static void set_barrier_data(C2Access& access) { + if (ZBarrierSet::barrier_needed(access.decorators(), access.type())) { + if (access.decorators() & ON_WEAK_OOP_REF) { + access.set_barrier_data(ZLoadBarrierWeak); + } else { + access.set_barrier_data(ZLoadBarrierStrong); + } + } } Node* ZBarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const { - Node* result = BarrierSetC2::load_at_resolved(access, val_type); - if (barrier_needed(access) && access.raw_access()->is_Mem()) { - if ((access.decorators() & ON_WEAK_OOP_REF) != 0) { - access.raw_access()->as_Load()->set_barrier_data(ZLoadBarrierWeak); - } else { - access.raw_access()->as_Load()->set_barrier_data(ZLoadBarrierStrong); - } - } - - return result; + set_barrier_data(access); + return BarrierSetC2::load_at_resolved(access, val_type); } Node* ZBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val, Node* new_val, const Type* val_type) const { - Node* result = BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, val_type); - if (barrier_needed(access)) { - access.raw_access()->as_LoadStore()->set_barrier_data(ZLoadBarrierStrong); - } - return result; + set_barrier_data(access); + return BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, val_type); } Node* ZBarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val, Node* new_val, const Type* value_type) const { - Node* result = BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type); - if (barrier_needed(access)) { - access.raw_access()->as_LoadStore()->set_barrier_data(ZLoadBarrierStrong); - } - return result; + set_barrier_data(access); + return BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type); } Node* ZBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const { - Node* result = BarrierSetC2::atomic_xchg_at_resolved(access, new_val, val_type); - if (barrier_needed(access)) { - access.raw_access()->as_LoadStore()->set_barrier_data(ZLoadBarrierStrong); - } - return result; + set_barrier_data(access); + return BarrierSetC2::atomic_xchg_at_resolved(access, new_val, val_type); } bool ZBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/jvmci/jvmciCompilerToVM.cpp --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -34,6 +34,8 @@ #include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/jvmciCodeInstaller.hpp" #include "jvmci/jvmciRuntime.hpp" +#include "logging/log.hpp" +#include "logging/logTag.hpp" #include "memory/oopFactory.hpp" #include "memory/universe.hpp" #include "oops/constantPool.inline.hpp" @@ -2296,11 +2298,9 @@ method->name_and_sig_as_C_string(), p2i(method->native_function()), p2i(entry))); } method->set_native_function(entry, Method::native_bind_event_is_interesting); - if (PrintJNIResolving) { - tty->print_cr("[Dynamic-linking native method %s.%s ... JNI]", - method->method_holder()->external_name(), - method->name()->as_C_string()); - } + log_debug(jni, resolve)("[Dynamic-linking native method %s.%s ... JNI]", + method->method_holder()->external_name(), + method->name()->as_C_string()); } } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/jvmci/jvmci_globals.hpp --- a/src/hotspot/share/jvmci/jvmci_globals.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -49,10 +49,14 @@ "Enable JVMCI") \ \ experimental(bool, EnableJVMCIProduct, false, \ - "Allow JVMCI to be used in product mode") \ + "Allow JVMCI to be used in product mode. This alters a subset of "\ + "JVMCI flags to be non-experimental, defaults UseJVMCICompiler " \ + "to true and defaults UseJVMCINativeLibrary to true if a JVMCI " \ + "native library is available.") \ \ experimental(bool, UseJVMCICompiler, false, \ - "Use JVMCI as the default compiler") \ + "Use JVMCI as the default compiler. Defaults to true if " \ + "EnableJVMCIProduct is true.") \ \ experimental(bool, JVMCIPrintProperties, false, \ "Prints properties used by the JVMCI compiler and exits") \ @@ -117,7 +121,8 @@ experimental(bool, UseJVMCINativeLibrary, false, \ "Execute JVMCI Java code from a shared library " \ "instead of loading it from class files and executing it " \ - "on the HotSpot heap") \ + "on the HotSpot heap. Defaults to true if EnableJVMCIProduct is " \ + "true and a JVMCI native library is available.")\ \ NOT_COMPILER2(diagnostic(bool, UseMultiplyToLenIntrinsic, false, \ "Enables intrinsification of BigInteger.multiplyToLen()")) \ diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/oops/method.cpp --- a/src/hotspot/share/oops/method.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/oops/method.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -36,6 +36,8 @@ #include "interpreter/bytecodes.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/oopMapCache.hpp" +#include "logging/log.hpp" +#include "logging/logTag.hpp" #include "memory/allocation.inline.hpp" #include "memory/heapInspection.hpp" #include "memory/metadataFactory.hpp" @@ -448,11 +450,11 @@ } else { method->clear_native_function(); } - if (PrintJNIResolving) { + if (log_is_enabled(Debug, jni, resolve)) { ResourceMark rm(THREAD); - tty->print_cr("[Registering JNI native method %s.%s]", - method->method_holder()->external_name(), - method->name()->as_C_string()); + log_debug(jni, resolve)("[Registering JNI native method %s.%s]", + method->method_holder()->external_name(), + method->name()->as_C_string()); } return true; } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/opto/graphKit.cpp --- a/src/hotspot/share/opto/graphKit.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/opto/graphKit.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -1493,18 +1493,19 @@ bool require_atomic_access, bool unaligned, bool mismatched, - bool unsafe) { + bool unsafe, + uint8_t barrier_data) { assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" ); const TypePtr* adr_type = NULL; // debug-mode-only argument debug_only(adr_type = C->get_adr_type(adr_idx)); Node* mem = memory(adr_idx); Node* ld; if (require_atomic_access && bt == T_LONG) { - ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe); + ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe, barrier_data); } else if (require_atomic_access && bt == T_DOUBLE) { - ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe); + ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe, barrier_data); } else { - ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched, unsafe); + ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched, unsafe, barrier_data); } ld = _gvn.transform(ld); if (((bt == T_OBJECT) && C->do_escape_analysis()) || C->eliminate_boxing()) { diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/opto/graphKit.hpp --- a/src/hotspot/share/opto/graphKit.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/opto/graphKit.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -523,27 +523,27 @@ Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false, bool unsafe = false) { + bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0) { // This version computes alias_index from bottom_type return make_load(ctl, adr, t, bt, adr->bottom_type()->is_ptr(), mo, control_dependency, require_atomic_access, - unaligned, mismatched, unsafe); + unaligned, mismatched, unsafe, barrier_data); } Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, const TypePtr* adr_type, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false, bool unsafe = false) { + bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0) { // This version computes alias_index from an address type assert(adr_type != NULL, "use other make_load factory"); return make_load(ctl, adr, t, bt, C->get_alias_index(adr_type), mo, control_dependency, require_atomic_access, - unaligned, mismatched, unsafe); + unaligned, mismatched, unsafe, barrier_data); } // This is the base version which is given an alias index. Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, int adr_idx, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false, bool unsafe = false); + bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0); // Create & transform a StoreNode and store the effect into the // parser's memory state. diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/opto/loopTransform.cpp --- a/src/hotspot/share/opto/loopTransform.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/opto/loopTransform.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -2975,16 +2975,17 @@ } #ifdef ASSERT -static CountedLoopNode* locate_pre_from_main(CountedLoopNode *cl) { - Node *ctrl = cl->skip_predicates(); +static CountedLoopNode* locate_pre_from_main(CountedLoopNode* main_loop) { + assert(!main_loop->is_main_no_pre_loop(), "Does not have a pre loop"); + Node* ctrl = main_loop->skip_predicates(); assert(ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, ""); - Node *iffm = ctrl->in(0); + Node* iffm = ctrl->in(0); assert(iffm->Opcode() == Op_If, ""); - Node *p_f = iffm->in(0); + Node* p_f = iffm->in(0); assert(p_f->Opcode() == Op_IfFalse, ""); - CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd(); - assert(pre_end->loopnode()->is_pre_loop(), ""); - return pre_end->loopnode(); + CountedLoopNode* pre_loop = p_f->in(0)->as_CountedLoopEnd()->loopnode(); + assert(pre_loop->is_pre_loop(), "No pre loop found"); + return pre_loop; } #endif @@ -3010,7 +3011,7 @@ } CountedLoopNode* main_head = next_head->as_CountedLoop(); - if (!main_head->is_main_loop()) { + if (!main_head->is_main_loop() || main_head->is_main_no_pre_loop()) { return; } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/opto/memnode.cpp --- a/src/hotspot/share/opto/memnode.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/opto/memnode.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -806,7 +806,7 @@ //----------------------------LoadNode::make----------------------------------- // Polymorphic factory method: Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypePtr* adr_type, const Type *rt, BasicType bt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe, uint8_t barrier_data) { Compile* C = gvn.C; // sanity check the alias category against the created node type @@ -857,6 +857,7 @@ if (unsafe) { load->set_unsafe_access(); } + load->set_barrier_data(barrier_data); if (load->Opcode() == Op_LoadN) { Node* ld = gvn.transform(load); return new DecodeNNode(ld, ld->bottom_type()->make_ptr()); @@ -866,7 +867,7 @@ } LoadLNode* LoadLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe, uint8_t barrier_data) { bool require_atomic = true; LoadLNode* load = new LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, control_dependency, require_atomic); if (unaligned) { @@ -878,11 +879,12 @@ if (unsafe) { load->set_unsafe_access(); } + load->set_barrier_data(barrier_data); return load; } LoadDNode* LoadDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe, uint8_t barrier_data) { bool require_atomic = true; LoadDNode* load = new LoadDNode(ctl, mem, adr, adr_type, rt, mo, control_dependency, require_atomic); if (unaligned) { @@ -894,6 +896,7 @@ if (unsafe) { load->set_unsafe_access(); } + load->set_barrier_data(barrier_data); return load; } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/opto/memnode.hpp --- a/src/hotspot/share/opto/memnode.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/opto/memnode.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -228,7 +228,8 @@ static Node* make(PhaseGVN& gvn, Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *rt, BasicType bt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false, bool unsafe = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false, + uint8_t barrier_data = 0); virtual uint hash() const; // Check the type @@ -412,7 +413,7 @@ bool require_atomic_access() const { return _require_atomic_access; } static LoadLNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false, bool unsafe = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { LoadNode::dump_spec(st); @@ -464,7 +465,7 @@ bool require_atomic_access() const { return _require_atomic_access; } static LoadDNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false, bool unsafe = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { LoadNode::dump_spec(st); diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/opto/superword.cpp --- a/src/hotspot/share/opto/superword.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/opto/superword.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -699,24 +699,34 @@ // Put memory ops from remaining packs back on memops list for // the best alignment search. uint orig_msize = memops.size(); - for (int i = 0; i < _packset.length(); i++) { - Node_List* p = _packset.at(i); + if (_packset.length() == 1 && orig_msize == 0) { + // If there are no remaining memory ops and only 1 pack we have only one choice + // for the alignment + Node_List* p = _packset.at(0); + assert(p->size() > 0, "sanity"); MemNode* s = p->at(0)->as_Mem(); assert(!same_velt_type(s, mem_ref), "sanity"); - memops.push(s); - } - best_align_to_mem_ref = find_align_to_ref(memops); - if (best_align_to_mem_ref == NULL) { - if (TraceSuperWord) { - tty->print_cr("SuperWord::find_adjacent_refs(): best_align_to_mem_ref == NULL"); + best_align_to_mem_ref = s; + } else { + for (int i = 0; i < _packset.length(); i++) { + Node_List* p = _packset.at(i); + MemNode* s = p->at(0)->as_Mem(); + assert(!same_velt_type(s, mem_ref), "sanity"); + memops.push(s); } - break; + best_align_to_mem_ref = find_align_to_ref(memops); + if (best_align_to_mem_ref == NULL) { + if (TraceSuperWord) { + tty->print_cr("SuperWord::find_adjacent_refs(): best_align_to_mem_ref == NULL"); + } + break; + } + best_iv_adjustment = get_iv_adjustment(best_align_to_mem_ref); + NOT_PRODUCT(find_adjacent_refs_trace_1(best_align_to_mem_ref, best_iv_adjustment);) + // Restore list. + while (memops.size() > orig_msize) + (void)memops.pop(); } - best_iv_adjustment = get_iv_adjustment(best_align_to_mem_ref); - NOT_PRODUCT(find_adjacent_refs_trace_1(best_align_to_mem_ref, best_iv_adjustment);) - // Restore list. - while (memops.size() > orig_msize) - (void)memops.pop(); } } // unaligned memory accesses diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/prims/jniCheck.cpp --- a/src/hotspot/share/prims/jniCheck.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/prims/jniCheck.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -28,6 +28,8 @@ #include "classfile/javaClasses.inline.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" +#include "logging/log.hpp" +#include "logging/logTag.hpp" #include "memory/allocation.inline.hpp" #include "memory/guardedMemory.hpp" #include "oops/instanceKlass.hpp" @@ -2303,10 +2305,7 @@ "Mismatched JNINativeInterface tables, check for new entries"); // with -verbose:jni this message will print - if (PrintJNIResolving) { - tty->print_cr("Checked JNI functions are being used to " \ - "validate JNI usage"); - } + log_debug(jni, resolve)("Checked JNI functions are being used to validate JNI usage"); return &checked_jni_NativeInterface; } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/prims/jvmtiEnv.cpp --- a/src/hotspot/share/prims/jvmtiEnv.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/prims/jvmtiEnv.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -809,14 +809,11 @@ LogConfiguration::configure_stdout(level, false, LOG_TAGS(class, load)); break; case JVMTI_VERBOSE_GC: - if (value == 0) { - LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(gc)); - } else { - LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc)); - } + LogConfiguration::configure_stdout(level, true, LOG_TAGS(gc)); break; case JVMTI_VERBOSE_JNI: - PrintJNIResolving = value != 0; + level = value == 0 ? LogLevel::Off : LogLevel::Debug; + LogConfiguration::configure_stdout(level, true, LOG_TAGS(jni, resolve)); break; default: return JVMTI_ERROR_ILLEGAL_ARGUMENT; diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/prims/nativeLookup.cpp --- a/src/hotspot/share/prims/nativeLookup.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/prims/nativeLookup.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -27,6 +27,8 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" +#include "logging/log.hpp" +#include "logging/logTag.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" @@ -413,11 +415,11 @@ method->set_native_function(entry, Method::native_bind_event_is_interesting); // -verbose:jni printing - if (PrintJNIResolving) { + if (log_is_enabled(Debug, jni, resolve)) { ResourceMark rm(THREAD); - tty->print_cr("[Dynamic-linking native method %s.%s ... JNI]", - method->method_holder()->external_name(), - method->name()->as_C_string()); + log_debug(jni, resolve)("[Dynamic-linking native method %s.%s ... JNI]", + method->method_holder()->external_name(), + method->name()->as_C_string()); } } return method->native_function(); diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/runtime/arguments.cpp --- a/src/hotspot/share/runtime/arguments.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/runtime/arguments.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -588,6 +588,7 @@ { "TraceSafepointCleanupTime", LogLevel::Info, true, LOG_TAGS(safepoint, cleanup) }, { "TraceJVMTIObjectTagging", LogLevel::Debug, true, LOG_TAGS(jvmti, objecttagging) }, { "TraceRedefineClasses", LogLevel::Info, false, LOG_TAGS(redefine, class) }, + { "PrintJNIResolving", LogLevel::Debug, true, LOG_TAGS(jni, resolve) }, { NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) } }; @@ -2400,9 +2401,7 @@ } else if (!strcmp(tail, ":gc")) { LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc)); } else if (!strcmp(tail, ":jni")) { - if (FLAG_SET_CMDLINE(PrintJNIResolving, true) != JVMFlag::SUCCESS) { - return JNI_EINVAL; - } + LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(jni, resolve)); } // -da / -ea / -disableassertions / -enableassertions // These accept an optional class/package name separated by a colon, e.g., diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -61,7 +61,7 @@ * 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result, * the minimum number of compiler threads is 2. * 5) Non-tiered emulation mode is on. CompilationModeFlag::disable_intermediate() == true. - * The mininum number of threads is 2. But if CompilationModeFlag::quick_internal() == false, then it's 1. + * The minimum number of threads is 2. But if CompilationModeFlag::quick_internal() == false, then it's 1. */ JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { int min_number_of_compiler_threads = 0; diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/runtime/globals.hpp --- a/src/hotspot/share/runtime/globals.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/runtime/globals.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -305,9 +305,6 @@ notproduct(bool, TraceCodeBlobStacks, false, \ "Trace stack-walk of codeblobs") \ \ - product(bool, PrintJNIResolving, false, \ - "Used to implement -v:jni") \ - \ notproduct(bool, PrintRewrites, false, \ "Print methods that are being rewritten") \ \ diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/services/attachListener.cpp --- a/src/hotspot/share/services/attachListener.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/services/attachListener.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -237,19 +237,7 @@ // This helps reduces the amount of unreachable objects in the dump // and makes it easier to browse. HeapDumper dumper(live_objects_only /* request GC */); - int res = dumper.dump(op->arg(0)); - if (res == 0) { - out->print_cr("Heap dump file created"); - } else { - // heap dump failed - ResourceMark rm; - char* error = dumper.error_as_C_string(); - if (error == NULL) { - out->print_cr("Dump failed - reason unknown"); - } else { - out->print_cr("%s", error); - } - } + dumper.dump(op->arg(0), out); } return JNI_OK; } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/services/diagnosticCommand.cpp --- a/src/hotspot/share/services/diagnosticCommand.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/services/diagnosticCommand.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -516,19 +516,7 @@ // This helps reduces the amount of unreachable objects in the dump // and makes it easier to browse. HeapDumper dumper(!_all.value() /* request GC if _all is false*/); - int res = dumper.dump(_filename.value()); - if (res == 0) { - output()->print_cr("Heap dump file created"); - } else { - // heap dump failed - ResourceMark rm; - char* error = dumper.error_as_C_string(); - if (error == NULL) { - output()->print_cr("Dump failed - reason unknown"); - } else { - output()->print_cr("%s", error); - } - } + dumper.dump(_filename.value(), output()); } int HeapDumpDCmd::num_arguments() { diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/services/heapDumper.cpp --- a/src/hotspot/share/services/heapDumper.cpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/services/heapDumper.cpp Tue Nov 12 10:09:40 2019 -0500 @@ -1969,12 +1969,12 @@ } // dump the heap to given path. -int HeapDumper::dump(const char* path) { +int HeapDumper::dump(const char* path, outputStream* out) { assert(path != NULL && strlen(path) > 0, "path missing"); // print message in interactive case - if (print_to_tty()) { - tty->print_cr("Dumping heap to %s ...", path); + if (out != NULL) { + out->print_cr("Dumping heap to %s ...", path); timer()->start(); } @@ -1982,8 +1982,8 @@ DumpWriter writer(path); if (!writer.is_open()) { set_error(writer.error()); - if (print_to_tty()) { - tty->print_cr("Unable to create %s: %s", path, + if (out != NULL) { + out->print_cr("Unable to create %s: %s", path, (error() != NULL) ? error() : "reason unknown"); } return -1; @@ -2003,13 +2003,13 @@ set_error(writer.error()); // print message in interactive case - if (print_to_tty()) { + if (out != NULL) { timer()->stop(); if (error() == NULL) { - tty->print_cr("Heap dump file created [" JULONG_FORMAT " bytes in %3.3f secs]", + out->print_cr("Heap dump file created [" JULONG_FORMAT " bytes in %3.3f secs]", writer.bytes_written(), timer()->seconds()); } else { - tty->print_cr("Dump file is incomplete: %s", writer.error()); + out->print_cr("Dump file is incomplete: %s", writer.error()); } } @@ -2137,8 +2137,7 @@ dump_file_seq++; // increment seq number for next time we dump HeapDumper dumper(false /* no GC before heap dump */, - true /* send to tty */, oome /* pass along out-of-memory-error flag */); - dumper.dump(my_path); + dumper.dump(my_path, tty); os::free(my_path); } diff -r 74e44250e3a7 -r af9779f2d6bf src/hotspot/share/services/heapDumper.hpp --- a/src/hotspot/share/services/heapDumper.hpp Fri Nov 08 20:41:14 2019 -0500 +++ b/src/hotspot/share/services/heapDumper.hpp Tue Nov 12 10:09:40 2019 -0500 @@ -41,24 +41,22 @@ // } // +class outputStream; + class HeapDumper : public StackObj { private: char* _error; - bool _print_to_tty; bool _gc_before_heap_dump; bool _oome; elapsedTimer _t; - HeapDumper(bool gc_before_heap_dump, bool print_to_tty, bool oome) : - _error(NULL), _print_to_tty(print_to_tty), _gc_before_heap_dump(gc_before_heap_dump), _oome(oome) { } + HeapDumper(bool gc_before_heap_dump, bool oome) : + _error(NULL), _gc_before_heap_dump(gc_before_heap_dump), _oome(oome) { } // string representation of error char* error() const { return _error; } void set_error(char* error); - // indicates if progress messages can be sent to tty - bool print_to_tty() const { return _print_to_tty; } - // internal timer. elapsedTimer* timer() { return &_t; } @@ -66,12 +64,13 @@ public: HeapDumper(bool gc_before_heap_dump) : - _error(NULL), _print_to_tty(false), _gc_before_heap_dump(gc_before_heap_dump), _oome(false) { } + _error(NULL), _gc_before_heap_dump(gc_before_heap_dump), _oome(false) { } ~HeapDumper(); // dumps the heap to the specified file, returns 0 if success. - int dump(const char* path); + // additional info is written to out if not NULL. + int dump(const char* path, outputStream* out = NULL); // returns error message (resource allocated), or NULL if no error char* error_as_C_string() const; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java --- a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java Tue Nov 12 10:09:40 2019 -0500 @@ -45,6 +45,8 @@ import java.security.cert.CertificateException; import javax.crypto.SealedObject; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * This class provides the keystore implementation referred to as "jceks". * This implementation strongly protects the keystore private keys using @@ -909,7 +911,8 @@ * hash with a bit of whitener. */ private MessageDigest getPreKeyedHash(char[] password) - throws NoSuchAlgorithmException, UnsupportedEncodingException { + throws NoSuchAlgorithmException + { int i, j; MessageDigest md = MessageDigest.getInstance("SHA"); @@ -921,7 +924,7 @@ md.update(passwdBytes); for (i=0; i name) { + assert Thread.holdsLock(stateLock); + + // unspecified (most options) + if (SocketOptionRegistry.findOption(name, Net.UNSPEC) != null) + return Net.UNSPEC; + + // IPv4 socket + if (family == StandardProtocolFamily.INET) + return StandardProtocolFamily.INET; + + // IPv6 socket that is unbound + if (localAddress == null) + return StandardProtocolFamily.INET6; + + // IPv6 socket bound to wildcard or IPv6 address + InetAddress address = localAddress.getAddress(); + if (address.isAnyLocalAddress() || (address instanceof Inet6Address)) + return StandardProtocolFamily.INET6; + + // IPv6 socket bound to IPv4 address + if (Net.canUseIPv6OptionsWithIPv4LocalAddress()) { + // IPV6_XXX options can be used + return StandardProtocolFamily.INET6; + } else { + // IPV6_XXX options cannot be used + return StandardProtocolFamily.INET; + } + } + @Override public DatagramChannel setOption(SocketOption name, T value) throws IOException @@ -252,14 +286,7 @@ synchronized (stateLock) { ensureOpen(); - if (name == StandardSocketOptions.IP_TOS || - name == StandardSocketOptions.IP_MULTICAST_TTL || - name == StandardSocketOptions.IP_MULTICAST_LOOP) - { - // options are protocol dependent - Net.setSocketOption(fd, family, name, value); - return this; - } + ProtocolFamily family = familyFor(name); if (name == StandardSocketOptions.IP_MULTICAST_IF) { NetworkInterface interf = (NetworkInterface)value; @@ -285,7 +312,7 @@ } // remaining options don't need any special handling - Net.setSocketOption(fd, Net.UNSPEC, name, value); + Net.setSocketOption(fd, family, name, value); return this; } } @@ -302,12 +329,7 @@ synchronized (stateLock) { ensureOpen(); - if (name == StandardSocketOptions.IP_TOS || - name == StandardSocketOptions.IP_MULTICAST_TTL || - name == StandardSocketOptions.IP_MULTICAST_LOOP) - { - return (T) Net.getSocketOption(fd, family, name); - } + ProtocolFamily family = familyFor(name); if (name == StandardSocketOptions.IP_MULTICAST_IF) { if (family == StandardProtocolFamily.INET) { @@ -333,11 +355,11 @@ } if (name == StandardSocketOptions.SO_REUSEADDR && reuseAddressEmulated) { - return (T)Boolean.valueOf(isReuseAddress); + return (T) Boolean.valueOf(isReuseAddress); } // no special handling - return (T) Net.getSocketOption(fd, Net.UNSPEC, name); + return (T) Net.getSocketOption(fd, family, name); } } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/nio/ch/Net.java --- a/src/java.base/share/classes/sun/nio/ch/Net.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/nio/ch/Net.java Tue Nov 12 10:09:40 2019 -0500 @@ -121,6 +121,14 @@ return canJoin6WithIPv4Group0(); } + /** + * Tells whether IPV6_XXX socket options should be used on an IPv6 socket + * that is bound to an IPv4 address. + */ + static boolean canUseIPv6OptionsWithIPv4LocalAddress() { + return canUseIPv6OptionsWithIPv4LocalAddress0(); + } + public static InetSocketAddress checkAddress(SocketAddress sa) { if (sa == null) throw new NullPointerException(); @@ -434,6 +442,8 @@ private static native boolean canJoin6WithIPv4Group0(); + private static native boolean canUseIPv6OptionsWithIPv4LocalAddress0(); + static FileDescriptor socket(boolean stream) throws IOException { return socket(UNSPEC, stream); } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java --- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Tue Nov 12 10:09:40 2019 -0500 @@ -51,6 +51,8 @@ import java.security.spec.PKCS8EncodedKeySpec; import java.util.*; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.security.AlgorithmParameters; import java.security.InvalidAlgorithmParameterException; import javax.crypto.spec.PBEParameterSpec; @@ -687,12 +689,14 @@ entry.attributes.addAll(attributes); } // set the keyId to current date - entry.keyId = ("Time " + (entry.date).getTime()).getBytes("UTF8"); + entry.keyId = ("Time " + (entry.date).getTime()).getBytes(UTF_8); // set the alias entry.alias = alias.toLowerCase(Locale.ENGLISH); // add the entry entries.put(alias.toLowerCase(Locale.ENGLISH), entry); + } catch (KeyStoreException kse) { + throw kse; } catch (Exception nsae) { throw new KeyStoreException("Key protection" + " algorithm not found: " + nsae, nsae); @@ -746,12 +750,8 @@ alias + "'"); } - try { - // set the keyId to current date - entry.keyId = ("Time " + (entry.date).getTime()).getBytes("UTF8"); - } catch (UnsupportedEncodingException ex) { - // Won't happen - } + // set the keyId to current date + entry.keyId = ("Time " + (entry.date).getTime()).getBytes(UTF_8); // set the alias entry.alias = alias.toLowerCase(Locale.ENGLISH); @@ -2499,18 +2499,18 @@ // attribute in pkcs12 with one private key entry and // associated cert-chain if (privateKeyCount == 1) { - keyId = "01".getBytes("UTF8"); + keyId = "01".getBytes(UTF_8); } else { continue; } } else { // keyId in a SecretKeyEntry is not significant - keyId = "00".getBytes("UTF8"); + keyId = "00".getBytes(UTF_8); } } entry.keyId = keyId; // restore date if it exists - String keyIdStr = new String(keyId, "UTF8"); + String keyIdStr = new String(keyId, UTF_8); Date date = null; if (keyIdStr.startsWith("Time ")) { try { @@ -2547,7 +2547,7 @@ if ((keyId == null) && (privateKeyCount == 1)) { // insert localKeyID only for EE cert or self-signed cert if (i == 0) { - keyId = "01".getBytes("UTF8"); + keyId = "01".getBytes(UTF_8); } } // Trusted certificate diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/provider/ConfigFile.java --- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,8 @@ import sun.security.util.PropertyExpander; import sun.security.util.ResourcesMgr; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * This class represents a default implementation for * {@code javax.security.auth.login.Configuration}. @@ -325,7 +327,7 @@ throws IOException { try (InputStreamReader isr - = new InputStreamReader(getInputStream(config), "UTF-8")) { + = new InputStreamReader(getInputStream(config), UTF_8)) { readConfig(isr, newConfig); } catch (FileNotFoundException fnfe) { if (debugConfig != null) { diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/provider/DomainKeyStore.java --- a/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/provider/DomainKeyStore.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ import java.security.cert.CertificateException; import java.util.*; +import static java.nio.charset.StandardCharsets.UTF_8; + import sun.security.pkcs.EncryptedPrivateKeyInfo; import sun.security.util.PolicyUtil; @@ -768,7 +770,7 @@ try (InputStreamReader configurationReader = new InputStreamReader( - PolicyUtil.getInputStream(configuration.toURL()), "UTF-8")) { + PolicyUtil.getInputStream(configuration.toURL()), UTF_8)) { parser.read(configurationReader); domains = parser.getDomainEntries(); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/provider/JavaKeyStore.java --- a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java Tue Nov 12 10:09:40 2019 -0500 @@ -32,6 +32,8 @@ import java.security.cert.CertificateException; import java.util.*; +import static java.nio.charset.StandardCharsets.UTF_8; + import sun.security.pkcs.EncryptedPrivateKeyInfo; import sun.security.pkcs12.PKCS12KeyStore; import sun.security.util.Debug; @@ -805,14 +807,14 @@ * hash with a bit of whitener. */ private MessageDigest getPreKeyedHash(char[] password) - throws NoSuchAlgorithmException, UnsupportedEncodingException + throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA"); byte[] passwdBytes = convertToBytes(password); md.update(passwdBytes); Arrays.fill(passwdBytes, (byte) 0x00); - md.update("Mighty Aphrodite".getBytes("UTF8")); + md.update("Mighty Aphrodite".getBytes(UTF_8)); return md; } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/provider/KeyProtector.java --- a/src/java.base/share/classes/sun/security/provider/KeyProtector.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/provider/KeyProtector.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package sun.security.provider; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.security.Key; import java.security.KeyStoreException; import java.security.MessageDigest; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/provider/PolicyFile.java --- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java Tue Nov 12 10:09:40 2019 -0500 @@ -42,12 +42,14 @@ import java.net.NetPermission; import java.util.concurrent.ConcurrentHashMap; import jdk.internal.access.JavaSecurityAccess; -import static jdk.internal.access.JavaSecurityAccess.ProtectionDomainCache; import jdk.internal.access.SharedSecrets; import jdk.internal.util.StaticProperty; import sun.security.util.*; import sun.net.www.ParseUtil; +import static java.nio.charset.StandardCharsets.UTF_8; +import static jdk.internal.access.JavaSecurityAccess.ProtectionDomainCache; + /** * This class represents a default Policy implementation for the * "JavaPolicy" type. @@ -559,8 +561,7 @@ return false; } - private InputStreamReader getInputStreamReader(InputStream is) - throws IOException { + private InputStreamReader getInputStreamReader(InputStream is) { /* * Read in policy using UTF-8 by default. * @@ -569,7 +570,7 @@ */ return (notUtf8) ? new InputStreamReader(is) - : new InputStreamReader(is, "UTF-8"); + : new InputStreamReader(is, UTF_8); } private void initStaticPolicy(final PolicyInfo newInfo) { diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/ssl/SSLExtension.java --- a/src/java.base/share/classes/sun/security/ssl/SSLExtension.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/ssl/SSLExtension.java Tue Nov 12 10:09:40 2019 -0500 @@ -696,8 +696,18 @@ } // To switch off the max_fragment_length extension. + // + // Note that "jsse.enableMFLNExtension" is the CSR approved + // property name. However, "jsse.enableMFLExtension" was used + // in the original implementation. Temporarily, if either of + // the two properties set to true, the extension is switch on. + // We may remove the "jsse.enableMFLExtension" property in the + // future. Please don't continue to use the misspelling property. enableExtension = - Utilities.getBooleanProperty("jsse.enableMFLExtension", false); + Utilities.getBooleanProperty( + "jsse.enableMFLNExtension", false) || + Utilities.getBooleanProperty( + "jsse.enableMFLExtension", false); if (!enableExtension) { extensions.remove(CH_MAX_FRAGMENT_LENGTH); } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/ssl/SSLLogger.java --- a/src/java.base/share/classes/sun/security/ssl/SSLLogger.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/ssl/SSLLogger.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,8 @@ import sun.security.util.HexDumpEncoder; import sun.security.x509.*; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Implementation of SSL logger. * @@ -229,7 +231,7 @@ try { String formatted = SSLSimpleFormatter.format(this, level, message, thrwbl); - System.err.write(formatted.getBytes("UTF-8")); + System.err.write(formatted.getBytes(UTF_8)); } catch (Exception exp) { // ignore it, just for debugging. } @@ -243,7 +245,7 @@ try { String formatted = SSLSimpleFormatter.format(this, level, message, params); - System.err.write(formatted.getBytes("UTF-8")); + System.err.write(formatted.getBytes(UTF_8)); } catch (Exception exp) { // ignore it, just for debugging. } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/util/DerInputStream.java --- a/src/java.base/share/classes/sun/security/util/DerInputStream.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/util/DerInputStream.java Tue Nov 12 10:09:40 2019 -0500 @@ -27,9 +27,12 @@ import java.io.InputStream; import java.io.IOException; +import java.math.BigInteger; +import java.nio.charset.Charset; import java.util.Date; import java.util.Vector; -import java.math.BigInteger; + +import static java.nio.charset.StandardCharsets.*; /** * A DER input stream, used for parsing ASN.1 DER-encoded data such as @@ -457,7 +460,7 @@ * Read a string that was encoded as a UTF8String DER value. */ public String getUTF8String() throws IOException { - return readString(DerValue.tag_UTF8String, "UTF-8", "UTF8"); + return readString(DerValue.tag_UTF8String, "UTF-8", UTF_8); } /** @@ -465,7 +468,7 @@ */ public String getPrintableString() throws IOException { return readString(DerValue.tag_PrintableString, "Printable", - "ASCII"); + US_ASCII); } /** @@ -475,22 +478,21 @@ /* * Works for common characters between T61 and ASCII. */ - return readString(DerValue.tag_T61String, "T61", "ISO-8859-1"); + return readString(DerValue.tag_T61String, "T61", ISO_8859_1); } /** - * Read a string that was encoded as a IA5tring DER value. + * Read a string that was encoded as a IA5String DER value. */ public String getIA5String() throws IOException { - return readString(DerValue.tag_IA5String, "IA5", "ASCII"); + return readString(DerValue.tag_IA5String, "IA5", US_ASCII); } /** * Read a string that was encoded as a BMPString DER value. */ public String getBMPString() throws IOException { - return readString(DerValue.tag_BMPString, "BMP", - "UnicodeBigUnmarked"); + return readString(DerValue.tag_BMPString, "BMP", UTF_16BE); } /** @@ -498,7 +500,7 @@ */ public String getGeneralString() throws IOException { return readString(DerValue.tag_GeneralString, "General", - "ASCII"); + US_ASCII); } /** @@ -510,7 +512,7 @@ * correspond to the stringTag above. */ private String readString(byte stringTag, String stringName, - String enc) throws IOException { + Charset charset) throws IOException { if (buffer.read() != stringTag) throw new IOException("DER input not a " + @@ -522,7 +524,7 @@ throw new IOException("Short read of DER " + stringName + " string"); - return new String(retval, enc); + return new String(retval, charset); } /** diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/util/DerOutputStream.java --- a/src/java.base/share/classes/sun/security/util/DerOutputStream.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/util/DerOutputStream.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,14 +28,16 @@ import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.IOException; +import java.math.BigInteger; +import java.nio.charset.Charset; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; import java.util.Comparator; import java.util.Arrays; -import java.math.BigInteger; import java.util.Locale; +import static java.nio.charset.StandardCharsets.*; /** * Output stream marshaling DER-encoded data. This is eventually provided @@ -398,14 +400,14 @@ * Marshals a string as a DER encoded UTF8String. */ public void putUTF8String(String s) throws IOException { - writeString(s, DerValue.tag_UTF8String, "UTF8"); + writeString(s, DerValue.tag_UTF8String, UTF_8); } /** * Marshals a string as a DER encoded PrintableString. */ public void putPrintableString(String s) throws IOException { - writeString(s, DerValue.tag_PrintableString, "ASCII"); + writeString(s, DerValue.tag_PrintableString, US_ASCII); } /** @@ -416,28 +418,28 @@ * Works for characters that are defined in both ASCII and * T61. */ - writeString(s, DerValue.tag_T61String, "ISO-8859-1"); + writeString(s, DerValue.tag_T61String, ISO_8859_1); } /** * Marshals a string as a DER encoded IA5String. */ public void putIA5String(String s) throws IOException { - writeString(s, DerValue.tag_IA5String, "ASCII"); + writeString(s, DerValue.tag_IA5String, US_ASCII); } /** * Marshals a string as a DER encoded BMPString. */ public void putBMPString(String s) throws IOException { - writeString(s, DerValue.tag_BMPString, "UnicodeBigUnmarked"); + writeString(s, DerValue.tag_BMPString, UTF_16BE); } /** * Marshals a string as a DER encoded GeneralString. */ public void putGeneralString(String s) throws IOException { - writeString(s, DerValue.tag_GeneralString, "ASCII"); + writeString(s, DerValue.tag_GeneralString, US_ASCII); } /** @@ -448,10 +450,10 @@ * @param enc the name of the encoder that should be used corresponding * to the above tag. */ - private void writeString(String s, byte stringTag, String enc) + private void writeString(String s, byte stringTag, Charset charset) throws IOException { - byte[] data = s.getBytes(enc); + byte[] data = s.getBytes(charset); write(stringTag); putLength(data.length); write(data); @@ -502,7 +504,7 @@ SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US); sdf.setTimeZone(tz); - byte[] time = (sdf.format(d)).getBytes("ISO-8859-1"); + byte[] time = (sdf.format(d)).getBytes(ISO_8859_1); /* * Write the formatted date. diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/util/DerValue.java --- a/src/java.base/share/classes/sun/security/util/DerValue.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/util/DerValue.java Tue Nov 12 10:09:40 2019 -0500 @@ -27,8 +27,11 @@ import java.io.*; import java.math.BigInteger; +import java.nio.charset.Charset; import java.util.Date; +import static java.nio.charset.StandardCharsets.*; + /** * Represents a single DER-encoded value. DER encoding rules are a subset * of the "Basic" Encoding Rules (BER), but they only support a single way @@ -204,7 +207,7 @@ /** * Creates a PrintableString or UTF8string DER value from a string */ - public DerValue(String value) throws IOException { + public DerValue(String value) { boolean isPrintableString = true; for (int i = 0; i < value.length(); i++) { if (!isPrintableStringChar(value.charAt(i))) { @@ -221,7 +224,7 @@ * @param stringTag the tag for the DER value to create * @param value the String object to use for the DER value */ - public DerValue(byte stringTag, String value) throws IOException { + public DerValue(byte stringTag, String value) { data = init(stringTag, value); } @@ -337,9 +340,8 @@ this(in, true); } - private DerInputStream init(byte stringTag, String value) - throws IOException { - String enc = null; + private DerInputStream init(byte stringTag, String value) { + final Charset charset; tag = stringTag; @@ -347,16 +349,16 @@ case tag_PrintableString: case tag_IA5String: case tag_GeneralString: - enc = "ASCII"; + charset = US_ASCII; break; case tag_T61String: - enc = "ISO-8859-1"; + charset = ISO_8859_1; break; case tag_BMPString: - enc = "UnicodeBigUnmarked"; + charset = UTF_16BE; break; case tag_UTF8String: - enc = "UTF8"; + charset = UTF_8; break; // TBD: Need encoder for UniversalString before it can // be handled. @@ -364,7 +366,7 @@ throw new IllegalArgumentException("Unsupported DER string type"); } - byte[] buf = value.getBytes(enc); + byte[] buf = value.getBytes(charset); length = buf.length; buffer = new DerInputBuffer(buf, true); DerInputStream result = new DerInputStream(buffer); @@ -665,7 +667,7 @@ throw new IOException( "DerValue.getPrintableString, not a string " + tag); - return new String(getDataBytes(), "ASCII"); + return new String(getDataBytes(), US_ASCII); } /** @@ -678,7 +680,7 @@ throw new IOException( "DerValue.getT61String, not T61 " + tag); - return new String(getDataBytes(), "ISO-8859-1"); + return new String(getDataBytes(), ISO_8859_1); } /** @@ -691,7 +693,7 @@ throw new IOException( "DerValue.getIA5String, not IA5 " + tag); - return new String(getDataBytes(), "ASCII"); + return new String(getDataBytes(), US_ASCII); } /** @@ -707,7 +709,7 @@ // BMPString is the same as Unicode in big endian, unmarked // format. - return new String(getDataBytes(), "UnicodeBigUnmarked"); + return new String(getDataBytes(), UTF_16BE); } /** @@ -721,7 +723,7 @@ throw new IOException( "DerValue.getUTF8String, not UTF-8 " + tag); - return new String(getDataBytes(), "UTF8"); + return new String(getDataBytes(), UTF_8); } /** @@ -735,7 +737,7 @@ throw new IOException( "DerValue.getGeneralString, not GeneralString " + tag); - return new String(getDataBytes(), "ASCII"); + return new String(getDataBytes(), US_ASCII); } /** diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/util/DomainName.java --- a/src/java.base/share/classes/sun/security/util/DomainName.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/util/DomainName.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import static java.nio.charset.StandardCharsets.UTF_8; + import sun.security.ssl.SSLLogger; /** @@ -151,7 +153,7 @@ private final boolean hasExceptions; private Rules(InputStream is) throws IOException { - InputStreamReader isr = new InputStreamReader(is, "UTF-8"); + InputStreamReader isr = new InputStreamReader(is, UTF_8); BufferedReader reader = new BufferedReader(isr); boolean hasExceptions = false; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/util/HexDumpEncoder.java --- a/src/java.base/share/classes/sun/security/util/HexDumpEncoder.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/util/HexDumpEncoder.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,8 @@ import java.io.IOException; import java.nio.ByteBuffer; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + /** * This class encodes a buffer into the classic: "Hexadecimal Dump" format of * the past. It is useful for analyzing the contents of binary buffers. @@ -183,17 +185,15 @@ */ public String encode(byte aBuffer[]) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); - String retVal = null; + ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer); try { encode(inStream, outStream); // explicit ascii->unicode conversion - retVal = outStream.toString("ISO-8859-1"); - } catch (Exception IOException) { + return outStream.toString(ISO_8859_1); + } catch (IOException ignore) { // This should never happen. throw new Error("CharacterEncoder.encode internal error"); } - return (retVal); } /** diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/x509/AVA.java --- a/src/java.base/share/classes/sun/security/x509/AVA.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/x509/AVA.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ import java.text.Normalizer; import java.util.*; +import static java.nio.charset.StandardCharsets.UTF_8; + import sun.security.action.GetBooleanAction; import sun.security.util.*; import sun.security.pkcs.PKCS9Attribute; @@ -525,14 +527,13 @@ return null; } - private static String getEmbeddedHexString(List hexList) - throws IOException { + private static String getEmbeddedHexString(List hexList) { int n = hexList.size(); byte[] hexBytes = new byte[n]; for (int i = 0; i < n; i++) { - hexBytes[i] = hexList.get(i).byteValue(); + hexBytes[i] = hexList.get(i).byteValue(); } - return new String(hexBytes, "UTF8"); + return new String(hexBytes, UTF_8); } private static boolean isTerminator(int ch, int format) { @@ -752,7 +753,7 @@ */ String valStr = null; try { - valStr = new String(value.getDataBytes(), "UTF8"); + valStr = new String(value.getDataBytes(), UTF_8); } catch (IOException ie) { throw new IllegalArgumentException("DER Value conversion"); } @@ -804,13 +805,7 @@ // embed non-printable/non-escaped char // as escaped hex pairs for debugging - byte[] valueBytes = null; - try { - valueBytes = Character.toString(c).getBytes("UTF8"); - } catch (IOException ie) { - throw new IllegalArgumentException - ("DER Value conversion"); - } + byte[] valueBytes = Character.toString(c).getBytes(UTF_8); for (int j = 0; j < valueBytes.length; j++) { sbuffer.append('\\'); char hexChar = Character.forDigit @@ -905,7 +900,7 @@ */ String valStr = null; try { - valStr = new String(value.getDataBytes(), "UTF8"); + valStr = new String(value.getDataBytes(), UTF_8); } catch (IOException ie) { throw new IllegalArgumentException("DER Value conversion"); } @@ -966,13 +961,7 @@ previousWhite = false; - byte[] valueBytes = null; - try { - valueBytes = Character.toString(c).getBytes("UTF8"); - } catch (IOException ie) { - throw new IllegalArgumentException - ("DER Value conversion"); - } + byte[] valueBytes = Character.toString(c).getBytes(UTF_8); for (int j = 0; j < valueBytes.length; j++) { sbuffer.append('\\'); sbuffer.append(Character.forDigit @@ -1116,7 +1105,7 @@ // embed escaped hex pairs byte[] valueBytes = - Character.toString(c).getBytes("UTF8"); + Character.toString(c).getBytes(UTF_8); for (int j = 0; j < valueBytes.length; j++) { sbuffer.append('\\'); char hexChar = Character.forDigit diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/classes/sun/security/x509/X509CertImpl.java --- a/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Tue Nov 12 10:09:40 2019 -0500 @@ -45,6 +45,8 @@ import sun.security.util.*; import sun.security.provider.X509Factory; +import static java.nio.charset.StandardCharsets.US_ASCII; + /** * The X509CertImpl class represents an X.509 certificate. These certificates * are widely used to support authentication and other functionality in @@ -250,7 +252,7 @@ DerValue der = null; String line = null; BufferedReader certBufferedReader = - new BufferedReader(new InputStreamReader(in, "ASCII")); + new BufferedReader(new InputStreamReader(in, US_ASCII)); try { line = certBufferedReader.readLine(); } catch (IOException ioe1) { diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/share/native/libjli/args.c --- a/src/java.base/share/native/libjli/args.c Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/share/native/libjli/args.c Tue Nov 12 10:09:40 2019 -0500 @@ -337,7 +337,9 @@ // remaining partial token if (ctx.state == IN_TOKEN || ctx.state == IN_QUOTE) { if (ctx.parts->size != 0) { - JLI_List_add(rv, JLI_List_combine(ctx.parts)); + token = JLI_List_combine(ctx.parts); + checkArg(token); + JLI_List_add(rv, token); } } JLI_List_free(ctx.parts); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/unix/native/libnio/ch/Net.c --- a/src/java.base/unix/native/libnio/ch/Net.c Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/unix/native/libnio/ch/Net.c Tue Nov 12 10:09:40 2019 -0500 @@ -158,24 +158,34 @@ JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl) { -#if defined(__APPLE__) || defined(_AIX) - /* for now IPv6 sockets cannot join IPv4 multicast groups */ +#if defined(__linux__) || defined(__APPLE__) || defined(__solaris__) + /* IPv6 sockets can join IPv4 multicast groups */ + return JNI_TRUE; +#else + /* IPv6 sockets cannot join IPv4 multicast groups */ return JNI_FALSE; -#else - return JNI_TRUE; #endif } JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl) { -#ifdef __solaris__ +#if defined(__APPLE__) || defined(__solaris__) + /* IPV6_ADD_MEMBERSHIP can be used to join IPv4 multicast groups */ return JNI_TRUE; #else + /* IPV6_ADD_MEMBERSHIP cannot be used to join IPv4 multicast groups */ return JNI_FALSE; #endif } +JNIEXPORT jboolean JNICALL +Java_sun_nio_ch_Net_canUseIPv6OptionsWithIPv4LocalAddress0(JNIEnv* env, jclass cl) +{ + /* IPV6_XXX socket options can be used on IPv6 sockets bound to IPv4 address */ + return JNI_TRUE; +} + JNIEXPORT jint JNICALL Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, jboolean stream, jboolean reuse, jboolean ignored) diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java --- a/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Tue Nov 12 10:09:40 2019 -0500 @@ -38,6 +38,7 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import jdk.internal.misc.Unsafe; /** * A multi-threaded implementation of Selector for Windows. @@ -47,12 +48,26 @@ */ class WindowsSelectorImpl extends SelectorImpl { + private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static int addressSize = unsafe.addressSize(); + + private static int dependsArch(int value32, int value64) { + return (addressSize == 4) ? value32 : value64; + } + // Initial capacity of the poll array private final int INIT_CAP = 8; // Maximum number of sockets for select(). // Should be INIT_CAP times a power of 2 private static final int MAX_SELECTABLE_FDS = 1024; + // Size of FD_SET struct to allocate a buffer for it in SubSelector, + // aligned to 8 bytes on 64-bit: + // struct { unsigned int fd_count; SOCKET fd_array[MAX_SELECTABLE_FDS]; }. + private static final long SIZEOF_FD_SET = dependsArch( + 4 + MAX_SELECTABLE_FDS * 4, // SOCKET = unsigned int + 4 + MAX_SELECTABLE_FDS * 8 + 4); // SOCKET = unsigned __int64 + // The list of SelectableChannels serviced by this Selector. Every mod // MAX_SELECTABLE_FDS entry is bogus, to align this array with the poll // array, where the corresponding entry is occupied by the wakeupSocket @@ -326,6 +341,9 @@ private final int[] readFds = new int [MAX_SELECTABLE_FDS + 1]; private final int[] writeFds = new int [MAX_SELECTABLE_FDS + 1]; private final int[] exceptFds = new int [MAX_SELECTABLE_FDS + 1]; + // Buffer for readfds, writefds and exceptfds structs that are passed + // to native select(). + private final long fdsBuffer = unsafe.allocateMemory(SIZEOF_FD_SET * 3); private SubSelector() { this.pollArrayIndex = 0; // main thread @@ -338,7 +356,7 @@ private int poll() throws IOException{ // poll for the main thread return poll0(pollWrapper.pollArrayAddress, Math.min(totalChannels, MAX_SELECTABLE_FDS), - readFds, writeFds, exceptFds, timeout); + readFds, writeFds, exceptFds, timeout, fdsBuffer); } private int poll(int index) throws IOException { @@ -347,11 +365,11 @@ (pollArrayIndex * PollArrayWrapper.SIZE_POLLFD), Math.min(MAX_SELECTABLE_FDS, totalChannels - (index + 1) * MAX_SELECTABLE_FDS), - readFds, writeFds, exceptFds, timeout); + readFds, writeFds, exceptFds, timeout, fdsBuffer); } private native int poll0(long pollAddress, int numfds, - int[] readFds, int[] writeFds, int[] exceptFds, long timeout); + int[] readFds, int[] writeFds, int[] exceptFds, long timeout, long fdsBuffer); private int processSelectedKeys(long updateCount, Consumer action) { int numKeysUpdated = 0; @@ -415,6 +433,10 @@ } return numKeysUpdated; } + + private void freeFDSetBuffer() { + unsafe.freeMemory(fdsBuffer); + } } // Represents a helper thread used for select. @@ -441,8 +463,10 @@ while (true) { // poll loop // wait for the start of poll. If this thread has become // redundant, then exit. - if (startLock.waitForStart(this)) + if (startLock.waitForStart(this)) { + subSelector.freeFDSetBuffer(); return; + } // call poll() try { subSelector.poll(index); @@ -533,6 +557,7 @@ for (SelectThread t: threads) t.makeZombie(); startLock.startThreads(); + subSelector.freeFDSetBuffer(); } @Override diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/windows/native/libnio/ch/Net.c --- a/src/java.base/windows/native/libnio/ch/Net.c Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/windows/native/libnio/ch/Net.c Tue Nov 12 10:09:40 2019 -0500 @@ -127,12 +127,21 @@ JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl) { - return JNI_FALSE; + /* IPv6 sockets can join IPv4 multicast groups */ + return JNI_TRUE; } JNIEXPORT jboolean JNICALL Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl) { + /* IPV6_ADD_MEMBERSHIP cannot be used to join IPv4 multicast groups */ + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL +Java_sun_nio_ch_Net_canUseIPv6OptionsWithIPv4LocalAddress0(JNIEnv* env, jclass cl) +{ + /* IPV6_XXX socket options cannot be used on IPv6 sockets bound to IPv4 address */ return JNI_FALSE; } @@ -279,7 +288,7 @@ SOCKETADDRESS sa; int sa_len = sizeof(sa); - if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) { + if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) == SOCKET_ERROR) { int error = WSAGetLastError(); if (error == WSAEINVAL) { return 0; @@ -297,7 +306,7 @@ int sa_len = sizeof(sa); int port; - if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) < 0) { + if (getsockname(fdval(env, fdo), &sa.sa, &sa_len) == SOCKET_ERROR) { NET_ThrowNew(env, WSAGetLastError(), "getsockname"); return NULL; } @@ -310,7 +319,7 @@ SOCKETADDRESS sa; int sa_len = sizeof(sa); - if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) < 0) { + if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) == SOCKET_ERROR) { int error = WSAGetLastError(); if (error == WSAEINVAL) { return 0; @@ -328,7 +337,7 @@ int sa_len = sizeof(sa); int port; - if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) < 0) { + if (getpeername(fdval(env, fdo), &sa.sa, &sa_len) == SOCKET_ERROR) { NET_ThrowNew(env, WSAGetLastError(), "getsockname"); return NULL; } @@ -366,7 +375,7 @@ } else { n = getsockopt(fdval(env, fdo), level, opt, arg, &arglen); } - if (n < 0) { + if (n == SOCKET_ERROR) { handleSocketError(env, WSAGetLastError()); return IOS_THROWN; } @@ -410,7 +419,7 @@ } else { n = setsockopt(fdval(env, fdo), level, opt, parg, arglen); } - if (n < 0) + if (n == SOCKET_ERROR) handleSocketError(env, WSAGetLastError()); } @@ -439,7 +448,7 @@ } n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen); - if (n < 0) { + if (n == SOCKET_ERROR) { if (join && (WSAGetLastError() == WSAENOPROTOOPT)) return IOS_UNAVAILABLE; handleSocketError(env, WSAGetLastError()); @@ -461,7 +470,7 @@ n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, (void*)&mreq_source, sizeof(mreq_source)); - if (n < 0) { + if (n == SOCKET_ERROR) { if (block && (WSAGetLastError() == WSAENOPROTOOPT)) return IOS_UNAVAILABLE; handleSocketError(env, WSAGetLastError()); @@ -516,8 +525,8 @@ n = setGroupSourceReqOption(env, fdo, opt, group, index, source); } - if (n < 0) { - handleSocketError(env, errno); + if (n == SOCKET_ERROR) { + handleSocketError(env, WSAGetLastError()); } return 0; } @@ -528,8 +537,8 @@ { int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE; int n = setGroupSourceReqOption(env, fdo, opt, group, index, source); - if (n < 0) { - handleSocketError(env, errno); + if (n == SOCKET_ERROR) { + handleSocketError(env, WSAGetLastError()); } return 0; } @@ -545,7 +554,7 @@ n = setsockopt(fdval(env, fdo), IPPROTO_IP, IP_MULTICAST_IF, (void*)&(in.s_addr), arglen); - if (n < 0) { + if (n == SOCKET_ERROR) { handleSocketError(env, WSAGetLastError()); } } @@ -558,7 +567,7 @@ int n; n = getsockopt(fdval(env, fdo), IPPROTO_IP, IP_MULTICAST_IF, (void*)&in, &arglen); - if (n < 0) { + if (n == SOCKET_ERROR) { handleSocketError(env, WSAGetLastError()); return IOS_THROWN; } @@ -568,27 +577,27 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_Net_setInterface6(JNIEnv* env, jobject this, jobject fdo, jint index) { - int value = (jint)index; + DWORD value = (jint)index; int arglen = sizeof(value); int n; n = setsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF, (void*)&(index), arglen); - if (n < 0) { - handleSocketError(env, errno); + if (n == SOCKET_ERROR) { + handleSocketError(env, WSAGetLastError()); } } JNIEXPORT jint JNICALL Java_sun_nio_ch_Net_getInterface6(JNIEnv* env, jobject this, jobject fdo) { - int index; + DWORD index; int arglen = sizeof(index); int n; n = getsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF, (void*)&index, &arglen); - if (n < 0) { - handleSocketError(env, errno); + if (n == SOCKET_ERROR) { + handleSocketError(env, WSAGetLastError()); return -1; } return (jint)index; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c --- a/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.base/windows/native/libnio/ch/WindowsSelectorImpl.c Tue Nov 12 10:09:40 2019 -0500 @@ -39,6 +39,7 @@ #include "jvm.h" #include "jni.h" #include "jni_util.h" +#include "nio.h" #include "sun_nio_ch_WindowsSelectorImpl.h" #include "sun_nio_ch_PollArrayWrapper.h" @@ -56,12 +57,14 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject this, jlong pollAddress, jint numfds, jintArray returnReadFds, jintArray returnWriteFds, - jintArray returnExceptFds, jlong timeout) + jintArray returnExceptFds, jlong timeout, jlong fdsBuffer) { DWORD result = 0; pollfd *fds = (pollfd *) pollAddress; int i; - FD_SET readfds, writefds, exceptfds; + FD_SET *readfds = (FD_SET *) jlong_to_ptr(fdsBuffer); + FD_SET *writefds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET)); + FD_SET *exceptfds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET) * 2); struct timeval timevalue, *tv; static struct timeval zerotime = {0, 0}; int read_count = 0, write_count = 0, except_count = 0; @@ -93,103 +96,61 @@ /* Set FD_SET structures required for select */ for (i = 0; i < numfds; i++) { if (fds[i].events & POLLIN) { - readfds.fd_array[read_count] = fds[i].fd; + readfds->fd_array[read_count] = fds[i].fd; read_count++; } if (fds[i].events & (POLLOUT | POLLCONN)) { - writefds.fd_array[write_count] = fds[i].fd; + writefds->fd_array[write_count] = fds[i].fd; write_count++; } - exceptfds.fd_array[except_count] = fds[i].fd; + exceptfds->fd_array[except_count] = fds[i].fd; except_count++; } - readfds.fd_count = read_count; - writefds.fd_count = write_count; - exceptfds.fd_count = except_count; + readfds->fd_count = read_count; + writefds->fd_count = write_count; + exceptfds->fd_count = except_count; /* Call select */ - if ((result = select(0 , &readfds, &writefds, &exceptfds, tv)) + if ((result = select(0 , readfds, writefds, exceptfds, tv)) == SOCKET_ERROR) { - /* Bad error - this should not happen frequently */ - /* Iterate over sockets and call select() on each separately */ - FD_SET errreadfds, errwritefds, errexceptfds; - readfds.fd_count = 0; - writefds.fd_count = 0; - exceptfds.fd_count = 0; - for (i = 0; i < numfds; i++) { - /* prepare select structures for the i-th socket */ - errreadfds.fd_count = 0; - errwritefds.fd_count = 0; - if (fds[i].events & POLLIN) { - errreadfds.fd_array[0] = fds[i].fd; - errreadfds.fd_count = 1; - } - if (fds[i].events & (POLLOUT | POLLCONN)) - { - errwritefds.fd_array[0] = fds[i].fd; - errwritefds.fd_count = 1; - } - errexceptfds.fd_array[0] = fds[i].fd; - errexceptfds.fd_count = 1; - - /* call select on the i-th socket */ - if (select(0, &errreadfds, &errwritefds, &errexceptfds, &zerotime) - == SOCKET_ERROR) { - /* This socket causes an error. Add it to exceptfds set */ - exceptfds.fd_array[exceptfds.fd_count] = fds[i].fd; - exceptfds.fd_count++; - } else { - /* This socket does not cause an error. Process result */ - if (errreadfds.fd_count == 1) { - readfds.fd_array[readfds.fd_count] = fds[i].fd; - readfds.fd_count++; - } - if (errwritefds.fd_count == 1) { - writefds.fd_array[writefds.fd_count] = fds[i].fd; - writefds.fd_count++; - } - if (errexceptfds.fd_count == 1) { - exceptfds.fd_array[exceptfds.fd_count] = fds[i].fd; - exceptfds.fd_count++; - } - } - } + JNU_ThrowIOExceptionWithLastError(env, "Select failed"); + return IOS_THROWN; } /* Return selected sockets. */ /* Each Java array consists of sockets count followed by sockets list */ #ifdef _WIN64 - resultbuf[0] = readfds.fd_count; - for (i = 0; i < (int)readfds.fd_count; i++) { - resultbuf[i + 1] = (int)readfds.fd_array[i]; + resultbuf[0] = readfds->fd_count; + for (i = 0; i < (int)readfds->fd_count; i++) { + resultbuf[i + 1] = (int)readfds->fd_array[i]; } (*env)->SetIntArrayRegion(env, returnReadFds, 0, - readfds.fd_count + 1, resultbuf); + readfds->fd_count + 1, resultbuf); - resultbuf[0] = writefds.fd_count; - for (i = 0; i < (int)writefds.fd_count; i++) { - resultbuf[i + 1] = (int)writefds.fd_array[i]; + resultbuf[0] = writefds->fd_count; + for (i = 0; i < (int)writefds->fd_count; i++) { + resultbuf[i + 1] = (int)writefds->fd_array[i]; } (*env)->SetIntArrayRegion(env, returnWriteFds, 0, - writefds.fd_count + 1, resultbuf); + writefds->fd_count + 1, resultbuf); - resultbuf[0] = exceptfds.fd_count; - for (i = 0; i < (int)exceptfds.fd_count; i++) { - resultbuf[i + 1] = (int)exceptfds.fd_array[i]; + resultbuf[0] = exceptfds->fd_count; + for (i = 0; i < (int)exceptfds->fd_count; i++) { + resultbuf[i + 1] = (int)exceptfds->fd_array[i]; } (*env)->SetIntArrayRegion(env, returnExceptFds, 0, - exceptfds.fd_count + 1, resultbuf); + exceptfds->fd_count + 1, resultbuf); #else (*env)->SetIntArrayRegion(env, returnReadFds, 0, - readfds.fd_count + 1, (jint *)&readfds); + readfds->fd_count + 1, (jint *)readfds); (*env)->SetIntArrayRegion(env, returnWriteFds, 0, - writefds.fd_count + 1, (jint *)&writefds); + writefds->fd_count + 1, (jint *)writefds); (*env)->SetIntArrayRegion(env, returnExceptFds, 0, - exceptfds.fd_count + 1, (jint *)&exceptfds); + exceptfds->fd_count + 1, (jint *)exceptfds); #endif return 0; } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java --- a/src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,11 +32,12 @@ import java.util.HashSet; import java.util.Arrays; import java.io.IOException; -import java.io.UnsupportedEncodingException; import sun.security.util.ObjectIdentifier; import sun.security.util.DerInputStream; import sun.security.util.DerOutputStream; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * This is the implementation class for GSSName. Conceptually the * GSSName is a container with mechanism specific name elements. Each @@ -227,13 +228,10 @@ byte[] bytes = null; if (appName instanceof String) { - try { - bytes = ((String) appName).getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - // Won't happen - } - } else + bytes = ((String) appName).getBytes(UTF_8); + } else { bytes = (byte[]) appName; + } if ((bytes[pos++] != 0x04) || (bytes[pos++] != 0x01)) @@ -320,21 +318,14 @@ if (!this.appNameType.equals(that.appNameType)) { return false; } - byte[] myBytes = null; - byte[] bytes = null; - try { - myBytes = + byte[] myBytes = (this.appNameStr != null ? - this.appNameStr.getBytes("UTF-8") : + this.appNameStr.getBytes(UTF_8) : this.appNameBytes); - bytes = + byte[] bytes = (that.appNameStr != null ? - that.appNameStr.getBytes("UTF-8") : + that.appNameStr.getBytes(UTF_8) : that.appNameBytes); - } catch (UnsupportedEncodingException e) { - // Won't happen - } - return Arrays.equals(myBytes, bytes); } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java --- a/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java Tue Nov 12 10:09:40 2019 -0500 @@ -32,12 +32,13 @@ import sun.security.krb5.KrbException; import javax.security.auth.kerberos.ServicePermission; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.Provider; import java.util.Locale; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Implements the GSSNameSpi for the krb5 mechanism. * @@ -51,9 +52,6 @@ private String gssNameStr = null; private Oid gssNameType = null; - // XXX Move this concept into PrincipalName's asn1Encode() sometime - private static String CHAR_ENCODING = "UTF-8"; - private Krb5NameElement(PrincipalName principalName, String gssNameStr, Oid gssNameType) { @@ -285,13 +283,7 @@ */ public byte[] export() throws GSSException { // XXX Apply the above constraints. - byte[] retVal = null; - try { - retVal = krb5PrincipalName.getName().getBytes(CHAR_ENCODING); - } catch (UnsupportedEncodingException e) { - // Can't happen - } - return retVal; + return krb5PrincipalName.getName().getBytes(UTF_8); } /** diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java --- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java Tue Nov 12 10:09:40 2019 -0500 @@ -29,7 +29,6 @@ import java.security.Provider; import java.security.Security; import java.io.IOException; -import java.io.UnsupportedEncodingException; import sun.security.krb5.Realm; import sun.security.jgss.GSSUtil; import sun.security.util.ObjectIdentifier; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSFactory.java --- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSFactory.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/NativeGSSFactory.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ package sun.security.jgss.wrapper; -import java.io.UnsupportedEncodingException; import java.security.Provider; import java.util.Vector; import org.ietf.jgss.*; @@ -34,6 +33,8 @@ import sun.security.jgss.GSSExceptionImpl; import sun.security.jgss.spi.*; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * JGSS plugin for generic mechanisms provided through native GSS framework. * @@ -80,14 +81,9 @@ public GSSNameSpi getNameElement(String nameStr, Oid nameType) throws GSSException { - try { - byte[] nameBytes = - (nameStr == null ? null : nameStr.getBytes("UTF-8")); - return new GSSNameElement(nameBytes, nameType, cStub); - } catch (UnsupportedEncodingException uee) { - // Shouldn't happen - throw new GSSExceptionImpl(GSSException.FAILURE, uee); - } + byte[] nameBytes = + (nameStr == null ? null : nameStr.getBytes(UTF_8)); + return new GSSNameElement(nameBytes, nameType, cStub); } public GSSNameSpi getNameElement(byte[] name, Oid nameType) diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/ETypeInfo.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ETypeInfo.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ETypeInfo.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,13 @@ package sun.security.krb5.internal; -import sun.security.util.*; +import java.io.IOException; + +import static java.nio.charset.StandardCharsets.UTF_8; + import sun.security.krb5.Asn1Exception; -import java.io.IOException; import sun.security.krb5.internal.util.KerberosString; +import sun.security.util.*; /** * Implements the ASN.1 ETYPE-INFO-ENTRY type. @@ -99,7 +102,7 @@ // KerberosString in most implementations. if (KerberosString.MSNAME) { - this.salt = new String(saltBytes, "UTF8"); + this.salt = new String(saltBytes, UTF_8); } else { this.salt = new String(saltBytes); } @@ -129,7 +132,7 @@ if (salt != null) { temp = new DerOutputStream(); if (KerberosString.MSNAME) { - temp.putOctetString(salt.getBytes("UTF8")); + temp.putOctetString(salt.getBytes(UTF_8)); } else { temp.putOctetString(salt.getBytes()); } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/PAData.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/PAData.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/PAData.java Tue Nov 12 10:09:40 2019 -0500 @@ -31,13 +31,15 @@ package sun.security.krb5.internal; -import sun.security.krb5.internal.crypto.EType; -import sun.security.util.*; -import sun.security.krb5.Asn1Exception; import java.io.IOException; import java.util.Vector; +import static java.nio.charset.StandardCharsets.*; + +import sun.security.krb5.Asn1Exception; import sun.security.krb5.internal.util.KerberosString; +import sun.security.krb5.internal.crypto.EType; +import sun.security.util.*; /** * Implements the ASN.1 PA-DATA type. @@ -263,7 +265,7 @@ switch (p.getType()) { case Krb5.PA_PW_SALT: paPwSalt = new String(p.getValue(), - KerberosString.MSNAME?"UTF8":"8859_1"); + KerberosString.MSNAME ? UTF_8 : ISO_8859_1); break; case Krb5.PA_ETYPE_INFO: d = new DerValue(p.getValue()); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/PAForUserEnc.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/PAForUserEnc.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/PAForUserEnc.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ import sun.security.util.DerOutputStream; import sun.security.util.DerValue; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Implements the ASN.1 PA-FOR-USER type. * @@ -163,25 +165,20 @@ * 4. the string value of auth-package field */ public byte[] getS4UByteArray() { - try { - ByteArrayOutputStream ba = new ByteArrayOutputStream(); - ba.write(new byte[4]); - for (String s: name.getNameStrings()) { - ba.write(s.getBytes("UTF-8")); - } - ba.write(name.getRealm().toString().getBytes("UTF-8")); - ba.write(AUTH_PACKAGE.getBytes("UTF-8")); - byte[] output = ba.toByteArray(); - int pnType = name.getNameType(); - output[0] = (byte)(pnType & 0xff); - output[1] = (byte)((pnType>>8) & 0xff); - output[2] = (byte)((pnType>>16) & 0xff); - output[3] = (byte)((pnType>>24) & 0xff); - return output; - } catch (IOException ioe) { - // not possible - throw new AssertionError("Cannot write ByteArrayOutputStream", ioe); + ByteArrayOutputStream ba = new ByteArrayOutputStream(); + ba.writeBytes(new byte[4]); + for (String s: name.getNameStrings()) { + ba.writeBytes(s.getBytes(UTF_8)); } + ba.writeBytes(name.getRealm().toString().getBytes(UTF_8)); + ba.writeBytes(AUTH_PACKAGE.getBytes(UTF_8)); + byte[] output = ba.toByteArray(); + int pnType = name.getNameType(); + output[0] = (byte)(pnType & 0xff); + output[1] = (byte)((pnType>>8) & 0xff); + output[2] = (byte)((pnType>>16) & 0xff); + output[3] = (byte)((pnType>>24) & 0xff); + return output; } public String toString() { diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Tue Nov 12 10:09:40 2019 -0500 @@ -51,6 +51,8 @@ import java.io.BufferedReader; import java.io.InputStreamReader; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + /** * CredentialsCache stores credentials(tickets, session keys, etc) in a * semi-permanent store @@ -594,7 +596,7 @@ BufferedReader commandResult = new BufferedReader - (new InputStreamReader(p.getInputStream(), "8859_1")); + (new InputStreamReader(p.getInputStream(), ISO_8859_1)); String s1 = null; if ((command.length == 1) && (command[0].equals("/usr/bin/env"))) { diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesDkCrypto.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,8 @@ import sun.security.krb5.internal.crypto.KeyUsage; import java.util.Arrays; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * This class provides the implementation of AES Encryption for Kerberos * as defined RFC 3962. @@ -104,7 +106,7 @@ byte[] saltUtf8 = null; try { - saltUtf8 = salt.getBytes("UTF-8"); + saltUtf8 = salt.getBytes(UTF_8); return stringToKey(password, saltUtf8, s2kparams); } catch (Exception e) { return null; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesSha2DkCrypto.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesSha2DkCrypto.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/AesSha2DkCrypto.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,8 @@ import sun.security.krb5.internal.crypto.KeyUsage; import java.util.Arrays; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * This class provides the implementation of AES Encryption with * HMAC-SHA2 for Kerberos 5 @@ -107,7 +109,7 @@ byte[] saltUtf8 = null; try { - saltUtf8 = salt.getBytes("UTF-8"); + saltUtf8 = salt.getBytes(UTF_8); return stringToKey(password, saltUtf8, s2kparams); } catch (Exception e) { return null; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/DkCrypto.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/DkCrypto.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/crypto/dk/DkCrypto.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. */ /* @@ -33,7 +33,6 @@ import javax.crypto.Cipher; import javax.crypto.Mac; import java.security.GeneralSecurityException; -import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -45,6 +44,8 @@ import sun.security.krb5.internal.crypto.KeyUsage; import sun.security.krb5.KrbCryptoException; +import static java.nio.charset.StandardCharsets.*; + /** * Implements Derive Key cryptography functionality as defined in RFC 3961. * http://www.ietf.org/rfc/rfc3961.txt @@ -672,13 +673,11 @@ } } -// String.getBytes("UTF-8"); +// String.getBytes(UTF_8); // Do this instead of using String to avoid making password immutable static byte[] charToUtf8(char[] chars) { - Charset utf8 = Charset.forName("UTF-8"); - CharBuffer cb = CharBuffer.wrap(chars); - ByteBuffer bb = utf8.encode(cb); + ByteBuffer bb = UTF_8.encode(cb); int len = bb.limit(); byte[] answer = new byte[len]; bb.get(answer, 0, len); @@ -686,10 +685,8 @@ } static byte[] charToUtf16(char[] chars) { - Charset utf8 = Charset.forName("UTF-16LE"); - CharBuffer cb = CharBuffer.wrap(chars); - ByteBuffer bb = utf8.encode(cb); + ByteBuffer bb = UTF_16LE.encode(cb); int len = bb.limit(); byte[] answer = new byte[len]; bb.get(answer, 0, len); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabEntry.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabEntry.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabEntry.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,4 +1,5 @@ /* + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +33,8 @@ import sun.security.krb5.*; import sun.security.krb5.internal.*; -import java.io.UnsupportedEncodingException; + +import static java.nio.charset.StandardCharsets.ISO_8859_1; /** * This class represents a Key Table entry. Each entry contains the service principal of @@ -83,17 +85,10 @@ int totalPrincipalLength = 0; String[] names = service.getNameStrings(); for (int i = 0; i < names.length; i++) { - try { - totalPrincipalLength += principalSize + names[i].getBytes("8859_1").length; - } catch (UnsupportedEncodingException exc) { - } + totalPrincipalLength += principalSize + names[i].getBytes(ISO_8859_1).length; } - int realmLen = 0; - try { - realmLen = realm.toString().getBytes("8859_1").length; - } catch (UnsupportedEncodingException exc) { - } + int realmLen = realm.toString().getBytes(ISO_8859_1).length; int size = principalComponentSize + realmSize + realmLen + totalPrincipalLength + principalTypeSize diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabOutputStream.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabOutputStream.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabOutputStream.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,4 +1,5 @@ /* + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +36,8 @@ import java.io.IOException; import java.io.FileOutputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; + +import static java.nio.charset.StandardCharsets.ISO_8859_1; /** * This class implements a buffered input stream. It is used for parsing key table @@ -68,21 +70,16 @@ } else write16(comp_num); - byte[] realm = null; - try { - realm = entry.service.getRealmString().getBytes("8859_1"); - } catch (UnsupportedEncodingException exc) { - } - + byte[] realm = entry.service.getRealmString().getBytes(ISO_8859_1); write16(realm.length); write(realm); + for (int i = 0; i < comp_num; i++) { - try { - write16(serviceNames[i].getBytes("8859_1").length); - write(serviceNames[i].getBytes("8859_1")); - } catch (UnsupportedEncodingException exc) { - } + byte[] serviceName = serviceNames[i].getBytes(ISO_8859_1); + write16(serviceName.length); + write(serviceName); } + write32(entry.service.getNameType()); //time is long, but we only use 4 bytes to store the data. write32((int)(entry.timestamp.getTime()/1000)); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.jgss/share/classes/sun/security/krb5/internal/util/KerberosString.java --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/util/KerberosString.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/util/KerberosString.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. * 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,6 +29,8 @@ import sun.security.action.GetPropertyAction; import sun.security.util.DerValue; +import static java.nio.charset.StandardCharsets.*; + /** * Implements the ASN.1 KerberosString type. * @@ -71,17 +73,17 @@ throw new IOException( "KerberosString's tag is incorrect: " + der.tag); } - s = new String(der.getDataBytes(), MSNAME?"UTF8":"ASCII"); + s = new String(der.getDataBytes(), MSNAME ? UTF_8 : US_ASCII); } public String toString() { return s; } - public DerValue toDerValue() throws IOException { + public DerValue toDerValue() { // No need to cache the result since this method is // only called once. return new DerValue(DerValue.tag_GeneralString, - s.getBytes(MSNAME?"UTF8":"ASCII")); + s.getBytes(MSNAME ? UTF_8 : US_ASCII)); } } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/ClientFactoryImpl.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/ClientFactoryImpl.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/ClientFactoryImpl.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,8 @@ import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.UnsupportedCallbackException; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Client factory for EXTERNAL, CRAM-MD5, PLAIN. * @@ -141,7 +143,7 @@ String authId; if (pw != null) { - bytepw = new String(pw).getBytes("UTF8"); + bytepw = new String(pw).getBytes(UTF_8); pcb.clearPassword(); } else { bytepw = null; diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Client.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Client.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Client.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import java.util.logging.Logger; import java.util.logging.Level; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Implements the CRAM-MD5 SASL client-side mechanism. * (RFC 2195). @@ -82,8 +84,8 @@ * data from the server. * @return A non-null byte array containing the response to be sent to * the server. - * @throws SaslException If platform does not have MD5 support - * @throw IllegalStateException if this method is invoked more than once. + * @throws SaslException if platform does not have MD5 support + * @throws IllegalStateException if this method is invoked more than once. */ public byte[] evaluateChallenge(byte[] challengeData) throws SaslException { @@ -103,7 +105,7 @@ try { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "CRAMCLNT01:Received challenge: {0}", - new String(challengeData, "UTF8")); + new String(challengeData, UTF_8)); } String digest = HMAC_MD5(pw, challengeData); @@ -118,13 +120,10 @@ completed = true; - return resp.getBytes("UTF8"); + return resp.getBytes(UTF_8); } catch (java.security.NoSuchAlgorithmException e) { aborted = true; throw new SaslException("MD5 algorithm not available on platform", e); - } catch (java.io.UnsupportedEncodingException e) { - aborted = true; - throw new SaslException("UTF8 not available on platform", e); } } } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Server.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Server.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Server.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,15 +25,15 @@ package com.sun.security.sasl; +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.util.logging.Level; +import java.util.Map; +import java.util.Random; import javax.security.sasl.*; import javax.security.auth.callback.*; -import java.util.Random; -import java.util.Map; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.NoSuchAlgorithmException; -import java.util.logging.Level; +import static java.nio.charset.StandardCharsets.UTF_8; /** * Implements the CRAM-MD5 SASL server-side mechanism. @@ -130,7 +130,7 @@ logger.log(Level.FINE, "CRAMSRV01:Generated challenge: {0}", challengeStr); - challengeData = challengeStr.getBytes("UTF8"); + challengeData = challengeStr.getBytes(UTF_8); return challengeData.clone(); } else { @@ -138,7 +138,7 @@ if(logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "CRAMSRV02:Received response: {0}", - new String(responseData, "UTF8")); + new String(responseData, UTF_8)); } // Extract username from response @@ -154,7 +154,7 @@ throw new SaslException( "CRAM-MD5: Invalid response; space missing"); } - String username = new String(responseData, 0, ulen, "UTF8"); + String username = new String(responseData, 0, ulen, UTF_8); logger.log(Level.FINE, "CRAMSRV03:Extracted username: {0}", username); @@ -177,7 +177,7 @@ for (int i = 0; i < pwChars.length; i++) { pwChars[i] = 0; } - pw = pwStr.getBytes("UTF8"); + pw = pwStr.getBytes(UTF_8); // Generate a keyed-MD5 digest from the user's password and // original challenge. @@ -190,7 +190,7 @@ clearPassword(); // Check whether digest is as expected - byte[] expectedDigest = digest.getBytes("UTF8"); + byte[] expectedDigest = digest.getBytes(UTF_8); int digestLen = responseData.length - ulen - 1; if (expectedDigest.length != digestLen) { aborted = true; @@ -222,9 +222,6 @@ completed = true; return null; } - } catch (UnsupportedEncodingException e) { - aborted = true; - throw new SaslException("UTF8 not available on platform", e); } catch (NoSuchAlgorithmException e) { aborted = true; throw new SaslException("MD5 algorithm not available on platform", e); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/ExternalClient.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/ExternalClient.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/ExternalClient.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ import javax.security.sasl.*; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Implements the EXTERNAL SASL client mechanism. * (RFC 2222). @@ -43,17 +45,10 @@ * Constructs an External mechanism with optional authorization ID. * * @param authorizationID If non-null, used to specify authorization ID. - * @throws SaslException if cannot convert authorizationID into UTF-8 - * representation. */ - ExternalClient(String authorizationID) throws SaslException { + ExternalClient(String authorizationID) { if (authorizationID != null) { - try { - username = authorizationID.getBytes("UTF8"); - } catch (java.io.UnsupportedEncodingException e) { - throw new SaslException("Cannot convert " + authorizationID + - " into UTF-8", e); - } + username = authorizationID.getBytes(UTF_8); } else { username = new byte[0]; } @@ -88,10 +83,9 @@ * * @param challengeData Ignored. * @return The possible empty initial response. - * @throws SaslException If authentication has already been called. + * @throws IllegalStateException If authentication has already been called. */ - public byte[] evaluateChallenge(byte[] challengeData) - throws SaslException { + public byte[] evaluateChallenge(byte[] challengeData) { if (completed) { throw new IllegalStateException( "EXTERNAL authentication already completed"); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ import javax.security.sasl.*; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Implements the PLAIN SASL client mechanism. * ( '\u00FF' ) { - return str.getBytes("UTF8"); - } + if (useUTF8) { + for (int i = 0; i < buffer.length; i++) { + if (buffer[i] > '\u00FF') { + return str.getBytes(UTF_8); } } - return str.getBytes("8859_1"); - } catch (UnsupportedEncodingException e) { - throw new SaslException( - "cannot encode string in UTF8 or 8859-1 (Latin-1)", e); } + return str.getBytes(ISO_8859_1); } protected static byte[] getPlatformCiphers() { @@ -461,8 +455,6 @@ * @return A non-null byte array containing the repsonse-value. * @throws NoSuchAlgorithmException if the platform does not have MD5 * digest support. - * @throws UnsupportedEncodingException if a an error occurs - * encoding a string into either Latin-1 or UTF-8. * @throws IOException if an error occurs writing to the output * byte array buffer. */ @@ -478,7 +470,6 @@ int nonceCount, byte[] authzidValue ) throws NoSuchAlgorithmException, - UnsupportedEncodingException, IOException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -845,14 +836,9 @@ try { generateIntegrityKeyPair(clientMode); - } catch (UnsupportedEncodingException e) { - throw new SaslException( - "DIGEST-MD5: Error encoding strings into UTF-8", e); - } catch (IOException e) { throw new SaslException("DIGEST-MD5: Error accessing buffers " + "required to create integrity key pairs", e); - } catch (NoSuchAlgorithmException e) { throw new SaslException("DIGEST-MD5: Unsupported digest " + "algorithm used to create integrity key pairs", e); @@ -866,16 +852,13 @@ * Generate client-server, server-client key pairs for DIGEST-MD5 * integrity checking. * - * @throws UnsupportedEncodingException if the UTF-8 encoding is not - * supported on the platform. * @throws IOException if an error occurs when writing to or from the * byte array output buffers. * @throws NoSuchAlgorithmException if the MD5 message digest algorithm * cannot loaded. */ private void generateIntegrityKeyPair(boolean clientMode) - throws UnsupportedEncodingException, IOException, - NoSuchAlgorithmException { + throws IOException, NoSuchAlgorithmException { byte[] cimagic = CLIENT_INT_MAGIC.getBytes(encoding); byte[] simagic = SVR_INT_MAGIC.getBytes(encoding); @@ -1130,11 +1113,6 @@ } catch (SaslException e) { throw e; - - } catch (UnsupportedEncodingException e) { - throw new SaslException( - "DIGEST-MD5: Error encoding string value into UTF-8", e); - } catch (IOException e) { throw new SaslException("DIGEST-MD5: Error accessing " + "buffers required to generate cipher keys", e); @@ -1152,14 +1130,11 @@ * byte array output buffers. * @throws NoSuchAlgorithmException if the MD5 message digest algorithm * cannot loaded. - * @throws UnsupportedEncodingException if an UTF-8 encoding is not - * supported on the platform. - * @throw SaslException if an error occurs initializing the keys and + * @throws SaslException if an error occurs initializing the keys and * IVs for the chosen cipher. */ private void generatePrivacyKeyPair(boolean clientMode) - throws IOException, UnsupportedEncodingException, - NoSuchAlgorithmException, SaslException { + throws IOException, NoSuchAlgorithmException, SaslException { byte[] ccmagic = CLIENT_CONF_MAGIC.getBytes(encoding); byte[] scmagic = SVR_CONF_MAGIC.getBytes(encoding); diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,14 +28,14 @@ import java.security.NoSuchAlgorithmException; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Arrays; +import java.util.logging.Level; -import java.util.logging.Level; +import static java.nio.charset.StandardCharsets.UTF_8; import javax.security.sasl.*; import javax.security.auth.callback.CallbackHandler; @@ -155,13 +155,7 @@ // authzID can only be encoded in UTF8 - RFC 2222 if (authzid != null) { this.authzid = authzid; - try { - authzidBytes = authzid.getBytes("UTF8"); - - } catch (UnsupportedEncodingException e) { - throw new SaslException( - "DIGEST-MD5: Error encoding authzid value into UTF-8", e); - } + authzidBytes = authzid.getBytes(UTF_8); } if (props != null) { @@ -272,7 +266,7 @@ * digest challenge format is detected. */ private void processChallenge(byte[][] challengeVal, List realmChoices) - throws SaslException, UnsupportedEncodingException { + throws SaslException { /* CHARSET: optional atmost once */ if (challengeVal[CHARSET] != null) { @@ -281,7 +275,7 @@ "violation. Unrecognised charset value: " + new String(challengeVal[CHARSET])); } else { - encoding = "UTF8"; + encoding = UTF_8; useUTF8 = true; } } diff -r 74e44250e3a7 -r af9779f2d6bf src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Server.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,10 +25,9 @@ package com.sun.security.sasl.digest; -import java.security.NoSuchAlgorithmException; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.security.NoSuchAlgorithmException; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.List; @@ -40,6 +39,8 @@ import javax.security.sasl.*; import javax.security.auth.callback.*; +import static java.nio.charset.StandardCharsets.*; + /** * An implementation of the DIGEST-MD5 server SASL mechanism. * (RFC 2831) @@ -171,7 +172,7 @@ } } - encoding = (useUTF8 ? "UTF8" : "8859_1"); + encoding = (useUTF8 ? UTF_8 : ISO_8859_1); // By default, use server name as realm if (serverRealms.isEmpty()) { @@ -229,9 +230,6 @@ step = 3; return challenge; - } catch (UnsupportedEncodingException e) { - throw new SaslException( - "DIGEST-MD5: Error encoding challenge", e); } catch (IOException e) { throw new SaslException( "DIGEST-MD5: Error generating challenge", e); @@ -247,11 +245,6 @@ byte[][] responseVal = parseDirectives(response, DIRECTIVE_KEY, null, REALM); challenge = validateClientResponse(responseVal); - } catch (SaslException e) { - throw e; - } catch (UnsupportedEncodingException e) { - throw new SaslException( - "DIGEST-MD5: Error validating client response", e); } finally { step = 0; // Set to invalid state } @@ -298,7 +291,7 @@ * auth-param = token "=" ( token | quoted-string ) */ private byte[] generateChallenge(List realms, String qopStr, - String cipherStr) throws UnsupportedEncodingException, IOException { + String cipherStr) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); // Realms (>= 0) @@ -389,7 +382,7 @@ * @return response-value ('rspauth') for client to validate */ private byte[] validateClientResponse(byte[][] responseVal) - throws SaslException, UnsupportedEncodingException { + throws SaslException { /* CHARSET: optional atmost once */ if (responseVal[CHARSET] != null) { diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java --- a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java Tue Nov 12 10:09:40 2019 -0500 @@ -51,29 +51,18 @@ * {@code null} if this is the default case. * If this case has multiple labels, returns the first label. * @return the expression for the case, or null + * @deprecated Please use {@link #getExpressions()}. */ + @Deprecated ExpressionTree getExpression(); /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * Returns the labels for this case. * For default case, returns an empty list. * * @return labels for this case * @since 12 - * - * @preview This method is modeling a case with multiple labels, - * which is part of a preview feature and may be removed - * if the preview feature is removed. */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) List getExpressions(); /** @@ -86,14 +75,6 @@ List getStatements(); /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * For case with kind {@linkplain CaseKind#RULE}, * returns the statement or expression after the arrow. * Returns {@code null} for case with kind @@ -102,40 +83,21 @@ * @return case value or null * @since 12 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) public default Tree getBody() { return null; } /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * Returns the kind of this case. * * @return the kind of this case * @since 12 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") public default CaseKind getCaseKind() { return CaseKind.STATEMENT; } /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This enum is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * The syntatic form of this case: *
    *
  • STATEMENT: {@code case : }
  • @@ -144,8 +106,6 @@ * * @since 12 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") public enum CaseKind { /** * Case is in the form: {@code case : }. diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java --- a/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java Tue Nov 12 10:09:40 2019 -0500 @@ -28,14 +28,6 @@ import java.util.List; /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This interface is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * A tree node for a {@code switch} expression. * * For example: @@ -49,7 +41,6 @@ * * @since 12 */ -@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) public interface SwitchExpressionTree extends ExpressionTree { /** * Returns the expression for the {@code switch} expression. diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java --- a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java Tue Nov 12 10:09:40 2019 -0500 @@ -240,20 +240,10 @@ SWITCH(SwitchTree.class), /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This enum constant is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * Used for instances of {@link SwitchExpressionTree}. * * @since 12 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") SWITCH_EXPRESSION(SwitchExpressionTree.class), /** @@ -662,20 +652,10 @@ OTHER(null), /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This enum constant is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * Used for instances of {@link YieldTree}. * * @since 13 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") YIELD(YieldTree.class); diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java --- a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java Tue Nov 12 10:09:40 2019 -0500 @@ -354,14 +354,6 @@ R visitSwitch(SwitchTree node, P p); /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * Visits a SwitchExpressionTree node. * * @param node the node being visited @@ -369,8 +361,6 @@ * @return a result value * @since 12 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") R visitSwitchExpression(SwitchExpressionTree node, P p); /** @@ -560,21 +550,11 @@ R visitOther(Tree node, P p); /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * Visits a YieldTree node. * @param node the node being visited * @param p a parameter value * @return a result value * @since 13 */ - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") R visitYield(YieldTree node, P p); } diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/tree/YieldTree.java --- a/src/jdk.compiler/share/classes/com/sun/source/tree/YieldTree.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/YieldTree.java Tue Nov 12 10:09:40 2019 -0500 @@ -26,14 +26,6 @@ package com.sun.source.tree; /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * A tree node for a {@code yield} statement. * * For example: @@ -45,7 +37,6 @@ * * @since 13 */ -@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) public interface YieldTree extends StatementTree { /** diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java --- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue Nov 12 10:09:40 2019 -0500 @@ -264,14 +264,6 @@ } /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * {@inheritDoc} This implementation calls {@code defaultAction}. * * @param node {@inheritDoc} @@ -279,8 +271,6 @@ * @return the result of {@code defaultAction} */ @Override - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") public R visitSwitchExpression(SwitchExpressionTree node, P p) { return defaultAction(node, p); } @@ -794,8 +784,6 @@ * @return the result of {@code defaultAction} */ @Override - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") public R visitYield(YieldTree node, P p) { return defaultAction(node, p); } diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java --- a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java Tue Nov 12 10:09:40 2019 -0500 @@ -334,14 +334,6 @@ } /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * {@inheritDoc} This implementation scans the children in left to right order. * * @param node {@inheritDoc} @@ -349,8 +341,6 @@ * @return the result of scanning */ @Override - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") public R visitSwitchExpression(SwitchExpressionTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); @@ -365,7 +355,6 @@ * @return the result of scanning */ @Override - @SuppressWarnings("preview") public R visitCase(CaseTree node, P p) { R r = scan(node.getExpressions(), p); if (node.getCaseKind() == CaseTree.CaseKind.RULE) @@ -938,14 +927,6 @@ } /** - * {@preview Associated with switch expressions, a preview feature of - * the Java language. - * - * This method is associated with switch expressions, a preview - * feature of the Java language. Preview features - * may be removed in a future release, or upgraded to permanent - * features of the Java language.} - * * {@inheritDoc} This implementation returns {@code null}. * * @param node {@inheritDoc} @@ -953,8 +934,6 @@ * @return the result of scanning */ @Override - @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS) - @SuppressWarnings("preview") public R visitYield(YieldTree node, P p) { return scan(node.getValue(), p); } diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java Tue Nov 12 10:09:40 2019 -0500 @@ -165,10 +165,7 @@ * @return true, if given feature is a preview feature. */ public boolean isPreview(Feature feature) { - if (feature == Feature.SWITCH_EXPRESSION || - feature == Feature.SWITCH_MULTIPLE_CASE_LABELS || - feature == Feature.SWITCH_RULE || - feature == Feature.TEXT_BLOCKS) + if (feature == Feature.TEXT_BLOCKS) return true; //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing). //When real preview features will be added, this method can be implemented to return 'true' diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Tue Nov 12 10:09:40 2019 -0500 @@ -1467,7 +1467,6 @@ // check that there are no duplicate case labels or default clauses. Set labels = new HashSet<>(); // The set of case labels. boolean hasDefault = false; // Is there a default label? - @SuppressWarnings("preview") CaseTree.CaseKind caseKind = null; boolean wasError = false; for (List l = cases; l.nonEmpty(); l = l.tail) { diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Nov 12 10:09:40 2019 -0500 @@ -1432,7 +1432,6 @@ } List stats = null; JCTree body = null; - @SuppressWarnings("preview") CaseTree.CaseKind kind; switch (token.kind) { case ARROW: @@ -2897,7 +2896,6 @@ nextToken(); checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS); }; - @SuppressWarnings("preview") CaseTree.CaseKind caseKind; JCTree body = null; if (token.kind == ARROW) { @@ -2922,7 +2920,6 @@ } case DEFAULT: { nextToken(); - @SuppressWarnings("preview") CaseTree.CaseKind caseKind; JCTree body = null; if (token.kind == ARROW) { @@ -3300,7 +3297,7 @@ if (allowYieldStatement) { return true; } else if (shouldWarn) { - log.warning(pos, Warnings.RestrictedTypeNotAllowedPreview(name, Source.JDK13)); + log.warning(pos, Warnings.RestrictedTypeNotAllowed(name, Source.JDK14)); } } return false; diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Nov 12 10:09:40 2019 -0500 @@ -1249,17 +1249,14 @@ public static class JCCase extends JCStatement implements CaseTree { //as CaseKind is deprecated for removal (as it is part of a preview feature), //using indirection through these fields to avoid unnecessary @SuppressWarnings: - @SuppressWarnings("preview") public static final CaseKind STATEMENT = CaseKind.STATEMENT; - @SuppressWarnings("preview") public static final CaseKind RULE = CaseKind.RULE; - @SuppressWarnings("preview") public final CaseKind caseKind; public List pats; public List stats; public JCTree body; public boolean completesNormally; - protected JCCase(@SuppressWarnings("preview") CaseKind caseKind, List pats, + protected JCCase(CaseKind caseKind, List pats, List stats, JCTree body) { Assert.checkNonNull(pats); Assert.check(pats.isEmpty() || pats.head != null); @@ -1273,21 +1270,17 @@ @Override @DefinedBy(Api.COMPILER_TREE) public Kind getKind() { return Kind.CASE; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override @Deprecated @DefinedBy(Api.COMPILER_TREE) public JCExpression getExpression() { return pats.head; } @Override @DefinedBy(Api.COMPILER_TREE) - @SuppressWarnings("preview") public List getExpressions() { return pats; } @Override @DefinedBy(Api.COMPILER_TREE) - @SuppressWarnings("preview") public List getStatements() { return caseKind == CaseKind.STATEMENT ? stats : null; } @Override @DefinedBy(Api.COMPILER_TREE) - @SuppressWarnings("preview") public JCTree getBody() { return body; } @Override @DefinedBy(Api.COMPILER_TREE) - @SuppressWarnings("preview") public CaseKind getCaseKind() { return caseKind; } @@ -1304,7 +1297,6 @@ /** * A "switch ( ) { }" construction. */ - @SuppressWarnings("preview") public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree { public JCExpression selector; public List cases; @@ -1585,7 +1577,6 @@ /** * A break-with from a switch expression. */ - @SuppressWarnings("preview") public static class JCYield extends JCStatement implements YieldTree { public JCExpression value; public JCTree target; @@ -3104,7 +3095,7 @@ JCLabeledStatement Labelled(Name label, JCStatement body); JCSwitch Switch(JCExpression selector, List cases); JCSwitchExpression SwitchExpression(JCExpression selector, List cases); - JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List pat, + JCCase Case(CaseTree.CaseKind caseKind, List pat, List stats, JCTree body); JCSynchronized Synchronized(JCExpression lock, JCBlock body); JCTry Try(JCBlock body, List catchers, JCBlock finalizer); diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java Tue Nov 12 10:09:40 2019 -0500 @@ -144,7 +144,6 @@ } @DefinedBy(Api.COMPILER_TREE) - @SuppressWarnings("preview") public JCTree visitYield(YieldTree node, P p) { JCYield t = (JCYield) node; JCExpression value = copy(t.value, p); @@ -380,7 +379,6 @@ } @DefinedBy(Api.COMPILER_TREE) - @SuppressWarnings("preview") public JCTree visitSwitchExpression(SwitchExpressionTree node, P p) { JCSwitchExpression t = (JCSwitchExpression) node; JCExpression selector = copy(t.selector, p); diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Nov 12 10:09:40 2019 -0500 @@ -274,7 +274,7 @@ return tree; } - public JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List pats, + public JCCase Case(CaseTree.CaseKind caseKind, List pats, List stats, JCTree body) { JCCase tree = new JCCase(caseKind, pats, stats, body); tree.pos = pos; diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java Tue Nov 12 10:09:40 2019 -0500 @@ -31,7 +31,8 @@ import java.io.OutputStream; import java.io.IOException; import java.io.ByteArrayInputStream; -import java.io.UnsupportedEncodingException; + +import static java.nio.charset.StandardCharsets.UTF_8; import java.util.Arrays; import java.util.Collections; @@ -2154,11 +2155,7 @@ if (!printable) { return "0x" + Functions.toHexString(bytes); } else { - try { - return new String(bytes, "UTF-8"); - } catch (UnsupportedEncodingException uee) { - return "0x" + Functions.toHexString(bytes); - } + return new String(bytes, UTF_8); } } diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11TlsPrfGenerator.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import javax.crypto.*; import javax.crypto.spec.*; +import static java.nio.charset.StandardCharsets.UTF_8; + import sun.security.internal.spec.TlsPrfParameterSpec; import static sun.security.pkcs11.TemplateManager.*; @@ -167,7 +169,7 @@ } } - byte[] label = P11Util.getBytesUTF8(spec.getLabel()); + byte[] label = spec.getLabel().getBytes(UTF_8); if (mechanism == CKM_NSS_TLS_PRF_GENERAL) { Session session = null; diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Util.java --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Util.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Util.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,14 +143,6 @@ return b; } - static byte[] getBytesUTF8(String s) { - try { - return s.getBytes("UTF8"); - } catch (java.io.UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - static byte[] sha1(byte[] data) { try { MessageDigest md = MessageDigest.getInstance("SHA-1"); diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java --- a/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,15 +26,17 @@ package com.oracle.security.ucrypto; import java.io.*; -import static java.io.StreamTokenizer.*; import java.math.BigInteger; import java.util.*; +import java.security.*; -import java.security.*; +import static java.io.StreamTokenizer.*; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import sun.security.action.GetPropertyAction; import sun.security.util.PropertyExpander; + /** * Configuration container and file parsing. * @@ -66,8 +68,8 @@ Config(String filename) throws IOException { FileInputStream in = new FileInputStream(expand(filename)); - reader = new BufferedReader(new InputStreamReader(in, "ISO-8859-1")); - parsedKeywords = new HashSet(); + reader = new BufferedReader(new InputStreamReader(in, ISO_8859_1)); + parsedKeywords = new HashSet<>(); st = new StreamTokenizer(reader); setupTokenizer(); parse(); diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/TranslatedException.java --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/TranslatedException.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/TranslatedException.java Tue Nov 12 10:09:40 2019 -0500 @@ -122,7 +122,7 @@ * a single exception is: * *
    -     *  '|'  '|'  '|' [ '|'  '|'  '|'  '|' ]*
    +     *  '|'  '|'  '|' [  '|'  '|'  '|'  '|'  '|'  '|'  '|' ]*
          * 
    * * Each exception is encoded before the exception it causes. @@ -149,8 +149,10 @@ for (int i = 0; i < stackTrace.length; i++) { StackTraceElement frame = stackTrace[i]; if (frame != null) { - enc.format("%s|%s|%s|%d|", frame.getClassName(), frame.getMethodName(), - encodedString(frame.getFileName()), frame.getLineNumber()); + enc.format("%s|%s|%s|%s|%s|%s|%d|", encodedString(frame.getClassLoaderName()), + encodedString(frame.getModuleName()), encodedString(frame.getModuleVersion()), + frame.getClassName(), frame.getMethodName(), + encodedString(frame.getFileName()), frame.getLineNumber()); } } } @@ -206,14 +208,26 @@ StackTraceElement[] suffix = getStackTraceSuffix(); StackTraceElement[] stackTrace = new StackTraceElement[stackTraceDepth + suffix.length]; for (int j = 0; j < stackTraceDepth; j++) { + String classLoaderName = parts[i++]; + String moduleName = parts[i++]; + String moduleVersion = parts[i++]; String className = parts[i++]; String methodName = parts[i++]; String fileName = parts[i++]; int lineNumber = Integer.parseInt(parts[i++]); + if (classLoaderName.isEmpty()) { + classLoaderName = null; + } + if (moduleName.isEmpty()) { + moduleName = null; + } + if (moduleVersion.isEmpty()) { + moduleVersion = null; + } if (fileName.isEmpty()) { fileName = null; } - stackTrace[j] = new StackTraceElement(className, methodName, fileName, lineNumber); + stackTrace[j] = new StackTraceElement(classLoaderName, moduleName, moduleVersion, className, methodName, fileName, lineNumber); } System.arraycopy(suffix, 0, stackTrace, stackTraceDepth, suffix.length); throwable.setStackTrace(stackTrace); diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Tue Nov 12 10:09:40 2019 -0500 @@ -484,7 +484,10 @@ } for (FlightRecorderListener cl : PlatformRecorder.getListeners()) { try { - cl.recordingStateChanged(getRecording()); + // Skip internal recordings + if (recording != null) { + cl.recordingStateChanged(recording); + } } catch (RuntimeException re) { Logger.log(JFR, WARN, "Error notifying recorder listener:" + re.getMessage()); } diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java --- a/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,8 @@ import java.util.logging.Level; import javax.security.sasl.*; +import static java.nio.charset.StandardCharsets.UTF_8; + // JAAS import javax.security.auth.callback.CallbackHandler; @@ -150,11 +152,7 @@ } if (authzID != null && authzID.length() > 0) { - try { - this.authzID = authzID.getBytes("UTF8"); - } catch (IOException e) { - throw new SaslException("Cannot encode authorization ID", e); - } + this.authzID = authzID.getBytes(UTF_8); } } diff -r 74e44250e3a7 -r af9779f2d6bf src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java --- a/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java Fri Nov 08 20:41:14 2019 -0500 +++ b/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,8 @@ import java.util.Map; import java.util.logging.Level; +import static java.nio.charset.StandardCharsets.UTF_8; + // JAAS import javax.security.auth.callback.*; @@ -300,12 +302,8 @@ // Get authorization identity, if any if (gssOutToken.length > 4) { - try { - authzid = new String(gssOutToken, 4, - gssOutToken.length - 4, "UTF-8"); - } catch (UnsupportedEncodingException uee) { - throw new SaslException ("Cannot decode authzid", uee); - } + authzid = new String(gssOutToken, 4, + gssOutToken.length - 4, UTF_8); } else { authzid = peer; } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/compiler/compilercontrol/CompilationModeHighOnlyTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/compilercontrol/CompilationModeHighOnlyTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019, Loongson Technology Co. Ltd. All rights reserved. + * 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 8233885 + * @summary CompLevel_initial_compile should be CompLevel_full_optimization for high-only mode + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:CompilationMode=high-only + * compiler.compilercontrol.CompilationModeHighOnlyTest + * + */ + +package compiler.compilercontrol; + +public class CompilationModeHighOnlyTest{ + public static void main(String[] args) { + System.out.println("Passed"); + } +} diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestTranslatedException.java --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestTranslatedException.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestTranslatedException.java Tue Nov 12 10:09:40 2019 -0500 @@ -26,7 +26,6 @@ * @requires vm.jvmci * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:open * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * @ignore 8233745 * @run testng/othervm * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler * jdk.vm.ci.hotspot.test.TestTranslatedException @@ -43,15 +42,6 @@ import org.testng.annotations.Test; public class TestTranslatedException { - - private static String printToString(Throwable throwable) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (PrintStream ps = new PrintStream(baos)) { - throwable.printStackTrace(ps); - } - return baos.toString(); - } - @SuppressWarnings("serial") public static class Untranslatable extends RuntimeException { public Untranslatable(String message, Throwable cause) { @@ -74,15 +64,47 @@ for (int i = 0; i < 10; i++) { throwable = new ExceptionInInitializerError(new InvocationTargetException(new RuntimeException(String.valueOf(i), throwable), "invoke")); } - String before = printToString(throwable); String encoding = (String) encode.invoke(null, throwable); Throwable decoded = (Throwable) decode.invoke(null, encoding); - String after = printToString(decoded); + assertThrowableEquals(throwable, decoded); + } - after = after.replace( - "jdk.vm.ci.hotspot.TranslatedException: [java.lang.ClassNotFoundException: jdk/vm/ci/hotspot/test/TestTranslatedException$Untranslatable]", - "jdk.vm.ci.hotspot.test.TestTranslatedException$Untranslatable: test exception"); - - Assert.assertEquals(before, after); + private static void assertThrowableEquals(Throwable original, Throwable decoded) { + try { + Assert.assertEquals(original == null, decoded == null); + while (original != null) { + if (Untranslatable.class.equals(original.getClass())) { + Assert.assertEquals("jdk.vm.ci.hotspot.TranslatedException", decoded.getClass().getName()); + Assert.assertEquals("[java.lang.ClassNotFoundException: jdk/vm/ci/hotspot/test/TestTranslatedException$Untranslatable]", decoded.getMessage()); + Assert.assertEquals("test exception", original.getMessage()); + } else { + Assert.assertEquals(original.getClass().getName(), decoded.getClass().getName()); + Assert.assertEquals(original.getMessage(), decoded.getMessage()); + } + StackTraceElement[] originalStack = original.getStackTrace(); + StackTraceElement[] decodedStack = decoded.getStackTrace(); + Assert.assertEquals(originalStack.length, decodedStack.length); + for (int i = 0, n = originalStack.length; i < n; ++i) { + StackTraceElement originalStackElement = originalStack[i]; + StackTraceElement decodedStackElement = decodedStack[i]; + Assert.assertEquals(originalStackElement.getClassLoaderName(), decodedStackElement.getClassLoaderName()); + Assert.assertEquals(originalStackElement.getModuleName(), decodedStackElement.getModuleName()); + Assert.assertEquals(originalStackElement.getClassName(), decodedStackElement.getClassName()); + Assert.assertEquals(originalStackElement.getMethodName(), decodedStackElement.getMethodName()); + Assert.assertEquals(originalStackElement.getFileName(), decodedStackElement.getFileName()); + Assert.assertEquals(originalStackElement.getLineNumber(), decodedStackElement.getLineNumber()); + } + original = original.getCause(); + decoded = decoded.getCause(); + } + } catch (AssertionError e) { + System.err.println("original:["); + original.printStackTrace(System.err); + System.err.println("]"); + System.err.println("decoded:["); + original.printStackTrace(System.err); + System.err.println("]"); + throw e; + } } } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/compiler/loopopts/TestRemoveMainPostLoops.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/loopopts/TestRemoveMainPostLoops.java Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8233529 + * @summary Verify that correct loops are selected when trying to remove main/post. + * @run main/othervm -XX:-TieredCompilation -Xbatch + * -XX:CompileCommand=compileonly,compiler.loopopts.TestRemoveMainPostLoops::test + * compiler.loopopts.TestRemoveMainPostLoops + */ + +package compiler.loopopts; + +public class TestRemoveMainPostLoops { + static int cnt1 = 0; + int cnt2 = 0; + + void testCallee() { + // (5) Only main and post loops are created (no pre loop -> "PeelMainPost") and main is unrolled. + for (int i = 0; i < 100; ++i) { + // (4) Inner loop is fully unrolled and removed. + for (int j = 0; j < 10; ++j) { + cnt1 += j; + } + } + } + + void test() { + for (int i = 0; i < 10_000; ++i) { + // (0) testCallee method is inlined + testCallee(); + cnt2 = 0; + // (1) OSR compilation is triggered in this loop. + // (2) Pre-/main-/post loops are created. + // (3) Main and post loops found empty and removed. + // (6) Pre loop is found empty, attempt to remove main and post loop then incorrectly selects main from (5). + for (int j = 0; j < 10; ++j) { + cnt2 = cnt1 + j; + } + } + } + + public static void main(String[] strArr) { + TestRemoveMainPostLoops test = new TestRemoveMainPostLoops(); + for (int i = 0; i < 100; i++) { + cnt1 = 0; + test.cnt2 = 0; + test.test(); + if (cnt1 != 45000000 || test.cnt2 != 45000009) { + throw new RuntimeException("Incorrect result: " + cnt1 + " " + test.cnt2); + } + } + } +} diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/compiler/loopopts/superword/AlignmentOnePack.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/loopopts/superword/AlignmentOnePack.java Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8229694 + * @summary Tests the case where there is only 1 pack and no operations left when calling SuperWord::find_align_to_ref() to find the best alignment again. + * + * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.loopopts.superword.AlignmentOnePack::test + * compiler.loopopts.superword.AlignmentOnePack + */ + +package compiler.loopopts.superword; + +public class AlignmentOnePack { + static int iFld; + + public static void test(int[] intArr, short[] shortArr) { + for (int j = 8; j < intArr.length;j++) { + shortArr[10] = 10; + shortArr[j] = 30; + intArr[7] = 260; + intArr[j-1] = 400; + iFld = intArr[j]; + } + } + + public static void main(String[] args) throws Exception { + int[] a = new int[16]; + short[] c = new short[16]; + + for (int i = 0; i < 10000; i++) { + test(a, c); + } + } +} diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/runtime/CheckUnhandledOops/TestVerifyOops.java --- a/test/hotspot/jtreg/runtime/CheckUnhandledOops/TestVerifyOops.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/runtime/CheckUnhandledOops/TestVerifyOops.java Tue Nov 12 10:09:40 2019 -0500 @@ -21,10 +21,19 @@ * questions. */ +// The test fails on sparc because there are errors in VerifyOops. /* * @test * @bug 8231058 - * @requires vm.debug & (os.arch != "sparc") & (os.arch != "sparcv9") + * @requires vm.debug & vm.bits == "64" + * @requires (os.arch != "sparcv9") + * @run main/othervm -XX:+VerifyOops -XX:+UseCompressedOops TestVerifyOops + * @run main/othervm -XX:+VerifyOops -XX:-UseCompressedOops TestVerifyOops + */ +/* + * @test + * @bug 8231058 + * @requires vm.debug & vm.bits == "32" * @run main/othervm -XX:+VerifyOops TestVerifyOops */ diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/runtime/execstack/TestMT.java --- a/test/hotspot/jtreg/runtime/execstack/TestMT.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/runtime/execstack/TestMT.java Tue Nov 12 10:09:40 2019 -0500 @@ -78,7 +78,7 @@ public void run() { for (int i = 0; i < 10; ++i) { TestMT.run(getName()); - yield(); + Thread.yield(); } } } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/gc/gctests/gctest02/gctest02.java --- a/test/hotspot/jtreg/vmTestbase/gc/gctests/gctest02/gctest02.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/gc/gctests/gctest02/gctest02.java Tue Nov 12 10:09:40 2019 -0500 @@ -180,7 +180,7 @@ while ( ThreadCount.get() > 0 ) { int buf[] = new int[32]; { - yield(); + Thread.yield(); } } } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/jit/regression/b4446672/b4446672.java --- a/test/hotspot/jtreg/vmTestbase/jit/regression/b4446672/b4446672.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/jit/regression/b4446672/b4446672.java Tue Nov 12 10:09:40 2019 -0500 @@ -76,7 +76,7 @@ System.out.println ("GCThread synchronized."); while (!done) { gcing=true; - yield(); + Thread.yield(); System.gc(); } } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java Tue Nov 12 10:09:40 2019 -0500 @@ -362,7 +362,7 @@ currentDepth++; if (maxDepth > currentDepth) { - yield(); + Thread.yield(); if (mixed) { int result = recursionNative(maxDepth, currentDepth, true); diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIEventsDebuggee.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIEventsDebuggee.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIEventsDebuggee.java Tue Nov 12 10:09:40 2019 -0500 @@ -232,7 +232,7 @@ public void run() { while (!startExecution) - yield(); + Thread.yield(); for (int i = 0; (i < actionsNumber) && !stopExecution; i++) executor.doEventAction(); diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/share/jdi/MonitorEventsDebuggee.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/MonitorEventsDebuggee.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/MonitorEventsDebuggee.java Tue Nov 12 10:09:40 2019 -0500 @@ -53,7 +53,7 @@ public void run() { // wait when interrupted thread switches state to 'TIMED_WAITING' while ((threadToInterrupt.getState() != Thread.State.WAITING) && !exitedFromWait) { - yield(); + Thread.yield(); } // threadToInterrupt 'spuriously' exited from wait() @@ -236,7 +236,7 @@ public void run() { // wait when blocked thread switches state to 'BLOCKED' while (blockedThread.getState() != Thread.State.BLOCKED) - yield(); + Thread.yield(); lockingThread.releaseLock(); } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/share/jpda/StateTestThread.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/StateTestThread.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/StateTestThread.java Tue Nov 12 10:09:40 2019 -0500 @@ -111,7 +111,7 @@ start(); while (!isRunning) - yield(); + Thread.yield(); break; case 2: @@ -119,7 +119,7 @@ isRunning = false; while (this.getState() != Thread.State.TIMED_WAITING) - yield(); + Thread.yield(); break; case 3: @@ -129,7 +129,7 @@ interrupt(); while (getState() != Thread.State.WAITING) - yield(); + Thread.yield(); break; case 4: @@ -141,7 +141,7 @@ } while (!readyToBeBlocked || (getState() != Thread.State.BLOCKED)) - yield(); + Thread.yield(); break; case 5: diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java Tue Nov 12 10:09:40 2019 -0500 @@ -325,7 +325,7 @@ throw new TestBug("Locking thread can't reach required state (state: " + requiredState + " wasn't reached) in 1 minute"); } - yield(); + Thread.yield(); } requiredState = null; diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/share/locks/MonitorLockingThread.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/locks/MonitorLockingThread.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/locks/MonitorLockingThread.java Tue Nov 12 10:09:40 2019 -0500 @@ -78,7 +78,7 @@ * should already occur) and then force MonitorLockingThread to release lock */ while (blockedThread.getState() != Thread.State.BLOCKED) - yield(); + Thread.yield(); lockingThread.releaseLock(); } @@ -98,7 +98,7 @@ synchronized (lockToHold) { holdsLock = true; while (isRunning) - yield(); + Thread.yield(); } holdsLock = false; } @@ -106,12 +106,12 @@ public void releaseLock() { isRunning = false; while (holdsLock) - yield(); + Thread.yield(); } public void acquireLock() { start(); while (!holdsLock) - yield(); + Thread.yield(); } } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/share/runner/ThreadsRunner.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/runner/ThreadsRunner.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/runner/ThreadsRunner.java Tue Nov 12 10:09:40 2019 -0500 @@ -81,7 +81,7 @@ stresser.start(runParams.getIterations()); while (!this.isInterrupted() && stresser.iteration()) { test.run(); - yield(); + Thread.yield(); } waitForOtherThreads(); } catch (OutOfMemoryError oom) { diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/jni/GarbageGenerator.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/GarbageGenerator.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/GarbageGenerator.java Tue Nov 12 10:09:40 2019 -0500 @@ -84,7 +84,7 @@ while (!done) { for (g = 0; g < ringSize; g++) { gr.add(allocSize); - yield(); + Thread.yield(); } gr.discard(); try { diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java Tue Nov 12 10:09:40 2019 -0500 @@ -295,7 +295,7 @@ } if (strace001.DEPTH - currentDepth > 0) { - yield(); + Thread.yield(); recursiveMethod(); } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java Tue Nov 12 10:09:40 2019 -0500 @@ -304,7 +304,7 @@ } if (strace002.DEPTH - currentDepth > 0) { - yield(); + Thread.yield(); recursiveMethod(); } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java Tue Nov 12 10:09:40 2019 -0500 @@ -387,7 +387,7 @@ if (strace005.DEPTH - currentDepth > 0) { try { - yield(); + Thread.yield(); recursiveMethod2(); } catch (StackOverflowError e) { // ignore this exception diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java Tue Nov 12 10:09:40 2019 -0500 @@ -331,7 +331,7 @@ if (strace006.DEPTH - currentDepth > 0) { try { - yield(); + Thread.yield(); recursiveMethod2(); } catch (StackOverflowError e) { // ignore this exception diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread005.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread005.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread005.java Tue Nov 12 10:09:40 2019 -0500 @@ -160,7 +160,7 @@ */ public void run() { while (!GO && !timeout()) - yield(); + Thread.yield(); while (!STOP && !timeout()) ; } diff -r 74e44250e3a7 -r af9779f2d6bf test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread006.java --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread006.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread006.java Tue Nov 12 10:09:40 2019 -0500 @@ -176,7 +176,7 @@ */ public void run() { while (!GO && !timeout()) - yield(); + Thread.yield(); while (!STOP && !timeout()) ; } diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/ProblemList.txt --- a/test/jdk/ProblemList.txt Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/ProblemList.txt Tue Nov 12 10:09:40 2019 -0500 @@ -861,7 +861,6 @@ # svc_tools -sun/tools/jstat/jstatClassloadOutput1.sh 8173942 generic-all sun/tools/jhsdb/BasicLauncherTest.java 8193639,8211767 solaris-all,linux-ppc64,linux-ppc64le sun/tools/jhsdb/HeapDumpTest.java 8193639 solaris-all sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8230731,8001227 windows-all diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/com/sun/jdi/InvokeHangTest.java --- a/test/jdk/com/sun/jdi/InvokeHangTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/com/sun/jdi/InvokeHangTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -64,7 +64,7 @@ // This is called from the debugger via invokeMethod public double invokeee() { System.out.println("Debuggee: invokeee in thread "+Thread.currentThread().toString()); - yield(); + Thread.yield(); return longMethod(2); } public double longMethod(int n) { diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/com/sun/jdi/SimulResumerTest.java --- a/test/jdk/com/sun/jdi/SimulResumerTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/com/sun/jdi/SimulResumerTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -71,7 +71,7 @@ public void bkpt1(int i) { synchronized(name1) { - yield(); + Thread.yield(); } } @@ -85,7 +85,7 @@ public void bkpt2(int i) { synchronized(name2) { - yield(); + Thread.yield(); } } diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/com/sun/jdi/TwoThreadsTest.java --- a/test/jdk/com/sun/jdi/TwoThreadsTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/com/sun/jdi/TwoThreadsTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -70,7 +70,7 @@ } public void bkpt1(int i) { - yield(); + Thread.yield(); } public void run1() { @@ -82,7 +82,7 @@ } public void bkpt2(int i) { - yield(); + Thread.yield(); } public void run2() { diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/java/awt/Graphics2D/MTGraphicsAccessTest/MTGraphicsAccessTest.java --- a/test/jdk/java/awt/Graphics2D/MTGraphicsAccessTest/MTGraphicsAccessTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/java/awt/Graphics2D/MTGraphicsAccessTest/MTGraphicsAccessTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -197,7 +197,7 @@ while (!done) { try { testRunnable.run(); - yield(); + Thread.yield(); } catch (Throwable t) { numexceptions++; t.printStackTrace(); diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/java/net/CookieHandler/B6791927.java --- a/test/jdk/java/net/CookieHandler/B6791927.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/java/net/CookieHandler/B6791927.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,9 @@ /** * @test - * @bug 6791927 + * @bug 6791927 8233886 * @summary Wrong Locale in HttpCookie::expiryDate2DeltaSeconds + * @run main/othervm B6791927 */ import java.net.*; @@ -32,12 +33,14 @@ import java.util.Locale; public class B6791927 { - public static final void main( String[] aaParamters ) throws Exception{ + public static final void main(String[] aaParamters) throws Exception { Locale reservedLocale = Locale.getDefault(); try { // Forces a non US locale Locale.setDefault(Locale.FRANCE); - List cookies = HttpCookie.parse("set-cookie: CUSTOMER=WILE_E_COYOTE; expires=Sat, 09-Nov-2019 23:12:40 GMT"); + List cookies = HttpCookie.parse("set-cookie:" + + " CUSTOMER=WILE_E_COYOTE;" + + " expires=Sat, 09-Nov-2041 23:12:40 GMT"); if (cookies == null || cookies.isEmpty()) { throw new RuntimeException("No cookie found"); } diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java --- a/test/jdk/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,11 +22,12 @@ */ /* @test - * @bug 4527345 7026376 6633549 + * @bug 4527345 7026376 6633549 8233435 * @summary Unit test for DatagramChannel's multicast support * @library /test/lib * @build jdk.test.lib.NetworkConfiguration * jdk.test.lib.Platform + * jdk.test.lib.net.IPSupport * MulticastSendReceiveTests * @run main MulticastSendReceiveTests * @run main/othervm -Djava.net.preferIPv4Stack=true MulticastSendReceiveTests @@ -41,6 +42,7 @@ import java.io.IOException; import java.util.stream.Collectors; +import jdk.test.lib.Platform; import jdk.test.lib.NetworkConfiguration; import jdk.test.lib.net.IPSupport; @@ -242,23 +244,37 @@ public static void main(String[] args) throws IOException { IPSupport.throwSkippedExceptionIfNonOperational(); + // IPv4 and IPv6 interfaces that support multicasting NetworkConfiguration config = NetworkConfiguration.probe(); + List ip4MulticastInterfaces = config.ip4MulticastInterfaces() + .collect(Collectors.toList()); + List ip6MulticastInterfaces = config.ip6MulticastInterfaces() + .collect(Collectors.toList()); // multicast groups used for the test InetAddress ip4Group = InetAddress.getByName("225.4.5.6"); InetAddress ip6Group = InetAddress.getByName("ff02::a"); - for (NetworkInterface nif: config.ip4MulticastInterfaces() - .collect(Collectors.toList())) { + + // Platforms that allow dual sockets join IPv4 multicast groups + boolean canIPv6JoinIPv4Group = + Platform.isLinux() || + Platform.isOSX() || + Platform.isSolaris() || + Platform.isWindows(); + + for (NetworkInterface nif : ip4MulticastInterfaces) { InetAddress source = config.ip4Addresses(nif).iterator().next(); + test(UNSPEC, nif, ip4Group, source); test(INET, nif, ip4Group, source); - test(UNSPEC, nif, ip4Group, source); + if (IPSupport.hasIPv6() && canIPv6JoinIPv4Group) { + test(INET6, nif, ip4Group, source); + } } - for (NetworkInterface nif: config.ip6MulticastInterfaces() - .collect(Collectors.toList())) { + for (NetworkInterface nif : ip6MulticastInterfaces) { InetAddress source = config.ip6Addresses(nif).iterator().next(); + test(UNSPEC, nif, ip6Group, source); test(INET6, nif, ip6Group, source); - test(UNSPEC, nif, ip6Group, source); } } } diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java --- a/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,10 +22,15 @@ */ /* @test - * @bug 4640544 8044773 + * @bug 4640544 8044773 8233435 * @summary Unit test for setOption/getOption/options methods * @requires !vm.graal.enabled + * @library /test/lib + * @build jdk.test.lib.net.IPSupport + * jdk.test.lib.NetworkConfiguration + * SocketOptionTests * @run main SocketOptionTests + * @run main/othervm -Djava.net.preferIPv4Stack=true SocketOptionTests * @run main/othervm --limit-modules=java.base SocketOptionTests */ @@ -34,23 +39,61 @@ import java.net.*; import java.io.IOException; import java.util.*; +import static java.net.StandardProtocolFamily.*; import static java.net.StandardSocketOptions.*; +import jdk.test.lib.NetworkConfiguration; +import jdk.test.lib.net.IPSupport; + public class SocketOptionTests { - static void checkOption(DatagramChannel dc, - SocketOption name, - T expectedValue) - throws IOException - { - T value = dc.getOption(name); - if (!value.equals(expectedValue)) - throw new RuntimeException("value not as expected"); + public static void main(String[] args) throws IOException { + IPSupport.throwSkippedExceptionIfNonOperational(); + + NetworkConfiguration config = NetworkConfiguration.probe(); + InetAddress ip4Address = config.ip4Addresses().findAny().orElse(null); + InetAddress ip6Address = config.ip6Addresses().findAny().orElse(null); + + System.out.println("[UNSPEC, bound to wildcard address]"); + try (DatagramChannel dc = DatagramChannel.open()) { + test(dc, new InetSocketAddress(0)); + } + + if (IPSupport.hasIPv4()) { + System.out.println("[INET, bound to wildcard address]"); + try (DatagramChannel dc = DatagramChannel.open(INET)) { + test(dc, new InetSocketAddress(0)); + } + System.out.println("[INET, bound to IPv4 address]"); + try (DatagramChannel dc = DatagramChannel.open(INET)) { + test(dc, new InetSocketAddress(ip4Address, 0)); + } + } + + if (IPSupport.hasIPv6()) { + System.out.println("[INET6, bound to wildcard address]"); + try (DatagramChannel dc = DatagramChannel.open(INET6)) { + test(dc, new InetSocketAddress(0)); + } + System.out.println("[INET6, bound to IPv6 address]"); + try (DatagramChannel dc = DatagramChannel.open(INET6)) { + test(dc, new InetSocketAddress(ip6Address, 0)); + } + } + + if (IPSupport.hasIPv4() && IPSupport.hasIPv6()) { + System.out.println("[UNSPEC, bound to IPv4 address]"); + try (DatagramChannel dc = DatagramChannel.open()) { + test(dc, new InetSocketAddress(ip4Address, 0)); + } + System.out.println("[INET6, bound to IPv4 address]"); + try (DatagramChannel dc = DatagramChannel.open(INET6)) { + test(dc, new InetSocketAddress(ip4Address, 0)); + } + } } - public static void main(String[] args) throws IOException { - DatagramChannel dc = DatagramChannel.open(); - + static void test(DatagramChannel dc, SocketAddress localAddress) throws IOException { // check supported options Set> options = dc.supportedOptions(); boolean reuseport = options.contains(SO_REUSEPORT); @@ -101,7 +144,7 @@ checkOption(dc, SO_REUSEPORT, false); } // bind socket - dc.bind(new InetSocketAddress(0)); + dc.bind(localAddress); // allow to change when bound dc.setOption(SO_BROADCAST, true); @@ -116,7 +159,6 @@ dc.setOption(IP_MULTICAST_LOOP, true); checkOption(dc, IP_MULTICAST_LOOP, true); - // NullPointerException try { dc.setOption(null, "value"); @@ -137,4 +179,14 @@ } catch (ClosedChannelException x) { } } + + static void checkOption(DatagramChannel dc, + SocketOption name, + T expectedValue) + throws IOException + { + T value = dc.getOption(name); + if (!value.equals(expectedValue)) + throw new RuntimeException("value not as expected"); + } } diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/java/nio/channels/Selector/StackOverflowTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/nio/channels/Selector/StackOverflowTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. and/or its affiliates. + * 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 8216472 + * @summary native call in WindowsSelectorImpl.SubSelector.poll can use + * more stack space than available in a shadow zone, this can cause + * a crash if selector is called from a deep recursive java call + * @requires (os.family == "windows") + */ + +import java.nio.channels.Selector; + +public class StackOverflowTest { + + public static void main(String[] args) throws Exception { + try (var sel = Selector.open()) { + recursiveSelect(sel); + } catch (StackOverflowError e) { + // ignore SOE from java calls + } + } + + static void recursiveSelect(Selector sel) throws Exception { + sel.selectNow(); + recursiveSelect(sel); + } +} diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java Tue Nov 12 10:09:40 2019 -0500 @@ -0,0 +1,37 @@ +package jdk.jfr.api.recorder; + +import java.nio.file.Paths; +import java.util.concurrent.atomic.AtomicBoolean; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; +/** + * @test TestRecorderListenerWithDump + * + * @key jfr + * @requires vm.hasJFR + * @run main/othervm jdk.jfr.api.recorder.TestRecorderListenerWithDump + */ +public class TestRecorderListenerWithDump { + + public static void main(String... args) throws Exception { + AtomicBoolean nullRecording = new AtomicBoolean(); + FlightRecorder.addListener(new FlightRecorderListener() { + public void recordingStateChanged(Recording r) { + if (r == null) { + nullRecording.set(true); + } else { + System.out.println("Recording " + r.getName() + " " + r.getState()); + } + } + }); + try (Recording r = new Recording()) { + r.start(); + r.dump(Paths.get("dump.jfr")); + } + if (nullRecording.get()) { + throw new Exception("FlightRecorderListener returned null recording"); + } + } +} diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java --- a/test/jdk/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java Tue Nov 12 10:09:40 2019 -0500 @@ -101,8 +101,9 @@ } // Retrieve all biased lock revocation events related to the provided lock class, sorted by start time - static List getRevocationEvents(Recording recording, String fieldName, Class lockClass) throws Throwable { + static List getRevocationEvents(Recording recording, String eventTypeName, String fieldName, Class lockClass) throws Throwable { return Events.fromRecording(recording).stream() + .filter(e -> e.getEventType().getName().equals(eventTypeName)) .filter(e -> ((RecordedClass)e.getValue(fieldName)).getName().equals(lockClass.getName())) .sorted(Comparator.comparing(RecordedEvent::getStartTime)) .collect(Collectors.toList()); @@ -119,7 +120,7 @@ Thread biasBreaker = triggerRevocation(1, MyLock.class); recording.stop(); - List events = getRevocationEvents(recording, "lockClass", MyLock.class); + List events = getRevocationEvents(recording, EventNames.BiasedLockRevocation, "lockClass", MyLock.class); Asserts.assertEQ(events.size(), 1); RecordedEvent event = events.get(0); @@ -143,7 +144,7 @@ Thread biasBreaker = triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class); recording.stop(); - List events = getRevocationEvents(recording, "revokedClass", MyLock.class); + List events = getRevocationEvents(recording, EventNames.BiasedLockClassRevocation, "revokedClass", MyLock.class); Asserts.assertEQ(events.size(), 1); RecordedEvent event = events.get(0); @@ -169,7 +170,7 @@ Thread.holdsLock(l); recording.stop(); - List events = getRevocationEvents(recording, "lockClass", MyLock.class); + List events = getRevocationEvents(recording, EventNames.BiasedLockSelfRevocation, "lockClass", MyLock.class); Asserts.assertEQ(events.size(), 1); RecordedEvent event = events.get(0); @@ -211,7 +212,7 @@ touch(l); recording.stop(); - List events = getRevocationEvents(recording, "lockClass", MyLock.class); + List events = getRevocationEvents(recording, EventNames.BiasedLockRevocation, "lockClass", MyLock.class); Asserts.assertEQ(events.size(), 1); RecordedEvent event = events.get(0); @@ -237,7 +238,7 @@ Thread biasBreaker1 = triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class); recording.stop(); - List events = getRevocationEvents(recording, "revokedClass", MyLock.class); + List events = getRevocationEvents(recording, EventNames.BiasedLockClassRevocation, "revokedClass", MyLock.class); Asserts.assertEQ(events.size(), 2); // The rebias event should occur before the noRebias one diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java --- a/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java Tue Nov 12 10:09:40 2019 -0500 @@ -107,7 +107,7 @@ } catch (BrokenBarrierException e) { // Another thread has been interrupted - wait for us to be interrupted as well while (!interrupted()) { - yield(); + Thread.yield(); } } catch (InterruptedException e) { // Normal way of stopping the thread diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/tools/launcher/ArgsFileTest.java --- a/test/jdk/tools/launcher/ArgsFileTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/tools/launcher/ArgsFileTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -23,7 +23,7 @@ /** * @test - * @bug 8027634 + * @bug 8027634 8231863 * @summary Argument parsing from file * @modules jdk.compiler * jdk.zipfs @@ -61,13 +61,17 @@ env.put(JLDEBUG_KEY, "true"); } - private File createArgFile(String fname, List lines) throws IOException { + private File createArgFile(String fname, List lines, boolean endWithNewline) throws IOException { File argFile = new File(fname); argFile.delete(); - createAFile(argFile, lines); + createAFile(argFile, lines, endWithNewline); return argFile; } + private File createArgFile(String fname, List lines) throws IOException { + return createArgFile(fname, lines, true); + } + private void verifyOptions(List args, TestResult tr) { if (args.isEmpty()) { return; @@ -266,6 +270,23 @@ userArgs.delete(); } + @Test + public void userApplicationWithoutEmptyLastLine() throws IOException { + File cpOpt = createArgFile("cpOpt", Arrays.asList("-classpath ."), false); + File vmArgs = createArgFile("vmArgs", Arrays.asList("-Xint"), false); + + TestResult tr = doExec(env, javaCmd, "-cp", "test.jar", "@cpOpt", "Foo", "-test"); + verifyOptions(Arrays.asList("-cp", "test.jar", "-classpath", ".", "Foo", "-test"), tr); + verifyUserArgs(Arrays.asList("-test"), tr, 6); + + tr = doExec(env, javaCmd, "-cp", "test.jar", "@vmArgs", "Foo", "-test"); + verifyOptions(Arrays.asList("-cp", "test.jar", "-Xint", "Foo", "-test"), tr); + verifyUserArgs(Arrays.asList("-test"), tr, 5); + + cpOpt.delete(); + vmArgs.delete(); + } + // test with missing file @Test public void missingFileNegativeTest() throws IOException { diff -r 74e44250e3a7 -r af9779f2d6bf test/jdk/tools/launcher/TestHelper.java --- a/test/jdk/tools/launcher/TestHelper.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/jdk/tools/launcher/TestHelper.java Tue Nov 12 10:09:40 2019 -0500 @@ -349,12 +349,23 @@ * occurs then back off for a moment and try again. When a number of * attempts fail, give up and throw an exception. */ - void createAFile(File aFile, List contents) throws IOException { + void createAFile(File aFile, List lines) throws IOException { + createAFile(aFile, lines, true); + } + + void createAFile(File aFile, List lines, boolean endWithNewline) throws IOException { IOException cause = null; for (int attempts = 0; attempts < 10; attempts++) { try { - Files.write(aFile.getAbsoluteFile().toPath(), contents, - Charset.defaultCharset(), CREATE, TRUNCATE_EXISTING, WRITE); + if (endWithNewline) { + Files.write(aFile.getAbsoluteFile().toPath(), + lines, Charset.defaultCharset(), + CREATE, TRUNCATE_EXISTING, WRITE); + } else { + Files.write(aFile.getAbsoluteFile().toPath(), + String.join(System.lineSeparator(), lines).getBytes(Charset.defaultCharset()), + CREATE, TRUNCATE_EXISTING, WRITE); + } if (cause != null) { /* * report attempts and errors that were encountered diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/ConditionalWithVoid.java --- a/test/langtools/tools/javac/ConditionalWithVoid.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/ConditionalWithVoid.java Tue Nov 12 10:09:40 2019 -0500 @@ -4,7 +4,7 @@ * @summary The compiler was allowing void types in its parsing of conditional expressions. * @author tball * - * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ConditionalWithVoid.java + * @compile/fail/ref=ConditionalWithVoid.out -XDrawDiagnostics ConditionalWithVoid.java */ public class ConditionalWithVoid { public void test(Object o, String s) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/ConditionalWithVoid.out --- a/test/langtools/tools/javac/ConditionalWithVoid.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/ConditionalWithVoid.out Tue Nov 12 10:09:40 2019 -0500 @@ -2,6 +2,4 @@ ConditionalWithVoid.java:14:53: compiler.err.void.not.allowed.here ConditionalWithVoid.java:16:82: compiler.err.void.not.allowed.here ConditionalWithVoid.java:18:64: compiler.err.void.not.allowed.here -- compiler.note.preview.filename: ConditionalWithVoid.java -- compiler.note.preview.recompile 4 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples.not-yet.txt --- a/test/langtools/tools/javac/diags/examples.not-yet.txt Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples.not-yet.txt Tue Nov 12 10:09:40 2019 -0500 @@ -116,6 +116,7 @@ compiler.warn.override.bridge compiler.warn.position.overflow # CRTable: caused by files with long lines >= 1024 chars compiler.warn.proc.type.already.exists # JavacFiler: just mentioned in TODO +compiler.warn.restricted.type.not.allowed.preview # not produced by the compiler right now compiler.warn.unchecked.assign # DEAD, replaced by compiler.misc.unchecked.assign compiler.warn.unchecked.cast.to.type # DEAD, replaced by compiler.misc.unchecked.cast.to.type compiler.warn.unexpected.archive.file # Paths: zip file with unknown extn diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java --- a/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.break.outside.switch.expression -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class BreakOutsideSwitchExpression { int t(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java --- a/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.continue.outside.switch.expression -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class ContinueOutsideSwitchExpression { int t(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/IllegalRefToRestrictedType.java --- a/test/langtools/tools/javac/diags/examples/IllegalRefToRestrictedType.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/IllegalRefToRestrictedType.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,7 +22,8 @@ */ // key: compiler.warn.illegal.ref.to.restricted.type -// key: compiler.warn.restricted.type.not.allowed.preview +// key: compiler.warn.restricted.type.not.allowed +// options: -Xlint:-options -source 13 class IllegalRefToVarType { yield list() { return null; } diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java --- a/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -24,9 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.incompatible.type.in.switch.expression // key: compiler.misc.inconvertible.types -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class IncompatibleTypesInSwitchExpression { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/InvalidYield.java --- a/test/langtools/tools/javac/diags/examples/InvalidYield.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/InvalidYield.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,7 +22,6 @@ */ // key: compiler.err.invalid.yield -// options: --enable-preview --source ${jdk.version} class BreakComplexValueNoSwitchExpressions { void t() { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/InvalidYieldWarning.java --- a/test/langtools/tools/javac/diags/examples/InvalidYieldWarning.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/InvalidYieldWarning.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,7 +22,7 @@ */ // key: compiler.warn.invalid.yield -// options: --source ${jdk.version} +// options: -Xlint:-options --source 13 class BreakComplexValueNoSwitchExpressions { void t() { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java --- a/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,8 +22,8 @@ */ // key: compiler.misc.feature.multiple.case.labels -// key: compiler.warn.preview.feature.use.plural -// options: --enable-preview -source ${jdk.version} -Xlint:preview +// key: compiler.err.feature.not.supported.in.source.plural +// options: -Xlint:-options -source 13 class MultipleCaseLabels { void m(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/NoSwitchExpression.java --- a/test/langtools/tools/javac/diags/examples/NoSwitchExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/NoSwitchExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,7 +22,6 @@ */ // key: compiler.err.no.switch.expression -// options: --enable-preview --source ${jdk.version} class BreakComplexValueNoSwitchExpressions { void t() { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/NoSwitchExpressionQualify.java --- a/test/langtools/tools/javac/diags/examples/NoSwitchExpressionQualify.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/NoSwitchExpressionQualify.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,7 +22,6 @@ */ // key: compiler.err.no.switch.expression.qualify -// options: --enable-preview --source ${jdk.version} class BreakComplexValueNoSwitchExpressions { void t() { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/NotExhaustive.java --- a/test/langtools/tools/javac/diags/examples/NotExhaustive.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/NotExhaustive.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.not.exhaustive -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class NotExhaustive { int t(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/RestrictedTypeNotAllowedPreview.java --- a/test/langtools/tools/javac/diags/examples/RestrictedTypeNotAllowedPreview.java Fri Nov 08 20:41:14 2019 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +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. - */ - -// key: compiler.warn.restricted.type.not.allowed.preview - -class yield { } diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java --- a/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.return.outside.switch.expression -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class ReturnOutsideSwitchExpression { int t(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java --- a/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.rule.completes.normally -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class RuleCompletesNormally { public String convert(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java --- a/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.switch.case.unexpected.statement -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class ReturnOutsideSwitchExpression { void t(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java --- a/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.switch.expression.completes.normally -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class SwitchExpressionCompletesNormally { public String convert(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java --- a/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.switch.expression.empty -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class BreakOutsideSwitchExpression { String t(E e) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchExpressionNoResultExpressions.java --- a/test/langtools/tools/javac/diags/examples/SwitchExpressionNoResultExpressions.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionNoResultExpressions.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.switch.expression.no.result.expressions -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class SwitchExpressionCompletesNormally { public String convert(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java --- a/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java Tue Nov 12 10:09:40 2019 -0500 @@ -24,9 +24,6 @@ // key: compiler.err.prob.found.req // key: compiler.misc.incompatible.ret.type.in.lambda // key: compiler.misc.switch.expression.target.cant.be.void -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class SwitchExpressionTargetCantBeVoid { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchExpressions.java --- a/test/langtools/tools/javac/diags/examples/SwitchExpressions.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchExpressions.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,8 +22,8 @@ */ // key: compiler.misc.feature.switch.expressions -// key: compiler.warn.preview.feature.use.plural -// options: --enable-preview -source ${jdk.version} -Xlint:preview +// key: compiler.err.feature.not.supported.in.source.plural +// options: -Xlint:-options -source 13 class SwitchExpressions { int m(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java --- a/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,9 +22,6 @@ */ // key: compiler.err.switch.mixing.case.types -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class SwitchMixingCaseTypes { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/diags/examples/SwitchRules.java --- a/test/langtools/tools/javac/diags/examples/SwitchRules.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/diags/examples/SwitchRules.java Tue Nov 12 10:09:40 2019 -0500 @@ -22,8 +22,8 @@ */ // key: compiler.misc.feature.switch.rules -// key: compiler.warn.preview.feature.use.plural -// options: --enable-preview -source ${jdk.version} -Xlint:preview +// key: compiler.err.feature.not.supported.in.source.plural +// options: -Xlint:-options -source 13 class SwitchExpressions { void m(int i) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java --- a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -76,9 +76,6 @@ } } - private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source", - Integer.toString(Runtime.version().feature())}; - private void program(String... constructs) { String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }"; for (String c : constructs) @@ -88,7 +85,7 @@ private void assertOK(String... constructs) { reset(); - addCompileOptions(PREVIEW_OPTIONS); + addCompileOptions(); program(constructs); try { compile(); @@ -101,7 +98,7 @@ private void assertOKWithWarning(String warning, String... constructs) { reset(); - addCompileOptions(PREVIEW_OPTIONS); + addCompileOptions(); program(constructs); try { compile(); @@ -114,7 +111,7 @@ private void assertFail(String expectedDiag, String... constructs) { reset(); - addCompileOptions(PREVIEW_OPTIONS); + addCompileOptions(); program(constructs); try { compile(); diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java --- a/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Adding switch expressions - * @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BadSwitchExpressionLambda.java + * @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics BadSwitchExpressionLambda.java */ class BadSwitchExpressionLambda { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out --- a/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,6 +1,4 @@ BadSwitchExpressionLambda.java:19:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.switch.expression.target.cant.be.void)) BadSwitchExpressionLambda.java:21:9: compiler.err.cant.apply.symbol: kindname.method, r, BadSwitchExpressionLambda.SAM, @11, kindname.class, BadSwitchExpressionLambda, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.switch.expression.target.cant.be.void))) BadSwitchExpressionLambda.java:22:16: compiler.err.prob.found.req: (compiler.misc.unexpected.ret.val) -- compiler.note.preview.filename: BadSwitchExpressionLambda.java -- compiler.note.preview.recompile 3 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/parser/JavacParserTest.java --- a/test/langtools/tools/javac/parser/JavacParserTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/parser/JavacParserTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -1096,7 +1096,7 @@ String expectedErrors = "Test.java:1:178: compiler.err.switch.case.unexpected.statement\n"; StringWriter out = new StringWriter(); JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(out, fm, null, - Arrays.asList("-XDrawDiagnostics", "--enable-preview", "-source", SOURCE_VERSION), + Arrays.asList("-XDrawDiagnostics"), null, Arrays.asList(new MyFileObject(code))); CompilationUnitTree cut = ct.parse().iterator().next(); diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/BlockExpression.java --- a/test/langtools/tools/javac/switchexpr/BlockExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/BlockExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Verify rule cases with expression statements and throw statements work. - * @compile --enable-preview -source ${jdk.version} BlockExpression.java - * @run main/othervm --enable-preview BlockExpression + * @compile BlockExpression.java + * @run main BlockExpression */ public class BlockExpression { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java --- a/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify the type of a conditional expression with nested switch expression is computed properly - * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BooleanNumericNonNumeric.java + * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics BooleanNumericNonNumeric.java */ public class BooleanNumericNonNumeric { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out --- a/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,3 @@ BooleanNumericNonNumeric.java:11:20: compiler.err.operator.cant.be.applied.1: +, int, boolean BooleanNumericNonNumeric.java:19:15: compiler.err.cant.deref: int -- compiler.note.preview.filename: BooleanNumericNonNumeric.java -- compiler.note.preview.recompile 2 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/BreakTest.java --- a/test/langtools/tools/javac/switchexpr/BreakTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/BreakTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -67,7 +67,7 @@ StringWriter out = new StringWriter(); JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors, - List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null, + List.of("-XDdev"), null, Arrays.asList(new MyFileObject(CODE))); List labels = new ArrayList<>(); new TreePathScanner() { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/CRT.java --- a/test/langtools/tools/javac/switchexpr/CRT.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/CRT.java Tue Nov 12 10:09:40 2019 -0500 @@ -151,9 +151,7 @@ tb.createDirectories(classes); tb.cleanDirectory(classes); new JavacTask(tb) - .options("-Xjcov", - "--enable-preview", - "-source", SOURCE_VERSION) + .options("-Xjcov") .outdir(classes) .sources("public class Test {\n" + code + diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java --- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8214031 8221413 * @summary Verify that definite assignment when true works (legal code) - * @compile --enable-preview --source ${jdk.version} DefiniteAssignment1.java - * @run main/othervm --enable-preview DefiniteAssignment1 + * @compile DefiniteAssignment1.java + * @run main DefiniteAssignment1 */ public class DefiniteAssignment1 { public static void main(String[] args) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java --- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8214031 * @summary Verify that definite assignment when true works (illegal code) - * @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source ${jdk.version} -XDrawDiagnostics DefiniteAssignment2.java + * @compile/fail/ref=DefiniteAssignment2.out -XDrawDiagnostics DefiniteAssignment2.java */ public class DefiniteAssignment2 { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/DefiniteAssignment2.out --- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.out Tue Nov 12 10:09:40 2019 -0500 @@ -5,6 +5,4 @@ DefiniteAssignment2.java:59:19: compiler.err.var.might.not.have.been.initialized: x DefiniteAssignment2.java:69:19: compiler.err.var.might.not.have.been.initialized: x DefiniteAssignment2.java:79:20: compiler.err.var.might.already.be.assigned: x -- compiler.note.preview.filename: DefiniteAssignment2.java -- compiler.note.preview.recompile 7 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/EmptySwitch.java --- a/test/langtools/tools/javac/switchexpr/EmptySwitch.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/EmptySwitch.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8206986 8226510 * @summary Verify than a switch that does not yield a value is rejected. - * @compile/fail/ref=EmptySwitch.out --enable-preview -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=FLOW EmptySwitch.java + * @compile/fail/ref=EmptySwitch.out -XDrawDiagnostics -XDshould-stop.at=FLOW EmptySwitch.java */ public class EmptySwitch { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/EmptySwitch.out --- a/test/langtools/tools/javac/switchexpr/EmptySwitch.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/EmptySwitch.out Tue Nov 12 10:09:40 2019 -0500 @@ -3,6 +3,4 @@ EmptySwitch.java:38:10: compiler.err.switch.expression.no.result.expressions EmptySwitch.java:44:9: compiler.err.switch.expression.completes.normally EmptySwitch.java:47:26: compiler.err.rule.completes.normally -- compiler.note.preview.filename: EmptySwitch.java -- compiler.note.preview.recompile 5 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java --- a/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,9 +25,9 @@ * @test * @bug 8206986 * @summary Verify that an switch expression over enum can be exhaustive without default. - * @compile --enable-preview -source ${jdk.version} ExhaustiveEnumSwitch.java + * @compile ExhaustiveEnumSwitch.java * @compile ExhaustiveEnumSwitchExtra.java - * @run main/othervm --enable-preview ExhaustiveEnumSwitch + * @run main ExhaustiveEnumSwitch */ public class ExhaustiveEnumSwitch { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,4 +1,4 @@ -ExpressionSwitch.java:40:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions) -ExpressionSwitch.java:41:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules) -ExpressionSwitch.java:93:31: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels) +ExpressionSwitch.java:40:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 14 +ExpressionSwitch.java:41:20: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.rules), 9, 14 +ExpressionSwitch.java:93:31: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 14 3 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitch.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java Tue Nov 12 10:09:40 2019 -0500 @@ -3,8 +3,8 @@ * @bug 8206986 8222169 8224031 * @summary Check expression switch works. * @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java - * @compile --enable-preview -source ${jdk.version} ExpressionSwitch.java - * @run main/othervm --enable-preview ExpressionSwitch + * @compile ExpressionSwitch.java + * @run main ExpressionSwitch */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Verify behavior of various kinds of breaks. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchBreaks1.java - * @run main/othervm --enable-preview ExpressionSwitchBreaks1 + * @compile ExpressionSwitchBreaks1.java + * @run main ExpressionSwitchBreaks1 */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Check behavior for invalid breaks. - * @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchBreaks2.java + * @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics ExpressionSwitchBreaks2.java */ public class ExpressionSwitchBreaks2 { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out Tue Nov 12 10:09:40 2019 -0500 @@ -7,6 +7,4 @@ ExpressionSwitchBreaks2.java:40:29: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, ExpressionSwitchBreaks2, null) ExpressionSwitchBreaks2.java:45:22: compiler.err.break.outside.switch.expression ExpressionSwitchBreaks2.java:49:22: compiler.err.break.outside.switch.expression -- compiler.note.preview.filename: ExpressionSwitchBreaks2.java -- compiler.note.preview.recompile 9 errors \ No newline at end of file diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 8214114 8214529 * @summary Verify various corner cases with nested switch expressions. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchBugs.java - * @run main/othervm --enable-preview ExpressionSwitchBugs + * @compile ExpressionSwitchBugs.java + * @run main ExpressionSwitchBugs */ public class ExpressionSwitchBugs { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8214031 * @summary Verify various corner cases with nested switch expressions. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchBugsInGen.java - * @run main/othervm --enable-preview ExpressionSwitchBugsInGen + * @compile ExpressionSwitchBugsInGen.java + * @run main ExpressionSwitchBugsInGen */ public class ExpressionSwitchBugsInGen { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Check switch expressions - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchCodeFromJLS.java - * @run main/othervm --enable-preview ExpressionSwitchCodeFromJLS + * @compile ExpressionSwitchCodeFromJLS.java + * @run main ExpressionSwitchCodeFromJLS */ public class ExpressionSwitchCodeFromJLS { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Check definite (un)assignment for in switch expressions. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchDA.java - * @run main/othervm --enable-preview ExpressionSwitchDA + * @compile ExpressionSwitchDA.java + * @run main ExpressionSwitchDA */ public class ExpressionSwitchDA { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8214031 8214114 * @summary Verify switch expressions embedded in various statements work properly. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchEmbedding.java - * @run main/othervm --enable-preview ExpressionSwitchEmbedding + * @compile ExpressionSwitchEmbedding.java + * @run main ExpressionSwitchEmbedding */ public class ExpressionSwitchEmbedding { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Check fall through in switch expressions. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchFallThrough.java - * @run main/othervm --enable-preview ExpressionSwitchFallThrough + * @compile ExpressionSwitchFallThrough.java + * @run main ExpressionSwitchFallThrough */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Check fall through in switch expressions. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchFallThrough1.java - * @run main/othervm --enable-preview ExpressionSwitchFallThrough1 + * @compile ExpressionSwitchFallThrough1.java + * @run main ExpressionSwitchFallThrough1 */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8212982 * @summary Verify a compile-time error is produced if switch expression does not provide a value - * @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ExpressionSwitchFlow.java + * @compile/fail/ref=ExpressionSwitchFlow.out -XDrawDiagnostics ExpressionSwitchFlow.java */ public class ExpressionSwitchFlow { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.out --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.out Tue Nov 12 10:09:40 2019 -0500 @@ -7,6 +7,4 @@ ExpressionSwitchFlow.java:53:9: compiler.err.switch.expression.completes.normally ExpressionSwitchFlow.java:61:9: compiler.err.switch.expression.completes.normally ExpressionSwitchFlow.java:69:9: compiler.err.switch.expression.completes.normally -- compiler.note.preview.filename: ExpressionSwitchFlow.java -- compiler.note.preview.recompile 9 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Check switch expressions embedded in switch expressions. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchInExpressionSwitch.java - * @run main/othervm --enable-preview ExpressionSwitchInExpressionSwitch + * @compile ExpressionSwitchInExpressionSwitch.java + * @run main ExpressionSwitchInExpressionSwitch */ public class ExpressionSwitchInExpressionSwitch { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Check types inferred for switch expressions. - * @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchInfer.java + * @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics ExpressionSwitchInfer.java */ import java.util.ArrayList; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.out --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,6 +1,4 @@ ExpressionSwitchInfer.java:17:95: compiler.err.cant.resolve.location.args: kindname.method, substring, , int, (compiler.misc.location: kindname.interface, java.lang.CharSequence, null) ExpressionSwitchInfer.java:26:38: compiler.err.cant.resolve.location.args: kindname.method, substring, , int, (compiler.misc.location: kindname.interface, java.lang.CharSequence, null) ExpressionSwitchInfer.java:30:23: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.switch.expression: (compiler.misc.inconvertible.types: int, java.lang.String)) -- compiler.note.preview.filename: ExpressionSwitchInfer.java -- compiler.note.preview.recompile 3 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8206986 * @summary Verify behavior when an intersection type is inferred for switch expression. - * @compile --enable-preview -source ${jdk.version} ExpressionSwitchIntersectionTypes.java - * @run main/othervm --enable-preview ExpressionSwitchIntersectionTypes + * @compile ExpressionSwitchIntersectionTypes.java + * @run main ExpressionSwitchIntersectionTypes */ public class ExpressionSwitchIntersectionTypes { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify behavior of not exhaustive switch expressions. - * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchNotExhaustive.java + * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics ExpressionSwitchNotExhaustive.java */ public class ExpressionSwitchNotExhaustive { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.out --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,6 +1,4 @@ ExpressionSwitchNotExhaustive.java:10:16: compiler.err.not.exhaustive ExpressionSwitchNotExhaustive.java:16:16: compiler.err.not.exhaustive ExpressionSwitchNotExhaustive.java:29:23: compiler.err.var.might.not.have.been.initialized: s -- compiler.note.preview.filename: ExpressionSwitchNotExhaustive.java -- compiler.note.preview.recompile 3 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchToString.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchToString.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchToString.java Tue Nov 12 10:09:40 2019 -0500 @@ -99,7 +99,7 @@ String sourceVersion = Integer.toString(Runtime.version().feature()); JavacTask ct = (JavacTask) tool.getTask(null, null, noErrors, - List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null, + List.of("-XDdev"), null, Arrays.asList(new MyFileObject(CODE))); String actualCode = ct.parse().iterator().next().toString(); actualCode = actualCode.replace(System.getProperty("line.separator"), "\n"); diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify reachability in switch expressions. - * @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchUnreachable.java + * @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics ExpressionSwitchUnreachable.java */ public class ExpressionSwitchUnreachable { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.out --- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.out Tue Nov 12 10:09:40 2019 -0500 @@ -4,6 +4,4 @@ ExpressionSwitchUnreachable.java:37:17: compiler.err.unreachable.stmt ExpressionSwitchUnreachable.java:45:17: compiler.err.unreachable.stmt ExpressionSwitchUnreachable.java:52:17: compiler.err.unreachable.stmt -- compiler.note.preview.filename: ExpressionSwitchUnreachable.java -- compiler.note.preview.recompile 6 errors \ No newline at end of file diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/LambdaCapture.java --- a/test/langtools/tools/javac/switchexpr/LambdaCapture.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/LambdaCapture.java Tue Nov 12 10:09:40 2019 -0500 @@ -26,7 +26,7 @@ * @bug 8220041 * @summary Verify variable capture works inside switch expressions which are * inside variable declarations - * @compile --enable-preview -source ${jdk.version} LambdaCapture.java + * @compile LambdaCapture.java */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ParseIncomplete.java --- a/test/langtools/tools/javac/switchexpr/ParseIncomplete.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ParseIncomplete.java Tue Nov 12 10:09:40 2019 -0500 @@ -68,7 +68,7 @@ StringWriter out = new StringWriter(); try { JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors, - List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null, + List.of("-XDdev"), null, Arrays.asList(new MyFileObject(code))); ct.parse().iterator().next(); } catch (Throwable t) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ParserRecovery.java --- a/test/langtools/tools/javac/switchexpr/ParserRecovery.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ParserRecovery.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify the parser handles broken input gracefully. - * @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ParserRecovery.java + * @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics ParserRecovery.java */ public class ParserRecovery { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/ParserRecovery.out --- a/test/langtools/tools/javac/switchexpr/ParserRecovery.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/ParserRecovery.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,3 @@ ParserRecovery.java:10:39: compiler.err.expected2: :, -> ParserRecovery.java:13:31: compiler.err.expected2: :, -> -- compiler.note.preview.filename: ParserRecovery.java -- compiler.note.preview.recompile 2 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java --- a/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java Tue Nov 12 10:09:40 2019 -0500 @@ -26,8 +26,8 @@ * @bug 8214113 * @summary Verify the switch expression's type does not have a constant attached, * and so the switch expression is not elided. - * @compile --enable-preview --source ${jdk.version} SwitchExpressionIsNotAConstant.java - * @run main/othervm --enable-preview SwitchExpressionIsNotAConstant + * @compile SwitchExpressionIsNotAConstant.java + * @run main SwitchExpressionIsNotAConstant */ public class SwitchExpressionIsNotAConstant { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java --- a/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify that scopes in rule cases are isolated. - * @compile/fail/ref=SwitchExpressionScopesIsolated.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchExpressionScopesIsolated.java + * @compile/fail/ref=SwitchExpressionScopesIsolated.out -XDrawDiagnostics SwitchExpressionScopesIsolated.java */ public class SwitchExpressionScopesIsolated { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.out --- a/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.out Tue Nov 12 10:09:40 2019 -0500 @@ -2,6 +2,4 @@ SwitchExpressionScopesIsolated.java:13:41: compiler.err.cant.resolve.location: kindname.variable, res, , , (compiler.misc.location: kindname.class, SwitchExpressionScopesIsolated, null) SwitchExpressionScopesIsolated.java:14:26: compiler.err.cant.resolve.location: kindname.variable, res, , , (compiler.misc.location: kindname.class, SwitchExpressionScopesIsolated, null) SwitchExpressionScopesIsolated.java:14:42: compiler.err.cant.resolve.location: kindname.variable, res, , , (compiler.misc.location: kindname.class, SwitchExpressionScopesIsolated, null) -- compiler.note.preview.filename: SwitchExpressionScopesIsolated.java -- compiler.note.preview.recompile 4 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java --- a/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -107,7 +107,7 @@ StringWriter out = new StringWriter(); JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors, - List.of("--enable-preview", "-source", Integer.toString(Runtime.version().feature())), null, + List.of(), null, Arrays.asList(new MyFileObject(code))); return ct.parse().iterator().next(); } diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/TryCatch.java --- a/test/langtools/tools/javac/switchexpr/TryCatch.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/TryCatch.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8214114 * @summary Verify try-catch inside a switch expression works properly. - * @compile --enable-preview -source ${jdk.version} TryCatch.java - * @run main/othervm --enable-preview TryCatch + * @compile TryCatch.java + * @run main TryCatch */ public class TryCatch { public static void main(String[] args) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/TryCatchFinally.java --- a/test/langtools/tools/javac/switchexpr/TryCatchFinally.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/TryCatchFinally.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,8 +25,8 @@ * @test * @bug 8220018 * @summary Verify that try-catch-finally inside a switch expression works properly. - * @compile --enable-preview -source ${jdk.version} TryCatchFinally.java - * @run main/othervm --enable-preview TryCatchFinally + * @compile TryCatchFinally.java + * @run main TryCatchFinally */ public class TryCatchFinally {//TODO: yield public static void main(String[] args) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.java --- a/test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8223305 8226522 * @summary Verify correct warnings w.r.t. yield - * @compile/ref=WarnWrongYieldTest.out -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=ATTR WarnWrongYieldTest.java + * @compile/ref=WarnWrongYieldTest.out -Xlint:-options -source 13 -XDrawDiagnostics -XDshould-stop.at=ATTR WarnWrongYieldTest.java */ package t; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.out --- a/test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,8 +1,8 @@ -WarnWrongYieldTest.java:39:11: compiler.warn.restricted.type.not.allowed.preview: yield, 13 -WarnWrongYieldTest.java:45:5: compiler.warn.restricted.type.not.allowed.preview: yield, 13 -WarnWrongYieldTest.java:72:15: compiler.warn.restricted.type.not.allowed.preview: yield, 13 -WarnWrongYieldTest.java:75:15: compiler.warn.restricted.type.not.allowed.preview: yield, 13 -WarnWrongYieldTest.java:81:21: compiler.warn.restricted.type.not.allowed.preview: yield, 13 +WarnWrongYieldTest.java:39:11: compiler.warn.restricted.type.not.allowed: yield, 14 +WarnWrongYieldTest.java:45:5: compiler.warn.restricted.type.not.allowed: yield, 14 +WarnWrongYieldTest.java:72:15: compiler.warn.restricted.type.not.allowed: yield, 14 +WarnWrongYieldTest.java:75:15: compiler.warn.restricted.type.not.allowed: yield, 14 +WarnWrongYieldTest.java:81:21: compiler.warn.restricted.type.not.allowed: yield, 14 WarnWrongYieldTest.java:93:9: compiler.warn.invalid.yield WarnWrongYieldTest.java:98:9: compiler.warn.invalid.yield WarnWrongYieldTest.java:103:9: compiler.warn.invalid.yield @@ -11,8 +11,8 @@ WarnWrongYieldTest.java:118:9: compiler.warn.invalid.yield WarnWrongYieldTest.java:123:22: compiler.warn.invalid.yield WarnWrongYieldTest.java:152:24: compiler.warn.invalid.yield -WarnWrongYieldTest.java:164:18: compiler.warn.restricted.type.not.allowed.preview: yield, 13 -WarnWrongYieldTest.java:168:23: compiler.warn.restricted.type.not.allowed.preview: yield, 13 +WarnWrongYieldTest.java:164:18: compiler.warn.restricted.type.not.allowed: yield, 14 +WarnWrongYieldTest.java:168:23: compiler.warn.restricted.type.not.allowed: yield, 14 WarnWrongYieldTest.java:34:28: compiler.warn.illegal.ref.to.restricted.type: yield WarnWrongYieldTest.java:45:5: compiler.warn.illegal.ref.to.restricted.type: yield WarnWrongYieldTest.java:168:23: compiler.warn.illegal.ref.to.restricted.type: yield diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/WrongBreakTest.java --- a/test/langtools/tools/javac/switchexpr/WrongBreakTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/WrongBreakTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8223305 * @summary Ensure javac is not crashing for wrong breaks. - * @compile/fail/ref=WrongBreakTest.out --enable-preview -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=FLOW WrongBreakTest.java + * @compile/fail/ref=WrongBreakTest.out -XDrawDiagnostics -XDshould-stop.at=FLOW WrongBreakTest.java */ public class WrongBreakTest { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/WrongBreakTest.out --- a/test/langtools/tools/javac/switchexpr/WrongBreakTest.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/WrongBreakTest.out Tue Nov 12 10:09:40 2019 -0500 @@ -4,6 +4,4 @@ WrongBreakTest.java:36:9: compiler.err.ref.ambiguous: test, kindname.method, test(int), WrongBreakTest, kindname.method, test(java.lang.Object), WrongBreakTest WrongBreakTest.java:38:13: compiler.err.no.switch.expression WrongBreakTest.java:41:13: compiler.err.no.switch.expression -- compiler.note.preview.filename: WrongBreakTest.java -- compiler.note.preview.recompile 6 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/WrongYieldTest.java --- a/test/langtools/tools/javac/switchexpr/WrongYieldTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/WrongYieldTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -25,7 +25,7 @@ * @test * @bug 8223305 8226522 * @summary Ensure proper errors are returned for yields. - * @compile/fail/ref=WrongYieldTest.out --enable-preview -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=ATTR WrongYieldTest.java + * @compile/fail/ref=WrongYieldTest.out -XDrawDiagnostics -XDshould-stop.at=ATTR WrongYieldTest.java */ package t; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchexpr/WrongYieldTest.out --- a/test/langtools/tools/javac/switchexpr/WrongYieldTest.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchexpr/WrongYieldTest.out Tue Nov 12 10:09:40 2019 -0500 @@ -26,6 +26,4 @@ WrongYieldTest.java:201:9: compiler.err.no.switch.expression WrongYieldTest.java:202:9: compiler.err.no.switch.expression WrongYieldTest.java:216:24: compiler.err.illegal.ref.to.restricted.type: yield -- compiler.note.preview.filename: WrongYieldTest.java -- compiler.note.preview.recompile 28 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/CaseTest.java --- a/test/langtools/tools/javac/switchextra/CaseTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/CaseTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -137,7 +137,7 @@ StringWriter out = new StringWriter(); JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors, - List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null, + List.of("-XDdev"), null, Arrays.asList(new MyFileObject(code))); return ct.parse().iterator().next(); } diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/DefiniteAssignment1.java --- a/test/langtools/tools/javac/switchextra/DefiniteAssignment1.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/DefiniteAssignment1.java Tue Nov 12 10:09:40 2019 -0500 @@ -24,8 +24,8 @@ /** * @test * @summary Verify that definite assignment works (legal code) - * @compile --enable-preview -source ${jdk.version} DefiniteAssignment1.java - * @run main/othervm --enable-preview DefiniteAssignment1 + * @compile DefiniteAssignment1.java + * @run main DefiniteAssignment1 */ public class DefiniteAssignment1 { public static void main(String[] args) { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/DefiniteAssignment2.java --- a/test/langtools/tools/javac/switchextra/DefiniteAssignment2.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/DefiniteAssignment2.java Tue Nov 12 10:09:40 2019 -0500 @@ -1,7 +1,7 @@ /** * @test /nodynamiccopyright/ * @summary Verify that definite assignment works (illegal code) - * @compile/fail/ref=DefiniteAssignment2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} DefiniteAssignment2.java + * @compile/fail/ref=DefiniteAssignment2.out -XDrawDiagnostics DefiniteAssignment2.java */ public class DefiniteAssignment2 { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/DefiniteAssignment2.out --- a/test/langtools/tools/javac/switchextra/DefiniteAssignment2.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/DefiniteAssignment2.out Tue Nov 12 10:09:40 2019 -0500 @@ -4,6 +4,4 @@ DefiniteAssignment2.java:52:28: compiler.err.var.might.not.have.been.initialized: x DefiniteAssignment2.java:62:28: compiler.err.var.might.not.have.been.initialized: x DefiniteAssignment2.java:73:28: compiler.err.var.might.not.have.been.initialized: x -- compiler.note.preview.filename: DefiniteAssignment2.java -- compiler.note.preview.recompile 6 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out --- a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,4 +1,4 @@ -MultipleLabelsExpression.java:31:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions) -MultipleLabelsExpression.java:32:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules) -MultipleLabelsExpression.java:33:19: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels) +MultipleLabelsExpression.java:31:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 14 +MultipleLabelsExpression.java:32:20: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.rules), 9, 14 +MultipleLabelsExpression.java:33:19: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 14 3 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java --- a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java Tue Nov 12 10:09:40 2019 -0500 @@ -3,8 +3,8 @@ * @bug 8206986 * @summary Verify cases with multiple labels work properly. * @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java - * @compile --enable-preview -source ${jdk.version} MultipleLabelsExpression.java - * @run main/othervm --enable-preview MultipleLabelsExpression + * @compile MultipleLabelsExpression.java + * @run main MultipleLabelsExpression */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out --- a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,2 +1,2 @@ -MultipleLabelsStatement.java:35:21: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels) +MultipleLabelsStatement.java:35:21: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 14 1 error diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java --- a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java Tue Nov 12 10:09:40 2019 -0500 @@ -3,8 +3,8 @@ * @bug 8206986 * @summary Verify cases with multiple labels work properly. * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java - * @compile --enable-preview -source ${jdk.version} MultipleLabelsStatement.java - * @run main/othervm --enable-preview MultipleLabelsStatement + * @compile MultipleLabelsStatement.java + * @run main MultipleLabelsStatement */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/RuleParsingTest.java --- a/test/langtools/tools/javac/switchextra/RuleParsingTest.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/RuleParsingTest.java Tue Nov 12 10:09:40 2019 -0500 @@ -95,7 +95,7 @@ StringWriter out = new StringWriter(); JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors, - List.of("--enable-preview", "-source", sourceVersion), null, + List.of(), null, Arrays.asList(new MyFileObject(code.toString()))); CompilationUnitTree cut = ct.parse().iterator().next(); Trees trees = Trees.instance(ct); diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java --- a/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java Tue Nov 12 10:09:40 2019 -0500 @@ -3,7 +3,7 @@ * @bug 8206986 * @summary Verify reasonable errors are produced when neither ':' nor '->' * is found are the expression of a case - * @compile/fail/ref=SwitchArrowBrokenConstant.out -source ${jdk.version} --enable-preview -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java + * @compile/fail/ref=SwitchArrowBrokenConstant.out -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java */ public class SwitchArrowBrokenConstant { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.out --- a/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.out Tue Nov 12 10:09:40 2019 -0500 @@ -6,6 +6,4 @@ SwitchArrowBrokenConstant.java:22:19: compiler.err.expected2: :, -> SwitchArrowBrokenConstant.java:25:20: compiler.err.expected2: :, -> SwitchArrowBrokenConstant.java:28:20: compiler.err.expected2: :, -> -- compiler.note.preview.filename: SwitchArrowBrokenConstant.java -- compiler.note.preview.recompile 8 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementArrow-old.out --- a/test/langtools/tools/javac/switchextra/SwitchStatementArrow-old.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementArrow-old.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,3 +1,3 @@ -SwitchStatementArrow.java:41:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules) -SwitchStatementArrow.java:42:21: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels) +SwitchStatementArrow.java:41:20: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.rules), 9, 14 +SwitchStatementArrow.java:42:21: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 14 2 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementArrow.java --- a/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java Tue Nov 12 10:09:40 2019 -0500 @@ -3,8 +3,8 @@ * @bug 8206986 * @summary Verify rule cases work properly. * @compile/fail/ref=SwitchStatementArrow-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchStatementArrow.java - * @compile --enable-preview -source ${jdk.version} SwitchStatementArrow.java - * @run main/othervm --enable-preview SwitchStatementArrow + * @compile SwitchStatementArrow.java + * @run main SwitchStatementArrow */ import java.util.Objects; diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementBroken.java --- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify that rule and ordinary cases cannot be mixed. - * @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementBroken.java + * @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics SwitchStatementBroken.java */ public class SwitchStatementBroken { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementBroken.out --- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,4 +1,2 @@ SwitchStatementBroken.java:15:13: compiler.err.switch.mixing.case.types -- compiler.note.preview.filename: SwitchStatementBroken.java -- compiler.note.preview.recompile 1 error diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java --- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify that not allowed types of statements cannot be used in rule case. - * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementBroken2.java + * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics SwitchStatementBroken2.java */ public class SwitchStatementBroken2 { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out --- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out Tue Nov 12 10:09:40 2019 -0500 @@ -3,6 +3,4 @@ SwitchStatementBroken2.java:19:23: compiler.err.switch.case.unexpected.statement SwitchStatementBroken2.java:22:27: compiler.err.variable.not.allowed SwitchStatementBroken2.java:23:24: compiler.err.switch.case.unexpected.statement -- compiler.note.preview.filename: SwitchStatementBroken2.java -- compiler.note.preview.recompile 5 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java --- a/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java Tue Nov 12 10:09:40 2019 -0500 @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8206986 * @summary Verify that scopes in rule cases are isolated. - * @compile/fail/ref=SwitchStatementScopesIsolated.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementScopesIsolated.java + * @compile/fail/ref=SwitchStatementScopesIsolated.out -XDrawDiagnostics SwitchStatementScopesIsolated.java */ public class SwitchStatementScopesIsolated { diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.out --- a/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.out Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.out Tue Nov 12 10:09:40 2019 -0500 @@ -1,5 +1,3 @@ SwitchStatementScopesIsolated.java:13:25: compiler.err.cant.resolve.location: kindname.variable, res, , , (compiler.misc.location: kindname.class, SwitchStatementScopesIsolated, null) SwitchStatementScopesIsolated.java:14:26: compiler.err.cant.resolve.location: kindname.variable, res, , , (compiler.misc.location: kindname.class, SwitchStatementScopesIsolated, null) -- compiler.note.preview.filename: SwitchStatementScopesIsolated.java -- compiler.note.preview.recompile 2 errors diff -r 74e44250e3a7 -r af9779f2d6bf test/langtools/tools/jdeps/listdeps/ListModuleDeps.java --- a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java Fri Nov 08 20:41:14 2019 -0500 +++ b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java Tue Nov 12 10:09:40 2019 -0500 @@ -92,7 +92,6 @@ public Object[][] jdkModules() { return new Object[][]{ {"jdk.compiler", new String[]{ - "java.base/jdk.internal", "java.base/jdk.internal.jmod", "java.base/jdk.internal.misc", "java.base/sun.reflect.annotation",