diff --git a/.hgtags b/.hgtags index 1ff45651554..930fac36912 100644 --- a/.hgtags +++ b/.hgtags @@ -608,4 +608,5 @@ f33197adda9ad82fdef46ac0f7dc0126204f35b2 jdk-15+2 d05fcdf25717d85e80a3a39a6b719458b22be5fe jdk-15+3 d54ce919da90dab361995bb4d87be9851f00537a jdk-14+30 bb0a7975b31ded63d594ee8dbfc4d4ead587f79b jdk-15+4 +decd3d2953b640f1043ee76953ff89238bff92e8 jdk-14+31 b97c1773ccafae4a8c16cc6aedb10b2a4f9a07ed jdk-15+5 diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 2fe10bb1700..f576933a88f 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -302,15 +302,21 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], if test "x$withval" = xexternal || test "x$withval" = xzipped; then AC_MSG_ERROR([AIX only supports the parameters 'none' and 'internal' for --with-native-debug-symbols]) fi + else + if test "x$OPENJDK_TARGET_OS" = xwindows; then + if test "x$withval" = xinternal; then + AC_MSG_ERROR([Windows does not support the parameter 'internal' for --with-native-debug-symbols]) + fi + fi fi ], [ - if test "x$OPENJDK_TARGET_OS" = xaix; then - # AIX doesn't support 'external' so use 'internal' as default - with_native_debug_symbols="internal" + if test "x$STATIC_BUILD" = xtrue; then + with_native_debug_symbols="none" else - if test "x$STATIC_BUILD" = xtrue; then - with_native_debug_symbols="none" + if test "x$OPENJDK_TARGET_OS" = xaix; then + # AIX doesn't support 'external' so use 'internal' as default + with_native_debug_symbols="internal" else with_native_debug_symbols="external" fi @@ -319,20 +325,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], NATIVE_DEBUG_SYMBOLS=$with_native_debug_symbols AC_MSG_RESULT([$NATIVE_DEBUG_SYMBOLS]) - if test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then - - if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then - if test "x$OBJCOPY" = x; then - # enabling of enable-debug-symbols and can't find objcopy - # this is an error - AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) - fi - fi - - COMPILE_WITH_DEBUG_SYMBOLS=true - COPY_DEBUG_SYMBOLS=true - ZIP_EXTERNAL_DEBUG_SYMBOLS=true - elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then + if test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then COMPILE_WITH_DEBUG_SYMBOLS=false COPY_DEBUG_SYMBOLS=false ZIP_EXTERNAL_DEBUG_SYMBOLS=false @@ -353,6 +346,19 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=true ZIP_EXTERNAL_DEBUG_SYMBOLS=false + elif test "x$NATIVE_DEBUG_SYMBOLS" = xzipped; then + + if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then + if test "x$OBJCOPY" = x; then + # enabling of enable-debug-symbols and can't find objcopy + # this is an error + AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) + fi + fi + + COMPILE_WITH_DEBUG_SYMBOLS=true + COPY_DEBUG_SYMBOLS=true + ZIP_EXTERNAL_DEBUG_SYMBOLS=true else AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped]) fi diff --git a/make/autoconf/toolchain_windows.m4 b/make/autoconf/toolchain_windows.m4 index 59052a09807..90482ab78f8 100644 --- a/make/autoconf/toolchain_windows.m4 +++ b/make/autoconf/toolchain_windows.m4 @@ -209,8 +209,8 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}" eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}" eval VS_TOOLSET_SUPPORTED="\${VS_TOOLSET_SUPPORTED_${VS_VERSION}}" - - VS_ENV_CMD="" + + VS_ENV_CMD="" # When using --with-tools-dir, assume it points to the correct and default # version of Visual Studio or that --with-toolchain-version was also set. diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index b1193df965c..1bd85efcf78 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1066,7 +1066,7 @@ var getJibProfilesDependencies = function (input, common) { // build_number: "b07", // file: "bundles/jcov-3_0.zip", organization: common.organization, - revision: "3.0-58-support+1.0", + revision: "3.0-59-support+1.0", ext: "zip", environment_name: "JCOV_HOME", }, diff --git a/make/hotspot/test/GtestImage.gmk b/make/hotspot/test/GtestImage.gmk index 660abe8becd..3f8381b3b50 100644 --- a/make/hotspot/test/GtestImage.gmk +++ b/make/hotspot/test/GtestImage.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # 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,12 +45,14 @@ ifeq ($(call isTargetOs, windows), true) FLATTEN := true, \ )) \ $(eval TARGETS += $$(COPY_GTEST_MSVCR_$v)) \ - $(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \ - SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \ - DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ - FILES := jvm.pdb gtestLauncher.pdb, \ - )) \ - $(eval TARGETS += $$(COPY_GTEST_PDB_$v)) \ + $(if $(call equals, $(COPY_DEBUG_SYMBOLS), true), \ + $(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \ + SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := jvm.pdb gtestLauncher.pdb, \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_PDB_$v)) \ + ) \ ) endif diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp index 45632635f44..33310d10985 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp @@ -35,8 +35,6 @@ #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" #include "code/compiledIC.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "nativeInst_aarch64.hpp" #include "oops/objArrayKlass.hpp" diff --git a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp index 4b6b1f3baf5..f57a67eedb9 100644 --- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp @@ -31,8 +31,6 @@ #include "c1/c1_ValueStack.hpp" #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "memory/universe.hpp" #include "nativeInst_arm.hpp" diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp index 0bfb7969030..788d4538c57 100644 --- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp @@ -33,8 +33,6 @@ #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" #include "gc/shared/collectedHeap.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" #include "memory/universe.hpp" #include "nativeInst_ppc.hpp" #include "oops/compressedOops.hpp" diff --git a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp index 42815aadebb..7fe43487325 100644 --- a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp +++ b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp @@ -294,7 +294,7 @@ void PatchingStub::align_patch_site(MacroAssembler* masm) { 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); NearLabel call_patch; @@ -331,7 +331,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { } #endif } 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 --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index 3c6e7e460ad..6f770cfc155 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -33,8 +33,6 @@ #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" #include "gc/shared/collectedHeap.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" #include "memory/universe.hpp" #include "nativeInst_s390.hpp" #include "oops/objArrayKlass.hpp" @@ -897,7 +895,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type, LIR_P bool needs_patching = (patch_code != lir_patch_none); if (addr->base()->type() == T_OBJECT) { - __ verify_oop(src); + __ verify_oop(src, FILE_AND_LINE); } PatchingStub* patch = NULL; @@ -972,7 +970,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type, LIR_P } else { __ z_lg(dest->as_register(), disp_value, disp_reg, src); } - __ verify_oop(dest->as_register()); + __ verify_oop(dest->as_register(), FILE_AND_LINE); break; } case T_FLOAT: @@ -1006,7 +1004,7 @@ void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) { if (dest->is_single_cpu()) { if (is_reference_type(type)) { __ mem2reg_opt(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()), true); - __ verify_oop(dest->as_register()); + __ verify_oop(dest->as_register(), FILE_AND_LINE); } else if (type == T_METADATA || type == T_ADDRESS) { __ mem2reg_opt(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()), true); } else { @@ -1033,7 +1031,7 @@ void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool po if (src->is_single_cpu()) { const Address dst = frame_map()->address_for_slot(dest->single_stack_ix()); if (is_reference_type(type)) { - __ verify_oop(src->as_register()); + __ verify_oop(src->as_register(), FILE_AND_LINE); __ reg2mem_opt(src->as_register(), dst, true); } else if (type == T_METADATA || type == T_ADDRESS) { __ reg2mem_opt(src->as_register(), dst, true); @@ -1079,7 +1077,7 @@ void LIR_Assembler::reg2reg(LIR_Opr from_reg, LIR_Opr to_reg) { ShouldNotReachHere(); } if (is_reference_type(to_reg->type())) { - __ verify_oop(to_reg->as_register()); + __ verify_oop(to_reg->as_register(), FILE_AND_LINE); } } @@ -1095,7 +1093,7 @@ void LIR_Assembler::reg2mem(LIR_Opr from, LIR_Opr dest_opr, BasicType type, bool needs_patching = (patch_code != lir_patch_none); if (addr->base()->is_oop_register()) { - __ verify_oop(dest); + __ verify_oop(dest, FILE_AND_LINE); } PatchingStub* patch = NULL; @@ -1130,7 +1128,7 @@ void LIR_Assembler::reg2mem(LIR_Opr from, LIR_Opr dest_opr, BasicType type, assert(disp_reg != Z_R0 || Immediate::is_simm20(disp_value), "should have set this up"); if (is_reference_type(type)) { - __ verify_oop(from->as_register()); + __ verify_oop(from->as_register(), FILE_AND_LINE); } bool short_disp = Immediate::is_uimm12(disp_value); @@ -2412,7 +2410,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { op->klass()->as_register(), *op->stub()->entry()); __ bind(*op->stub()->continuation()); - __ verify_oop(op->obj()->as_register()); + __ verify_oop(op->obj()->as_register(), FILE_AND_LINE); } void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) { @@ -2548,7 +2546,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L } assert(obj != k_RInfo, "must be different"); - __ verify_oop(obj); + __ verify_oop(obj, FILE_AND_LINE); // Get object class. // Not a safepoint as obj null check happens earlier. @@ -3009,7 +3007,7 @@ void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) { 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 || tmp1 != obj DEBUG_ONLY(|| true)) { __ z_ltgr(tmp1, obj); diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp index b2680769dcf..a357f79ffcc 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp @@ -40,7 +40,7 @@ void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) { Label ic_miss, ic_hit; - verify_oop(receiver); + verify_oop(receiver, FILE_AND_LINE); int klass_offset = oopDesc::klass_offset_in_bytes(); if (!ImplicitNullChecks || MacroAssembler::needs_explicit_null_check(klass_offset)) { @@ -83,7 +83,7 @@ void C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hd assert_different_registers(hdr, obj, disp_hdr); NearLabel done; - verify_oop(obj); + verify_oop(obj, FILE_AND_LINE); // Load object header. z_lg(hdr, Address(obj, hdr_offset)); @@ -158,7 +158,7 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_ // Load object. z_lg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes())); } - verify_oop(obj); + verify_oop(obj, FILE_AND_LINE); // Test if object header is pointing to the displaced header, and if so, restore // the displaced header in the object. If the object header is not pointing to // the displaced header, get the object header instead. @@ -278,7 +278,7 @@ void C1_MacroAssembler::initialize_object( // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id))); // } - verify_oop(obj); + verify_oop(obj, FILE_AND_LINE); } void C1_MacroAssembler::allocate_array( @@ -336,16 +336,15 @@ void C1_MacroAssembler::allocate_array( // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id))); // } - verify_oop(obj); + verify_oop(obj, FILE_AND_LINE); } #ifndef PRODUCT void C1_MacroAssembler::verify_stack_oop(int stack_offset) { - Unimplemented(); - // if (!VerifyOops) return; - // verify_oop_addr(Address(SP, stack_offset + STACK_BIAS)); + if (!VerifyOops) return; + verify_oop_addr(Address(Z_SP, stack_offset), FILE_AND_LINE); } void C1_MacroAssembler::verify_not_null_oop(Register r) { @@ -354,7 +353,7 @@ void C1_MacroAssembler::verify_not_null_oop(Register r) { compareU64_and_branch(r, (intptr_t)0, bcondNotEqual, not_null); stop("non-null oop required"); bind(not_null); - verify_oop(r); + verify_oop(r, FILE_AND_LINE); } void C1_MacroAssembler::invalidate_registers(Register preserve1, diff --git a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp index eeb934bfdaa..e7526d17c6d 100644 --- a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp +++ b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp @@ -339,7 +339,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { oop_maps->add_gc_map(call_offset, map); restore_live_registers_except_r2(sasm); - __ verify_oop(obj); + __ verify_oop(obj, FILE_AND_LINE); __ z_br(Z_R14); } break; @@ -405,7 +405,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { oop_maps->add_gc_map(call_offset, map); restore_live_registers_except_r2(sasm); - __ verify_oop(obj); + __ verify_oop(obj, FILE_AND_LINE); __ z_br(Z_R14); } break; @@ -423,7 +423,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { restore_live_registers_except_r2(sasm); // Z_R2,: new multi array - __ verify_oop(Z_R2); + __ verify_oop(Z_R2, FILE_AND_LINE); __ z_br(Z_R14); } break; diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp index d0bb0c0e41c..2bdfa801053 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp @@ -400,11 +400,11 @@ void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value __ z_tmll(tmp1, JNIHandles::weak_tag_mask); // Test for jweak tag. __ z_braz(Lnot_weak); - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); DecoratorSet decorators = IN_NATIVE | ON_PHANTOM_OOP_REF; g1_write_barrier_pre(masm, decorators, (const Address*)NULL, value, noreg, tmp1, tmp2, true); __ bind(Lnot_weak); - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); __ bind(Ldone); } diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp index f99100dcb6d..2fce9a4589b 100644 --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp @@ -108,7 +108,7 @@ void BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, __ z_nill(value, ~JNIHandles::weak_tag_mask); __ z_lg(value, 0, value); // Resolve (untagged) jobject. - __ verify_oop(value); + __ verify_oop(value, FILE_AND_LINE); __ bind(Ldone); } diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index 48af3cf0cf3..cbee39e3eae 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -1664,7 +1664,7 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, Address mdo_addr, compareU64_and_branch(obj, (intptr_t)0, Assembler::bcondEqual, null_seen); } - verify_oop(obj); + MacroAssembler::verify_oop(obj, FILE_AND_LINE); load_klass(klass, obj); // Klass seen before, nothing to do (regardless of unknown bit). @@ -2073,7 +2073,7 @@ void InterpreterMacroAssembler::access_local_int(Register index, Register dst) { } 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); } } // Inline assembly for: diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 49fb3492783..e774e0a9748 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -3587,7 +3587,7 @@ void MacroAssembler::get_vm_result(Register oop_result) { z_lg(oop_result, Address(Z_thread, JavaThread::vm_result_offset())); clear_mem(Address(Z_thread, JavaThread::vm_result_offset()), sizeof(void*)); - verify_oop(oop_result); + verify_oop(oop_result, FILE_AND_LINE); } void MacroAssembler::get_vm_result_2(Register result) { @@ -6813,26 +6813,94 @@ void MacroAssembler::verify_thread() { } } +// Save and restore functions: Exclude Z_R0. +void MacroAssembler::save_volatile_regs(Register dst, int offset, bool include_fp, bool include_flags) { + z_stmg(Z_R1, Z_R5, offset, dst); offset += 5 * BytesPerWord; + if (include_fp) { + z_std(Z_F0, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F1, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F2, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F3, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F4, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F5, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F6, Address(dst, offset)); offset += BytesPerWord; + z_std(Z_F7, Address(dst, offset)); offset += BytesPerWord; + } + if (include_flags) { + Label done; + z_mvi(Address(dst, offset), 2); // encoding: equal + z_bre(done); + z_mvi(Address(dst, offset), 4); // encoding: higher + z_brh(done); + z_mvi(Address(dst, offset), 1); // encoding: lower + bind(done); + } +} +void MacroAssembler::restore_volatile_regs(Register src, int offset, bool include_fp, bool include_flags) { + z_lmg(Z_R1, Z_R5, offset, src); offset += 5 * BytesPerWord; + if (include_fp) { + z_ld(Z_F0, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F1, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F2, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F3, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F4, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F5, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F6, Address(src, offset)); offset += BytesPerWord; + z_ld(Z_F7, Address(src, offset)); offset += BytesPerWord; + } + if (include_flags) { + z_cli(Address(src, offset), 2); // see encoding above + } +} + // Plausibility check for oops. void MacroAssembler::verify_oop(Register oop, const char* msg) { if (!VerifyOops) return; BLOCK_COMMENT("verify_oop {"); - Register tmp = Z_R0; - unsigned int nbytes_save = 5*BytesPerWord; - address entry = StubRoutines::verify_oop_subroutine_entry_address(); + unsigned int nbytes_save = (5 + 8 + 1) * BytesPerWord; + address entry_addr = StubRoutines::verify_oop_subroutine_entry_address(); save_return_pc(); - push_frame_abi160(nbytes_save); - z_stmg(Z_R1, Z_R5, frame::z_abi_160_size, Z_SP); - z_lgr(Z_ARG2, oop); - load_const(Z_ARG1, (address) msg); - load_const(Z_R1, entry); + // Push frame, but preserve flags + z_lgr(Z_R0, Z_SP); + z_lay(Z_SP, -((int64_t)nbytes_save + frame::z_abi_160_size), Z_SP); + z_stg(Z_R0, _z_abi(callers_sp), Z_SP); + + save_volatile_regs(Z_SP, frame::z_abi_160_size, true, true); + + lgr_if_needed(Z_ARG2, oop); + load_const_optimized(Z_ARG1, (address)msg); + load_const_optimized(Z_R1, entry_addr); z_lg(Z_R1, 0, Z_R1); call_c(Z_R1); - z_lmg(Z_R1, Z_R5, frame::z_abi_160_size, Z_SP); + restore_volatile_regs(Z_SP, frame::z_abi_160_size, true, true); + pop_frame(); + restore_return_pc(); + + BLOCK_COMMENT("} verify_oop "); +} + +void MacroAssembler::verify_oop_addr(Address addr, const char* msg) { + if (!VerifyOops) return; + + BLOCK_COMMENT("verify_oop {"); + unsigned int nbytes_save = (5 + 8) * BytesPerWord; + address entry_addr = StubRoutines::verify_oop_subroutine_entry_address(); + + save_return_pc(); + unsigned int frame_size = push_frame_abi160(nbytes_save); // kills Z_R0 + save_volatile_regs(Z_SP, frame::z_abi_160_size, true, false); + + z_lg(Z_ARG2, addr.plus_disp(frame_size)); + load_const_optimized(Z_ARG1, (address)msg); + load_const_optimized(Z_R1, entry_addr); + z_lg(Z_R1, 0, Z_R1); + call_c(Z_R1); + + restore_volatile_regs(Z_SP, frame::z_abi_160_size, true, false); pop_frame(); restore_return_pc(); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 8600c78a608..fb20b51ed29 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -973,8 +973,15 @@ class MacroAssembler: public Assembler { // Verify Z_thread contents. void verify_thread(); + // Save and restore functions: Exclude Z_R0. + void save_volatile_regs( Register dst, int offset, bool include_fp, bool include_flags); + void restore_volatile_regs(Register src, int offset, bool include_fp, bool include_flags); + // Only if +VerifyOops. + // Kills Z_R0. void verify_oop(Register reg, const char* s = "broken oop"); + // Kills Z_R0, condition code. + void verify_oop_addr(Address addr, const char* msg = "contains broken oop"); // TODO: verify_method and klass metadata (compare against vptr?). void _verify_method_ptr(Register reg, const char * msg, const char * file, int line) {} diff --git a/src/hotspot/cpu/s390/methodHandles_s390.cpp b/src/hotspot/cpu/s390/methodHandles_s390.cpp index bb456117a1c..ca93ef3f136 100644 --- a/src/hotspot/cpu/s390/methodHandles_s390.cpp +++ b/src/hotspot/cpu/s390/methodHandles_s390.cpp @@ -85,7 +85,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm, BLOCK_COMMENT("verify_klass {"); - __ verify_oop(obj_reg); + __ verify_oop(obj_reg, FILE_AND_LINE); __ compareU64_and_branch(obj_reg, (intptr_t)0L, Assembler::bcondEqual, L_bad); __ load_klass(temp_reg, obj_reg); // klass_addr is a klass in allstatic SystemDictionaryHandles. Can't get GCed. @@ -194,22 +194,22 @@ void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm, BLOCK_COMMENT("jump_to_lambda_form {"); // Load the invoker, as MH -> MH.form -> LF.vmentry - __ verify_oop(recv); + __ verify_oop(recv, FILE_AND_LINE); __ load_heap_oop(method_temp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())), noreg, noreg, IS_NOT_NULL); - __ verify_oop(method_temp); + __ verify_oop(method_temp, FILE_AND_LINE); __ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())), noreg, noreg, IS_NOT_NULL); - __ verify_oop(method_temp); + __ verify_oop(method_temp, FILE_AND_LINE); __ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes())), noreg, noreg, IS_NOT_NULL); - __ verify_oop(method_temp); + __ verify_oop(method_temp, FILE_AND_LINE); __ z_lg(method_temp, Address(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()))); @@ -385,7 +385,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, 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(receiver_reg); diff --git a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp index dae5d46a8cc..54beb8263ea 100644 --- a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp +++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp @@ -892,9 +892,9 @@ static void verify_oop_args(MacroAssembler *masm, if (r->is_stack()) { __ z_lg(Z_R0_scratch, Address(Z_SP, r->reg2stack() * VMRegImpl::stack_slot_size + wordSize)); - __ verify_oop(Z_R0_scratch); + __ verify_oop(Z_R0_scratch, FILE_AND_LINE); } else { - __ verify_oop(r->as_Register()); + __ verify_oop(r->as_Register(), FILE_AND_LINE); } } } @@ -2686,7 +2686,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm __ z_ltgr(Z_ARG1, Z_ARG1); __ z_bre(ic_miss); } - __ verify_oop(Z_ARG1); + __ verify_oop(Z_ARG1, FILE_AND_LINE); // Check ic: object class <-> cached class // Compress cached class for comparison. That's more efficient. @@ -2955,7 +2955,7 @@ void SharedRuntime::generate_deopt_blob() { #ifdef ASSERT // verify that there is really an exception oop in JavaThread __ z_lg(Z_ARG1, Address(Z_thread, JavaThread::exception_oop_offset())); - __ verify_oop(Z_ARG1); + __ MacroAssembler::verify_oop(Z_ARG1, FILE_AND_LINE); // verify that there is no pending exception __ asm_assert_mem8_is_zero(in_bytes(Thread::pending_exception_offset()), Z_thread, diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index 419f6832ad5..4a2e28b9569 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -667,6 +667,17 @@ class StubGenerator: public StubCodeGenerator { return start; } +#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, oopDesc* o) { + if (!oopDesc::is_oop_or_null(o)) { + fatal("%s. oop: " PTR_FORMAT, message, p2i(o)); + } + ++ StubRoutines::_verify_oop_count; + } +#endif + // Return address of code to be called from code generated by // MacroAssembler::verify_oop. // @@ -679,6 +690,11 @@ class StubGenerator: public StubCodeGenerator { // StubCodeMark mark(this, "StubRoutines", "verify_oop_stub"); address start = 0; + +#if !defined(PRODUCT) + start = CAST_FROM_FN_PTR(address, verify_oop_helper); +#endif + return start; } diff --git a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp index 0fa7e059fba..e9d2dc5bc99 100644 --- a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp +++ b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp @@ -31,8 +31,6 @@ #include "c1/c1_ValueStack.hpp" #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "memory/universe.hpp" #include "nativeInst_sparc.hpp" diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index 4fb9dd1bb27..b58c5a2bd24 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -32,8 +32,6 @@ #include "c1/c1_ValueStack.hpp" #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "nativeInst_x86.hpp" #include "oops/objArrayKlass.hpp" diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp index 993addd3a35..97609ef0e2a 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp @@ -30,6 +30,8 @@ #include "code/nativeInst.hpp" #include "code/vtableStubs.hpp" #include "gc/shared/gcLocker.hpp" +#include "gc/shared/barrierSet.hpp" +#include "gc/shared/barrierSetAssembler.hpp" #include "interpreter/interpreter.hpp" #include "logging/log.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 67e176fcd2d..05f1d61f77a 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2225,7 +2225,7 @@ void LIRGenerator::do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegi int lng = x->length(); for (int i = 0; i < lng; i++) { - SwitchRange* one_range = x->at(i); + C1SwitchRange* one_range = x->at(i); int low_key = one_range->low_key(); int high_key = one_range->high_key(); BlockBegin* dest = one_range->sux(); @@ -2257,7 +2257,7 @@ SwitchRangeArray* LIRGenerator::create_lookup_ranges(TableSwitch* x) { BlockBegin* sux = x->sux_at(0); int key = x->lo_key(); BlockBegin* default_sux = x->default_sux(); - SwitchRange* range = new SwitchRange(key, sux); + C1SwitchRange* range = new C1SwitchRange(key, sux); for (int i = 0; i < len; i++, key++) { BlockBegin* new_sux = x->sux_at(i); if (sux == new_sux) { @@ -2268,7 +2268,7 @@ SwitchRangeArray* LIRGenerator::create_lookup_ranges(TableSwitch* x) { if (sux != default_sux) { res->append(range); } - range = new SwitchRange(key, new_sux); + range = new C1SwitchRange(key, new_sux); } sux = new_sux; } @@ -2286,7 +2286,7 @@ SwitchRangeArray* LIRGenerator::create_lookup_ranges(LookupSwitch* x) { BlockBegin* default_sux = x->default_sux(); int key = x->key_at(0); BlockBegin* sux = x->sux_at(0); - SwitchRange* range = new SwitchRange(key, sux); + C1SwitchRange* range = new C1SwitchRange(key, sux); for (int i = 1; i < len; i++) { int new_key = x->key_at(i); BlockBegin* new_sux = x->sux_at(i); @@ -2298,7 +2298,7 @@ SwitchRangeArray* LIRGenerator::create_lookup_ranges(LookupSwitch* x) { if (range->sux() != default_sux) { res->append(range); } - range = new SwitchRange(new_key, new_sux); + range = new C1SwitchRange(new_key, new_sux); } key = new_key; sux = new_sux; diff --git a/src/hotspot/share/c1/c1_LIRGenerator.hpp b/src/hotspot/share/c1/c1_LIRGenerator.hpp index 5e8f71a13c3..9908d916ef1 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.hpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,18 +42,17 @@ class BarrierSetC1; class LIRGenerator; class LIREmitter; class Invoke; -class SwitchRange; class LIRItem; typedef GrowableArray LIRItemList; -class SwitchRange: public CompilationResourceObj { +class C1SwitchRange: public CompilationResourceObj { private: int _low_key; int _high_key; BlockBegin* _sux; public: - SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {} + C1SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {} void set_high_key(int key) { _high_key = key; } int high_key() const { return _high_key; } @@ -61,8 +60,8 @@ class SwitchRange: public CompilationResourceObj { BlockBegin* sux() const { return _sux; } }; -typedef GrowableArray SwitchRangeArray; -typedef GrowableArray SwitchRangeList; +typedef GrowableArray SwitchRangeArray; +typedef GrowableArray SwitchRangeList; class ResolveNode; diff --git a/src/hotspot/share/code/debugInfo.cpp b/src/hotspot/share/code/debugInfo.cpp index 245774ee633..ebb5dd6258f 100644 --- a/src/hotspot/share/code/debugInfo.cpp +++ b/src/hotspot/share/code/debugInfo.cpp @@ -51,7 +51,15 @@ void DebugInfoWriteStream::write_metadata(Metadata* h) { } oop DebugInfoReadStream::read_oop() { - oop o = code()->oop_at(read_int()); + nmethod* nm = const_cast(code())->as_nmethod_or_null(); + oop o; + if (nm != NULL) { + // Despite these oops being found inside nmethods that are on-stack, + // they are not kept alive by all GCs (e.g. G1 and Shenandoah). + o = nm->oop_at_phantom(read_int()); + } else { + o = code()->oop_at(read_int()); + } assert(oopDesc::is_oop_or_null(o), "oop only"); return o; } diff --git a/src/hotspot/share/gc/g1/g1Allocator.cpp b/src/hotspot/share/gc/g1/g1Allocator.cpp index 787f3a3ace2..cb172b5f5b5 100644 --- a/src/hotspot/share/gc/g1/g1Allocator.cpp +++ b/src/hotspot/share/gc/g1/g1Allocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -412,8 +412,7 @@ size_t G1PLABAllocator::undo_waste() const { } bool G1ArchiveAllocator::_archive_check_enabled = false; -G1ArchiveRegionMap G1ArchiveAllocator::_closed_archive_region_map; -G1ArchiveRegionMap G1ArchiveAllocator::_open_archive_region_map; +G1ArchiveRegionMap G1ArchiveAllocator::_archive_region_map; G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h, bool open) { // Create the archive allocator, and also enable archive object checking diff --git a/src/hotspot/share/gc/g1/g1Allocator.hpp b/src/hotspot/share/gc/g1/g1Allocator.hpp index 69218e1596f..d4b675ea725 100644 --- a/src/hotspot/share/gc/g1/g1Allocator.hpp +++ b/src/hotspot/share/gc/g1/g1Allocator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -203,12 +203,17 @@ public: void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz, uint node_index); }; -// G1ArchiveRegionMap is a boolean array used to mark G1 regions as +// G1ArchiveRegionMap is an array used to mark G1 regions as // archive regions. This allows a quick check for whether an object // should not be marked because it is in an archive region. -class G1ArchiveRegionMap : public G1BiasedMappedArray { +class G1ArchiveRegionMap : public G1BiasedMappedArray { +public: + static const uint8_t NoArchive = 0; + static const uint8_t OpenArchive = 1; + static const uint8_t ClosedArchive = 2; + protected: - bool default_value() const { return false; } + uint8_t default_value() const { return NoArchive; } }; // G1ArchiveAllocator is used to allocate memory in archive @@ -290,7 +295,7 @@ public: // Mark regions containing the specified address range as archive/non-archive. static inline void set_range_archive(MemRegion range, bool open); - static inline void clear_range_archive(MemRegion range, bool open); + static inline void clear_range_archive(MemRegion range); // Check if the object is in closed archive static inline bool is_closed_archive_object(oop object); @@ -301,8 +306,7 @@ public: private: static bool _archive_check_enabled; - static G1ArchiveRegionMap _closed_archive_region_map; - static G1ArchiveRegionMap _open_archive_region_map; + static G1ArchiveRegionMap _archive_region_map; // Check if an object is in a closed archive region using the _closed_archive_region_map. static inline bool in_closed_archive_range(oop object); diff --git a/src/hotspot/share/gc/g1/g1Allocator.inline.hpp b/src/hotspot/share/gc/g1/g1Allocator.inline.hpp index 0b0f7a98b45..8f9d9051cf7 100644 --- a/src/hotspot/share/gc/g1/g1Allocator.inline.hpp +++ b/src/hotspot/share/gc/g1/g1Allocator.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,12 +131,9 @@ inline void G1ArchiveAllocator::enable_archive_object_check() { _archive_check_enabled = true; size_t length = G1CollectedHeap::heap()->max_reserved_capacity(); - _closed_archive_region_map.initialize(G1CollectedHeap::heap()->base(), - G1CollectedHeap::heap()->base() + length, - HeapRegion::GrainBytes); - _open_archive_region_map.initialize(G1CollectedHeap::heap()->base(), - G1CollectedHeap::heap()->base() + length, - HeapRegion::GrainBytes); + _archive_region_map.initialize(G1CollectedHeap::heap()->base(), + G1CollectedHeap::heap()->base() + length, + HeapRegion::GrainBytes); } // Set the regions containing the specified address range as archive. @@ -146,36 +143,26 @@ inline void G1ArchiveAllocator::set_range_archive(MemRegion range, bool open) { open ? "open" : "closed", p2i(range.start()), p2i(range.last())); - if (open) { - _open_archive_region_map.set_by_address(range, true); - } else { - _closed_archive_region_map.set_by_address(range, true); - } + uint8_t const value = open ? G1ArchiveRegionMap::OpenArchive : G1ArchiveRegionMap::ClosedArchive; + _archive_region_map.set_by_address(range, value); } // Clear the archive regions map containing the specified address range. -inline void G1ArchiveAllocator::clear_range_archive(MemRegion range, bool open) { +inline void G1ArchiveAllocator::clear_range_archive(MemRegion range) { assert(_archive_check_enabled, "archive range check not enabled"); - log_info(gc, cds)("Clear %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]", - open ? "open" : "closed", + log_info(gc, cds)("Clear archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]", p2i(range.start()), p2i(range.last())); - if (open) { - _open_archive_region_map.set_by_address(range, false); - } else { - _closed_archive_region_map.set_by_address(range, false); - } + _archive_region_map.set_by_address(range, G1ArchiveRegionMap::NoArchive); } // Check if an object is in a closed archive region using the _archive_region_map. inline bool G1ArchiveAllocator::in_closed_archive_range(oop object) { - // This is the out-of-line part of is_closed_archive_object test, done separately - // to avoid additional performance impact when the check is not enabled. - return _closed_archive_region_map.get_by_address((HeapWord*)object); + return _archive_region_map.get_by_address((HeapWord*)object) == G1ArchiveRegionMap::ClosedArchive; } inline bool G1ArchiveAllocator::in_open_archive_range(oop object) { - return _open_archive_region_map.get_by_address((HeapWord*)object); + return _archive_region_map.get_by_address((HeapWord*)object) == G1ArchiveRegionMap::OpenArchive; } // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range @@ -193,8 +180,8 @@ inline bool G1ArchiveAllocator::is_open_archive_object(oop object) { } inline bool G1ArchiveAllocator::is_archived_object(oop object) { - return (archive_check_enabled() && (in_closed_archive_range(object) || - in_open_archive_range(object))); + return archive_check_enabled() && + (_archive_region_map.get_by_address((HeapWord*)object) != G1ArchiveRegionMap::NoArchive); } #endif // SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 988d3581e56..a03e0a570ae 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -766,7 +766,7 @@ inline HeapWord* G1CollectedHeap::attempt_allocation(size_t min_word_size, return result; } -void G1CollectedHeap::dealloc_archive_regions(MemRegion* ranges, size_t count, bool is_open) { +void G1CollectedHeap::dealloc_archive_regions(MemRegion* ranges, size_t count) { assert(!is_init_completed(), "Expect to be called at JVM init time"); assert(ranges != NULL, "MemRegion array NULL"); assert(count != 0, "No MemRegions provided"); @@ -828,7 +828,7 @@ void G1CollectedHeap::dealloc_archive_regions(MemRegion* ranges, size_t count, b } // Notify mark-sweep that this is no longer an archive range. - G1ArchiveAllocator::clear_range_archive(ranges[i], is_open); + G1ArchiveAllocator::clear_range_archive(ranges[i]); } if (uncommitted_regions != 0) { @@ -2151,6 +2151,13 @@ bool G1CollectedHeap::try_collect_concurrently(GCCause::Cause cause, return op.gc_succeeded(); } + // If VMOp skipped initiating concurrent marking cycle because + // we're terminating, then we're done. + if (op.terminating()) { + LOG_COLLECT_CONCURRENTLY(cause, "skipped: terminating"); + return false; + } + // Lock to get consistent set of values. uint old_marking_started_after; uint old_marking_completed_after; diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index fa44634cab8..10f82f3f2d9 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -723,7 +723,7 @@ public: // which had been allocated by alloc_archive_regions. This should be called // rather than fill_archive_regions at JVM init time if the archive file // mapping failed, with the same non-overlapping and sorted MemRegion array. - void dealloc_archive_regions(MemRegion* range, size_t count, bool is_open); + void dealloc_archive_regions(MemRegion* range, size_t count); oop materialize_archived_object(oop obj); diff --git a/src/hotspot/share/gc/g1/g1VMOperations.cpp b/src/hotspot/share/gc/g1/g1VMOperations.cpp index d1060ca7547..449a3a05b94 100644 --- a/src/hotspot/share/gc/g1/g1VMOperations.cpp +++ b/src/hotspot/share/gc/g1/g1VMOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,7 @@ VM_G1TryInitiateConcMark::VM_G1TryInitiateConcMark(uint gc_count_before, _target_pause_time_ms(target_pause_time_ms), _transient_failure(false), _cycle_already_in_progress(false), + _terminating(false), _gc_succeeded(false) {} @@ -66,7 +67,17 @@ void VM_G1TryInitiateConcMark::doit() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); GCCauseSetter x(g1h, _gc_cause); - if (!g1h->policy()->force_initial_mark_if_outside_cycle(_gc_cause)) { + + // Record for handling by caller. + _terminating = g1h->_cm_thread->should_terminate(); + + if (_terminating && GCCause::is_user_requested_gc(_gc_cause)) { + // When terminating, the request to initiate a concurrent cycle will be + // ignored by do_collection_pause_at_safepoint; instead it will just do + // a young-only or mixed GC (depending on phase). For a user request + // there's no point in even doing that much, so done. For some non-user + // requests the alternative GC might still be needed. + } else if (!g1h->policy()->force_initial_mark_if_outside_cycle(_gc_cause)) { // Failure to force the next GC pause to be an initial mark indicates // there is already a concurrent marking cycle in progress. Set flag // to notify the caller and return immediately. diff --git a/src/hotspot/share/gc/g1/g1VMOperations.hpp b/src/hotspot/share/gc/g1/g1VMOperations.hpp index 99c2055939e..efb01d67aee 100644 --- a/src/hotspot/share/gc/g1/g1VMOperations.hpp +++ b/src/hotspot/share/gc/g1/g1VMOperations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,7 @@ class VM_G1TryInitiateConcMark : public VM_GC_Operation { double _target_pause_time_ms; bool _transient_failure; bool _cycle_already_in_progress; + bool _terminating; bool _gc_succeeded; public: @@ -63,6 +64,7 @@ public: virtual void doit(); bool transient_failure() const { return _transient_failure; } bool cycle_already_in_progress() const { return _cycle_already_in_progress; } + bool terminating() const { return _terminating; } bool gc_succeeded() const { return _gc_succeeded; } }; diff --git a/src/hotspot/share/gc/shared/gcTrace.cpp b/src/hotspot/share/gc/shared/gcTrace.cpp index 03a04b2405a..aeddbee841c 100644 --- a/src/hotspot/share/gc/shared/gcTrace.cpp +++ b/src/hotspot/share/gc/shared/gcTrace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,7 +100,7 @@ void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) { KlassInfoTable cit(false); if (!cit.allocation_failed()) { - HeapInspection hi(false, false, false, NULL); + HeapInspection hi; hi.populate_table(&cit, is_alive_cl); ObjectCountEventSenderClosure event_sender(cit.size_of_instances_in_words(), Ticks::now()); cit.iterate(&event_sender); diff --git a/src/hotspot/share/gc/shared/gcVMOperations.cpp b/src/hotspot/share/gc/shared/gcVMOperations.cpp index 82ecd33bbad..ab9f509eb04 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.cpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,8 +151,7 @@ void VM_GC_HeapInspection::doit() { log_warning(gc)("GC locker is held; pre-dump GC was skipped"); } } - HeapInspection inspect(_csv_format, _print_help, _print_class_stats, - _columns); + HeapInspection inspect; inspect.heap_inspection(_out); } diff --git a/src/hotspot/share/gc/shared/gcVMOperations.hpp b/src/hotspot/share/gc/shared/gcVMOperations.hpp index c96e69b7c0e..4b91c7cf51e 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.hpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,32 +125,17 @@ class VM_GC_HeapInspection: public VM_GC_Operation { private: outputStream* _out; bool _full_gc; - bool _csv_format; // "comma separated values" format for spreadsheet. - bool _print_help; - bool _print_class_stats; - const char* _columns; public: VM_GC_HeapInspection(outputStream* out, bool request_full_gc) : VM_GC_Operation(0 /* total collections, dummy, ignored */, GCCause::_heap_inspection /* GC Cause */, 0 /* total full collections, dummy, ignored */, - request_full_gc) { - _out = out; - _full_gc = request_full_gc; - _csv_format = false; - _print_help = false; - _print_class_stats = false; - _columns = NULL; - } + request_full_gc), _out(out), _full_gc(request_full_gc) {} ~VM_GC_HeapInspection() {} virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; } virtual bool skip_operation() const; virtual void doit(); - void set_csv_format(bool value) {_csv_format = value;} - void set_print_help(bool value) {_print_help = value;} - void set_print_class_stats(bool value) {_print_class_stats = value;} - void set_columns(const char* value) {_columns = value;} protected: bool collect(); }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp index 0aa5087a92e..e950e08a44c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp @@ -223,7 +223,9 @@ public: ShenandoahReentrantLocker locker(nm_data->lock()); // Heal oops and disarm - ShenandoahNMethod::heal_nmethod(nm); + if (_heap->is_evacuation_in_progress()) { + ShenandoahNMethod::heal_nmethod(nm); + } ShenandoahNMethod::disarm_nmethod(nm); // Clear compiled ICs and exception caches diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index df6101a8c7b..7bd982ad21c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1715,7 +1715,6 @@ void ShenandoahEvacUpdateCleanupOopStorageRootsClosure::do_oop(oop* p) { if (obj == old) { _dead_counter ++; } - assert(*p == NULL, "Must be"); } else if (_evac_in_progress && _heap->in_collection_set(obj)) { oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj); if (resolved == obj) { @@ -2805,7 +2804,7 @@ void ShenandoahHeap::entry_init_traversal() { ShenandoahGCPhase total_phase(ShenandoahPhaseTimings::total_pause); ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_traversal_gc); - static const char* msg = "Pause Init Traversal"; + static const char* msg = init_traversal_event_message(); GCTraceTime(Info, gc) time(msg, gc_timer()); EventMark em("%s", msg); @@ -2820,7 +2819,7 @@ void ShenandoahHeap::entry_final_traversal() { ShenandoahGCPhase total_phase(ShenandoahPhaseTimings::total_pause); ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_traversal_gc); - static const char* msg = "Pause Final Traversal"; + static const char* msg = final_traversal_event_message(); GCTraceTime(Info, gc) time(msg, gc_timer()); EventMark em("%s", msg); @@ -2972,7 +2971,7 @@ void ShenandoahHeap::entry_preclean() { } void ShenandoahHeap::entry_traversal() { - static const char* msg = "Concurrent traversal"; + static const char* msg = conc_traversal_event_message(); GCTraceTime(Info, gc) time(msg, NULL, GCCause::_no_gc, true); EventMark em("%s", msg); @@ -3141,6 +3140,51 @@ const char* ShenandoahHeap::conc_mark_event_message() const { } } +const char* ShenandoahHeap::init_traversal_event_message() const { + bool proc_refs = process_references(); + bool unload_cls = unload_classes(); + + if (proc_refs && unload_cls) { + return "Pause Init Traversal (process weakrefs) (unload classes)"; + } else if (proc_refs) { + return "Pause Init Traversal (process weakrefs)"; + } else if (unload_cls) { + return "Pause Init Traversal (unload classes)"; + } else { + return "Pause Init Traversal"; + } +} + +const char* ShenandoahHeap::final_traversal_event_message() const { + bool proc_refs = process_references(); + bool unload_cls = unload_classes(); + + if (proc_refs && unload_cls) { + return "Pause Final Traversal (process weakrefs) (unload classes)"; + } else if (proc_refs) { + return "Pause Final Traversal (process weakrefs)"; + } else if (unload_cls) { + return "Pause Final Traversal (unload classes)"; + } else { + return "Pause Final Traversal"; + } +} + +const char* ShenandoahHeap::conc_traversal_event_message() const { + bool proc_refs = process_references(); + bool unload_cls = unload_classes(); + + if (proc_refs && unload_cls) { + return "Concurrent Traversal (process weakrefs) (unload classes)"; + } else if (proc_refs) { + return "Concurrent Traversal (process weakrefs)"; + } else if (unload_cls) { + return "Concurrent Traversal (unload classes)"; + } else { + return "Concurrent Traversal"; + } +} + const char* ShenandoahHeap::degen_event_message(ShenandoahDegenPoint point) const { switch (point) { case _degenerated_unset: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 7272d8d728a..008e3c22c0f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -438,6 +438,9 @@ private: const char* init_mark_event_message() const; const char* final_mark_event_message() const; const char* conc_mark_event_message() const; + const char* init_traversal_event_message() const; + const char* final_traversal_event_message() const; + const char* conc_traversal_event_message() const; const char* degen_event_message(ShenandoahDegenPoint point) const; // ---------- GC subsystems diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp index ad899ea0c4f..98abe87d84a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2015, 2020, Red Hat, Inc. All rights reserved. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as @@ -226,6 +226,7 @@ private: ShenandoahThreadRoots _thread_roots; ShenandoahCodeCacheRoots _code_roots; ShenandoahVMRoots _vm_roots; + ShenandoahStringDedupRoots _dedup_roots; ShenandoahClassLoaderDataRoots _cld_roots; public: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp index 67669c16194..5be19fd5cdb 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as @@ -250,6 +250,9 @@ void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops, CLDC if (code != NULL && !ShenandoahConcurrentScanCodeRoots) { _code_roots.code_blobs_do(code, worker_id); } + + AlwaysTrueClosure always_true; + _dedup_roots.oops_do(&always_true, oops, worker_id); } template diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp index ffeedfa7b16..8dad30cb569 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as @@ -193,9 +193,6 @@ public: } else { _rp->roots_do(worker_id, &roots_cl, &cld_cl, &code_cl); } - - AlwaysTrueClosure is_alive; - _dedup_roots.oops_do(&is_alive, &roots_cl, worker_id); } } }; diff --git a/src/hotspot/share/jfr/metadata/metadata.xml b/src/hotspot/share/jfr/metadata/metadata.xml index cd9705f71c7..f69330dea2e 100644 --- a/src/hotspot/share/jfr/metadata/metadata.xml +++ b/src/hotspot/share/jfr/metadata/metadata.xml @@ -1,7 +1,7 @@ }. - * - * @param name the value for the {@code id} or {@code name} attribute - * @return a content tree for the anchor - */ - public Content createAnchor(String name) { - return createAnchor(getName(name), null); - } - - /** - * Creates an anchor of the form {@code }. - * - * @param sectionName the value for the {@code id} or {@code name} attribute - * @return a content tree for the anchor - */ - public Content createAnchor(SectionName sectionName) { - return createAnchor(sectionName.getName(), null); - } - - /** - * Creates an anchor of the form {@code }. - * - * @param sectionName the first part of the value for the {@code id} or {@code name} attribute - * @param name the second part of the value for the {@code id} or {@code name} attribute - * @return a content tree for the anchor - */ - public Content createAnchor(SectionName sectionName, String name) { - return createAnchor(sectionName.getName() + getName(name), null); - } - - /** - * Creates an anchor of the form {@code content}. - * - * @param name the value for the {@code id} or {@code name} attribute - * @param content the content that should be added to the anchor, - * or null, to use an empty comment - * @return a content tree for the marker anchor - */ - public Content createAnchor(String name, Content content) { - return HtmlTree.A_ID(getName(name), (content == null ? EMPTY_COMMENT : content)); - } - - private static final Content EMPTY_COMMENT = new Comment(" "); - /** * Creates a link of the form {@code label}. * diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java index bb4dbea749b..e3ef55e916e 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java @@ -24,12 +24,9 @@ */ package jdk.javadoc.internal.doclets.formats.html.markup; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.SortedSet; @@ -79,12 +76,13 @@ public class Navigation { private boolean displaySummaryModulesLink; private boolean displaySummaryPackagesLink; private boolean displaySummaryServicesLink; - private final Map> topBottomNavContents; private Content userHeader; private Content userFooter; private final String rowListTitle; private final Content searchLabel; + private static final Content EMPTY_COMMENT = new Comment(" "); + public enum PageMode { ALLCLASSES, ALLPACKAGES, @@ -141,41 +139,8 @@ public class Navigation { this.path = path; this.pathToRoot = path.parent().invert(); this.links = new Links(path); - this.topBottomNavContents = new HashMap<>(); this.rowListTitle = configuration.getResources().getText("doclet.Navigation"); this.searchLabel = contents.getContent("doclet.search"); - populateNavContents(Position.TOP); - populateNavContents(Position.BOTTOM); - } - - /** - * Populate the navigation contents for top and bottom navigation - * - * @param position the position of the navigation bar on the page - */ - private void populateNavContents(Position position) { - Deque queue = new ArrayDeque<>(); - Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links"); - switch (position) { - case TOP: - queue.addLast(links.createAnchor(SectionName.NAVBAR_TOP)); - queue.addLast(links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks, - skipNavLinks.toString(), "")); - queue.addLast(links.createAnchor(SectionName.NAVBAR_TOP_FIRSTROW)); - queue.addLast(links.createAnchor(SectionName.SKIP_NAVBAR_TOP)); - topBottomNavContents.put(position, queue); - break; - case BOTTOM: - queue.addLast(links.createAnchor(SectionName.NAVBAR_BOTTOM)); - queue.addLast(links.createLink(SectionName.SKIP_NAVBAR_BOTTOM, skipNavLinks, - skipNavLinks.toString(), "")); - queue.addLast(links.createAnchor(SectionName.NAVBAR_BOTTOM_FIRSTROW)); - queue.addLast(links.createAnchor(SectionName.SKIP_NAVBAR_BOTTOM)); - topBottomNavContents.put(position, queue); - break; - default: - break; - } } public Navigation setNavLinkModule(Content navLinkModule) { @@ -946,23 +911,27 @@ public class Navigation { if (configuration.nonavbar) { return new ContentBuilder(); } - Deque queue; Content tree = HtmlTree.NAV(); HtmlTree navDiv = new HtmlTree(HtmlTag.DIV); + Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links"); if (top) { - queue = topBottomNavContents.get(Position.TOP); tree.add(Position.TOP.startOfNav()); - navDiv.setStyle(HtmlStyle.topNav); + navDiv.setStyle(HtmlStyle.topNav) + .setId(SectionName.NAVBAR_TOP.getName()) + .add(HtmlTree.DIV(HtmlStyle.skipNav, + links.createLink(SectionName.SKIP_NAVBAR_TOP, skipNavLinks, + skipNavLinks.toString(), ""))); } else { - queue = topBottomNavContents.get(Position.BOTTOM); tree.add(Position.BOTTOM.startOfNav()); - navDiv.setStyle(HtmlStyle.bottomNav); + navDiv.setStyle(HtmlStyle.bottomNav) + .setId(SectionName.NAVBAR_BOTTOM.getName()) + .add(HtmlTree.DIV(HtmlStyle.skipNav, + links.createLink(SectionName.SKIP_NAVBAR_BOTTOM, skipNavLinks, + skipNavLinks.toString(), ""))); } - navDiv.add(queue.poll()); - HtmlTree skipLinkDiv = HtmlTree.DIV(HtmlStyle.skipNav, queue.poll()); - navDiv.add(skipLinkDiv); - navDiv.add(queue.poll()); HtmlTree navList = new HtmlTree(HtmlTag.UL); + navList.setId(top ? SectionName.NAVBAR_TOP_FIRSTROW.getName() + : SectionName.NAVBAR_BOTTOM_FIRSTROW.getName()); navList.setStyle(HtmlStyle.navList); navList.put(HtmlAttr.TITLE, rowListTitle); addMainNavLinks(navList); @@ -990,10 +959,12 @@ public class Navigation { tree.add(subDiv); if (top) { tree.add(Position.TOP.endOfNav()); - tree.add(HtmlTree.DIV(HtmlStyle.skipNav, queue.poll())); + tree.add(HtmlTree.SPAN(HtmlStyle.skipNav, EMPTY_COMMENT) + .setId(SectionName.SKIP_NAVBAR_TOP.getName())); } else { - tree.add(queue.poll()); tree.add(Position.BOTTOM.endOfNav()); + tree.add(HtmlTree.SPAN(HtmlStyle.skipNav, EMPTY_COMMENT) + .setId(SectionName.SKIP_NAVBAR_BOTTOM.getName())); } return tree; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java index 6b69cdfc104..613357b6312 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java @@ -77,6 +77,7 @@ public class Table { private final List bodyRows; private final List bodyRowMasks; private String rowIdPrefix = "i"; + private String id; /** * Creates a builder for an HTML table. @@ -276,6 +277,17 @@ public class Table { return this; } + /** + * Sets the id attribute of the table. + * + * @param id the id + * @return this object + */ + public Table setId(String id) { + this.id = id; + return this; + } + /** * Add a row of data to the table. * Each item of content should be suitable for use as the content of a @@ -396,6 +408,9 @@ public class Table { public Content toContent() { HtmlTree mainDiv = new HtmlTree(HtmlTag.DIV); mainDiv.setStyle(tableStyle); + if (id != null) { + mainDiv.setId(id); + } HtmlTree table = new HtmlTree(HtmlTag.TABLE); if (tabMap == null || tabs.size() == 1) { if (tabMap == null) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java index 8b431b7432c..e7d5ee27a93 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java @@ -56,18 +56,17 @@ public interface AnnotationTypeFieldWriter { /** * Add the annotation type details tree header. * - * @param typeElement the annotation type being documented + * @return content tree for the annotation details header */ - Content getAnnotationDetailsTreeHeader(TypeElement typeElement); + Content getAnnotationDetailsTreeHeader(); /** * Get the annotation type documentation tree header. * * @param member the annotation type being documented - * @param annotationDetailsTree the content tree representing annotation type details * @return content tree for the annotation type documentation header */ - Content getAnnotationDocTreeHeader(Element member, Content annotationDetailsTree); + Content getAnnotationDocTreeHeader(Element member); /** * Get the annotation type details tree. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java index 07411b7df4d..5fa12dbe2ff 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java @@ -56,18 +56,17 @@ public interface AnnotationTypeRequiredMemberWriter { /** * Add the annotation type details tree header. * - * @param typeElement the annotation type being documented + * @return content tree for the annotation details header */ - Content getAnnotationDetailsTreeHeader(TypeElement typeElement); + Content getAnnotationDetailsTreeHeader(); /** * Get the annotation type documentation tree header. * * @param member the annotation type being documented - * @param annotationDetailsTree the content tree representing annotation type details * @return content tree for the annotation type documentation header */ - Content getAnnotationDocTreeHeader(Element member, Content annotationDetailsTree); + Content getAnnotationDocTreeHeader(Element member); /** * Get the annotation type details tree. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java index 3328bc64f38..e62fda3888d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java @@ -42,22 +42,18 @@ public interface ConstructorWriter { /** * Get the constructor details tree header. * - * @param typeElement the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the constructor details header */ - Content getConstructorDetailsTreeHeader(TypeElement typeElement, - Content memberDetailsTree); + Content getConstructorDetailsTreeHeader(Content memberDetailsTree); /** * Get the constructor documentation tree header. * * @param constructor the constructor being documented - * @param constructorDetailsTree the content tree representing constructor details * @return content tree for the constructor documentation header */ - Content getConstructorDocTreeHeader(ExecutableElement constructor, - Content constructorDetailsTree); + Content getConstructorDocTreeHeader(ExecutableElement constructor); /** * Get the signature for the given constructor. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java index 74e9f0c4fce..db10230af05 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java @@ -43,20 +43,18 @@ public interface FieldWriter { /** * Get the field details tree header. * - * @param typeElement the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the field details header */ - Content getFieldDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree); + Content getFieldDetailsTreeHeader(Content memberDetailsTree); /** * Get the field documentation tree header. * * @param field the constructor being documented - * @param fieldDetailsTree the content tree representing field details * @return content tree for the field documentation header */ - Content getFieldDocTreeHeader(VariableElement field, Content fieldDetailsTree); + Content getFieldDocTreeHeader(VariableElement field); /** * Get the signature for the given field. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java index 3f577dc13a3..1292d40fd96 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java @@ -43,20 +43,18 @@ public interface MethodWriter { /** * Get the method details tree header. * - * @param typeElement the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the method details header */ - Content getMethodDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree); + Content getMethodDetailsTreeHeader(Content memberDetailsTree); /** * Get the method documentation tree header. * * @param method the method being documented - * @param methodDetailsTree the content tree representing method details * @return content tree for the method documentation header */ - Content getMethodDocTreeHeader(ExecutableElement method, Content methodDetailsTree); + Content getMethodDocTreeHeader(ExecutableElement method); /** * Get the signature for the given method. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java index 9a882e4c7fe..f04651fe52d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java @@ -42,22 +42,18 @@ public interface PropertyWriter { /** * Get the property details tree header. * - * @param typeElement the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the property details header */ - Content getPropertyDetailsTreeHeader(TypeElement typeElement, - Content memberDetailsTree); + Content getPropertyDetailsTreeHeader(Content memberDetailsTree); /** * Get the property documentation tree header. * * @param property the property being documented - * @param propertyDetailsTree the content tree representing property details * @return content tree for the property documentation header */ - Content getPropertyDocTreeHeader(ExecutableElement property, - Content propertyDetailsTree); + Content getPropertyDocTreeHeader(ExecutableElement property); /** * Get the signature for the given property. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java index 7bd227b80ff..7758211a55b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java @@ -137,13 +137,12 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder { } if (hasMembersToDocument()) { writer.addAnnotationFieldDetailsMarker(memberDetailsTree); - Content annotationDetailsTreeHeader = writer.getAnnotationDetailsTreeHeader(typeElement); + Content annotationDetailsTreeHeader = writer.getAnnotationDetailsTreeHeader(); Content detailsTree = writer.getMemberTreeHeader(); for (Element member : members) { currentMember = member; - Content annotationDocTree = writer.getAnnotationDocTreeHeader(currentMember, - detailsTree); + Content annotationDocTree = writer.getAnnotationDocTreeHeader(currentMember); buildSignature(annotationDocTree); buildDeprecationInfo(annotationDocTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java index 6214cbf8c1c..6d4574a6407 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java @@ -139,13 +139,12 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { } if (hasMembersToDocument()) { writer.addAnnotationDetailsMarker(memberDetailsTree); - Content annotationDetailsTreeHeader = writer.getAnnotationDetailsTreeHeader(typeElement); + Content annotationDetailsTreeHeader = writer.getAnnotationDetailsTreeHeader(); Content detailsTree = writer.getMemberTreeHeader(); for (Element member : members) { currentMember = member; - Content annotationDocTree = writer.getAnnotationDocTreeHeader( - currentMember, detailsTree); + Content annotationDocTree = writer.getAnnotationDocTreeHeader(currentMember); buildAnnotationTypeMemberChildren(annotationDocTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java index d93aafaa2e7..4e1aa409871 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java @@ -132,13 +132,12 @@ public class ConstructorBuilder extends AbstractMemberBuilder { return; } if (hasMembersToDocument()) { - Content constructorDetailsTreeHeader = writer.getConstructorDetailsTreeHeader(typeElement, - memberDetailsTree); + Content constructorDetailsTreeHeader = writer.getConstructorDetailsTreeHeader(memberDetailsTree); Content constructorDetailsTree = writer.getMemberTreeHeader(); for (Element constructor : constructors) { currentConstructor = (ExecutableElement)constructor; - Content constructorDocTree = writer.getConstructorDocTreeHeader(currentConstructor, constructorDetailsTree); + Content constructorDocTree = writer.getConstructorDocTreeHeader(currentConstructor); buildSignature(constructorDocTree); buildDeprecationInfo(constructorDocTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java index cb04351cf8b..3396681862d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java @@ -122,12 +122,12 @@ public class FieldBuilder extends AbstractMemberBuilder { return; } if (!fields.isEmpty()) { - Content fieldDetailsTreeHeader = writer.getFieldDetailsTreeHeader(typeElement, memberDetailsTree); + Content fieldDetailsTreeHeader = writer.getFieldDetailsTreeHeader(memberDetailsTree); Content fieldDetailsTree = writer.getMemberTreeHeader(); for (Element element : fields) { currentElement = (VariableElement)element; - Content fieldDocTree = writer.getFieldDocTreeHeader(currentElement, fieldDetailsTree); + Content fieldDocTree = writer.getFieldDocTreeHeader(currentElement); buildSignature(fieldDocTree); buildDeprecationInfo(fieldDocTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java index 6993c6c2a6f..40f26c9b919 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java @@ -123,13 +123,12 @@ public class MethodBuilder extends AbstractMemberBuilder { return; } if (hasMembersToDocument()) { - Content methodDetailsTreeHeader = writer.getMethodDetailsTreeHeader(typeElement, - memberDetailsTree); + Content methodDetailsTreeHeader = writer.getMethodDetailsTreeHeader(memberDetailsTree); Content methodDetailsTree = writer.getMemberTreeHeader(); for (Element method : methods) { currentMethod = (ExecutableElement)method; - Content methodDocTree = writer.getMethodDocTreeHeader(currentMethod, methodDetailsTree); + Content methodDocTree = writer.getMethodDocTreeHeader(currentMethod); buildSignature(methodDocTree); buildDeprecationInfo(methodDocTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java index f8217b694b6..de44b77cdad 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java @@ -122,14 +122,12 @@ public class PropertyBuilder extends AbstractMemberBuilder { return; } if (hasMembersToDocument()) { - Content propertyDetailsTreeHeader = writer.getPropertyDetailsTreeHeader(typeElement, - memberDetailsTree); + Content propertyDetailsTreeHeader = writer.getPropertyDetailsTreeHeader(memberDetailsTree); Content propertyDetailsTree = writer.getMemberTreeHeader(); for (Element property : properties) { currentProperty = (ExecutableElement)property; - Content propertyDocTree = writer.getPropertyDocTreeHeader(currentProperty, - propertyDetailsTree); + Content propertyDocTree = writer.getPropertyDocTreeHeader(currentProperty); buildSignature(propertyDocTree); buildPropertyComments(propertyDocTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java index b312031e3ac..6a15afedb7a 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java @@ -192,7 +192,7 @@ public class DeprecatedAPIListBuilder { /** * Return true if the list of a given type has size greater than 0. * - * @param type the type of list being checked. + * @param kind the type of list being checked. */ public boolean hasDocumentation(DeprElementKind kind) { return !deprecatedMap.get(kind).isEmpty(); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java index e29f41979bc..e0a3ec17a06 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,13 +58,6 @@ import java.util.zip.ZipFile; * a .class file, a directory, or a JAR file. */ public class ClassFileReader implements Closeable { - /** - * Returns a ClassFileReader instance of a given path. - */ - public static ClassFileReader newInstance(Path path) throws IOException { - return newInstance(path, null); - } - /** * Returns a ClassFileReader instance of a given path. */ diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java index 0766e5a3d32..307a488f405 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -915,6 +915,11 @@ class JdepsTask { option); return false; } + if (!options.rootModules.isEmpty()) { + reportError("err.invalid.options", "-m or --module", + option); + return false; + } return true; } @@ -922,12 +927,12 @@ class JdepsTask { boolean run(JdepsConfiguration config) throws IOException { // check if any JAR file contains unnamed package for (String arg : inputArgs) { - try (ClassFileReader reader = ClassFileReader.newInstance(Paths.get(arg))) { + try (ClassFileReader reader = ClassFileReader.newInstance(Paths.get(arg), config.getVersion())) { Optional classInUnnamedPackage = reader.entries().stream() - .filter(n -> n.endsWith(".class")) - .filter(cn -> toPackageName(cn).isEmpty()) - .findFirst(); + .filter(n -> n.endsWith(".class")) + .filter(cn -> toPackageName(cn).isEmpty()) + .findFirst(); if (classInUnnamedPackage.isPresent()) { if (classInUnnamedPackage.get().equals("module-info.class")) { @@ -942,10 +947,10 @@ class JdepsTask { ModuleInfoBuilder builder = new ModuleInfoBuilder(config, inputArgs, dir, openModule); - boolean ok = builder.run(); - - if (!ok && !options.nowarning) { + boolean ok = builder.run(options.ignoreMissingDeps, log, options.nowarning); + if (!ok) { reportError("err.missing.dependences"); + log.println(); builder.visitMissingDeps(new SimpleDepVisitor()); } return ok; @@ -981,7 +986,7 @@ class JdepsTask { throw new UncheckedBadArgs(new BadArgs("err.invalid.options", list, "--check")); } - return new ModuleAnalyzer(config, log, modules).run(); + return new ModuleAnalyzer(config, log, modules).run(options.ignoreMissingDeps); } /* @@ -1041,7 +1046,7 @@ class JdepsTask { separator); boolean ok = analyzer.run(options.depth(), options.ignoreMissingDeps); if (!ok) { - reportError("err.cant.list.module.deps"); + reportError("err.missing.dependences"); log.println(); analyzer.visitMissingDeps(new SimpleDepVisitor()); } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java index 233f62b80ba..3bab7be1d92 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,16 @@ */ package com.sun.tools.jdeps; -import static com.sun.tools.jdeps.Graph.*; import static com.sun.tools.jdeps.JdepsFilter.DEFAULT_FILTER; import static com.sun.tools.jdeps.Module.*; import static java.lang.module.ModuleDescriptor.Requires.Modifier.*; import static java.util.stream.Collectors.*; import com.sun.tools.classfile.Dependency; -import com.sun.tools.jdeps.JdepsTask.BadArgs; import java.io.IOException; -import java.io.OutputStream; import java.io.PrintWriter; import java.lang.module.ModuleDescriptor; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -80,23 +74,32 @@ public class ModuleAnalyzer { } } - public boolean run() throws IOException { + public boolean run(boolean ignoreMissingDeps) throws IOException { try { - // compute "requires transitive" dependences - modules.values().forEach(ModuleDeps::computeRequiresTransitive); - - modules.values().forEach(md -> { + for (ModuleDeps md: modules.values()) { + // compute "requires transitive" dependences + md.computeRequiresTransitive(ignoreMissingDeps); // compute "requires" dependences - md.computeRequires(); + md.computeRequires(ignoreMissingDeps); + // print module descriptor + md.printModuleDescriptor(); + // apply transitive reduction and reports recommended requires. - md.analyzeDeps(); - }); + boolean ok = md.analyzeDeps(); + if (!ok) return false; + + if (ignoreMissingDeps && md.hasMissingDependencies()) { + log.format("Warning: --ignore-missing-deps specified. Missing dependencies from %s are ignored%n", + md.root.name()); + } + } } finally { dependencyFinder.shutdown(); } return true; } + class ModuleDeps { final Module root; Set requiresTransitive; @@ -110,23 +113,22 @@ public class ModuleAnalyzer { /** * Compute 'requires transitive' dependences by analyzing API dependencies */ - private void computeRequiresTransitive() { + private void computeRequiresTransitive(boolean ignoreMissingDeps) { // record requires transitive - this.requiresTransitive = computeRequires(true) + this.requiresTransitive = computeRequires(true, ignoreMissingDeps) .filter(m -> !m.name().equals(JAVA_BASE)) .collect(toSet()); trace("requires transitive: %s%n", requiresTransitive); } - private void computeRequires() { - this.requires = computeRequires(false).collect(toSet()); + private void computeRequires(boolean ignoreMissingDeps) { + this.requires = computeRequires(false, ignoreMissingDeps).collect(toSet()); trace("requires: %s%n", requires); } - private Stream computeRequires(boolean apionly) { + private Stream computeRequires(boolean apionly, boolean ignoreMissingDeps) { // analyze all classes - if (apionly) { dependencyFinder.parseExportedAPIs(Stream.of(root)); } else { @@ -135,9 +137,14 @@ public class ModuleAnalyzer { // find the modules of all the dependencies found return dependencyFinder.getDependences(root) + .filter(a -> !(ignoreMissingDeps && Analyzer.notFound(a))) .map(Archive::getModule); } + boolean hasMissingDependencies() { + return dependencyFinder.getDependences(root).anyMatch(Analyzer::notFound); + } + ModuleDescriptor descriptor() { return descriptor(requiresTransitive, requires); } @@ -196,12 +203,30 @@ public class ModuleAnalyzer { return descriptor(requiresTransitive, g.adjacentNodes(root)); } + private void showMissingDeps() { + // build the analyzer if there are missing dependences + Analyzer analyzer = new Analyzer(configuration, Analyzer.Type.CLASS, DEFAULT_FILTER); + analyzer.run(Set.of(root), dependencyFinder.locationToArchive()); + log.println("Error: Missing dependencies: classes not found from the module path."); + Analyzer.Visitor visitor = new Analyzer.Visitor() { + @Override + public void visitDependence(String origin, Archive originArchive, String target, Archive targetArchive) { + log.format(" %-50s -> %-50s %s%n", origin, target, targetArchive.getName()); + } + }; + analyzer.visitDependences(root, visitor, Analyzer.Type.VERBOSE, Analyzer::notFound); + log.println(); + } + /** * Apply transitive reduction on the resulting graph and reports * recommended requires. */ - private void analyzeDeps() { - printModuleDescriptor(log, root); + private boolean analyzeDeps() { + if (requires.stream().anyMatch(m -> m == UNNAMED_MODULE)) { + showMissingDeps(); + return false; + } ModuleDescriptor analyzedDescriptor = descriptor(); if (!matches(root.descriptor(), analyzedDescriptor)) { @@ -223,6 +248,7 @@ public class ModuleAnalyzer { checkQualifiedExports(); log.println(); + return true; } private void checkQualifiedExports() { @@ -239,6 +265,10 @@ public class ModuleAnalyzer { .collect(joining(",")))); } + void printModuleDescriptor() { + printModuleDescriptor(log, root); + } + private void printModuleDescriptor(PrintWriter out, Module module) { ModuleDescriptor descriptor = module.descriptor(); out.format("%s (%s)%n", descriptor.name(), module.location()); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java index fe05bd8636c..94fba26c5b7 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,7 +98,7 @@ public class ModuleInfoBuilder { } } - public boolean run() throws IOException { + public boolean run(boolean ignoreMissingDeps, PrintWriter log, boolean quiet) throws IOException { try { // pass 1: find API dependencies Map> requiresTransitive = computeRequiresTransitive(); @@ -108,52 +108,65 @@ public class ModuleInfoBuilder { analyzer.run(automaticModules(), dependencyFinder.locationToArchive()); - boolean missingDeps = false; for (Module m : automaticModules()) { Set apiDeps = requiresTransitive.containsKey(m) ? requiresTransitive.get(m) : Collections.emptySet(); - Path file = outputdir.resolve(m.name()).resolve("module-info.java"); + // if this is a multi-release JAR, write to versions/$VERSION/module-info.java + Runtime.Version version = configuration.getVersion(); + Path dir = version != null + ? outputdir.resolve(m.name()) + .resolve("versions") + .resolve(String.valueOf(version.feature())) + : outputdir.resolve(m.name()); + Path file = dir.resolve("module-info.java"); // computes requires and requires transitive - Module normalModule = toNormalModule(m, apiDeps); + Module normalModule = toNormalModule(m, apiDeps, ignoreMissingDeps); if (normalModule != null) { automaticToNormalModule.put(m, normalModule); // generate module-info.java - System.out.format("writing to %s%n", file); + if (!quiet) { + if (ignoreMissingDeps && analyzer.requires(m).anyMatch(Analyzer::notFound)) { + log.format("Warning: --ignore-missing-deps specified. Missing dependencies from %s are ignored%n", + m.name()); + } + log.format("writing to %s%n", file); + } writeModuleInfo(file, normalModule.descriptor()); } else { // find missing dependences - System.out.format("Missing dependence: %s not generated%n", file); - missingDeps = true; + return false; } } - return !missingDeps; } finally { dependencyFinder.shutdown(); } + return true; } - private Module toNormalModule(Module module, Set requiresTransitive) + private Module toNormalModule(Module module, Set requiresTransitive, boolean ignoreMissingDeps) throws IOException { // done analysis module.close(); - if (analyzer.requires(module).anyMatch(Analyzer::notFound)) { + if (!ignoreMissingDeps && analyzer.requires(module).anyMatch(Analyzer::notFound)) { // missing dependencies return null; } Map requires = new HashMap<>(); requiresTransitive.stream() + .filter(a -> !(ignoreMissingDeps && Analyzer.notFound(a))) .map(Archive::getModule) .forEach(m -> requires.put(m.name(), Boolean.TRUE)); analyzer.requires(module) + .filter(a -> !(ignoreMissingDeps && Analyzer.notFound(a))) .map(Archive::getModule) .forEach(d -> requires.putIfAbsent(d.name(), Boolean.FALSE)); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties index 2b55e39aad6..98babe8e7ed 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -229,7 +229,6 @@ main.opt.multi-release=\ err.command.set={0} and {1} options are specified. err.unknown.option=unknown option: {0} err.missing.arg=no value given for {0} -err.missing.dependences=missing dependencies err.invalid.arg.for.option=invalid argument for option: {0} err.option.after.class=option must be specified before classes: {0} err.genmoduleinfo.not.jarfile={0} is a modular JAR file that cannot be specified with the --generate-module-info option @@ -246,8 +245,8 @@ err.multirelease.option.exists={0} is not a multi-release jar file but --multi-r err.multirelease.option.notfound={0} is a multi-release jar file but --multi-release option is not set err.multirelease.version.associated=class {0} already associated with version {1}, trying to add version {2} err.multirelease.jar.malformed=malformed multi-release jar, {0}, bad entry: {1} -err.cant.list.module.deps=\ -Missing dependencies from the module path and classpath.\n\ +err.missing.dependences=\ +Missing dependencies: classes not found from the module path and classpath.\n\ To suppress this error, use --ignore-missing-deps to continue. warn.invalid.arg=Path does not exist: {0} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java index ab9c69dfeae..2937e2b77f0 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,6 +93,21 @@ public final class Recording implements Closeable { private final PlatformRecording internal; + /** + * Creates a recording with settings from a map of name-value pairs. + *

+ * A newly created recording is in the {@link RecordingState#NEW} state. To start + * the recording, invoke the {@link Recording#start()} method. + * + * @throws IllegalStateException if Flight Recorder can't be created (for + * example, if the Java Virtual Machine (JVM) lacks Flight Recorder + * support, or if the file repository can't be created or accessed) + * + * @throws SecurityException If a security manager is used and + * FlightRecorderPermission "accessFlightRecorder" is not set. + * + * @see jdk.jfr + */ public Recording(Map settings) { PlatformRecorder r = FlightRecorder.getFlightRecorder().getInternal(); synchronized (r) { @@ -424,7 +439,7 @@ public final class Recording implements Closeable { * * @since 14 */ - public void setFlushInterval(Duration interval) { + /*package private*/ void setFlushInterval(Duration interval) { Objects.nonNull(interval); if (interval.isNegative()) { throw new IllegalArgumentException("Stream interval can't be negative"); @@ -439,7 +454,7 @@ public final class Recording implements Closeable { * * @since 14 */ - public Duration getFlushInterval() { + /*package private*/ Duration getFlushInterval() { return internal.getFlushInterval(); } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java index 70d13baf98c..054770a8dcb 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,7 +86,6 @@ public final class RecordingStream implements AutoCloseable, EventStream { Utils.checkAccessFlightRecorder(); AccessControlContext acc = AccessController.getContext(); this.recording = new Recording(); - this.recording.setFlushInterval(Duration.ofMillis(1000)); try { PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); this.directoryStream = new EventDirectoryStream(acc, null, SecuritySupport.PRIVILIGED, pr); @@ -267,20 +266,6 @@ public final class RecordingStream implements AutoCloseable, EventStream { recording.setMaxSize(maxSize); } - /** - * Determines how often events are made available for streaming. - * - * @param interval the interval at which events are made available to the - * stream, no {@code null} - * - * @throws IllegalArgumentException if {@code interval} is negative - * - * @throws IllegalStateException if the stream is closed - */ - public void setFlushInterval(Duration interval) { - recording.setFlushInterval(interval); - } - @Override public void setReuse(boolean reuse) { directoryStream.setReuse(reuse); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java index 5237d85d761..d46e682b752 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; import jdk.jfr.internal.OldObjectSample; +import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.Type; @@ -186,7 +187,8 @@ final class DCmdStart extends AbstractDCmd { } if (flush != null) { - recording.setFlushInterval(Duration.ofNanos(flush)); + PlatformRecording p = PrivateAccess.getInstance().getPlatformRecording(recording); + p.setFlushInterval(Duration.ofNanos(flush)); } if (maxSize != null) { diff --git a/src/jdk.jfr/share/conf/jfr/default.jfc b/src/jdk.jfr/share/conf/jfr/default.jfc index d67cf5e9bb7..a15159b6154 100644 --- a/src/jdk.jfr/share/conf/jfr/default.jfc +++ b/src/jdk.jfr/share/conf/jfr/default.jfc @@ -671,32 +671,7 @@ - true - 0 ns - - - - true - 0 ns - - - - true - 0 ns - - - - true - 0 ns - - - - true - 0 ns - - - - true + false 0 ns diff --git a/src/jdk.jfr/share/conf/jfr/profile.jfc b/src/jdk.jfr/share/conf/jfr/profile.jfc index c25e2facbf9..9edecee0690 100644 --- a/src/jdk.jfr/share/conf/jfr/profile.jfc +++ b/src/jdk.jfr/share/conf/jfr/profile.jfc @@ -671,32 +671,7 @@ - true - 0 ns - - - - true - 0 ns - - - - true - 0 ns - - - - true - 0 ns - - - - true - 0 ns - - - - true + false 0 ns diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties index 34d4d1bf245..fec33911612 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -46,7 +46,8 @@ main.opt.module-path=\ \ if it exists. main.opt.add-modules=\ -\ --add-modules [,...] Root modules to resolve +\ --add-modules [,...] Root modules to resolve in addition to the\n\ +\ initial modules. can also be ALL-MODULE-PATH. main.opt.limit-modules=\ \ --limit-modules [,...] Limit the universe of observable\n\ diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java index c834c00f62a..1fa09dfae5c 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -596,6 +596,7 @@ class Feedback { INTERFACE("interface declaration"), ENUM("enum declaration"), ANNOTATION("annotation interface declaration"), + RECORD("record declaration"), METHOD("method declaration -- note: {type}==parameter-types"), VARDECL("variable declaration without init"), VARINIT("variable declaration with init"), diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index ebb03c69dd5..d8be3651b87 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3324,6 +3324,9 @@ public class JShellTool implements MessageHandler { case ANNOTATION_TYPE_SUBKIND: kind = "@interface"; break; + case RECORD_SUBKIND: + kind = "record"; + break; default: assert false : "Wrong kind" + ck.subKind(); kind = "class"; @@ -3819,6 +3822,9 @@ public class JShellTool implements MessageHandler { case ANNOTATION_TYPE_SUBKIND: custom(FormatCase.ANNOTATION, ((TypeDeclSnippet) sn).name()); break; + case RECORD_SUBKIND: + custom(FormatCase.RECORD, ((TypeDeclSnippet) sn).name()); + break; case METHOD_SUBKIND: custom(FormatCase.METHOD, ((MethodSnippet) sn).name(), ((MethodSnippet) sn).parameterTypes()); break; diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties index ce62966eea6..eb6f6c113f6 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -855,6 +855,7 @@ The case selector kind describes the kind of snippet. The values are:\n\t\ interface -- interface declaration\n\t\ enum -- enum declaration\n\t\ annotation -- annotation interface declaration\n\t\ + record -- record declaration\n\t\ method -- method declaration -- note: {type}==parameter-types\n\t\ vardecl -- variable declaration without init\n\t\ varinit -- variable declaration with init\n\t\ @@ -1158,12 +1159,12 @@ startup.feedback = \ /set format verbose action ' update overwrote' overwrote-update \n\ /set format verbose action ' update dropped' dropped-update \n\ \n\ -/set format verbose until ', however, it cannot be instantiated or its methods invoked until' defined-class-primary \n\ +/set format verbose until ', however, it cannot be instantiated or its methods invoked until' defined-class,record-primary \n\ /set format verbose until ', however, its methods cannot be invoked until' defined-interface-primary \n\ /set format verbose until ', however, it cannot be used until' defined-enum,annotation-primary \n\ /set format verbose until ', however, it cannot be invoked until' defined-method-primary \n\ /set format verbose until ', however, it cannot be referenced until' notdefined-primary \n\ -/set format verbose until ' which cannot be instantiated or its methods invoked until' defined-class-update \n\ +/set format verbose until ' which cannot be instantiated or its methods invoked until' defined-class,record-update \n\ /set format verbose until ' whose methods cannot be invoked until' defined-interface-update \n\ /set format verbose until ' which cannot be invoked until' defined-method-update \n\ /set format verbose until ' which cannot be referenced until' notdefined-update \n\ @@ -1183,6 +1184,7 @@ startup.feedback = \ /set format verbose typeKind 'interface' interface \n\ /set format verbose typeKind 'enum' enum \n\ /set format verbose typeKind 'annotation interface' annotation \n\ +/set format verbose typeKind 'record' record \n\ \n\ /set format verbose result '{name} ==> {value}{post}' added,modified,replaced-ok-primary \n\ \n\ @@ -1194,10 +1196,10 @@ startup.feedback = \ /set format verbose display '{pre}{action} variable {name}{post}' dropped-vardecl,varinit,expression \n\ /set format verbose display '{pre}{action} variable {name}, reset to null{post}' replaced-vardecl,varinit-ok-update \n\ \n\ -/set format verbose display '{pre}{action} {typeKind} {name}{resolve}{post}' class,interface,enum,annotation \n\ +/set format verbose display '{pre}{action} {typeKind} {name}{resolve}{post}' class,interface,enum,annotation,record \n\ /set format verbose display '{pre}{action} method {name}({type}){resolve}{post}' method \n\ \n\ -/set format verbose display '{pre}attempted to use {typeKind} {name}{resolve}{post}' used-class,interface,enum,annotation \n\ +/set format verbose display '{pre}attempted to use {typeKind} {name}{resolve}{post}' used-class,interface,enum,annotation,record \n\ /set format verbose display '{pre}attempted to call method {name}({type}){resolve}{post}' used-method \n\ \n\ /set truncation verbose 80\n\ @@ -1211,7 +1213,7 @@ startup.feedback = \ \n\ /set prompt concise 'jshell> ' ' ...> ' \n\ \n\ -/set format concise display '' class,interface,enum,annotation,method,assignment,varinit,vardecl-ok \n\ +/set format concise display '' class,interface,enum,annotation,record,method,assignment,varinit,vardecl-ok \n\ \n\ /set feedback normal \n\ \n\ diff --git a/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java b/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java index 01d7898feea..4e95e807aae 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/Corraller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,10 @@ import static com.sun.tools.javac.code.Flags.PUBLIC; import static com.sun.tools.javac.code.Flags.STATIC; import static com.sun.tools.javac.code.Flags.INTERFACE; import static com.sun.tools.javac.code.Flags.ENUM; +import static com.sun.tools.javac.code.Flags.RECORD; +import static com.sun.tools.javac.code.Flags.SYNTHETIC; +import com.sun.tools.javac.tree.JCTree.Tag; +import com.sun.tools.javac.tree.TreeInfo; import jdk.jshell.Wrap.CompoundWrap; import jdk.jshell.Wrap.Range; import jdk.jshell.Wrap.RangeWrap; @@ -114,6 +118,7 @@ class Corraller extends Visitor { public void visitClassDef(JCClassDecl tree) { boolean isEnum = (tree.mods.flags & ENUM) != 0; boolean isInterface = (tree.mods.flags & INTERFACE ) != 0; + boolean isRecord = (tree.mods.flags & RECORD ) != 0; int classBegin = dis.getStartPosition(tree); int classEnd = dis.getEndPosition(tree); //debugWrap("visitClassDef: %d-%d = %s\n", classBegin, classEnd, source.substring(classBegin, classEnd)); @@ -151,8 +156,12 @@ class Corraller extends Visitor { // non-enum boolean constructorSeen = false; for (List l = tree.defs; l.nonEmpty(); l = l.tail) { - wrappedDefs.append("\n "); JCTree t = l.head; + if (isRecord && t.hasTag(Tag.VARDEF) && (TreeInfo.flags(t) & RECORD) != 0) { + //record parameters are part of the record's header + continue; + } + wrappedDefs.append("\n "); switch (t.getKind()) { case METHOD: constructorSeen = constructorSeen || ((MethodTree)t).getName() == tree.name.table.names.init; @@ -166,7 +175,14 @@ class Corraller extends Visitor { } wrappedDefs.append(corral(t)); } - if (!constructorSeen && !isInterface && !isEnum) { + if (!constructorSeen && isRecord) { + // Generate a default constructor, since + // this is a regular record and there are no constructors + if (wrappedDefs.length() > 0) { + wrappedDefs.append("\n "); + } + wrappedDefs.append(" public " + tree.name.toString() + " " + resolutionExceptionBlock); + } else if (!constructorSeen && !isInterface && !isEnum) { // Generate a default constructor, since // this is a regular class and there are no constructors if (wrappedDefs.length() > 0) { @@ -175,7 +191,9 @@ class Corraller extends Visitor { wrappedDefs.append(defaultConstructor(tree)); } } - bodyBegin = dis.getStartPosition(tree.defs.head); + if (!isRecord) { + bodyBegin = dis.getStartPosition(tree.defs.head); + } } Object defs = wrappedDefs.length() == 1 ? wrappedDefs.first() diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index ec2cf7d7846..6ab936ccbc6 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -93,6 +93,7 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8193639 solaris-all runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64 runtime/ReservedStack/ReservedStackTest.java 8231031 generic-all +runtime/Metaspace/DefineClass.java 8236901 generic-all ############################################################################# @@ -133,7 +134,7 @@ serviceability/sa/TestG1HeapRegion.java 8193639 solaris-all serviceability/sa/TestHeapDumpForInvokeDynamic.java 8193639 solaris-all serviceability/sa/TestHeapDumpForLargeArray.java 8193639 solaris-all serviceability/sa/TestInstanceKlassSize.java 8193639,8230664 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/TestInstanceKlassSizeForInterface.java 8193639 solaris-all +serviceability/sa/TestInstanceKlassSizeForInterface.java 8193639,8230664 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/TestIntConstant.java 8193639 solaris-all serviceability/sa/TestJhsdbJstackLock.java 8193639 solaris-all serviceability/sa/TestJmapCore.java 8193639 solaris-all diff --git a/test/hotspot/jtreg/compiler/c2/TestJumpTable.java b/test/hotspot/jtreg/compiler/c2/TestJumpTable.java new file mode 100644 index 00000000000..7cd5f8188a8 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestJumpTable.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8229855 + * @summary Test jump table with key value that gets out of bounds after loop unrolling. + * @run main/othervm -XX:CompileCommand=dontinline,compiler.c2.TestJumpTable::test* + * -Xbatch -XX:-TieredCompilation -XX:-UseSwitchProfiling + * compiler.c2.TestJumpTable + */ + +package compiler.c2; + +public class TestJumpTable { + + public static int test() { + int res = 0; + for (int i = 10; i < 50; ++i) { + switch (i * 5) { + case 15: + case 25: + case 40: + case 101: + return 42; + case 45: + case 51: + case 60: + res++; + break; + } + } + return res; + } + + public static void main(String[] args) { + for (int i = 0; i < 20_000; ++i) { + test(); + } + } +} diff --git a/test/hotspot/jtreg/compiler/macronodes/TestCompleteVolatileStore.java b/test/hotspot/jtreg/compiler/macronodes/TestCompleteVolatileStore.java new file mode 100644 index 00000000000..74b24b662e7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/macronodes/TestCompleteVolatileStore.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8236140 + * @requires vm.gc.Serial + * @summary Tests proper rehashing of a captured volatile field StoreL node when completing it. + * @run main/othervm -Xbatch -XX:+UseSerialGC -XX:CompileCommand=compileonly,compiler.macronodes.TestCompleteVolatileStore::test + * compiler.macronodes.TestCompleteVolatileStore + */ + +package compiler.macronodes; + +public class TestCompleteVolatileStore { + int i1 = 4; + + public void test() { + /* + * The store to the volatile field 'l1' (StoreL) of 'a' is captured in the Initialize node of 'a' + * (i.e. additional input to it) and completed in InitializeNode::complete_stores. + * Since 'l1' is volatile, the hash of the StoreL is non-zero triggering the hash assertion failure. + */ + A a = new A(); + + // Make sure that the CheckCastPP node of 'a' is used in the input chain of the Intialize node of 'b' + B b = new B(a); + + // Make sure 'b' is non-scalar-replacable to avoid eliminating all allocations + B[] arr = new B[i1]; + arr[i1-3] = b; + } + + public static void main(String[] strArr) { + TestCompleteVolatileStore _instance = new TestCompleteVolatileStore(); + for (int i = 0; i < 10_000; i++ ) { + _instance.test(); + } + } +} + +class A { + // Needs to be volatile to have a non-zero hash for the StoreL node. + volatile long l1; + + A() { + // StoreL gets captured and is later processed in InitializeNode::complete_stores while expanding the allocation node. + this.l1 = 256; + } +} + +class B { + A a; + + B(A a) { + this.a = a; + } +} + diff --git a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java index 5e0b70a200f..fbab8e008b0 100644 --- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java +++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ public class TestGCLogMessages { } public boolean isAvailable() { - return Compiler.isC2Enabled() || Compiler.isGraalEnabled(); + return Compiler.isC2OrJVMCIIncludedInVmBuild(); } } diff --git a/test/hotspot/jtreg/gc/shenandoah/jvmti/TestHeapDump.java b/test/hotspot/jtreg/gc/shenandoah/jvmti/TestHeapDump.java index fed358d24ad..35f861c952c 100644 --- a/test/hotspot/jtreg/gc/shenandoah/jvmti/TestHeapDump.java +++ b/test/hotspot/jtreg/gc/shenandoah/jvmti/TestHeapDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as @@ -40,6 +40,15 @@ * @run main/othervm/native/timeout=300 -agentlib:TestHeapDump -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx128m -XX:ShenandoahGCHeuristics=aggressive -XX:-UseCompressedOops TestHeapDump */ +/** + * @test TestHeapDump + * @summary Tests JVMTI heap dumps + * @key gc + * @requires vm.gc.Shenandoah & !vm.graal.enabled + * @compile TestHeapDump.java + * @run main/othervm/native/timeout=300 -agentlib:TestHeapDump -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx128m -XX:ShenandoahGCHeuristics=aggressive -XX:+UseStringDeduplication TestHeapDump + */ + import java.lang.ref.Reference; public class TestHeapDump { diff --git a/test/hotspot/jtreg/gc/z/TestUncommit.java b/test/hotspot/jtreg/gc/z/TestUncommit.java index 5929063f191..9ac990ed79c 100644 --- a/test/hotspot/jtreg/gc/z/TestUncommit.java +++ b/test/hotspot/jtreg/gc/z/TestUncommit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,16 @@ package gc.z; /* * @test TestUncommit - * @requires vm.gc.Z & !vm.graal.enabled + * @requires vm.gc.Z & !vm.graal.enabled & vm.compMode != "Xcomp" * @summary Test ZGC uncommit unused memory - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xms128M -Xmx512M -XX:ZUncommitDelay=10 gc.z.TestUncommit true 3 - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xms512M -Xmx512M -XX:ZUncommitDelay=10 gc.z.TestUncommit false 1 - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xms128M -Xmx512M -XX:ZUncommitDelay=10 -XX:-ZUncommit gc.z.TestUncommit false 1 + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc*,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=10 gc.z.TestUncommit true 3 + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc*,gc+stats=off -Xms512M -Xmx512M -XX:ZUncommitDelay=10 gc.z.TestUncommit false 1 + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xlog:gc*,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=10 -XX:-ZUncommit gc.z.TestUncommit false 1 + */ + +/* + * This test is disabled when running with -Xcomp, since it seems to affect + * the timing of the test, causing memory to appear to be uncommitted too fast. */ import java.util.ArrayList; diff --git a/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp b/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp index c9c66117295..fbff3c847f1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp @@ -67,7 +67,8 @@ void JNICALL VMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { jvmti->RunAgentThread(agent_thread, GenerateEventsThread, NULL, JVMTI_THREAD_NORM_PRIORITY); } -jint Agent_OnLoad(JavaVM* vm, char* options, void* reserved) { +JNIEXPORT +jint JNICALL Agent_OnLoad(JavaVM* vm, char* options, void* reserved) { jvmtiEnv* jvmti; vm->GetEnv((void**)&jvmti, JVMTI_VERSION_1_0); diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java index fddb2180563..8abd004912f 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,40 +50,23 @@ import java.util.*; * jdk.hotspot.agent/sun.jvm.hotspot.utilities * jdk.hotspot.agent/sun.jvm.hotspot.oops * jdk.hotspot.agent/sun.jvm.hotspot.debugger - * @run main/othervm TestInstanceKlassSize + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestInstanceKlassSize */ +import sun.hotspot.WhiteBox; + public class TestInstanceKlassSize { - private static String getJcmdInstanceKlassSize(OutputAnalyzer output, - String instanceKlassName) { - for (String s : output.asLines()) { - if (s.contains(instanceKlassName)) { - String tokens[]; - System.out.println(s); - tokens = s.split("\\s+"); - return tokens[3]; - } - } - return null; - } - - private static OutputAnalyzer jcmd(Long pid, - String... toolArgs) throws Exception { - ProcessBuilder processBuilder = new ProcessBuilder(); - JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jcmd"); - launcher.addToolArg(Long.toString(pid)); - if (toolArgs != null) { - for (String toolArg : toolArgs) { - launcher.addToolArg(toolArg); - } - } - - processBuilder.command(launcher.getCommand()); - System.out.println( - processBuilder.command().stream().collect(Collectors.joining(" "))); - return ProcessTools.executeProcess(processBuilder); - } + public static WhiteBox wb = WhiteBox.getWhiteBox(); + private static String[] SAInstanceKlassNames = new String[] { + "java.lang.Object", + "java.util.Vector", + "java.lang.String", + "java.lang.Thread", + "java.lang.Byte" + }; private static void startMeWithArgs() throws Exception { @@ -100,48 +83,41 @@ public class TestInstanceKlassSize { throw new RuntimeException(ex); } try { - String[] instanceKlassNames = new String[] { - " java.lang.Object", - " java.util.Vector", - " java.lang.String", - " java.lang.Thread", - " java.lang.Byte", - }; + // Run this app with the LingeredApp PID to get SA output from the LingeredApp String[] toolArgs = { "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-Xbootclasspath/a:.", "TestInstanceKlassSize", Long.toString(app.getPid()) }; - OutputAnalyzer jcmdOutput = jcmd( - app.getPid(), - "GC.class_stats", "VTab,ITab,OopMap,KlassBytes"); ProcessBuilder processBuilder = ProcessTools .createJavaProcessBuilder(toolArgs); output = ProcessTools.executeProcess(processBuilder); System.out.println(output.getOutput()); output.shouldHaveExitValue(0); - // Check whether the size matches that which jcmd outputs - for (String instanceKlassName : instanceKlassNames) { - System.out.println ("Trying to match for" + instanceKlassName); - String jcmdInstanceKlassSize = getJcmdInstanceKlassSize( - jcmdOutput, - instanceKlassName); - Asserts.assertNotNull(jcmdInstanceKlassSize, - "Could not get the instance klass size from the jcmd output"); + // Check whether the size matches with value from VM. + for (String instanceKlassName : SAInstanceKlassNames) { + Class iklass = Class.forName(instanceKlassName); + System.out.println ("Trying to match for " + instanceKlassName); + String size = String.valueOf(wb.getKlassMetadataSize(iklass)); + boolean match = false; for (String s : output.asLines()) { if (s.contains(instanceKlassName)) { Asserts.assertTrue( - s.contains(jcmdInstanceKlassSize), - "The size computed by SA for" + + s.contains(size), "The size computed by SA for" + instanceKlassName + " does not match."); + match = true; } } + Asserts.assertTrue(match, "Found a match for " + instanceKlassName); } } finally { LingeredApp.stopApp(app); @@ -179,13 +155,6 @@ public class TestInstanceKlassSize { System.out.println ("No args run. Starting with args now."); startMeWithArgs(); } else { - String[] SAInstanceKlassNames = new String[] { - "java.lang.Object", - "java.util.Vector", - "java.lang.String", - "java.lang.Thread", - "java.lang.Byte" - }; SAInstanceKlassSize(Integer.parseInt(args[0]), SAInstanceKlassNames); } } diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java index 0dec0283975..fcfee61f993 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,11 +47,17 @@ import jdk.test.lib.Asserts; * jdk.hotspot.agent/sun.jvm.hotspot.utilities * jdk.hotspot.agent/sun.jvm.hotspot.oops * jdk.hotspot.agent/sun.jvm.hotspot.debugger - * @run main/othervm TestInstanceKlassSizeForInterface + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestInstanceKlassSize */ +import sun.hotspot.WhiteBox; + public class TestInstanceKlassSizeForInterface { + public static WhiteBox wb = WhiteBox.getWhiteBox(); + private static LingeredAppWithInterface theApp = null; private static void SAInstanceKlassSize(int lingeredAppPid, @@ -103,6 +109,9 @@ public class TestInstanceKlassSizeForInterface { "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-Xbootclasspath/a:.", "TestInstanceKlassSizeForInterface", Integer.toString(lingeredAppPid) }; @@ -114,35 +123,21 @@ public class TestInstanceKlassSizeForInterface { SAOutput.shouldHaveExitValue(0); System.out.println(SAOutput.getOutput()); - // Run jcmd on the LingeredApp process - ProcessBuilder pb = new ProcessBuilder(); - pb.command(new String[] { - JDKToolFinder.getJDKTool("jcmd"), - Long.toString(lingeredAppPid), - "GC.class_stats", - "VTab,ITab,OopMap,KlassBytes" - } - ); - - OutputAnalyzer jcmdOutput = new OutputAnalyzer(pb.start()); - System.out.println(jcmdOutput.getOutput()); - // Match the sizes from both the output streams for (String instanceKlassName : instanceKlassNames) { + Class iklass = Class.forName(instanceKlassName); System.out.println ("Trying to match for " + instanceKlassName); - String jcmdInstanceKlassSize = getJcmdInstanceKlassSize( - jcmdOutput, - instanceKlassName); - Asserts.assertNotNull(jcmdInstanceKlassSize, - "Could not get the instance klass size from the jcmd output"); + String size = String.valueOf(wb.getKlassMetadataSize(iklass)); + boolean match = false; for (String s : SAOutput.asLines()) { if (s.contains(instanceKlassName)) { - Asserts.assertTrue( - s.contains(jcmdInstanceKlassSize), - "The size computed by SA for " + - instanceKlassName + " does not match."); - } + Asserts.assertTrue( + s.contains(size), "The size computed by SA for" + + instanceKlassName + " does not match."); + match = true; + } } + Asserts.assertTrue(match, "Found a match for " + instanceKlassName); } } diff --git a/test/jdk/java/foreign/TestArrays.java b/test/jdk/java/foreign/TestArrays.java index f9ec0da992a..5aef6429077 100644 --- a/test/jdk/java/foreign/TestArrays.java +++ b/test/jdk/java/foreign/TestArrays.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,7 @@ import java.lang.invoke.VarHandle; import java.util.function.BiConsumer; import java.util.function.Consumer; +import org.testng.SkipException; import org.testng.annotations.*; import static org.testng.Assert.*; @@ -76,8 +77,8 @@ public class TestArrays { static VarHandle shortHandle = shorts.varHandle(short.class, PathElement.sequenceElement()); static VarHandle intHandle = ints.varHandle(int.class, PathElement.sequenceElement()); static VarHandle floatHandle = floats.varHandle(float.class, PathElement.sequenceElement()); - static VarHandle longHandle = doubles.varHandle(long.class, PathElement.sequenceElement()); - static VarHandle doubleHandle = longs.varHandle(double.class, PathElement.sequenceElement()); + static VarHandle longHandle = longs.varHandle(long.class, PathElement.sequenceElement()); + static VarHandle doubleHandle = doubles.varHandle(double.class, PathElement.sequenceElement()); static void initBytes(MemoryAddress base, SequenceLayout seq, BiConsumer handleSetter) { for (long i = 0; i < seq.elementCount().getAsLong() ; i++) { @@ -103,8 +104,13 @@ public class TestArrays { } } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test(expectedExceptions = { UnsupportedOperationException.class, + OutOfMemoryError.class }) public void testTooBigForArray() { + if (System.getProperty("sun.arch.data.model").equals("32")) { + throw new SkipException("32-bit Unsafe does not support this allocation size"); + } + MemorySegment.allocateNative((long) Integer.MAX_VALUE * 2).toByteArray(); } diff --git a/test/jdk/java/foreign/TestByteBuffer.java b/test/jdk/java/foreign/TestByteBuffer.java index 43f9c4a535c..ef785e49b5a 100644 --- a/test/jdk/java/foreign/TestByteBuffer.java +++ b/test/jdk/java/foreign/TestByteBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,6 +70,7 @@ import java.util.function.Supplier; import java.util.stream.Stream; import jdk.internal.foreign.MemoryAddressImpl; +import org.testng.SkipException; import org.testng.annotations.*; import sun.nio.ch.DirectBuffer; @@ -119,8 +120,8 @@ public class TestByteBuffer { static VarHandle shortHandle = shorts.varHandle(short.class, PathElement.sequenceElement()); static VarHandle intHandle = ints.varHandle(int.class, PathElement.sequenceElement()); static VarHandle floatHandle = floats.varHandle(float.class, PathElement.sequenceElement()); - static VarHandle longHandle = doubles.varHandle(long.class, PathElement.sequenceElement()); - static VarHandle doubleHandle = longs.varHandle(double.class, PathElement.sequenceElement()); + static VarHandle longHandle = longs.varHandle(long.class, PathElement.sequenceElement()); + static VarHandle doubleHandle = doubles.varHandle(double.class, PathElement.sequenceElement()); static void initTuples(MemoryAddress base) { @@ -247,6 +248,13 @@ public class TestByteBuffer { } } + static void checkByteArrayAlignment(MemoryLayout layout) { + if (layout.bitSize() > 32 + && System.getProperty("sun.arch.data.model").equals("32")) { + throw new SkipException("avoid unaligned access on 32-bit system"); + } + } + @Test(dataProvider = "bufferOps") public void testScopedBuffer(Function bufferFactory, Map members) { Buffer bb; @@ -338,6 +346,7 @@ public class TestByteBuffer { @Test(dataProvider="resizeOps") public void testResizeHeap(Consumer checker, Consumer initializer, SequenceLayout seq) { + checkByteArrayAlignment(seq.elementLayout()); int capacity = (int)seq.byteSize(); MemoryAddress base = MemorySegment.ofArray(new byte[capacity]).baseAddress(); initializer.accept(base); @@ -346,6 +355,7 @@ public class TestByteBuffer { @Test(dataProvider="resizeOps") public void testResizeBuffer(Consumer checker, Consumer initializer, SequenceLayout seq) { + checkByteArrayAlignment(seq.elementLayout()); int capacity = (int)seq.byteSize(); MemoryAddress base = MemorySegment.ofByteBuffer(ByteBuffer.wrap(new byte[capacity])).baseAddress(); initializer.accept(base); @@ -354,6 +364,7 @@ public class TestByteBuffer { @Test(dataProvider="resizeOps") public void testResizeRoundtripHeap(Consumer checker, Consumer initializer, SequenceLayout seq) { + checkByteArrayAlignment(seq.elementLayout()); int capacity = (int)seq.byteSize(); byte[] arr = new byte[capacity]; MemorySegment segment = MemorySegment.ofArray(arr); @@ -382,13 +393,19 @@ public class TestByteBuffer { leaked.asByteBuffer(); } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test(expectedExceptions = { UnsupportedOperationException.class, + OutOfMemoryError.class }) public void testTooBigForByteBuffer() { + if (System.getProperty("sun.arch.data.model").equals("32")) { + throw new SkipException("32-bit Unsafe does not support this allocation size"); + } + MemorySegment.allocateNative((long) Integer.MAX_VALUE * 2).asByteBuffer(); } @Test(dataProvider="resizeOps") public void testCopyHeapToNative(Consumer checker, Consumer initializer, SequenceLayout seq) { + checkByteArrayAlignment(seq.elementLayout()); int bytes = (int)seq.byteSize(); try (MemorySegment nativeArray = MemorySegment.allocateNative(bytes); MemorySegment heapArray = MemorySegment.ofArray(new byte[bytes])) { @@ -400,6 +417,7 @@ public class TestByteBuffer { @Test(dataProvider="resizeOps") public void testCopyNativeToHeap(Consumer checker, Consumer initializer, SequenceLayout seq) { + checkByteArrayAlignment(seq.elementLayout()); int bytes = (int)seq.byteSize(); try (MemorySegment nativeArray = MemorySegment.allocateNative(seq); MemorySegment heapArray = MemorySegment.ofArray(new byte[bytes])) { diff --git a/test/jdk/java/foreign/TestMemoryAlignment.java b/test/jdk/java/foreign/TestMemoryAlignment.java index f8330bcfd53..999fd759912 100644 --- a/test/jdk/java/foreign/TestMemoryAlignment.java +++ b/test/jdk/java/foreign/TestMemoryAlignment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +23,7 @@ /* * @test + * @requires vm.bits != "32" * @run testng TestMemoryAlignment */ diff --git a/test/jdk/java/foreign/TestSegments.java b/test/jdk/java/foreign/TestSegments.java index 128e773b35a..298cf0c7290 100644 --- a/test/jdk/java/foreign/TestSegments.java +++ b/test/jdk/java/foreign/TestSegments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,8 @@ public class TestSegments { MemorySegment.allocateNative(layout); } - @Test(expectedExceptions = OutOfMemoryError.class) + @Test(expectedExceptions = { OutOfMemoryError.class, + IllegalArgumentException.class }) public void testAllocateTooBig() { MemorySegment.allocateNative(Long.MAX_VALUE); } diff --git a/test/jdk/java/foreign/TestTypeAccess.java b/test/jdk/java/foreign/TestTypeAccess.java new file mode 100644 index 00000000000..b555f0987ac --- /dev/null +++ b/test/jdk/java/foreign/TestTypeAccess.java @@ -0,0 +1,54 @@ +/* + * 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 + * @run testng TestTypeAccess + */ + +import jdk.incubator.foreign.MemorySegment; +import jdk.incubator.foreign.MemoryLayouts; +import org.testng.annotations.*; + +import java.lang.invoke.VarHandle; +import java.lang.invoke.WrongMethodTypeException; + +public class TestTypeAccess { + + static final VarHandle INT_HANDLE = MemoryLayouts.JAVA_INT.varHandle(int.class); + + @Test(expectedExceptions=ClassCastException.class) + public void testMemoryAddressCoordinateAsString() { + try (MemorySegment s = MemorySegment.allocateNative(8)) { + int v = (int)INT_HANDLE.get("string"); + } + } + + @Test(expectedExceptions=WrongMethodTypeException.class) + public void testMemoryCoordinatePrimitive() { + try (MemorySegment s = MemorySegment.allocateNative(8)) { + int v = (int)INT_HANDLE.get(1); + } + } +} diff --git a/test/jdk/java/foreign/libNativeAccess.c b/test/jdk/java/foreign/libNativeAccess.c index edd47176b36..ef6d5d90f37 100644 --- a/test/jdk/java/foreign/libNativeAccess.c +++ b/test/jdk/java/foreign/libNativeAccess.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -16,7 +16,7 @@ * 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 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * @@ -24,88 +24,89 @@ #include "jni.h" #include +#include JNIEXPORT jbyte JNICALL Java_TestNative_getByteRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jbyte *arr = (jbyte*)addr; + jbyte *arr = (jbyte*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jbyte JNICALL Java_TestNative_getByteBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getByteRaw(env, cls, addr, index); } JNIEXPORT jchar JNICALL Java_TestNative_getCharRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jchar *arr = (jchar*)addr; + jchar *arr = (jchar*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jchar JNICALL Java_TestNative_getCharBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getCharRaw(env, cls, addr, index); } JNIEXPORT jshort JNICALL Java_TestNative_getShortRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jshort *arr = (jshort*)addr; + jshort *arr = (jshort*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jshort JNICALL Java_TestNative_getShortBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getShortRaw(env, cls, addr, index); } JNIEXPORT jint JNICALL Java_TestNative_getIntRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jint *arr = (jint*)addr; + jint *arr = (jint*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jint JNICALL Java_TestNative_getIntBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getIntRaw(env, cls, addr, index); } JNIEXPORT jfloat JNICALL Java_TestNative_getFloatRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jfloat *arr = (jfloat*)addr; + jfloat *arr = (jfloat*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jfloat JNICALL Java_TestNative_getFloatBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getFloatRaw(env, cls, addr, index); } JNIEXPORT jlong JNICALL Java_TestNative_getLongRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jlong *arr = (jlong*)addr; + jlong *arr = (jlong*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jlong JNICALL Java_TestNative_getLongBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getLongRaw(env, cls, addr, index); } JNIEXPORT jdouble JNICALL Java_TestNative_getDoubleRaw(JNIEnv *env, jclass cls, jlong addr, jint index) { - jdouble *arr = (jdouble*)addr; + jdouble *arr = (jdouble*)(uintptr_t)addr; return arr[index]; } JNIEXPORT jdouble JNICALL Java_TestNative_getDoubleBuffer(JNIEnv *env, jclass cls, jobject buf, jint index) { - jlong addr = (jlong)(*env)->GetDirectBufferAddress(env, buf); + jlong addr = (jlong)(uintptr_t)(*env)->GetDirectBufferAddress(env, buf); return Java_TestNative_getDoubleRaw(env, cls, addr, index); } diff --git a/test/jdk/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/test/jdk/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java index 91be7bdb253..7b061ed9d63 100644 --- a/test/jdk/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java +++ b/test/jdk/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java @@ -25,10 +25,10 @@ * @test LFGarbageCollectedTest * @bug 8046703 * @key randomness + * @library /lib/testlibrary /java/lang/invoke/common * @ignore 8078602 * @summary Test verifies that lambda forms are garbage collected * @author kshefov - * @library /lib/testlibrary /java/lang/invoke/common * @build jdk.test.lib.TimeLimitedRunner * @build TestMethods * @build LambdaFormTestCase diff --git a/test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java b/test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java index 3d512e3bafd..ef79d363c73 100644 --- a/test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java +++ b/test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -336,8 +336,9 @@ public class Basic { } // close channel (should cause initial read to complete) + SocketChannel peer = server.accept(); ch.close(); - server.accept().close(); + peer.close(); // check that AsynchronousCloseException is thrown try { @@ -352,7 +353,7 @@ public class Basic { ch = AsynchronousSocketChannel.open(); ch.connect(server.address()).get(); - SocketChannel peer = server.accept(); + peer = server.accept(); peer.setOption(SO_RCVBUF, 1); final AtomicReference writeException = diff --git a/test/jdk/java/text/Bidi/Bug6850113.java b/test/jdk/java/text/Bidi/Bug6850113.java index 063c347c685..94f78225e49 100644 --- a/test/jdk/java/text/Bidi/Bug6850113.java +++ b/test/jdk/java/text/Bidi/Bug6850113.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,14 +22,14 @@ */ /* * @test - * @bug 6850113 + * @bug 6850113 8174270 * @summary Verify the return value of digit() for some digits. - * @modules java.base/sun.text.normalizer + * @modules java.base/jdk.internal.icu.lang * @compile -XDignore.symbol.file=true Bug6850113.java * @run main Bug6850113 */ -import sun.text.normalizer.UCharacter; +import jdk.internal.icu.lang.UCharacter; public class Bug6850113 { diff --git a/test/jdk/java/text/Bidi/Bug7051769.java b/test/jdk/java/text/Bidi/Bug7051769.java index a0737ec0afc..a13c6775ece 100644 --- a/test/jdk/java/text/Bidi/Bug7051769.java +++ b/test/jdk/java/text/Bidi/Bug7051769.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7051769 8038092 + * @bug 7051769 8038092 8174270 * @summary verify that Bidi.toString() returns the corect result. * The second run is intended to test lazy SharedSectets init for 8038092 * @modules java.desktop @@ -40,7 +40,7 @@ public class Bug7051769 { if (System.getProperty("preloadBidi", "").equals("true")) { // Make sure the SharedSecret is lazily initialized correctly try { - Class.forName("sun.text.bidi.BidiBase"); + Class.forName("jdk.internal.icu.text.BidiBase"); System.out.println("BidiBase class has been pre-loaded."); } catch (ClassNotFoundException e) { System.out.println("BidiBase class could not be pre-loaded."); @@ -68,7 +68,7 @@ public class Bug7051769 { TextAttribute.RUN_DIRECTION_RTL); String text = "\u0623\u0643\u062a\u0648\u0628\u0631 10"; - String expected = "sun.text.bidi.BidiBase[dir: 2 baselevel: 1 length: 9 runs: [1 1 1 1 1 1 1 2 2] text: [0x623 0x643 0x62a 0x648 0x628 0x631 0x20 0x661 0x660]]"; + String expected = "jdk.internal.icu.text.BidiBase[dir: 2 baselevel: 1 length: 9 runs: [1 1 1 1 1 1 1 2 2] text: [0x623 0x643 0x62a 0x648 0x628 0x631 0x20 0x661 0x660]]"; AttributedString as = new AttributedString(text, attrNS); AttributedCharacterIterator itr = as.getIterator(); diff --git a/test/jdk/java/text/Normalizer/ConformanceTest.java b/test/jdk/java/text/Normalizer/ConformanceTest.java index bbf19edcb3d..f84494ff9e7 100644 --- a/test/jdk/java/text/Normalizer/ConformanceTest.java +++ b/test/jdk/java/text/Normalizer/ConformanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * 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,10 @@ */ /* * @test - * @bug 4221795 6565620 6959267 7070436 7198195 8032446 8221431 + * @bug 4221795 6565620 6959267 7070436 7198195 8032446 8174270 8221431 * @summary Confirm Normalizer's fundamental behavior * @library /lib/testlibrary/java/lang - * @modules java.base/sun.text java.base/sun.text.normalizer + * @modules java.base/sun.text java.base/jdk.internal.icu.text * @compile -XDignore.symbol.file ConformanceTest.java * @run main/timeout=3000 ConformanceTest */ @@ -34,14 +34,12 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; -import java.lang.reflect.Method; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.util.BitSet; import java.util.StringTokenizer; -import sun.text.normalizer.NormalizerBase; -import sun.text.normalizer.NormalizerImpl; +import jdk.internal.icu.text.NormalizerBase; /* * Conformance test for java.text.Normalizer and sun.text.Normalizer. diff --git a/test/jdk/java/text/Normalizer/ICUBasicTest.java b/test/jdk/java/text/Normalizer/ICUBasicTest.java index 9bdca11f3c1..f7e17eae7e2 100644 --- a/test/jdk/java/text/Normalizer/ICUBasicTest.java +++ b/test/jdk/java/text/Normalizer/ICUBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * 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,10 @@ */ /* * @test - * @bug 4221795 8032446 + * @bug 4221795 8032446 8174270 * @summary Confirm Normalizer's fundamental behavior. Imported from ICU4J 3.2's * src/com/ibm/icu/dev/test and modified. - * @modules java.base/sun.text java.base/sun.text.normalizer + * @modules java.base/sun.text java.base/jdk.internal.icu.text * @library /java/text/testlib * @compile -XDignore.symbol.file ICUBasicTest.java * @run main/timeout=30 ICUBasicTest @@ -39,11 +39,9 @@ */ import sun.text.Normalizer; -import sun.text.normalizer.NormalizerBase; -import sun.text.normalizer.NormalizerImpl; +import jdk.internal.icu.text.NormalizerBase; import static java.text.Normalizer.Form.*; -import static sun.text.normalizer.NormalizerBase.Mode.*; public class ICUBasicTest extends IntlTest { diff --git a/test/jdk/java/text/Normalizer/NormalizerAPITest.java b/test/jdk/java/text/Normalizer/NormalizerAPITest.java index 68dd7435af2..00deb3c843c 100644 --- a/test/jdk/java/text/Normalizer/NormalizerAPITest.java +++ b/test/jdk/java/text/Normalizer/NormalizerAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. * 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,9 +23,9 @@ /* * @test - * @bug 4221795 + * @bug 4221795 8174270 * @summary Confirm Normalizer's fundamental behavior - * @modules java.base/sun.text java.base/sun.text.normalizer + * @modules java.base/sun.text java.base/jdk.internal.icu.text * @library /java/text/testlib * @compile -XDignore.symbol.file NormalizerAPITest.java * @run main/timeout=30 NormalizerAPITest @@ -64,8 +64,8 @@ public class NormalizerAPITest extends IntlTest { static final int[] options = { 0x00, sun.text.Normalizer.UNICODE_3_2, - sun.text.normalizer.NormalizerBase.UNICODE_3_2, - sun.text.normalizer.NormalizerBase.UNICODE_LATEST, + jdk.internal.icu.text.NormalizerBase.UNICODE_3_2, + jdk.internal.icu.text.NormalizerBase.UNICODE_LATEST, }; static final String nonNullStr = "testdata"; @@ -319,7 +319,7 @@ public class NormalizerAPITest extends IntlTest { in.getClass().getSimpleName() + ") failed."); } out = sun.text.Normalizer.normalize(in, NFD, - sun.text.normalizer.NormalizerBase.UNICODE_LATEST); + jdk.internal.icu.text.NormalizerBase.UNICODE_LATEST); if (!out.equals(expected.toString())) { errln("sun.text.Normalizer.normalize(" + in.getClass().getSimpleName() + ") failed."); @@ -330,7 +330,7 @@ public class NormalizerAPITest extends IntlTest { in.getClass().getSimpleName() + ") failed."); } if (!sun.text.Normalizer.isNormalized(expected, NFD, - sun.text.normalizer.NormalizerBase.UNICODE_LATEST)) { + jdk.internal.icu.text.NormalizerBase.UNICODE_LATEST)) { errln("sun.text.Normalizer.isNormalize(" + in.getClass().getSimpleName() + ") failed."); } diff --git a/test/jdk/java/text/Normalizer/ThreadSafeTest.java b/test/jdk/java/text/Normalizer/ThreadSafeTest.java index 2a7da5f0ca8..a55af98c790 100644 --- a/test/jdk/java/text/Normalizer/ThreadSafeTest.java +++ b/test/jdk/java/text/Normalizer/ThreadSafeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. * 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,10 +23,10 @@ /* * @test - * @bug 4221795 8032446 - * @summary Confirm that java.text.Normalizer and sun.text.Normalize are + * @bug 4221795 8032446 8174270 + * @summary Confirm that java.text.Normalizer and sun.text.Normalizer are * thread-safe. - * @modules java.base/sun.text java.base/sun.text.normalizer + * @modules java.base/sun.text java.base/jdk.internal.icu.text * @compile -XDignore.symbol.file ThreadSafeTest.java * @run main/othervm -esa ThreadSafeTest 5 10 */ @@ -115,7 +115,7 @@ public class ThreadSafeTest { sun.text.Normalizer.UNICODE_3_2); testJavaNormalize(2, java.text.Normalizer.Form.NFKD); testSunNormalize(3, java.text.Normalizer.Form.NFC, - sun.text.normalizer.NormalizerBase.UNICODE_LATEST); + jdk.internal.icu.text.NormalizerBase.UNICODE_LATEST); testJavaNormalize(4, java.text.Normalizer.Form.NFD); testIsNormalized(0, java.text.Normalizer.Form.NFKC); diff --git a/test/jdk/java/util/ArrayList/SubListModCount.java b/test/jdk/java/util/ArrayList/SubListModCount.java new file mode 100644 index 00000000000..9e16d737509 --- /dev/null +++ b/test/jdk/java/util/ArrayList/SubListModCount.java @@ -0,0 +1,68 @@ +/* + * 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 8234423 + * @summary Modifying ArrayList.subList().subList() resets modCount of subList + */ + +import java.util.ArrayList; +import java.util.ConcurrentModificationException; + +public class SubListModCount { + public static void main(String[] args) { + int failures = 0; + var root = new ArrayList(); + var subList = root.subList(0, 0); + root.add(42); + try { + subList.size(); + failures++; + System.out.println("Accessing subList"); + } catch (ConcurrentModificationException expected) { + } + var subSubList = subList.subList(0, 0); + try { + subSubList.size(); + failures++; + System.out.println("Accessing subList.subList"); + } catch (ConcurrentModificationException expected) { + } + try { + subSubList.add(42); + failures++; + System.out.println("Modifying subList.subList"); + } catch (ConcurrentModificationException expected) { + } + try { + subList.size(); + failures++; + System.out.println("Accessing subList again"); + } catch (ConcurrentModificationException expected) { + } + if (failures > 0) { + throw new AssertionError(failures + " tests failed"); + } + } +} diff --git a/test/jdk/java/util/jar/JarFile/jarVerification/FooService.java b/test/jdk/java/util/jar/JarFile/jarVerification/FooService.java new file mode 100644 index 00000000000..61bdae97521 --- /dev/null +++ b/test/jdk/java/util/jar/JarFile/jarVerification/FooService.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +public abstract class FooService { } diff --git a/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java b/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java new file mode 100644 index 00000000000..4d191d7b3cd --- /dev/null +++ b/test/jdk/java/util/jar/JarFile/jarVerification/MultiProviderTest.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8234466 + * @summary attempt to trigger class loading from the classloader + * during JAR file verification + * @library /test/lib + * @build jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.process.* + * jdk.test.lib.util.JarUtils + * jdk.test.lib.JDKToolLauncher + * MultiThreadLoad FooService + * @modules java.base/jdk.internal.access:+open + * @run main MultiProviderTest + * @run main MultiProviderTest sign + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.Utils; +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.util.JarUtils; + +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.util.Arrays.asList; + +public class MultiProviderTest { + + private static final String METAINFO = "META-INF/services/FooService"; + private static String COMBO_CP = Utils.TEST_CLASS_PATH + File.pathSeparator; + private static String TEST_CLASS_PATH = System.getProperty("test.classes", "."); + private static boolean signJars = false; + static final int NUM_JARS = 5; + + + private static final String KEYSTORE = "keystore.jks"; + private static final String ALIAS = "JavaTest"; + private static final String STOREPASS = "changeit"; + private static final String KEYPASS = "changeit"; + + public static void main(String[] args) throws Throwable { + signJars = args.length >=1 && args[0].equals("sign"); + initialize(); + List cmds = new ArrayList<>(); + cmds.add(JDKToolFinder.getJDKTool("java")); + cmds.addAll(asList(Utils.getTestJavaOpts())); + cmds.addAll(List.of( + "-cp", + COMBO_CP, + "--add-opens", + "java.base/jdk.internal.access=ALL-UNNAMED", + "-Djava.util.logging.config.file=" + + Path.of(System.getProperty("test.src", "."), "logging.properties").toString(), + "MultiThreadLoad", + TEST_CLASS_PATH)); + + try { + OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(cmds.stream() + .filter(t -> !t.isEmpty()) + .toArray(String[]::new)) + .shouldHaveExitValue(0); + System.out.println("Output:" + outputAnalyzer.getOutput()); + } catch (Throwable t) { + throw new RuntimeException("Unexpected fail.", t); + } + } + + public static void initialize() throws Throwable { + if (signJars) { + genKey(); + } + for (int i = 0; i < NUM_JARS; i++) { + String p = "FooProvider" + i; + String jarName = "FooProvider" + i + ".jar"; + Path javaPath = Path.of(p + ".java"); + Path jarPath = Path.of(p + ".jar"); + String contents = "public class FooProvider" + i + " extends FooService { }"; + Files.write(javaPath, contents.getBytes()); + CompilerUtils.compile(javaPath, Path.of(System.getProperty("test.classes")), "-cp", Utils.TEST_CLASS_PATH); + createJar(jarPath, p, List.of(p)); + if (signJars) { + signJar(TEST_CLASS_PATH + File.separator + jarName); + } + COMBO_CP += TEST_CLASS_PATH + File.separator + jarName + File.pathSeparator; + } + } + + private static void createProviderConfig(Path config, String providerName) throws Exception { + Files.createDirectories(config.getParent()); + Files.write(config, providerName.getBytes(), CREATE); + } + + private static void createJar(Path jar, String provider, List files) throws Exception { + Path xdir = Path.of(provider); + createProviderConfig(xdir.resolve(METAINFO), provider); + + for (String f : files) { + Path source = Path.of(Utils.TEST_CLASSES, f + ".class"); + Path target = xdir.resolve(source.getFileName()); + Files.copy(source, target, REPLACE_EXISTING); + } + JarUtils.createJarFile(Path.of(TEST_CLASS_PATH, jar.getFileName().toString()), xdir); + } + + private static void genKey() throws Throwable { + String keytool = JDKToolFinder.getJDKTool("keytool"); + Files.deleteIfExists(Paths.get(KEYSTORE)); + ProcessTools.executeCommand(keytool, + "-J-Duser.language=en", + "-J-Duser.country=US", + "-genkey", + "-keyalg", "rsa", + "-alias", ALIAS, + "-keystore", KEYSTORE, + "-keypass", KEYPASS, + "-dname", "cn=sample", + "-storepass", STOREPASS + ).shouldHaveExitValue(0); + } + + + private static OutputAnalyzer signJar(String jarName) throws Throwable { + List args = new ArrayList<>(); + args.add("-verbose"); + args.add(jarName); + args.add(ALIAS); + + return jarsigner(args); + } + + private static OutputAnalyzer jarsigner(List extra) + throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner") + .addVMArg("-Duser.language=en") + .addVMArg("-Duser.country=US") + .addToolArg("-keystore") + .addToolArg(KEYSTORE) + .addToolArg("-storepass") + .addToolArg(STOREPASS) + .addToolArg("-keypass") + .addToolArg(KEYPASS); + for (String s : extra) { + if (s.startsWith("-J")) { + launcher.addVMArg(s.substring(2)); + } else { + launcher.addToolArg(s); + } + } + return ProcessTools.executeCommand(launcher.getCommand()); + } + +} + diff --git a/test/jdk/java/util/jar/JarFile/jarVerification/MultiThreadLoad.java b/test/jdk/java/util/jar/JarFile/jarVerification/MultiThreadLoad.java new file mode 100644 index 00000000000..c461cfc9b8c --- /dev/null +++ b/test/jdk/java/util/jar/JarFile/jarVerification/MultiThreadLoad.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.internal.access.JavaUtilJarAccess; +import jdk.internal.access.SharedSecrets; + +import java.io.*; +import java.nio.file.Path; +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.jar.JarFile; + +public class MultiThreadLoad { + + private static PrintStream out = System.err; + static String TEST_CLASS_PATH; + private static final JavaUtilJarAccess JUJA = SharedSecrets.javaUtilJarAccess(); + private static CountDownLatch cdl = new CountDownLatch(1); + + private static Set setOf(Iterable it) { + Set s = new HashSet(); + for (T t : it) + s.add(t); + return s; + } + + private static void checkEquals(Set s1, Set s2, boolean eq) { + if (s1.equals(s2) != eq) + throw new RuntimeException(String.format("%b %s : %s", + eq, s1, s2)); + } + + abstract static class TestLoader { + String name; + + TestLoader(String name) { this.name = name; } + + abstract ServiceLoader load(); + } + + static TestLoader tcclLoader = new TestLoader("Thread context class loader") { + ServiceLoader load() { + return ServiceLoader.load(FooService.class); + } + }; + + static TestLoader systemClLoader = new TestLoader("System class loader") { + ServiceLoader load() { + return ServiceLoader.load(FooService.class, ClassLoader.getSystemClassLoader()); + } + }; + + static TestLoader nullClLoader = new TestLoader("null (defer to system class loader)") { + ServiceLoader load() { + return ServiceLoader.load(FooService.class, null); + } + }; + + public static void main(String[] args) { + // keep reference to variables for the newly launced process + TEST_CLASS_PATH = args[0]; + for (TestLoader tl : Arrays.asList(tcclLoader, systemClLoader, nullClLoader)) { + test(tl); + } + } + + static void test(TestLoader tl) { + Runnable r1 = () -> { + ServiceLoader sl = tl.load(); + out.format("%s: %s%n", tl.name, sl); + + // Providers are cached + Set ps = setOf(sl); + cdl.countDown(); + checkEquals(ps, setOf(sl), true); + + // The cache can be flushed and reloaded + sl.reload(); + checkEquals(ps, setOf(sl), false); + }; + + Runnable r2 = () -> { + jarCrawler(Path.of(TEST_CLASS_PATH)); + }; + new Thread(r2).start(); + new Thread(r1).start(); + + } + + private static void jarCrawler(Path p) { + try { + // let the other thread spin up + cdl.await(); + } catch (InterruptedException e) { + // ignore + } + try { + for (int i = MultiProviderTest.NUM_JARS -1; i >= 0; i--) { + JUJA.ensureInitialization(new JarFile(TEST_CLASS_PATH + File.separator + + "FooProvider" + i + ".jar")); + } + } catch (Exception e) { + System.out.println("Exception during jar crawl: "); + e.printStackTrace(System.out); + } + + } +} diff --git a/test/jdk/java/util/jar/JarFile/jarVerification/logging.properties b/test/jdk/java/util/jar/JarFile/jarVerification/logging.properties new file mode 100644 index 00000000000..0ab0c516b1a --- /dev/null +++ b/test/jdk/java/util/jar/JarFile/jarVerification/logging.properties @@ -0,0 +1,13 @@ +############################################################ +# Configuration file for log testing +# +############################################################ + +handlers= java.util.logging.ConsoleHandler + +.level= FINE + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +jdk.event.security.level = FINE diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java index 700c895f42d..2d70233a2af 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetEndTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,6 @@ public final class TestSetEndTime { CountDownLatch closed = new CountDownLatch(1); AtomicInteger count = new AtomicInteger(); try (RecordingStream rs = new RecordingStream()) { - rs.setFlushInterval(Duration.ofSeconds(1)); rs.onEvent(e -> { count.incrementAndGet(); }); diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetFlushInterval.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetFlushInterval.java deleted file mode 100644 index 0891b37cb42..00000000000 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestSetFlushInterval.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jfr.api.consumer.recordingstream; - -import java.time.Duration; - -import jdk.jfr.consumer.RecordingStream; -import jdk.test.lib.jfr.EventNames; - -/** - * @test - * @summary Tests RecordingStream::setFlushInterval - * @key jfr - * @requires vm.hasJFR - * @library /test/lib - * @run main/othervm jdk.jfr.api.consumer.recordingstream.TestSetFlushInterval - */ -public class TestSetFlushInterval { - - public static void main(String... args) throws Exception { - Duration expectedDuration = Duration.ofMillis(1001); - try (RecordingStream r = new RecordingStream()) { - r.setFlushInterval(expectedDuration); - r.enable(EventNames.ActiveRecording); - r.onEvent(e -> { - System.out.println(e); - Duration duration = e.getDuration("flushInterval"); - if (expectedDuration.equals(duration)) { - System.out.println("Closing recording"); - r.close(); - return; - } - System.out.println("Flush interval not set, was " + duration + - ", but expected " + expectedDuration); - }); - r.start(); - } - } -} diff --git a/test/jdk/jdk/jfr/api/consumer/security/TestStreamingRemote.java b/test/jdk/jdk/jfr/api/consumer/security/TestStreamingRemote.java index ef2612f4386..370cb0a9ceb 100644 --- a/test/jdk/jdk/jfr/api/consumer/security/TestStreamingRemote.java +++ b/test/jdk/jdk/jfr/api/consumer/security/TestStreamingRemote.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,6 @@ public class TestStreamingRemote { public static void main(String... args) throws Exception { try (Recording r = new Recording()) { - r.setFlushInterval(Duration.ofSeconds(1)); r.start(); String repository = System.getProperty("jdk.jfr.repository"); Path policy = createPolicyFile(repository); diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java index eb701deb45d..61f54815c04 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestInProcessMigration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,6 @@ public class TestInProcessMigration { System.out.println("Started es.startAsync()"); try (Recording r = new Recording()) { - r.setFlushInterval(Duration.ofSeconds(1)); r.start(); // Chunk in default repository MigrationEvent e1 = new MigrationEvent(); diff --git a/test/jdk/jdk/jfr/api/recording/time/TestSetFlushInterval.java b/test/jdk/jdk/jfr/api/recording/time/TestSetFlushInterval.java deleted file mode 100644 index 3b73533dcd6..00000000000 --- a/test/jdk/jdk/jfr/api/recording/time/TestSetFlushInterval.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.jfr.api.recording.time; - -import java.time.Duration; -import java.util.concurrent.CountDownLatch; - -import jdk.jfr.Recording; -import jdk.jfr.consumer.EventStream; -import jdk.test.lib.Asserts; - -/** - * @test - * @key jfr - * @summary Test Recording::SetFlushInterval(...) and - * Recording::getFlushInterval() - * @requires vm.hasJFR - * @library /test/lib - * @run main/othervm jdk.jfr.api.recording.time.TestSetFlushInterval - */ - -public class TestSetFlushInterval { - - public static void main(String[] args) throws Throwable { - testSetGet(); - testSetNull(); - testFlush(); - } - - static void testFlush() throws Exception { - CountDownLatch flush = new CountDownLatch(1); - try (EventStream es = EventStream.openRepository()) { - es.onFlush(() -> { - flush.countDown(); - }); - es.startAsync(); - try (Recording r = new Recording()) { - r.setFlushInterval(Duration.ofSeconds(1)); - r.start(); - flush.await(); - } - } - } - - static void testSetNull() { - try (Recording r = new Recording()) { - r.setFlushInterval(null); - Asserts.fail("Expected NullPointerException"); - } catch (NullPointerException npe) { - // as expected - } - } - - static void testSetGet() { - try (Recording r = new Recording()) { - Duration a = Duration.ofNanos(21378461289374646L); - r.setFlushInterval(a); - Duration b = r.getFlushInterval(); - Asserts.assertEQ(a, b); - } - } - -} diff --git a/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java index 882af097735..88c50be949a 100644 --- a/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java +++ b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * 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 java.time.Duration; import jdk.jfr.FlightRecorder; import jdk.jfr.Recording; +import jdk.jfr.internal.PlatformRecording; +import jdk.jfr.internal.PrivateAccess; /** * @test @@ -36,14 +38,17 @@ import jdk.jfr.Recording; * @key jfr * @requires vm.hasJFR * @library /test/lib /test/jdk - * @run main/othervm -XX:StartFlightRecording=flush-interval=1s jdk.jfr.startupargs.TestFlushInterval + * @modules jdk.jfr/jdk.jfr.internal + * @run main/othervm -XX:StartFlightRecording=flush-interval=2s jdk.jfr.startupargs.TestFlushInterval */ public class TestFlushInterval { public static void main(String[] args) throws Exception { for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { - Duration d = r.getFlushInterval(); - if (d.equals(Duration.ofSeconds(1))) { + PrivateAccess p = PrivateAccess.getInstance(); + PlatformRecording pr = p.getPlatformRecording(r); + Duration d = pr.getFlushInterval(); + if (d.equals(Duration.ofSeconds(2))) { return; //OK } else { throw new Exception("Unexpected flush-interval " + d); diff --git a/test/jdk/sun/net/idn/NFS4StringPrep.java b/test/jdk/sun/net/idn/NFS4StringPrep.java index e1dbe925407..86bdaadc338 100644 --- a/test/jdk/sun/net/idn/NFS4StringPrep.java +++ b/test/jdk/sun/net/idn/NFS4StringPrep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +32,8 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.text.ParseException; -import sun.net.idn.StringPrep; -import sun.text.normalizer.UCharacterIterator; +import jdk.internal.icu.text.StringPrep; +import jdk.internal.icu.text.UCharacterIterator; /** * @author ram diff --git a/test/jdk/sun/net/idn/PunycodeTest.java b/test/jdk/sun/net/idn/PunycodeTest.java index 7fe0bc6adbc..ce11f981942 100644 --- a/test/jdk/sun/net/idn/PunycodeTest.java +++ b/test/jdk/sun/net/idn/PunycodeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,17 +23,16 @@ /* * @test - * @summary Unit test for sun.net.idn.Punycode - * @bug 4737170 - * @modules java.base/sun.net.idn + * @summary Unit test for jdk.internal.icu.impl.Punycode + * @bug 4737170 8174270 + * @modules java.base/jdk.internal.icu.impl * @compile -XDignore.symbol.file PunycodeTest.java * @run main/othervm -ea PunycodeTest * @author Edward Wang */ import java.util.Scanner; -import java.text.ParseException; -import sun.net.idn.Punycode; +import jdk.internal.icu.impl.Punycode; /** * unit test for Punycode that is also originated from the sample code diff --git a/test/jdk/sun/net/idn/TestStringPrep.java b/test/jdk/sun/net/idn/TestStringPrep.java index 95340ae720f..6ee0db7fc28 100644 --- a/test/jdk/sun/net/idn/TestStringPrep.java +++ b/test/jdk/sun/net/idn/TestStringPrep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,10 +23,9 @@ /* * @test - * @summary Unit test for sun.net.idn.Punycode - * @bug 4737170 8060097 - * @modules java.base/sun.net.idn:+open - * java.base/sun.text.normalizer + * @summary Unit test for jdk.internal.icu.text.StringPrep + * @bug 4737170 8060097 8174270 + * @modules java.base/jdk.internal.icu.text * @library . * @compile -XDignore.symbol.file TestStringPrep.java NFS4StringPrep.java * TestData.java @@ -44,8 +43,8 @@ import java.text.ParseException; import java.io.InputStream; import java.util.Locale; -import sun.net.idn.StringPrep; -import sun.text.normalizer.UCharacterIterator; +import jdk.internal.icu.text.StringPrep; +import jdk.internal.icu.text.UCharacterIterator; public class TestStringPrep { public static void main(String[] args) throws Exception { diff --git a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java index cbc12528e6a..a51d5d63612 100644 --- a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ import tests.Result; /* * @test * @bug 8152143 8152704 8155649 8165804 8185841 8176841 8190918 - * 8179071 8202537 8221432 + * 8179071 8202537 8221432 8222098 * @summary IncludeLocalesPlugin tests * @author Naoto Sato * @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g) @@ -56,7 +56,7 @@ import tests.Result; * jdk.compiler * @build tests.* * @build tools.jlink.plugins.GetAvailableLocales - * @run main/othervm -Xmx1g IncludeLocalesPluginTest + * @run main/othervm/timeout=180 -Xmx1g IncludeLocalesPluginTest */ public class IncludeLocalesPluginTest { diff --git a/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java b/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java index fd4f640f6fc..3f0beca3aeb 100644 --- a/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java +++ b/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java @@ -51,15 +51,15 @@ public class AccessSkipNav extends JavadocTester { checkOutput("p1/C1.html", true, // Top navbar "Skip navigation links", - // Top navbar - "\n" + // Top navbar + "\n" + "\n" - + "", + + "", // Bottom navbar "Skip navigation links", - // Bottom navbar - "\n" + // Bottom navbar + "\n" + "\n" - + ""); + + ""); } } diff --git a/test/langtools/jdk/javadoc/doclet/constantValues/TestConstantValuesDriver.java b/test/langtools/jdk/javadoc/doclet/constantValues/TestConstantValuesDriver.java index 79b9c08c053..13e611158e2 100644 --- a/test/langtools/jdk/javadoc/doclet/constantValues/TestConstantValuesDriver.java +++ b/test/langtools/jdk/javadoc/doclet/constantValues/TestConstantValuesDriver.java @@ -53,29 +53,29 @@ public class TestConstantValuesDriver extends JavadocTester { "TEST3PASSES", "TEST4PASSES", "\"<Hello World>\"", - "public static final byte\n" + + "public static final byte\n" + "" + "BYTE_MAX_VALUE\n" + "127", - "public static final byte\n" + + "public static final byte\n" + "" + "BYTE_MIN_VALUE\n" + "-127", - "public static final char\n" + + "public static final char\n" + "" + "CHAR_MAX_VALUE\n" + "65535", - "public static final double", + "public static final double", "" + "DOUBLE_MAX_VALUE\n" + "1.7976931348623157E308", - "public static final double\n" + + "public static final double\n" + "" + "DOUBLE_MIN_VALUE", - "public static final boolean\n" + + "public static final boolean\n" + "" + "GOODBYE", - "public static final boolean\n" + + "public static final boolean\n" + "HELLO\n" + "true" ); diff --git a/test/langtools/jdk/javadoc/doclet/testAnchorNames/TestAnchorNames.java b/test/langtools/jdk/javadoc/doclet/testAnchorNames/TestAnchorNames.java index 7fcd14b07c2..dff15cdab6d 100644 --- a/test/langtools/jdk/javadoc/doclet/testAnchorNames/TestAnchorNames.java +++ b/test/langtools/jdk/javadoc/doclet/testAnchorNames/TestAnchorNames.java @@ -61,15 +61,19 @@ public class TestAnchorNames extends JavadocTester { // Test some section markers and links to these markers checkOutput("pkg1/RegClass.html", true, - "", + "", "", - "", + "

\n" + + "

Nested Class Summary

", "
", - "", + "
\n" + + "

Method Summary

", "
", - "", + "
\n" + + "

Field Details

", "
", - "", + "
\n" + + "

Constructor Details

", "
"); // Test some members and link to these members @@ -80,59 +84,59 @@ public class TestAnchorNames extends JavadocTester { // Test some fields checkOutput("pkg1/RegClass.html", true, - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", ""); checkOutput("pkg1/DeprMemClass.html", true, - "", + "
", ""); // Test constructor checkOutput("pkg1/RegClass.html", true, - "", + "
", ""); // Test some methods checkOutput("pkg1/RegClass.html", true, - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", "", - "", + "
", ""); checkOutput("pkg1/DeprMemClass.html", true, - "", + "
", ""); // Test enum checkOutput("pkg1/RegClass.Te$t_Enum.html", true, - "", + "
", ""); // Test nested class checkOutput("pkg1/RegClass._NestedClas$.html", true, - "", + "
", ""); // Test class use page @@ -151,11 +155,11 @@ public class TestAnchorNames extends JavadocTester { // Test serialized form page checkOutput("serialized-form.html", true, //This is the marker for the link that appears in the pkg1.RegClass.html page - ""); + "
"); // Test member name index page checkOutput("index-all.html", true, - "", + "

$

", "
$", "_"); } @@ -194,10 +198,10 @@ public class TestAnchorNames extends JavadocTester { checkExit(Exit.OK); checkOutput("p/Def.html", true, - "", - "", - "", - ""); + "
", + "
", + "
", + "
"); checkOutput("p/Ref.html", true, "àé", diff --git a/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java b/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java index 4aede79cb7b..6a2b73edd45 100644 --- a/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java +++ b/test/langtools/jdk/javadoc/doclet/testAnnotationOptional/TestAnnotationOptional.java @@ -49,6 +49,6 @@ public class TestAnnotationOptional extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg/AnnotationOptional.html", true, - ""); + "
"); } } diff --git a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java index db342246064..1d9d628b823 100644 --- a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java +++ b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java @@ -60,7 +60,8 @@ public class TestAnnotationTypes extends JavadocTester { "DEFAULT_NAME" + "", "", - "

DEFAULT_NAME

\n" + "
\n" + + "

DEFAULT_NAME

\n" + "
static final " + "java.lang.String " + "DEFAULT_NAME
\n"); @@ -75,15 +76,14 @@ public class TestAnnotationTypes extends JavadocTester { "", "