diff --git a/.hgtags b/.hgtags index 6c9bae85cd4..df941df95c2 100644 --- a/.hgtags +++ b/.hgtags @@ -266,3 +266,5 @@ c5495e25c7258ab5f96a1ae14610887d76d2be63 jdk9-b18 28dd0c7beb3cad9cf95f17b4b5ad87eb447a4084 jdk9-b21 9678e0db8ff6ed845d4c2ee4a3baf7f386a777e5 jdk9-b22 39cfdc2dcaf3f195c55398e4e677ab053b07e3d2 jdk9-b23 +d9ce05f36ffec3e5e8af62a92455c1c66a63c320 jdk9-b24 +13a5c76976fe48e55c9727c25fae2d2ce7c05da0 jdk9-b25 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 4748a943834..fe5540a5d8e 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -266,3 +266,5 @@ ee4fd72b2ec3d92497f37163352f294aa695c6fb jdk9-b20 9052803f4d01feda28b3d65f2b64dd457d21c7b6 jdk9-b21 8e4bdab4c362aadde2d321f968cd503a2f779e2f jdk9-b22 88567461a2cd9b7fb431fee6440005a694df1f47 jdk9-b23 +1d4a293fbec19dc2d5790bbb2c7dd0ed8f265484 jdk9-b24 +aefd8899a8d6615fb34ba99b2e38996a7145baa8 jdk9-b25 diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 57465032e77..39216b544a6 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -4311,7 +4311,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1404942241 +DATE_WHEN_GENERATED=1405336663 ############################################################################### # @@ -14548,7 +14548,7 @@ $as_echo "$with_jvm_variants" >&6; } if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then INCLUDE_SA=false fi - if test "x$VAR_CPU" = xppc64 ; then + if test "x$OPENJDK_TARGET_OS" = xaix ; then INCLUDE_SA=false fi diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index b012aa756b4..75affdeeeef 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -158,7 +158,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JVM_VARIANTS], if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then INCLUDE_SA=false fi - if test "x$VAR_CPU" = xppc64 ; then + if test "x$OPENJDK_TARGET_OS" = xaix ; then INCLUDE_SA=false fi AC_SUBST(INCLUDE_SA) diff --git a/corba/.hgtags b/corba/.hgtags index a6c27d443ef..80f38489230 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -266,3 +266,5 @@ eecc1b6adc7e193d00a0641eb0963add5a4c06e8 jdk9-b19 3615a4e7f0542ca7552ad6454b742c73ee211d8e jdk9-b21 ddc07abf4307855c0dc904cc5c96cc764023a930 jdk9-b22 57735d66face054440a63ce99789eac5a5ee1dfd jdk9-b23 +8a44142bb7fc8118f70f91a1b97c12dfc50563ee jdk9-b24 +da08cca6b97f41b7081a3e176dcb400af6e4bb26 jdk9-b25 diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 41a4099fc84..a39d162f8d8 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -426,3 +426,5 @@ c1af79d122ec9f715fa29312b5e91763f3a4dfc4 jdk9-b20 17b4a5e831b398738feedb0afe75245744510153 jdk9-b21 518d1fcc0799494f013e00e0a94a91b6f212d54f jdk9-b22 dd472cdacc32e3afc7c5bfa7ef16ea0e0befb7fa jdk9-b23 +dde2d03b0ea46a27650839e3a1d212c7c1f7b4c8 jdk9-b24 +6de94e8693240cec8aae11f6b42f43433456a733 jdk9-b25 diff --git a/hotspot/agent/src/os/solaris/proc/saproc.cpp b/hotspot/agent/src/os/solaris/proc/saproc.cpp index 2af5eba6307..3f0e6b25814 100644 --- a/hotspot/agent/src/os/solaris/proc/saproc.cpp +++ b/hotspot/agent/src/os/solaris/proc/saproc.cpp @@ -314,7 +314,7 @@ static void * pathmap_dlopen(const char * name, int mode) { handle = dlopen(name, mode); } if (_libsaproc_debug) { - printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%x\n", name, handle); + printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%lx\n", name, (unsigned long) handle); } return handle; } diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make index 00db453d5f8..5aabf4c52ac 100644 --- a/hotspot/make/excludeSrc.make +++ b/hotspot/make/excludeSrc.make @@ -119,8 +119,8 @@ ifeq ($(INCLUDE_NMT), false) CFLAGS += -DINCLUDE_NMT=0 Src_Files_EXCLUDE += \ - memBaseline.cpp memPtr.cpp memRecorder.cpp memReporter.cpp memSnapshot.cpp memTrackWorker.cpp \ - memTracker.cpp nmtDCmd.cpp + memBaseline.cpp memReporter.cpp mallocTracker.cpp virtualMemoryTracker.cpp nmtCommon.cpp \ + memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp endif -include $(HS_ALT_MAKE)/excludeSrc.make diff --git a/hotspot/make/jprt.properties b/hotspot/make/jprt.properties index a6ff452c2ce..252216f32b5 100644 --- a/hotspot/make/jprt.properties +++ b/hotspot/make/jprt.properties @@ -356,14 +356,15 @@ jprt.make.rule.test.targets.standard.internalvmtests = \ ${jprt.my.windows.x64}-fastdebug-c2-internalvmtests jprt.make.rule.test.targets.standard.reg.group = \ - ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GROUP, \ - ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GROUP, \ - ${jprt.my.linux.i586}-{product|fastdebug}-c2-GROUP, \ - ${jprt.my.linux.x64}-{product|fastdebug}-c2-GROUP, \ - ${jprt.my.windows.i586}-{product|fastdebug}-c2-GROUP, \ - ${jprt.my.windows.x64}-{product|fastdebug}-c2-GROUP, \ - ${jprt.my.linux.i586}-{product|fastdebug}-c1-GROUP, \ - ${jprt.my.windows.i586}-{product|fastdebug}-c1-GROUP + ${jprt.my.solaris.sparcv9}-fastdebug-c2-GROUP, \ + ${jprt.my.solaris.x64}-fastdebug-c2-GROUP, \ + ${jprt.my.linux.i586}-fastdebug-c2-GROUP, \ + ${jprt.my.linux.x64}-fastdebug-c2-GROUP, \ + ${jprt.my.macosx.x64}-fastdebug-c2-GROUP, \ + ${jprt.my.windows.i586}-fastdebug-c2-GROUP, \ + ${jprt.my.windows.x64}-fastdebug-c2-GROUP, \ + ${jprt.my.linux.i586}-fastdebug-c1-GROUP, \ + ${jprt.my.windows.i586}-fastdebug-c1-GROUP jprt.make.rule.test.targets.standard = \ ${jprt.make.rule.test.targets.standard.client}, \ diff --git a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp index 5a1c0f1d9c8..0c8cf435aea 100644 --- a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp @@ -298,6 +298,7 @@ class Assembler : public AbstractAssembler { LWZ_OPCODE = (32u << OPCODE_SHIFT), LWZX_OPCODE = (31u << OPCODE_SHIFT | 23u << 1), LWZU_OPCODE = (33u << OPCODE_SHIFT), + LWBRX_OPCODE = (31u << OPCODE_SHIFT | 534 << 1), LHA_OPCODE = (42u << OPCODE_SHIFT), LHAX_OPCODE = (31u << OPCODE_SHIFT | 343u << 1), @@ -306,6 +307,7 @@ class Assembler : public AbstractAssembler { LHZ_OPCODE = (40u << OPCODE_SHIFT), LHZX_OPCODE = (31u << OPCODE_SHIFT | 279u << 1), LHZU_OPCODE = (41u << OPCODE_SHIFT), + LHBRX_OPCODE = (31u << OPCODE_SHIFT | 790 << 1), LBZ_OPCODE = (34u << OPCODE_SHIFT), LBZX_OPCODE = (31u << OPCODE_SHIFT | 87u << 1), @@ -1364,11 +1366,17 @@ class Assembler : public AbstractAssembler { inline void lwax( Register d, Register s1, Register s2); inline void lwa( Register d, int si16, Register s1); + // 4 bytes reversed + inline void lwbrx( Register d, Register s1, Register s2); + // 2 bytes inline void lhzx( Register d, Register s1, Register s2); inline void lhz( Register d, int si16, Register s1); inline void lhzu( Register d, int si16, Register s1); + // 2 bytes reversed + inline void lhbrx( Register d, Register s1, Register s2); + // 2 bytes inline void lhax( Register d, Register s1, Register s2); inline void lha( Register d, int si16, Register s1); @@ -1858,10 +1866,12 @@ class Assembler : public AbstractAssembler { inline void lwz( Register d, int si16); inline void lwax( Register d, Register s2); inline void lwa( Register d, int si16); + inline void lwbrx(Register d, Register s2); inline void lhzx( Register d, Register s2); inline void lhz( Register d, int si16); inline void lhax( Register d, Register s2); inline void lha( Register d, int si16); + inline void lhbrx(Register d, Register s2); inline void lbzx( Register d, Register s2); inline void lbz( Register d, int si16); inline void ldx( Register d, Register s2); diff --git a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp index 3b7eb5f55e5..87db4bff89d 100644 --- a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp +++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp @@ -263,10 +263,14 @@ inline void Assembler::lwzu( Register d, int si16, Register s1) { assert(d != inline void Assembler::lwax( Register d, Register s1, Register s2) { emit_int32(LWAX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} inline void Assembler::lwa( Register d, int si16, Register s1) { emit_int32(LWA_OPCODE | rt(d) | ds(si16) | ra0mem(s1));} +inline void Assembler::lwbrx( Register d, Register s1, Register s2) { emit_int32(LWBRX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} + inline void Assembler::lhzx( Register d, Register s1, Register s2) { emit_int32(LHZX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} inline void Assembler::lhz( Register d, int si16, Register s1) { emit_int32(LHZ_OPCODE | rt(d) | d1(si16) | ra0mem(s1));} inline void Assembler::lhzu( Register d, int si16, Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LHZU_OPCODE | rt(d) | d1(si16) | rta0mem(s1));} +inline void Assembler::lhbrx( Register d, Register s1, Register s2) { emit_int32(LHBRX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} + inline void Assembler::lhax( Register d, Register s1, Register s2) { emit_int32(LHAX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} inline void Assembler::lha( Register d, int si16, Register s1) { emit_int32(LHA_OPCODE | rt(d) | d1(si16) | ra0mem(s1));} inline void Assembler::lhau( Register d, int si16, Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LHAU_OPCODE | rt(d) | d1(si16) | rta0mem(s1));} @@ -736,10 +740,12 @@ inline void Assembler::lwzx( Register d, Register s2) { emit_int32( LWZX_OPCODE inline void Assembler::lwz( Register d, int si16 ) { emit_int32( LWZ_OPCODE | rt(d) | d1(si16));} inline void Assembler::lwax( Register d, Register s2) { emit_int32( LWAX_OPCODE | rt(d) | rb(s2));} inline void Assembler::lwa( Register d, int si16 ) { emit_int32( LWA_OPCODE | rt(d) | ds(si16));} +inline void Assembler::lwbrx(Register d, Register s2) { emit_int32( LWBRX_OPCODE| rt(d) | rb(s2));} inline void Assembler::lhzx( Register d, Register s2) { emit_int32( LHZX_OPCODE | rt(d) | rb(s2));} inline void Assembler::lhz( Register d, int si16 ) { emit_int32( LHZ_OPCODE | rt(d) | d1(si16));} inline void Assembler::lhax( Register d, Register s2) { emit_int32( LHAX_OPCODE | rt(d) | rb(s2));} inline void Assembler::lha( Register d, int si16 ) { emit_int32( LHA_OPCODE | rt(d) | d1(si16));} +inline void Assembler::lhbrx(Register d, Register s2) { emit_int32( LHBRX_OPCODE| rt(d) | rb(s2));} inline void Assembler::lbzx( Register d, Register s2) { emit_int32( LBZX_OPCODE | rt(d) | rb(s2));} inline void Assembler::lbz( Register d, int si16 ) { emit_int32( LBZ_OPCODE | rt(d) | d1(si16));} inline void Assembler::ld( Register d, int si16 ) { emit_int32( LD_OPCODE | rt(d) | ds(si16));} diff --git a/hotspot/src/cpu/ppc/vm/cppInterpreterGenerator_ppc.hpp b/hotspot/src/cpu/ppc/vm/cppInterpreterGenerator_ppc.hpp index 6e43183ea3f..94cbe0ac24a 100644 --- a/hotspot/src/cpu/ppc/vm/cppInterpreterGenerator_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/cppInterpreterGenerator_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright 2012, 2013 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,8 +26,9 @@ #ifndef CPU_PPC_VM_CPPINTERPRETERGENERATOR_PPC_HPP #define CPU_PPC_VM_CPPINTERPRETERGENERATOR_PPC_HPP - address generate_normal_entry(void); - address generate_native_entry(void); + address generate_normal_entry(bool synchronized); + address generate_native_entry(bool synchronized); + address generate_math_entry(AbstractInterpreter::MethodKind kind) { return NULL; } void lock_method(void); void unlock_method(void); diff --git a/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp b/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp index 8a9534e260d..3ff878b9328 100644 --- a/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp @@ -938,8 +938,9 @@ void CppInterpreterGenerator::generate_counter_incr(Label& overflow) { // Interpreter stub for calling a native method. (C++ interpreter) // This sets up a somewhat different looking stack for calling the native method // than the typical interpreter frame setup. +// The synchronized parameter is ignored. // -address CppInterpreterGenerator::generate_native_entry(void) { +address CppInterpreterGenerator::generate_native_entry(bool synchronized) { if (native_entry != NULL) return native_entry; address entry = __ pc(); @@ -1729,7 +1730,8 @@ void CppInterpreterGenerator::generate_more_monitors() { __ std(R0, BasicObjectLock::obj_offset_in_bytes(), stack_base); // Mark lock as unused } -address CppInterpreterGenerator::generate_normal_entry(void) { +// The synchronized parameter is ignored +address CppInterpreterGenerator::generate_normal_entry(bool synchronized) { if (interpreter_frame_manager != NULL) return interpreter_frame_manager; address entry = __ pc(); @@ -2789,38 +2791,6 @@ address CppInterpreterGenerator::generate_normal_entry(void) { return interpreter_frame_manager; } -// Generate code for various sorts of method entries -// -address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) { - address entry_point = NULL; - - switch (kind) { - case Interpreter::zerolocals : break; - case Interpreter::zerolocals_synchronized : break; - case Interpreter::native : // Fall thru - case Interpreter::native_synchronized : entry_point = ((CppInterpreterGenerator*)this)->generate_native_entry(); break; - case Interpreter::empty : break; - case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break; - case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break; - // These are special interpreter intrinsics which we don't support so far. - case Interpreter::java_lang_math_sin : break; - case Interpreter::java_lang_math_cos : break; - case Interpreter::java_lang_math_tan : break; - case Interpreter::java_lang_math_abs : break; - case Interpreter::java_lang_math_log : break; - case Interpreter::java_lang_math_log10 : break; - case Interpreter::java_lang_math_sqrt : break; - case Interpreter::java_lang_math_pow : break; - case Interpreter::java_lang_math_exp : break; - case Interpreter::java_lang_ref_reference_get: entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break; - default : ShouldNotReachHere(); break; - } - - if (entry_point) { - return entry_point; - } - return ((InterpreterGenerator*)this)->generate_normal_entry(); -} InterpreterGenerator::InterpreterGenerator(StubQueue* code) : CppInterpreterGenerator(code) { diff --git a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp index 98c34b15a33..a47f9f56593 100644 --- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp +++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp @@ -119,9 +119,15 @@ void InterpreterMacroAssembler::check_and_handle_popframe(Register scratch_reg) // Call the Interpreter::remove_activation_preserving_args_entry() // func to get the address of the same-named entrypoint in the // generated interpreter code. +#if defined(ABI_ELFv2) + call_c(CAST_FROM_FN_PTR(address, + Interpreter::remove_activation_preserving_args_entry), + relocInfo::none); +#else call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, Interpreter::remove_activation_preserving_args_entry), relocInfo::none); +#endif // Jump to Interpreter::_remove_activation_preserving_args_entry. mtctr(R3_RET); @@ -331,29 +337,40 @@ void InterpreterMacroAssembler::empty_expression_stack() { void InterpreterMacroAssembler::get_2_byte_integer_at_bcp(int bcp_offset, Register Rdst, signedOrNot is_signed) { +#if defined(VM_LITTLE_ENDIAN) + if (bcp_offset) { + load_const_optimized(Rdst, bcp_offset); + lhbrx(Rdst, R14_bcp, Rdst); + } else { + lhbrx(Rdst, R14_bcp); + } + if (is_signed == Signed) { + extsh(Rdst, Rdst); + } +#else // Read Java big endian format. if (is_signed == Signed) { lha(Rdst, bcp_offset, R14_bcp); } else { lhz(Rdst, bcp_offset, R14_bcp); } -#if 0 - assert(Rtmp != Rdst, "need separate temp register"); - Register Rfirst = Rtmp; - lbz(Rfirst, bcp_offset, R14_bcp); // first byte - lbz(Rdst, bcp_offset+1, R14_bcp); // second byte - - // Rdst = ((Rfirst<<8) & 0xFF00) | (Rdst &~ 0xFF00) - rldimi(/*RA=*/Rdst, /*RS=*/Rfirst, /*sh=*/8, /*mb=*/48); - if (is_signed == Signed) { - extsh(Rdst, Rdst); - } #endif } void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(int bcp_offset, Register Rdst, signedOrNot is_signed) { +#if defined(VM_LITTLE_ENDIAN) + if (bcp_offset) { + load_const_optimized(Rdst, bcp_offset); + lwbrx(Rdst, R14_bcp, Rdst); + } else { + lwbrx(Rdst, R14_bcp); + } + if (is_signed == Signed) { + extsw(Rdst, Rdst); + } +#else // Read Java big endian format. if (bcp_offset & 3) { // Offset unaligned? load_const_optimized(Rdst, bcp_offset); @@ -369,18 +386,26 @@ void InterpreterMacroAssembler::get_4_byte_integer_at_bcp(int bcp_offset lwz(Rdst, bcp_offset, R14_bcp); } } +#endif } + // Load the constant pool cache index from the bytecode stream. // // Kills / writes: // - Rdst, Rscratch void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size) { assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); + // Cache index is always in the native format, courtesy of Rewriter. if (index_size == sizeof(u2)) { - get_2_byte_integer_at_bcp(bcp_offset, Rdst, Unsigned); + lhz(Rdst, bcp_offset, R14_bcp); } else if (index_size == sizeof(u4)) { - get_4_byte_integer_at_bcp(bcp_offset, Rdst, Signed); + if (bcp_offset & 3) { + load_const_optimized(Rdst, bcp_offset); + lwax(Rdst, R14_bcp, Rdst); + } else { + lwa(Rdst, bcp_offset, R14_bcp); + } assert(ConstantPool::decode_invokedynamic_index(~123) == 123, "else change next line"); nand(Rdst, Rdst, Rdst); // convert to plain index } else if (index_size == sizeof(u1)) { @@ -397,6 +422,29 @@ void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int b add(cache, R27_constPoolCache, cache); } +// Load 4-byte signed or unsigned integer in Java format (that is, big-endian format) +// from (Rsrc)+offset. +void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset, + signedOrNot is_signed) { +#if defined(VM_LITTLE_ENDIAN) + if (offset) { + load_const_optimized(Rdst, offset); + lwbrx(Rdst, Rdst, Rsrc); + } else { + lwbrx(Rdst, Rsrc); + } + if (is_signed == Signed) { + extsw(Rdst, Rdst); + } +#else + if (is_signed == Signed) { + lwa(Rdst, offset, Rsrc); + } else { + lwz(Rdst, offset, Rsrc); + } +#endif +} + // Load object from cpool->resolved_references(index). void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index) { assert_different_registers(result, index); diff --git a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.hpp b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.hpp index b4c95a6458c..37c743228e9 100644 --- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.hpp +++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.hpp @@ -130,6 +130,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2)); + void get_u4(Register Rdst, Register Rsrc, int offset, signedOrNot is_signed); // common code diff --git a/hotspot/src/cpu/ppc/vm/interpreterGenerator_ppc.hpp b/hotspot/src/cpu/ppc/vm/interpreterGenerator_ppc.hpp index 74f6001e766..d4f53f0accc 100644 --- a/hotspot/src/cpu/ppc/vm/interpreterGenerator_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/interpreterGenerator_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright 2012, 2013 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -31,7 +31,12 @@ private: address generate_abstract_entry(void); - address generate_accessor_entry(void); + address generate_jump_to_normal_entry(void); + address generate_accessor_entry(void) { return generate_jump_to_normal_entry(); } + address generate_empty_entry(void) { return generate_jump_to_normal_entry(); } address generate_Reference_get_entry(void); + // Not supported + address generate_CRC32_update_entry() { return NULL; } + address generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) { return NULL; } #endif // CPU_PPC_VM_INTERPRETERGENERATOR_PPC_HPP diff --git a/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp b/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp index 96814188f03..d64da8ea17a 100644 --- a/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/interpreter_ppc.cpp @@ -428,6 +428,19 @@ address AbstractInterpreterGenerator::generate_result_handler_for(BasicType type return entry; } + +// Call an accessor method (assuming it is resolved, otherwise drop into +// vanilla (slow path) entry. +address InterpreterGenerator::generate_jump_to_normal_entry(void) { + address entry = __ pc(); + address normal_entry = Interpreter::entry_for_kind(Interpreter::zerolocals); + assert(normal_entry != NULL, "should already be generated."); + __ branch_to_entry(normal_entry, R11_scratch1); + __ flush(); + + return entry; +} + // Abstract method entry. // address InterpreterGenerator::generate_abstract_entry(void) { @@ -485,203 +498,6 @@ address InterpreterGenerator::generate_abstract_entry(void) { return entry; } -// Call an accessor method (assuming it is resolved, otherwise drop into -// vanilla (slow path) entry. -address InterpreterGenerator::generate_accessor_entry(void) { - if (!UseFastAccessorMethods && (!FLAG_IS_ERGO(UseFastAccessorMethods))) { - return NULL; - } - - Label Lslow_path, Lacquire; - - const Register - Rclass_or_obj = R3_ARG1, - Rconst_method = R4_ARG2, - Rcodes = Rconst_method, - Rcpool_cache = R5_ARG3, - Rscratch = R11_scratch1, - Rjvmti_mode = Rscratch, - Roffset = R12_scratch2, - Rflags = R6_ARG4, - Rbtable = R7_ARG5; - - static address branch_table[number_of_states]; - - address entry = __ pc(); - - // Check for safepoint: - // Ditch this, real man don't need safepoint checks. - - // Also check for JVMTI mode - // Check for null obj, take slow path if so. - __ ld(Rclass_or_obj, Interpreter::stackElementSize, CC_INTERP_ONLY(R17_tos) NOT_CC_INTERP(R15_esp)); - __ lwz(Rjvmti_mode, thread_(interp_only_mode)); - __ cmpdi(CCR1, Rclass_or_obj, 0); - __ cmpwi(CCR0, Rjvmti_mode, 0); - __ crorc(/*CCR0 eq*/2, /*CCR1 eq*/4+2, /*CCR0 eq*/2); - __ beq(CCR0, Lslow_path); // this==null or jvmti_mode!=0 - - // Do 2 things in parallel: - // 1. Load the index out of the first instruction word, which looks like this: - // <0x2a><0xb4>. - // 2. Load constant pool cache base. - __ ld(Rconst_method, in_bytes(Method::const_offset()), R19_method); - __ ld(Rcpool_cache, in_bytes(ConstMethod::constants_offset()), Rconst_method); - - __ lhz(Rcodes, in_bytes(ConstMethod::codes_offset()) + 2, Rconst_method); // Lower half of 32 bit field. - __ ld(Rcpool_cache, ConstantPool::cache_offset_in_bytes(), Rcpool_cache); - - // Get the const pool entry by means of . - const int codes_shift = exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord); - __ slwi(Rscratch, Rcodes, codes_shift); // (codes&0xFFFF)<print_cr("accessor_entry: branch_table[%d] = 0x%llx (opcode 0x%llx)", i, branch_table[i], *((unsigned int*)branch_table[i])); - } -#endif - - __ bind(Lslow_path); - __ branch_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), Rscratch); - __ flush(); - - return entry; -} - // Interpreter intrinsic for WeakReference.get(). // 1. Don't push a full blown frame and go on dispatching, but fetch the value // into R8 and return quickly @@ -713,7 +529,6 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // and so we don't need to call the G1 pre-barrier. Thus we can use the // regular method entry code to generate the NPE. // - // This code is based on generate_accessor_enty. address entry = __ pc(); @@ -768,7 +583,7 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { return entry; } else { - return generate_accessor_entry(); + return generate_jump_to_normal_entry(); } } diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index 18870359ad9..ab2d535bbc9 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -1283,8 +1283,6 @@ int Compile::ConstantTable::calculate_table_base_offset() const { bool MachConstantBaseNode::requires_postalloc_expand() const { return true; } void MachConstantBaseNode::postalloc_expand(GrowableArray *nodes, PhaseRegAlloc *ra_) { - Compile *C = ra_->C; - iRegPdstOper *op_dst = new iRegPdstOper(); MachNode *m1 = new loadToc_hiNode(); MachNode *m2 = new loadToc_loNode(); @@ -2229,7 +2227,7 @@ const bool Matcher::isSimpleConstant64(jlong value) { } /* TODO: PPC port // Make a new machine dependent decode node (with its operands). -MachTypeNode *Matcher::make_decode_node(Compile *C) { +MachTypeNode *Matcher::make_decode_node() { assert(Universe::narrow_oop_base() == NULL && Universe::narrow_oop_shift() == 0, "This method is only implemented for unscaled cOops mode so far"); MachTypeNode *decode = new decodeN_unscaledNode(); @@ -2593,7 +2591,7 @@ typedef struct { MachNode *_last; } loadConLNodesTuple; -loadConLNodesTuple loadConLNodesTuple_create(Compile *C, PhaseRegAlloc *ra_, Node *toc, immLOper *immSrc, +loadConLNodesTuple loadConLNodesTuple_create(PhaseRegAlloc *ra_, Node *toc, immLOper *immSrc, OptoReg::Name reg_second, OptoReg::Name reg_first) { loadConLNodesTuple nodes; @@ -2669,7 +2667,7 @@ encode %{ enc_class postalloc_expand_load_long_constant(iRegLdst dst, immL src, iRegLdst toc) %{ // Create new nodes. loadConLNodesTuple loadConLNodes = - loadConLNodesTuple_create(C, ra_, n_toc, op_src, + loadConLNodesTuple_create(ra_, n_toc, op_src, ra_->get_reg_second(this), ra_->get_reg_first(this)); // Push new nodes. @@ -3391,7 +3389,7 @@ encode %{ immLOper *op_repl = new immLOper((jlong)replicate_immF(op_src->constantF())); loadConLNodesTuple loadConLNodes = - loadConLNodesTuple_create(C, ra_, n_toc, op_repl, + loadConLNodesTuple_create(ra_, n_toc, op_repl, ra_->get_reg_second(this), ra_->get_reg_first(this)); // Push new nodes. @@ -3611,7 +3609,7 @@ encode %{ // Create the nodes for loading the IC from the TOC. loadConLNodesTuple loadConLNodes_IC = - loadConLNodesTuple_create(C, ra_, n_toc, new immLOper((jlong)Universe::non_oop_word()), + loadConLNodesTuple_create(ra_, n_toc, new immLOper((jlong)Universe::non_oop_word()), OptoReg::Name(R19_H_num), OptoReg::Name(R19_num)); // Create the call node. @@ -3765,7 +3763,7 @@ encode %{ #if defined(ABI_ELFv2) jlong entry_address = (jlong) this->entry_point(); assert(entry_address, "need address here"); - loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper(entry_address), + loadConLNodes_Entry = loadConLNodesTuple_create(ra_, n_toc, new immLOper(entry_address), OptoReg::Name(R12_H_num), OptoReg::Name(R12_num)); #else // Get the struct that describes the function we are about to call. @@ -3777,13 +3775,13 @@ encode %{ loadConLNodesTuple loadConLNodes_Toc; // Create nodes and operands for loading the entry point. - loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper(entry_address), + loadConLNodes_Entry = loadConLNodesTuple_create(ra_, n_toc, new immLOper(entry_address), OptoReg::Name(R12_H_num), OptoReg::Name(R12_num)); // Create nodes and operands for loading the env pointer. if (fd->env() != NULL) { - loadConLNodes_Env = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper((jlong) fd->env()), + loadConLNodes_Env = loadConLNodesTuple_create(ra_, n_toc, new immLOper((jlong) fd->env()), OptoReg::Name(R11_H_num), OptoReg::Name(R11_num)); } else { loadConLNodes_Env._large_hi = NULL; @@ -3796,7 +3794,7 @@ encode %{ } // Create nodes and operands for loading the Toc point. - loadConLNodes_Toc = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper((jlong) fd->toc()), + loadConLNodes_Toc = loadConLNodesTuple_create(ra_, n_toc, new immLOper((jlong) fd->toc()), OptoReg::Name(R2_H_num), OptoReg::Name(R2_num)); #endif // ABI_ELFv2 // mtctr node diff --git a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.hpp b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.hpp index 051ed26e728..ea12f04124c 100644 --- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.hpp @@ -30,7 +30,6 @@ address generate_normal_entry(bool synchronized); address generate_native_entry(bool synchronized); address generate_math_entry(AbstractInterpreter::MethodKind kind); - address generate_empty_entry(void); void lock_method(Register Rflags, Register Rscratch1, Register Rscratch2, bool flags_preloaded=false); void unlock_method(bool check_exceptions = true); diff --git a/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp b/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp index b787fecc7d5..c53d73ec890 100644 --- a/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp @@ -176,8 +176,12 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, const Register size = R12_scratch2; __ get_cache_and_index_at_bcp(cache, 1, index_size); - // Big Endian (get least significant byte of 64 bit value): + // Get least significant byte of 64 bit value: +#if defined(VM_LITTLE_ENDIAN) + __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()), cache); +#else __ lbz(size, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()) + 7, cache); +#endif __ sldi(size, size, Interpreter::logStackElementSize); __ add(R15_esp, R15_esp, size); __ dispatch_next(state, step); @@ -598,48 +602,6 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist // End of helpers -// ============================================================================ -// Various method entries -// - -// Empty method, generate a very fast return. We must skip this entry if -// someone's debugging, indicated by the flag -// "interp_mode" in the Thread obj. -// Note: empty methods are generated mostly methods that do assertions, which are -// disabled in the "java opt build". -address TemplateInterpreterGenerator::generate_empty_entry(void) { - if (!UseFastEmptyMethods) { - NOT_PRODUCT(__ should_not_reach_here();) - return Interpreter::entry_for_kind(Interpreter::zerolocals); - } - - Label Lslow_path; - const Register Rjvmti_mode = R11_scratch1; - address entry = __ pc(); - - __ lwz(Rjvmti_mode, thread_(interp_only_mode)); - __ cmpwi(CCR0, Rjvmti_mode, 0); - __ bne(CCR0, Lslow_path); // jvmti_mode!=0 - - // Noone's debuggin: Simply return. - // Pop c2i arguments (if any) off when we return. -#ifdef ASSERT - __ ld(R9_ARG7, 0, R1_SP); - __ ld(R10_ARG8, 0, R21_sender_SP); - __ cmpd(CCR0, R9_ARG7, R10_ARG8); - __ asm_assert_eq("backlink", 0x545); -#endif // ASSERT - __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. - - // And we're done. - __ blr(); - - __ bind(Lslow_path); - __ branch_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R11_scratch1); - __ flush(); - - return entry; -} // Support abs and sqrt like in compiler. // For others we can use a normal (native) entry. @@ -858,7 +820,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // Our signature handlers copy required arguments to the C stack // (outgoing C args), R3_ARG1 to R10_ARG8, and FARG1 to FARG13. __ mr(R3_ARG1, R18_locals); +#if !defined(ABI_ELFv2) __ ld(signature_handler_fd, 0, signature_handler_fd); +#endif __ call_stub(signature_handler_fd); @@ -1020,8 +984,13 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // native result across the call. No oop is present. __ mr(R3_ARG1, R16_thread); +#if defined(ABI_ELFv2) + __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans), + relocInfo::none); +#else __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans), relocInfo::none); +#endif __ bind(sync_check_done); @@ -1278,45 +1247,6 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { return entry; } -// ============================================================================= -// Entry points - -address AbstractInterpreterGenerator::generate_method_entry( - AbstractInterpreter::MethodKind kind) { - // Determine code generation flags. - bool synchronized = false; - address entry_point = NULL; - - switch (kind) { - case Interpreter::zerolocals : break; - case Interpreter::zerolocals_synchronized: synchronized = true; break; - case Interpreter::native : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); break; - case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(true); break; - case Interpreter::empty : entry_point = ((InterpreterGenerator*) this)->generate_empty_entry(); break; - case Interpreter::accessor : entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry(); break; - case Interpreter::abstract : entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry(); break; - - case Interpreter::java_lang_math_sin : // fall thru - case Interpreter::java_lang_math_cos : // fall thru - case Interpreter::java_lang_math_tan : // fall thru - case Interpreter::java_lang_math_abs : // fall thru - case Interpreter::java_lang_math_log : // fall thru - case Interpreter::java_lang_math_log10 : // fall thru - case Interpreter::java_lang_math_sqrt : // fall thru - case Interpreter::java_lang_math_pow : // fall thru - case Interpreter::java_lang_math_exp : entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind); break; - case Interpreter::java_lang_ref_reference_get - : entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break; - default : ShouldNotReachHere(); break; - } - - if (entry_point) { - return entry_point; - } - - return ((InterpreterGenerator*) this)->generate_normal_entry(synchronized); -} - // These should never be compiled since the interpreter will prefer // the compiled version to the intrinsic version. bool AbstractInterpreter::can_be_compiled(methodHandle m) { @@ -1344,7 +1274,7 @@ int AbstractInterpreter::size_activation(int max_stack, int callee_locals, bool is_top_frame) { // Note: This calculation must exactly parallel the frame setup - // in AbstractInterpreterGenerator::generate_method_entry. + // in InterpreterGenerator::generate_fixed_frame. assert(Interpreter::stackElementWords == 1, "sanity"); const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize; const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) : diff --git a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp index 0b375da582e..6a34053a496 100644 --- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp +++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp @@ -189,8 +189,12 @@ void TemplateTable::patch_bytecode(Bytecodes::Code new_bc, Register Rnew_bc, Reg assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); assert(load_bc_into_bc_reg, "we use bc_reg as temp"); __ get_cache_and_index_at_bcp(Rtemp /* dst = cache */, 1); - // Big Endian: ((*(cache+indices))>>((1+byte_no)*8))&0xFF + // ((*(cache+indices))>>((1+byte_no)*8))&0xFF: +#if defined(VM_LITTLE_ENDIAN) + __ lbz(Rnew_bc, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 1 + byte_no, Rtemp); +#else __ lbz(Rnew_bc, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 7 - (1 + byte_no), Rtemp); +#endif __ cmpwi(CCR0, Rnew_bc, 0); __ li(Rnew_bc, (unsigned int)(unsigned char)new_bc); __ beq(CCR0, L_patch_done); @@ -1839,8 +1843,8 @@ void TemplateTable::tableswitch() { __ clrrdi(Rdef_offset_addr, Rdef_offset_addr, log2_long((jlong)BytesPerInt)); // Load lo & hi. - __ lwz(Rlow_byte, BytesPerInt, Rdef_offset_addr); - __ lwz(Rhigh_byte, BytesPerInt * 2, Rdef_offset_addr); + __ get_u4(Rlow_byte, Rdef_offset_addr, BytesPerInt, InterpreterMacroAssembler::Unsigned); + __ get_u4(Rhigh_byte, Rdef_offset_addr, 2 *BytesPerInt, InterpreterMacroAssembler::Unsigned); // Check for default case (=index outside [low,high]). __ cmpw(CCR0, R17_tos, Rlow_byte); @@ -1854,12 +1858,17 @@ void TemplateTable::tableswitch() { __ profile_switch_case(Rindex, Rhigh_byte /* scratch */, Rscratch1, Rscratch2); __ sldi(Rindex, Rindex, LogBytesPerInt); __ addi(Rindex, Rindex, 3 * BytesPerInt); +#if defined(VM_LITTLE_ENDIAN) + __ lwbrx(Roffset, Rdef_offset_addr, Rindex); + __ extsw(Roffset, Roffset); +#else __ lwax(Roffset, Rdef_offset_addr, Rindex); +#endif __ b(Ldispatch); __ bind(Ldefault_case); __ profile_switch_default(Rhigh_byte, Rscratch1); - __ lwa(Roffset, 0, Rdef_offset_addr); + __ get_u4(Roffset, Rdef_offset_addr, 0, InterpreterMacroAssembler::Signed); __ bind(Ldispatch); @@ -1875,12 +1884,11 @@ void TemplateTable::lookupswitch() { // Table switch using linear search through cases. // Bytecode stream format: // Bytecode (1) | 4-byte padding | default offset (4) | count (4) | value/offset pair1 (8) | value/offset pair2 (8) | ... -// Note: Everything is big-endian format here. So on little endian machines, we have to revers offset and count and cmp value. +// Note: Everything is big-endian format here. void TemplateTable::fast_linearswitch() { transition(itos, vtos); - Label Lloop_entry, Lsearch_loop, Lfound, Lcontinue_execution, Ldefault_case; - + Label Lloop_entry, Lsearch_loop, Lcontinue_execution, Ldefault_case; Register Rcount = R3_ARG1, Rcurrent_pair = R4_ARG2, Rdef_offset_addr = R5_ARG3, // Is going to contain address of default offset. @@ -1894,47 +1902,40 @@ void TemplateTable::fast_linearswitch() { __ clrrdi(Rdef_offset_addr, Rdef_offset_addr, log2_long((jlong)BytesPerInt)); // Setup loop counter and limit. - __ lwz(Rcount, BytesPerInt, Rdef_offset_addr); // Load count. + __ get_u4(Rcount, Rdef_offset_addr, BytesPerInt, InterpreterMacroAssembler::Unsigned); __ addi(Rcurrent_pair, Rdef_offset_addr, 2 * BytesPerInt); // Rcurrent_pair now points to first pair. - // Set up search loop. - __ cmpwi(CCR0, Rcount, 0); - __ beq(CCR0, Ldefault_case); - __ mtctr(Rcount); + __ cmpwi(CCR0, Rcount, 0); + __ bne(CCR0, Lloop_entry); - // linear table search - __ bind(Lsearch_loop); - - __ lwz(Rvalue, 0, Rcurrent_pair); - __ lwa(Roffset, 1 * BytesPerInt, Rcurrent_pair); - - __ cmpw(CCR0, Rvalue, Rcmp_value); - __ beq(CCR0, Lfound); - - __ addi(Rcurrent_pair, Rcurrent_pair, 2 * BytesPerInt); - __ bdnz(Lsearch_loop); - - // default case + // Default case __ bind(Ldefault_case); - - __ lwa(Roffset, 0, Rdef_offset_addr); + __ get_u4(Roffset, Rdef_offset_addr, 0, InterpreterMacroAssembler::Signed); if (ProfileInterpreter) { __ profile_switch_default(Rdef_offset_addr, Rcount/* scratch */); - __ b(Lcontinue_execution); + } + __ b(Lcontinue_execution); + + // Next iteration + __ bind(Lsearch_loop); + __ bdz(Ldefault_case); + __ addi(Rcurrent_pair, Rcurrent_pair, 2 * BytesPerInt); + __ bind(Lloop_entry); + __ get_u4(Rvalue, Rcurrent_pair, 0, InterpreterMacroAssembler::Unsigned); + __ cmpw(CCR0, Rvalue, Rcmp_value); + __ bne(CCR0, Lsearch_loop); + + // Found, load offset. + __ get_u4(Roffset, Rcurrent_pair, BytesPerInt, InterpreterMacroAssembler::Signed); + // Calculate case index and profile + __ mfctr(Rcurrent_pair); + if (ProfileInterpreter) { + __ sub(Rcurrent_pair, Rcount, Rcurrent_pair); + __ profile_switch_case(Rcurrent_pair, Rcount /*scratch*/, Rdef_offset_addr/*scratch*/, Rscratch); } - // Entry found, skip Roffset bytecodes and continue. - __ bind(Lfound); - if (ProfileInterpreter) { - // Calc the num of the pair we hit. Careful, Rcurrent_pair points 2 ints - // beyond the actual current pair due to the auto update load above! - __ sub(Rcurrent_pair, Rcurrent_pair, Rdef_offset_addr); - __ addi(Rcurrent_pair, Rcurrent_pair, - 2 * BytesPerInt); - __ srdi(Rcurrent_pair, Rcurrent_pair, LogBytesPerInt + 1); - __ profile_switch_case(Rcurrent_pair, Rcount /*scratch*/, Rdef_offset_addr/*scratch*/, Rscratch); - __ bind(Lcontinue_execution); - } + __ bind(Lcontinue_execution); __ add(R14_bcp, Roffset, R14_bcp); __ dispatch_next(vtos); } @@ -1990,7 +1991,7 @@ void TemplateTable::fast_binaryswitch() { // initialize i & j __ li(Ri,0); - __ lwz(Rj, -BytesPerInt, Rarray); + __ get_u4(Rj, Rarray, -BytesPerInt, InterpreterMacroAssembler::Unsigned); // and start. Label entry; @@ -2007,7 +2008,11 @@ void TemplateTable::fast_binaryswitch() { // i = h; // } __ sldi(Rscratch, Rh, log_entry_size); +#if defined(VM_LITTLE_ENDIAN) + __ lwbrx(Rscratch, Rscratch, Rarray); +#else __ lwzx(Rscratch, Rscratch, Rarray); +#endif // if (key < current value) // Rh = Rj @@ -2039,20 +2044,20 @@ void TemplateTable::fast_binaryswitch() { // Ri = value offset __ sldi(Ri, Ri, log_entry_size); __ add(Ri, Ri, Rarray); - __ lwz(Rscratch, 0, Ri); + __ get_u4(Rscratch, Ri, 0, InterpreterMacroAssembler::Unsigned); Label not_found; // Ri = offset offset __ cmpw(CCR0, Rkey, Rscratch); __ beq(CCR0, not_found); // entry not found -> j = default offset - __ lwz(Rj, -2 * BytesPerInt, Rarray); + __ get_u4(Rj, Rarray, -2 * BytesPerInt, InterpreterMacroAssembler::Unsigned); __ b(default_case); __ bind(not_found); // entry found -> j = offset __ profile_switch_case(Rh, Rj, Rscratch, Rkey); - __ lwz(Rj, BytesPerInt, Ri); + __ get_u4(Rj, Ri, BytesPerInt, InterpreterMacroAssembler::Unsigned); if (ProfileInterpreter) { __ b(continue_execution); @@ -2147,8 +2152,11 @@ void TemplateTable::resolve_cache_and_index(int byte_no, Register Rcache, Regist assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); // We are resolved if the indices offset contains the current bytecode. - // Big Endian: +#if defined(VM_LITTLE_ENDIAN) + __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + byte_no + 1, Rcache); +#else __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 7 - (byte_no + 1), Rcache); +#endif // Acquire by cmp-br-isync (see below). __ cmpdi(CCR0, Rscratch, (int)bytecode()); __ beq(CCR0, Lresolved); diff --git a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp index 75047c7cb42..0e66115a3f8 100644 --- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp @@ -29,6 +29,7 @@ #include "compiler/disassembler.hpp" #include "memory/resourceArea.hpp" #include "runtime/java.hpp" +#include "runtime/os.hpp" #include "runtime/stubCodeGenerator.hpp" #include "utilities/defaultStream.hpp" #include "vm_version_ppc.hpp" @@ -108,7 +109,7 @@ void VM_Version::initialize() { (has_vand() ? " vand" : "") // Make sure number of %s matches num_features! ); - _features_str = strdup(buf); + _features_str = os::strdup(buf); NOT_PRODUCT(if (Verbose) print_features();); // PPC64 supports 8-byte compare-exchange operations (see diff --git a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp index e5325211b5a..4a84b6c3387 100644 --- a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "interpreter/interpreter.hpp" #include "interpreter/interpreterGenerator.hpp" #include "interpreter/interpreterRuntime.hpp" +#include "interpreter/interp_masm.hpp" #include "oops/arrayOop.hpp" #include "oops/methodData.hpp" #include "oops/method.hpp" @@ -68,9 +69,7 @@ bool CppInterpreter::contains(address pc) { #define STATE(field_name) Lstate, in_bytes(byte_offset_of(BytecodeInterpreter, field_name)) #define __ _masm-> -Label frame_manager_entry; -Label fast_accessor_slow_entry_path; // fast accessor methods need to be able to jmp to unsynchronized - // c++ interpreter entry point this holds that entry point label. +Label frame_manager_entry; // c++ interpreter entry point this holds that entry point label. static address unctrap_frame_manager_entry = NULL; @@ -452,110 +451,6 @@ address InterpreterGenerator::generate_empty_entry(void) { return NULL; } -// Call an accessor method (assuming it is resolved, otherwise drop into -// vanilla (slow path) entry - -// Generates code to elide accessor methods -// Uses G3_scratch and G1_scratch as scratch -address InterpreterGenerator::generate_accessor_entry(void) { - - // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; - // parameter size = 1 - // Note: We can only use this code if the getfield has been resolved - // and if we don't have a null-pointer exception => check for - // these conditions first and use slow path if necessary. - address entry = __ pc(); - Label slow_path; - - if ( UseFastAccessorMethods) { - // Check if we need to reach a safepoint and generate full interpreter - // frame if so. - AddressLiteral sync_state(SafepointSynchronize::address_of_state()); - __ load_contents(sync_state, G3_scratch); - __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); - __ br(Assembler::notEqual, false, Assembler::pn, slow_path); - __ delayed()->nop(); - - // Check if local 0 != NULL - __ ld_ptr(Gargs, G0, Otos_i ); // get local 0 - __ tst(Otos_i); // check if local 0 == NULL and go the slow path - __ brx(Assembler::zero, false, Assembler::pn, slow_path); - __ delayed()->nop(); - - - // read first instruction word and extract bytecode @ 1 and index @ 2 - // get first 4 bytes of the bytecodes (big endian!) - __ ld_ptr(Address(G5_method, in_bytes(Method::const_offset())), G1_scratch); - __ ld(Address(G1_scratch, in_bytes(ConstMethod::codes_offset())), G1_scratch); - - // move index @ 2 far left then to the right most two bytes. - __ sll(G1_scratch, 2*BitsPerByte, G1_scratch); - __ srl(G1_scratch, 2*BitsPerByte - exact_log2(in_words( - ConstantPoolCacheEntry::size()) * BytesPerWord), G1_scratch); - - // get constant pool cache - __ ld_ptr(G5_method, in_bytes(Method::const_offset()), G3_scratch); - __ ld_ptr(G3_scratch, in_bytes(ConstMethod::constants_offset()), G3_scratch); - __ ld_ptr(G3_scratch, ConstantPool::cache_offset_in_bytes(), G3_scratch); - - // get specific constant pool cache entry - __ add(G3_scratch, G1_scratch, G3_scratch); - - // Check the constant Pool cache entry to see if it has been resolved. - // If not, need the slow path. - ByteSize cp_base_offset = ConstantPoolCache::base_offset(); - __ ld_ptr(G3_scratch, in_bytes(cp_base_offset + ConstantPoolCacheEntry::indices_offset()), G1_scratch); - __ srl(G1_scratch, 2*BitsPerByte, G1_scratch); - __ and3(G1_scratch, 0xFF, G1_scratch); - __ cmp(G1_scratch, Bytecodes::_getfield); - __ br(Assembler::notEqual, false, Assembler::pn, slow_path); - __ delayed()->nop(); - - // Get the type and return field offset from the constant pool cache - __ ld_ptr(G3_scratch, in_bytes(cp_base_offset + ConstantPoolCacheEntry::flags_offset()), G1_scratch); - __ ld_ptr(G3_scratch, in_bytes(cp_base_offset + ConstantPoolCacheEntry::f2_offset()), G3_scratch); - - Label xreturn_path; - // Need to differentiate between igetfield, agetfield, bgetfield etc. - // because they are different sizes. - // Get the type from the constant pool cache - __ srl(G1_scratch, ConstantPoolCacheEntry::tos_state_shift, G1_scratch); - // Make sure we don't need to mask G1_scratch after the above shift - ConstantPoolCacheEntry::verify_tos_state_shift(); - __ cmp(G1_scratch, atos ); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ld_ptr(Otos_i, G3_scratch, Otos_i); - __ cmp(G1_scratch, itos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ld(Otos_i, G3_scratch, Otos_i); - __ cmp(G1_scratch, stos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ldsh(Otos_i, G3_scratch, Otos_i); - __ cmp(G1_scratch, ctos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->lduh(Otos_i, G3_scratch, Otos_i); -#ifdef ASSERT - __ cmp(G1_scratch, btos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i); - __ should_not_reach_here(); -#endif - __ ldsb(Otos_i, G3_scratch, Otos_i); - __ bind(xreturn_path); - - // _ireturn/_areturn - __ retl(); // return from leaf routine - __ delayed()->mov(O5_savedSP, SP); - - // Generate regular method entry - __ bind(slow_path); - __ ba(fast_accessor_slow_entry_path); - __ delayed()->nop(); - return entry; - } - return NULL; -} - address InterpreterGenerator::generate_Reference_get_entry(void) { #if INCLUDE_ALL_GCS if (UseG1GC) { @@ -573,7 +468,7 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // If G1 is not enabled then attempt to go through the accessor entry point // Reference.get is an accessor - return generate_accessor_entry(); + return generate_jump_to_normal_entry(); } // @@ -1870,23 +1765,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { __ ba(call_interpreter_2); __ delayed()->st_ptr(O1, STATE(_stack)); - - // Fast accessor methods share this entry point. - // This works because frame manager is in the same codelet - // This can either be an entry via call_stub/c1/c2 or a recursive interpreter call - // we need to do a little register fixup here once we distinguish the two of them - if (UseFastAccessorMethods && !synchronized) { - // Call stub_return address still in O7 - __ bind(fast_accessor_slow_entry_path); - __ set((intptr_t)return_from_native_method - 8, Gtmp1); - __ cmp(Gtmp1, O7); // returning to interpreter? - __ brx(Assembler::equal, true, Assembler::pt, re_dispatch); // yep - __ delayed()->nop(); - __ ba(re_dispatch); - __ delayed()->mov(G0, prevState); // initial entry - - } - // interpreter returning to native code (call_stub/c1/c2) // convert result and unwind initial activation // L2_scratch - scaled result type index diff --git a/hotspot/src/cpu/sparc/vm/interpreterGenerator_sparc.hpp b/hotspot/src/cpu/sparc/vm/interpreterGenerator_sparc.hpp index 0558b7b3c3c..de4997bce7a 100644 --- a/hotspot/src/cpu/sparc/vm/interpreterGenerator_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/interpreterGenerator_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,9 +32,11 @@ address generate_normal_entry(bool synchronized); address generate_native_entry(bool synchronized); address generate_abstract_entry(void); - address generate_math_entry(AbstractInterpreter::MethodKind kind); - address generate_empty_entry(void); - address generate_accessor_entry(void); + // there are no math intrinsics on sparc + address generate_math_entry(AbstractInterpreter::MethodKind kind) { return NULL; } + address generate_jump_to_normal_entry(void); + address generate_accessor_entry(void) { return generate_jump_to_normal_entry(); } + address generate_empty_entry(void) { return generate_jump_to_normal_entry(); } address generate_Reference_get_entry(void); void lock_method(void); void save_native_result(void); @@ -43,4 +45,7 @@ void generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue); void generate_counter_overflow(Label& Lcontinue); + // Not supported + address generate_CRC32_update_entry() { return NULL; } + address generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) { return NULL; } #endif // CPU_SPARC_VM_INTERPRETERGENERATOR_SPARC_HPP diff --git a/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp index debdaeae7a4..f8d8f590c99 100644 --- a/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp @@ -241,6 +241,15 @@ void InterpreterGenerator::generate_counter_overflow(Label& Lcontinue) { // Various method entries +address InterpreterGenerator::generate_jump_to_normal_entry(void) { + address entry = __ pc(); + assert(Interpreter::entry_for_kind(Interpreter::zerolocals) != NULL, "should already be generated"); + AddressLiteral al(Interpreter::entry_for_kind(Interpreter::zerolocals)); + __ jump_to(al, G3_scratch); + __ delayed()->nop(); + return entry; +} + // Abstract method entry // Attempt to execute abstract method. Throw exception // @@ -255,159 +264,6 @@ address InterpreterGenerator::generate_abstract_entry(void) { } - -//---------------------------------------------------------------------------------------------------- -// Entry points & stack frame layout -// -// Here we generate the various kind of entries into the interpreter. -// The two main entry type are generic bytecode methods and native call method. -// These both come in synchronized and non-synchronized versions but the -// frame layout they create is very similar. The other method entry -// types are really just special purpose entries that are really entry -// and interpretation all in one. These are for trivial methods like -// accessor, empty, or special math methods. -// -// When control flow reaches any of the entry types for the interpreter -// the following holds -> -// -// C2 Calling Conventions: -// -// The entry code below assumes that the following registers are set -// when coming in: -// G5_method: holds the Method* of the method to call -// Lesp: points to the TOS of the callers expression stack -// after having pushed all the parameters -// -// The entry code does the following to setup an interpreter frame -// pop parameters from the callers stack by adjusting Lesp -// set O0 to Lesp -// compute X = (max_locals - num_parameters) -// bump SP up by X to accomadate the extra locals -// compute X = max_expression_stack -// + vm_local_words -// + 16 words of register save area -// save frame doing a save sp, -X, sp growing towards lower addresses -// set Lbcp, Lmethod, LcpoolCache -// set Llocals to i0 -// set Lmonitors to FP - rounded_vm_local_words -// set Lesp to Lmonitors - 4 -// -// The frame has now been setup to do the rest of the entry code - -// Try this optimization: Most method entries could live in a -// "one size fits all" stack frame without all the dynamic size -// calculations. It might be profitable to do all this calculation -// statically and approximately for "small enough" methods. - -//----------------------------------------------------------------------------------------------- - -// C1 Calling conventions -// -// Upon method entry, the following registers are setup: -// -// g2 G2_thread: current thread -// g5 G5_method: method to activate -// g4 Gargs : pointer to last argument -// -// -// Stack: -// -// +---------------+ <--- sp -// | | -// : reg save area : -// | | -// +---------------+ <--- sp + 0x40 -// | | -// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) -// | | -// +---------------+ <--- sp + 0x5c -// | | -// : free : -// | | -// +---------------+ <--- Gargs -// | | -// : arguments : -// | | -// +---------------+ -// | | -// -// -// -// AFTER FRAME HAS BEEN SETUP for method interpretation the stack looks like: -// -// +---------------+ <--- sp -// | | -// : reg save area : -// | | -// +---------------+ <--- sp + 0x40 -// | | -// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) -// | | -// +---------------+ <--- sp + 0x5c -// | | -// : : -// | | <--- Lesp -// +---------------+ <--- Lmonitors (fp - 0x18) -// | VM locals | -// +---------------+ <--- fp -// | | -// : reg save area : -// | | -// +---------------+ <--- fp + 0x40 -// | | -// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) -// | | -// +---------------+ <--- fp + 0x5c -// | | -// : free : -// | | -// +---------------+ -// | | -// : nonarg locals : -// | | -// +---------------+ -// | | -// : arguments : -// | | <--- Llocals -// +---------------+ <--- Gargs -// | | - -address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) { - // determine code generation flags - bool synchronized = false; - address entry_point = NULL; - - switch (kind) { - case Interpreter::zerolocals : break; - case Interpreter::zerolocals_synchronized: synchronized = true; break; - case Interpreter::native : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false); break; - case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true); break; - case Interpreter::empty : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry(); break; - case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break; - case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break; - - case Interpreter::java_lang_math_sin : break; - case Interpreter::java_lang_math_cos : break; - case Interpreter::java_lang_math_tan : break; - case Interpreter::java_lang_math_sqrt : break; - case Interpreter::java_lang_math_abs : break; - case Interpreter::java_lang_math_log : break; - case Interpreter::java_lang_math_log10 : break; - case Interpreter::java_lang_math_pow : break; - case Interpreter::java_lang_math_exp : break; - case Interpreter::java_lang_ref_reference_get - : entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break; - default: - fatal(err_msg("unexpected method kind: %d", kind)); - break; - } - - if (entry_point) return entry_point; - - return ((InterpreterGenerator*)this)->generate_normal_entry(synchronized); -} - - bool AbstractInterpreter::can_be_compiled(methodHandle m) { // No special entry points that preclude compilation return true; diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index c261900003b..99ec87803d5 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -6184,7 +6184,11 @@ instruct loadConP_no_oop_cheap(iRegP dst, immP_no_oop_cheap con) %{ ins_cost(DEFAULT_COST * 3/2); format %{ "SET $con,$dst\t! non-oop ptr" %} ins_encode %{ - __ set($con$$constant, $dst$$Register); + if (_opnds[1]->constant_reloc() == relocInfo::metadata_type) { + __ set_metadata_constant((Metadata*)$con$$constant, $dst$$Register); + } else { + __ set($con$$constant, $dst$$Register); + } %} ins_pipe(loadConP); %} diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp index 1f8503161cc..93f87807482 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp @@ -456,6 +456,115 @@ void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rframe // Generate a fixed interpreter frame. This is identical setup for interpreted // methods and for native methods hence the shared code. + +//---------------------------------------------------------------------------------------------------- +// Stack frame layout +// +// When control flow reaches any of the entry types for the interpreter +// the following holds -> +// +// C2 Calling Conventions: +// +// The entry code below assumes that the following registers are set +// when coming in: +// G5_method: holds the Method* of the method to call +// Lesp: points to the TOS of the callers expression stack +// after having pushed all the parameters +// +// The entry code does the following to setup an interpreter frame +// pop parameters from the callers stack by adjusting Lesp +// set O0 to Lesp +// compute X = (max_locals - num_parameters) +// bump SP up by X to accomadate the extra locals +// compute X = max_expression_stack +// + vm_local_words +// + 16 words of register save area +// save frame doing a save sp, -X, sp growing towards lower addresses +// set Lbcp, Lmethod, LcpoolCache +// set Llocals to i0 +// set Lmonitors to FP - rounded_vm_local_words +// set Lesp to Lmonitors - 4 +// +// The frame has now been setup to do the rest of the entry code + +// Try this optimization: Most method entries could live in a +// "one size fits all" stack frame without all the dynamic size +// calculations. It might be profitable to do all this calculation +// statically and approximately for "small enough" methods. + +//----------------------------------------------------------------------------------------------- + +// C1 Calling conventions +// +// Upon method entry, the following registers are setup: +// +// g2 G2_thread: current thread +// g5 G5_method: method to activate +// g4 Gargs : pointer to last argument +// +// +// Stack: +// +// +---------------+ <--- sp +// | | +// : reg save area : +// | | +// +---------------+ <--- sp + 0x40 +// | | +// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) +// | | +// +---------------+ <--- sp + 0x5c +// | | +// : free : +// | | +// +---------------+ <--- Gargs +// | | +// : arguments : +// | | +// +---------------+ +// | | +// +// +// +// AFTER FRAME HAS BEEN SETUP for method interpretation the stack looks like: +// +// +---------------+ <--- sp +// | | +// : reg save area : +// | | +// +---------------+ <--- sp + 0x40 +// | | +// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) +// | | +// +---------------+ <--- sp + 0x5c +// | | +// : : +// | | <--- Lesp +// +---------------+ <--- Lmonitors (fp - 0x18) +// | VM locals | +// +---------------+ <--- fp +// | | +// : reg save area : +// | | +// +---------------+ <--- fp + 0x40 +// | | +// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) +// | | +// +---------------+ <--- fp + 0x5c +// | | +// : free : +// | | +// +---------------+ +// | | +// : nonarg locals : +// | | +// +---------------+ +// | | +// : arguments : +// | | <--- Llocals +// +---------------+ <--- Gargs +// | | + void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { // // @@ -599,136 +708,6 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { } -// Empty method, generate a very fast return. - -address InterpreterGenerator::generate_empty_entry(void) { - - // A method that does nother but return... - - address entry = __ pc(); - Label slow_path; - - // do nothing for empty methods (do not even increment invocation counter) - if ( UseFastEmptyMethods) { - // If we need a safepoint check, generate full interpreter entry. - AddressLiteral sync_state(SafepointSynchronize::address_of_state()); - __ set(sync_state, G3_scratch); - __ cmp_and_br_short(G3_scratch, SafepointSynchronize::_not_synchronized, Assembler::notEqual, Assembler::pn, slow_path); - - // Code: _return - __ retl(); - __ delayed()->mov(O5_savedSP, SP); - - __ bind(slow_path); - (void) generate_normal_entry(false); - - return entry; - } - return NULL; -} - -// Call an accessor method (assuming it is resolved, otherwise drop into -// vanilla (slow path) entry - -// Generates code to elide accessor methods -// Uses G3_scratch and G1_scratch as scratch -address InterpreterGenerator::generate_accessor_entry(void) { - - // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; - // parameter size = 1 - // Note: We can only use this code if the getfield has been resolved - // and if we don't have a null-pointer exception => check for - // these conditions first and use slow path if necessary. - address entry = __ pc(); - Label slow_path; - - - // XXX: for compressed oops pointer loading and decoding doesn't fit in - // delay slot and damages G1 - if ( UseFastAccessorMethods && !UseCompressedOops ) { - // Check if we need to reach a safepoint and generate full interpreter - // frame if so. - AddressLiteral sync_state(SafepointSynchronize::address_of_state()); - __ load_contents(sync_state, G3_scratch); - __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); - __ cmp_and_br_short(G3_scratch, SafepointSynchronize::_not_synchronized, Assembler::notEqual, Assembler::pn, slow_path); - - // Check if local 0 != NULL - __ ld_ptr(Gargs, G0, Otos_i ); // get local 0 - // check if local 0 == NULL and go the slow path - __ br_null_short(Otos_i, Assembler::pn, slow_path); - - - // read first instruction word and extract bytecode @ 1 and index @ 2 - // get first 4 bytes of the bytecodes (big endian!) - __ ld_ptr(G5_method, Method::const_offset(), G1_scratch); - __ ld(G1_scratch, ConstMethod::codes_offset(), G1_scratch); - - // move index @ 2 far left then to the right most two bytes. - __ sll(G1_scratch, 2*BitsPerByte, G1_scratch); - __ srl(G1_scratch, 2*BitsPerByte - exact_log2(in_words( - ConstantPoolCacheEntry::size()) * BytesPerWord), G1_scratch); - - // get constant pool cache - __ ld_ptr(G5_method, Method::const_offset(), G3_scratch); - __ ld_ptr(G3_scratch, ConstMethod::constants_offset(), G3_scratch); - __ ld_ptr(G3_scratch, ConstantPool::cache_offset_in_bytes(), G3_scratch); - - // get specific constant pool cache entry - __ add(G3_scratch, G1_scratch, G3_scratch); - - // Check the constant Pool cache entry to see if it has been resolved. - // If not, need the slow path. - ByteSize cp_base_offset = ConstantPoolCache::base_offset(); - __ ld_ptr(G3_scratch, cp_base_offset + ConstantPoolCacheEntry::indices_offset(), G1_scratch); - __ srl(G1_scratch, 2*BitsPerByte, G1_scratch); - __ and3(G1_scratch, 0xFF, G1_scratch); - __ cmp_and_br_short(G1_scratch, Bytecodes::_getfield, Assembler::notEqual, Assembler::pn, slow_path); - - // Get the type and return field offset from the constant pool cache - __ ld_ptr(G3_scratch, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), G1_scratch); - __ ld_ptr(G3_scratch, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), G3_scratch); - - Label xreturn_path; - // Need to differentiate between igetfield, agetfield, bgetfield etc. - // because they are different sizes. - // Get the type from the constant pool cache - __ srl(G1_scratch, ConstantPoolCacheEntry::tos_state_shift, G1_scratch); - // Make sure we don't need to mask G1_scratch after the above shift - ConstantPoolCacheEntry::verify_tos_state_shift(); - __ cmp(G1_scratch, atos ); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ld_ptr(Otos_i, G3_scratch, Otos_i); - __ cmp(G1_scratch, itos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ld(Otos_i, G3_scratch, Otos_i); - __ cmp(G1_scratch, stos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ldsh(Otos_i, G3_scratch, Otos_i); - __ cmp(G1_scratch, ctos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->lduh(Otos_i, G3_scratch, Otos_i); -#ifdef ASSERT - __ cmp(G1_scratch, btos); - __ br(Assembler::equal, true, Assembler::pt, xreturn_path); - __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i); - __ should_not_reach_here(); -#endif - __ ldsb(Otos_i, G3_scratch, Otos_i); - __ bind(xreturn_path); - - // _ireturn/_areturn - __ retl(); // return from leaf routine - __ delayed()->mov(O5_savedSP, SP); - - // Generate regular method entry - __ bind(slow_path); - (void) generate_normal_entry(false); - return entry; - } - return NULL; -} - // Method entry for java.lang.ref.Reference.get. address InterpreterGenerator::generate_Reference_get_entry(void) { #if INCLUDE_ALL_GCS @@ -806,7 +785,7 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // If G1 is not enabled then attempt to go through the accessor entry point // Reference.get is an accessor - return generate_accessor_entry(); + return generate_jump_to_normal_entry(); } // @@ -1242,8 +1221,6 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { // Generic method entry to (asm) interpreter -//------------------------------------------------------------------------------------------------------------------------ -// address InterpreterGenerator::generate_normal_entry(bool synchronized) { address entry = __ pc(); @@ -1410,123 +1387,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { return entry; } - -//---------------------------------------------------------------------------------------------------- -// Entry points & stack frame layout -// -// Here we generate the various kind of entries into the interpreter. -// The two main entry type are generic bytecode methods and native call method. -// These both come in synchronized and non-synchronized versions but the -// frame layout they create is very similar. The other method entry -// types are really just special purpose entries that are really entry -// and interpretation all in one. These are for trivial methods like -// accessor, empty, or special math methods. -// -// When control flow reaches any of the entry types for the interpreter -// the following holds -> -// -// C2 Calling Conventions: -// -// The entry code below assumes that the following registers are set -// when coming in: -// G5_method: holds the Method* of the method to call -// Lesp: points to the TOS of the callers expression stack -// after having pushed all the parameters -// -// The entry code does the following to setup an interpreter frame -// pop parameters from the callers stack by adjusting Lesp -// set O0 to Lesp -// compute X = (max_locals - num_parameters) -// bump SP up by X to accomadate the extra locals -// compute X = max_expression_stack -// + vm_local_words -// + 16 words of register save area -// save frame doing a save sp, -X, sp growing towards lower addresses -// set Lbcp, Lmethod, LcpoolCache -// set Llocals to i0 -// set Lmonitors to FP - rounded_vm_local_words -// set Lesp to Lmonitors - 4 -// -// The frame has now been setup to do the rest of the entry code - -// Try this optimization: Most method entries could live in a -// "one size fits all" stack frame without all the dynamic size -// calculations. It might be profitable to do all this calculation -// statically and approximately for "small enough" methods. - -//----------------------------------------------------------------------------------------------- - -// C1 Calling conventions -// -// Upon method entry, the following registers are setup: -// -// g2 G2_thread: current thread -// g5 G5_method: method to activate -// g4 Gargs : pointer to last argument -// -// -// Stack: -// -// +---------------+ <--- sp -// | | -// : reg save area : -// | | -// +---------------+ <--- sp + 0x40 -// | | -// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) -// | | -// +---------------+ <--- sp + 0x5c -// | | -// : free : -// | | -// +---------------+ <--- Gargs -// | | -// : arguments : -// | | -// +---------------+ -// | | -// -// -// -// AFTER FRAME HAS BEEN SETUP for method interpretation the stack looks like: -// -// +---------------+ <--- sp -// | | -// : reg save area : -// | | -// +---------------+ <--- sp + 0x40 -// | | -// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) -// | | -// +---------------+ <--- sp + 0x5c -// | | -// : : -// | | <--- Lesp -// +---------------+ <--- Lmonitors (fp - 0x18) -// | VM locals | -// +---------------+ <--- fp -// | | -// : reg save area : -// | | -// +---------------+ <--- fp + 0x40 -// | | -// : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) -// | | -// +---------------+ <--- fp + 0x5c -// | | -// : free : -// | | -// +---------------+ -// | | -// : nonarg locals : -// | | -// +---------------+ -// | | -// : arguments : -// | | <--- Llocals -// +---------------+ <--- Gargs -// | | - static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) { // Figure out the size of an interpreter frame (in words) given that we have a fully allocated diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp index 79bf7139a12..91a9f76af4c 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -26,6 +26,7 @@ #include "asm/macroAssembler.inline.hpp" #include "memory/resourceArea.hpp" #include "runtime/java.hpp" +#include "runtime/os.hpp" #include "runtime/stubCodeGenerator.hpp" #include "vm_version_sparc.hpp" @@ -249,7 +250,7 @@ void VM_Version::initialize() { (!has_hardware_fsmuld() ? ", no-fsmuld" : "")); // buf is started with ", " or is empty - _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf); + _features_str = os::strdup(strlen(buf) > 2 ? buf + 2 : buf); // There are three 64-bit SPARC families that do not overlap, e.g., // both is_ultra3() and is_sparc64() cannot be true at the same time. diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 64b8ce731a5..34219277523 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -3853,6 +3853,15 @@ void Assembler::vpbroadcastd(XMMRegister dst, XMMRegister src) { emit_int8((unsigned char)(0xC0 | encode)); } +// Carry-Less Multiplication Quadword +void Assembler::pclmulqdq(XMMRegister dst, XMMRegister src, int mask) { + assert(VM_Version::supports_clmul(), ""); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A); + emit_int8(0x44); + emit_int8((unsigned char)(0xC0 | encode)); + emit_int8((unsigned char)mask); +} + // Carry-Less Multiplication Quadword void Assembler::vpclmulqdq(XMMRegister dst, XMMRegister nds, XMMRegister src, int mask) { assert(VM_Version::supports_avx() && VM_Version::supports_clmul(), ""); diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 12bc14e7195..8edf31cada8 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1837,6 +1837,7 @@ private: void vpbroadcastd(XMMRegister dst, XMMRegister src); // Carry-Less Multiplication Quadword + void pclmulqdq(XMMRegister dst, XMMRegister src, int mask); void vpclmulqdq(XMMRegister dst, XMMRegister nds, XMMRegister src, int mask); // AVX instruction which is used to clear upper 128 bits of YMM registers and diff --git a/hotspot/src/cpu/x86/vm/cppInterpreterGenerator_x86.hpp b/hotspot/src/cpu/x86/vm/cppInterpreterGenerator_x86.hpp index 2f9f1d47deb..9f81215b396 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreterGenerator_x86.hpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreterGenerator_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,21 +27,6 @@ protected: -#if 0 - address generate_asm_interpreter_entry(bool synchronized); - address generate_native_entry(bool synchronized); - address generate_abstract_entry(void); - address generate_math_entry(AbstractInterpreter::MethodKind kind); - address generate_empty_entry(void); - address generate_accessor_entry(void); - address generate_Reference_get_entry(void); - void lock_method(void); - void generate_stack_overflow_check(void); - - void generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue); - void generate_counter_overflow(Label* do_continue); -#endif - void generate_more_monitors(); void generate_deopt_handling(); address generate_interpreter_frame_manager(bool synchronized); // C++ interpreter only diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp index 9eb1a6ebf77..27f1b309727 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,9 +66,6 @@ extern "C" void RecursiveInterpreterActivation(interpreterState istate ) #define __ _masm-> #define STATE(field_name) (Address(state, byte_offset_of(BytecodeInterpreter, field_name))) -Label fast_accessor_slow_entry_path; // fast accessor methods need to be able to jmp to unsynchronized - // c++ interpreter entry point this holds that entry point label. - // default registers for state and sender_sp // state and sender_sp are the same on 32bit because we have no choice. // state could be rsi on 64bit but it is an arg reg and not callee save @@ -660,7 +657,6 @@ void InterpreterGenerator::generate_stack_overflow_check(void) { // generate_method_entry) so the guard should work for them too. // - // monitor entry size: see picture of stack set (generate_method_entry) and frame_i486.hpp const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; // total overhead size: entry_size + (saved rbp, thru expr stack bottom). @@ -794,156 +790,6 @@ void InterpreterGenerator::lock_method(void) { __ lock_object(monitor); } -// Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry - -address InterpreterGenerator::generate_accessor_entry(void) { - - // rbx: Method* - - // rsi/r13: senderSP must preserved for slow path, set SP to it on fast path - - Label xreturn_path; - - // do fastpath for resolved accessor methods - if (UseFastAccessorMethods) { - - address entry_point = __ pc(); - - Label slow_path; - // If we need a safepoint check, generate full interpreter entry. - ExternalAddress state(SafepointSynchronize::address_of_state()); - __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), - SafepointSynchronize::_not_synchronized); - - __ jcc(Assembler::notEqual, slow_path); - // ASM/C++ Interpreter - // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; parameter size = 1 - // Note: We can only use this code if the getfield has been resolved - // and if we don't have a null-pointer exception => check for - // these conditions first and use slow path if necessary. - // rbx,: method - // rcx: receiver - __ movptr(rax, Address(rsp, wordSize)); - - // check if local 0 != NULL and read field - __ testptr(rax, rax); - __ jcc(Assembler::zero, slow_path); - - // read first instruction word and extract bytecode @ 1 and index @ 2 - __ movptr(rdx, Address(rbx, Method::const_offset())); - __ movptr(rdi, Address(rdx, ConstMethod::constants_offset())); - __ movl(rdx, Address(rdx, ConstMethod::codes_offset())); - // Shift codes right to get the index on the right. - // The bytecode fetched looks like <0xb4><0x2a> - __ shrl(rdx, 2*BitsPerByte); - __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); - __ movptr(rdi, Address(rdi, ConstantPool::cache_offset_in_bytes())); - - // rax,: local 0 - // rbx,: method - // rcx: receiver - do not destroy since it is needed for slow path! - // rcx: scratch - // rdx: constant pool cache index - // rdi: constant pool cache - // rsi/r13: sender sp - - // check if getfield has been resolved and read constant pool cache entry - // check the validity of the cache entry by testing whether _indices field - // contains Bytecode::_getfield in b1 byte. - assert(in_words(ConstantPoolCacheEntry::size()) == 4, "adjust shift below"); - __ movl(rcx, - Address(rdi, - rdx, - Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset())); - __ shrl(rcx, 2*BitsPerByte); - __ andl(rcx, 0xFF); - __ cmpl(rcx, Bytecodes::_getfield); - __ jcc(Assembler::notEqual, slow_path); - - // Note: constant pool entry is not valid before bytecode is resolved - __ movptr(rcx, - Address(rdi, - rdx, - Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::f2_offset())); - __ movl(rdx, - Address(rdi, - rdx, - Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); - - Label notByte, notShort, notChar; - const Address field_address (rax, rcx, Address::times_1); - - // Need to differentiate between igetfield, agetfield, bgetfield etc. - // because they are different sizes. - // Use the type from the constant pool cache - __ shrl(rdx, ConstantPoolCacheEntry::tos_state_shift); - // Make sure we don't need to mask rdx after the above shift - ConstantPoolCacheEntry::verify_tos_state_shift(); -#ifdef _LP64 - Label notObj; - __ cmpl(rdx, atos); - __ jcc(Assembler::notEqual, notObj); - // atos - __ movptr(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notObj); -#endif // _LP64 - __ cmpl(rdx, btos); - __ jcc(Assembler::notEqual, notByte); - __ load_signed_byte(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notByte); - __ cmpl(rdx, stos); - __ jcc(Assembler::notEqual, notShort); - __ load_signed_short(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notShort); - __ cmpl(rdx, ctos); - __ jcc(Assembler::notEqual, notChar); - __ load_unsigned_short(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notChar); -#ifdef ASSERT - Label okay; -#ifndef _LP64 - __ cmpl(rdx, atos); - __ jcc(Assembler::equal, okay); -#endif // _LP64 - __ cmpl(rdx, itos); - __ jcc(Assembler::equal, okay); - __ stop("what type is this?"); - __ bind(okay); -#endif // ASSERT - // All the rest are a 32 bit wordsize - __ movl(rax, field_address); - - __ bind(xreturn_path); - - // _ireturn/_areturn - __ pop(rdi); // get return address - __ mov(rsp, sender_sp_on_entry); // set sp to sender sp - __ jmp(rdi); - - // generate a vanilla interpreter entry as the slow path - __ bind(slow_path); - // We will enter c++ interpreter looking like it was - // called by the call_stub this will cause it to return - // a tosca result to the invoker which might have been - // the c++ interpreter itself. - - __ jmp(fast_accessor_slow_entry_path); - return entry_point; - - } else { - return NULL; - } - -} - address InterpreterGenerator::generate_Reference_get_entry(void) { #if INCLUDE_ALL_GCS if (UseG1GC) { @@ -961,7 +807,7 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // If G1 is not enabled then attempt to go through the accessor entry point // Reference.get is an accessor - return generate_accessor_entry(); + return generate_jump_to_normal_entry(); } // @@ -1670,10 +1516,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { address entry_point = __ pc(); - // Fast accessor methods share this entry point. - // This works because frame manager is in the same codelet - if (UseFastAccessorMethods && !synchronized) __ bind(fast_accessor_slow_entry_path); - Label dispatch_entry_2; __ movptr(rcx, sender_sp_on_entry); __ movptr(state, (int32_t)NULL_WORD); // no current activation @@ -2212,40 +2054,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { return entry_point; } -address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) { - // determine code generation flags - bool synchronized = false; - address entry_point = NULL; - - switch (kind) { - case Interpreter::zerolocals : break; - case Interpreter::zerolocals_synchronized: synchronized = true; break; - case Interpreter::native : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false); break; - case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true); break; - case Interpreter::empty : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry(); break; - case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break; - case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break; - - case Interpreter::java_lang_math_sin : // fall thru - case Interpreter::java_lang_math_cos : // fall thru - case Interpreter::java_lang_math_tan : // fall thru - case Interpreter::java_lang_math_abs : // fall thru - case Interpreter::java_lang_math_log : // fall thru - case Interpreter::java_lang_math_log10 : // fall thru - case Interpreter::java_lang_math_sqrt : // fall thru - case Interpreter::java_lang_math_pow : // fall thru - case Interpreter::java_lang_math_exp : // fall thru - entry_point = ((InterpreterGenerator*)this)->generate_math_entry(kind); break; - case Interpreter::java_lang_ref_reference_get - : entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); break; - default : ShouldNotReachHere(); break; - } - - if (entry_point) return entry_point; - - return ((InterpreterGenerator*)this)->generate_normal_entry(synchronized); - -} InterpreterGenerator::InterpreterGenerator(StubQueue* code) : CppInterpreterGenerator(code) { diff --git a/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.cpp new file mode 100644 index 00000000000..229803a80ff --- /dev/null +++ b/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "asm/macroAssembler.hpp" +#include "interpreter/interpreter.hpp" +#include "interpreter/interpreterGenerator.hpp" +#include "interpreter/interpreterRuntime.hpp" +#include "interpreter/interp_masm.hpp" + +#define __ _masm-> + +// Jump into normal path for accessor and empty entry to jump to normal entry +// The "fast" optimization don't update compilation count therefore can disable inlining +// for these functions that should be inlined. +address InterpreterGenerator::generate_jump_to_normal_entry(void) { + address entry_point = __ pc(); + + assert(Interpreter::entry_for_kind(Interpreter::zerolocals) != NULL, "should already be generated"); + __ jump(RuntimeAddress(Interpreter::entry_for_kind(Interpreter::zerolocals))); + return entry_point; +} + +// Abstract method entry +// Attempt to execute abstract method. Throw exception +address InterpreterGenerator::generate_abstract_entry(void) { + + address entry_point = __ pc(); + + // abstract method entry + +#ifndef CC_INTERP + // pop return address, reset last_sp to NULL + __ empty_expression_stack(); + __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) + __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) +#endif + + // throw exception + __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); + // the call_VM checks for exception, so we should never return here. + __ should_not_reach_here(); + + return entry_point; +} diff --git a/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.hpp b/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.hpp index 08f47708cdc..b802e9c405b 100644 --- a/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.hpp +++ b/hotspot/src/cpu/x86/vm/interpreterGenerator_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,8 +36,9 @@ address generate_native_entry(bool synchronized); address generate_abstract_entry(void); address generate_math_entry(AbstractInterpreter::MethodKind kind); - address generate_empty_entry(void); - address generate_accessor_entry(void); + address generate_jump_to_normal_entry(void); + address generate_accessor_entry(void) { return generate_jump_to_normal_entry(); } + address generate_empty_entry(void) { return generate_jump_to_normal_entry(); } address generate_Reference_get_entry(); address generate_CRC32_update_entry(); address generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind); diff --git a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp index abe354360ff..4a2903b3736 100644 --- a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp @@ -67,45 +67,6 @@ address AbstractInterpreterGenerator::generate_slow_signature_handler() { } -// -// Various method entries (that c++ and asm interpreter agree upon) -//------------------------------------------------------------------------------------------------------------------------ -// -// - -// Empty method, generate a very fast return. - -address InterpreterGenerator::generate_empty_entry(void) { - - // rbx,: Method* - // rcx: receiver (unused) - // rsi: previous interpreter state (C++ interpreter) must preserve - // rsi: sender sp must set sp to this value on return - - if (!UseFastEmptyMethods) return NULL; - - address entry_point = __ pc(); - - // If we need a safepoint check, generate full interpreter entry. - Label slow_path; - ExternalAddress state(SafepointSynchronize::address_of_state()); - __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), - SafepointSynchronize::_not_synchronized); - __ jcc(Assembler::notEqual, slow_path); - - // do nothing for empty methods (do not even increment invocation counter) - // Code: _return - // _return - // return w/o popping parameters - __ pop(rax); - __ mov(rsp, rsi); - __ jmp(rax); - - __ bind(slow_path); - (void) generate_normal_entry(false); - return entry_point; -} - address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { // rbx,: Method* @@ -216,36 +177,6 @@ address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKin } -// Abstract method entry -// Attempt to execute abstract method. Throw exception -address InterpreterGenerator::generate_abstract_entry(void) { - - // rbx,: Method* - // rcx: receiver (unused) - // rsi: previous interpreter state (C++ interpreter) must preserve - - // rsi: sender SP - - address entry_point = __ pc(); - - // abstract method entry - -#ifndef CC_INTERP - // pop return address, reset last_sp to NULL - __ empty_expression_stack(); - __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) - __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) -#endif - - // throw exception - __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); - // the call_VM checks for exception, so we should never return here. - __ should_not_reach_here(); - - return entry_point; -} - - void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in diff --git a/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp index 65ffc6d2e97..af4f7fac388 100644 --- a/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp @@ -301,66 +301,6 @@ address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKin return entry_point; } - -// Abstract method entry -// Attempt to execute abstract method. Throw exception -address InterpreterGenerator::generate_abstract_entry(void) { - // rbx: Method* - // r13: sender SP - - address entry_point = __ pc(); - - // abstract method entry - -#ifndef CC_INTERP - // pop return address, reset last_sp to NULL - __ empty_expression_stack(); - __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) - __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) -#endif - - // throw exception - __ call_VM(noreg, CAST_FROM_FN_PTR(address, - InterpreterRuntime::throw_AbstractMethodError)); - // the call_VM checks for exception, so we should never return here. - __ should_not_reach_here(); - - return entry_point; -} - - -// Empty method, generate a very fast return. - -address InterpreterGenerator::generate_empty_entry(void) { - // rbx: Method* - // r13: sender sp must set sp to this value on return - - if (!UseFastEmptyMethods) { - return NULL; - } - - address entry_point = __ pc(); - - // If we need a safepoint check, generate full interpreter entry. - Label slow_path; - __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), - SafepointSynchronize::_not_synchronized); - __ jcc(Assembler::notEqual, slow_path); - - // do nothing for empty methods (do not even increment invocation counter) - // Code: _return - // _return - // return w/o popping parameters - __ pop(rax); - __ mov(rsp, r13); - __ jmp(rax); - - __ bind(slow_path); - (void) generate_normal_entry(false); - return entry_point; - -} - void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index 5b324124138..7216c198027 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -7316,17 +7316,34 @@ void MacroAssembler::update_byte_crc32(Register crc, Register val, Register tabl * Fold 128-bit data chunk */ void MacroAssembler::fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegister xtmp, Register buf, int offset) { - vpclmulhdq(xtmp, xK, xcrc); // [123:64] - vpclmulldq(xcrc, xK, xcrc); // [63:0] - vpxor(xcrc, xcrc, Address(buf, offset), false /* vector256 */); - pxor(xcrc, xtmp); + if (UseAVX > 0) { + vpclmulhdq(xtmp, xK, xcrc); // [123:64] + vpclmulldq(xcrc, xK, xcrc); // [63:0] + vpxor(xcrc, xcrc, Address(buf, offset), false /* vector256 */); + pxor(xcrc, xtmp); + } else { + movdqa(xtmp, xcrc); + pclmulhdq(xtmp, xK); // [123:64] + pclmulldq(xcrc, xK); // [63:0] + pxor(xcrc, xtmp); + movdqu(xtmp, Address(buf, offset)); + pxor(xcrc, xtmp); + } } void MacroAssembler::fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegister xtmp, XMMRegister xbuf) { - vpclmulhdq(xtmp, xK, xcrc); - vpclmulldq(xcrc, xK, xcrc); - pxor(xcrc, xbuf); - pxor(xcrc, xtmp); + if (UseAVX > 0) { + vpclmulhdq(xtmp, xK, xcrc); + vpclmulldq(xcrc, xK, xcrc); + pxor(xcrc, xbuf); + pxor(xcrc, xtmp); + } else { + movdqa(xtmp, xcrc); + pclmulhdq(xtmp, xK); + pclmulldq(xcrc, xK); + pxor(xcrc, xbuf); + pxor(xcrc, xtmp); + } } /** @@ -7444,9 +7461,17 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, Regi // Fold 128 bits in xmm1 down into 32 bits in crc register. BIND(L_fold_128b); movdqu(xmm0, ExternalAddress(StubRoutines::x86::crc_by128_masks_addr())); - vpclmulqdq(xmm2, xmm0, xmm1, 0x1); - vpand(xmm3, xmm0, xmm2, false /* vector256 */); - vpclmulqdq(xmm0, xmm0, xmm3, 0x1); + if (UseAVX > 0) { + vpclmulqdq(xmm2, xmm0, xmm1, 0x1); + vpand(xmm3, xmm0, xmm2, false /* vector256 */); + vpclmulqdq(xmm0, xmm0, xmm3, 0x1); + } else { + movdqa(xmm2, xmm0); + pclmulqdq(xmm2, xmm1, 0x1); + movdqa(xmm3, xmm0); + pand(xmm3, xmm2); + pclmulqdq(xmm0, xmm3, 0x1); + } psrldq(xmm1, 8); psrldq(xmm2, 4); pxor(xmm0, xmm1); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 3d8802632a4..3b3073e633a 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -966,6 +966,16 @@ public: void mulss(XMMRegister dst, Address src) { Assembler::mulss(dst, src); } void mulss(XMMRegister dst, AddressLiteral src); + // Carry-Less Multiplication Quadword + void pclmulldq(XMMRegister dst, XMMRegister src) { + // 0x00 - multiply lower 64 bits [0:63] + Assembler::pclmulqdq(dst, src, 0x00); + } + void pclmulhdq(XMMRegister dst, XMMRegister src) { + // 0x11 - multiply upper 64 bits [64:127] + Assembler::pclmulqdq(dst, src, 0x11); + } + void sqrtsd(XMMRegister dst, XMMRegister src) { Assembler::sqrtsd(dst, src); } void sqrtsd(XMMRegister dst, Address src) { Assembler::sqrtsd(dst, src); } void sqrtsd(XMMRegister dst, AddressLiteral src); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.cpp index 23dcbee036e..7a12d82e9af 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.cpp @@ -38,7 +38,7 @@ int AbstractInterpreter::size_activation(int max_stack, int callee_locals, bool is_top_frame) { // Note: This calculation must exactly parallel the frame setup - // in AbstractInterpreterGenerator::generate_method_entry. + // in InterpreterGenerator::generate_fixed_frame. // fixed size of an interpreter frame: int overhead = frame::sender_sp_offset - diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index e705dfbe0ce..93772f3df4c 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -468,10 +468,10 @@ void InterpreterGenerator::generate_stack_overflow_check(void) { // rax, // NOTE: since the additional locals are also always pushed (wasn't obvious in - // generate_method_entry) so the guard should work for them too. + // generate_fixed_frame) so the guard should work for them too. // - // monitor entry size: see picture of stack set (generate_method_entry) and frame_x86.hpp + // monitor entry size: see picture of stack in frame_x86.hpp const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; // total overhead size: entry_size + (saved rbp, thru expr stack bottom). @@ -633,145 +633,6 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { __ movptr(Address(rsp, 0), rsp); // set expression stack bottom } -// End of helpers - -// -// Various method entries -//------------------------------------------------------------------------------------------------------------------------ -// -// - -// Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry - -address InterpreterGenerator::generate_accessor_entry(void) { - - // rbx,: Method* - // rcx: receiver (preserve for slow entry into asm interpreter) - - // rsi: senderSP must preserved for slow path, set SP to it on fast path - - address entry_point = __ pc(); - Label xreturn_path; - - // do fastpath for resolved accessor methods - if (UseFastAccessorMethods) { - Label slow_path; - // If we need a safepoint check, generate full interpreter entry. - ExternalAddress state(SafepointSynchronize::address_of_state()); - __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), - SafepointSynchronize::_not_synchronized); - - __ jcc(Assembler::notEqual, slow_path); - // ASM/C++ Interpreter - // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; parameter size = 1 - // Note: We can only use this code if the getfield has been resolved - // and if we don't have a null-pointer exception => check for - // these conditions first and use slow path if necessary. - // rbx,: method - // rcx: receiver - __ movptr(rax, Address(rsp, wordSize)); - - // check if local 0 != NULL and read field - __ testptr(rax, rax); - __ jcc(Assembler::zero, slow_path); - - // read first instruction word and extract bytecode @ 1 and index @ 2 - __ movptr(rdx, Address(rbx, Method::const_offset())); - __ movptr(rdi, Address(rdx, ConstMethod::constants_offset())); - __ movl(rdx, Address(rdx, ConstMethod::codes_offset())); - // Shift codes right to get the index on the right. - // The bytecode fetched looks like <0xb4><0x2a> - __ shrl(rdx, 2*BitsPerByte); - __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); - __ movptr(rdi, Address(rdi, ConstantPool::cache_offset_in_bytes())); - - // rax,: local 0 - // rbx,: method - // rcx: receiver - do not destroy since it is needed for slow path! - // rcx: scratch - // rdx: constant pool cache index - // rdi: constant pool cache - // rsi: sender sp - - // check if getfield has been resolved and read constant pool cache entry - // check the validity of the cache entry by testing whether _indices field - // contains Bytecode::_getfield in b1 byte. - assert(in_words(ConstantPoolCacheEntry::size()) == 4, "adjust shift below"); - __ movl(rcx, - Address(rdi, - rdx, - Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset())); - __ shrl(rcx, 2*BitsPerByte); - __ andl(rcx, 0xFF); - __ cmpl(rcx, Bytecodes::_getfield); - __ jcc(Assembler::notEqual, slow_path); - - // Note: constant pool entry is not valid before bytecode is resolved - __ movptr(rcx, - Address(rdi, - rdx, - Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::f2_offset())); - __ movl(rdx, - Address(rdi, - rdx, - Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); - - Label notByte, notShort, notChar; - const Address field_address (rax, rcx, Address::times_1); - - // Need to differentiate between igetfield, agetfield, bgetfield etc. - // because they are different sizes. - // Use the type from the constant pool cache - __ shrl(rdx, ConstantPoolCacheEntry::tos_state_shift); - // Make sure we don't need to mask rdx after the above shift - ConstantPoolCacheEntry::verify_tos_state_shift(); - __ cmpl(rdx, btos); - __ jcc(Assembler::notEqual, notByte); - __ load_signed_byte(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notByte); - __ cmpl(rdx, stos); - __ jcc(Assembler::notEqual, notShort); - __ load_signed_short(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notShort); - __ cmpl(rdx, ctos); - __ jcc(Assembler::notEqual, notChar); - __ load_unsigned_short(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notChar); -#ifdef ASSERT - Label okay; - __ cmpl(rdx, atos); - __ jcc(Assembler::equal, okay); - __ cmpl(rdx, itos); - __ jcc(Assembler::equal, okay); - __ stop("what type is this?"); - __ bind(okay); -#endif // ASSERT - // All the rest are a 32 bit wordsize - // This is ok for now. Since fast accessors should be going away - __ movptr(rax, field_address); - - __ bind(xreturn_path); - - // _ireturn/_areturn - __ pop(rdi); // get return address - __ mov(rsp, rsi); // set sp to sender sp - __ jmp(rdi); - - // generate a vanilla interpreter entry as the slow path - __ bind(slow_path); - - (void) generate_normal_entry(false); - return entry_point; - } - return NULL; - -} // Method entry for java.lang.ref.Reference.get. address InterpreterGenerator::generate_Reference_get_entry(void) { @@ -862,7 +723,7 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // If G1 is not enabled then attempt to go through the accessor entry point // Reference.get is an accessor - return generate_accessor_entry(); + return generate_jump_to_normal_entry(); } /** @@ -1557,100 +1418,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { return entry_point; } -//------------------------------------------------------------------------------------------------------------------------ -// Entry points -// -// Here we generate the various kind of entries into the interpreter. -// The two main entry type are generic bytecode methods and native call method. -// These both come in synchronized and non-synchronized versions but the -// frame layout they create is very similar. The other method entry -// types are really just special purpose entries that are really entry -// and interpretation all in one. These are for trivial methods like -// accessor, empty, or special math methods. -// -// When control flow reaches any of the entry types for the interpreter -// the following holds -> -// -// Arguments: -// -// rbx,: Method* -// rcx: receiver -// -// -// Stack layout immediately at entry -// -// [ return address ] <--- rsp -// [ parameter n ] -// ... -// [ parameter 1 ] -// [ expression stack ] (caller's java expression stack) - -// Assuming that we don't go to one of the trivial specialized -// entries the stack will look like below when we are ready to execute -// the first bytecode (or call the native routine). The register usage -// will be as the template based interpreter expects (see interpreter_x86.hpp). -// -// local variables follow incoming parameters immediately; i.e. -// the return address is moved to the end of the locals). -// -// [ monitor entry ] <--- rsp -// ... -// [ monitor entry ] -// [ expr. stack bottom ] -// [ saved rsi ] -// [ current rdi ] -// [ Method* ] -// [ saved rbp, ] <--- rbp, -// [ return address ] -// [ local variable m ] -// ... -// [ local variable 1 ] -// [ parameter n ] -// ... -// [ parameter 1 ] <--- rdi - -address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) { - // determine code generation flags - bool synchronized = false; - address entry_point = NULL; - InterpreterGenerator* ig_this = (InterpreterGenerator*)this; - - switch (kind) { - case Interpreter::zerolocals : break; - case Interpreter::zerolocals_synchronized: synchronized = true; break; - case Interpreter::native : entry_point = ig_this->generate_native_entry(false); break; - case Interpreter::native_synchronized : entry_point = ig_this->generate_native_entry(true); break; - case Interpreter::empty : entry_point = ig_this->generate_empty_entry(); break; - case Interpreter::accessor : entry_point = ig_this->generate_accessor_entry(); break; - case Interpreter::abstract : entry_point = ig_this->generate_abstract_entry(); break; - - case Interpreter::java_lang_math_sin : // fall thru - case Interpreter::java_lang_math_cos : // fall thru - case Interpreter::java_lang_math_tan : // fall thru - case Interpreter::java_lang_math_abs : // fall thru - case Interpreter::java_lang_math_log : // fall thru - case Interpreter::java_lang_math_log10 : // fall thru - case Interpreter::java_lang_math_sqrt : // fall thru - case Interpreter::java_lang_math_pow : // fall thru - case Interpreter::java_lang_math_exp : entry_point = ig_this->generate_math_entry(kind); break; - case Interpreter::java_lang_ref_reference_get - : entry_point = ig_this->generate_Reference_get_entry(); break; - case Interpreter::java_util_zip_CRC32_update - : entry_point = ig_this->generate_CRC32_update_entry(); break; - case Interpreter::java_util_zip_CRC32_updateBytes - : // fall thru - case Interpreter::java_util_zip_CRC32_updateByteBuffer - : entry_point = ig_this->generate_CRC32_updateBytes_entry(kind); break; - default: - fatal(err_msg("unexpected method kind: %d", kind)); - break; - } - - if (entry_point) return entry_point; - - return ig_this->generate_normal_entry(synchronized); - -} // These should never be compiled since the interpreter will prefer // the compiled version to the intrinsic version. diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index 9c81d6787a1..f3390c94ca9 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -400,7 +400,7 @@ void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { // page mechanism will work for that. // // NOTE: Since the additional locals are also always pushed (wasn't -// obvious in generate_method_entry) so the guard should work for them +// obvious in generate_fixed_frame) so the guard should work for them // too. // // Args: @@ -411,8 +411,7 @@ void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { // rax void InterpreterGenerator::generate_stack_overflow_check(void) { - // monitor entry size: see picture of stack set - // (generate_method_entry) and frame_amd64.hpp + // monitor entry size: see picture of stack in frame_x86.hpp const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; // total overhead size: entry_size + (saved rbp through expr stack @@ -600,153 +599,6 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { // End of helpers -// Various method entries -//------------------------------------------------------------------------------------------------------------------------ -// -// - -// Call an accessor method (assuming it is resolved, otherwise drop -// into vanilla (slow path) entry -address InterpreterGenerator::generate_accessor_entry(void) { - // rbx: Method* - - // r13: senderSP must preserver for slow path, set SP to it on fast path - - address entry_point = __ pc(); - Label xreturn_path; - - // do fastpath for resolved accessor methods - if (UseFastAccessorMethods) { - // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites - // thereof; parameter size = 1 - // Note: We can only use this code if the getfield has been resolved - // and if we don't have a null-pointer exception => check for - // these conditions first and use slow path if necessary. - Label slow_path; - // If we need a safepoint check, generate full interpreter entry. - __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), - SafepointSynchronize::_not_synchronized); - - __ jcc(Assembler::notEqual, slow_path); - // rbx: method - __ movptr(rax, Address(rsp, wordSize)); - - // check if local 0 != NULL and read field - __ testptr(rax, rax); - __ jcc(Assembler::zero, slow_path); - - // read first instruction word and extract bytecode @ 1 and index @ 2 - __ movptr(rdx, Address(rbx, Method::const_offset())); - __ movptr(rdi, Address(rdx, ConstMethod::constants_offset())); - __ movl(rdx, Address(rdx, ConstMethod::codes_offset())); - // Shift codes right to get the index on the right. - // The bytecode fetched looks like <0xb4><0x2a> - __ shrl(rdx, 2 * BitsPerByte); - __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); - __ movptr(rdi, Address(rdi, ConstantPool::cache_offset_in_bytes())); - - // rax: local 0 - // rbx: method - // rdx: constant pool cache index - // rdi: constant pool cache - - // check if getfield has been resolved and read constant pool cache entry - // check the validity of the cache entry by testing whether _indices field - // contains Bytecode::_getfield in b1 byte. - assert(in_words(ConstantPoolCacheEntry::size()) == 4, - "adjust shift below"); - __ movl(rcx, - Address(rdi, - rdx, - Address::times_8, - ConstantPoolCache::base_offset() + - ConstantPoolCacheEntry::indices_offset())); - __ shrl(rcx, 2 * BitsPerByte); - __ andl(rcx, 0xFF); - __ cmpl(rcx, Bytecodes::_getfield); - __ jcc(Assembler::notEqual, slow_path); - - // Note: constant pool entry is not valid before bytecode is resolved - __ movptr(rcx, - Address(rdi, - rdx, - Address::times_8, - ConstantPoolCache::base_offset() + - ConstantPoolCacheEntry::f2_offset())); - // edx: flags - __ movl(rdx, - Address(rdi, - rdx, - Address::times_8, - ConstantPoolCache::base_offset() + - ConstantPoolCacheEntry::flags_offset())); - - Label notObj, notInt, notByte, notShort; - const Address field_address(rax, rcx, Address::times_1); - - // Need to differentiate between igetfield, agetfield, bgetfield etc. - // because they are different sizes. - // Use the type from the constant pool cache - __ shrl(rdx, ConstantPoolCacheEntry::tos_state_shift); - // Make sure we don't need to mask edx after the above shift - ConstantPoolCacheEntry::verify_tos_state_shift(); - - __ cmpl(rdx, atos); - __ jcc(Assembler::notEqual, notObj); - // atos - __ load_heap_oop(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notObj); - __ cmpl(rdx, itos); - __ jcc(Assembler::notEqual, notInt); - // itos - __ movl(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notInt); - __ cmpl(rdx, btos); - __ jcc(Assembler::notEqual, notByte); - // btos - __ load_signed_byte(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notByte); - __ cmpl(rdx, stos); - __ jcc(Assembler::notEqual, notShort); - // stos - __ load_signed_short(rax, field_address); - __ jmp(xreturn_path); - - __ bind(notShort); -#ifdef ASSERT - Label okay; - __ cmpl(rdx, ctos); - __ jcc(Assembler::equal, okay); - __ stop("what type is this?"); - __ bind(okay); -#endif - // ctos - __ load_unsigned_short(rax, field_address); - - __ bind(xreturn_path); - - // _ireturn/_areturn - __ pop(rdi); - __ mov(rsp, r13); - __ jmp(rdi); - __ ret(0); - - // generate a vanilla interpreter entry as the slow path - __ bind(slow_path); - (void) generate_normal_entry(false); - } else { - (void) generate_normal_entry(false); - } - - return entry_point; -} - // Method entry for java.lang.ref.Reference.get. address InterpreterGenerator::generate_Reference_get_entry(void) { #if INCLUDE_ALL_GCS @@ -773,8 +625,6 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // and so we don't need to call the G1 pre-barrier. Thus we can use the // regular method entry code to generate the NPE. // - // This code is based on generate_accessor_enty. - // // rbx: Method* // r13: senderSP must preserve for slow path, set SP to it on fast path @@ -832,7 +682,7 @@ address InterpreterGenerator::generate_Reference_get_entry(void) { // If G1 is not enabled then attempt to go through the accessor entry point // Reference.get is an accessor - return generate_accessor_entry(); + return generate_jump_to_normal_entry(); } /** @@ -1566,100 +1416,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { return entry_point; } -// Entry points -// -// Here we generate the various kind of entries into the interpreter. -// The two main entry type are generic bytecode methods and native -// call method. These both come in synchronized and non-synchronized -// versions but the frame layout they create is very similar. The -// other method entry types are really just special purpose entries -// that are really entry and interpretation all in one. These are for -// trivial methods like accessor, empty, or special math methods. -// -// When control flow reaches any of the entry types for the interpreter -// the following holds -> -// -// Arguments: -// -// rbx: Method* -// -// Stack layout immediately at entry -// -// [ return address ] <--- rsp -// [ parameter n ] -// ... -// [ parameter 1 ] -// [ expression stack ] (caller's java expression stack) - -// Assuming that we don't go to one of the trivial specialized entries -// the stack will look like below when we are ready to execute the -// first bytecode (or call the native routine). The register usage -// will be as the template based interpreter expects (see -// interpreter_amd64.hpp). -// -// local variables follow incoming parameters immediately; i.e. -// the return address is moved to the end of the locals). -// -// [ monitor entry ] <--- rsp -// ... -// [ monitor entry ] -// [ expr. stack bottom ] -// [ saved r13 ] -// [ current r14 ] -// [ Method* ] -// [ saved ebp ] <--- rbp -// [ return address ] -// [ local variable m ] -// ... -// [ local variable 1 ] -// [ parameter n ] -// ... -// [ parameter 1 ] <--- r14 - -address AbstractInterpreterGenerator::generate_method_entry( - AbstractInterpreter::MethodKind kind) { - // determine code generation flags - bool synchronized = false; - address entry_point = NULL; - InterpreterGenerator* ig_this = (InterpreterGenerator*)this; - - switch (kind) { - case Interpreter::zerolocals : break; - case Interpreter::zerolocals_synchronized: synchronized = true; break; - case Interpreter::native : entry_point = ig_this->generate_native_entry(false); break; - case Interpreter::native_synchronized : entry_point = ig_this->generate_native_entry(true); break; - case Interpreter::empty : entry_point = ig_this->generate_empty_entry(); break; - case Interpreter::accessor : entry_point = ig_this->generate_accessor_entry(); break; - case Interpreter::abstract : entry_point = ig_this->generate_abstract_entry(); break; - - case Interpreter::java_lang_math_sin : // fall thru - case Interpreter::java_lang_math_cos : // fall thru - case Interpreter::java_lang_math_tan : // fall thru - case Interpreter::java_lang_math_abs : // fall thru - case Interpreter::java_lang_math_log : // fall thru - case Interpreter::java_lang_math_log10 : // fall thru - case Interpreter::java_lang_math_sqrt : // fall thru - case Interpreter::java_lang_math_pow : // fall thru - case Interpreter::java_lang_math_exp : entry_point = ig_this->generate_math_entry(kind); break; - case Interpreter::java_lang_ref_reference_get - : entry_point = ig_this->generate_Reference_get_entry(); break; - case Interpreter::java_util_zip_CRC32_update - : entry_point = ig_this->generate_CRC32_update_entry(); break; - case Interpreter::java_util_zip_CRC32_updateBytes - : // fall thru - case Interpreter::java_util_zip_CRC32_updateByteBuffer - : entry_point = ig_this->generate_CRC32_updateBytes_entry(kind); break; - default: - fatal(err_msg("unexpected method kind: %d", kind)); - break; - } - - if (entry_point) { - return entry_point; - } - - return ig_this->generate_normal_entry(synchronized); -} // These should never be compiled since the interpreter will prefer // the compiled version to the intrinsic version. diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp index 57a1545166a..5145d801298 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp @@ -27,6 +27,7 @@ #include "asm/macroAssembler.inline.hpp" #include "memory/resourceArea.hpp" #include "runtime/java.hpp" +#include "runtime/os.hpp" #include "runtime/stubCodeGenerator.hpp" #include "vm_version_x86.hpp" @@ -514,7 +515,7 @@ void VM_Version::get_processor_features() { (supports_tscinv() ? ", tscinv": ""), (supports_bmi1() ? ", bmi1" : ""), (supports_bmi2() ? ", bmi2" : "")); - _features_str = strdup(buf); + _features_str = os::strdup(buf); // UseSSE is set to the smaller of what hardware supports and what // the command line requires. I.e., you cannot set UseSSE to 2 on @@ -559,7 +560,7 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseCLMUL, false); } - if (UseCLMUL && (UseAVX > 0) && (UseSSE > 2)) { + if (UseCLMUL && (UseSSE > 2)) { if (FLAG_IS_DEFAULT(UseCRC32Intrinsics)) { UseCRC32Intrinsics = true; } @@ -805,6 +806,21 @@ void VM_Version::get_processor_features() { } } } + if ((cpu_family() == 0x06) && + ((extended_cpu_model() == 0x36) || // Centerton + (extended_cpu_model() == 0x37) || // Silvermont + (extended_cpu_model() == 0x4D))) { +#ifdef COMPILER2 + if (FLAG_IS_DEFAULT(OptoScheduling)) { + OptoScheduling = true; + } +#endif + if (supports_sse4_2()) { // Silvermont + if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) { + UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus + } + } + } } // Use count leading zeros count instruction if available. @@ -892,23 +908,25 @@ void VM_Version::get_processor_features() { AllocatePrefetchDistance = allocate_prefetch_distance(); AllocatePrefetchStyle = allocate_prefetch_style(); - if( is_intel() && cpu_family() == 6 && supports_sse3() ) { - if( AllocatePrefetchStyle == 2 ) { // watermark prefetching on Core + if (is_intel() && cpu_family() == 6 && supports_sse3()) { + if (AllocatePrefetchStyle == 2) { // watermark prefetching on Core #ifdef _LP64 AllocatePrefetchDistance = 384; #else AllocatePrefetchDistance = 320; #endif } - if( supports_sse4_2() && supports_ht() ) { // Nehalem based cpus + if (supports_sse4_2() && supports_ht()) { // Nehalem based cpus AllocatePrefetchDistance = 192; AllocatePrefetchLines = 4; + } #ifdef COMPILER2 - if (AggressiveOpts && FLAG_IS_DEFAULT(UseFPUForSpilling)) { + if (supports_sse4_2()) { + if (FLAG_IS_DEFAULT(UseFPUForSpilling)) { FLAG_SET_DEFAULT(UseFPUForSpilling, true); } -#endif } +#endif } assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value"); diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp index fe9115be9ec..929481c3fbf 100644 --- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -831,60 +831,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { return generate_entry((address) CppInterpreter::normal_entry); } -address AbstractInterpreterGenerator::generate_method_entry( - AbstractInterpreter::MethodKind kind) { - address entry_point = NULL; - - switch (kind) { - case Interpreter::zerolocals: - case Interpreter::zerolocals_synchronized: - break; - - case Interpreter::native: - entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); - break; - - case Interpreter::native_synchronized: - entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); - break; - - case Interpreter::empty: - entry_point = ((InterpreterGenerator*) this)->generate_empty_entry(); - break; - - case Interpreter::accessor: - entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry(); - break; - - case Interpreter::abstract: - entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry(); - break; - - case Interpreter::java_lang_math_sin: - case Interpreter::java_lang_math_cos: - case Interpreter::java_lang_math_tan: - case Interpreter::java_lang_math_abs: - case Interpreter::java_lang_math_log: - case Interpreter::java_lang_math_log10: - case Interpreter::java_lang_math_sqrt: - case Interpreter::java_lang_math_pow: - case Interpreter::java_lang_math_exp: - entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind); - break; - - case Interpreter::java_lang_ref_reference_get: - entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry(); - break; - - default: - ShouldNotReachHere(); - } - - if (entry_point == NULL) - entry_point = ((InterpreterGenerator*) this)->generate_normal_entry(false); - - return entry_point; -} InterpreterGenerator::InterpreterGenerator(StubQueue* code) : CppInterpreterGenerator(code) { diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp index 0f88bba8537..7698a7a2480 100644 --- a/hotspot/src/cpu/zero/vm/globals_zero.hpp +++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -61,6 +61,12 @@ define_pd_global(uintx, CMSYoungGenPerWorker, 16*M); // default max size of CMS define_pd_global(uintx, TypeProfileLevel, 0); -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct) +#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct) \ + product(bool, UseFastEmptyMethods, true, \ + "Use fast method entry code for empty methods") \ + \ + product(bool, UseFastAccessorMethods, true, \ + "Use fast method entry code for accessor methods") \ + \ #endif // CPU_ZERO_VM_GLOBALS_ZERO_HPP diff --git a/hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp b/hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp index eb170370630..68516b4daf9 100644 --- a/hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp +++ b/hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,4 +39,7 @@ address generate_accessor_entry(); address generate_Reference_get_entry(); + // Not supported + address generate_CRC32_update_entry() { return NULL; } + address generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) { return NULL; } #endif // CPU_ZERO_VM_INTERPRETERGENERATOR_ZERO_HPP diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index 70ca91a62ce..6d8c55bf541 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -58,6 +58,7 @@ #include "runtime/mutexLocker.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/orderAccess.inline.hpp" +#include "runtime/os.hpp" #include "runtime/osThread.hpp" #include "runtime/perfMemory.hpp" #include "runtime/sharedRuntime.hpp" @@ -378,10 +379,10 @@ void os::Aix::query_multipage_support() { // default should be 4K. size_t data_page_size = SIZE_4K; { - void* p = ::malloc(SIZE_16M); + void* p = os::malloc(SIZE_16M, mtInternal); guarantee(p != NULL, "malloc failed"); data_page_size = os::Aix::query_pagesize(p); - ::free(p); + os::free(p); } // query default shm page size (LDR_CNTRL SHMPSIZE) diff --git a/hotspot/src/os/aix/vm/porting_aix.cpp b/hotspot/src/os/aix/vm/porting_aix.cpp index 5e6a78ddcc9..038693cfdf1 100644 --- a/hotspot/src/os/aix/vm/porting_aix.cpp +++ b/hotspot/src/os/aix/vm/porting_aix.cpp @@ -24,6 +24,8 @@ #include "asm/assembler.hpp" #include "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" +#include "runtime/os.hpp" #include "loadlib_aix.hpp" #include "porting_aix.hpp" #include "utilities/debug.hpp" @@ -83,7 +85,7 @@ class fixed_strings { while (n) { node* p = n; n = n->next; - free(p->v); + os::free(p->v); delete p; } } @@ -95,7 +97,7 @@ class fixed_strings { } } node* p = new node; - p->v = strdup(s); + p->v = os::strdup_check_oom(s); p->next = first; first = p; return p->v; diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index b0756b8bc2b..51e9f866cf2 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -2439,23 +2439,25 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, } // The memory is committed - MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, CALLER_PC); return addr; } bool os::release_memory_special(char* base, size_t bytes) { - MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - // detaching the SHM segment will also delete it, see reserve_memory_special() - int rslt = shmdt(base); - if (rslt == 0) { - tkr.record((address)base, bytes); - return true; + if (MemTracker::tracking_level() > NMT_minimal) { + Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + // detaching the SHM segment will also delete it, see reserve_memory_special() + int rslt = shmdt(base); + if (rslt == 0) { + tkr.record((address)base, bytes); + return true; + } else { + return false; + } } else { - tkr.discard(); - return false; + return shmdt(base) == 0; } - } size_t os::large_page_size() { diff --git a/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp b/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp index e812a76f51b..2737fe38ce1 100644 --- a/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp +++ b/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp @@ -753,7 +753,7 @@ static char* mmap_create_shared(size_t size) { (void)::memset((void*) mapAddress, 0, size); // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, CURRENT_PC, mtInternal); return mapAddress; } @@ -918,7 +918,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor } // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, CURRENT_PC, mtInternal); *addr = mapAddress; *sizep = size; diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index ed12d800c5b..9668cb17d7d 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -3504,9 +3504,12 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t al assert(is_ptr_aligned(start, alignment), "Must be"); - // os::reserve_memory_special will record this memory area. - // Need to release it here to prevent overlapping reservations. - MemTracker::record_virtual_memory_release((address)start, bytes); + if (MemTracker::tracking_level() > NMT_minimal) { + // os::reserve_memory_special will record this memory area. + // Need to release it here to prevent overlapping reservations. + Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + tkr.record((address)start, bytes); + } char* end = start + bytes; @@ -3601,7 +3604,7 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, } // The memory is committed - MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, CALLER_PC); } return addr; @@ -3617,24 +3620,30 @@ bool os::Linux::release_memory_special_huge_tlbfs(char* base, size_t bytes) { } bool os::release_memory_special(char* base, size_t bytes) { - assert(UseLargePages, "only for large pages"); - - MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - bool res; + if (MemTracker::tracking_level() > NMT_minimal) { + Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + res = os::Linux::release_memory_special_impl(base, bytes); + if (res) { + tkr.record((address)base, bytes); + } + + } else { + res = os::Linux::release_memory_special_impl(base, bytes); + } + return res; +} + +bool os::Linux::release_memory_special_impl(char* base, size_t bytes) { + assert(UseLargePages, "only for large pages"); + bool res; + if (UseSHM) { res = os::Linux::release_memory_special_shm(base, bytes); } else { assert(UseHugeTLBFS, "must be"); res = os::Linux::release_memory_special_huge_tlbfs(base, bytes); } - - if (res) { - tkr.record((address)base, bytes); - } else { - tkr.discard(); - } - return res; } diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 1b62f3f35ea..cf9b71b4033 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -108,6 +108,7 @@ class Linux { static char* reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec); static char* reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec); + static bool release_memory_special_impl(char* base, size_t bytes); static bool release_memory_special_shm(char* base, size_t bytes); static bool release_memory_special_huge_tlbfs(char* base, size_t bytes); diff --git a/hotspot/src/os/linux/vm/perfMemory_linux.cpp b/hotspot/src/os/linux/vm/perfMemory_linux.cpp index 9708734295f..2eef5da69f9 100644 --- a/hotspot/src/os/linux/vm/perfMemory_linux.cpp +++ b/hotspot/src/os/linux/vm/perfMemory_linux.cpp @@ -753,7 +753,7 @@ static char* mmap_create_shared(size_t size) { (void)::memset((void*) mapAddress, 0, size); // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, CURRENT_PC, mtInternal); return mapAddress; } @@ -924,7 +924,7 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor } // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, CURRENT_PC, mtInternal); *addr = mapAddress; *sizep = size; diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index d17bc15cbae..66ad5d8a904 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -75,21 +75,41 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* VMError::report_coredump_status(buffer, success); } -address os::get_caller_pc(int n) { +int os::get_native_stack(address* stack, int frames, int toSkip) { #ifdef _NMT_NOINLINE_ - n ++; + toSkip++; #endif + + int frame_idx = 0; + int num_of_frames; // number of frames captured frame fr = os::current_frame(); - while (n > 0 && fr.pc() && - !os::is_first_C_frame(&fr) && fr.sender_pc()) { - fr = os::get_sender_for_C_frame(&fr); - n --; + while (fr.pc() && frame_idx < frames) { + if (toSkip > 0) { + toSkip --; + } else { + stack[frame_idx ++] = fr.pc(); + } + if (fr.fp() == NULL || os::is_first_C_frame(&fr) + ||fr.sender_pc() == NULL || fr.cb() != NULL) break; + + if (fr.sender_pc() && !os::is_first_C_frame(&fr)) { + fr = os::get_sender_for_C_frame(&fr); + } else { + break; + } } - if (n == 0) { - return fr.pc(); - } else { - return NULL; + num_of_frames = frame_idx; + for (; frame_idx < frames; frame_idx ++) { + stack[frame_idx] = NULL; } + + return num_of_frames; +} + + +bool os::unsetenv(const char* name) { + assert(name != NULL, "Null pointer"); + return (::unsetenv(name) == 0); } int os::get_last_error() { diff --git a/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp b/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp index 1fa30012d6b..2d279af0c2b 100644 --- a/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp +++ b/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp @@ -770,7 +770,8 @@ static char* mmap_create_shared(size_t size) { (void)::memset((void*) mapAddress, 0, size); // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, + size, CURRENT_PC, mtInternal); return mapAddress; } @@ -941,7 +942,8 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor } // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, + size, CURRENT_PC, mtInternal); *addr = mapAddress; *sizep = size; diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index d312b975abc..73055a88039 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -138,9 +138,8 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { // Workaround for issue when a custom launcher doesn't call // DestroyJavaVM and NMT is trying to track memory when free is // called from a static destructor - if (MemTracker::is_on()) { - MemTracker::shutdown(MemTracker::NMT_normal); - } + MemTracker::shutdown(); + break; default: break; @@ -163,6 +162,10 @@ bool os::getenv(const char* name, char* buffer, int len) { return result > 0 && result < len; } +bool os::unsetenv(const char* name) { + assert(name != NULL, "Null pointer"); + return (SetEnvironmentVariable(name, NULL) == TRUE); +} // No setuid programs under Windows. bool os::have_special_privileges() { @@ -319,15 +322,16 @@ extern "C" void breakpoint() { * So far, this method is only used by Native Memory Tracking, which is * only supported on Windows XP or later. */ -address os::get_caller_pc(int n) { +int os::get_native_stack(address* stack, int frames, int toSkip) { #ifdef _NMT_NOINLINE_ - n++; + toSkip ++; #endif - address pc; - if (os::Kernel32Dll::RtlCaptureStackBackTrace(n + 1, 1, (PVOID*)&pc, NULL) == 1) { - return pc; + int captured = Kernel32Dll::RtlCaptureStackBackTrace(toSkip + 1, frames, + (PVOID*)stack, NULL); + for (int index = captured; index < frames; index ++) { + stack[index] = NULL; } - return NULL; + return captured; } @@ -2901,7 +2905,7 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags, PAGE_READWRITE); // If reservation failed, return NULL if (p_buf == NULL) return NULL; - MemTracker::record_virtual_memory_reserve((address)p_buf, size_of_reserve, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve((address)p_buf, size_of_reserve, CALLER_PC); os::release_memory(p_buf, bytes + chunk_size); // we still need to round up to a page boundary (in case we are using large pages) @@ -2967,7 +2971,7 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags, // need to create a dummy 'reserve' record to match // the release. MemTracker::record_virtual_memory_reserve((address)p_buf, - bytes_to_release, mtNone, CALLER_PC); + bytes_to_release, CALLER_PC); os::release_memory(p_buf, bytes_to_release); } #ifdef ASSERT @@ -2986,11 +2990,10 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags, } // Although the memory is allocated individually, it is returned as one. // NMT records it as one block. - address pc = CALLER_PC; if ((flags & MEM_COMMIT) != 0) { - MemTracker::record_virtual_memory_reserve_and_commit((address)p_buf, bytes, mtNone, pc); + MemTracker::record_virtual_memory_reserve_and_commit((address)p_buf, bytes, CALLER_PC); } else { - MemTracker::record_virtual_memory_reserve((address)p_buf, bytes, mtNone, pc); + MemTracker::record_virtual_memory_reserve((address)p_buf, bytes, CALLER_PC); } // made it this far, success @@ -3188,8 +3191,7 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr, boo DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; char * res = (char *)VirtualAlloc(addr, bytes, flag, prot); if (res != NULL) { - address pc = CALLER_PC; - MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, mtNone, pc); + MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, CALLER_PC); } return res; diff --git a/hotspot/src/os/windows/vm/perfMemory_windows.cpp b/hotspot/src/os/windows/vm/perfMemory_windows.cpp index 1bf27296520..e1b59253e82 100644 --- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp +++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "oops/oop.inline.hpp" #include "os_windows.inline.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/os.hpp" #include "runtime/perfMemory.hpp" #include "services/memTracker.hpp" #include "utilities/exceptions.hpp" @@ -1388,7 +1389,7 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena // the file has been successfully created and the file mapping // object has been created. sharedmem_fileHandle = fh; - sharedmem_fileName = strdup(filename); + sharedmem_fileName = os::strdup(filename); return fmh; } @@ -1498,7 +1499,8 @@ static char* mapping_create_shared(size_t size) { (void)memset(mapAddress, '\0', size); // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, + size, CURRENT_PC, mtInternal); return (char*) mapAddress; } @@ -1680,7 +1682,8 @@ static void open_file_mapping(const char* user, int vmid, } // it does not go through os api, the operation has to record from here - MemTracker::record_virtual_memory_reserve((address)mapAddress, size, mtInternal, CURRENT_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress, size, + CURRENT_PC, mtInternal); *addrp = (char*)mapAddress; @@ -1834,10 +1837,14 @@ void PerfMemory::detach(char* addr, size_t bytes, TRAPS) { return; } - MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - remove_file_mapping(addr); - // it does not go through os api, the operation has to record from here - tkr.record((address)addr, bytes); + if (MemTracker::tracking_level() > NMT_minimal) { + // it does not go through os api, the operation has to record from here + Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + remove_file_mapping(addr); + tkr.record((address)addr, bytes); + } else { + remove_file_mapping(addr); + } } char* PerfMemory::backing_store_filename() { diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp index 028e33f37d4..56ccc721fa0 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp @@ -23,6 +23,8 @@ */ #include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" #include "runtime/os.hpp" #include "vm_version_sparc.hpp" @@ -48,7 +50,7 @@ static void do_sysinfo(int si, const char* string, int* features, int mask) { // All SI defines used below must be supported. guarantee(bufsize != -1, "must be supported"); - char* buf = (char*) malloc(bufsize); + char* buf = (char*) os::malloc(bufsize, mtInternal); if (buf == NULL) return; @@ -60,7 +62,7 @@ static void do_sysinfo(int si, const char* string, int* features, int mask) { } } - free(buf); + os::free(buf); } int VM_Version::platform_features(int features) { @@ -161,7 +163,7 @@ int VM_Version::platform_features(int features) { char tmp; size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1); - char* buf = (char*) malloc(bufsize); + char* buf = (char*) os::malloc(bufsize, mtInternal); if (buf != NULL) { if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) { @@ -184,7 +186,7 @@ int VM_Version::platform_features(int features) { if (vis[3] == '2') features |= vis2_instructions_m; } } - free(buf); + os::free(buf); } } @@ -228,7 +230,7 @@ int VM_Version::platform_features(int features) { } #endif // Convert to UPPER case before compare. - char* impl = strdup(implementation); + char* impl = os::strdup_check_oom(implementation); for (int i = 0; impl[i] != 0; i++) impl[i] = (char)toupper((uint)impl[i]); @@ -252,7 +254,7 @@ int VM_Version::platform_features(int features) { implementation = "SPARC"; } } - free((void*)impl); + os::free((void*)impl); break; } } // for( diff --git a/hotspot/src/share/vm/adlc/output_c.cpp b/hotspot/src/share/vm/adlc/output_c.cpp index 6169c8f62b7..68e92380cf2 100644 --- a/hotspot/src/share/vm/adlc/output_c.cpp +++ b/hotspot/src/share/vm/adlc/output_c.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -997,7 +997,7 @@ void ArchDesc::build_pipe_classes(FILE *fp_cpp) { int nopcnt = 0; for ( _pipeline->_noplist.reset(); (nop = _pipeline->_noplist.iter()) != NULL; nopcnt++ ); - fprintf(fp_cpp, "void Bundle::initialize_nops(MachNode * nop_list[%d], Compile *C) {\n", nopcnt); + fprintf(fp_cpp, "void Bundle::initialize_nops(MachNode * nop_list[%d]) {\n", nopcnt); int i = 0; for ( _pipeline->_noplist.reset(); (nop = _pipeline->_noplist.iter()) != NULL; i++ ) { fprintf(fp_cpp, " nop_list[%d] = (MachNode *) new %sNode();\n", i, nop); @@ -1369,7 +1369,7 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch fprintf(fp, " ra_->add_reference(root, inst%d);\n", inst_num); fprintf(fp, " ra_->set_oop (root, ra_->is_oop(inst%d));\n", inst_num); fprintf(fp, " ra_->set_pair(root->_idx, ra_->get_reg_second(inst%d), ra_->get_reg_first(inst%d));\n", inst_num, inst_num); - fprintf(fp, " root->_opnds[0] = inst%d->_opnds[0]->clone(C); // result\n", inst_num); + fprintf(fp, " root->_opnds[0] = inst%d->_opnds[0]->clone(); // result\n", inst_num); fprintf(fp, " // ----- Done with initial setup -----\n"); } else { if( (op_form == NULL) || (op_form->is_base_constant(globals) == Form::none) ) { @@ -1382,7 +1382,7 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch } else { fprintf(fp, " // no ideal edge for constants after matching\n"); } - fprintf(fp, " root->_opnds[%d] = inst%d->_opnds[%d]->clone(C);\n", + fprintf(fp, " root->_opnds[%d] = inst%d->_opnds[%d]->clone();\n", opnds_index, inst_num, inst_op_num ); } ++opnds_index; @@ -1402,7 +1402,7 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch // Define the Peephole method for an instruction node void ArchDesc::definePeephole(FILE *fp, InstructForm *node) { // Generate Peephole function header - fprintf(fp, "MachNode *%sNode::peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ) {\n", node->_ident); + fprintf(fp, "MachNode *%sNode::peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted) {\n", node->_ident); fprintf(fp, " bool matches = true;\n"); // Identify the maximum instruction position, @@ -1593,7 +1593,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { } const char *resultOper = new_inst->reduce_result(); - fprintf(fp," n%d->set_opnd_array(0, state->MachOperGenerator( %s, C ));\n", + fprintf(fp," n%d->set_opnd_array(0, state->MachOperGenerator(%s));\n", cnt, machOperEnum(resultOper)); // get the formal operand NameList @@ -1634,7 +1634,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { // If there is no use of the created operand, just skip it if (new_pos != NameList::Not_in_list) { //Copy the operand from the original made above - fprintf(fp," n%d->set_opnd_array(%d, op%d->clone(C)); // %s\n", + fprintf(fp," n%d->set_opnd_array(%d, op%d->clone()); // %s\n", cnt, new_pos, exp_pos-node->num_opnds(), opid); // Check for who defines this operand & add edge if needed fprintf(fp," if(tmp%d != NULL)\n", exp_pos); @@ -1662,7 +1662,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { new_pos = new_inst->operand_position(parameter,Component::USE); if (new_pos != -1) { // Copy the operand from the ExpandNode to the new node - fprintf(fp," n%d->set_opnd_array(%d, opnd_array(%d)->clone(C)); // %s\n", + fprintf(fp," n%d->set_opnd_array(%d, opnd_array(%d)->clone()); // %s\n", cnt, new_pos, exp_pos, opid); // For each operand add appropriate input edges by looking at tmp's fprintf(fp," if(tmp%d == this) {\n", exp_pos); @@ -1729,14 +1729,14 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { declared_def = true; } if (op && op->_interface && op->_interface->is_RegInterface()) { - fprintf(fp," def = new MachTempNode(state->MachOperGenerator( %s, C ));\n", + fprintf(fp," def = new MachTempNode(state->MachOperGenerator(%s));\n", machOperEnum(op->_ident)); fprintf(fp," add_req(def);\n"); // The operand for TEMP is already constructed during // this mach node construction, see buildMachNode(). // // int idx = node->operand_position_format(comp->_name); - // fprintf(fp," set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n", + // fprintf(fp," set_opnd_array(%d, state->MachOperGenerator(%s));\n", // idx, machOperEnum(op->_ident)); } else { assert(false, "can't have temps which aren't registers"); @@ -1802,7 +1802,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { uint j = node->unique_opnds_idx(i); // unique_opnds_idx(i) is unique if unique_opnds_idx(j) is not unique. if( j != node->unique_opnds_idx(j) ) { - fprintf(fp," set_opnd_array(%d, opnd_array(%d)->clone(C)); // %s\n", + fprintf(fp," set_opnd_array(%d, opnd_array(%d)->clone()); // %s\n", new_num_opnds, i, comp->_name); // delete not unique edges here fprintf(fp," for(unsigned i = 0; i < num%d; i++) {\n", i); @@ -2839,12 +2839,12 @@ static void defineIn_RegMask(FILE *fp, FormDict &globals, OperandForm &oper) { // generate code to create a clone for a class derived from MachOper // -// (0) MachOper *MachOperXOper::clone(Compile* C) const { +// (0) MachOper *MachOperXOper::clone() const { // (1) return new MachXOper( _ccode, _c0, _c1, ..., _cn); // (2) } // static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) { - fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper._ident); + fprintf(fp,"MachOper *%sOper::clone() const {\n", oper._ident); // Check for constants that need to be copied over const int num_consts = oper.num_consts(globalNames); const bool is_ideal_bool = oper.is_ideal_bool(); @@ -3043,7 +3043,7 @@ void ArchDesc::define_oper_interface(FILE *fp, OperandForm &oper, FormDict &glob static void define_fill_new_machnode(bool used, FILE *fp_cpp) { fprintf(fp_cpp, "\n"); fprintf(fp_cpp, "// Copy _idx, inputs and operands to new node\n"); - fprintf(fp_cpp, "void MachNode::fill_new_machnode( MachNode* node, Compile* C) const {\n"); + fprintf(fp_cpp, "void MachNode::fill_new_machnode(MachNode* node) const {\n"); if( !used ) { fprintf(fp_cpp, " // This architecture does not have cisc or short branch instructions\n"); fprintf(fp_cpp, " ShouldNotCallThis();\n"); @@ -3064,7 +3064,7 @@ static void define_fill_new_machnode(bool used, FILE *fp_cpp) { fprintf(fp_cpp, " MachOper **to = node->_opnds;\n"); fprintf(fp_cpp, " for( int i = 0; i < nopnds; i++ ) {\n"); fprintf(fp_cpp, " if( i != cisc_operand() ) \n"); - fprintf(fp_cpp, " to[i] = _opnds[i]->clone(C);\n"); + fprintf(fp_cpp, " to[i] = _opnds[i]->clone();\n"); fprintf(fp_cpp, " }\n"); fprintf(fp_cpp, "}\n"); } @@ -3105,7 +3105,7 @@ void ArchDesc::defineClasses(FILE *fp) { if ( strcmp(oper->_ident,"label") == 0 ) { defineIn_RegMask(_CPP_MISC_file._fp, _globalNames, *oper); - fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper->_ident); + fprintf(fp,"MachOper *%sOper::clone() const {\n", oper->_ident); fprintf(fp," return new %sOper(_label, _block_num);\n", oper->_ident); fprintf(fp,"}\n"); @@ -3124,7 +3124,7 @@ void ArchDesc::defineClasses(FILE *fp) { if ( strcmp(oper->_ident,"method") == 0 ) { defineIn_RegMask(_CPP_MISC_file._fp, _globalNames, *oper); - fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper->_ident); + fprintf(fp,"MachOper *%sOper::clone() const {\n", oper->_ident); fprintf(fp," return new %sOper(_method);\n", oper->_ident); fprintf(fp,"}\n"); @@ -3845,7 +3845,7 @@ void ArchDesc::buildMachOperGenerator(FILE *fp_cpp) { "// that invokes 'new' on the corresponding class constructor.\n"); fprintf(fp_cpp, "\n"); fprintf(fp_cpp, "MachOper *State::MachOperGenerator"); - fprintf(fp_cpp, "(int opcode, Compile* C)"); + fprintf(fp_cpp, "(int opcode)"); fprintf(fp_cpp, "{\n"); fprintf(fp_cpp, "\n"); fprintf(fp_cpp, " switch(opcode) {\n"); @@ -3921,7 +3921,7 @@ void ArchDesc::buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *inden int index = clist.operand_position(comp->_name, comp->_usedef, inst); const char *opcode = machOperEnum(comp->_type); fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index); - fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode); + fprintf(fp_cpp, "MachOperGenerator(%s));\n", opcode); } } else if ( inst->is_chain_of_constant(_globalNames, opType) ) { @@ -3978,7 +3978,7 @@ void InstructForm::declare_cisc_version(ArchDesc &AD, FILE *fp_hpp) { InstructForm *inst_cisc = cisc_spill_alternate(); if (inst_cisc != NULL) { fprintf(fp_hpp, " virtual int cisc_operand() const { return %d; }\n", cisc_spill_operand()); - fprintf(fp_hpp, " virtual MachNode *cisc_version(int offset, Compile* C);\n"); + fprintf(fp_hpp, " virtual MachNode *cisc_version(int offset);\n"); fprintf(fp_hpp, " virtual void use_cisc_RegMask();\n"); fprintf(fp_hpp, " virtual const RegMask *cisc_RegMask() const { return _cisc_RegMask; }\n"); } @@ -4008,7 +4008,7 @@ bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) { // Construct CISC version of this instruction fprintf(fp_cpp, "\n"); fprintf(fp_cpp, "// Build CISC version of this instruction\n"); - fprintf(fp_cpp, "MachNode *%sNode::cisc_version( int offset, Compile* C ) {\n", this->_ident); + fprintf(fp_cpp, "MachNode *%sNode::cisc_version(int offset) {\n", this->_ident); // Create the MachNode object fprintf(fp_cpp, " %sNode *node = new %sNode();\n", name, name); // Fill in the bottom_type where requested @@ -4023,7 +4023,7 @@ bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) { fprintf(fp_cpp, "\n"); fprintf(fp_cpp, " // Copy _idx, inputs and operands to new node\n"); - fprintf(fp_cpp, " fill_new_machnode(node, C);\n"); + fprintf(fp_cpp, " fill_new_machnode(node);\n"); // Construct operand to access [stack_pointer + offset] fprintf(fp_cpp, " // Construct operand to access [stack_pointer + offset]\n"); fprintf(fp_cpp, " node->set_opnd_array(cisc_operand(), new %sOper(offset));\n", cisc_oper_name); @@ -4042,7 +4042,7 @@ bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) { // Build prototypes for short branch methods void InstructForm::declare_short_branch_methods(FILE *fp_hpp) { if (has_short_branch_form()) { - fprintf(fp_hpp, " virtual MachNode *short_branch_version(Compile* C);\n"); + fprintf(fp_hpp, " virtual MachNode *short_branch_version();\n"); } } @@ -4055,7 +4055,7 @@ bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) { // Construct short_branch_version() method. fprintf(fp_cpp, "// Build short branch version of this instruction\n"); - fprintf(fp_cpp, "MachNode *%sNode::short_branch_version(Compile* C) {\n", this->_ident); + fprintf(fp_cpp, "MachNode *%sNode::short_branch_version() {\n", this->_ident); // Create the MachNode object fprintf(fp_cpp, " %sNode *node = new %sNode();\n", name, name); if( is_ideal_if() ) { @@ -4071,7 +4071,7 @@ bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) { // Short branch version must use same node index for access // through allocator's tables fprintf(fp_cpp, " // Copy _idx, inputs and operands to new node\n"); - fprintf(fp_cpp, " fill_new_machnode(node, C);\n"); + fprintf(fp_cpp, " fill_new_machnode(node);\n"); // Return result and exit scope fprintf(fp_cpp, " return node;\n"); @@ -4097,7 +4097,7 @@ void ArchDesc::buildMachNodeGenerator(FILE *fp_cpp) { "// that invokes 'new' on the corresponding class constructor.\n"); fprintf(fp_cpp, "\n"); fprintf(fp_cpp, "MachNode *State::MachNodeGenerator"); - fprintf(fp_cpp, "(int opcode, Compile* C)"); + fprintf(fp_cpp, "(int opcode)"); fprintf(fp_cpp, "{\n"); fprintf(fp_cpp, " switch(opcode) {\n"); diff --git a/hotspot/src/share/vm/adlc/output_h.cpp b/hotspot/src/share/vm/adlc/output_h.cpp index 7e020fb1726..c204af9f13b 100644 --- a/hotspot/src/share/vm/adlc/output_h.cpp +++ b/hotspot/src/share/vm/adlc/output_h.cpp @@ -1119,7 +1119,7 @@ void ArchDesc::declare_pipe_classes(FILE *fp_hpp) { fprintf(fp_hpp, " _nop_count = %d\n", _pipeline->_nopcnt); fprintf(fp_hpp, " };\n\n"); - fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n", + fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d]);\n\n", _pipeline->_nopcnt); fprintf(fp_hpp, "#ifndef PRODUCT\n"); fprintf(fp_hpp, " void dump(outputStream *st = tty) const;\n"); @@ -1240,7 +1240,7 @@ void ArchDesc::declareClasses(FILE *fp) { constant_type, _globalNames); // Clone function - fprintf(fp," virtual MachOper *clone(Compile* C) const;\n"); + fprintf(fp," virtual MachOper *clone() const;\n"); // Support setting a spill offset into a constant operand. // We only support setting an 'int' offset, while in the @@ -1718,7 +1718,7 @@ void ArchDesc::declareClasses(FILE *fp) { // If there is an explicit peephole rule, build it if ( instr->peepholes() != NULL ) { - fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n"); + fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted);\n"); } // Output the declaration for number of relocation entries @@ -1863,7 +1863,7 @@ void ArchDesc::declareClasses(FILE *fp) { } if ( instr->num_post_match_opnds() != 0 || instr->is_chain_of_constant(_globalNames) ) { - fprintf(fp," friend MachNode *State::MachNodeGenerator(int opcode, Compile* C);\n"); + fprintf(fp," friend MachNode *State::MachNodeGenerator(int opcode);\n"); } if ( instr->rematerialize(_globalNames, get_registers()) ) { fprintf(fp," // Rematerialize %s\n", instr->_ident); @@ -2071,8 +2071,8 @@ void ArchDesc::defineStateClass(FILE *fp) { fprintf(fp," DEBUG_ONLY( ~State(void); ) // Destructor\n"); fprintf(fp,"\n"); fprintf(fp," // Methods created by ADLC and invoked by Reduce\n"); - fprintf(fp," MachOper *MachOperGenerator( int opcode, Compile* C );\n"); - fprintf(fp," MachNode *MachNodeGenerator( int opcode, Compile* C );\n"); + fprintf(fp," MachOper *MachOperGenerator(int opcode);\n"); + fprintf(fp," MachNode *MachNodeGenerator(int opcode);\n"); fprintf(fp,"\n"); fprintf(fp," // Assign a state to a node, definition of method produced by ADLC\n"); fprintf(fp," bool DFA( int opcode, const Node *ideal );\n"); diff --git a/hotspot/src/share/vm/asm/codeBuffer.cpp b/hotspot/src/share/vm/asm/codeBuffer.cpp index 9c4bc206158..085330a6444 100644 --- a/hotspot/src/share/vm/asm/codeBuffer.cpp +++ b/hotspot/src/share/vm/asm/codeBuffer.cpp @@ -269,7 +269,7 @@ address CodeBuffer::decode_begin() { GrowableArray* CodeBuffer::create_patch_overflow() { if (_overflow_arena == NULL) { - _overflow_arena = new (mtCode) Arena(); + _overflow_arena = new (mtCode) Arena(mtCode); } return new (_overflow_arena) GrowableArray(_overflow_arena, 8, 0, 0); } diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index f673b236f19..b547c1d3554 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -48,7 +48,7 @@ Compiler::Compiler() : AbstractCompiler(c1) { void Compiler::init_c1_runtime() { BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); - Arena* arena = new (mtCompiler) Arena(); + Arena* arena = new (mtCompiler) Arena(mtCompiler); Runtime1::initialize(buffer_blob); FrameMap::initialize(); // initialize data structures diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp index 48b560840e3..f2753cbff9d 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp @@ -30,6 +30,7 @@ #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_ValueStack.hpp" #include "ci/ciInstance.hpp" +#include "runtime/os.hpp" void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) { // we must have enough patching space so that call can be inserted @@ -848,7 +849,7 @@ void LIR_Assembler::verify_oop_map(CodeEmitInfo* info) { stringStream st; st.print("bad oop %s at %d", r->as_Register()->name(), _masm->offset()); #ifdef SPARC - _masm->_verify_oop(r->as_Register(), strdup(st.as_string()), __FILE__, __LINE__); + _masm->_verify_oop(r->as_Register(), os::strdup(st.as_string(), mtCompiler), __FILE__, __LINE__); #else _masm->verify_oop(r->as_Register()); #endif diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index afed1de995f..833b357d2e4 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -1613,25 +1613,22 @@ void LinearScan::allocate_registers() { Interval* precolored_cpu_intervals, *not_precolored_cpu_intervals; Interval* precolored_fpu_intervals, *not_precolored_fpu_intervals; - create_unhandled_lists(&precolored_cpu_intervals, ¬_precolored_cpu_intervals, is_precolored_cpu_interval, is_virtual_cpu_interval); - if (has_fpu_registers()) { - create_unhandled_lists(&precolored_fpu_intervals, ¬_precolored_fpu_intervals, is_precolored_fpu_interval, is_virtual_fpu_interval); -#ifdef ASSERT - } else { - // fpu register allocation is omitted because no virtual fpu registers are present - // just check this again... - create_unhandled_lists(&precolored_fpu_intervals, ¬_precolored_fpu_intervals, is_precolored_fpu_interval, is_virtual_fpu_interval); - assert(not_precolored_fpu_intervals == Interval::end(), "missed an uncolored fpu interval"); -#endif - } - // allocate cpu registers + create_unhandled_lists(&precolored_cpu_intervals, ¬_precolored_cpu_intervals, + is_precolored_cpu_interval, is_virtual_cpu_interval); + + // allocate fpu registers + create_unhandled_lists(&precolored_fpu_intervals, ¬_precolored_fpu_intervals, + is_precolored_fpu_interval, is_virtual_fpu_interval); + + // the fpu interval allocation cannot be moved down below with the fpu section as + // the cpu_lsw.walk() changes interval positions. + LinearScanWalker cpu_lsw(this, precolored_cpu_intervals, not_precolored_cpu_intervals); cpu_lsw.walk(); cpu_lsw.finish_allocation(); if (has_fpu_registers()) { - // allocate fpu registers LinearScanWalker fpu_lsw(this, precolored_fpu_intervals, not_precolored_fpu_intervals); fpu_lsw.walk(); fpu_lsw.finish_allocation(); diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 310b4c2a407..5353a61964d 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -86,7 +86,8 @@ static bool firstEnv = true; // ------------------------------------------------------------------ // ciEnv::ciEnv -ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) { +ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) + : _ciEnv_arena(mtCompiler) { VM_ENTRY_MARK; // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. @@ -144,7 +145,7 @@ ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) { _jvmti_can_pop_frame = false; } -ciEnv::ciEnv(Arena* arena) { +ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) { ASSERT_IN_VM; // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.cpp b/hotspot/src/share/vm/ci/ciObjectFactory.cpp index 6bacf2b2f1f..aaa607ff135 100644 --- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp +++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,7 +112,7 @@ void ciObjectFactory::initialize() { // This Arena is long lived and exists in the resource mark of the // compiler thread that initializes the initial ciObjectFactory which // creates the shared ciObjects that all later ciObjectFactories use. - Arena* arena = new (mtCompiler) Arena(); + Arena* arena = new (mtCompiler) Arena(mtCompiler); ciEnv initial(arena); ciEnv* env = ciEnv::current(); env->_factory->init_shared_objects(); diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 1664411337f..1467462f1bf 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -273,13 +273,17 @@ void ClassPathZipEntry::contents_do(void f(const char* name, void* context), voi } LazyClassPathEntry::LazyClassPathEntry(char* path, const struct stat* st) : ClassPathEntry() { - _path = strdup(path); + _path = os::strdup_check_oom(path); _st = *st; _meta_index = NULL; _resolved_entry = NULL; _has_error = false; } +LazyClassPathEntry::~LazyClassPathEntry() { + os::free(_path); +} + bool LazyClassPathEntry::is_jar_file() { return ((_st.st_mode & S_IFREG) == S_IFREG); } @@ -416,7 +420,7 @@ void ClassLoader::setup_meta_index() { default: { if (!skipCurrentJar && cur_entry != NULL) { - char* new_name = strdup(package_name); + char* new_name = os::strdup_check_oom(package_name); boot_class_path_packages.append(new_name); } } @@ -438,7 +442,7 @@ void ClassLoader::setup_meta_index() { void ClassLoader::setup_bootstrap_search_path() { assert(_first_entry == NULL, "should not setup bootstrap class search path twice"); - char* sys_class_path = os::strdup(Arguments::get_sysclasspath()); + char* sys_class_path = os::strdup_check_oom(Arguments::get_sysclasspath()); if (TraceClassLoading && Verbose) { tty->print_cr("[Bootstrap loader class path=%s]", sys_class_path); } @@ -460,6 +464,7 @@ void ClassLoader::setup_bootstrap_search_path() { end++; } } + os::free(sys_class_path); } ClassPathEntry* ClassLoader::create_class_path_entry(char *path, const struct stat* st, bool lazy, TRAPS) { diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp index 2cfcde6387e..4a7a841705d 100644 --- a/hotspot/src/share/vm/classfile/classLoader.hpp +++ b/hotspot/src/share/vm/classfile/classLoader.hpp @@ -128,6 +128,8 @@ class LazyClassPathEntry: public ClassPathEntry { bool is_jar_file(); const char* name() { return _path; } LazyClassPathEntry(char* path, const struct stat* st); + virtual ~LazyClassPathEntry(); + ClassFileStream* open_stream(const char* name, TRAPS); void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; } virtual bool is_lazy(); diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index 00761e478ad..d688235f1f5 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -70,9 +70,9 @@ Symbol* SymbolTable::allocate_symbol(const u1* name, int len, bool c_heap, TRAPS void SymbolTable::initialize_symbols(int arena_alloc_size) { // Initialize the arena for global symbols, size passed in depends on CDS. if (arena_alloc_size == 0) { - _arena = new (mtSymbol) Arena(); + _arena = new (mtSymbol) Arena(mtSymbol); } else { - _arena = new (mtSymbol) Arena(arena_alloc_size); + _arena = new (mtSymbol) Arena(mtSymbol, arena_alloc_size); } } diff --git a/hotspot/src/share/vm/code/dependencies.cpp b/hotspot/src/share/vm/code/dependencies.cpp index 0f50425bcdd..9761d8d98b3 100644 --- a/hotspot/src/share/vm/code/dependencies.cpp +++ b/hotspot/src/share/vm/code/dependencies.cpp @@ -407,56 +407,66 @@ void Dependencies::check_valid_dependency_type(DepType dept) { // for the sake of the compiler log, print out current dependencies: void Dependencies::log_all_dependencies() { if (log() == NULL) return; - ciBaseObject* args[max_arg_count]; + ResourceMark rm; for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray* deps = _deps[dept]; - if (deps->length() == 0) continue; + int deplen = deps->length(); + if (deplen == 0) { + continue; + } int stride = dep_args(dept); + GrowableArray* ciargs = new GrowableArray(stride); for (int i = 0; i < deps->length(); i += stride) { for (int j = 0; j < stride; j++) { // flush out the identities before printing - args[j] = deps->at(i+j); + ciargs->push(deps->at(i+j)); } - write_dependency_to(log(), dept, stride, args); + write_dependency_to(log(), dept, ciargs); + ciargs->clear(); } + guarantee(deplen == deps->length(), "deps array cannot grow inside nested ResoureMark scope"); } } void Dependencies::write_dependency_to(CompileLog* log, DepType dept, - int nargs, DepArgument args[], + GrowableArray* args, Klass* witness) { if (log == NULL) { return; } + ResourceMark rm; ciEnv* env = ciEnv::current(); - ciBaseObject* ciargs[max_arg_count]; - assert(nargs <= max_arg_count, "oob"); - for (int j = 0; j < nargs; j++) { - if (args[j].is_oop()) { - ciargs[j] = env->get_object(args[j].oop_value()); + GrowableArray* ciargs = new GrowableArray(args->length()); + for (GrowableArrayIterator it = args->begin(); it != args->end(); ++it) { + DepArgument arg = *it; + if (arg.is_oop()) { + ciargs->push(env->get_object(arg.oop_value())); } else { - ciargs[j] = env->get_metadata(args[j].metadata_value()); + ciargs->push(env->get_metadata(arg.metadata_value())); } } - Dependencies::write_dependency_to(log, dept, nargs, ciargs, witness); + int argslen = ciargs->length(); + Dependencies::write_dependency_to(log, dept, ciargs, witness); + guarantee(argslen == ciargs->length(), "ciargs array cannot grow inside nested ResoureMark scope"); } void Dependencies::write_dependency_to(CompileLog* log, DepType dept, - int nargs, ciBaseObject* args[], + GrowableArray* args, Klass* witness) { - if (log == NULL) return; - assert(nargs <= max_arg_count, "oob"); - int argids[max_arg_count]; - int ctxkj = dep_context_arg(dept); // -1 if no context arg - int j; - for (j = 0; j < nargs; j++) { - if (args[j]->is_object()) { - argids[j] = log->identify(args[j]->as_object()); + if (log == NULL) { + return; + } + ResourceMark rm; + GrowableArray* argids = new GrowableArray(args->length()); + for (GrowableArrayIterator it = args->begin(); it != args->end(); ++it) { + ciBaseObject* obj = *it; + if (obj->is_object()) { + argids->push(log->identify(obj->as_object())); } else { - argids[j] = log->identify(args[j]->as_metadata()); + argids->push(log->identify(obj->as_metadata())); } } if (witness != NULL) { @@ -465,16 +475,17 @@ void Dependencies::write_dependency_to(CompileLog* log, log->begin_elem("dependency"); } log->print(" type='%s'", dep_name(dept)); - if (ctxkj >= 0) { - log->print(" ctxk='%d'", argids[ctxkj]); + const int ctxkj = dep_context_arg(dept); // -1 if no context arg + if (ctxkj >= 0 && ctxkj < argids->length()) { + log->print(" ctxk='%d'", argids->at(ctxkj)); } // write remaining arguments, if any. - for (j = 0; j < nargs; j++) { + for (int j = 0; j < argids->length(); j++) { if (j == ctxkj) continue; // already logged if (j == 1) { - log->print( " x='%d'", argids[j]); + log->print( " x='%d'", argids->at(j)); } else { - log->print(" x%d='%d'", j, argids[j]); + log->print(" x%d='%d'", j, argids->at(j)); } } if (witness != NULL) { @@ -486,9 +497,12 @@ void Dependencies::write_dependency_to(CompileLog* log, void Dependencies::write_dependency_to(xmlStream* xtty, DepType dept, - int nargs, DepArgument args[], + GrowableArray* args, Klass* witness) { - if (xtty == NULL) return; + if (xtty == NULL) { + return; + } + ResourceMark rm; ttyLocker ttyl; int ctxkj = dep_context_arg(dept); // -1 if no context arg if (witness != NULL) { @@ -498,23 +512,24 @@ void Dependencies::write_dependency_to(xmlStream* xtty, } xtty->print(" type='%s'", dep_name(dept)); if (ctxkj >= 0) { - xtty->object("ctxk", args[ctxkj].metadata_value()); + xtty->object("ctxk", args->at(ctxkj).metadata_value()); } // write remaining arguments, if any. - for (int j = 0; j < nargs; j++) { + for (int j = 0; j < args->length(); j++) { if (j == ctxkj) continue; // already logged + DepArgument arg = args->at(j); if (j == 1) { - if (args[j].is_oop()) { - xtty->object("x", args[j].oop_value()); + if (arg.is_oop()) { + xtty->object("x", arg.oop_value()); } else { - xtty->object("x", args[j].metadata_value()); + xtty->object("x", arg.metadata_value()); } } else { char xn[10]; sprintf(xn, "x%d", j); - if (args[j].is_oop()) { - xtty->object(xn, args[j].oop_value()); + if (arg.is_oop()) { + xtty->object(xn, arg.oop_value()); } else { - xtty->object(xn, args[j].metadata_value()); + xtty->object(xn, arg.metadata_value()); } } } @@ -525,7 +540,7 @@ void Dependencies::write_dependency_to(xmlStream* xtty, xtty->end_elem(); } -void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], +void Dependencies::print_dependency(DepType dept, GrowableArray* args, Klass* witness) { ResourceMark rm; ttyLocker ttyl; // keep the following output all in one block @@ -534,8 +549,8 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], dep_name(dept)); // print arguments int ctxkj = dep_context_arg(dept); // -1 if no context arg - for (int j = 0; j < nargs; j++) { - DepArgument arg = args[j]; + for (int j = 0; j < args->length(); j++) { + DepArgument arg = args->at(j); bool put_star = false; if (arg.is_null()) continue; const char* what; @@ -571,31 +586,33 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], void Dependencies::DepStream::log_dependency(Klass* witness) { if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime ResourceMark rm; - int nargs = argument_count(); - DepArgument args[max_arg_count]; + const int nargs = argument_count(); + GrowableArray* args = new GrowableArray(nargs); for (int j = 0; j < nargs; j++) { if (type() == call_site_target_value) { - args[j] = argument_oop(j); + args->push(argument_oop(j)); } else { - args[j] = argument(j); + args->push(argument(j)); } } + int argslen = args->length(); if (_deps != NULL && _deps->log() != NULL) { - Dependencies::write_dependency_to(_deps->log(), - type(), nargs, args, witness); + Dependencies::write_dependency_to(_deps->log(), type(), args, witness); } else { - Dependencies::write_dependency_to(xtty, - type(), nargs, args, witness); + Dependencies::write_dependency_to(xtty, type(), args, witness); } + guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope"); } void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { + ResourceMark rm; int nargs = argument_count(); - DepArgument args[max_arg_count]; + GrowableArray* args = new GrowableArray(nargs); for (int j = 0; j < nargs; j++) { - args[j] = argument(j); + args->push(argument(j)); } - Dependencies::print_dependency(type(), nargs, args, witness); + int argslen = args->length(); + Dependencies::print_dependency(type(), args, witness); if (verbose) { if (_code != NULL) { tty->print(" code: "); @@ -603,6 +620,7 @@ void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { tty->cr(); } } + guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope"); } diff --git a/hotspot/src/share/vm/code/dependencies.hpp b/hotspot/src/share/vm/code/dependencies.hpp index 3501b57fd51..ff4ff328f8d 100644 --- a/hotspot/src/share/vm/code/dependencies.hpp +++ b/hotspot/src/share/vm/code/dependencies.hpp @@ -369,20 +369,36 @@ class Dependencies: public ResourceObj { void copy_to(nmethod* nm); void log_all_dependencies(); - void log_dependency(DepType dept, int nargs, ciBaseObject* args[]) { - write_dependency_to(log(), dept, nargs, args); + + void log_dependency(DepType dept, GrowableArray* args) { + ResourceMark rm; + int argslen = args->length(); + write_dependency_to(log(), dept, args); + guarantee(argslen == args->length(), + "args array cannot grow inside nested ResoureMark scope"); } + void log_dependency(DepType dept, ciBaseObject* x0, ciBaseObject* x1 = NULL, ciBaseObject* x2 = NULL) { - if (log() == NULL) return; - ciBaseObject* args[max_arg_count]; - args[0] = x0; - args[1] = x1; - args[2] = x2; - assert(2 < max_arg_count, ""); - log_dependency(dept, dep_args(dept), args); + if (log() == NULL) { + return; + } + ResourceMark rm; + GrowableArray* ciargs = + new GrowableArray(dep_args(dept)); + assert (x0 != NULL, "no log x0"); + ciargs->push(x0); + + if (x1 != NULL) { + ciargs->push(x1); + } + if (x2 != NULL) { + ciargs->push(x2); + } + assert(ciargs->length() == dep_args(dept), ""); + log_dependency(dept, ciargs); } class DepArgument : public ResourceObj { @@ -405,20 +421,8 @@ class Dependencies: public ResourceObj { Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; } }; - static void write_dependency_to(CompileLog* log, - DepType dept, - int nargs, ciBaseObject* args[], - Klass* witness = NULL); - static void write_dependency_to(CompileLog* log, - DepType dept, - int nargs, DepArgument args[], - Klass* witness = NULL); - static void write_dependency_to(xmlStream* xtty, - DepType dept, - int nargs, DepArgument args[], - Klass* witness = NULL); static void print_dependency(DepType dept, - int nargs, DepArgument args[], + GrowableArray* args, Klass* witness = NULL); private: @@ -427,6 +431,18 @@ class Dependencies: public ResourceObj { static Klass* ctxk_encoded_as_null(DepType dept, Metadata* x); + static void write_dependency_to(CompileLog* log, + DepType dept, + GrowableArray* args, + Klass* witness = NULL); + static void write_dependency_to(CompileLog* log, + DepType dept, + GrowableArray* args, + Klass* witness = NULL); + static void write_dependency_to(xmlStream* xtty, + DepType dept, + GrowableArray* args, + Klass* witness = NULL); public: // Use this to iterate over an nmethod's dependency set. // Works on new and old dependency sets. diff --git a/hotspot/src/share/vm/compiler/compilerOracle.cpp b/hotspot/src/share/vm/compiler/compilerOracle.cpp index b646158af28..7cf3be645f2 100644 --- a/hotspot/src/share/vm/compiler/compilerOracle.cpp +++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp @@ -33,6 +33,7 @@ #include "oops/symbol.hpp" #include "runtime/handles.inline.hpp" #include "runtime/jniHandles.hpp" +#include "runtime/os.hpp" class MethodMatcher : public CHeapObj { public: @@ -175,7 +176,11 @@ class MethodOptionMatcher: public MethodMatcher { Symbol* method_name, Mode method_mode, Symbol* signature, const char * opt, MethodMatcher* next): MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next) { - option = opt; + option = os::strdup_check_oom(opt); + } + + virtual ~MethodOptionMatcher() { + os::free((void*)option); } bool match(methodHandle method, const char* opt) { @@ -498,7 +503,7 @@ void CompilerOracle::parse_from_line(char* line) { tty->print("CompilerOracle: %s ", command_names[command]); match->print(); } - match = add_option_string(c_name, c_match, m_name, m_match, signature, strdup(option)); + match = add_option_string(c_name, c_match, m_name, m_match, signature, option); line += bytes_read; } } else { diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp index c2df7a29512..aed729017c0 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,8 @@ void ConcurrentMarkSweepPolicy::initialize_alignments() { } void ConcurrentMarkSweepPolicy::initialize_generations() { - _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); + _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, + CURRENT_PC, AllocFailStrategy::RETURN_NULL); if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index b907eda96ad..737692135d1 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -2167,7 +2167,9 @@ void ConcurrentMark::cleanup() { g1h->increment_total_collections(); // Clean out dead classes and update Metaspace sizes. - ClassLoaderDataGraph::purge(); + if (ClassUnloadingWithConcurrentMark) { + ClassLoaderDataGraph::purge(); + } MetaspaceGC::compute_new_size(); // We reclaimed old regions so we should calculate the sizes to make @@ -2597,24 +2599,27 @@ void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { assert(_markStack.isEmpty(), "Marking should have completed"); // Unload Klasses, String, Symbols, Code Cache, etc. - - G1RemarkGCTraceTime trace("Unloading", G1Log::finer()); - - bool purged_classes; - { - G1RemarkGCTraceTime trace("System Dictionary Unloading", G1Log::finest()); - purged_classes = SystemDictionary::do_unloading(&g1_is_alive); - } + G1RemarkGCTraceTime trace("Unloading", G1Log::finer()); - { - G1RemarkGCTraceTime trace("Parallel Unloading", G1Log::finest()); - weakRefsWorkParallelPart(&g1_is_alive, purged_classes); - } + if (ClassUnloadingWithConcurrentMark) { + bool purged_classes; - if (G1StringDedup::is_enabled()) { - G1RemarkGCTraceTime trace("String Deduplication Unlink", G1Log::finest()); - G1StringDedup::unlink(&g1_is_alive); + { + G1RemarkGCTraceTime trace("System Dictionary Unloading", G1Log::finest()); + purged_classes = SystemDictionary::do_unloading(&g1_is_alive); + } + + { + G1RemarkGCTraceTime trace("Parallel Unloading", G1Log::finest()); + weakRefsWorkParallelPart(&g1_is_alive, purged_classes); + } + } + + if (G1StringDedup::is_enabled()) { + G1RemarkGCTraceTime trace("String Deduplication Unlink", G1Log::finest()); + G1StringDedup::unlink(&g1_is_alive); + } } } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 1467d1baabc..a41173191d8 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -4920,10 +4920,15 @@ public: if (_g1h->g1_policy()->during_initial_mark_pause()) { // We also need to mark copied objects. strong_root_cl = &scan_mark_root_cl; - weak_root_cl = &scan_mark_weak_root_cl; strong_cld_cl = &scan_mark_cld_cl; - weak_cld_cl = &scan_mark_weak_cld_cl; strong_code_cl = &scan_mark_code_cl; + if (ClassUnloadingWithConcurrentMark) { + weak_root_cl = &scan_mark_weak_root_cl; + weak_cld_cl = &scan_mark_weak_cld_cl; + } else { + weak_root_cl = &scan_mark_root_cl; + weak_cld_cl = &scan_mark_cld_cl; + } } else { strong_root_cl = &scan_only_root_cl; weak_root_cl = &scan_only_root_cl; @@ -4994,6 +4999,7 @@ g1_process_roots(OopClosure* scan_non_heap_roots, double closure_app_time_sec = 0.0; bool during_im = _g1h->g1_policy()->during_initial_mark_pause(); + bool trace_metadata = during_im && ClassUnloadingWithConcurrentMark; BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); BufferingOopClosure buf_scan_non_heap_weak_roots(scan_non_heap_weak_roots); @@ -5003,8 +5009,8 @@ g1_process_roots(OopClosure* scan_non_heap_roots, &buf_scan_non_heap_roots, &buf_scan_non_heap_weak_roots, scan_strong_clds, - // Initial Mark handles the weak CLDs separately. - (during_im ? NULL : scan_weak_clds), + // Unloading Initial Marks handle the weak CLDs separately. + (trace_metadata ? NULL : scan_weak_clds), scan_strong_code); // Now the CM ref_processor roots. @@ -5016,7 +5022,7 @@ g1_process_roots(OopClosure* scan_non_heap_roots, ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots); } - if (during_im) { + if (trace_metadata) { // Barrier to make sure all workers passed // the strong CLD and strong nmethods phases. active_strong_roots_scope()->wait_until_all_workers_done_with_threads(n_par_threads()); @@ -6536,6 +6542,9 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure { G1CollectedHeap* g1h = G1CollectedHeap::heap(); + oop obj = (oop)r->bottom(); + CMBitMap* next_bitmap = g1h->concurrent_mark()->nextMarkBitMap(); + // The following checks whether the humongous object is live are sufficient. // The main additional check (in addition to having a reference from the roots // or the young gen) is whether the humongous object has a remembered set entry. @@ -6572,37 +6581,41 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure { g1h->humongous_region_is_always_live(region_idx)) { if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) { - gclog_or_tty->print_cr("Live humongous %d region %d with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is dead-bitmap %d live-other %d obj array %d", + gclog_or_tty->print_cr("Live humongous %d region %d with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d", r->isHumongous(), region_idx, r->rem_set()->occupied(), r->rem_set()->strong_code_roots_list_length(), - g1h->mark_in_progress() && !g1h->g1_policy()->during_initial_mark_pause(), + next_bitmap->isMarked(r->bottom()), g1h->humongous_is_live(region_idx), - oop(r->bottom())->is_objArray() + obj->is_objArray() ); } return false; } - guarantee(!((oop)(r->bottom()))->is_objArray(), + guarantee(!obj->is_objArray(), err_msg("Eagerly reclaiming object arrays is not supported, but the object "PTR_FORMAT" is.", r->bottom())); if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) { - gclog_or_tty->print_cr("Reclaim humongous region %d start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is dead-bitmap %d live-other %d obj array %d", + gclog_or_tty->print_cr("Reclaim humongous region %d start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d", r->isHumongous(), r->bottom(), region_idx, r->region_num(), r->rem_set()->occupied(), r->rem_set()->strong_code_roots_list_length(), - g1h->mark_in_progress() && !g1h->g1_policy()->during_initial_mark_pause(), + next_bitmap->isMarked(r->bottom()), g1h->humongous_is_live(region_idx), - oop(r->bottom())->is_objArray() + obj->is_objArray() ); } + // Need to clear mark bit of the humongous object if already set. + if (next_bitmap->isMarked(r->bottom())) { + next_bitmap->clear(r->bottom()); + } _freed_bytes += r->used(); r->set_containing_set(NULL); _humongous_regions_removed.increment(1u, r->capacity()); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp index 89e3e813b98..bf5824f1ed2 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp @@ -288,7 +288,12 @@ void G1ParScanThreadState::undo_allocation(GCAllocPurpose purpose, HeapWord* obj } HeapWord* G1ParScanThreadState::allocate(GCAllocPurpose purpose, size_t word_sz) { - HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz); + HeapWord* obj = NULL; + if (purpose == GCAllocForSurvived) { + obj = alloc_buffer(GCAllocForSurvived)->allocate_aligned(word_sz, SurvivorAlignmentInBytes); + } else { + obj = alloc_buffer(GCAllocForTenured)->allocate(word_sz); + } if (obj != NULL) { return obj; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp index 69b17c56702..96f885a730c 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp @@ -349,23 +349,8 @@ void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, assert((ParallelGCThreads > 0) || worker_i == 0, "invariant"); - // The two flags below were introduced temporarily to serialize - // the updating and scanning of remembered sets. There are some - // race conditions when these two operations are done in parallel - // and they are causing failures. When we resolve said race - // conditions, we'll revert back to parallel remembered set - // updating and scanning. See CRs 6677707 and 6677708. - if (G1UseParallelRSetUpdating || (worker_i == 0)) { - updateRS(&into_cset_dcq, worker_i); - } else { - _g1p->phase_times()->record_update_rs_processed_buffers(worker_i, 0); - _g1p->phase_times()->record_update_rs_time(worker_i, 0.0); - } - if (G1UseParallelRSetScanning || (worker_i == 0)) { - scanRS(oc, code_root_cl, worker_i); - } else { - _g1p->phase_times()->record_scan_rs_time(worker_i, 0.0); - } + updateRS(&into_cset_dcq, worker_i); + scanRS(oc, code_root_cl, worker_i); // We now clear the cached values of _cset_rs_update_cl for this worker _cset_rs_update_cl[worker_i] = NULL; diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp index 5f05a9e9fce..17ae309240d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp @@ -220,14 +220,6 @@ product(uintx, G1HeapRegionSize, 0, \ "Size of the G1 regions.") \ \ - experimental(bool, G1UseParallelRSetUpdating, true, \ - "Enables the parallelization of remembered set updating " \ - "during evacuation pauses") \ - \ - experimental(bool, G1UseParallelRSetScanning, true, \ - "Enables the parallelization of remembered set scanning " \ - "during evacuation pauses") \ - \ product(uintx, G1ConcRefinementThreads, 0, \ "If non-0 is the number of parallel rem set update threads, " \ "otherwise the value is determined ergonomically.") \ diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp index ebe4c067b9d..62ae230f1a3 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp @@ -94,26 +94,37 @@ G1OffsetTableContigSpace::block_start_const(const void* p) const { inline bool HeapRegion::block_is_obj(const HeapWord* p) const { G1CollectedHeap* g1h = G1CollectedHeap::heap(); - return !g1h->is_obj_dead(oop(p), this); + if (ClassUnloadingWithConcurrentMark) { + return !g1h->is_obj_dead(oop(p), this); + } + return p < top(); } inline size_t HeapRegion::block_size(const HeapWord *addr) const { + if (addr == top()) { + return pointer_delta(end(), addr); + } + + if (block_is_obj(addr)) { + return oop(addr)->size(); + } + + assert(ClassUnloadingWithConcurrentMark, + err_msg("All blocks should be objects if G1 Class Unloading isn't used. " + "HR: ["PTR_FORMAT", "PTR_FORMAT", "PTR_FORMAT") " + "addr: " PTR_FORMAT, + p2i(bottom()), p2i(top()), p2i(end()), p2i(addr))); + // Old regions' dead objects may have dead classes // We need to find the next live object in some other // manner than getting the oop size G1CollectedHeap* g1h = G1CollectedHeap::heap(); - if (g1h->is_obj_dead(oop(addr), this)) { - HeapWord* next = g1h->concurrent_mark()->prevMarkBitMap()-> - getNextMarkedWordAddress(addr, prev_top_at_mark_start()); + HeapWord* next = g1h->concurrent_mark()->prevMarkBitMap()-> + getNextMarkedWordAddress(addr, prev_top_at_mark_start()); - assert(next > addr, "must get the next live object"); - - return pointer_delta(next, addr); - } else if (addr == top()) { - return pointer_delta(end(), addr); - } - return oop(addr)->size(); + assert(next > addr, "must get the next live object"); + return pointer_delta(next, addr); } inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t word_size) { diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp index 68e2957c05c..5093327e997 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @@ -289,7 +289,7 @@ OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) : } _fine_grain_regions = NEW_C_HEAP_ARRAY3(PerRegionTablePtr, _max_fine_entries, - mtGC, 0, AllocFailStrategy::RETURN_NULL); + mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL); if (_fine_grain_regions == NULL) { vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, OOM_MALLOC_ERROR, diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index bddc6f678a3..cc86629281e 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -28,12 +28,12 @@ #include "gc_implementation/parNew/parOopClosures.inline.hpp" #include "gc_implementation/shared/adaptiveSizePolicy.hpp" #include "gc_implementation/shared/ageTable.hpp" -#include "gc_implementation/shared/parGCAllocBuffer.hpp" +#include "gc_implementation/shared/copyFailedInfo.hpp" #include "gc_implementation/shared/gcHeapSummary.hpp" #include "gc_implementation/shared/gcTimer.hpp" #include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/gcTraceTime.hpp" -#include "gc_implementation/shared/copyFailedInfo.hpp" +#include "gc_implementation/shared/parGCAllocBuffer.inline.hpp" #include "gc_implementation/shared/spaceDecorator.hpp" #include "memory/defNewGeneration.inline.hpp" #include "memory/genCollectedHeap.hpp" @@ -252,7 +252,7 @@ HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) { plab->set_word_size(buf_size); plab->set_buf(buf_space); record_survivor_plab(buf_space, buf_size); - obj = plab->allocate(word_sz); + obj = plab->allocate_aligned(word_sz, SurvivorAlignmentInBytes); // Note that we cannot compare buf_size < word_sz below // because of AlignmentReserve (see ParGCAllocBuffer::allocate()). assert(obj != NULL || plab->words_remaining() < word_sz, diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp index bde15f7b8f8..7685353ed1e 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp @@ -168,7 +168,7 @@ class ParScanThreadState { HeapWord* alloc_in_to_space_slow(size_t word_sz); HeapWord* alloc_in_to_space(size_t word_sz) { - HeapWord* obj = to_space_alloc_buffer()->allocate(word_sz); + HeapWord* obj = to_space_alloc_buffer()->allocate_aligned(word_sz, SurvivorAlignmentInBytes); if (obj != NULL) return obj; else return alloc_in_to_space_slow(word_sz); } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp index e87529c734d..05c27a3f3da 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP #include "gc_implementation/parallelScavenge/objectStartArray.hpp" +#include "gc_interface/collectedHeap.inline.hpp" #include "memory/allocation.hpp" // @@ -94,23 +95,9 @@ class PSYoungPromotionLAB : public PSPromotionLAB { PSYoungPromotionLAB() { } // Not MT safe - HeapWord* allocate(size_t size) { - // Can't assert this, when young fills, we keep the LAB around, but flushed. - // assert(_state != flushed, "Sanity"); - HeapWord* obj = top(); - HeapWord* new_top = obj + size; - // The 'new_top>obj' check is needed to detect overflow of obj+size. - if (new_top > obj && new_top <= end()) { - set_top(new_top); - assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top), - "checking alignment"); - return obj; - } + inline HeapWord* allocate(size_t size); - return NULL; - } - - debug_only(virtual bool lab_is_valid(MemRegion lab)); + debug_only(virtual bool lab_is_valid(MemRegion lab);) }; class PSOldPromotionLAB : public PSPromotionLAB { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.inline.hpp new file mode 100644 index 00000000000..0e5d7e7f7f2 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.inline.hpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_INLINE_HPP +#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_INLINE_HPP + +#include "gc_implementation/parallelScavenge/psPromotionLAB.hpp" +#include "gc_interface/collectedHeap.inline.hpp" + +HeapWord* PSYoungPromotionLAB::allocate(size_t size) { + // Can't assert this, when young fills, we keep the LAB around, but flushed. + // assert(_state != flushed, "Sanity"); + HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes); + if (obj == NULL) { + return NULL; + } + + HeapWord* new_top = obj + size; + // The 'new_top>obj' check is needed to detect overflow of obj+size. + if (new_top > obj && new_top <= end()) { + set_top(new_top); + assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned((intptr_t)new_top), + "checking alignment"); + return obj; + } else { + set_top(obj); + return NULL; + } +} + +#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_INLINE_HPP diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp index 356c2585168..b2de74d4175 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp @@ -27,6 +27,7 @@ #include "gc_implementation/parallelScavenge/psOldGen.hpp" #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" +#include "gc_implementation/parallelScavenge/psPromotionLAB.inline.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" #include "oops/oop.psgc.inline.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp index 3677ee26e28..6f1c5eb8eba 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp @@ -24,7 +24,7 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP - +#include "gc_interface/collectedHeap.hpp" #include "memory/allocation.hpp" #include "memory/blockOffsetTable.hpp" #include "memory/threadLocalAllocBuffer.hpp" @@ -84,6 +84,9 @@ public: } } + // Allocate the object aligned to "alignment_in_bytes". + HeapWord* allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes); + // Undo the last allocation in the buffer, which is required to be of the // "obj" of the given "word_sz". void undo_allocation(HeapWord* obj, size_t word_sz) { diff --git a/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.inline.hpp b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.inline.hpp new file mode 100644 index 00000000000..352ce05a3e5 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/shared/parGCAllocBuffer.inline.hpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_PARGCALLOCBUFFER_INLINE_HPP +#define SHARE_VM_GC_IMPLEMENTATION_SHARED_PARGCALLOCBUFFER_INLINE_HPP + +#include "gc_implementation/shared/parGCAllocBuffer.hpp" +#include "gc_interface/collectedHeap.inline.hpp" + +HeapWord* ParGCAllocBuffer::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) { + + HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes); + if (res == NULL) { + return NULL; + } + + // Set _top so that allocate(), which expects _top to be correctly set, + // can be used below. + _top = res; + return allocate(word_sz); +} + +#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_PARGCALLOCBUFFER_INLINE_HPP diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp index bb7028ec9c1..b80332b2ab1 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp @@ -195,6 +195,7 @@ void VM_GenCollectFull::doit() { gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_level); } +// Returns true iff concurrent GCs unloads metadata. bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() { #if INCLUDE_ALL_GCS if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) { @@ -202,7 +203,7 @@ bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() { return true; } - if (UseG1GC) { + if (UseG1GC && ClassUnloadingWithConcurrentMark) { G1CollectedHeap* g1h = G1CollectedHeap::heap(); g1h->g1_policy()->set_initiate_conc_mark_if_possible(); diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp index d3c2fba9276..d4fa7ffc0ec 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp @@ -351,6 +351,12 @@ class CollectedHeap : public CHeapObj { fill_with_object(start, pointer_delta(end, start), zap); } + // Return the address "addr" aligned by "alignment_in_bytes" if such + // an address is below "end". Return NULL otherwise. + inline static HeapWord* align_allocation_or_fail(HeapWord* addr, + HeapWord* end, + unsigned short alignment_in_bytes); + // Some heaps may offer a contiguous region for shared non-blocking // allocation, via inlined code (by exporting the address of the top and // end fields defining the extent of the contiguous allocation region.) diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp index 89315a9424f..302d0c7cb3a 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp @@ -241,6 +241,44 @@ inline void CollectedHeap::oop_iterate_no_header(OopClosure* cl) { oop_iterate(&no_header_cl); } + +inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr, + HeapWord* end, + unsigned short alignment_in_bytes) { + if (alignment_in_bytes <= ObjectAlignmentInBytes) { + return addr; + } + + assert(is_ptr_aligned(addr, HeapWordSize), + err_msg("Address " PTR_FORMAT " is not properly aligned.", p2i(addr))); + assert(is_size_aligned(alignment_in_bytes, HeapWordSize), + err_msg("Alignment size %u is incorrect.", alignment_in_bytes)); + + HeapWord* new_addr = (HeapWord*) align_pointer_up(addr, alignment_in_bytes); + size_t padding = pointer_delta(new_addr, addr); + + if (padding == 0) { + return addr; + } + + if (padding < CollectedHeap::min_fill_size()) { + padding += alignment_in_bytes / HeapWordSize; + assert(padding >= CollectedHeap::min_fill_size(), + err_msg("alignment_in_bytes %u is expect to be larger " + "than the minimum object size", alignment_in_bytes)); + new_addr = addr + padding; + } + + assert(new_addr > addr, err_msg("Unexpected arithmetic overflow " + PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr))); + if(new_addr < end) { + CollectedHeap::fill_with_object(addr, padding); + return new_addr; + } else { + return NULL; + } +} + #ifndef PRODUCT inline bool diff --git a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp index 783066e0adb..de54137168e 100644 --- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp @@ -280,9 +280,6 @@ class AbstractInterpreterGenerator: public StackObj { address generate_result_handler_for(BasicType type); address generate_slow_signature_handler(); - // entry point generator - address generate_method_entry(AbstractInterpreter::MethodKind kind); - void bang_stack_shadow_pages(bool native_call); void generate_all(); diff --git a/hotspot/src/share/vm/interpreter/cppInterpreter.cpp b/hotspot/src/share/vm/interpreter/cppInterpreter.cpp index 0007aa8be25..c154a746f4d 100644 --- a/hotspot/src/share/vm/interpreter/cppInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/cppInterpreter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,7 +108,7 @@ void CppInterpreterGenerator::generate_all() { } -#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind) +#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = ((InterpreterGenerator*)this)->generate_method_entry(Interpreter::kind) { CodeletMark cm(_masm, "(kind = frame_manager)"); // all non-native method kinds diff --git a/hotspot/src/share/vm/interpreter/interpreter.cpp b/hotspot/src/share/vm/interpreter/interpreter.cpp index 4807cd08398..00c116234da 100644 --- a/hotspot/src/share/vm/interpreter/interpreter.cpp +++ b/hotspot/src/share/vm/interpreter/interpreter.cpp @@ -29,6 +29,7 @@ #include "interpreter/bytecodeHistogram.hpp" #include "interpreter/bytecodeInterpreter.hpp" #include "interpreter/interpreter.hpp" +#include "interpreter/interpreterGenerator.hpp" #include "interpreter/interpreterRuntime.hpp" #include "interpreter/interp_masm.hpp" #include "interpreter/templateTable.hpp" @@ -261,7 +262,7 @@ AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(methodHandle m) // Special intrinsic method? // Note: This test must come _after_ the test for native methods, // otherwise we will run into problems with JDK 1.2, see also - // AbstractInterpreterGenerator::generate_method_entry() for + // InterpreterGenerator::generate_method_entry() for // for details. switch (m->intrinsic_id()) { case vmIntrinsics::_dsin : return java_lang_math_sin ; @@ -521,3 +522,50 @@ void AbstractInterpreterGenerator::initialize_method_handle_entries() { Interpreter::_entry_table[kind] = Interpreter::_entry_table[Interpreter::abstract]; } } + +// Generate method entries +address InterpreterGenerator::generate_method_entry( + AbstractInterpreter::MethodKind kind) { + // determine code generation flags + bool synchronized = false; + address entry_point = NULL; + + switch (kind) { + case Interpreter::zerolocals : break; + case Interpreter::zerolocals_synchronized: synchronized = true; break; + case Interpreter::native : entry_point = generate_native_entry(false); break; + case Interpreter::native_synchronized : entry_point = generate_native_entry(true); break; + case Interpreter::empty : entry_point = generate_empty_entry(); break; + case Interpreter::accessor : entry_point = generate_accessor_entry(); break; + case Interpreter::abstract : entry_point = generate_abstract_entry(); break; + + case Interpreter::java_lang_math_sin : // fall thru + case Interpreter::java_lang_math_cos : // fall thru + case Interpreter::java_lang_math_tan : // fall thru + case Interpreter::java_lang_math_abs : // fall thru + case Interpreter::java_lang_math_log : // fall thru + case Interpreter::java_lang_math_log10 : // fall thru + case Interpreter::java_lang_math_sqrt : // fall thru + case Interpreter::java_lang_math_pow : // fall thru + case Interpreter::java_lang_math_exp : entry_point = generate_math_entry(kind); break; + case Interpreter::java_lang_ref_reference_get + : entry_point = generate_Reference_get_entry(); break; +#ifndef CC_INTERP + case Interpreter::java_util_zip_CRC32_update + : entry_point = generate_CRC32_update_entry(); break; + case Interpreter::java_util_zip_CRC32_updateBytes + : // fall thru + case Interpreter::java_util_zip_CRC32_updateByteBuffer + : entry_point = generate_CRC32_updateBytes_entry(kind); break; +#endif // CC_INTERP + default: + fatal(err_msg("unexpected method kind: %d", kind)); + break; + } + + if (entry_point) { + return entry_point; + } + + return generate_normal_entry(synchronized); +} diff --git a/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp index 7bc43eccb21..5c4242df884 100644 --- a/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp +++ b/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,9 +37,11 @@ class InterpreterGenerator: public CC_INTERP_ONLY(CppInterpreterGenerator) NOT_CC_INTERP(TemplateInterpreterGenerator) { -public: + public: -InterpreterGenerator(StubQueue* _code); + InterpreterGenerator(StubQueue* _code); + // entry point generator + address generate_method_entry(AbstractInterpreter::MethodKind kind); #ifdef TARGET_ARCH_x86 # include "interpreterGenerator_x86.hpp" diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp index 9f28e20f9b7..d42da317345 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp @@ -364,7 +364,7 @@ void TemplateInterpreterGenerator::generate_all() { #define method_entry(kind) \ { CodeletMark cm(_masm, "method entry point (kind = " #kind ")"); \ - Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind); \ + Interpreter::_entry_table[Interpreter::kind] = ((InterpreterGenerator*)this)->generate_method_entry(Interpreter::kind); \ } // all non-native method kinds diff --git a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp index ee1b0f5acc5..e3740c47c4e 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,9 +59,6 @@ class TemplateInterpreterGenerator: public AbstractInterpreterGenerator { address generate_safept_entry_for(TosState state, address runtime_entry); void generate_throw_exception(); - // entry point generator -// address generate_method_entry(AbstractInterpreter::MethodKind kind); - // Instruction generation void generate_and_dispatch (Template* t, TosState tos_out = ilgl); void set_vtos_entry_points (Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep); diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index ac9ff11bb65..ec9a8497836 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -422,26 +422,23 @@ void Chunk::start_chunk_pool_cleaner_task() { } //------------------------------Arena------------------------------------------ -NOT_PRODUCT(volatile jint Arena::_instance_count = 0;) -Arena::Arena(size_t init_size) { +Arena::Arena(MEMFLAGS flag, size_t init_size) : _flags(flag), _size_in_bytes(0) { size_t round_size = (sizeof (char *)) - 1; init_size = (init_size+round_size) & ~round_size; _first = _chunk = new (AllocFailStrategy::EXIT_OOM, init_size) Chunk(init_size); _hwm = _chunk->bottom(); // Save the cached hwm, max _max = _chunk->top(); - _size_in_bytes = 0; + MemTracker::record_new_arena(flag); set_size_in_bytes(init_size); - NOT_PRODUCT(Atomic::inc(&_instance_count);) } -Arena::Arena() { +Arena::Arena(MEMFLAGS flag) : _flags(flag), _size_in_bytes(0) { _first = _chunk = new (AllocFailStrategy::EXIT_OOM, Chunk::init_size) Chunk(Chunk::init_size); _hwm = _chunk->bottom(); // Save the cached hwm, max _max = _chunk->top(); - _size_in_bytes = 0; + MemTracker::record_new_arena(flag); set_size_in_bytes(Chunk::init_size); - NOT_PRODUCT(Atomic::inc(&_instance_count);) } Arena *Arena::move_contents(Arena *copy) { @@ -463,7 +460,7 @@ Arena *Arena::move_contents(Arena *copy) { Arena::~Arena() { destruct_contents(); - NOT_PRODUCT(Atomic::dec(&_instance_count);) + MemTracker::record_arena_free(_flags); } void* Arena::operator new(size_t size) throw() { @@ -479,21 +476,21 @@ void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) // dynamic memory type binding void* Arena::operator new(size_t size, MEMFLAGS flags) throw() { #ifdef ASSERT - void* p = (void*)AllocateHeap(size, flags|otArena, CALLER_PC); + void* p = (void*)AllocateHeap(size, flags, CALLER_PC); if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p); return p; #else - return (void *) AllocateHeap(size, flags|otArena, CALLER_PC); + return (void *) AllocateHeap(size, flags, CALLER_PC); #endif } void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw() { #ifdef ASSERT - void* p = os::malloc(size, flags|otArena, CALLER_PC); + void* p = os::malloc(size, flags, CALLER_PC); if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p); return p; #else - return os::malloc(size, flags|otArena, CALLER_PC); + return os::malloc(size, flags, CALLER_PC); #endif } @@ -518,8 +515,9 @@ void Arena::destruct_contents() { // change the size void Arena::set_size_in_bytes(size_t size) { if (_size_in_bytes != size) { + long delta = (long)(size - size_in_bytes()); _size_in_bytes = size; - MemTracker::record_arena_size((address)this, size); + MemTracker::record_arena_size_change(delta, _flags); } } diff --git a/hotspot/src/share/vm/memory/allocation.hpp b/hotspot/src/share/vm/memory/allocation.hpp index fbfff65dad4..adb72e86aab 100644 --- a/hotspot/src/share/vm/memory/allocation.hpp +++ b/hotspot/src/share/vm/memory/allocation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,51 +133,34 @@ class AllocatedObj { /* - * MemoryType bitmap layout: - * | 16 15 14 13 12 11 10 09 | 08 07 06 05 | 04 03 02 01 | - * | memory type | object | reserved | - * | | type | | + * Memory types */ enum MemoryType { // Memory type by sub systems. It occupies lower byte. - mtNone = 0x0000, // undefined - mtClass = 0x0100, // memory class for Java classes - mtThread = 0x0200, // memory for thread objects - mtThreadStack = 0x0300, - mtCode = 0x0400, // memory for generated code - mtGC = 0x0500, // memory for GC - mtCompiler = 0x0600, // memory for compiler - mtInternal = 0x0700, // memory used by VM, but does not belong to + mtJavaHeap = 0x00, // Java heap + mtClass = 0x01, // memory class for Java classes + mtThread = 0x02, // memory for thread objects + mtThreadStack = 0x03, + mtCode = 0x04, // memory for generated code + mtGC = 0x05, // memory for GC + mtCompiler = 0x06, // memory for compiler + mtInternal = 0x07, // memory used by VM, but does not belong to // any of above categories, and not used for // native memory tracking - mtOther = 0x0800, // memory not used by VM - mtSymbol = 0x0900, // symbol - mtNMT = 0x0A00, // memory used by native memory tracking - mtChunk = 0x0B00, // chunk that holds content of arenas - mtJavaHeap = 0x0C00, // Java heap - mtClassShared = 0x0D00, // class data sharing - mtTest = 0x0E00, // Test type for verifying NMT - mtTracing = 0x0F00, // memory used for Tracing - mt_number_of_types = 0x000F, // number of memory types (mtDontTrack + mtOther = 0x08, // memory not used by VM + mtSymbol = 0x09, // symbol + mtNMT = 0x0A, // memory used by native memory tracking + mtClassShared = 0x0B, // class data sharing + mtChunk = 0x0C, // chunk that holds content of arenas + mtTest = 0x0D, // Test type for verifying NMT + mtTracing = 0x0E, // memory used for Tracing + mtNone = 0x0F, // undefined + mt_number_of_types = 0x10 // number of memory types (mtDontTrack // is not included as validate type) - mtDontTrack = 0x0F00, // memory we do not or cannot track - mt_masks = 0x7F00, - - // object type mask - otArena = 0x0010, // an arena object - otNMTRecorder = 0x0020, // memory recorder object - ot_masks = 0x00F0 }; -#define IS_MEMORY_TYPE(flags, type) ((flags & mt_masks) == type) -#define HAS_VALID_MEMORY_TYPE(flags)((flags & mt_masks) != mtNone) -#define FLAGS_TO_MEMORY_TYPE(flags) (flags & mt_masks) +typedef MemoryType MEMFLAGS; -#define IS_ARENA_OBJ(flags) ((flags & ot_masks) == otArena) -#define IS_NMT_RECORDER(flags) ((flags & ot_masks) == otNMTRecorder) -#define NMT_CAN_TRACK(flags) (!IS_NMT_RECORDER(flags) && !(IS_MEMORY_TYPE(flags, mtDontTrack))) - -typedef unsigned short MEMFLAGS; #if INCLUDE_NMT @@ -189,27 +172,23 @@ const bool NMT_track_callsite = false; #endif // INCLUDE_NMT -// debug build does not inline -#if defined(_NMT_NOINLINE_) - #define CURRENT_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0) - #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0) - #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(3) : 0) -#else - #define CURRENT_PC (NMT_track_callsite? os::get_caller_pc(0) : 0) - #define CALLER_PC (NMT_track_callsite ? os::get_caller_pc(1) : 0) - #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0) -#endif - +class NativeCallStack; template class CHeapObj ALLOCATION_SUPER_CLASS_SPEC { public: - _NOINLINE_ void* operator new(size_t size, address caller_pc = 0) throw(); + _NOINLINE_ void* operator new(size_t size, const NativeCallStack& stack) throw(); + _NOINLINE_ void* operator new(size_t size) throw(); _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant, - address caller_pc = 0) throw(); - _NOINLINE_ void* operator new [](size_t size, address caller_pc = 0) throw(); + const NativeCallStack& stack) throw(); + _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant) + throw(); + _NOINLINE_ void* operator new [](size_t size, const NativeCallStack& stack) throw(); + _NOINLINE_ void* operator new [](size_t size) throw(); _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, - address caller_pc = 0) throw(); + const NativeCallStack& stack) throw(); + _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) + throw(); void operator delete(void* p); void operator delete [] (void* p); }; @@ -384,13 +363,15 @@ class Chunk: CHeapObj { //------------------------------Arena------------------------------------------ // Fast allocation of memory -class Arena : public CHeapObj { +class Arena : public CHeapObj { protected: friend class ResourceMark; friend class HandleMark; friend class NoHandleMark; friend class VMStructs; + MEMFLAGS _flags; // Memory tracking flags + Chunk *_first; // First chunk Chunk *_chunk; // current chunk char *_hwm, *_max; // High water mark and max in current chunk @@ -418,8 +399,8 @@ protected: } public: - Arena(); - Arena(size_t init_size); + Arena(MEMFLAGS memflag); + Arena(MEMFLAGS memflag, size_t init_size); ~Arena(); void destruct_contents(); char* hwm() const { return _hwm; } @@ -518,8 +499,6 @@ protected: static void free_malloced_objects(Chunk* chunk, char* hwm, char* max, char* hwm2) PRODUCT_RETURN; static void free_all(char** start, char** end) PRODUCT_RETURN; - // how many arena instances - NOT_PRODUCT(static volatile jint _instance_count;) private: // Reset this Arena to empty, access will trigger grow if necessary void reset(void) { @@ -681,7 +660,7 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { NEW_C_HEAP_ARRAY3(type, (size), memflags, pc, AllocFailStrategy::RETURN_NULL) #define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\ - NEW_C_HEAP_ARRAY3(type, (size), memflags, (address)0, AllocFailStrategy::RETURN_NULL) + NEW_C_HEAP_ARRAY3(type, (size), memflags, CURRENT_PC, AllocFailStrategy::RETURN_NULL) #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\ (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags)) diff --git a/hotspot/src/share/vm/memory/allocation.inline.hpp b/hotspot/src/share/vm/memory/allocation.inline.hpp index 806088b9bae..ddce9f5909b 100644 --- a/hotspot/src/share/vm/memory/allocation.inline.hpp +++ b/hotspot/src/share/vm/memory/allocation.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "runtime/atomic.inline.hpp" #include "runtime/os.hpp" +#include "services/memTracker.hpp" // Explicit C-heap memory management @@ -49,12 +50,10 @@ inline void inc_stat_counter(volatile julong* dest, julong add_value) { #endif // allocate using malloc; will fail if no memory available -inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0, +inline char* AllocateHeap(size_t size, MEMFLAGS flags, + const NativeCallStack& stack, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { - if (pc == 0) { - pc = CURRENT_PC; - } - char* p = (char*) os::malloc(size, flags, pc); + char* p = (char*) os::malloc(size, flags, stack); #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p); #endif @@ -63,10 +62,14 @@ inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0, } return p; } - -inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags, +inline char* AllocateHeap(size_t size, MEMFLAGS flags, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { - char* p = (char*) os::realloc(old, size, flags, CURRENT_PC); + return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode); +} + +inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { + char* p = (char*) os::realloc(old, size, flag, CURRENT_PC); #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p); #endif @@ -85,8 +88,22 @@ inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) { template void* CHeapObj::operator new(size_t size, - address caller_pc) throw() { - void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); + const NativeCallStack& stack) throw() { + void* p = (void*)AllocateHeap(size, F, stack); +#ifdef ASSERT + if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); +#endif + return p; +} + +template void* CHeapObj::operator new(size_t size) throw() { + return CHeapObj::operator new(size, CALLER_PC); +} + +template void* CHeapObj::operator new (size_t size, + const std::nothrow_t& nothrow_constant, const NativeCallStack& stack) throw() { + void* p = (void*)AllocateHeap(size, F, stack, + AllocFailStrategy::RETURN_NULL); #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); #endif @@ -94,23 +111,28 @@ template void* CHeapObj::operator new(size_t size, } template void* CHeapObj::operator new (size_t size, - const std::nothrow_t& nothrow_constant, address caller_pc) throw() { - void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), - AllocFailStrategy::RETURN_NULL); -#ifdef ASSERT - if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); -#endif - return p; + const std::nothrow_t& nothrow_constant) throw() { + return CHeapObj::operator new(size, nothrow_constant, CALLER_PC); } template void* CHeapObj::operator new [](size_t size, - address caller_pc) throw() { - return CHeapObj::operator new(size, caller_pc); + const NativeCallStack& stack) throw() { + return CHeapObj::operator new(size, stack); +} + +template void* CHeapObj::operator new [](size_t size) + throw() { + return CHeapObj::operator new(size, CALLER_PC); } template void* CHeapObj::operator new [](size_t size, - const std::nothrow_t& nothrow_constant, address caller_pc) throw() { - return CHeapObj::operator new(size, nothrow_constant, caller_pc); + const std::nothrow_t& nothrow_constant, const NativeCallStack& stack) throw() { + return CHeapObj::operator new(size, nothrow_constant, stack); +} + +template void* CHeapObj::operator new [](size_t size, + const std::nothrow_t& nothrow_constant) throw() { + return CHeapObj::operator new(size, nothrow_constant, CALLER_PC); } template void CHeapObj::operator delete(void* p){ diff --git a/hotspot/src/share/vm/memory/cardTableRS.cpp b/hotspot/src/share/vm/memory/cardTableRS.cpp index 7c9d3618673..078c22b7c47 100644 --- a/hotspot/src/share/vm/memory/cardTableRS.cpp +++ b/hotspot/src/share/vm/memory/cardTableRS.cpp @@ -56,7 +56,7 @@ CardTableRS::CardTableRS(MemRegion whole_heap, #endif set_bs(_ct_bs); _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, GenCollectedHeap::max_gens + 1, - mtGC, 0, AllocFailStrategy::RETURN_NULL); + mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL); if (_last_cur_val_in_gen == NULL) { vm_exit_during_initialization("Could not create last_cur_val_in_gen array."); } diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index af6e39d05f0..45a99dcaa15 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -909,7 +909,8 @@ void MarkSweepPolicy::initialize_alignments() { } void MarkSweepPolicy::initialize_generations() { - _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); + _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, CURRENT_PC, + AllocFailStrategy::RETURN_NULL); if (_generations == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); } diff --git a/hotspot/src/share/vm/memory/defNewGeneration.cpp b/hotspot/src/share/vm/memory/defNewGeneration.cpp index 281228d28eb..0271b04c351 100644 --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp @@ -790,7 +790,7 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) { // Try allocating obj in to-space (unless too old) if (old->age() < tenuring_threshold()) { - obj = (oop) to()->allocate(s); + obj = (oop) to()->allocate_aligned(s); } // Otherwise try allocating obj tenured diff --git a/hotspot/src/share/vm/memory/heapInspection.cpp b/hotspot/src/share/vm/memory/heapInspection.cpp index 7a4c6fc8752..cc8f4fc061a 100644 --- a/hotspot/src/share/vm/memory/heapInspection.cpp +++ b/hotspot/src/share/vm/memory/heapInspection.cpp @@ -135,7 +135,7 @@ KlassInfoTable::KlassInfoTable(bool need_class_stats) { _ref = (HeapWord*) Universe::boolArrayKlassObj(); _buckets = (KlassInfoBucket*) AllocateHeap(sizeof(KlassInfoBucket) * _num_buckets, - mtInternal, 0, AllocFailStrategy::RETURN_NULL); + mtInternal, CURRENT_PC, AllocFailStrategy::RETURN_NULL); if (_buckets != NULL) { _size = _num_buckets; for (int index = 0; index < _size; index++) { diff --git a/hotspot/src/share/vm/memory/memRegion.cpp b/hotspot/src/share/vm/memory/memRegion.cpp index 9eb2be56930..8c33ddca1de 100644 --- a/hotspot/src/share/vm/memory/memRegion.cpp +++ b/hotspot/src/share/vm/memory/memRegion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,11 +103,13 @@ MemRegion MemRegion::minus(const MemRegion mr2) const { } void* MemRegion::operator new(size_t size) throw() { - return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL); + return (address)AllocateHeap(size, mtGC, CURRENT_PC, + AllocFailStrategy::RETURN_NULL); } void* MemRegion::operator new [](size_t size) throw() { - return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL); + return (address)AllocateHeap(size, mtGC, CURRENT_PC, + AllocFailStrategy::RETURN_NULL); } void MemRegion::operator delete(void* p) { FreeHeap(p, mtGC); diff --git a/hotspot/src/share/vm/memory/resourceArea.hpp b/hotspot/src/share/vm/memory/resourceArea.hpp index e1cafe7f048..02dffc7a4b4 100644 --- a/hotspot/src/share/vm/memory/resourceArea.hpp +++ b/hotspot/src/share/vm/memory/resourceArea.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,11 +49,11 @@ class ResourceArea: public Arena { debug_only(static int _warned;) // to suppress multiple warnings public: - ResourceArea() { + ResourceArea() : Arena(mtThread) { debug_only(_nesting = 0;) } - ResourceArea(size_t init_size) : Arena(init_size) { + ResourceArea(size_t init_size) : Arena(mtThread, init_size) { debug_only(_nesting = 0;); } @@ -64,7 +64,7 @@ public: if (UseMallocOnly) { // use malloc, but save pointer in res. area for later freeing char** save = (char**)internal_malloc_4(sizeof(char*)); - return (*save = (char*)os::malloc(size, mtThread)); + return (*save = (char*)os::malloc(size, mtThread, CURRENT_PC)); } #endif return (char*)Amalloc(size, alloc_failmode); diff --git a/hotspot/src/share/vm/memory/sharedHeap.cpp b/hotspot/src/share/vm/memory/sharedHeap.cpp index e0a5d9961cb..5d268c38515 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.cpp +++ b/hotspot/src/share/vm/memory/sharedHeap.cpp @@ -159,9 +159,9 @@ SharedHeap::StrongRootsScope::~StrongRootsScope() { Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false); void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) { - // The Thread work barrier is only needed by G1. + // The Thread work barrier is only needed by G1 Class Unloading. // No need to use the barrier if this is single-threaded code. - if (UseG1GC && n_workers > 0) { + if (UseG1GC && ClassUnloadingWithConcurrentMark && n_workers > 0) { uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads); if (new_value == n_workers) { // This thread is last. Notify the others. @@ -172,6 +172,9 @@ void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) } void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) { + assert(UseG1GC, "Currently only used by G1"); + assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading"); + // No need to use the barrier if this is single-threaded code. if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) { MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); diff --git a/hotspot/src/share/vm/memory/space.cpp b/hotspot/src/share/vm/memory/space.cpp index 330dd3fdef9..41f1a72150a 100644 --- a/hotspot/src/share/vm/memory/space.cpp +++ b/hotspot/src/share/vm/memory/space.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/shared/liveRange.hpp" #include "gc_implementation/shared/markSweep.hpp" #include "gc_implementation/shared/spaceDecorator.hpp" +#include "gc_interface/collectedHeap.inline.hpp" #include "memory/blockOffsetTable.inline.hpp" #include "memory/defNewGeneration.hpp" #include "memory/genCollectedHeap.hpp" @@ -720,6 +721,27 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size, } while (true); } +HeapWord* ContiguousSpace::allocate_aligned(size_t size) { + assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked"); + HeapWord* end_value = end(); + + HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes); + if (obj == NULL) { + return NULL; + } + + if (pointer_delta(end_value, obj) >= size) { + HeapWord* new_top = obj + size; + set_top(new_top); + assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top), + "checking alignment"); + return obj; + } else { + set_top(obj); + return NULL; + } +} + // Requires locking. HeapWord* ContiguousSpace::allocate(size_t size) { return allocate_impl(size, end()); diff --git a/hotspot/src/share/vm/memory/space.hpp b/hotspot/src/share/vm/memory/space.hpp index 0653884e043..f78a8c7ab4b 100644 --- a/hotspot/src/share/vm/memory/space.hpp +++ b/hotspot/src/share/vm/memory/space.hpp @@ -526,6 +526,7 @@ class ContiguousSpace: public CompactibleSpace { // Allocation (return NULL if full) virtual HeapWord* allocate(size_t word_size); virtual HeapWord* par_allocate(size_t word_size); + HeapWord* allocate_aligned(size_t word_size); // Iteration void oop_iterate(ExtendedOopClosure* cl); diff --git a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp index 5a8d4d0afaf..b613e4ee73f 100644 --- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp +++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp @@ -55,8 +55,6 @@ inline void oopDesc::follow_contents(ParCompactionManager* cm) { klass()->oop_follow_contents(cm, this); } -// Used by parallel old GC. - inline oop oopDesc::forward_to_atomic(oop p) { assert(ParNewGeneration::is_legal_forward_ptr(p), "illegal forwarding pointer value."); diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp index 246446167ca..0b3ee7a7279 100644 --- a/hotspot/src/share/vm/opto/callGenerator.cpp +++ b/hotspot/src/share/vm/opto/callGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -357,7 +357,7 @@ void LateInlineCallGenerator::do_late_inline() { // Make sure the state is a MergeMem for parsing. if (!map->in(TypeFunc::Memory)->is_MergeMem()) { - Node* mem = MergeMemNode::make(C, map->in(TypeFunc::Memory)); + Node* mem = MergeMemNode::make(map->in(TypeFunc::Memory)); C->initial_gvn()->set_type_bottom(mem); map->set_req(TypeFunc::Memory, mem); } diff --git a/hotspot/src/share/vm/opto/callnode.cpp b/hotspot/src/share/vm/opto/callnode.cpp index 275052bf8a9..3ee81242e5b 100644 --- a/hotspot/src/share/vm/opto/callnode.cpp +++ b/hotspot/src/share/vm/opto/callnode.cpp @@ -688,7 +688,7 @@ Node *CallNode::match( const ProjNode *proj, const Matcher *match ) { return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); case TypeFunc::Parms+1: // For LONG & DOUBLE returns - assert(tf()->_range->field_at(TypeFunc::Parms+1) == Type::HALF, ""); + assert(tf()->range()->field_at(TypeFunc::Parms+1) == Type::HALF, ""); // 2nd half of doubles and longs return new MachProjNode(this,proj->_con, RegMask::Empty, (uint)OptoReg::Bad); @@ -778,7 +778,7 @@ bool CallNode::has_non_debug_use(Node *n) { } // Returns the unique CheckCastPP of a call -// or 'this' if there are several CheckCastPP +// or 'this' if there are several CheckCastPP or unexpected uses // or returns NULL if there is no one. Node *CallNode::result_cast() { Node *cast = NULL; @@ -794,6 +794,13 @@ Node *CallNode::result_cast() { return this; // more than 1 CheckCastPP } cast = use; + } else if (!use->is_Initialize() && + !use->is_AddP()) { + // Expected uses are restricted to a CheckCastPP, an Initialize + // node, and AddP nodes. If we encounter any other use (a Phi + // node can be seen in rare cases) return this to prevent + // incorrect optimizations. + return this; } } return cast; diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp index d99118edc83..ab633c106a6 100644 --- a/hotspot/src/share/vm/opto/cfgnode.cpp +++ b/hotspot/src/share/vm/opto/cfgnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,6 +108,7 @@ static Node *merge_region(RegionNode *region, PhaseGVN *phase) { rreq++; // One more input to Region } // Found a region to merge into Region + igvn->_worklist.push(r); // Clobber pointer to the now dead 'r' region->set_req(i, phase->C->top()); } @@ -449,6 +450,7 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Remove TOP or NULL input paths. If only 1 input path remains, this Region // degrades to a copy. bool add_to_worklist = false; + bool modified = false; int cnt = 0; // Count of values merging DEBUG_ONLY( int cnt_orig = req(); ) // Save original inputs count int del_it = 0; // The last input path we delete @@ -459,6 +461,7 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Remove useless control copy inputs if( n->is_Region() && n->as_Region()->is_copy() ) { set_req(i, n->nonnull_req()); + modified = true; i--; continue; } @@ -466,12 +469,14 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *call = n->in(0); if (call->is_Call() && call->as_Call()->entry_point() == OptoRuntime::rethrow_stub()) { set_req(i, call->in(0)); + modified = true; i--; continue; } } if( phase->type(n) == Type::TOP ) { set_req(i, NULL); // Ignore TOP inputs + modified = true; i--; continue; } @@ -691,7 +696,7 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { } } - return NULL; + return modified ? this : NULL; } @@ -1871,7 +1876,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { igvn->register_new_node_with_optimizer(new_base); hook->add_req(new_base); } - MergeMemNode* result = MergeMemNode::make(phase->C, new_base); + MergeMemNode* result = MergeMemNode::make(new_base); for (uint i = 1; i < req(); ++i) { Node *ii = in(i); if (ii->is_MergeMem()) { diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp index 822d83a9c23..50c7d596bf2 100644 --- a/hotspot/src/share/vm/opto/chaitin.cpp +++ b/hotspot/src/share/vm/opto/chaitin.cpp @@ -1620,7 +1620,7 @@ void PhaseChaitin::fixup_spills() { C->check_node_count(0, "out of nodes fixing spills"); if (C->failing()) return; // Transform node - MachNode *cisc = mach->cisc_version(stk_offset, C)->as_Mach(); + MachNode *cisc = mach->cisc_version(stk_offset)->as_Mach(); cisc->set_req(inp,fp); // Base register is frame pointer if( cisc->oper_input_base() > 1 && mach->oper_input_base() <= 1 ) { assert( cisc->oper_input_base() == 2, "Only adding one edge"); diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 585f9315241..9bf539deb71 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -647,6 +647,10 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr _printer(IdealGraphPrinter::printer()), #endif _congraph(NULL), + _comp_arena(mtCompiler), + _node_arena(mtCompiler), + _old_arena(mtCompiler), + _Compile_types(mtCompiler), _replay_inline_data(NULL), _late_inlines(comp_arena(), 2, 0, NULL), _string_late_inlines(comp_arena(), 2, 0, NULL), @@ -954,6 +958,10 @@ Compile::Compile( ciEnv* ci_env, _in_dump_cnt(0), _printer(NULL), #endif + _comp_arena(mtCompiler), + _node_arena(mtCompiler), + _old_arena(mtCompiler), + _Compile_types(mtCompiler), _dead_node_list(comp_arena()), _dead_node_count(0), _congraph(NULL), @@ -1039,6 +1047,7 @@ void Compile::Init(int aliaslevel) { _node_note_array = NULL; _default_node_notes = NULL; + DEBUG_ONLY( _modified_nodes = NULL; ) // Used in Optimize() _immutable_memory = NULL; // filled in at first inquiry @@ -1247,6 +1256,18 @@ void Compile::print_missing_nodes() { } } } +void Compile::record_modified_node(Node* n) { + if (_modified_nodes != NULL && !_inlining_incrementally && + n->outcnt() != 0 && !n->is_Con()) { + _modified_nodes->push(n); + } +} + +void Compile::remove_modified_node(Node* n) { + if (_modified_nodes != NULL) { + _modified_nodes->remove(n); + } +} #endif #ifndef PRODUCT @@ -2035,6 +2056,9 @@ void Compile::Optimize() { // Iterative Global Value Numbering, including ideal transforms // Initialize IterGVN with types and values from parse-time GVN PhaseIterGVN igvn(initial_gvn()); +#ifdef ASSERT + _modified_nodes = new (comp_arena()) Unique_Node_List(comp_arena()); +#endif { NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) igvn.optimize(); @@ -2197,6 +2221,7 @@ void Compile::Optimize() { } } + DEBUG_ONLY( _modified_nodes = NULL; ) } // (End scope of igvn; run destructor if necessary for asserts.) process_print_inlining(); @@ -2825,7 +2850,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { // oops implicit null check is not generated. // This will allow to generate normal oop implicit null check. if (Matcher::gen_narrow_oop_implicit_null_checks()) - new_in2 = ConNode::make(this, TypeNarrowOop::NULL_PTR); + new_in2 = ConNode::make(TypeNarrowOop::NULL_PTR); // // This transformation together with CastPP transformation above // will generated code for implicit NULL checks for compressed oops. @@ -2864,9 +2889,9 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { // NullCheck base_reg // } else if (t->isa_oopptr()) { - new_in2 = ConNode::make(this, t->make_narrowoop()); + new_in2 = ConNode::make(t->make_narrowoop()); } else if (t->isa_klassptr()) { - new_in2 = ConNode::make(this, t->make_narrowklass()); + new_in2 = ConNode::make(t->make_narrowklass()); } } if (new_in2 != NULL) { @@ -2899,11 +2924,11 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { const Type* t = in1->bottom_type(); if (t == TypePtr::NULL_PTR) { assert(t->isa_oopptr(), "null klass?"); - n->subsume_by(ConNode::make(this, TypeNarrowOop::NULL_PTR), this); + n->subsume_by(ConNode::make(TypeNarrowOop::NULL_PTR), this); } else if (t->isa_oopptr()) { - n->subsume_by(ConNode::make(this, t->make_narrowoop()), this); + n->subsume_by(ConNode::make(t->make_narrowoop()), this); } else if (t->isa_klassptr()) { - n->subsume_by(ConNode::make(this, t->make_narrowklass()), this); + n->subsume_by(ConNode::make(t->make_narrowklass()), this); } } if (in1->outcnt() == 0) { @@ -2964,7 +2989,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { if (d) { // Replace them with a fused divmod if supported if (Matcher::has_match_rule(Op_DivModI)) { - DivModINode* divmod = DivModINode::make(this, n); + DivModINode* divmod = DivModINode::make(n); d->subsume_by(divmod->div_proj(), this); n->subsume_by(divmod->mod_proj(), this); } else { @@ -2984,7 +3009,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { if (d) { // Replace them with a fused divmod if supported if (Matcher::has_match_rule(Op_DivModL)) { - DivModLNode* divmod = DivModLNode::make(this, n); + DivModLNode* divmod = DivModLNode::make(n); d->subsume_by(divmod->div_proj(), this); n->subsume_by(divmod->mod_proj(), this); } else { @@ -3010,7 +3035,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { if (n->req()-1 > 2) { // Replace many operand PackNodes with a binary tree for matching PackNode* p = (PackNode*) n; - Node* btp = p->binary_tree_pack(this, 1, n->req()); + Node* btp = p->binary_tree_pack(1, n->req()); n->subsume_by(btp, this); } break; @@ -3035,11 +3060,11 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { if (t != NULL && t->is_con()) { juint shift = t->get_con(); if (shift > mask) { // Unsigned cmp - n->set_req(2, ConNode::make(this, TypeInt::make(shift & mask))); + n->set_req(2, ConNode::make(TypeInt::make(shift & mask))); } } else { if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { - Node* shift = new AndINode(in2, ConNode::make(this, TypeInt::make(mask))); + Node* shift = new AndINode(in2, ConNode::make(TypeInt::make(mask))); n->set_req(2, shift); } } @@ -4031,6 +4056,7 @@ void Compile::cleanup_expensive_nodes(PhaseIterGVN &igvn) { int j = 0; int identical = 0; int i = 0; + bool modified = false; for (; i < _expensive_nodes->length()-1; i++) { assert(j <= i, "can't write beyond current index"); if (_expensive_nodes->at(i)->Opcode() == _expensive_nodes->at(i+1)->Opcode()) { @@ -4043,20 +4069,23 @@ void Compile::cleanup_expensive_nodes(PhaseIterGVN &igvn) { identical = 0; } else { Node* n = _expensive_nodes->at(i); - igvn.hash_delete(n); - n->set_req(0, NULL); + igvn.replace_input_of(n, 0, NULL); igvn.hash_insert(n); + modified = true; } } if (identical > 0) { _expensive_nodes->at_put(j++, _expensive_nodes->at(i)); } else if (_expensive_nodes->length() >= 1) { Node* n = _expensive_nodes->at(i); - igvn.hash_delete(n); - n->set_req(0, NULL); + igvn.replace_input_of(n, 0, NULL); igvn.hash_insert(n); + modified = true; } _expensive_nodes->trunc_to(j); + if (modified) { + igvn.optimize(); + } } void Compile::add_expensive_node(Node * n) { diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 29380e1f898..d9af09a3af1 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -344,6 +344,8 @@ class Compile : public Phase { VectorSet _dead_node_list; // Set of dead nodes uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N). // So use this to keep count and make the call O(1). + DEBUG_ONLY( Unique_Node_List* _modified_nodes; ) // List of nodes which inputs were modified + debug_only(static int _debug_idx;) // Monotonic counter (not reset), use -XX:BreakAtNode= Arena _node_arena; // Arena for new-space Nodes Arena _old_arena; // Arena for old-space Nodes, lifetime during xform @@ -766,6 +768,11 @@ class Compile : public Phase { void print_missing_nodes(); #endif + // Record modified nodes to check that they are put on IGVN worklist + void record_modified_node(Node* n) NOT_DEBUG_RETURN; + void remove_modified_node(Node* n) NOT_DEBUG_RETURN; + DEBUG_ONLY( Unique_Node_List* modified_nodes() const { return _modified_nodes; } ) + // Constant table ConstantTable& constant_table() { return _constant_table; } diff --git a/hotspot/src/share/vm/opto/connode.cpp b/hotspot/src/share/vm/opto/connode.cpp index 485e8df7951..fa074f97b3d 100644 --- a/hotspot/src/share/vm/opto/connode.cpp +++ b/hotspot/src/share/vm/opto/connode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ uint ConNode::hash() const { } //------------------------------make------------------------------------------- -ConNode *ConNode::make( Compile* C, const Type *t ) { +ConNode *ConNode::make(const Type *t) { switch( t->basic_type() ) { case T_INT: return new ConINode( t->is_int() ); case T_LONG: return new ConLNode( t->is_long() ); diff --git a/hotspot/src/share/vm/opto/connode.hpp b/hotspot/src/share/vm/opto/connode.hpp index 446b807a846..d1c68862ebf 100644 --- a/hotspot/src/share/vm/opto/connode.hpp +++ b/hotspot/src/share/vm/opto/connode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public: virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; } // Polymorphic factory method: - static ConNode* make( Compile* C, const Type *t ); + static ConNode* make(const Type *t); }; //------------------------------ConINode--------------------------------------- @@ -57,7 +57,7 @@ public: virtual int Opcode() const; // Factory method: - static ConINode* make( Compile* C, int con ) { + static ConINode* make(int con) { return new ConINode( TypeInt::make(con) ); } @@ -71,7 +71,7 @@ public: virtual int Opcode() const; // Factory methods: - static ConPNode* make( Compile *C ,address con ) { + static ConPNode* make(address con) { if (con == NULL) return new ConPNode( TypePtr::NULL_PTR ) ; else @@ -105,7 +105,7 @@ public: virtual int Opcode() const; // Factory method: - static ConLNode* make( Compile *C ,jlong con ) { + static ConLNode* make(jlong con) { return new ConLNode( TypeLong::make(con) ); } @@ -119,7 +119,7 @@ public: virtual int Opcode() const; // Factory method: - static ConFNode* make( Compile *C, float con ) { + static ConFNode* make(float con) { return new ConFNode( TypeF::make(con) ); } @@ -133,7 +133,7 @@ public: virtual int Opcode() const; // Factory method: - static ConDNode* make( Compile *C, double con ) { + static ConDNode* make(double con) { return new ConDNode( TypeD::make(con) ); } diff --git a/hotspot/src/share/vm/opto/divnode.cpp b/hotspot/src/share/vm/opto/divnode.cpp index 8a27c24e37e..4677d00a9f7 100644 --- a/hotspot/src/share/vm/opto/divnode.cpp +++ b/hotspot/src/share/vm/opto/divnode.cpp @@ -479,7 +479,10 @@ Node *DivINode::Ideal(PhaseGVN *phase, bool can_reshape) { if (i == 0) return NULL; // Dividing by zero constant does not idealize - set_req(0,NULL); // Dividing by a not-zero constant; no faulting + if (in(0) != NULL) { + phase->igvn_rehash_node_delayed(this); + set_req(0, NULL); // Dividing by a not-zero constant; no faulting + } // Dividing by MININT does not optimize as a power-of-2 shift. if( i == min_jint ) return NULL; @@ -578,7 +581,10 @@ Node *DivLNode::Ideal( PhaseGVN *phase, bool can_reshape) { if (l == 0) return NULL; // Dividing by zero constant does not idealize - set_req(0,NULL); // Dividing by a not-zero constant; no faulting + if (in(0) != NULL) { + phase->igvn_rehash_node_delayed(this); + set_req(0, NULL); // Dividing by a not-zero constant; no faulting + } // Dividing by MINLONG does not optimize as a power-of-2 shift. if( l == min_jlong ) return NULL; @@ -1274,7 +1280,7 @@ DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) } //------------------------------make------------------------------------------ -DivModINode* DivModINode::make(Compile* C, Node* div_or_mod) { +DivModINode* DivModINode::make(Node* div_or_mod) { Node* n = div_or_mod; assert(n->Opcode() == Op_DivI || n->Opcode() == Op_ModI, "only div or mod input pattern accepted"); @@ -1286,7 +1292,7 @@ DivModINode* DivModINode::make(Compile* C, Node* div_or_mod) { } //------------------------------make------------------------------------------ -DivModLNode* DivModLNode::make(Compile* C, Node* div_or_mod) { +DivModLNode* DivModLNode::make(Node* div_or_mod) { Node* n = div_or_mod; assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL, "only div or mod input pattern accepted"); diff --git a/hotspot/src/share/vm/opto/divnode.hpp b/hotspot/src/share/vm/opto/divnode.hpp index 03f5be546bc..195803e2000 100644 --- a/hotspot/src/share/vm/opto/divnode.hpp +++ b/hotspot/src/share/vm/opto/divnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -168,7 +168,7 @@ public: virtual Node *match( const ProjNode *proj, const Matcher *m ); // Make a divmod and associated projections from a div or mod. - static DivModINode* make(Compile* C, Node* div_or_mod); + static DivModINode* make(Node* div_or_mod); }; //------------------------------DivModLNode--------------------------------------- @@ -181,7 +181,7 @@ public: virtual Node *match( const ProjNode *proj, const Matcher *m ); // Make a divmod and associated projections from a div or mod. - static DivModLNode* make(Compile* C, Node* div_or_mod); + static DivModLNode* make(Node* div_or_mod); }; #endif // SHARE_VM_OPTO_DIVNODE_HPP diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp index 10791a5991d..a4c84b63846 100644 --- a/hotspot/src/share/vm/opto/escape.cpp +++ b/hotspot/src/share/vm/opto/escape.cpp @@ -1452,7 +1452,6 @@ int ConnectionGraph::find_init_values(JavaObjectNode* pta, PointsToNode* init_va return 0; InitializeNode* ini = alloc->as_Allocate()->initialization(); - Compile* C = _compile; bool visited_bottom_offset = false; GrowableArray offsets_worklist; diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index e7269aa514e..8228aad4fac 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -591,7 +591,7 @@ void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) { C->log()->elem("hot_throw preallocated='1' reason='%s'", Deoptimization::trap_reason_name(reason)); const TypeInstPtr* ex_con = TypeInstPtr::make(ex_obj); - Node* ex_node = _gvn.transform( ConNode::make(C, ex_con) ); + Node* ex_node = _gvn.transform(ConNode::make(ex_con)); // Clear the detail message of the preallocated exception object. // Weblogic sometimes mutates the detail message of exceptions @@ -706,7 +706,7 @@ SafePointNode* GraphKit::clone_map() { if (map() == NULL) return NULL; // Clone the memory edge first - Node* mem = MergeMemNode::make(C, map()->memory()); + Node* mem = MergeMemNode::make(map()->memory()); gvn().set_type_bottom(mem); SafePointNode *clonemap = (SafePointNode*)map()->clone(); @@ -1135,7 +1135,7 @@ Node* GraphKit::ConvI2UL(Node* offset) { return longcon((julong) offset_con); } Node* conv = _gvn.transform( new ConvI2LNode(offset)); - Node* mask = _gvn.transform( ConLNode::make(C, (julong) max_juint) ); + Node* mask = _gvn.transform(ConLNode::make((julong) max_juint)); return _gvn.transform( new AndLNode(conv, mask) ); } @@ -1435,7 +1435,7 @@ Node* GraphKit::reset_memory() { //------------------------------set_all_memory--------------------------------- void GraphKit::set_all_memory(Node* newmem) { - Node* mergemem = MergeMemNode::make(C, newmem); + Node* mergemem = MergeMemNode::make(newmem); gvn().set_type_bottom(mergemem); map()->set_memory(mergemem); } @@ -1464,9 +1464,9 @@ Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, Node* mem = memory(adr_idx); Node* ld; if (require_atomic_access && bt == T_LONG) { - ld = LoadLNode::make_atomic(C, ctl, mem, adr, adr_type, t, mo); + ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo); } else if (require_atomic_access && bt == T_DOUBLE) { - ld = LoadDNode::make_atomic(C, ctl, mem, adr, adr_type, t, mo); + ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo); } else { ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo); } @@ -1488,9 +1488,9 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt, Node *mem = memory(adr_idx); Node* st; if (require_atomic_access && bt == T_LONG) { - st = StoreLNode::make_atomic(C, ctl, mem, adr, adr_type, val, mo); + st = StoreLNode::make_atomic(ctl, mem, adr, adr_type, val, mo); } else if (require_atomic_access && bt == T_DOUBLE) { - st = StoreDNode::make_atomic(C, ctl, mem, adr, adr_type, val, mo); + st = StoreDNode::make_atomic(ctl, mem, adr, adr_type, val, mo); } else { st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt, mo); } @@ -2084,9 +2084,9 @@ Node* GraphKit::just_allocated_object(Node* current_control) { void GraphKit::round_double_arguments(ciMethod* dest_method) { // (Note: TypeFunc::make has a cache that makes this fast.) const TypeFunc* tf = TypeFunc::make(dest_method); - int nargs = tf->_domain->_cnt - TypeFunc::Parms; + int nargs = tf->domain()->cnt() - TypeFunc::Parms; for (int j = 0; j < nargs; j++) { - const Type *targ = tf->_domain->field_at(j + TypeFunc::Parms); + const Type *targ = tf->domain()->field_at(j + TypeFunc::Parms); if( targ->basic_type() == T_DOUBLE ) { // If any parameters are doubles, they must be rounded before // the call, dstore_rounding does gvn.transform @@ -2188,10 +2188,10 @@ void GraphKit::record_profiled_arguments_for_speculation(ciMethod* dest_method, return; } const TypeFunc* tf = TypeFunc::make(dest_method); - int nargs = tf->_domain->_cnt - TypeFunc::Parms; + int nargs = tf->domain()->cnt() - TypeFunc::Parms; int skip = Bytecodes::has_receiver(bc) ? 1 : 0; for (int j = skip, i = 0; j < nargs && i < TypeProfileArgsLimit; j++) { - const Type *targ = tf->_domain->field_at(j + TypeFunc::Parms); + const Type *targ = tf->domain()->field_at(j + TypeFunc::Parms); if (targ->basic_type() == T_OBJECT || targ->basic_type() == T_ARRAY) { bool maybe_null = true; ciKlass* better_type = NULL; @@ -3364,7 +3364,7 @@ Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, // This will allow us to observe initializations when they occur, // and link them properly (as a group) to the InitializeNode. assert(init->in(InitializeNode::Memory) == malloc, ""); - MergeMemNode* minit_in = MergeMemNode::make(C, malloc); + MergeMemNode* minit_in = MergeMemNode::make(malloc); init->set_req(InitializeNode::Memory, minit_in); record_for_igvn(minit_in); // fold it up later, if possible Node* minit_out = memory(rawidx); diff --git a/hotspot/src/share/vm/opto/idealKit.cpp b/hotspot/src/share/vm/opto/idealKit.cpp index a0a9cbe62cc..3038982e648 100644 --- a/hotspot/src/share/vm/opto/idealKit.cpp +++ b/hotspot/src/share/vm/opto/idealKit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -320,7 +320,7 @@ Node* IdealKit::copy_cvstate() { Node* ns = new_cvstate(); for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i)); // We must clone memory since it will be updated as we do stores. - ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory))); + ns->set_req(TypeFunc::Memory, MergeMemNode::make(ns->in(TypeFunc::Memory))); return ns; } @@ -359,7 +359,7 @@ Node* IdealKit::load(Node* ctl, Node* mem = memory(adr_idx); Node* ld; if (require_atomic_access && bt == T_LONG) { - ld = LoadLNode::make_atomic(C, ctl, mem, adr, adr_type, t, MemNode::unordered); + ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, MemNode::unordered); } else { ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, MemNode::unordered); } @@ -375,7 +375,7 @@ Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt, Node *mem = memory(adr_idx); Node* st; if (require_atomic_access && bt == T_LONG) { - st = StoreLNode::make_atomic(C, ctl, mem, adr, adr_type, val, mo); + st = StoreLNode::make_atomic(ctl, mem, adr, adr_type, val, mo); } else { st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt, mo); } diff --git a/hotspot/src/share/vm/opto/lcm.cpp b/hotspot/src/share/vm/opto/lcm.cpp index a601752d4cd..187d2699768 100644 --- a/hotspot/src/share/vm/opto/lcm.cpp +++ b/hotspot/src/share/vm/opto/lcm.cpp @@ -464,7 +464,9 @@ Node* PhaseCFG::select(Block* block, Node_List &worklist, GrowableArray &re iop == Op_CreateEx || // Create-exception must start block iop == Op_CheckCastPP ) { - worklist.map(i,worklist.pop()); + // select the node n + // remove n from worklist and retain the order of remaining nodes + worklist.remove((uint)i); return n; } @@ -550,7 +552,9 @@ Node* PhaseCFG::select(Block* block, Node_List &worklist, GrowableArray &re assert(idx >= 0, "index should be set"); Node *n = worklist[(uint)idx]; // Get the winner - worklist.map((uint)idx, worklist.pop()); // Compress worklist + // select the node n + // remove n from worklist and retain the order of remaining nodes + worklist.remove((uint)idx); return n; } diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 8e01709fcda..1cfa17b5852 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -1905,7 +1905,7 @@ bool LibraryCallKit::inline_pow() { Node *bolyplus1 = _gvn.transform(new BoolNode( cmpyplus1, BoolTest::eq )); Node* correctedsign = NULL; if (ConditionalMoveLimit != 0) { - correctedsign = _gvn.transform( CMoveNode::make(C, NULL, bolyplus1, signnode, longcon(0), TypeLong::LONG)); + correctedsign = _gvn.transform(CMoveNode::make(NULL, bolyplus1, signnode, longcon(0), TypeLong::LONG)); } else { IfNode *ifyplus1 = create_and_xform_if(ylong_path,bolyplus1, PROB_FAIR, COUNT_UNKNOWN); RegionNode *r = new RegionNode(3); @@ -1934,7 +1934,7 @@ bool LibraryCallKit::inline_pow() { // (1&(long)y)==1?-DPow(abs(x), y):DPow(abs(x), y) Node *signresult = NULL; if (ConditionalMoveLimit != 0) { - signresult = _gvn.transform( CMoveNode::make(C, NULL, bol3, absxpowy, negabsxpowy, Type::DOUBLE)); + signresult = _gvn.transform(CMoveNode::make(NULL, bol3, absxpowy, negabsxpowy, Type::DOUBLE)); } else { IfNode *ifyeven = create_and_xform_if(ylong_path,bol3, PROB_FAIR, COUNT_UNKNOWN); RegionNode *r = new RegionNode(3); @@ -2268,7 +2268,7 @@ LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { // which could hinder other optimizations. // Since Math.min/max is often used with arraycopy, we want // tightly_coupled_allocation to be able to see beyond min/max expressions. - Node* cmov = CMoveNode::make(C, NULL, best_bol, + Node* cmov = CMoveNode::make(NULL, best_bol, answer_if_false, answer_if_true, TypeInt::make(lo, hi, widen)); diff --git a/hotspot/src/share/vm/opto/loopPredicate.cpp b/hotspot/src/share/vm/opto/loopPredicate.cpp index 4f2ddd3d068..a55f73db1ac 100644 --- a/hotspot/src/share/vm/opto/loopPredicate.cpp +++ b/hotspot/src/share/vm/opto/loopPredicate.cpp @@ -107,8 +107,7 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* rgn = new RegionNode(1); rgn->add_req(uncommon_proj); register_control(rgn, loop, uncommon_proj); - _igvn.hash_delete(call); - call->set_req(0, rgn); + _igvn.replace_input_of(call, 0, rgn); // When called from beautify_loops() idom is not constructed yet. if (_idom != NULL) { set_idom(call, rgn, dom_depth(rgn)); @@ -166,8 +165,7 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* if (new_entry == NULL) { // Attach if_cont to iff - _igvn.hash_delete(iff); - iff->set_req(0, if_cont); + _igvn.replace_input_of(iff, 0, if_cont); if (_idom != NULL) { set_idom(iff, if_cont, dom_depth(iff)); } @@ -194,8 +192,7 @@ ProjNode* PhaseIterGVN::create_new_if_for_predicate(ProjNode* cont_proj, Node* n rgn = new RegionNode(1); register_new_node_with_optimizer(rgn); rgn->add_req(uncommon_proj); - hash_delete(call); - call->set_req(0, rgn); + replace_input_of(call, 0, rgn); } else { // Find region's edge corresponding to uncommon_proj for (; proj_index < rgn->req(); proj_index++) diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp index 73ec0617370..9701cfd2cf2 100644 --- a/hotspot/src/share/vm/opto/loopTransform.cpp +++ b/hotspot/src/share/vm/opto/loopTransform.cpp @@ -924,15 +924,13 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ if( bol->outcnt() != 1 ) { bol = bol->clone(); register_new_node(bol,main_end->in(CountedLoopEndNode::TestControl)); - _igvn.hash_delete(main_end); - main_end->set_req(CountedLoopEndNode::TestValue, bol); + _igvn.replace_input_of(main_end, CountedLoopEndNode::TestValue, bol); } // Need only 1 user of 'cmp' because I will be hacking the loop bounds. if( cmp->outcnt() != 1 ) { cmp = cmp->clone(); register_new_node(cmp,main_end->in(CountedLoopEndNode::TestControl)); - _igvn.hash_delete(bol); - bol->set_req(1, cmp); + _igvn.replace_input_of(bol, 1, cmp); } //------------------------------ @@ -1118,8 +1116,7 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ Node* pre_bol = pre_end->in(CountedLoopEndNode::TestValue)->as_Bool(); BoolNode* new_bol0 = new BoolNode(pre_bol->in(1), new_test); register_new_node( new_bol0, pre_head->in(0) ); - _igvn.hash_delete(pre_end); - pre_end->set_req(CountedLoopEndNode::TestValue, new_bol0); + _igvn.replace_input_of(pre_end, CountedLoopEndNode::TestValue, new_bol0); // Modify main loop guard condition assert(min_iff->in(CountedLoopEndNode::TestValue) == min_bol, "guard okay"); BoolNode* new_bol1 = new BoolNode(min_bol->in(1), new_test); @@ -1130,8 +1127,7 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ BoolNode* main_bol = main_end->in(CountedLoopEndNode::TestValue)->as_Bool(); BoolNode* new_bol2 = new BoolNode(main_bol->in(1), new_test); register_new_node( new_bol2, main_end->in(CountedLoopEndNode::TestControl) ); - _igvn.hash_delete(main_end); - main_end->set_req(CountedLoopEndNode::TestValue, new_bol2); + _igvn.replace_input_of(main_end, CountedLoopEndNode::TestValue, new_bol2); } // Flag main loop @@ -1346,8 +1342,7 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad Node* bol2 = loop_end->in(1)->clone(); bol2->set_req(1, cmp2); register_new_node(bol2, ctrl2); - _igvn.hash_delete(loop_end); - loop_end->set_req(1, bol2); + _igvn.replace_input_of(loop_end, 1, bol2); } // Step 3: Find the min-trip test guaranteed before a 'main' loop. // Make it a 1-trip test (means at least 2 trips). @@ -1356,8 +1351,7 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad // can edit it's inputs directly. Hammer in the new limit for the // minimum-trip guard. assert(opaq->outcnt() == 1, ""); - _igvn.hash_delete(opaq); - opaq->set_req(1, new_limit); + _igvn.replace_input_of(opaq, 1, new_limit); } // Adjust max trip count. The trip count is intentionally rounded @@ -1407,8 +1401,7 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad register_new_node( cmp2, ctrl2 ); Node *bol2 = new BoolNode( cmp2, loop_end->test_trip() ); register_new_node( bol2, ctrl2 ); - _igvn.hash_delete(loop_end); - loop_end->set_req(CountedLoopEndNode::TestValue, bol2); + _igvn.replace_input_of(loop_end, CountedLoopEndNode::TestValue, bol2); // Step 3: Find the min-trip test guaranteed before a 'main' loop. // Make it a 1-trip test (means at least 2 trips). @@ -1997,8 +1990,7 @@ void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) { : (Node*)new MaxINode(pre_limit, orig_limit); register_new_node(pre_limit, pre_ctrl); } - _igvn.hash_delete(pre_opaq); - pre_opaq->set_req(1, pre_limit); + _igvn.replace_input_of(pre_opaq, 1, pre_limit); // Note:: we are making the main loop limit no longer precise; // need to round up based on stride. @@ -2027,10 +2019,9 @@ void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) { Node *main_bol = main_cle->in(1); // Hacking loop bounds; need private copies of exit test if( main_bol->outcnt() > 1 ) {// BoolNode shared? - _igvn.hash_delete(main_cle); main_bol = main_bol->clone();// Clone a private BoolNode register_new_node( main_bol, main_cle->in(0) ); - main_cle->set_req(1,main_bol); + _igvn.replace_input_of(main_cle, 1, main_bol); } Node *main_cmp = main_bol->in(1); if( main_cmp->outcnt() > 1 ) { // CmpNode shared? diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index 5ee44d084bd..5ca0ab059db 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -133,7 +133,7 @@ Node *PhaseIdealLoop::get_early_ctrl( Node *n ) { // Return earliest legal location assert(early == find_non_split_ctrl(early), "unexpected early control"); - if (n->is_expensive()) { + if (n->is_expensive() && !_verify_only && !_verify_me) { assert(n->in(0), "should have control input"); early = get_early_ctrl_for_expensive(n, early); } @@ -226,8 +226,7 @@ Node *PhaseIdealLoop::get_early_ctrl_for_expensive(Node *n, Node* earliest) { } if (ctl != n->in(0)) { - _igvn.hash_delete(n); - n->set_req(0, ctl); + _igvn.replace_input_of(n, 0, ctl); _igvn.hash_insert(n); } @@ -521,8 +520,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { assert(check_iff->in(1)->Opcode() == Op_Conv2B && check_iff->in(1)->in(1)->Opcode() == Op_Opaque1, ""); Node* opq = check_iff->in(1)->in(1); - _igvn.hash_delete(opq); - opq->set_req(1, bol); + _igvn.replace_input_of(opq, 1, bol); // Update ctrl. set_ctrl(opq, check_iff->in(0)); set_ctrl(check_iff->in(1), check_iff->in(0)); @@ -690,7 +688,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { incr->set_req(2,stride); incr = _igvn.register_new_node_with_optimizer(incr); set_early_ctrl( incr ); - _igvn.hash_delete(phi); + _igvn.rehash_node_delayed(phi); phi->set_req_X( LoopNode::LoopBackControl, incr, &_igvn ); // If phi type is more restrictive than Int, raise to @@ -743,8 +741,8 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { iffalse = iff2; iftrue = ift2; } else { - _igvn.hash_delete(iffalse); - _igvn.hash_delete(iftrue); + _igvn.rehash_node_delayed(iffalse); + _igvn.rehash_node_delayed(iftrue); iffalse->set_req_X( 0, le, &_igvn ); iftrue ->set_req_X( 0, le, &_igvn ); } @@ -1257,6 +1255,7 @@ void IdealLoopTree::split_fall_in( PhaseIdealLoop *phase, int fall_in_cnt ) { _head->del_req(i); } } + igvn.rehash_node_delayed(_head); // Transform landing pad igvn.register_new_node_with_optimizer(landing_pad, _head); // Insert landing pad into the header @@ -1397,7 +1396,7 @@ void IdealLoopTree::merge_many_backedges( PhaseIdealLoop *phase ) { igvn.register_new_node_with_optimizer(r, _head); // Plug region into end of loop _head, followed by hot_tail while( _head->req() > 3 ) _head->del_req( _head->req()-1 ); - _head->set_req(2, r); + igvn.replace_input_of(_head, 2, r); if( hot_idx ) _head->add_req(hot_tail); // Split all the Phis up between '_head' loop and the Region 'r' @@ -1419,7 +1418,7 @@ void IdealLoopTree::merge_many_backedges( PhaseIdealLoop *phase ) { igvn.register_new_node_with_optimizer(phi, n); // Add the merge phi to the old Phi while( n->req() > 3 ) n->del_req( n->req()-1 ); - n->set_req(2, phi); + igvn.replace_input_of(n, 2, phi); if( hot_idx ) n->add_req(hot_phi); } } @@ -1495,13 +1494,14 @@ bool IdealLoopTree::beautify_loops( PhaseIdealLoop *phase ) { if( fall_in_cnt > 1 ) { // Since I am just swapping inputs I do not need to update def-use info Node *tmp = _head->in(1); + igvn.rehash_node_delayed(_head); _head->set_req( 1, _head->in(fall_in_cnt) ); _head->set_req( fall_in_cnt, tmp ); // Swap also all Phis for (DUIterator_Fast imax, i = _head->fast_outs(imax); i < imax; i++) { Node* phi = _head->fast_out(i); if( phi->is_Phi() ) { - igvn.hash_delete(phi); // Yank from hash before hacking edges + igvn.rehash_node_delayed(phi); // Yank from hash before hacking edges tmp = phi->in(1); phi->set_req( 1, phi->in(fall_in_cnt) ); phi->set_req( fall_in_cnt, tmp ); @@ -2905,6 +2905,7 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { uint k = 0; // Probably cfg->in(0) while( cfg->in(k) != m ) k++; // But check incase cfg is a Region cfg->set_req( k, if_t ); // Now point to NeverBranch + _igvn._worklist.push(cfg); // Now create the never-taken loop exit Node *if_f = new CProjNode( iff, 1 ); diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp index e25a6b0762e..20ad4ff1f6d 100644 --- a/hotspot/src/share/vm/opto/loopopts.cpp +++ b/hotspot/src/share/vm/opto/loopopts.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -625,7 +625,7 @@ Node *PhaseIdealLoop::conditional_move( Node *region ) { set_ctrl(inp, cmov_ctrl); } } - Node *cmov = CMoveNode::make( C, cmov_ctrl, iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi) ); + Node *cmov = CMoveNode::make(cmov_ctrl, iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi)); register_new_node( cmov, cmov_ctrl ); _igvn.replace_node( phi, cmov ); #ifndef PRODUCT @@ -2574,7 +2574,7 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { new_head->set_unswitch_count(head->unswitch_count()); // Preserve _igvn.register_new_node_with_optimizer(new_head); assert(first_not_peeled->in(0) == last_peel, "last_peel <- first_not_peeled"); - first_not_peeled->set_req(0, new_head); + _igvn.replace_input_of(first_not_peeled, 0, new_head); set_loop(new_head, loop); loop->_body.push(new_head); not_peel.set(new_head->_idx); diff --git a/hotspot/src/share/vm/opto/machnode.cpp b/hotspot/src/share/vm/opto/machnode.cpp index 69139e104f7..a2112199f26 100644 --- a/hotspot/src/share/vm/opto/machnode.cpp +++ b/hotspot/src/share/vm/opto/machnode.cpp @@ -178,7 +178,7 @@ uint MachNode::cmp( const Node &node ) const { } // Return an equivalent instruction using memory for cisc_operand position -MachNode *MachNode::cisc_version(int offset, Compile* C) { +MachNode *MachNode::cisc_version(int offset) { ShouldNotCallThis(); return NULL; } @@ -411,7 +411,7 @@ int MachNode::operand_index(const MachOper *oper) const { //------------------------------peephole--------------------------------------- // Apply peephole rule(s) to this instruction -MachNode *MachNode::peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ) { +MachNode *MachNode::peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted) { return NULL; } diff --git a/hotspot/src/share/vm/opto/machnode.hpp b/hotspot/src/share/vm/opto/machnode.hpp index 78ab196b3a5..a557c02e6c6 100644 --- a/hotspot/src/share/vm/opto/machnode.hpp +++ b/hotspot/src/share/vm/opto/machnode.hpp @@ -152,7 +152,7 @@ public: virtual uint cmp( const MachOper &oper ) const; // Virtual clone, since I do not know how big the MachOper is. - virtual MachOper *clone(Compile* C) const = 0; + virtual MachOper *clone() const = 0; // Return ideal Type from simple operands. Fail for complex operands. virtual const Type *type() const; @@ -202,10 +202,10 @@ public: // Copy inputs and operands to new node of instruction. // Called from cisc_version() and short_branch_version(). // !!!! The method's body is defined in ad_.cpp file. - void fill_new_machnode(MachNode *n, Compile* C) const; + void fill_new_machnode(MachNode *n) const; // Return an equivalent instruction using memory for cisc_operand position - virtual MachNode *cisc_version(int offset, Compile* C); + virtual MachNode *cisc_version(int offset); // Modify this instruction's register mask to use stack version for cisc_operand virtual void use_cisc_RegMask(); @@ -317,7 +317,7 @@ public: virtual const class TypePtr *adr_type() const; // Apply peephole rule(s) to this instruction - virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ); + virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted); // Top-level ideal Opcode matched virtual int ideal_Opcode() const { return Op_Node; } @@ -627,7 +627,7 @@ public: virtual void save_label(Label** label, uint* block_num) = 0; // Support for short branches - virtual MachNode *short_branch_version(Compile* C) { return NULL; } + virtual MachNode *short_branch_version() { return NULL; } virtual bool pinned() const { return true; }; }; @@ -985,7 +985,7 @@ public: labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {} - virtual MachOper *clone(Compile* C) const; + virtual MachOper *clone() const; virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; } @@ -1012,7 +1012,7 @@ public: methodOper() : _method(0) {} methodOper(intptr_t method) : _method(method) {} - virtual MachOper *clone(Compile* C) const; + virtual MachOper *clone() const; virtual intptr_t method() const { return _method; } diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp index 5b1f4397642..33e808383c9 100644 --- a/hotspot/src/share/vm/opto/macro.cpp +++ b/hotspot/src/share/vm/opto/macro.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -702,6 +702,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray result_cast(); + assert(res == NULL || res->is_CheckCastPP(), "unexpected AllocateNode result"); const TypeOopPtr* res_type = NULL; if (res != NULL) { // Could be NULL when there are no users res_type = _igvn.type(res)->isa_oopptr(); @@ -791,6 +792,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray del_req(last--); } + _igvn._worklist.push(sfpt); // rollback processed safepoints while (safepoints_done.length() > 0) { SafePointNode* sfpt_done = safepoints_done.pop(); @@ -815,6 +817,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray debug_start(); int end = jvms->debug_end(); sfpt->replace_edges_in_range(res, sobj, start, end); + _igvn._worklist.push(sfpt); safepoints_done.append_if_missing(sfpt); // keep it for rollback } return true; @@ -1034,6 +1038,8 @@ bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) { return false; } + assert(boxing->result_cast() == NULL, "unexpected boxing node result"); + extract_call_projections(boxing); const TypeTuple* r = boxing->tf()->range(); @@ -1775,6 +1781,7 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, Node *pf_region = new RegionNode(3); Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY, TypeRawPtr::BOTTOM ); + transform_later(pf_region); // Generate several prefetch instructions. uint lines = (length != NULL) ? AllocatePrefetchLines : AllocateInstancePrefetchLines; diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index cce4a739473..8ecb54b2dc9 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -305,7 +305,7 @@ void Matcher::match( ) { // to avoid false sharing if the corresponding mach node is not used. // The corresponding mach node is only used in rare cases for derived // pointers. - Node* new_ideal_null = ConNode::make(C, TypePtr::NULL_PTR); + Node* new_ideal_null = ConNode::make(TypePtr::NULL_PTR); // Swap out to old-space; emptying new-space Arena *old = C->node_arena()->move_contents(C->old_arena()); @@ -1643,8 +1643,8 @@ MachNode *Matcher::ReduceInst( State *s, int rule, Node *&mem ) { } // Build the object to represent this state & prepare for recursive calls - MachNode *mach = s->MachNodeGenerator( rule, C ); - mach->_opnds[0] = s->MachOperGenerator( _reduceOp[rule], C ); + MachNode *mach = s->MachNodeGenerator(rule); + mach->_opnds[0] = s->MachOperGenerator(_reduceOp[rule]); assert( mach->_opnds[0] != NULL, "Missing result operand" ); Node *leaf = s->_leaf; // Check for instruction or instruction chain rule @@ -1756,13 +1756,13 @@ void Matcher::ReduceInst_Chain_Rule( State *s, int rule, Node *&mem, MachNode *m assert( 0 <= opnd_class_instance && opnd_class_instance < NUM_OPERANDS, "Bad AD file: Instruction chain rule must chain from operand"); // Insert operand into array of operands for this instruction - mach->_opnds[1] = s->MachOperGenerator( opnd_class_instance, C ); + mach->_opnds[1] = s->MachOperGenerator(opnd_class_instance); ReduceOper( s, newrule, mem, mach ); } else { // Chain from the result of an instruction assert( newrule >= _LAST_MACH_OPER, "Do NOT chain from internal operand"); - mach->_opnds[1] = s->MachOperGenerator( _reduceOp[catch_op], C ); + mach->_opnds[1] = s->MachOperGenerator(_reduceOp[catch_op]); Node *mem1 = (Node*)1; debug_only(Node *save_mem_node = _mem_node;) mach->add_req( ReduceInst(s, newrule, mem1) ); @@ -1807,7 +1807,7 @@ uint Matcher::ReduceInst_Interior( State *s, int rule, Node *&mem, MachNode *mac if( newrule < NUM_OPERANDS ) { // Operand/operandClass or internalOp/instruction? // Operand/operandClass // Insert operand into array of operands for this instruction - mach->_opnds[num_opnds++] = newstate->MachOperGenerator( opnd_class_instance, C ); + mach->_opnds[num_opnds++] = newstate->MachOperGenerator(opnd_class_instance); ReduceOper( newstate, newrule, mem, mach ); } else { // Child is internal operand or new instruction @@ -1818,7 +1818,7 @@ uint Matcher::ReduceInst_Interior( State *s, int rule, Node *&mem, MachNode *mac } else { // instruction --> call build operand( ) to catch result // --> ReduceInst( newrule ) - mach->_opnds[num_opnds++] = s->MachOperGenerator( _reduceOp[catch_op], C ); + mach->_opnds[num_opnds++] = s->MachOperGenerator(_reduceOp[catch_op]); Node *mem1 = (Node*)1; debug_only(Node *save_mem_node = _mem_node;) mach->add_req( ReduceInst( newstate, newrule, mem1 ) ); diff --git a/hotspot/src/share/vm/opto/mathexactnode.cpp b/hotspot/src/share/vm/opto/mathexactnode.cpp index 00466ad3d50..a96656854f5 100644 --- a/hotspot/src/share/vm/opto/mathexactnode.cpp +++ b/hotspot/src/share/vm/opto/mathexactnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -191,7 +191,7 @@ struct IdealHelper { NativeType val1 = TypeClass::as_self(type1)->get_con(); NativeType val2 = TypeClass::as_self(type2)->get_con(); if (node->will_overflow(val1, val2) == false) { - Node* con_result = ConINode::make(phase->C, 0); + Node* con_result = ConINode::make(0); return con_result; } return NULL; diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp index 1c4d2bd773e..694a1eccda6 100644 --- a/hotspot/src/share/vm/opto/memnode.cpp +++ b/hotspot/src/share/vm/opto/memnode.cpp @@ -933,12 +933,12 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP return (LoadNode*)NULL; } -LoadLNode* LoadLNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { +LoadLNode* LoadLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { bool require_atomic = true; return new LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, require_atomic); } -LoadDNode* LoadDNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { +LoadDNode* LoadDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { bool require_atomic = true; return new LoadDNode(ctl, mem, adr, adr_type, rt, mo, require_atomic); } @@ -1471,6 +1471,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* ctrl = in(MemNode::Control); Node* address = in(MemNode::Address); + bool progress = false; // Skip up past a SafePoint control. Cannot do this for Stores because // pointer stores & cardmarks must stay on the same side of a SafePoint. @@ -1478,6 +1479,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { phase->C->get_alias_index(phase->type(address)->is_ptr()) != Compile::AliasIdxRaw ) { ctrl = ctrl->in(0); set_req(MemNode::Control,ctrl); + progress = true; } intptr_t ignore = 0; @@ -1490,6 +1492,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { && all_controls_dominate(base, phase->C->start())) { // A method-invariant, non-null address (constant or 'this' argument). set_req(MemNode::Control, NULL); + progress = true; } } @@ -1550,7 +1553,7 @@ Node *LoadNode::Ideal(PhaseGVN *phase, bool can_reshape) { } } - return NULL; // No further progress + return progress ? this : NULL; } // Helper to recognize certain Klass fields which are invariant across @@ -2014,7 +2017,6 @@ const Type* LoadSNode::Value(PhaseTransform *phase) const { //----------------------------LoadKlassNode::make------------------------------ // Polymorphic factory method: Node *LoadKlassNode::make( PhaseGVN& gvn, Node *mem, Node *adr, const TypePtr* at, const TypeKlassPtr *tk ) { - Compile* C = gvn.C; Node *ctl = NULL; // sanity check the alias category against the created node type const TypePtr *adr_type = adr->bottom_type()->isa_ptr(); @@ -2379,12 +2381,12 @@ StoreNode* StoreNode::make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const return (StoreNode*)NULL; } -StoreLNode* StoreLNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo) { +StoreLNode* StoreLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo) { bool require_atomic = true; return new StoreLNode(ctl, mem, adr, adr_type, val, mo, require_atomic); } -StoreDNode* StoreDNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo) { +StoreDNode* StoreDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo) { bool require_atomic = true; return new StoreDNode(ctl, mem, adr, adr_type, val, mo, require_atomic); } @@ -2460,7 +2462,7 @@ Node *StoreNode::Ideal(PhaseGVN *phase, bool can_reshape) { // and I need to disappear. if (moved != NULL) { // %%% hack to ensure that Ideal returns a new node: - mem = MergeMemNode::make(phase->C, mem); + mem = MergeMemNode::make(mem); return mem; // fold me away } } @@ -2820,7 +2822,6 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, intptr_t start_offset, Node* end_offset, PhaseGVN* phase) { - Compile* C = phase->C; intptr_t offset = start_offset; int unit = BytesPerLong; @@ -2847,7 +2848,6 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, return mem; } - Compile* C = phase->C; int unit = BytesPerLong; Node* zbase = start_offset; Node* zend = end_offset; @@ -2875,7 +2875,6 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, return mem; } - Compile* C = phase->C; assert((end_offset % BytesPerInt) == 0, "odd end offset"); intptr_t done_offset = end_offset; if ((done_offset % BytesPerLong) != 0) { @@ -2944,6 +2943,7 @@ Node *MemBarNode::Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; } + bool progress = false; // Eliminate volatile MemBars for scalar replaced objects. if (can_reshape && req() == (Precedent+1)) { bool eliminate = false; @@ -2966,6 +2966,7 @@ Node *MemBarNode::Ideal(PhaseGVN *phase, bool can_reshape) { phase->is_IterGVN()->_worklist.push(my_mem); // remove dead node later my_mem = NULL; } + progress = true; } if (my_mem != NULL && my_mem->is_Mem()) { const TypeOopPtr* t_oop = my_mem->in(MemNode::Address)->bottom_type()->isa_oopptr(); @@ -2995,7 +2996,7 @@ Node *MemBarNode::Ideal(PhaseGVN *phase, bool can_reshape) { return new ConINode(TypeInt::ZERO); } } - return NULL; + return progress ? this : NULL; } //------------------------------Value------------------------------------------ @@ -3497,6 +3498,7 @@ Node* InitializeNode::capture_store(StoreNode* st, intptr_t start, // if it redundantly stored the same value (or zero to fresh memory). // In any case, wire it in: + phase->igvn_rehash_node_delayed(this); set_req(i, new_st); // The caller may now kill the old guy. @@ -4126,7 +4128,7 @@ MergeMemNode::MergeMemNode(Node *new_base) : Node(1+Compile::AliasIdxRaw) { // Make a new, untransformed MergeMem with the same base as 'mem'. // If mem is itself a MergeMem, populate the result with the same edges. -MergeMemNode* MergeMemNode::make(Compile* C, Node* mem) { +MergeMemNode* MergeMemNode::make(Node* mem) { return new MergeMemNode(mem); } diff --git a/hotspot/src/share/vm/opto/memnode.hpp b/hotspot/src/share/vm/opto/memnode.hpp index 000ccdcbbbc..4a7064ad6d6 100644 --- a/hotspot/src/share/vm/opto/memnode.hpp +++ b/hotspot/src/share/vm/opto/memnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -333,7 +333,7 @@ public: virtual int store_Opcode() const { return Op_StoreL; } virtual BasicType memory_type() const { return T_LONG; } bool require_atomic_access() const { return _require_atomic_access; } - static LoadLNode* make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, + static LoadLNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { @@ -384,7 +384,7 @@ public: virtual int store_Opcode() const { return Op_StoreD; } virtual BasicType memory_type() const { return T_DOUBLE; } bool require_atomic_access() const { return _require_atomic_access; } - static LoadDNode* make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, + static LoadDNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { @@ -593,7 +593,7 @@ public: virtual int Opcode() const; virtual BasicType memory_type() const { return T_LONG; } bool require_atomic_access() const { return _require_atomic_access; } - static StoreLNode* make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo); + static StoreLNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { StoreNode::dump_spec(st); @@ -629,7 +629,7 @@ public: virtual int Opcode() const; virtual BasicType memory_type() const { return T_DOUBLE; } bool require_atomic_access() const { return _require_atomic_access; } - static StoreDNode* make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo); + static StoreDNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { StoreNode::dump_spec(st); @@ -1138,7 +1138,7 @@ public: // If the input is a whole memory state, clone it with all its slices intact. // Otherwise, make a new memory state with just that base memory input. // In either case, the result is a newly created MergeMem. - static MergeMemNode* make(Compile* C, Node* base_memory); + static MergeMemNode* make(Node* base_memory); virtual int Opcode() const; virtual Node *Identity( PhaseTransform *phase ); diff --git a/hotspot/src/share/vm/opto/movenode.cpp b/hotspot/src/share/vm/opto/movenode.cpp index b7e32deb2e4..234cdebf031 100644 --- a/hotspot/src/share/vm/opto/movenode.cpp +++ b/hotspot/src/share/vm/opto/movenode.cpp @@ -88,7 +88,7 @@ Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) { if( in(Condition)->is_Bool() ) { BoolNode* b = in(Condition)->as_Bool(); BoolNode* b2 = b->negate(phase); - return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); + return make(in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type); } } return NULL; @@ -158,7 +158,7 @@ const Type *CMoveNode::Value( PhaseTransform *phase ) const { //------------------------------make------------------------------------------- // Make a correctly-flavored CMove. Since _type is directly determined // from the inputs we do not need to specify it here. -CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) { +CMoveNode *CMoveNode::make(Node *c, Node *bol, Node *left, Node *right, const Type *t) { switch( t->basic_type() ) { case T_INT: return new CMoveINode( bol, left, right, t->is_int() ); case T_FLOAT: return new CMoveFNode( bol, left, right, t ); @@ -196,7 +196,7 @@ Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( in(Condition)->is_Bool() ) { BoolNode* b = in(Condition)->as_Bool(); BoolNode* b2 = b->negate(phase); - return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); + return make(in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type); } } diff --git a/hotspot/src/share/vm/opto/movenode.hpp b/hotspot/src/share/vm/opto/movenode.hpp index 8aac944ed92..bb99f7ba083 100644 --- a/hotspot/src/share/vm/opto/movenode.hpp +++ b/hotspot/src/share/vm/opto/movenode.hpp @@ -47,7 +47,7 @@ class CMoveNode : public TypeNode { virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); virtual const Type *Value( PhaseTransform *phase ) const; virtual Node *Identity( PhaseTransform *phase ); - static CMoveNode *make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ); + static CMoveNode *make(Node *c, Node *bol, Node *left, Node *right, const Type *t); // Helper function to spot cmove graph shapes static Node *is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ); }; diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp index f48e87c0c33..dd602600b45 100644 --- a/hotspot/src/share/vm/opto/node.cpp +++ b/hotspot/src/share/vm/opto/node.cpp @@ -507,7 +507,7 @@ Node *Node::clone() const { (const void*)(&mthis->_opnds), 1)); mach->_opnds = to; for ( uint i = 0; i < nopnds; ++i ) { - to[i] = from[i]->clone(C); + to[i] = from[i]->clone(); } } // cloning CallNode may need to clone JVMState @@ -620,6 +620,7 @@ void Node::destruct() { *(address*)this = badAddress; // smash the C++ vtbl, probably _in = _out = (Node**) badAddress; _max = _cnt = _outmax = _outcnt = 0; + compile->remove_modified_node(this); #endif } @@ -765,6 +766,7 @@ void Node::del_req( uint idx ) { if (n != NULL) n->del_out((Node *)this); _in[idx] = in(--_cnt); // Compact the array _in[_cnt] = NULL; // NULL out emptied slot + Compile::current()->record_modified_node(this); } //------------------------------del_req_ordered-------------------------------- @@ -780,6 +782,7 @@ void Node::del_req_ordered( uint idx ) { Copy::conjoint_words_to_lower((HeapWord*)&_in[idx+1], (HeapWord*)&_in[idx], ((_cnt-idx-1)*sizeof(Node*))); } _in[--_cnt] = NULL; // NULL out emptied slot + Compile::current()->record_modified_node(this); } //------------------------------ins_req---------------------------------------- @@ -1297,6 +1300,7 @@ static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) { // Done with outputs. igvn->hash_delete(dead); igvn->_worklist.remove(dead); + igvn->C->remove_modified_node(dead); igvn->set_type(dead, Type::TOP); if (dead->is_macro()) { igvn->C->remove_macro_node(dead); diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp index 5bb9c6873d7..b483e36c8bf 100644 --- a/hotspot/src/share/vm/opto/node.hpp +++ b/hotspot/src/share/vm/opto/node.hpp @@ -398,6 +398,7 @@ protected: if (*p != NULL) (*p)->del_out((Node *)this); (*p) = n; if (n != NULL) n->add_out((Node *)this); + Compile::current()->record_modified_node(this); } // Light version of set_req() to init inputs after node creation. void init_req( uint i, Node *n ) { @@ -409,6 +410,7 @@ protected: assert( _in[i] == NULL, "sanity"); _in[i] = n; if (n != NULL) n->add_out((Node *)this); + Compile::current()->record_modified_node(this); } // Find first occurrence of n among my edges: int find_edge(Node* n); diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index 15bf30b393a..16ec69c219d 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -526,7 +526,7 @@ void Compile::shorten_branches(uint* blk_starts, int& code_size, int& reloc_size if (_matcher->is_short_branch_offset(mach->rule(), br_size, offset)) { // We've got a winner. Replace this branch. - MachNode* replacement = mach->as_MachBranch()->short_branch_version(this); + MachNode* replacement = mach->as_MachBranch()->short_branch_version(); // Update the jmp_size. int new_size = replacement->size(_regalloc); @@ -785,9 +785,10 @@ void Compile::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local, // grow downwards in all implementations. // (If, on some machine, the interpreter's Java locals or stack // were to grow upwards, the embedded doubles would be word-swapped.) - jint *dp = (jint*)&d; - array->append(new ConstantIntValue(dp[1])); - array->append(new ConstantIntValue(dp[0])); + jlong_accessor acc; + acc.long_value = jlong_cast(d); + array->append(new ConstantIntValue(acc.words[1])); + array->append(new ConstantIntValue(acc.words[0])); #endif break; } @@ -804,9 +805,10 @@ void Compile::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local, // grow downwards in all implementations. // (If, on some machine, the interpreter's Java locals or stack // were to grow upwards, the embedded doubles would be word-swapped.) - jint *dp = (jint*)&d; - array->append(new ConstantIntValue(dp[1])); - array->append(new ConstantIntValue(dp[0])); + jlong_accessor acc; + acc.long_value = d; + array->append(new ConstantIntValue(acc.words[1])); + array->append(new ConstantIntValue(acc.words[0])); #endif break; } @@ -1174,7 +1176,7 @@ CodeBuffer* Compile::init_buffer(uint* blk_starts) { // fill in the nop array for bundling computations MachNode *_nop_list[Bundle::_nop_count]; - Bundle::initialize_nops(_nop_list, this); + Bundle::initialize_nops(_nop_list); return cb; } @@ -1408,7 +1410,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { if (_matcher->is_short_branch_offset(mach->rule(), br_size, offset)) { // We've got a winner. Replace this branch. - MachNode* replacement = mach->as_MachBranch()->short_branch_version(this); + MachNode* replacement = mach->as_MachBranch()->short_branch_version(); // Update the jmp_size. int new_size = replacement->size(_regalloc); diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp index a758f72acdc..118cb62db5c 100644 --- a/hotspot/src/share/vm/opto/parse1.cpp +++ b/hotspot/src/share/vm/opto/parse1.cpp @@ -575,12 +575,13 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses) decrement_age(); } } - if (depth() == 1) { + + if (depth() == 1 && !failing()) { // Add check to deoptimize the nmethod if RTM state was changed rtm_deopt(); } - // Check for bailouts during method entry. + // Check for bailouts during method entry or RTM state check setup. if (failing()) { if (log) log->done("parse"); C->set_default_node_notes(caller_nn); @@ -1756,7 +1757,7 @@ void Parse::merge_memory_edges(MergeMemNode* n, int pnum, bool nophi) { if (remerge == NULL) { assert(base != NULL, ""); assert(base->in(0) != NULL, "should not be xformed away"); - remerge = MergeMemNode::make(C, base->in(pnum)); + remerge = MergeMemNode::make(base->in(pnum)); gvn().set_type(remerge, Type::MEMORY); base->set_req(pnum, remerge); } @@ -2199,7 +2200,7 @@ void Parse::add_safepoint() { // down below a SafePoint. // Clone the current memory state - Node* mem = MergeMemNode::make(C, map()->memory()); + Node* mem = MergeMemNode::make(map()->memory()); mem = _gvn.transform(mem); @@ -2213,7 +2214,7 @@ void Parse::add_safepoint() { // Create a node for the polling address if( add_poll_param ) { - Node *polladr = ConPNode::make(C, (address)os::get_polling_page()); + Node *polladr = ConPNode::make((address)os::get_polling_page()); sfpnt->init_req(TypeFunc::Parms+0, _gvn.transform(polladr)); } diff --git a/hotspot/src/share/vm/opto/parseHelper.cpp b/hotspot/src/share/vm/opto/parseHelper.cpp index 45d627d2500..a71fb8f7752 100644 --- a/hotspot/src/share/vm/opto/parseHelper.cpp +++ b/hotspot/src/share/vm/opto/parseHelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) { // Get method const TypePtr* method_type = TypeMetadataPtr::make(method); - Node *method_node = _gvn.transform( ConNode::make(C, method_type) ); + Node *method_node = _gvn.transform(ConNode::make(method_type)); kill_dead_locals(); diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index b4470dcef53..3e063ae987e 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -615,7 +615,7 @@ ConNode* PhaseTransform::makecon(const Type *t) { // Make an idealized constant - one of ConINode, ConPNode, etc. ConNode* PhaseValues::uncached_makecon(const Type *t) { assert(t->singleton(), "must be a constant"); - ConNode* x = ConNode::make(C, t); + ConNode* x = ConNode::make(t); ConNode* k = (ConNode*)hash_find_insert(x); // Value numbering if (k == NULL) { set_type(x, t); // Missed, provide type mapping @@ -933,9 +933,32 @@ void PhaseIterGVN::init_verifyPhaseIterGVN() { for (int i = 0; i < _verify_window_size; i++) { _verify_window[i] = NULL; } +#ifdef ASSERT + // Verify that all modified nodes are on _worklist + Unique_Node_List* modified_list = C->modified_nodes(); + while (modified_list != NULL && modified_list->size()) { + Node* n = modified_list->pop(); + if (n->outcnt() != 0 && !n->is_Con() && !_worklist.member(n)) { + n->dump(); + assert(false, "modified node is not on IGVN._worklist"); + } + } +#endif } void PhaseIterGVN::verify_PhaseIterGVN() { +#ifdef ASSERT + // Verify nodes with changed inputs. + Unique_Node_List* modified_list = C->modified_nodes(); + while (modified_list != NULL && modified_list->size()) { + Node* n = modified_list->pop(); + if (n->outcnt() != 0 && !n->is_Con()) { // skip dead and Con nodes + n->dump(); + assert(false, "modified node was not processed by IGVN.transform_old()"); + } + } +#endif + C->verify_graph_edges(); if( VerifyOpto && allow_progress() ) { // Must turn off allow_progress to enable assert and break recursion @@ -964,6 +987,14 @@ void PhaseIterGVN::verify_PhaseIterGVN() { (int) _verify_counter, (int) _verify_full_passes); } } + +#ifdef ASSERT + while (modified_list->size()) { + Node* n = modified_list->pop(); + n->dump(); + assert(false, "VerifyIterativeGVN: new modified node was added"); + } +#endif } #endif /* PRODUCT */ @@ -1066,6 +1097,7 @@ Node *PhaseIterGVN::transform_old(Node* n) { Node* k = n; DEBUG_ONLY(dead_loop_check(k);) DEBUG_ONLY(bool is_new = (k->outcnt() == 0);) + C->remove_modified_node(k); Node* i = k->Ideal(this, /*can_reshape=*/true); assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes"); #ifndef PRODUCT @@ -1107,6 +1139,7 @@ Node *PhaseIterGVN::transform_old(Node* n) { DEBUG_ONLY(dead_loop_check(k);) // Try idealizing again DEBUG_ONLY(is_new = (k->outcnt() == 0);) + C->remove_modified_node(k); i = k->Ideal(this, /*can_reshape=*/true); assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes"); #ifndef PRODUCT @@ -1259,6 +1292,7 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { _stack.pop(); // Remove dead node from iterative worklist _worklist.remove(dead); + C->remove_modified_node(dead); // Constant node that has no out-edges and has only one in-edge from // root is usually dead. However, sometimes reshaping walk makes // it reachable by adding use edges. So, we will NOT count Con nodes @@ -1288,7 +1322,7 @@ void PhaseIterGVN::subsume_node( Node *old, Node *nn ) { for (DUIterator_Last imin, i = old->last_outs(imin); i >= imin; ) { Node* use = old->last_out(i); // for each use... // use might need re-hashing (but it won't if it's a new node) - bool is_in_table = _table.hash_delete( use ); + rehash_node_delayed(use); // Update use-def info as well // We remove all occurrences of old within use->in, // so as to avoid rehashing any node more than once. @@ -1300,11 +1334,6 @@ void PhaseIterGVN::subsume_node( Node *old, Node *nn ) { ++num_edges; } } - // Insert into GVN hash table if unique - // If a duplicate, 'use' will be cleaned up when pulled off worklist - if( is_in_table ) { - hash_find_insert(use); - } i -= num_edges; // we deleted 1 or more copies of this edge } @@ -1599,7 +1628,7 @@ Node *PhaseCCP::transform_once( Node *n ) { if( t == Type::TOP ) { // cache my top node on the Compile instance if( C->cached_top_node() == NULL || C->cached_top_node()->in(0) == NULL ) { - C->set_cached_top_node( ConNode::make(C, Type::TOP) ); + C->set_cached_top_node(ConNode::make(Type::TOP)); set_type(C->top(), Type::TOP); } nn = C->top(); @@ -1725,7 +1754,7 @@ void PhasePeephole::do_transform() { MachNode *m = n->as_Mach(); int deleted_count = 0; // check for peephole opportunities - MachNode *m2 = m->peephole( block, instruction_index, _regalloc, deleted_count, C ); + MachNode *m2 = m->peephole(block, instruction_index, _regalloc, deleted_count); if( m2 != NULL ) { #ifndef PRODUCT if( PrintOptoPeephole ) { diff --git a/hotspot/src/share/vm/opto/phaseX.hpp b/hotspot/src/share/vm/opto/phaseX.hpp index ccb24819e7c..53b7a03d458 100644 --- a/hotspot/src/share/vm/opto/phaseX.hpp +++ b/hotspot/src/share/vm/opto/phaseX.hpp @@ -311,6 +311,9 @@ public: const Type* limit_type) const { ShouldNotCallThis(); return NULL; } + // Delayed node rehash if this is an IGVN phase + virtual void igvn_rehash_node_delayed(Node* n) {} + #ifndef PRODUCT void dump_old2new_map() const; void dump_new( uint new_lidx ) const; @@ -488,6 +491,10 @@ public: _worklist.push(n); } + void igvn_rehash_node_delayed(Node* n) { + rehash_node_delayed(n); + } + // Replace ith edge of "n" with "in" void replace_input_of(Node* n, int i, Node* in) { rehash_node_delayed(n); diff --git a/hotspot/src/share/vm/opto/rootnode.cpp b/hotspot/src/share/vm/opto/rootnode.cpp index 56775ed7e01..4cf51528df5 100644 --- a/hotspot/src/share/vm/opto/rootnode.cpp +++ b/hotspot/src/share/vm/opto/rootnode.cpp @@ -35,10 +35,12 @@ //------------------------------Ideal------------------------------------------ // Remove dead inputs Node *RootNode::Ideal(PhaseGVN *phase, bool can_reshape) { + bool modified = false; for( uint i = 1; i < req(); i++ ) { // For all inputs // Check for and remove dead inputs if( phase->type(in(i)) == Type::TOP ) { del_req(i--); // Delete TOP inputs + modified = true; } } @@ -56,7 +58,7 @@ Node *RootNode::Ideal(PhaseGVN *phase, bool can_reshape) { // If we want to get the rest of the win later, we should pattern match // simple recursive call trees to closed-form solutions. - return NULL; // No further opportunities exposed + return modified ? this : NULL; } //============================================================================= diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index 2a2fb131dfd..0bf5c9da587 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -1381,11 +1381,11 @@ NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCount } NamedCounter* c; if (tag == NamedCounter::BiasedLockingCounter) { - c = new BiasedLockingNamedCounter(strdup(st.as_string())); + c = new BiasedLockingNamedCounter(st.as_string()); } else if (tag == NamedCounter::RTMLockingCounter) { - c = new RTMLockingNamedCounter(strdup(st.as_string())); + c = new RTMLockingNamedCounter(st.as_string()); } else { - c = new NamedCounter(strdup(st.as_string()), tag); + c = new NamedCounter(st.as_string(), tag); } // atomically add the new counter to the head of the list. We only diff --git a/hotspot/src/share/vm/opto/runtime.hpp b/hotspot/src/share/vm/opto/runtime.hpp index b5e8bc34d98..612afc58807 100644 --- a/hotspot/src/share/vm/opto/runtime.hpp +++ b/hotspot/src/share/vm/opto/runtime.hpp @@ -75,11 +75,17 @@ private: public: NamedCounter(const char *n, CounterTag tag = NoTag): - _name(n), + _name(n == NULL ? NULL : os::strdup(n)), _count(0), _next(NULL), _tag(tag) {} + ~NamedCounter() { + if (_name != NULL) { + os::free((void*)_name); + } + } + const char * name() const { return _name; } int count() const { return _count; } address addr() { return (address)&_count; } diff --git a/hotspot/src/share/vm/opto/stringopts.cpp b/hotspot/src/share/vm/opto/stringopts.cpp index fcca4684833..1d9bae5a6ac 100644 --- a/hotspot/src/share/vm/opto/stringopts.cpp +++ b/hotspot/src/share/vm/opto/stringopts.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1438,7 +1438,7 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) { } // Make sure the memory state is a MergeMem for parsing. if (!map->in(TypeFunc::Memory)->is_MergeMem()) { - map->set_req(TypeFunc::Memory, MergeMemNode::make(C, map->in(TypeFunc::Memory))); + map->set_req(TypeFunc::Memory, MergeMemNode::make(map->in(TypeFunc::Memory))); } jvms->set_map(map); diff --git a/hotspot/src/share/vm/opto/subnode.cpp b/hotspot/src/share/vm/opto/subnode.cpp index e5f24b6ca6c..c6593549398 100644 --- a/hotspot/src/share/vm/opto/subnode.cpp +++ b/hotspot/src/share/vm/opto/subnode.cpp @@ -1168,7 +1168,6 @@ uint BoolNode::cmp( const Node &n ) const { Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) { if (test_value->is_Con()) return test_value; if (test_value->is_Bool()) return test_value; - Compile* C = phase->C; if (test_value->is_CMove() && test_value->in(CMoveNode::Condition)->is_Bool()) { BoolNode* bol = test_value->in(CMoveNode::Condition)->as_Bool(); @@ -1191,7 +1190,7 @@ Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) { //--------------------------------as_int_value--------------------------------- Node* BoolNode::as_int_value(PhaseGVN* phase) { // Inverse to make_predicate. The CMove probably boils down to a Conv2B. - Node* cmov = CMoveNode::make(phase->C, NULL, this, + Node* cmov = CMoveNode::make(NULL, this, phase->intcon(0), phase->intcon(1), TypeInt::BOOL); return phase->transform(cmov); @@ -1199,7 +1198,6 @@ Node* BoolNode::as_int_value(PhaseGVN* phase) { //----------------------------------negate------------------------------------- BoolNode* BoolNode::negate(PhaseGVN* phase) { - Compile* C = phase->C; return new BoolNode(in(1), _test.negate()); } diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 72fabf9cc22..e20a187c6da 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1378,9 +1378,23 @@ void SuperWord::output() { if (n->is_Load()) { Node* ctl = n->in(MemNode::Control); Node* mem = first->in(MemNode::Memory); + SWPointer p1(n->as_Mem(), this); + // Identify the memory dependency for the new loadVector node by + // walking up through memory chain. + // This is done to give flexibility to the new loadVector node so that + // it can move above independent storeVector nodes. + while (mem->is_StoreVector()) { + SWPointer p2(mem->as_Mem(), this); + int cmp = p1.cmp(p2); + if (SWPointer::not_equal(cmp) || !SWPointer::comparable(cmp)) { + mem = mem->in(MemNode::Memory); + } else { + break; // dependent memory + } + } Node* adr = low_adr->in(MemNode::Address); const TypePtr* atyp = n->adr_type(); - vn = LoadVectorNode::make(C, opc, ctl, mem, adr, atyp, vlen, velt_basic_type(n)); + vn = LoadVectorNode::make(opc, ctl, mem, adr, atyp, vlen, velt_basic_type(n)); vlen_in_bytes = vn->as_LoadVector()->memory_size(); } else if (n->is_Store()) { // Promote value to be stored to vector @@ -1389,7 +1403,7 @@ void SuperWord::output() { Node* mem = first->in(MemNode::Memory); Node* adr = low_adr->in(MemNode::Address); const TypePtr* atyp = n->adr_type(); - vn = StoreVectorNode::make(C, opc, ctl, mem, adr, atyp, val, vlen); + vn = StoreVectorNode::make(opc, ctl, mem, adr, atyp, val, vlen); vlen_in_bytes = vn->as_StoreVector()->memory_size(); } else if (n->req() == 3) { // Promote operands to vector @@ -1401,7 +1415,7 @@ void SuperWord::output() { in1 = in2; in2 = tmp; } - vn = VectorNode::make(C, opc, in1, in2, vlen, velt_basic_type(n)); + vn = VectorNode::make(opc, in1, in2, vlen, velt_basic_type(n)); vlen_in_bytes = vn->as_Vector()->length_in_bytes(); } else { ShouldNotReachHere(); @@ -1450,11 +1464,11 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { if (t != NULL && t->is_con()) { juint shift = t->get_con(); if (shift > mask) { // Unsigned cmp - cnt = ConNode::make(C, TypeInt::make(shift & mask)); + cnt = ConNode::make(TypeInt::make(shift & mask)); } } else { if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { - cnt = ConNode::make(C, TypeInt::make(mask)); + cnt = ConNode::make(TypeInt::make(mask)); _igvn.register_new_node_with_optimizer(cnt); cnt = new AndINode(opd, cnt); _igvn.register_new_node_with_optimizer(cnt); @@ -1462,7 +1476,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { } assert(opd->bottom_type()->isa_int(), "int type only"); // Move non constant shift count into vector register. - cnt = VectorNode::shift_count(C, p0, cnt, vlen, velt_basic_type(p0)); + cnt = VectorNode::shift_count(p0, cnt, vlen, velt_basic_type(p0)); } if (cnt != opd) { _igvn.register_new_node_with_optimizer(cnt); @@ -1475,7 +1489,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { // p0's vector. Use p0's type because size of operand's container in // vector should match p0's size regardless operand's size. const Type* p0_t = velt_type(p0); - VectorNode* vn = VectorNode::scalar2vector(_phase->C, opd, vlen, p0_t); + VectorNode* vn = VectorNode::scalar2vector(opd, vlen, p0_t); _igvn.register_new_node_with_optimizer(vn); _phase->set_ctrl(vn, _phase->get_ctrl(opd)); @@ -1490,7 +1504,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { // Insert pack operation BasicType bt = velt_basic_type(p0); - PackNode* pk = PackNode::make(_phase->C, opd, vlen, bt); + PackNode* pk = PackNode::make(opd, vlen, bt); DEBUG_ONLY( const BasicType opd_bt = opd->bottom_type()->basic_type(); ) for (uint i = 1; i < vlen; i++) { @@ -1546,7 +1560,7 @@ void SuperWord::insert_extracts(Node_List* p) { _igvn.hash_delete(def); int def_pos = alignment(def) / data_size(def); - Node* ex = ExtractNode::make(_phase->C, def, def_pos, velt_basic_type(def)); + Node* ex = ExtractNode::make(def, def_pos, velt_basic_type(def)); _igvn.register_new_node_with_optimizer(ex); _phase->set_ctrl(ex, _phase->get_ctrl(def)); _igvn.replace_input_of(use, idx, ex); diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp index 39662643ac9..8a5eddf56b9 100644 --- a/hotspot/src/share/vm/opto/type.cpp +++ b/hotspot/src/share/vm/opto/type.cpp @@ -265,7 +265,7 @@ void Type::Initialize_shared(Compile* current) { // locking. Arena* save = current->type_arena(); - Arena* shared_type_arena = new (mtCompiler)Arena(); + Arena* shared_type_arena = new (mtCompiler)Arena(mtCompiler); current->set_type_arena(shared_type_arena); _shared_type_dict = @@ -5087,11 +5087,11 @@ int TypeFunc::hash(void) const { // Dump Function Type #ifndef PRODUCT void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const { - if( _range->_cnt <= Parms ) + if( _range->cnt() <= Parms ) st->print("void"); else { uint i; - for (i = Parms; i < _range->_cnt-1; i++) { + for (i = Parms; i < _range->cnt()-1; i++) { _range->field_at(i)->dump2(d,depth,st); st->print("/"); } @@ -5104,9 +5104,9 @@ void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const { return; } d.Insert((void*)this,(void*)this); // Stop recursion - if (Parms < _domain->_cnt) + if (Parms < _domain->cnt()) _domain->field_at(Parms)->dump2(d,depth-1,st); - for (uint i = Parms+1; i < _domain->_cnt; i++) { + for (uint i = Parms+1; i < _domain->cnt(); i++) { st->print(", "); _domain->field_at(i)->dump2(d,depth-1,st); } diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp index e4340df4f9a..e0aeba1e91e 100644 --- a/hotspot/src/share/vm/opto/type.hpp +++ b/hotspot/src/share/vm/opto/type.hpp @@ -609,16 +609,16 @@ public: // signature types. class TypeTuple : public Type { TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { } + + const uint _cnt; // Count of fields + const Type ** const _fields; // Array of field types + public: virtual bool eq( const Type *t ) const; virtual int hash() const; // Type specific hashing virtual bool singleton(void) const; // TRUE if type is a singleton virtual bool empty(void) const; // TRUE if type is vacuous -public: - const uint _cnt; // Count of fields - const Type ** const _fields; // Array of field types - // Accessors: uint cnt() const { return _cnt; } const Type* field_at(uint i) const { @@ -1447,6 +1447,10 @@ class TypeFunc : public Type { virtual int hash() const; // Type specific hashing virtual bool singleton(void) const; // TRUE if type is a singleton virtual bool empty(void) const; // TRUE if type is vacuous + + const TypeTuple* const _domain; // Domain of inputs + const TypeTuple* const _range; // Range of results + public: // Constants are shared among ADLC and VM enum { Control = AdlcVMDeps::Control, @@ -1457,8 +1461,6 @@ public: Parms = AdlcVMDeps::Parms }; - const TypeTuple* const _domain; // Domain of inputs - const TypeTuple* const _range; // Range of results // Accessors: const TypeTuple* domain() const { return _domain; } diff --git a/hotspot/src/share/vm/opto/vectornode.cpp b/hotspot/src/share/vm/opto/vectornode.cpp index 21b51e5b524..b4a07799efb 100644 --- a/hotspot/src/share/vm/opto/vectornode.cpp +++ b/hotspot/src/share/vm/opto/vectornode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -245,7 +245,7 @@ void VectorNode::vector_operands(Node* n, uint* start, uint* end) { } // Return the vector version of a scalar operation node. -VectorNode* VectorNode::make(Compile* C, int opc, Node* n1, Node* n2, uint vlen, BasicType bt) { +VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt) { const TypeVect* vt = TypeVect::make(bt, vlen); int vopc = VectorNode::opcode(opc, bt); // This method should not be called for unimplemented vectors. @@ -299,7 +299,7 @@ VectorNode* VectorNode::make(Compile* C, int opc, Node* n1, Node* n2, uint vlen, } // Scalar promotion -VectorNode* VectorNode::scalar2vector(Compile* C, Node* s, uint vlen, const Type* opd_t) { +VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t) { BasicType bt = opd_t->array_element_basic_type(); const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen) : TypeVect::make(bt, vlen); @@ -323,7 +323,7 @@ VectorNode* VectorNode::scalar2vector(Compile* C, Node* s, uint vlen, const Type return NULL; } -VectorNode* VectorNode::shift_count(Compile* C, Node* shift, Node* cnt, uint vlen, BasicType bt) { +VectorNode* VectorNode::shift_count(Node* shift, Node* cnt, uint vlen, BasicType bt) { assert(VectorNode::is_shift(shift) && !cnt->is_Con(), "only variable shift count"); // Match shift count type with shift vector type. const TypeVect* vt = TypeVect::make(bt, vlen); @@ -342,7 +342,7 @@ VectorNode* VectorNode::shift_count(Compile* C, Node* shift, Node* cnt, uint vle } // Return initial Pack node. Additional operands added with add_opd() calls. -PackNode* PackNode::make(Compile* C, Node* s, uint vlen, BasicType bt) { +PackNode* PackNode::make(Node* s, uint vlen, BasicType bt) { const TypeVect* vt = TypeVect::make(bt, vlen); switch (bt) { case T_BOOLEAN: @@ -365,18 +365,18 @@ PackNode* PackNode::make(Compile* C, Node* s, uint vlen, BasicType bt) { } // Create a binary tree form for Packs. [lo, hi) (half-open) range -PackNode* PackNode::binary_tree_pack(Compile* C, int lo, int hi) { +PackNode* PackNode::binary_tree_pack(int lo, int hi) { int ct = hi - lo; assert(is_power_of_2(ct), "power of 2"); if (ct == 2) { - PackNode* pk = PackNode::make(C, in(lo), 2, vect_type()->element_basic_type()); + PackNode* pk = PackNode::make(in(lo), 2, vect_type()->element_basic_type()); pk->add_opd(in(lo+1)); return pk; } else { int mid = lo + ct/2; - PackNode* n1 = binary_tree_pack(C, lo, mid); - PackNode* n2 = binary_tree_pack(C, mid, hi ); + PackNode* n1 = binary_tree_pack(lo, mid); + PackNode* n2 = binary_tree_pack(mid, hi ); BasicType bt = n1->vect_type()->element_basic_type(); assert(bt == n2->vect_type()->element_basic_type(), "should be the same"); @@ -402,23 +402,23 @@ PackNode* PackNode::binary_tree_pack(Compile* C, int lo, int hi) { } // Return the vector version of a scalar load node. -LoadVectorNode* LoadVectorNode::make(Compile* C, int opc, Node* ctl, Node* mem, +LoadVectorNode* LoadVectorNode::make(int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, uint vlen, BasicType bt) { const TypeVect* vt = TypeVect::make(bt, vlen); return new LoadVectorNode(ctl, mem, adr, atyp, vt); } // Return the vector version of a scalar store node. -StoreVectorNode* StoreVectorNode::make(Compile* C, int opc, Node* ctl, Node* mem, +StoreVectorNode* StoreVectorNode::make(int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, Node* val, uint vlen) { return new StoreVectorNode(ctl, mem, adr, atyp, val); } // Extract a scalar element of vector. -Node* ExtractNode::make(Compile* C, Node* v, uint position, BasicType bt) { +Node* ExtractNode::make(Node* v, uint position, BasicType bt) { assert((int)position < Matcher::max_vector_size(bt), "pos in range"); - ConINode* pos = ConINode::make(C, (int)position); + ConINode* pos = ConINode::make((int)position); switch (bt) { case T_BOOLEAN: return new ExtractUBNode(v, pos); diff --git a/hotspot/src/share/vm/opto/vectornode.hpp b/hotspot/src/share/vm/opto/vectornode.hpp index 0b95a10d8a6..759d724335d 100644 --- a/hotspot/src/share/vm/opto/vectornode.hpp +++ b/hotspot/src/share/vm/opto/vectornode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,9 +52,9 @@ class VectorNode : public TypeNode { virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(vect_type()->length_in_bytes()); } - static VectorNode* scalar2vector(Compile* C, Node* s, uint vlen, const Type* opd_t); - static VectorNode* shift_count(Compile* C, Node* shift, Node* cnt, uint vlen, BasicType bt); - static VectorNode* make(Compile* C, int opc, Node* n1, Node* n2, uint vlen, BasicType bt); + static VectorNode* scalar2vector(Node* s, uint vlen, const Type* opd_t); + static VectorNode* shift_count(Node* shift, Node* cnt, uint vlen, BasicType bt); + static VectorNode* make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt); static int opcode(int opc, BasicType bt); static bool implemented(int opc, uint vlen, BasicType bt); @@ -371,7 +371,7 @@ class LoadVectorNode : public LoadNode { virtual int store_Opcode() const { return Op_StoreVector; } - static LoadVectorNode* make(Compile* C, int opc, Node* ctl, Node* mem, + static LoadVectorNode* make(int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, uint vlen, BasicType bt); }; @@ -394,7 +394,7 @@ class StoreVectorNode : public StoreNode { virtual BasicType memory_type() const { return T_VOID; } virtual int memory_size() const { return vect_type()->length_in_bytes(); } - static StoreVectorNode* make(Compile* C, int opc, Node* ctl, Node* mem, + static StoreVectorNode* make(int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, Node* val, uint vlen); }; @@ -465,9 +465,9 @@ class PackNode : public VectorNode { } // Create a binary tree form for Packs. [lo, hi) (half-open) range - PackNode* binary_tree_pack(Compile* C, int lo, int hi); + PackNode* binary_tree_pack(int lo, int hi); - static PackNode* make(Compile* C, Node* s, uint vlen, BasicType bt); + static PackNode* make(Node* s, uint vlen, BasicType bt); }; //------------------------------PackBNode-------------------------------------- @@ -552,7 +552,7 @@ class ExtractNode : public Node { virtual int Opcode() const; uint pos() const { return in(2)->get_int(); } - static Node* make(Compile* C, Node* v, uint position, BasicType bt); + static Node* make(Node* v, uint position, BasicType bt); }; //------------------------------ExtractBNode----------------------------------- diff --git a/hotspot/src/share/vm/precompiled/precompiled.hpp b/hotspot/src/share/vm/precompiled/precompiled.hpp index be70cfffd6e..121c8aa14c6 100644 --- a/hotspot/src/share/vm/precompiled/precompiled.hpp +++ b/hotspot/src/share/vm/precompiled/precompiled.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,10 +222,17 @@ # include "runtime/vmThread.hpp" # include "runtime/vm_operations.hpp" # include "runtime/vm_version.hpp" +# include "services/allocationSite.hpp" # include "services/lowMemoryDetector.hpp" +# include "services/mallocTracker.hpp" +# include "services/memBaseline.hpp" # include "services/memoryPool.hpp" # include "services/memoryService.hpp" # include "services/memoryUsage.hpp" +# include "services/memReporter.hpp" +# include "services/memTracker.hpp" +# include "services/nmtCommon.hpp" +# include "services/virtualMemoryTracker.hpp" # include "utilities/accessFlags.hpp" # include "utilities/array.hpp" # include "utilities/bitMap.hpp" @@ -240,6 +247,7 @@ # include "utilities/hashtable.hpp" # include "utilities/histogram.hpp" # include "utilities/macros.hpp" +# include "utilities/nativeCallStack.hpp" # include "utilities/numberSeq.hpp" # include "utilities/ostream.hpp" # include "utilities/preserveException.hpp" diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 51548acdba3..a64f3c21313 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -74,6 +74,7 @@ #include "runtime/signature.hpp" #include "runtime/thread.inline.hpp" #include "runtime/vm_operations.hpp" +#include "services/memTracker.hpp" #include "services/runtimeService.hpp" #include "trace/tracing.hpp" #include "utilities/defaultStream.hpp" @@ -2697,6 +2698,7 @@ static char* get_bad_address() { if (bad_address != NULL) { os::protect_memory(bad_address, size, os::MEM_PROT_READ, /*is_committed*/false); + MemTracker::record_virtual_memory_type((void*)bad_address, mtInternal); } } return bad_address; @@ -3857,6 +3859,7 @@ void TestOldSize_test(); void TestKlass_test(); void TestBitMap_test(); void TestAsUtf8(); +void Test_linked_list(); #if INCLUDE_ALL_GCS void TestOldFreeSpaceCalculation_test(); void TestG1BiasedArray_test(); @@ -3887,6 +3890,7 @@ void execute_internal_vm_tests() { run_unit_test(TestBitMap_test()); run_unit_test(TestAsUtf8()); run_unit_test(ObjectMonitor::sanity_checks()); + run_unit_test(Test_linked_list()); #if INCLUDE_VM_STRUCTS run_unit_test(VMStructs::test()); #endif diff --git a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp index d2dab57a374..b614b5acea0 100644 --- a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp +++ b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -316,6 +316,7 @@ void JvmtiManageCapabilities::update() { avail.can_generate_frame_pop_events || avail.can_generate_method_entry_events || avail.can_generate_method_exit_events; +#ifdef ZERO bool enter_all_methods = interp_events || avail.can_generate_breakpoint_events; @@ -324,6 +325,7 @@ void JvmtiManageCapabilities::update() { UseFastEmptyMethods = false; UseFastAccessorMethods = false; } +#endif // ZERO if (avail.can_generate_breakpoint_events) { RewriteFrequentPairs = false; diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index e6805b12e5b..5cc72ff5e0c 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -52,8 +52,10 @@ #include "gc_implementation/g1/heapRegionRemSet.hpp" #endif // INCLUDE_ALL_GCS -#ifdef INCLUDE_NMT +#if INCLUDE_NMT +#include "services/mallocSiteTable.hpp" #include "services/memTracker.hpp" +#include "utilities/nativeCallStack.hpp" #endif // INCLUDE_NMT #include "compiler/compileBroker.hpp" @@ -255,14 +257,18 @@ WB_END // NMT picks it up correctly WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) jlong addr = 0; - - if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { addr = (jlong)(uintptr_t)os::malloc(size, mtTest); - } - return addr; WB_END +// Alloc memory with pseudo call stack. The test can create psudo malloc +// allocation site to stress the malloc tracking. +WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack)) + address pc = (address)(size_t)pseudo_stack; + NativeCallStack stack(&pc, 1); + return (jlong)os::malloc(size, mtTest, stack); +WB_END + // Free the memory allocated by NMTAllocTest WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem)) os::free((void*)(uintptr_t)mem, mtTest); @@ -271,10 +277,8 @@ WB_END WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) jlong addr = 0; - if (MemTracker::is_on() && !MemTracker::shutdown_in_progress()) { addr = (jlong)(uintptr_t)os::reserve_memory(size); MemTracker::record_virtual_memory_type((address)addr, mtTest); - } return addr; WB_END @@ -293,20 +297,20 @@ WB_ENTRY(void, WB_NMTReleaseMemory(JNIEnv* env, jobject o, jlong addr, jlong siz os::release_memory((char *)(uintptr_t)addr, size); WB_END -// Block until the current generation of NMT data to be merged, used to reliably test the NMT feature -WB_ENTRY(jboolean, WB_NMTWaitForDataMerge(JNIEnv* env)) - - if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { - return false; - } - - return MemTracker::wbtest_wait_for_data_merge(); -WB_END - WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env)) - return MemTracker::tracking_level() == MemTracker::NMT_detail; + return MemTracker::tracking_level() == NMT_detail; WB_END +WB_ENTRY(void, WB_NMTOverflowHashBucket(JNIEnv* env, jobject o, jlong num)) + address pc = (address)1; + for (jlong index = 0; index < num; index ++) { + NativeCallStack stack(&pc, 1); + os::malloc(0, mtTest, stack); + pc += MallocSiteTable::hash_buckets(); + } +WB_END + + #endif // INCLUDE_NMT static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { @@ -843,12 +847,13 @@ static JNINativeMethod methods[] = { #endif // INCLUDE_ALL_GCS #if INCLUDE_NMT {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, + {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack}, {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree }, {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory }, {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory }, {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory }, {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory }, - {CC"NMTWaitForDataMerge", CC"()Z", (void*)&WB_NMTWaitForDataMerge}, + {CC"NMTOverflowHashBucket", CC"(J)V", (void*)&WB_NMTOverflowHashBucket}, {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported}, #endif // INCLUDE_NMT {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 3f0bff025ec..8a906b157c7 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -300,6 +300,11 @@ static ObsoleteFlag obsolete_jvm_flags[] = { { "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) }, +#ifndef ZERO + { "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) }, +#endif // ZERO { NULL, JDK_Version(0), JDK_Version(0) } }; @@ -799,7 +804,7 @@ void Arguments::add_string(char*** bldarray, int* count, const char* arg) { } else { *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal); } - (*bldarray)[*count] = strdup(arg); + (*bldarray)[*count] = os::strdup_check_oom(arg); *count = new_count; } @@ -1070,16 +1075,6 @@ void Arguments::set_mode_flags(Mode mode) { UseCompiler = true; UseLoopCounter = true; -#ifndef ZERO - // Turn these off for mixed and comp. Leave them on for Zero. - if (FLAG_IS_DEFAULT(UseFastAccessorMethods)) { - UseFastAccessorMethods = (mode == _int); - } - if (FLAG_IS_DEFAULT(UseFastEmptyMethods)) { - UseFastEmptyMethods = (mode == _int); - } -#endif - // Default values may be platform/compiler dependent - // use the saved values ClipInlining = Arguments::_ClipInlining; @@ -1431,6 +1426,22 @@ bool verify_object_alignment() { (int)ObjectAlignmentInBytes, os::vm_page_size()); return false; } + if(SurvivorAlignmentInBytes == 0) { + SurvivorAlignmentInBytes = ObjectAlignmentInBytes; + } else { + if (!is_power_of_2(SurvivorAlignmentInBytes)) { + jio_fprintf(defaultStream::error_stream(), + "error: SurvivorAlignmentInBytes=%d must be power of 2\n", + (int)SurvivorAlignmentInBytes); + return false; + } + if (SurvivorAlignmentInBytes < ObjectAlignmentInBytes) { + jio_fprintf(defaultStream::error_stream(), + "error: SurvivorAlignmentInBytes=%d must be greater than ObjectAlignmentInBytes=%d \n", + (int)SurvivorAlignmentInBytes, (int)ObjectAlignmentInBytes); + return false; + } + } return true; } @@ -1869,7 +1880,7 @@ void Arguments::process_java_compiler_argument(char* arg) { } void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) { - _sun_java_launcher = strdup(launcher); + _sun_java_launcher = os::strdup_check_oom(launcher); } bool Arguments::created_by_java_launcher() { @@ -2372,7 +2383,7 @@ bool Arguments::check_vm_args_consistency() { if (PrintNMTStatistics) { #if INCLUDE_NMT - if (MemTracker::tracking_level() == MemTracker::NMT_off) { + if (MemTracker::tracking_level() == NMT_off) { #endif // INCLUDE_NMT warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled"); PrintNMTStatistics = false; @@ -2979,7 +2990,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, // Redirect GC output to the file. -Xloggc: // ostream_init_log(), when called will use this filename // to initialize a fileStream. - _gc_log_filename = strdup(tail); + _gc_log_filename = os::strdup_check_oom(tail); if (!is_filename_valid(_gc_log_filename)) { jio_fprintf(defaultStream::output_stream(), "Invalid file name for use with -Xloggc: Filename can only contain the " @@ -3582,15 +3593,24 @@ jint Arguments::parse(const JavaVMInitArgs* args) { CommandLineFlags::printFlags(tty, false); vm_exit(0); } - if (match_option(option, "-XX:NativeMemoryTracking", &tail)) { #if INCLUDE_NMT - MemTracker::init_tracking_options(tail); -#else - jio_fprintf(defaultStream::error_stream(), - "Native Memory Tracking is not supported in this VM\n"); - return JNI_ERR; -#endif + if (match_option(option, "-XX:NativeMemoryTracking", &tail)) { + // The launcher did not setup nmt environment variable properly. +// if (!MemTracker::check_launcher_nmt_support(tail)) { +// warning("Native Memory Tracking did not setup properly, using wrong launcher?"); +// } + + // Verify if nmt option is valid. + if (MemTracker::verify_nmt_option()) { + // Late initialization, still in single-threaded mode. + if (MemTracker::tracking_level() >= NMT_summary) { + MemTracker::init(); + } + } else { + vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); + } } +#endif #ifndef PRODUCT diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index a7ad943cf7c..f630d5d35cc 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -661,7 +661,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m (iframe->interpreter_frame_expression_stack_size() == (next_mask_expression_stack_size - top_frame_expression_stack_adjustment))) || (is_top_frame && (exec_mode == Unpack_exception) && iframe->interpreter_frame_expression_stack_size() == 0) || - (is_top_frame && (exec_mode == Unpack_uncommon_trap || exec_mode == Unpack_reexecute) && + (is_top_frame && (exec_mode == Unpack_uncommon_trap || exec_mode == Unpack_reexecute || el->should_reexecute()) && (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + cur_invoke_parameter_size)) )) { ttyLocker ttyl; diff --git a/hotspot/src/share/vm/runtime/fprofiler.cpp b/hotspot/src/share/vm/runtime/fprofiler.cpp index aec76268824..7f741fee561 100644 --- a/hotspot/src/share/vm/runtime/fprofiler.cpp +++ b/hotspot/src/share/vm/runtime/fprofiler.cpp @@ -629,10 +629,16 @@ class vmNode : public ProfilerNode { } vmNode(const char* name, const TickPosition where) : ProfilerNode() { - _name = name; + _name = os::strdup(name); update(where); } + ~vmNode() { + if (_name != NULL) { + os::free((void*)_name); + } + } + const char *name() const { return _name; } bool is_compiled() const { return true; } @@ -784,7 +790,7 @@ void ThreadProfiler::vm_update(const char* name, TickPosition where) { assert(index >= 0, "Must be positive"); // Note that we call strdup below since the symbol may be resource allocated if (!table[index]) { - table[index] = new (this) vmNode(os::strdup(name), where); + table[index] = new (this) vmNode(name, where); } else { ProfilerNode* prev = table[index]; for(ProfilerNode* node = prev; node; node = node->next()) { @@ -794,7 +800,7 @@ void ThreadProfiler::vm_update(const char* name, TickPosition where) { } prev = node; } - prev->set_next(new (this) vmNode(os::strdup(name), where)); + prev->set_next(new (this) vmNode(name, where)); } } diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 2d1805e2fb6..561eb81e864 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -945,11 +945,6 @@ class CommandLineFlags { diagnostic(bool, PrintNMTStatistics, false, \ "Print native memory tracking summary data if it is on") \ \ - diagnostic(bool, AutoShutdownNMT, true, \ - "Automatically shutdown native memory tracking under stress " \ - "situations. When set to false, native memory tracking tries to " \ - "stay alive at the expense of JVM performance") \ - \ diagnostic(bool, LogCompilation, false, \ "Log compilation activity in detail to LogFile") \ \ @@ -1078,6 +1073,9 @@ class CommandLineFlags { product(bool, ClassUnloading, true, \ "Do unloading of classes") \ \ + product(bool, ClassUnloadingWithConcurrentMark, true, \ + "Do unloading of classes with a concurrent marking cycle") \ + \ develop(bool, DisableStartThread, false, \ "Disable starting of additional Java threads " \ "(for debugging only)") \ @@ -2786,12 +2784,6 @@ class CommandLineFlags { product(bool, UseLoopCounter, true, \ "Increment invocation counter on backward branch") \ \ - product(bool, UseFastEmptyMethods, true, \ - "Use fast method entry code for empty methods") \ - \ - product(bool, UseFastAccessorMethods, true, \ - "Use fast method entry code for accessor methods") \ - \ product_pd(bool, UseOnStackReplacement, \ "Use on stack replacement, calls runtime if invoc. counter " \ "overflows in loop") \ @@ -3871,6 +3863,9 @@ class CommandLineFlags { product(bool, PrintGCCause, true, \ "Include GC cause in GC logging") \ \ + experimental(intx, SurvivorAlignmentInBytes, 0, \ + "Default survivor space alignment in bytes") \ + \ product(bool , AllowNonVirtualCalls, false, \ "Obey the ACC_SUPER flag and allow invokenonvirtual calls") \ \ diff --git a/hotspot/src/share/vm/runtime/handles.hpp b/hotspot/src/share/vm/runtime/handles.hpp index e7212214a14..3eef0adbc60 100644 --- a/hotspot/src/share/vm/runtime/handles.hpp +++ b/hotspot/src/share/vm/runtime/handles.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -227,7 +227,7 @@ class HandleArea: public Arena { HandleArea* _prev; // link to outer (older) area public: // Constructor - HandleArea(HandleArea* prev) : Arena(Chunk::tiny_size) { + HandleArea(HandleArea* prev) : Arena(mtThread, Chunk::tiny_size) { debug_only(_handle_mark_nesting = 0); debug_only(_no_handle_mark_nesting = 0); _prev = prev; diff --git a/hotspot/src/share/vm/runtime/init.cpp b/hotspot/src/share/vm/runtime/init.cpp index 6c654d280e2..68c8845aaf7 100644 --- a/hotspot/src/share/vm/runtime/init.cpp +++ b/hotspot/src/share/vm/runtime/init.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,10 @@ #include "runtime/init.hpp" #include "runtime/safepoint.hpp" #include "runtime/sharedRuntime.hpp" +#include "services/memTracker.hpp" #include "utilities/macros.hpp" + // Initialization done by VM thread in vm_init_globals() void check_ThreadShadow(); void eventlog_init(); @@ -131,6 +133,12 @@ jint init_globals() { javaClasses_init(); // must happen after vtable initialization stubRoutines_init2(); // note: StubRoutines need 2-phase init +#if INCLUDE_NMT + // Solaris stack is walkable only after stubRoutines are set up. + // On Other platforms, the stack is always walkable. + NMT_stack_walkable = true; +#endif // INCLUDE_NMT + // All the flags that get adjusted by VM_Version_init and os::init_2 // have been set so dump the flags now. if (PrintFlagsFinal) { diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index cfecf0a5d57..881d808cdf7 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -57,7 +57,6 @@ #include "runtime/thread.inline.hpp" #include "runtime/timer.hpp" #include "runtime/vm_operations.hpp" -#include "services/memReporter.hpp" #include "services/memTracker.hpp" #include "trace/tracing.hpp" #include "utilities/dtrace.hpp" @@ -349,12 +348,7 @@ void print_statistics() { #endif // ENABLE_ZAP_DEAD_LOCALS // Native memory tracking data if (PrintNMTStatistics) { - if (MemTracker::is_on()) { - BaselineTTYOutputer outputer(tty); - MemTracker::print_memory_usage(outputer, K, false); - } else { - tty->print_cr("%s", MemTracker::reason()); - } + MemTracker::final_report(tty); } } @@ -390,12 +384,7 @@ void print_statistics() { // Native memory tracking data if (PrintNMTStatistics) { - if (MemTracker::is_on()) { - BaselineTTYOutputer outputer(tty); - MemTracker::print_memory_usage(outputer, K, false); - } else { - tty->print_cr("%s", MemTracker::reason()); - } + MemTracker::final_report(tty); } } @@ -544,10 +533,6 @@ void before_exit(JavaThread * thread) { BeforeExit_lock->notify_all(); } - // Shutdown NMT before exit. Otherwise, - // it will run into trouble when system destroys static variables. - MemTracker::shutdown(MemTracker::NMT_normal); - if (VerifyStringTableAtExit) { int fail_cnt = 0; { diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index d24c688bf13..5fe937a6bae 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -52,6 +52,7 @@ #include "runtime/thread.inline.hpp" #include "runtime/vm_version.hpp" #include "services/attachListener.hpp" +#include "services/nmtCommon.hpp" #include "services/memTracker.hpp" #include "services/threadService.hpp" #include "utilities/defaultStream.hpp" @@ -516,6 +517,14 @@ char *os::strdup(const char *str, MEMFLAGS flags) { return dup_str; } +char* os::strdup_check_oom(const char* str, MEMFLAGS flags) { + char* p = os::strdup(str, flags); + if (p == NULL) { + vm_exit_out_of_memory(strlen(str) + 1, OOM_MALLOC_ERROR, "os::strdup_check_oom"); + } + return p; +} + #define paranoid 0 /* only set to 1 if you suspect checking code has bug */ @@ -553,7 +562,11 @@ static u_char* testMalloc(size_t alloc_size) { return ptr; } -void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { +void* os::malloc(size_t size, MEMFLAGS flags) { + return os::malloc(size, flags, CALLER_PC); +} + +void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); @@ -579,11 +592,15 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { size = 1; } + // NMT support + NMT_TrackingLevel level = MemTracker::tracking_level(); + size_t nmt_header_size = MemTracker::malloc_header_size(level); + #ifndef ASSERT - const size_t alloc_size = size; + const size_t alloc_size = size + nmt_header_size; #else - const size_t alloc_size = GuardedMemory::get_total_size(size); - if (size > alloc_size) { // Check for rollover. + const size_t alloc_size = GuardedMemory::get_total_size(size + nmt_header_size); + if (size + nmt_header_size > alloc_size) { // Check for rollover. return NULL; } #endif @@ -602,7 +619,7 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { return NULL; } // Wrap memory with guard - GuardedMemory guarded(ptr, size); + GuardedMemory guarded(ptr, size + nmt_header_size); ptr = guarded.get_user_ptr(); #endif if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) { @@ -615,48 +632,50 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { } // we do not track guard memory - MemTracker::record_malloc((address)ptr, size, memflags, caller == 0 ? CALLER_PC : caller); - - return ptr; + return MemTracker::record_malloc((address)ptr, size, memflags, stack, level); } +void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) { + return os::realloc(memblock, size, flags, CALLER_PC); +} -void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, address caller) { +void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { #ifndef ASSERT NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); - MemTracker::Tracker tkr = MemTracker::get_realloc_tracker(); - void* ptr = ::realloc(memblock, size); - if (ptr != NULL) { - tkr.record((address)memblock, (address)ptr, size, memflags, - caller == 0 ? CALLER_PC : caller); - } else { - tkr.discard(); - } - return ptr; + // NMT support + void* membase = MemTracker::record_free(memblock); + NMT_TrackingLevel level = MemTracker::tracking_level(); + size_t nmt_header_size = MemTracker::malloc_header_size(level); + void* ptr = ::realloc(membase, size + nmt_header_size); + return MemTracker::record_malloc(ptr, size, memflags, stack, level); #else if (memblock == NULL) { - return os::malloc(size, memflags, (caller == 0 ? CALLER_PC : caller)); + return os::malloc(size, memflags, stack); } if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { tty->print_cr("os::realloc caught " PTR_FORMAT, memblock); breakpoint(); } - verify_memory(memblock); + // NMT support + void* membase = MemTracker::malloc_base(memblock); + verify_memory(membase); NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); if (size == 0) { return NULL; } // always move the block - void* ptr = os::malloc(size, memflags, caller == 0 ? CALLER_PC : caller); + void* ptr = os::malloc(size, memflags, stack); if (PrintMalloc) { tty->print_cr("os::remalloc " SIZE_FORMAT " bytes, " PTR_FORMAT " --> " PTR_FORMAT, size, memblock, ptr); } // Copy to new memory if malloc didn't fail if ( ptr != NULL ) { - GuardedMemory guarded(memblock); - memcpy(ptr, memblock, MIN2(size, guarded.get_user_size())); - if (paranoid) verify_memory(ptr); + GuardedMemory guarded(MemTracker::malloc_base(memblock)); + // Guard's user data contains NMT header + size_t memblock_size = guarded.get_user_size() - MemTracker::malloc_header_size(memblock); + memcpy(ptr, memblock, MIN2(size, memblock_size)); + if (paranoid) verify_memory(MemTracker::malloc_base(ptr)); if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) { tty->print_cr("os::realloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, ptr); breakpoint(); @@ -669,7 +688,6 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, address caller void os::free(void *memblock, MEMFLAGS memflags) { - address trackp = (address) memblock; NOT_PRODUCT(inc_stat_counter(&num_frees, 1)); #ifdef ASSERT if (memblock == NULL) return; @@ -677,20 +695,22 @@ void os::free(void *memblock, MEMFLAGS memflags) { if (tty != NULL) tty->print_cr("os::free caught " PTR_FORMAT, memblock); breakpoint(); } - verify_memory(memblock); + void* membase = MemTracker::record_free(memblock); + verify_memory(membase); NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); - GuardedMemory guarded(memblock); + GuardedMemory guarded(membase); size_t size = guarded.get_user_size(); inc_stat_counter(&free_bytes, size); - memblock = guarded.release_for_freeing(); + membase = guarded.release_for_freeing(); if (PrintMalloc && tty != NULL) { - fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, (uintptr_t)memblock); + fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, (uintptr_t)membase); } + ::free(membase); +#else + void* membase = MemTracker::record_free(memblock); + ::free(membase); #endif - MemTracker::record_free(trackp, memflags); - - ::free(memblock); } void os::init_random(long initval) { @@ -1404,7 +1424,7 @@ bool os::create_stack_guard_pages(char* addr, size_t bytes) { char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint) { char* result = pd_reserve_memory(bytes, addr, alignment_hint); if (result != NULL) { - MemTracker::record_virtual_memory_reserve((address)result, bytes, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); } return result; @@ -1414,7 +1434,7 @@ char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint, MEMFLAGS flags) { char* result = pd_reserve_memory(bytes, addr, alignment_hint); if (result != NULL) { - MemTracker::record_virtual_memory_reserve((address)result, bytes, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); MemTracker::record_virtual_memory_type((address)result, flags); } @@ -1424,7 +1444,7 @@ char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint, char* os::attempt_reserve_memory_at(size_t bytes, char* addr) { char* result = pd_attempt_reserve_memory_at(bytes, addr); if (result != NULL) { - MemTracker::record_virtual_memory_reserve((address)result, bytes, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); } return result; } @@ -1464,23 +1484,29 @@ void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint, } bool os::uncommit_memory(char* addr, size_t bytes) { - MemTracker::Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker(); - bool res = pd_uncommit_memory(addr, bytes); - if (res) { - tkr.record((address)addr, bytes); + bool res; + if (MemTracker::tracking_level() > NMT_minimal) { + Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker(); + res = pd_uncommit_memory(addr, bytes); + if (res) { + tkr.record((address)addr, bytes); + } } else { - tkr.discard(); + res = pd_uncommit_memory(addr, bytes); } return res; } bool os::release_memory(char* addr, size_t bytes) { - MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - bool res = pd_release_memory(addr, bytes); - if (res) { - tkr.record((address)addr, bytes); + bool res; + if (MemTracker::tracking_level() > NMT_minimal) { + Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + res = pd_release_memory(addr, bytes); + if (res) { + tkr.record((address)addr, bytes); + } } else { - tkr.discard(); + res = pd_release_memory(addr, bytes); } return res; } @@ -1491,7 +1517,7 @@ char* os::map_memory(int fd, const char* file_name, size_t file_offset, bool allow_exec) { char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec); if (result != NULL) { - MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, mtNone, CALLER_PC); + MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC); } return result; } @@ -1504,12 +1530,15 @@ char* os::remap_memory(int fd, const char* file_name, size_t file_offset, } bool os::unmap_memory(char *addr, size_t bytes) { - MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - bool result = pd_unmap_memory(addr, bytes); - if (result) { - tkr.record((address)addr, bytes); + bool result; + if (MemTracker::tracking_level() > NMT_minimal) { + Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); + result = pd_unmap_memory(addr, bytes); + if (result) { + tkr.record((address)addr, bytes); + } } else { - tkr.discard(); + result = pd_unmap_memory(addr, bytes); } return result; } diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index b65e7ab44c5..5029a238a00 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -65,6 +65,8 @@ class JavaThread; class Event; class DLL; class FileHandle; +class NativeCallStack; + template class GrowableArray; // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose @@ -96,9 +98,11 @@ const bool ExecMem = true; // Typedef for structured exception handling support typedef void (*java_call_t)(JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread); +class MallocTracker; + class os: AllStatic { friend class VMStructs; - + friend class MallocTracker; public: enum { page_sizes_max = 9 }; // Size of _page_sizes array (8 plus a sentinel) @@ -160,7 +164,10 @@ class os: AllStatic { // Override me as needed static int file_name_strcmp(const char* s1, const char* s2); + // get/unset environment variable static bool getenv(const char* name, char* buffer, int len); + static bool unsetenv(const char* name); + static bool have_special_privileges(); static jlong javaTimeMillis(); @@ -207,8 +214,13 @@ class os: AllStatic { // Interface for detecting multiprocessor system static inline bool is_MP() { +#if !INCLUDE_NMT assert(_processor_count > 0, "invalid processor count"); return _processor_count > 1 || AssumeMP; +#else + // NMT needs atomic operations before this initialization. + return true; +#endif } static julong available_memory(); static julong physical_memory(); @@ -635,15 +647,25 @@ class os: AllStatic { static void* thread_local_storage_at(int index); static void free_thread_local_storage(int index); - // Stack walk - static address get_caller_pc(int n = 0); + // Retrieve native stack frames. + // Parameter: + // stack: an array to storage stack pointers. + // frames: size of above array. + // toSkip: number of stack frames to skip at the beginning. + // Return: number of stack frames captured. + static int get_native_stack(address* stack, int size, int toSkip = 0); // General allocation (must be MT-safe) - static void* malloc (size_t size, MEMFLAGS flags, address caller_pc = 0); - static void* realloc (void *memblock, size_t size, MEMFLAGS flags, address caller_pc = 0); + static void* malloc (size_t size, MEMFLAGS flags, const NativeCallStack& stack); + static void* malloc (size_t size, MEMFLAGS flags); + static void* realloc (void *memblock, size_t size, MEMFLAGS flag, const NativeCallStack& stack); + static void* realloc (void *memblock, size_t size, MEMFLAGS flag); + static void free (void *memblock, MEMFLAGS flags = mtNone); static bool check_heap(bool force = false); // verify C heap integrity static char* strdup(const char *, MEMFLAGS flags = mtInternal); // Like strdup + // Like strdup, but exit VM when strdup() returns NULL + static char* strdup_check_oom(const char*, MEMFLAGS flags = mtInternal); #ifndef PRODUCT static julong num_mallocs; // # of calls to malloc/realloc diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index 4b16f6b04a8..05460b84dc0 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -52,7 +52,6 @@ #include "runtime/sweeper.hpp" #include "runtime/synchronizer.hpp" #include "runtime/thread.inline.hpp" -#include "services/memTracker.hpp" #include "services/runtimeService.hpp" #include "utilities/events.hpp" #include "utilities/macros.hpp" @@ -527,10 +526,6 @@ void SafepointSynchronize::do_cleanup_tasks() { TraceTime t7("purging class loader data graph", TraceSafepointCleanupTime); ClassLoaderDataGraph::purge_if_needed(); } - - if (MemTracker::is_on()) { - MemTracker::sync(); - } } diff --git a/hotspot/src/share/vm/runtime/sharedRuntimeMath.hpp b/hotspot/src/share/vm/runtime/sharedRuntimeMath.hpp index 4259227c3b3..26c9147f8b1 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntimeMath.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntimeMath.hpp @@ -27,20 +27,51 @@ #include -// VM_LITTLE_ENDIAN is #defined appropriately in the Makefiles -// [jk] this is not 100% correct because the float word order may different -// from the byte order (e.g. on ARM FPA) +// Used to access the lower/higher 32 bits of a double +typedef union { + double d; + struct { #ifdef VM_LITTLE_ENDIAN -# define __HI(x) *(1+(int*)&x) -# define __LO(x) *(int*)&x + int lo; + int hi; #else -# define __HI(x) *(int*)&x -# define __LO(x) *(1+(int*)&x) + int hi; + int lo; #endif + } split; +} DoubleIntConv; + +static inline int high(double d) { + DoubleIntConv x; + x.d = d; + return x.split.hi; +} + +static inline int low(double d) { + DoubleIntConv x; + x.d = d; + return x.split.lo; +} + +static inline void set_high(double* d, int high) { + DoubleIntConv conv; + conv.d = *d; + conv.split.hi = high; + *d = conv.d; +} + +static inline void set_low(double* d, int low) { + DoubleIntConv conv; + conv.d = *d; + conv.split.lo = low; + *d = conv.d; +} static double copysignA(double x, double y) { - __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000); - return x; + DoubleIntConv convX; + convX.d = x; + convX.split.hi = (convX.split.hi & 0x7fffffff) | (high(y) & 0x80000000); + return convX.d; } /* @@ -67,30 +98,32 @@ twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ hugeX = 1.0e+300, tiny = 1.0e-300; -static double scalbnA (double x, int n) { +static double scalbnA(double x, int n) { int k,hx,lx; - hx = __HI(x); - lx = __LO(x); + hx = high(x); + lx = low(x); k = (hx&0x7ff00000)>>20; /* extract exponent */ if (k==0) { /* 0 or subnormal x */ if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ x *= two54; - hx = __HI(x); + hx = high(x); k = ((hx&0x7ff00000)>>20) - 54; if (n< -50000) return tiny*x; /*underflow*/ } if (k==0x7ff) return x+x; /* NaN or Inf */ k = k+n; - if (k > 0x7fe) return hugeX*copysignA(hugeX,x); /* overflow */ - if (k > 0) /* normal result */ - {__HI(x) = (hx&0x800fffff)|(k<<20); return x;} + if (k > 0x7fe) return hugeX*copysignA(hugeX,x); /* overflow */ + if (k > 0) { /* normal result */ + set_high(&x, (hx&0x800fffff)|(k<<20)); + return x; + } if (k <= -54) { if (n > 50000) /* in case integer overflow in n+k */ return hugeX*copysignA(hugeX,x); /*overflow*/ else return tiny*copysignA(tiny,x); /*underflow*/ } k += 54; /* subnormal result */ - __HI(x) = (hx&0x800fffff)|(k<<20); + set_high(&x, (hx&0x800fffff)|(k<<20)); return x*twom54; } diff --git a/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp b/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp index 69feb28bdfb..3b8c8a3010b 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp @@ -40,6 +40,7 @@ // generated; can not figure out how to turn down optimization for one // file in the IDE on Windows #ifdef WIN32 +# pragma warning( disable: 4748 ) // /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function # pragma optimize ( "", off ) #endif @@ -114,8 +115,8 @@ static double __ieee754_log(double x) { int k,hx,i,j; unsigned lx; - hx = __HI(x); /* high word of x */ - lx = __LO(x); /* low word of x */ + hx = high(x); /* high word of x */ + lx = low(x); /* low word of x */ k=0; if (hx < 0x00100000) { /* x < 2**-1022 */ @@ -123,13 +124,13 @@ static double __ieee754_log(double x) { return -two54/zero; /* log(+-0)=-inf */ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ - hx = __HI(x); /* high word of x */ + hx = high(x); /* high word of x */ } if (hx >= 0x7ff00000) return x+x; k += (hx>>20)-1023; hx &= 0x000fffff; i = (hx+0x95f64)&0x100000; - __HI(x) = hx|(i^0x3ff00000); /* normalize x or x/2 */ + set_high(&x, hx|(i^0x3ff00000)); /* normalize x or x/2 */ k += (i>>20); f = x-1.0; if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ @@ -208,8 +209,8 @@ static double __ieee754_log10(double x) { int i,k,hx; unsigned lx; - hx = __HI(x); /* high word of x */ - lx = __LO(x); /* low word of x */ + hx = high(x); /* high word of x */ + lx = low(x); /* low word of x */ k=0; if (hx < 0x00100000) { /* x < 2**-1022 */ @@ -217,14 +218,14 @@ static double __ieee754_log10(double x) { return -two54/zero; /* log(+-0)=-inf */ if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ - hx = __HI(x); /* high word of x */ + hx = high(x); /* high word of x */ } if (hx >= 0x7ff00000) return x+x; k += (hx>>20)-1023; i = ((unsigned)k&0x80000000)>>31; hx = (hx&0x000fffff)|((0x3ff-i)<<20); y = (double)(k+i); - __HI(x) = hx; + set_high(&x, hx); z = y*log10_2lo + ivln10*__ieee754_log(x); return z+y*log10_2hi; } @@ -319,14 +320,14 @@ static double __ieee754_exp(double x) { int k=0,xsb; unsigned hx; - hx = __HI(x); /* high word of x */ + hx = high(x); /* high word of x */ xsb = (hx>>31)&1; /* sign bit of x */ hx &= 0x7fffffff; /* high word of |x| */ /* filter out non-finite argument */ if(hx >= 0x40862E42) { /* if |x|>=709.78... */ if(hx>=0x7ff00000) { - if(((hx&0xfffff)|__LO(x))!=0) + if(((hx&0xfffff)|low(x))!=0) return x+x; /* NaN */ else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */ } @@ -357,10 +358,10 @@ static double __ieee754_exp(double x) { if(k==0) return one-((x*c)/(c-2.0)-x); else y = one-((lo-(x*c)/(2.0-c))-hi); if(k >= -1021) { - __HI(y) += (k<<20); /* add k to y's exponent */ + set_high(&y, high(y) + (k<<20)); /* add k to y's exponent */ return y; } else { - __HI(y) += ((k+1000)<<20);/* add k to y's exponent */ + set_high(&y, high(y) + ((k+1000)<<20)); /* add k to y's exponent */ return y*twom1000; } } @@ -447,8 +448,8 @@ double __ieee754_pow(double x, double y) { unsigned lx,ly; i0 = ((*(int*)&one)>>29)^1; i1=1-i0; - hx = __HI(x); lx = __LO(x); - hy = __HI(y); ly = __LO(y); + hx = high(x); lx = low(x); + hy = high(y); ly = low(y); ix = hx&0x7fffffff; iy = hy&0x7fffffff; /* y==zero: x**0 = 1 */ @@ -548,14 +549,14 @@ double __ieee754_pow(double x, double y) { u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ v = t*ivln2_l-w*ivln2; t1 = u+v; - __LO(t1) = 0; + set_low(&t1, 0); t2 = v-(t1-u); } else { double ss,s2,s_h,s_l,t_h,t_l; n = 0; /* take care subnormal number */ if(ix<0x00100000) - {ax *= two53; n -= 53; ix = __HI(ax); } + {ax *= two53; n -= 53; ix = high(ax); } n += ((ix)>>20)-0x3ff; j = ix&0x000fffff; /* determine interval */ @@ -563,17 +564,17 @@ double __ieee754_pow(double x, double y) { if(j<=0x3988E) k=0; /* |x|>1)|0x20000000)+0x00080000+(k<<18); + set_high(&t_h, ((ix>>1)|0x20000000)+0x00080000+(k<<18)); t_l = ax - (t_h-bp[k]); s_l = v*((u-s_h*t_h)-s_h*t_l); /* compute log(ax) */ @@ -582,32 +583,32 @@ double __ieee754_pow(double x, double y) { r += s_l*(s_h+ss); s2 = s_h*s_h; t_h = 3.0+s2+r; - __LO(t_h) = 0; + set_low(&t_h, 0); t_l = r-((t_h-3.0)-s2); /* u+v = ss*(1+...) */ u = s_h*t_h; v = s_l*t_h+t_l*ss; /* 2/(3log2)*(ss+...) */ p_h = u+v; - __LO(p_h) = 0; + set_low(&p_h, 0); p_l = v-(p_h-u); z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ z_l = cp_l*p_h+p_l*cp+dp_l[k]; /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */ t = (double)n; t1 = (((z_h+z_l)+dp_h[k])+t); - __LO(t1) = 0; + set_low(&t1, 0); t2 = z_l-(((t1-t)-dp_h[k])-z_h); } /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ y1 = y; - __LO(y1) = 0; + set_low(&y1, 0); p_l = (y-y1)*t1+y*t2; p_h = y1*t1; z = p_l+p_h; - j = __HI(z); - i = __LO(z); + j = high(z); + i = low(z); if (j>=0x40900000) { /* z >= 1024 */ if(((j-0x40900000)|i)!=0) /* if z > 1024 */ return s*hugeX*hugeX; /* overflow */ @@ -631,13 +632,13 @@ double __ieee754_pow(double x, double y) { n = j+(0x00100000>>(k+1)); k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ t = zeroX; - __HI(t) = (n&~(0x000fffff>>k)); + set_high(&t, (n&~(0x000fffff>>k))); n = ((n&0x000fffff)|0x00100000)>>(20-k); if(j<0) n = -n; p_h -= t; } t = p_l+p_h; - __LO(t) = 0; + set_low(&t, 0); u = t*lg2_h; v = (p_l-(t-p_h))*lg2+t*lg2_l; z = u+v; @@ -646,10 +647,10 @@ double __ieee754_pow(double x, double y) { t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); r = (z*t1)/(t1-two)-(w+z*w); z = one-(r-z); - j = __HI(z); + j = high(z); j += (n<<20); if((j>>20)<=0) z = scalbnA(z,n); /* subnormal output */ - else __HI(z) += (n<<20); + else set_high(&z, high(z) + (n<<20)); return s*z; } diff --git a/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp b/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp index 84f35aa9317..8acd7401585 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp @@ -519,7 +519,7 @@ static double __kernel_sin(double x, double y, int iy) { double z,r,v; int ix; - ix = __HI(x)&0x7fffffff; /* high word of x */ + ix = high(x)&0x7fffffff; /* high word of x */ if(ix<0x3e400000) /* |x| < 2**-27 */ {if((int)x==0) return x;} /* generate inexact */ z = x*x; @@ -574,9 +574,9 @@ C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ static double __kernel_cos(double x, double y) { - double a,h,z,r,qx; + double a,h,z,r,qx=0; int ix; - ix = __HI(x)&0x7fffffff; /* ix = |x|'s high word*/ + ix = high(x)&0x7fffffff; /* ix = |x|'s high word*/ if(ix<0x3e400000) { /* if x < 2**27 */ if(((int)x)==0) return one; /* generate inexact */ } @@ -588,8 +588,8 @@ static double __kernel_cos(double x, double y) if(ix > 0x3fe90000) { /* x > 0.78125 */ qx = 0.28125; } else { - __HI(qx) = ix-0x00200000; /* x/4 */ - __LO(qx) = 0; + set_high(&qx, ix-0x00200000); /* x/4 */ + set_low(&qx, 0); } h = 0.5*z-qx; a = one-qx; @@ -654,11 +654,11 @@ static double __kernel_tan(double x, double y, int iy) { double z,r,v,w,s; int ix,hx; - hx = __HI(x); /* high word of x */ + hx = high(x); /* high word of x */ ix = hx&0x7fffffff; /* high word of |x| */ if(ix<0x3e300000) { /* x < 2**-28 */ if((int)x==0) { /* generate inexact */ - if (((ix | __LO(x)) | (iy + 1)) == 0) + if (((ix | low(x)) | (iy + 1)) == 0) return one / fabsd(x); else { if (iy == 1) @@ -667,10 +667,10 @@ static double __kernel_tan(double x, double y, int iy) double a, t; z = w = x + y; - __LO(z) = 0; + set_low(&z, 0); v = y - (z - x); t = a = -one / w; - __LO(t) = 0; + set_low(&t, 0); s = one + t * z; return t + a * (s + t * v); } @@ -705,10 +705,10 @@ static double __kernel_tan(double x, double y, int iy) /* compute -1.0/(x+r) accurately */ double a,t; z = w; - __LO(z) = 0; + set_low(&z, 0); v = r-(z - x); /* z+v = r+x */ t = a = -1.0/w; /* a = -1.0/w */ - __LO(t) = 0; + set_low(&t, 0); s = 1.0+t*z; return t+a*(s+t*v); } @@ -757,7 +757,7 @@ JRT_LEAF(jdouble, SharedRuntime::dsin(jdouble x)) int n, ix; /* High word of x. */ - ix = __HI(x); + ix = high(x); /* |x| ~< pi/4 */ ix &= 0x7fffffff; @@ -815,7 +815,7 @@ JRT_LEAF(jdouble, SharedRuntime::dcos(jdouble x)) int n, ix; /* High word of x. */ - ix = __HI(x); + ix = high(x); /* |x| ~< pi/4 */ ix &= 0x7fffffff; @@ -872,7 +872,7 @@ JRT_LEAF(jdouble, SharedRuntime::dtan(jdouble x)) int n, ix; /* High word of x. */ - ix = __HI(x); + ix = high(x); /* |x| ~< pi/4 */ ix &= 0x7fffffff; diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 08785805729..9956ed28846 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -297,8 +297,7 @@ void Thread::record_stack_base_and_size() { #if INCLUDE_NMT // record thread's native stack, stack grows downward address stack_low_addr = stack_base() - stack_size(); - MemTracker::record_thread_stack(stack_low_addr, stack_size(), this, - CURRENT_PC); + MemTracker::record_thread_stack(stack_low_addr, stack_size()); #endif // INCLUDE_NMT } @@ -316,7 +315,7 @@ Thread::~Thread() { #if INCLUDE_NMT if (_stack_base != NULL) { address low_stack_addr = stack_base() - stack_size(); - MemTracker::release_thread_stack(low_stack_addr, stack_size(), this); + MemTracker::release_thread_stack(low_stack_addr, stack_size()); #ifdef ASSERT set_stack_base(NULL); #endif @@ -1425,9 +1424,6 @@ void JavaThread::initialize() { set_monitor_chunks(NULL); set_next(NULL); set_thread_state(_thread_new); -#if INCLUDE_NMT - set_recorder(NULL); -#endif _terminated = _not_terminated; _privileged_stack_top = NULL; _array_for_gc = NULL; @@ -1503,7 +1499,6 @@ JavaThread::JavaThread(bool is_attaching_via_jni) : _jni_attach_state = _not_attaching_via_jni; } assert(deferred_card_mark().is_empty(), "Default MemRegion ctor"); - _safepoint_visible = false; } bool JavaThread::reguard_stack(address cur_sp) { @@ -1566,7 +1561,6 @@ JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread : os::java_thread; os::create_thread(this, thr_type, stack_sz); - _safepoint_visible = false; // The _osthread may be NULL here because we ran out of memory (too many threads active). // We need to throw and OutOfMemoryError - however we cannot do this here because the caller // may hold a lock and all locks must be unlocked before throwing the exception (throwing @@ -1584,13 +1578,6 @@ JavaThread::~JavaThread() { tty->print_cr("terminate thread %p", this); } - // By now, this thread should already be invisible to safepoint, - // and its per-thread recorder also collected. - assert(!is_safepoint_visible(), "wrong state"); -#if INCLUDE_NMT - assert(get_recorder() == NULL, "Already collected"); -#endif // INCLUDE_NMT - // JSR166 -- return the parker to the free list Parker::Release(_parker); _parker = NULL; @@ -3359,11 +3346,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // initialize TLS ThreadLocalStorage::init(); - // Bootstrap native memory tracking, so it can start recording memory - // activities before worker thread is started. This is the first phase - // of bootstrapping, VM is currently running in single-thread mode. - MemTracker::bootstrap_single_thread(); - // Initialize output stream logging ostream_init_log(); @@ -3414,9 +3396,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // Initialize Java-Level synchronization subsystem ObjectMonitor::Initialize(); - // Second phase of bootstrapping, VM is about entering multi-thread mode - MemTracker::bootstrap_multi_thread(); - // Initialize global modules jint status = init_globals(); if (status != JNI_OK) { @@ -3438,9 +3417,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // real raw monitor. VM is setup enough here for raw monitor enter. JvmtiExport::transition_pending_onload_raw_monitors(); - // Fully start NMT - MemTracker::start(); - // Create the VMThread { TraceTime timer("Start VMThread", TraceStartupTime); VMThread::create(); @@ -3995,8 +3971,6 @@ void Threads::add(JavaThread* p, bool force_daemon) { daemon = false; } - p->set_safepoint_visible(true); - ThreadService::add_thread(p, daemon); // Possible GC point. @@ -4042,13 +4016,6 @@ void Threads::remove(JavaThread* p) { // to do callbacks into the safepoint code. However, the safepoint code is not aware // of this thread since it is removed from the queue. p->set_terminated_value(); - - // Now, this thread is not visible to safepoint - p->set_safepoint_visible(false); - // once the thread becomes safepoint invisible, we can not use its per-thread - // recorder. And Threads::do_threads() no longer walks this thread, so we have - // to release its per-thread recorder here. - MemTracker::thread_exiting(p); } // unlock Threads_lock // Since Events::log uses a lock, we grab it outside the Threads_lock diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 7df1c0f3cbc..332fd8666f8 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -43,10 +43,6 @@ #include "runtime/unhandledOops.hpp" #include "utilities/macros.hpp" -#if INCLUDE_NMT -#include "services/memRecorder.hpp" -#endif // INCLUDE_NMT - #include "trace/traceBackend.hpp" #include "trace/traceMacros.hpp" #include "utilities/exceptions.hpp" @@ -1036,16 +1032,6 @@ class JavaThread: public Thread { bool do_not_unlock_if_synchronized() { return _do_not_unlock_if_synchronized; } void set_do_not_unlock_if_synchronized(bool val) { _do_not_unlock_if_synchronized = val; } -#if INCLUDE_NMT - // native memory tracking - inline MemRecorder* get_recorder() const { return (MemRecorder*)_recorder; } - inline void set_recorder(MemRecorder* rc) { _recorder = rc; } - - private: - // per-thread memory recorder - MemRecorder* volatile _recorder; -#endif // INCLUDE_NMT - // Suspend/resume support for JavaThread private: inline void set_ext_suspended(); @@ -1485,19 +1471,6 @@ public: return result; } - // NMT (Native memory tracking) support. - // This flag helps NMT to determine if this JavaThread will be blocked - // at safepoint. If not, ThreadCritical is needed for writing memory records. - // JavaThread is only safepoint visible when it is in Threads' thread list, - // it is not visible until it is added to the list and becomes invisible - // once it is removed from the list. - public: - bool is_safepoint_visible() const { return _safepoint_visible; } - void set_safepoint_visible(bool visible) { _safepoint_visible = visible; } - private: - bool _safepoint_visible; - - // Static operations public: // Returns the running thread as a JavaThread static inline JavaThread* current(); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 3ff41705843..72f7896f5e9 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -52,6 +52,7 @@ #include "interpreter/bytecodes.hpp" #include "interpreter/interpreter.hpp" #include "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" #include "memory/cardTableRS.hpp" #include "memory/defNewGeneration.hpp" #include "memory/freeBlockDictionary.hpp" @@ -93,6 +94,7 @@ #include "runtime/globals.hpp" #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/os.hpp" #include "runtime/perfMemory.hpp" #include "runtime/serviceThread.hpp" #include "runtime/sharedRuntime.hpp" @@ -3296,14 +3298,14 @@ static int recursiveFindType(VMTypeEntry* origtypes, const char* typeName, bool } } if (strstr(typeName, " const") == typeName + len - 6) { - char * s = strdup(typeName); + char * s = os::strdup_check_oom(typeName); s[len - 6] = '\0'; // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName); if (recursiveFindType(origtypes, s, true) == 1) { - free(s); + os::free(s); return 1; } - free(s); + os::free(s); } if (!isRecurse) { tty->print_cr("type \"%s\" not found", typeName); diff --git a/hotspot/src/share/vm/services/allocationSite.hpp b/hotspot/src/share/vm/services/allocationSite.hpp new file mode 100644 index 00000000000..07f8595f815 --- /dev/null +++ b/hotspot/src/share/vm/services/allocationSite.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_ALLOCATION_SITE_HPP +#define SHARE_VM_SERVICES_ALLOCATION_SITE_HPP + +#include "memory/allocation.hpp" +#include "utilities/nativeCallStack.hpp" + +// Allocation site represents a code path that makes a memory +// allocation +template class AllocationSite VALUE_OBJ_CLASS_SPEC { + private: + NativeCallStack _call_stack; + E e; + public: + AllocationSite(const NativeCallStack& stack) : _call_stack(stack) { } + int hash() const { return _call_stack.hash(); } + bool equals(const NativeCallStack& stack) const { + return _call_stack.equals(stack); + } + + bool equals(const AllocationSite& other) const { + return other.equals(_call_stack); + } + + const NativeCallStack* call_stack() const { + return &_call_stack; + } + + // Information regarding this allocation + E* data() { return &e; } + const E* peek() const { return &e; } +}; + +#endif // SHARE_VM_SERVICES_ALLOCATION_SITE_HPP diff --git a/hotspot/src/share/vm/services/mallocSiteTable.cpp b/hotspot/src/share/vm/services/mallocSiteTable.cpp new file mode 100644 index 00000000000..ec11cfabe69 --- /dev/null +++ b/hotspot/src/share/vm/services/mallocSiteTable.cpp @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#include "precompiled.hpp" + + +#include "memory/allocation.inline.hpp" +#include "runtime/atomic.hpp" +#include "services/mallocSiteTable.hpp" + +/* + * Early os::malloc() calls come from initializations of static variables, long before entering any + * VM code. Upon the arrival of the first os::malloc() call, malloc site hashtable has to be + * initialized, along with the allocation site for the hashtable entries. + * To ensure that malloc site hashtable can be initialized without triggering any additional os::malloc() + * call, the hashtable bucket array and hashtable entry allocation site have to be static. + * It is not a problem for hashtable bucket, since it is an array of pointer type, C runtime just + * allocates a block memory and zero the memory for it. + * But for hashtable entry allocation site object, things get tricky. C runtime not only allocates + * memory for it, but also calls its constructor at some later time. If we initialize the allocation site + * at the first os::malloc() call, the object will be reinitialized when its constructor is called + * by C runtime. + * To workaround above issue, we declare a static size_t array with the size of the CallsiteHashtableEntry, + * the memory is used to instantiate CallsiteHashtableEntry for the hashtable entry allocation site. + * Given it is a primitive type array, C runtime will do nothing other than assign the memory block for the variable, + * which is exactly what we want. + * The same trick is also applied to create NativeCallStack object for CallsiteHashtableEntry memory allocation. + * + * Note: C++ object usually aligns to particular alignment, depends on compiler implementation, we declare + * the memory as size_t arrays, to ensure the memory is aligned to native machine word alignment. + */ + +// Reserve enough memory for NativeCallStack and MallocSiteHashtableEntry objects +size_t MallocSiteTable::_hash_entry_allocation_stack[CALC_OBJ_SIZE_IN_TYPE(NativeCallStack, size_t)]; +size_t MallocSiteTable::_hash_entry_allocation_site[CALC_OBJ_SIZE_IN_TYPE(MallocSiteHashtableEntry, size_t)]; + +// Malloc site hashtable buckets +MallocSiteHashtableEntry* MallocSiteTable::_table[MallocSiteTable::table_size]; + +// concurrent access counter +volatile int MallocSiteTable::_access_count = 0; + +// Tracking hashtable contention +NOT_PRODUCT(int MallocSiteTable::_peak_count = 0;) + + +/* + * Initialize malloc site table. + * Hashtable entry is malloc'd, so it can cause infinite recursion. + * To avoid above problem, we pre-initialize a hash entry for + * this allocation site. + * The method is called during C runtime static variable initialization + * time, it is in single-threaded mode from JVM perspective. + */ +bool MallocSiteTable::initialize() { + assert(sizeof(_hash_entry_allocation_stack) >= sizeof(NativeCallStack), "Sanity Check"); + assert(sizeof(_hash_entry_allocation_site) >= sizeof(MallocSiteHashtableEntry), + "Sanity Check"); + assert((size_t)table_size <= MAX_MALLOCSITE_TABLE_SIZE, "Hashtable overflow"); + + // Fake the call stack for hashtable entry allocation + assert(NMT_TrackingStackDepth > 1, "At least one tracking stack"); + + // Create pseudo call stack for hashtable entry allocation + address pc[3]; + if (NMT_TrackingStackDepth >= 3) { + pc[2] = (address)MallocSiteTable::allocation_at; + } + if (NMT_TrackingStackDepth >= 2) { + pc[1] = (address)MallocSiteTable::lookup_or_add; + } + pc[0] = (address)MallocSiteTable::new_entry; + + // Instantiate NativeCallStack object, have to use placement new operator. (see comments above) + NativeCallStack* stack = ::new ((void*)_hash_entry_allocation_stack) + NativeCallStack(pc, MIN2(((int)(sizeof(pc) / sizeof(address))), ((int)NMT_TrackingStackDepth))); + + // Instantiate hash entry for hashtable entry allocation callsite + MallocSiteHashtableEntry* entry = ::new ((void*)_hash_entry_allocation_site) + MallocSiteHashtableEntry(*stack); + + // Add the allocation site to hashtable. + int index = hash_to_index(stack->hash()); + _table[index] = entry; + + return true; +} + +// Walks entries in the hashtable. +// It stops walk if the walker returns false. +bool MallocSiteTable::walk(MallocSiteWalker* walker) { + MallocSiteHashtableEntry* head; + for (int index = 0; index < table_size; index ++) { + head = _table[index]; + while (head != NULL) { + if (!walker->do_malloc_site(head->peek())) { + return false; + } + head = (MallocSiteHashtableEntry*)head->next(); + } + } + return true; +} + +/* + * The hashtable does not have deletion policy on individual entry, + * and each linked list node is inserted via compare-and-swap, + * so each linked list is stable, the contention only happens + * at the end of linked list. + * This method should not return NULL under normal circumstance. + * If NULL is returned, it indicates: + * 1. Out of memory, it cannot allocate new hash entry. + * 2. Overflow hash bucket. + * Under any of above circumstances, caller should handle the situation. + */ +MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, + size_t* pos_idx) { + int index = hash_to_index(key.hash()); + assert(index >= 0, "Negative index"); + *bucket_idx = (size_t)index; + *pos_idx = 0; + + // First entry for this hash bucket + if (_table[index] == NULL) { + MallocSiteHashtableEntry* entry = new_entry(key); + // OOM check + if (entry == NULL) return NULL; + + // swap in the head + if (Atomic::cmpxchg_ptr((void*)entry, (volatile void *)&_table[index], NULL) == NULL) { + return entry->data(); + } + + delete entry; + } + + MallocSiteHashtableEntry* head = _table[index]; + while (head != NULL && (*pos_idx) <= MAX_BUCKET_LENGTH) { + MallocSite* site = head->data(); + if (site->equals(key)) { + // found matched entry + return head->data(); + } + + if (head->next() == NULL && (*pos_idx) < MAX_BUCKET_LENGTH) { + MallocSiteHashtableEntry* entry = new_entry(key); + // OOM check + if (entry == NULL) return NULL; + if (head->atomic_insert(entry)) { + (*pos_idx) ++; + return entry->data(); + } + // contended, other thread won + delete entry; + } + head = (MallocSiteHashtableEntry*)head->next(); + (*pos_idx) ++; + } + return NULL; +} + +// Access malloc site +MallocSite* MallocSiteTable::malloc_site(size_t bucket_idx, size_t pos_idx) { + assert(bucket_idx < table_size, "Invalid bucket index"); + MallocSiteHashtableEntry* head = _table[bucket_idx]; + for (size_t index = 0; index < pos_idx && head != NULL; + index ++, head = (MallocSiteHashtableEntry*)head->next()); + assert(head != NULL, "Invalid position index"); + return head->data(); +} + +// Allocates MallocSiteHashtableEntry object. Special call stack +// (pre-installed allocation site) has to be used to avoid infinite +// recursion. +MallocSiteHashtableEntry* MallocSiteTable::new_entry(const NativeCallStack& key) { + void* p = AllocateHeap(sizeof(MallocSiteHashtableEntry), mtNMT, + *hash_entry_allocation_stack(), AllocFailStrategy::RETURN_NULL); + return ::new (p) MallocSiteHashtableEntry(key); +} + +void MallocSiteTable::reset() { + for (int index = 0; index < table_size; index ++) { + MallocSiteHashtableEntry* head = _table[index]; + _table[index] = NULL; + delete_linked_list(head); + } +} + +void MallocSiteTable::delete_linked_list(MallocSiteHashtableEntry* head) { + MallocSiteHashtableEntry* p; + while (head != NULL) { + p = head; + head = (MallocSiteHashtableEntry*)head->next(); + if (p != (MallocSiteHashtableEntry*)_hash_entry_allocation_site) { + delete p; + } + } +} + +void MallocSiteTable::shutdown() { + AccessLock locker(&_access_count); + locker.exclusiveLock(); + reset(); +} + +bool MallocSiteTable::walk_malloc_site(MallocSiteWalker* walker) { + assert(walker != NULL, "NuLL walker"); + AccessLock locker(&_access_count); + if (locker.sharedLock()) { + NOT_PRODUCT(_peak_count = MAX2(_peak_count, _access_count);) + return walk(walker); + } + return false; +} + + +void MallocSiteTable::AccessLock::exclusiveLock() { + jint target; + jint val; + + assert(_lock_state != ExclusiveLock, "Can only call once"); + assert(*_lock >= 0, "Can not content exclusive lock"); + + // make counter negative to block out shared locks + do { + val = *_lock; + target = _MAGIC_ + *_lock; + } while (Atomic::cmpxchg(target, _lock, val) != val); + + // wait for all readers to exit + while (*_lock != _MAGIC_) { +#ifdef _WINDOWS + os::naked_short_sleep(1); +#else + os::naked_yield(); +#endif + } + _lock_state = ExclusiveLock; +} + + diff --git a/hotspot/src/share/vm/services/mallocSiteTable.hpp b/hotspot/src/share/vm/services/mallocSiteTable.hpp new file mode 100644 index 00000000000..e291211cac8 --- /dev/null +++ b/hotspot/src/share/vm/services/mallocSiteTable.hpp @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_MALLOC_SITE_TABLE_HPP +#define SHARE_VM_SERVICES_MALLOC_SITE_TABLE_HPP + +#if INCLUDE_NMT + +#include "memory/allocation.hpp" +#include "runtime/atomic.hpp" +#include "services/allocationSite.hpp" +#include "services/mallocTracker.hpp" +#include "services/nmtCommon.hpp" + +// MallocSite represents a code path that eventually calls +// os::malloc() to allocate memory +class MallocSite : public AllocationSite { + public: + MallocSite() : + AllocationSite(emptyStack) { } + + MallocSite(const NativeCallStack& stack) : + AllocationSite(stack) { } + + void allocate(size_t size) { data()->allocate(size); } + void deallocate(size_t size) { data()->deallocate(size); } + + // Memory allocated from this code path + size_t size() const { return peek()->size(); } + // The number of calls were made + size_t count() const { return peek()->count(); } +}; + +// Malloc site hashtable entry +class MallocSiteHashtableEntry : public CHeapObj { + private: + MallocSite _malloc_site; + MallocSiteHashtableEntry* _next; + + public: + MallocSiteHashtableEntry() : _next(NULL) { } + + MallocSiteHashtableEntry(NativeCallStack stack): + _malloc_site(stack), _next(NULL) { } + + inline const MallocSiteHashtableEntry* next() const { + return _next; + } + + // Insert an entry atomically. + // Return true if the entry is inserted successfully. + // The operation can be failed due to contention from other thread. + bool atomic_insert(const MallocSiteHashtableEntry* entry) { + return (Atomic::cmpxchg_ptr((void*)entry, (volatile void*)&_next, + NULL) == NULL); + } + + void set_callsite(const MallocSite& site) { + _malloc_site = site; + } + + inline const MallocSite* peek() const { return &_malloc_site; } + inline MallocSite* data() { return &_malloc_site; } + + inline long hash() const { return _malloc_site.hash(); } + inline bool equals(const NativeCallStack& stack) const { + return _malloc_site.equals(stack); + } + // Allocation/deallocation on this allocation site + inline void allocate(size_t size) { _malloc_site.allocate(size); } + inline void deallocate(size_t size) { _malloc_site.deallocate(size); } + // Memory counters + inline size_t size() const { return _malloc_site.size(); } + inline size_t count() const { return _malloc_site.count(); } +}; + +// The walker walks every entry on MallocSiteTable +class MallocSiteWalker : public StackObj { + public: + virtual bool do_malloc_site(const MallocSite* e) { return false; } +}; + +/* + * Native memory tracking call site table. + * The table is only needed when detail tracking is enabled. + */ +class MallocSiteTable : AllStatic { + private: + // The number of hash bucket in this hashtable. The number should + // be tuned if malloc activities changed significantly. + // The statistics data can be obtained via Jcmd + // jcmd VM.native_memory statistics. + + // Currently, (number of buckets / number of entires) ratio is + // about 1 / 6 + enum { + table_base_size = 128, // The base size is calculated from statistics to give + // table ratio around 1:6 + table_size = (table_base_size * NMT_TrackingStackDepth - 1) + }; + + + // This is a very special lock, that allows multiple shared accesses (sharedLock), but + // once exclusive access (exclusiveLock) is requested, all shared accesses are + // rejected forever. + class AccessLock : public StackObj { + enum LockState { + NoLock, + SharedLock, + ExclusiveLock + }; + + private: + // A very large negative number. The only possibility to "overflow" + // this number is when there are more than -min_jint threads in + // this process, which is not going to happen in foreseeable future. + const static int _MAGIC_ = min_jint; + + LockState _lock_state; + volatile int* _lock; + public: + AccessLock(volatile int* lock) : + _lock(lock), _lock_state(NoLock) { + } + + ~AccessLock() { + if (_lock_state == SharedLock) { + Atomic::dec((volatile jint*)_lock); + } + } + // Acquire shared lock. + // Return true if shared access is granted. + inline bool sharedLock() { + jint res = Atomic::add(1, _lock); + if (res < 0) { + Atomic::add(-1, _lock); + return false; + } + _lock_state = SharedLock; + return true; + } + // Acquire exclusive lock + void exclusiveLock(); + }; + + public: + static bool initialize(); + static void shutdown(); + + NOT_PRODUCT(static int access_peak_count() { return _peak_count; }) + + // Number of hash buckets + static inline int hash_buckets() { return (int)table_size; } + + // Access and copy a call stack from this table. Shared lock should be + // acquired before access the entry. + static inline bool access_stack(NativeCallStack& stack, size_t bucket_idx, + size_t pos_idx) { + AccessLock locker(&_access_count); + if (locker.sharedLock()) { + NOT_PRODUCT(_peak_count = MAX2(_peak_count, _access_count);) + MallocSite* site = malloc_site(bucket_idx, pos_idx); + if (site != NULL) { + stack = *site->call_stack(); + return true; + } + } + return false; + } + + // Record a new allocation from specified call path. + // Return true if the allocation is recorded successfully, bucket_idx + // and pos_idx are also updated to indicate the entry where the allocation + // information was recorded. + // Return false only occurs under rare scenarios: + // 1. out of memory + // 2. overflow hash bucket + static inline bool allocation_at(const NativeCallStack& stack, size_t size, + size_t* bucket_idx, size_t* pos_idx) { + AccessLock locker(&_access_count); + if (locker.sharedLock()) { + NOT_PRODUCT(_peak_count = MAX2(_peak_count, _access_count);) + MallocSite* site = lookup_or_add(stack, bucket_idx, pos_idx); + if (site != NULL) site->allocate(size); + return site != NULL; + } + return false; + } + + // Record memory deallocation. bucket_idx and pos_idx indicate where the allocation + // information was recorded. + static inline bool deallocation_at(size_t size, size_t bucket_idx, size_t pos_idx) { + AccessLock locker(&_access_count); + if (locker.sharedLock()) { + NOT_PRODUCT(_peak_count = MAX2(_peak_count, _access_count);) + MallocSite* site = malloc_site(bucket_idx, pos_idx); + if (site != NULL) { + site->deallocate(size); + return true; + } + } + return false; + } + + // Walk this table. + static bool walk_malloc_site(MallocSiteWalker* walker); + + private: + static MallocSiteHashtableEntry* new_entry(const NativeCallStack& key); + static void reset(); + + // Delete a bucket linked list + static void delete_linked_list(MallocSiteHashtableEntry* head); + + static MallocSite* lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, size_t* pos_idx); + static MallocSite* malloc_site(size_t bucket_idx, size_t pos_idx); + static bool walk(MallocSiteWalker* walker); + + static inline int hash_to_index(int hash) { + hash = (hash > 0) ? hash : (-hash); + return (hash % table_size); + } + + static inline const NativeCallStack* hash_entry_allocation_stack() { + return (NativeCallStack*)_hash_entry_allocation_stack; + } + + private: + // Counter for counting concurrent access + static volatile int _access_count; + + // The callsite hashtable. It has to be a static table, + // since malloc call can come from C runtime linker. + static MallocSiteHashtableEntry* _table[table_size]; + + + // Reserve enough memory for placing the objects + + // The memory for hashtable entry allocation stack object + static size_t _hash_entry_allocation_stack[CALC_OBJ_SIZE_IN_TYPE(NativeCallStack, size_t)]; + // The memory for hashtable entry allocation callsite object + static size_t _hash_entry_allocation_site[CALC_OBJ_SIZE_IN_TYPE(MallocSiteHashtableEntry, size_t)]; + NOT_PRODUCT(static int _peak_count;) +}; + +#endif // INCLUDE_NMT +#endif // SHARE_VM_SERVICES_MALLOC_SITE_TABLE_HPP diff --git a/hotspot/src/share/vm/services/mallocTracker.cpp b/hotspot/src/share/vm/services/mallocTracker.cpp new file mode 100644 index 00000000000..d60dd383576 --- /dev/null +++ b/hotspot/src/share/vm/services/mallocTracker.cpp @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#include "precompiled.hpp" + +#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" +#include "services/mallocSiteTable.hpp" +#include "services/mallocTracker.hpp" +#include "services/mallocTracker.inline.hpp" +#include "services/memTracker.hpp" + +size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; + +// Total malloc'd memory amount +size_t MallocMemorySnapshot::total() const { + size_t amount = 0; + for (int index = 0; index < mt_number_of_types; index ++) { + amount += _malloc[index].malloc_size(); + } + amount += _tracking_header.size() + total_arena(); + return amount; +} + +// Total malloc'd memory used by arenas +size_t MallocMemorySnapshot::total_arena() const { + size_t amount = 0; + for (int index = 0; index < mt_number_of_types; index ++) { + amount += _malloc[index].arena_size(); + } + return amount; +} + + +void MallocMemorySnapshot::reset() { + _tracking_header.reset(); + for (int index = 0; index < mt_number_of_types; index ++) { + _malloc[index].reset(); + } +} + +// Make adjustment by subtracting chunks used by arenas +// from total chunks to get total free chunck size +void MallocMemorySnapshot::make_adjustment() { + size_t arena_size = total_arena(); + int chunk_idx = NMTUtil::flag_to_index(mtChunk); + _malloc[chunk_idx].record_free(arena_size); +} + + +void MallocMemorySummary::initialize() { + assert(sizeof(_snapshot) >= sizeof(MallocMemorySnapshot), "Sanity Check"); + // Uses placement new operator to initialize static area. + ::new ((void*)_snapshot)MallocMemorySnapshot(); +} + +void MallocHeader::release() const { + // Tracking already shutdown, no housekeeping is needed anymore + if (MemTracker::tracking_level() <= NMT_minimal) return; + + MallocMemorySummary::record_free(size(), flags()); + MallocMemorySummary::record_free_malloc_header(sizeof(MallocHeader)); + if (tracking_level() == NMT_detail) { + MallocSiteTable::deallocation_at(size(), _bucket_idx, _pos_idx); + } +} + +bool MallocHeader::record_malloc_site(const NativeCallStack& stack, size_t size, + size_t* bucket_idx, size_t* pos_idx) const { + bool ret = MallocSiteTable::allocation_at(stack, size, bucket_idx, pos_idx); + + // Something went wrong, could be OOM or overflow malloc site table. + // We want to keep tracking data under OOM circumstance, so transition to + // summary tracking. + if (!ret) { + MemTracker::transition_to(NMT_summary); + } + return ret; +} + +bool MallocHeader::get_stack(NativeCallStack& stack) const { + return MallocSiteTable::access_stack(stack, _bucket_idx, _pos_idx); +} + +bool MallocTracker::initialize(NMT_TrackingLevel level) { + if (level >= NMT_summary) { + MallocMemorySummary::initialize(); + } + + if (level == NMT_detail) { + return MallocSiteTable::initialize(); + } + return true; +} + +bool MallocTracker::transition(NMT_TrackingLevel from, NMT_TrackingLevel to) { + assert(from != NMT_off, "Can not transition from off state"); + assert(to != NMT_off, "Can not transition to off state"); + if (from == NMT_minimal) { + MallocMemorySummary::reset(); + } + + if (to == NMT_detail) { + assert(from == NMT_minimal || from == NMT_summary, "Just check"); + return MallocSiteTable::initialize(); + } else if (from == NMT_detail) { + assert(to == NMT_minimal || to == NMT_summary, "Just check"); + MallocSiteTable::shutdown(); + } + return true; +} + +// Record a malloc memory allocation +void* MallocTracker::record_malloc(void* malloc_base, size_t size, MEMFLAGS flags, + const NativeCallStack& stack, NMT_TrackingLevel level) { + void* memblock; // the address for user data + MallocHeader* header = NULL; + + if (malloc_base == NULL) { + return NULL; + } + + // Check malloc size, size has to <= MAX_MALLOC_SIZE. This is only possible on 32-bit + // systems, when malloc size >= 1GB, but is is safe to assume it won't happen. + if (size > MAX_MALLOC_SIZE) { + fatal("Should not use malloc for big memory block, use virtual memory instead"); + } + // Uses placement global new operator to initialize malloc header + switch(level) { + case NMT_off: + return malloc_base; + case NMT_minimal: { + MallocHeader* hdr = ::new (malloc_base) MallocHeader(); + break; + } + case NMT_summary: { + header = ::new (malloc_base) MallocHeader(size, flags); + break; + } + case NMT_detail: { + header = ::new (malloc_base) MallocHeader(size, flags, stack); + break; + } + default: + ShouldNotReachHere(); + } + memblock = (void*)((char*)malloc_base + sizeof(MallocHeader)); + + // The alignment check: 8 bytes alignment for 32 bit systems. + // 16 bytes alignment for 64-bit systems. + assert(((size_t)memblock & (sizeof(size_t) * 2 - 1)) == 0, "Alignment check"); + + // Sanity check + assert(get_memory_tracking_level(memblock) == level, + "Wrong tracking level"); + +#ifdef ASSERT + if (level > NMT_minimal) { + // Read back + assert(get_size(memblock) == size, "Wrong size"); + assert(get_flags(memblock) == flags, "Wrong flags"); + } +#endif + + return memblock; +} + +void* MallocTracker::record_free(void* memblock) { + // Never turned on + if (MemTracker::tracking_level() == NMT_off || + memblock == NULL) { + return memblock; + } + MallocHeader* header = malloc_header(memblock); + header->release(); + + return (void*)header; +} + + diff --git a/hotspot/src/share/vm/services/mallocTracker.hpp b/hotspot/src/share/vm/services/mallocTracker.hpp new file mode 100644 index 00000000000..3b84270477b --- /dev/null +++ b/hotspot/src/share/vm/services/mallocTracker.hpp @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_MALLOC_TRACKER_HPP +#define SHARE_VM_SERVICES_MALLOC_TRACKER_HPP + +#if INCLUDE_NMT + +#include "memory/allocation.hpp" +#include "runtime/atomic.hpp" +#include "services/nmtCommon.hpp" +#include "utilities/nativeCallStack.hpp" + +/* + * This counter class counts memory allocation and deallocation, + * records total memory allocation size and number of allocations. + * The counters are updated atomically. + */ +class MemoryCounter VALUE_OBJ_CLASS_SPEC { + private: + size_t _count; + size_t _size; + + DEBUG_ONLY(size_t _peak_count;) + DEBUG_ONLY(size_t _peak_size; ) + + public: + MemoryCounter() : _count(0), _size(0) { + DEBUG_ONLY(_peak_count = 0;) + DEBUG_ONLY(_peak_size = 0;) + } + + // Reset counters + void reset() { + _size = 0; + _count = 0; + DEBUG_ONLY(_peak_size = 0;) + DEBUG_ONLY(_peak_count = 0;) + } + + inline void allocate(size_t sz) { + Atomic::add(1, (volatile MemoryCounterType*)&_count); + if (sz > 0) { + Atomic::add((MemoryCounterType)sz, (volatile MemoryCounterType*)&_size); + DEBUG_ONLY(_peak_size = MAX2(_peak_size, _size)); + } + DEBUG_ONLY(_peak_count = MAX2(_peak_count, _count);) + } + + inline void deallocate(size_t sz) { + assert(_count > 0, "Negative counter"); + assert(_size >= sz, "Negative size"); + Atomic::add(-1, (volatile MemoryCounterType*)&_count); + if (sz > 0) { + Atomic::add(-(MemoryCounterType)sz, (volatile MemoryCounterType*)&_size); + } + } + + inline void resize(long sz) { + if (sz != 0) { + Atomic::add((MemoryCounterType)sz, (volatile MemoryCounterType*)&_size); + DEBUG_ONLY(_peak_size = MAX2(_size, _peak_size);) + } + } + + inline size_t count() const { return _count; } + inline size_t size() const { return _size; } + DEBUG_ONLY(inline size_t peak_count() const { return _peak_count; }) + DEBUG_ONLY(inline size_t peak_size() const { return _peak_size; }) + +}; + +/* + * Malloc memory used by a particular subsystem. + * It includes the memory acquired through os::malloc() + * call and arena's backing memory. + */ +class MallocMemory VALUE_OBJ_CLASS_SPEC { + private: + MemoryCounter _malloc; + MemoryCounter _arena; + + public: + MallocMemory() { } + + inline void record_malloc(size_t sz) { + _malloc.allocate(sz); + } + + inline void record_free(size_t sz) { + _malloc.deallocate(sz); + } + + inline void record_new_arena() { + _arena.allocate(0); + } + + inline void record_arena_free() { + _arena.deallocate(0); + } + + inline void record_arena_size_change(long sz) { + _arena.resize(sz); + } + + void reset() { + _malloc.reset(); + _arena.reset(); + } + + inline size_t malloc_size() const { return _malloc.size(); } + inline size_t malloc_count() const { return _malloc.count();} + inline size_t arena_size() const { return _arena.size(); } + inline size_t arena_count() const { return _arena.count(); } + + DEBUG_ONLY(inline const MemoryCounter& malloc_counter() const { return _malloc; }) + DEBUG_ONLY(inline const MemoryCounter& arena_counter() const { return _arena; }) +}; + +class MallocMemorySummary; + +// A snapshot of malloc'd memory, includes malloc memory +// usage by types and memory used by tracking itself. +class MallocMemorySnapshot : public ResourceObj { + friend class MallocMemorySummary; + + private: + MallocMemory _malloc[mt_number_of_types]; + MemoryCounter _tracking_header; + + + public: + inline MallocMemory* by_type(MEMFLAGS flags) { + int index = NMTUtil::flag_to_index(flags); + return &_malloc[index]; + } + + inline MallocMemory* by_index(int index) { + assert(index >= 0, "Index out of bound"); + assert(index < mt_number_of_types, "Index out of bound"); + return &_malloc[index]; + } + + inline MemoryCounter* malloc_overhead() { + return &_tracking_header; + } + + // Total malloc'd memory amount + size_t total() const; + // Total malloc'd memory used by arenas + size_t total_arena() const; + + inline size_t thread_count() { + return by_type(mtThreadStack)->malloc_count(); + } + + void reset(); + + void copy_to(MallocMemorySnapshot* s) { + s->_tracking_header = _tracking_header; + for (int index = 0; index < mt_number_of_types; index ++) { + s->_malloc[index] = _malloc[index]; + } + } + + // Make adjustment by subtracting chunks used by arenas + // from total chunks to get total free chunk size + void make_adjustment(); +}; + +/* + * This class is for collecting malloc statistics at summary level + */ +class MallocMemorySummary : AllStatic { + private: + // Reserve memory for placement of MallocMemorySnapshot object + static size_t _snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; + + public: + static void initialize(); + + static inline void record_malloc(size_t size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->record_malloc(size); + } + + static inline void record_free(size_t size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->record_free(size); + } + + static inline void record_new_arena(MEMFLAGS flag) { + as_snapshot()->by_type(flag)->record_new_arena(); + } + + static inline void record_arena_free(MEMFLAGS flag) { + as_snapshot()->by_type(flag)->record_arena_free(); + } + + static inline void record_arena_size_change(long size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->record_arena_size_change(size); + } + + static void snapshot(MallocMemorySnapshot* s) { + as_snapshot()->copy_to(s); + s->make_adjustment(); + } + + // Record memory used by malloc tracking header + static inline void record_new_malloc_header(size_t sz) { + as_snapshot()->malloc_overhead()->allocate(sz); + } + + static inline void record_free_malloc_header(size_t sz) { + as_snapshot()->malloc_overhead()->deallocate(sz); + } + + // The memory used by malloc tracking headers + static inline size_t tracking_overhead() { + return as_snapshot()->malloc_overhead()->size(); + } + + // Reset all counters to zero + static void reset() { + as_snapshot()->reset(); + } + + static MallocMemorySnapshot* as_snapshot() { + return (MallocMemorySnapshot*)_snapshot; + } +}; + + +/* + * Malloc tracking header. + * To satisfy malloc alignment requirement, NMT uses 2 machine words for tracking purpose, + * which ensures 8-bytes alignment on 32-bit systems and 16-bytes on 64-bit systems (Product build). + */ + +class MallocHeader VALUE_OBJ_CLASS_SPEC { +#ifdef _LP64 + size_t _size : 62; + size_t _level : 2; + size_t _flags : 8; + size_t _pos_idx : 16; + size_t _bucket_idx: 40; +#define MAX_MALLOCSITE_TABLE_SIZE ((size_t)1 << 40) +#define MAX_BUCKET_LENGTH ((size_t)(1 << 16)) +#define MAX_MALLOC_SIZE (((size_t)1 << 62) - 1) +#else + size_t _size : 30; + size_t _level : 2; + size_t _flags : 8; + size_t _pos_idx : 8; + size_t _bucket_idx: 16; +#define MAX_MALLOCSITE_TABLE_SIZE ((size_t)(1 << 16)) +#define MAX_BUCKET_LENGTH ((size_t)(1 << 8)) +// Max malloc size = 1GB - 1 on 32 bit system, such has total 4GB memory +#define MAX_MALLOC_SIZE ((size_t)(1 << 30) - 1) +#endif // _LP64 + + public: + // Summary tracking header + MallocHeader(size_t size, MEMFLAGS flags) { + assert(sizeof(MallocHeader) == sizeof(void*) * 2, + "Wrong header size"); + + _level = NMT_summary; + _flags = flags; + set_size(size); + MallocMemorySummary::record_malloc(size, flags); + MallocMemorySummary::record_new_malloc_header(sizeof(MallocHeader)); + } + // Detail tracking header + MallocHeader(size_t size, MEMFLAGS flags, const NativeCallStack& stack) { + assert(sizeof(MallocHeader) == sizeof(void*) * 2, + "Wrong header size"); + + _level = NMT_detail; + _flags = flags; + set_size(size); + size_t bucket_idx; + size_t pos_idx; + if (record_malloc_site(stack, size, &bucket_idx, &pos_idx)) { + assert(bucket_idx <= MAX_MALLOCSITE_TABLE_SIZE, "Overflow bucket index"); + assert(pos_idx <= MAX_BUCKET_LENGTH, "Overflow bucket position index"); + _bucket_idx = bucket_idx; + _pos_idx = pos_idx; + } + MallocMemorySummary::record_malloc(size, flags); + MallocMemorySummary::record_new_malloc_header(sizeof(MallocHeader)); + } + // Minimal tracking header + MallocHeader() { + assert(sizeof(MallocHeader) == sizeof(void*) * 2, + "Wrong header size"); + + _level = (unsigned short)NMT_minimal; + } + + inline NMT_TrackingLevel tracking_level() const { + return (NMT_TrackingLevel)_level; + } + + inline size_t size() const { return _size; } + inline MEMFLAGS flags() const { return (MEMFLAGS)_flags; } + bool get_stack(NativeCallStack& stack) const; + + // Cleanup tracking information before the memory is released. + void release() const; + + private: + inline void set_size(size_t size) { + assert(size <= MAX_MALLOC_SIZE, "Malloc size too large, should use virtual memory?"); + _size = size; + } + bool record_malloc_site(const NativeCallStack& stack, size_t size, + size_t* bucket_idx, size_t* pos_idx) const; +}; + + +// Main class called from MemTracker to track malloc activities +class MallocTracker : AllStatic { + public: + // Initialize malloc tracker for specific tracking level + static bool initialize(NMT_TrackingLevel level); + + static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to); + + // malloc tracking header size for specific tracking level + static inline size_t malloc_header_size(NMT_TrackingLevel level) { + return (level == NMT_off) ? 0 : sizeof(MallocHeader); + } + + // Parameter name convention: + // memblock : the beginning address for user data + // malloc_base: the beginning address that includes malloc tracking header + // + // The relationship: + // memblock = (char*)malloc_base + sizeof(nmt header) + // + + // Record malloc on specified memory block + static void* record_malloc(void* malloc_base, size_t size, MEMFLAGS flags, + const NativeCallStack& stack, NMT_TrackingLevel level); + + // Record free on specified memory block + static void* record_free(void* memblock); + + // Get tracking level of specified memory block + static inline NMT_TrackingLevel get_memory_tracking_level(void* memblock); + + + // Offset memory address to header address + static inline void* get_base(void* memblock); + static inline void* get_base(void* memblock, NMT_TrackingLevel level) { + if (memblock == NULL || level == NMT_off) return memblock; + return (char*)memblock - malloc_header_size(level); + } + + // Get memory size + static inline size_t get_size(void* memblock) { + MallocHeader* header = malloc_header(memblock); + assert(header->tracking_level() >= NMT_summary, + "Wrong tracking level"); + return header->size(); + } + + // Get memory type + static inline MEMFLAGS get_flags(void* memblock) { + MallocHeader* header = malloc_header(memblock); + assert(header->tracking_level() >= NMT_summary, + "Wrong tracking level"); + return header->flags(); + } + + // Get header size + static inline size_t get_header_size(void* memblock) { + return (memblock == NULL) ? 0 : sizeof(MallocHeader); + } + + static inline void record_new_arena(MEMFLAGS flags) { + MallocMemorySummary::record_new_arena(flags); + } + + static inline void record_arena_free(MEMFLAGS flags) { + MallocMemorySummary::record_arena_free(flags); + } + + static inline void record_arena_size_change(int size, MEMFLAGS flags) { + MallocMemorySummary::record_arena_size_change(size, flags); + } + private: + static inline MallocHeader* malloc_header(void *memblock) { + assert(memblock != NULL, "NULL pointer"); + MallocHeader* header = (MallocHeader*)((char*)memblock - sizeof(MallocHeader)); + assert(header->tracking_level() >= NMT_minimal, "Bad header"); + return header; + } +}; + +#endif // INCLUDE_NMT + + +#endif //SHARE_VM_SERVICES_MALLOC_TRACKER_HPP diff --git a/hotspot/src/share/vm/services/mallocTracker.inline.hpp b/hotspot/src/share/vm/services/mallocTracker.inline.hpp new file mode 100644 index 00000000000..338295b6566 --- /dev/null +++ b/hotspot/src/share/vm/services/mallocTracker.inline.hpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_MALLOC_TRACKER_INLINE_HPP +#define SHARE_VM_SERVICES_MALLOC_TRACKER_INLINE_HPP + +#include "services/mallocTracker.hpp" +#include "services/memTracker.hpp" + +inline NMT_TrackingLevel MallocTracker::get_memory_tracking_level(void* memblock) { + assert(memblock != NULL, "Sanity check"); + if (MemTracker::tracking_level() == NMT_off) return NMT_off; + MallocHeader* header = malloc_header(memblock); + return header->tracking_level(); +} + +inline void* MallocTracker::get_base(void* memblock){ + return get_base(memblock, MemTracker::tracking_level()); +} + +#endif // SHARE_VM_SERVICES_MALLOC_TRACKER_INLINE_HPP + diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index 2d6f2ff1d23..890309fdfc4 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1914,7 +1914,7 @@ void ThreadTimesClosure::do_thread(Thread* thread) { ResourceMark rm(THREAD); // thread->name() uses ResourceArea assert(thread->name() != NULL, "All threads should have a name"); - _names_chars[_count] = strdup(thread->name()); + _names_chars[_count] = os::strdup(thread->name()); _times->long_at_put(_count, os::is_thread_cpu_time_supported() ? os::thread_cpu_time(thread) : -1); _count++; @@ -1932,7 +1932,7 @@ void ThreadTimesClosure::do_unlocked() { ThreadTimesClosure::~ThreadTimesClosure() { for (int i = 0; i < _count; i++) { - free(_names_chars[i]); + os::free(_names_chars[i]); } FREE_C_HEAP_ARRAY(char *, _names_chars, mtInternal); } diff --git a/hotspot/src/share/vm/services/memBaseline.cpp b/hotspot/src/share/vm/services/memBaseline.cpp index 62e51873c7b..26cef4ceebb 100644 --- a/hotspot/src/share/vm/services/memBaseline.cpp +++ b/hotspot/src/share/vm/services/memBaseline.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,471 +22,301 @@ * */ #include "precompiled.hpp" + #include "memory/allocation.hpp" #include "runtime/safepoint.hpp" #include "runtime/thread.inline.hpp" #include "services/memBaseline.hpp" #include "services/memTracker.hpp" +/* + * Sizes are sorted in descenting order for reporting + */ +int compare_malloc_size(const MallocSite& s1, const MallocSite& s2) { + if (s1.size() == s2.size()) { + return 0; + } else if (s1.size() > s2.size()) { + return -1; + } else { + return 1; + } +} -MemType2Name MemBaseline::MemType2NameMap[NUMBER_OF_MEMORY_TYPE] = { - {mtJavaHeap, "Java Heap"}, - {mtClass, "Class"}, - {mtThreadStack,"Thread Stack"}, - {mtThread, "Thread"}, - {mtCode, "Code"}, - {mtGC, "GC"}, - {mtCompiler, "Compiler"}, - {mtInternal, "Internal"}, - {mtOther, "Other"}, - {mtSymbol, "Symbol"}, - {mtNMT, "Memory Tracking"}, - {mtTracing, "Tracing"}, - {mtChunk, "Pooled Free Chunks"}, - {mtClassShared,"Shared spaces for classes"}, - {mtTest, "Test"}, - {mtNone, "Unknown"} // It can happen when type tagging records are lagging - // behind + +int compare_virtual_memory_size(const VirtualMemoryAllocationSite& s1, + const VirtualMemoryAllocationSite& s2) { + if (s1.reserved() == s2.reserved()) { + return 0; + } else if (s1.reserved() > s2.reserved()) { + return -1; + } else { + return 1; + } +} + +// Sort into allocation site addresses order for baseline comparison +int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { + return s1.call_stack()->compare(*s2.call_stack()); +} + + +int compare_virtual_memory_site(const VirtualMemoryAllocationSite& s1, + const VirtualMemoryAllocationSite& s2) { + return s1.call_stack()->compare(*s2.call_stack()); +} + +/* + * Walker to walk malloc allocation site table + */ +class MallocAllocationSiteWalker : public MallocSiteWalker { + private: + SortedLinkedList + _malloc_sites; + size_t _count; + + // Entries in MallocSiteTable with size = 0 and count = 0, + // when the malloc site is not longer there. + public: + MallocAllocationSiteWalker(Arena* arena) : _count(0), _malloc_sites(arena) { + } + + inline size_t count() const { return _count; } + + LinkedList* malloc_sites() { + return &_malloc_sites; + } + + bool do_malloc_site(const MallocSite* site) { + if (site->size() >= MemBaseline::SIZE_THRESHOLD) { + if (_malloc_sites.add(*site) != NULL) { + _count++; + return true; + } else { + return false; // OOM + } + } else { + // malloc site does not meet threshold, ignore and continue + return true; + } + } }; -MemBaseline::MemBaseline() { - _baselined = false; - - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - _malloc_data[index].set_type(MemType2NameMap[index]._flag); - _vm_data[index].set_type(MemType2NameMap[index]._flag); - _arena_data[index].set_type(MemType2NameMap[index]._flag); - } - - _malloc_cs = NULL; - _vm_cs = NULL; - _vm_map = NULL; - - _number_of_classes = 0; - _number_of_threads = 0; +// Compare virtual memory region's base address +int compare_virtual_memory_base(const ReservedMemoryRegion& r1, const ReservedMemoryRegion& r2) { + return r1.compare(r2); } +// Walk all virtual memory regions for baselining +class VirtualMemoryAllocationWalker : public VirtualMemoryWalker { + private: + SortedLinkedList + _virtual_memory_regions; + size_t _count; -void MemBaseline::clear() { - if (_malloc_cs != NULL) { - delete _malloc_cs; - _malloc_cs = NULL; + public: + VirtualMemoryAllocationWalker(Arena* a) : _count(0), _virtual_memory_regions(a) { } - if (_vm_cs != NULL) { - delete _vm_cs; - _vm_cs = NULL; - } - - if (_vm_map != NULL) { - delete _vm_map; - _vm_map = NULL; - } - - reset(); -} - - -void MemBaseline::reset() { - _baselined = false; - _total_vm_reserved = 0; - _total_vm_committed = 0; - _total_malloced = 0; - _number_of_classes = 0; - - if (_malloc_cs != NULL) _malloc_cs->clear(); - if (_vm_cs != NULL) _vm_cs->clear(); - if (_vm_map != NULL) _vm_map->clear(); - - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - _malloc_data[index].clear(); - _vm_data[index].clear(); - _arena_data[index].clear(); - } -} - -MemBaseline::~MemBaseline() { - clear(); -} - -// baseline malloc'd memory records, generate overall summary and summaries by -// memory types -bool MemBaseline::baseline_malloc_summary(const MemPointerArray* malloc_records) { - MemPointerArrayIteratorImpl malloc_itr((MemPointerArray*)malloc_records); - MemPointerRecord* malloc_ptr = (MemPointerRecord*)malloc_itr.current(); - size_t used_arena_size = 0; - int index; - while (malloc_ptr != NULL) { - index = flag2index(FLAGS_TO_MEMORY_TYPE(malloc_ptr->flags())); - size_t size = malloc_ptr->size(); - if (malloc_ptr->is_arena_memory_record()) { - // We do have anonymous arenas, they are either used as value objects, - // which are embedded inside other objects, or used as stack objects. - _arena_data[index].inc(size); - used_arena_size += size; - } else { - _total_malloced += size; - _malloc_data[index].inc(size); - if (malloc_ptr->is_arena_record()) { - // see if arena memory record present - MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next(); - if (next_malloc_ptr != NULL && next_malloc_ptr->is_arena_memory_record()) { - assert(next_malloc_ptr->is_memory_record_of_arena(malloc_ptr), - "Arena records do not match"); - size = next_malloc_ptr->size(); - _arena_data[index].inc(size); - used_arena_size += size; - malloc_itr.next(); - } - } - } - malloc_ptr = (MemPointerRecordEx*)malloc_itr.next(); - } - - // substract used arena size to get size of arena chunk in free list - index = flag2index(mtChunk); - _malloc_data[index].reduce(used_arena_size); - // we really don't know how many chunks in free list, so just set to - // 0 - _malloc_data[index].overwrite_counter(0); - - return true; -} - -// check if there is a safepoint in progress, if so, block the thread -// for the safepoint -void MemBaseline::check_safepoint(JavaThread* thr) { - if (SafepointSynchronize::is_synchronizing()) { - // grab and drop the SR_lock to honor the safepoint protocol - MutexLocker ml(thr->SR_lock()); - } -} - -// baseline mmap'd memory records, generate overall summary and summaries by -// memory types -bool MemBaseline::baseline_vm_summary(const MemPointerArray* vm_records) { - MemPointerArrayIteratorImpl vm_itr((MemPointerArray*)vm_records); - VMMemRegion* vm_ptr = (VMMemRegion*)vm_itr.current(); - int index; - while (vm_ptr != NULL) { - if (vm_ptr->is_reserved_region()) { - index = flag2index(FLAGS_TO_MEMORY_TYPE(vm_ptr->flags())); - // we use the number of thread stack to count threads - if (IS_MEMORY_TYPE(vm_ptr->flags(), mtThreadStack)) { - _number_of_threads ++; - } - _total_vm_reserved += vm_ptr->size(); - _vm_data[index].inc(vm_ptr->size(), 0); - } else { - _total_vm_committed += vm_ptr->size(); - _vm_data[index].inc(0, vm_ptr->size()); - } - vm_ptr = (VMMemRegion*)vm_itr.next(); - } - return true; -} - -// baseline malloc'd memory by callsites, but only the callsites with memory allocation -// over 1KB are stored. -bool MemBaseline::baseline_malloc_details(const MemPointerArray* malloc_records) { - assert(MemTracker::track_callsite(), "detail tracking is off"); - - MemPointerArrayIteratorImpl malloc_itr(const_cast(malloc_records)); - MemPointerRecordEx* malloc_ptr = (MemPointerRecordEx*)malloc_itr.current(); - MallocCallsitePointer malloc_callsite; - - // initailize malloc callsite array - if (_malloc_cs == NULL) { - _malloc_cs = new (std::nothrow) MemPointerArrayImpl(64); - // out of native memory - if (_malloc_cs == NULL || _malloc_cs->out_of_memory()) { - return false; - } - } else { - _malloc_cs->clear(); - } - - MemPointerArray* malloc_data = const_cast(malloc_records); - - // sort into callsite pc order. Details are aggregated by callsites - malloc_data->sort((FN_SORT)malloc_sort_by_pc); - bool ret = true; - - // baseline memory that is totaled over 1 KB - while (malloc_ptr != NULL) { - if (!MemPointerRecord::is_arena_memory_record(malloc_ptr->flags())) { - // skip thread stacks - if (!IS_MEMORY_TYPE(malloc_ptr->flags(), mtThreadStack)) { - if (malloc_callsite.addr() != malloc_ptr->pc()) { - if ((malloc_callsite.amount()/K) > 0) { - if (!_malloc_cs->append(&malloc_callsite)) { - ret = false; - break; - } - } - malloc_callsite = MallocCallsitePointer(malloc_ptr->pc()); - } - malloc_callsite.inc(malloc_ptr->size()); - } - } - malloc_ptr = (MemPointerRecordEx*)malloc_itr.next(); - } - - // restore to address order. Snapshot malloc data is maintained in memory - // address order. - malloc_data->sort((FN_SORT)malloc_sort_by_addr); - - if (!ret) { - return false; - } - // deal with last record - if (malloc_callsite.addr() != 0 && (malloc_callsite.amount()/K) > 0) { - if (!_malloc_cs->append(&malloc_callsite)) { - return false; - } - } - return true; -} - -// baseline mmap'd memory by callsites -bool MemBaseline::baseline_vm_details(const MemPointerArray* vm_records) { - assert(MemTracker::track_callsite(), "detail tracking is off"); - - VMCallsitePointer vm_callsite; - VMCallsitePointer* cur_callsite = NULL; - MemPointerArrayIteratorImpl vm_itr((MemPointerArray*)vm_records); - VMMemRegionEx* vm_ptr = (VMMemRegionEx*)vm_itr.current(); - - // initialize virtual memory map array - if (_vm_map == NULL) { - _vm_map = new (std::nothrow) MemPointerArrayImpl(vm_records->length()); - if (_vm_map == NULL || _vm_map->out_of_memory()) { - return false; - } - } else { - _vm_map->clear(); - } - - // initialize virtual memory callsite array - if (_vm_cs == NULL) { - _vm_cs = new (std::nothrow) MemPointerArrayImpl(64); - if (_vm_cs == NULL || _vm_cs->out_of_memory()) { - return false; - } - } else { - _vm_cs->clear(); - } - - // consolidate virtual memory data - VMMemRegionEx* reserved_rec = NULL; - VMMemRegionEx* committed_rec = NULL; - - // vm_ptr is coming in increasing base address order - while (vm_ptr != NULL) { - if (vm_ptr->is_reserved_region()) { - // consolidate reserved memory regions for virtual memory map. - // The criteria for consolidation is: - // 1. two adjacent reserved memory regions - // 2. belong to the same memory type - // 3. reserved from the same callsite - if (reserved_rec == NULL || - reserved_rec->base() + reserved_rec->size() != vm_ptr->addr() || - FLAGS_TO_MEMORY_TYPE(reserved_rec->flags()) != FLAGS_TO_MEMORY_TYPE(vm_ptr->flags()) || - reserved_rec->pc() != vm_ptr->pc()) { - if (!_vm_map->append(vm_ptr)) { + bool do_allocation_site(const ReservedMemoryRegion* rgn) { + if (rgn->size() >= MemBaseline::SIZE_THRESHOLD) { + if (_virtual_memory_regions.add(*rgn) != NULL) { + _count ++; + return true; + } else { return false; } - // inserted reserved region, we need the pointer to the element in virtual - // memory map array. - reserved_rec = (VMMemRegionEx*)_vm_map->at(_vm_map->length() - 1); - } else { - reserved_rec->expand_region(vm_ptr->addr(), vm_ptr->size()); } - - if (cur_callsite != NULL && !_vm_cs->append(cur_callsite)) { - return false; - } - vm_callsite = VMCallsitePointer(vm_ptr->pc()); - cur_callsite = &vm_callsite; - vm_callsite.inc(vm_ptr->size(), 0); - } else { - // consolidate committed memory regions for virtual memory map - // The criterial is: - // 1. two adjacent committed memory regions - // 2. committed from the same callsite - if (committed_rec == NULL || - committed_rec->base() + committed_rec->size() != vm_ptr->addr() || - committed_rec->pc() != vm_ptr->pc()) { - if (!_vm_map->append(vm_ptr)) { - return false; - } - committed_rec = (VMMemRegionEx*)_vm_map->at(_vm_map->length() - 1); - } else { - committed_rec->expand_region(vm_ptr->addr(), vm_ptr->size()); - } - vm_callsite.inc(0, vm_ptr->size()); - } - vm_ptr = (VMMemRegionEx*)vm_itr.next(); + return true; } - // deal with last record - if (cur_callsite != NULL && !_vm_cs->append(cur_callsite)) { + + LinkedList* virtual_memory_allocations() { + return &_virtual_memory_regions; + } +}; + + +bool MemBaseline::baseline_summary() { + assert(_malloc_memory_snapshot == NULL, "Malloc baseline not yet reset"); + assert(_virtual_memory_snapshot == NULL, "Virtual baseline not yet reset"); + + _malloc_memory_snapshot = new (arena()) MallocMemorySnapshot(); + _virtual_memory_snapshot = new (arena()) VirtualMemorySnapshot(); + if (_malloc_memory_snapshot == NULL || _virtual_memory_snapshot == NULL) { + return false; + } + MallocMemorySummary::snapshot(_malloc_memory_snapshot); + VirtualMemorySummary::snapshot(_virtual_memory_snapshot); + return true; +} + +bool MemBaseline::baseline_allocation_sites() { + assert(arena() != NULL, "Just check"); + // Malloc allocation sites + MallocAllocationSiteWalker malloc_walker(arena()); + if (!MallocSiteTable::walk_malloc_site(&malloc_walker)) { return false; } - // sort it into callsite pc order. Details are aggregated by callsites - _vm_cs->sort((FN_SORT)bl_vm_sort_by_pc); + _malloc_sites.set_head(malloc_walker.malloc_sites()->head()); + // The malloc sites are collected in size order + _malloc_sites_order = by_size; - // walk the array to consolidate record by pc - MemPointerArrayIteratorImpl itr(_vm_cs); - VMCallsitePointer* callsite_rec = (VMCallsitePointer*)itr.current(); - VMCallsitePointer* next_rec = (VMCallsitePointer*)itr.next(); - while (next_rec != NULL) { - assert(callsite_rec != NULL, "Sanity check"); - if (next_rec->addr() == callsite_rec->addr()) { - callsite_rec->inc(next_rec->reserved_amount(), next_rec->committed_amount()); - itr.remove(); - next_rec = (VMCallsitePointer*)itr.current(); - } else { - callsite_rec = next_rec; - next_rec = (VMCallsitePointer*)itr.next(); - } + // Virtual memory allocation sites + VirtualMemoryAllocationWalker virtual_memory_walker(arena()); + if (!VirtualMemoryTracker::walk_virtual_memory(&virtual_memory_walker)) { + return false; + } + + // Virtual memory allocations are collected in call stack order + _virtual_memory_allocations.set_head(virtual_memory_walker.virtual_memory_allocations()->head()); + + if (!aggregate_virtual_memory_allocation_sites()) { + return false; + } + // Virtual memory allocation sites are aggregrated in call stack order + _virtual_memory_sites_order = by_address; + + return true; +} + +bool MemBaseline::baseline(bool summaryOnly) { + if (arena() == NULL) { + _arena = new (std::nothrow, mtNMT) Arena(mtNMT); + if (arena() == NULL) return false; + } + + reset(); + + _class_count = InstanceKlass::number_of_instance_classes(); + + if (!baseline_summary()) { + return false; + } + + _baseline_type = Summary_baselined; + + // baseline details + if (!summaryOnly && + MemTracker::tracking_level() == NMT_detail) { + baseline_allocation_sites(); + _baseline_type = Detail_baselined; } return true; } -// baseline a snapshot. If summary_only = false, memory usages aggregated by -// callsites are also baselined. -// The method call can be lengthy, especially when detail tracking info is -// requested. So the method checks for safepoint explicitly. -bool MemBaseline::baseline(MemSnapshot& snapshot, bool summary_only) { - Thread* THREAD = Thread::current(); - assert(THREAD->is_Java_thread(), "must be a JavaThread"); - MutexLocker snapshot_locker(snapshot._lock); - reset(); - _baselined = baseline_malloc_summary(snapshot._alloc_ptrs); - if (_baselined) { - check_safepoint((JavaThread*)THREAD); - _baselined = baseline_vm_summary(snapshot._vm_ptrs); - } - _number_of_classes = snapshot.number_of_classes(); +int compare_allocation_site(const VirtualMemoryAllocationSite& s1, + const VirtualMemoryAllocationSite& s2) { + return s1.call_stack()->compare(*s2.call_stack()); +} - if (!summary_only && MemTracker::track_callsite() && _baselined) { - check_safepoint((JavaThread*)THREAD); - _baselined = baseline_malloc_details(snapshot._alloc_ptrs); - if (_baselined) { - check_safepoint((JavaThread*)THREAD); - _baselined = baseline_vm_details(snapshot._vm_ptrs); +bool MemBaseline::aggregate_virtual_memory_allocation_sites() { + SortedLinkedList + allocation_sites(arena()); + + VirtualMemoryAllocationIterator itr = virtual_memory_allocations(); + const ReservedMemoryRegion* rgn; + VirtualMemoryAllocationSite* site; + while ((rgn = itr.next()) != NULL) { + VirtualMemoryAllocationSite tmp(*rgn->call_stack()); + site = allocation_sites.find(tmp); + if (site == NULL) { + LinkedListNode* node = + allocation_sites.add(tmp); + if (node == NULL) return false; + site = node->data(); } - } - return _baselined; -} - - -int MemBaseline::flag2index(MEMFLAGS flag) const { - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - if (MemType2NameMap[index]._flag == flag) { - return index; - } - } - assert(false, "no type"); - return -1; -} - -const char* MemBaseline::type2name(MEMFLAGS type) { - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - if (MemType2NameMap[index]._flag == type) { - return MemType2NameMap[index]._name; - } - } - assert(false, err_msg("bad type %x", type)); - return NULL; -} - - -MemBaseline& MemBaseline::operator=(const MemBaseline& other) { - _total_malloced = other._total_malloced; - _total_vm_reserved = other._total_vm_reserved; - _total_vm_committed = other._total_vm_committed; - - _baselined = other._baselined; - _number_of_classes = other._number_of_classes; - - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - _malloc_data[index] = other._malloc_data[index]; - _vm_data[index] = other._vm_data[index]; - _arena_data[index] = other._arena_data[index]; + site->reserve_memory(rgn->size()); + site->commit_memory(rgn->committed_size()); } - if (MemTracker::track_callsite()) { - assert(_malloc_cs != NULL && _vm_cs != NULL, "out of memory"); - assert(other._malloc_cs != NULL && other._vm_cs != NULL, - "not properly baselined"); - _malloc_cs->clear(); - _vm_cs->clear(); - int index; - for (index = 0; index < other._malloc_cs->length(); index ++) { - _malloc_cs->append(other._malloc_cs->at(index)); - } + _virtual_memory_sites.set_head(allocation_sites.head()); + return true; +} - for (index = 0; index < other._vm_cs->length(); index ++) { - _vm_cs->append(other._vm_cs->at(index)); - } +MallocSiteIterator MemBaseline::malloc_sites(SortingOrder order) { + assert(!_malloc_sites.is_empty(), "Detail baseline?"); + switch(order) { + case by_size: + malloc_sites_to_size_order(); + break; + case by_site: + malloc_sites_to_allocation_site_order(); + break; + case by_address: + default: + ShouldNotReachHere(); } - return *this; + return MallocSiteIterator(_malloc_sites.head()); } -/* compare functions for sorting */ - -// sort snapshot malloc'd records in callsite pc order -int MemBaseline::malloc_sort_by_pc(const void* p1, const void* p2) { - assert(MemTracker::track_callsite(),"Just check"); - const MemPointerRecordEx* mp1 = (const MemPointerRecordEx*)p1; - const MemPointerRecordEx* mp2 = (const MemPointerRecordEx*)p2; - return UNSIGNED_COMPARE(mp1->pc(), mp2->pc()); -} - -// sort baselined malloc'd records in size order -int MemBaseline::bl_malloc_sort_by_size(const void* p1, const void* p2) { - assert(MemTracker::is_on(), "Just check"); - const MallocCallsitePointer* mp1 = (const MallocCallsitePointer*)p1; - const MallocCallsitePointer* mp2 = (const MallocCallsitePointer*)p2; - return UNSIGNED_COMPARE(mp2->amount(), mp1->amount()); -} - -// sort baselined malloc'd records in callsite pc order -int MemBaseline::bl_malloc_sort_by_pc(const void* p1, const void* p2) { - assert(MemTracker::is_on(), "Just check"); - const MallocCallsitePointer* mp1 = (const MallocCallsitePointer*)p1; - const MallocCallsitePointer* mp2 = (const MallocCallsitePointer*)p2; - return UNSIGNED_COMPARE(mp1->addr(), mp2->addr()); +VirtualMemorySiteIterator MemBaseline::virtual_memory_sites(SortingOrder order) { + assert(!_virtual_memory_sites.is_empty(), "Detail baseline?"); + switch(order) { + case by_size: + virtual_memory_sites_to_size_order(); + break; + case by_site: + virtual_memory_sites_to_reservation_site_order(); + break; + case by_address: + default: + ShouldNotReachHere(); + } + return VirtualMemorySiteIterator(_virtual_memory_sites.head()); } -// sort baselined mmap'd records in size (reserved size) order -int MemBaseline::bl_vm_sort_by_size(const void* p1, const void* p2) { - assert(MemTracker::is_on(), "Just check"); - const VMCallsitePointer* mp1 = (const VMCallsitePointer*)p1; - const VMCallsitePointer* mp2 = (const VMCallsitePointer*)p2; - return UNSIGNED_COMPARE(mp2->reserved_amount(), mp1->reserved_amount()); +// Sorting allocations sites in different orders +void MemBaseline::malloc_sites_to_size_order() { + if (_malloc_sites_order != by_size) { + SortedLinkedList + tmp(arena()); + + // Add malloc sites to sorted linked list to sort into size order + tmp.move(&_malloc_sites); + _malloc_sites.set_head(tmp.head()); + tmp.set_head(NULL); + _malloc_sites_order = by_size; + } } -// sort baselined mmap'd records in callsite pc order -int MemBaseline::bl_vm_sort_by_pc(const void* p1, const void* p2) { - assert(MemTracker::is_on(), "Just check"); - const VMCallsitePointer* mp1 = (const VMCallsitePointer*)p1; - const VMCallsitePointer* mp2 = (const VMCallsitePointer*)p2; - return UNSIGNED_COMPARE(mp1->addr(), mp2->addr()); +void MemBaseline::malloc_sites_to_allocation_site_order() { + if (_malloc_sites_order != by_site) { + SortedLinkedList + tmp(arena()); + // Add malloc sites to sorted linked list to sort into site (address) order + tmp.move(&_malloc_sites); + _malloc_sites.set_head(tmp.head()); + tmp.set_head(NULL); + _malloc_sites_order = by_site; + } } +void MemBaseline::virtual_memory_sites_to_size_order() { + if (_virtual_memory_sites_order != by_size) { + SortedLinkedList + tmp(arena()); -// sort snapshot malloc'd records in memory block address order -int MemBaseline::malloc_sort_by_addr(const void* p1, const void* p2) { - assert(MemTracker::is_on(), "Just check"); - const MemPointerRecord* mp1 = (const MemPointerRecord*)p1; - const MemPointerRecord* mp2 = (const MemPointerRecord*)p2; - int delta = UNSIGNED_COMPARE(mp1->addr(), mp2->addr()); - assert(p1 == p2 || delta != 0, "dup pointer"); - return delta; + tmp.move(&_virtual_memory_sites); + + _virtual_memory_sites.set_head(tmp.head()); + tmp.set_head(NULL); + _virtual_memory_sites_order = by_size; + } +} + +void MemBaseline::virtual_memory_sites_to_reservation_site_order() { + if (_virtual_memory_sites_order != by_size) { + SortedLinkedList + tmp(arena()); + + tmp.add(&_virtual_memory_sites); + + _virtual_memory_sites.set_head(tmp.head()); + tmp.set_head(NULL); + + _virtual_memory_sites_order = by_size; + } } diff --git a/hotspot/src/share/vm/services/memBaseline.hpp b/hotspot/src/share/vm/services/memBaseline.hpp index 864c6cc5724..bf742f8d56a 100644 --- a/hotspot/src/share/vm/services/memBaseline.hpp +++ b/hotspot/src/share/vm/services/memBaseline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,425 +25,205 @@ #ifndef SHARE_VM_SERVICES_MEM_BASELINE_HPP #define SHARE_VM_SERVICES_MEM_BASELINE_HPP +#if INCLUDE_NMT + #include "memory/allocation.hpp" #include "runtime/mutex.hpp" -#include "services/memPtr.hpp" -#include "services/memSnapshot.hpp" +#include "services/mallocSiteTable.hpp" +#include "services/mallocTracker.hpp" +#include "services/nmtCommon.hpp" +#include "services/virtualMemoryTracker.hpp" +#include "utilities/linkedlist.hpp" -// compare unsigned number -#define UNSIGNED_COMPARE(a, b) ((a > b) ? 1 : ((a == b) ? 0 : -1)) +typedef LinkedListIterator MallocSiteIterator; +typedef LinkedListIterator VirtualMemorySiteIterator; +typedef LinkedListIterator VirtualMemoryAllocationIterator; /* - * MallocCallsitePointer and VMCallsitePointer are used - * to baseline memory blocks with their callsite information. - * They are only available when detail tracking is turned - * on. - */ - -/* baselined malloc record aggregated by callsite */ -class MallocCallsitePointer : public MemPointer { - private: - size_t _count; // number of malloc invocation from this callsite - size_t _amount; // total amount of memory malloc-ed from this callsite - - public: - MallocCallsitePointer() { - _count = 0; - _amount = 0; - } - - MallocCallsitePointer(address pc) : MemPointer(pc) { - _count = 0; - _amount = 0; - } - - MallocCallsitePointer& operator=(const MallocCallsitePointer& p) { - MemPointer::operator=(p); - _count = p.count(); - _amount = p.amount(); - return *this; - } - - inline void inc(size_t size) { - _count ++; - _amount += size; - }; - - inline size_t count() const { - return _count; - } - - inline size_t amount() const { - return _amount; - } -}; - -// baselined virtual memory record aggregated by callsite -class VMCallsitePointer : public MemPointer { - private: - size_t _count; // number of invocation from this callsite - size_t _reserved_amount; // total reserved amount - size_t _committed_amount; // total committed amount - - public: - VMCallsitePointer() { - _count = 0; - _reserved_amount = 0; - _committed_amount = 0; - } - - VMCallsitePointer(address pc) : MemPointer(pc) { - _count = 0; - _reserved_amount = 0; - _committed_amount = 0; - } - - VMCallsitePointer& operator=(const VMCallsitePointer& p) { - MemPointer::operator=(p); - _count = p.count(); - _reserved_amount = p.reserved_amount(); - _committed_amount = p.committed_amount(); - return *this; - } - - inline void inc(size_t reserved, size_t committed) { - _count ++; - _reserved_amount += reserved; - _committed_amount += committed; - } - - inline size_t count() const { - return _count; - } - - inline size_t reserved_amount() const { - return _reserved_amount; - } - - inline size_t committed_amount() const { - return _committed_amount; - } -}; - -// maps a memory type flag to readable name -typedef struct _memType2Name { - MEMFLAGS _flag; - const char* _name; -} MemType2Name; - - -// This class aggregates malloc'd records by memory type -class MallocMem VALUE_OBJ_CLASS_SPEC { - private: - MEMFLAGS _type; - - size_t _count; - size_t _amount; - - public: - MallocMem() { - _type = mtNone; - _count = 0; - _amount = 0; - } - - MallocMem(MEMFLAGS flags) { - assert(HAS_VALID_MEMORY_TYPE(flags), "no type"); - _type = FLAGS_TO_MEMORY_TYPE(flags); - _count = 0; - _amount = 0; - } - - inline void set_type(MEMFLAGS flag) { - _type = flag; - } - - inline void clear() { - _count = 0; - _amount = 0; - _type = mtNone; - } - - MallocMem& operator=(const MallocMem& m) { - assert(_type == m.type(), "different type"); - _count = m.count(); - _amount = m.amount(); - return *this; - } - - inline void inc(size_t amt) { - _amount += amt; - _count ++; - } - - inline void reduce(size_t amt) { - assert(_amount >= amt, "Just check"); - _amount -= amt; - } - - inline void overwrite_counter(size_t count) { - _count = count; - } - - inline MEMFLAGS type() const { - return _type; - } - - inline bool is_type(MEMFLAGS flags) const { - return FLAGS_TO_MEMORY_TYPE(flags) == _type; - } - - inline size_t count() const { - return _count; - } - - inline size_t amount() const { - return _amount; - } -}; - -// This class records live arena's memory usage -class ArenaMem : public MallocMem { - public: - ArenaMem(MEMFLAGS typeflag): MallocMem(typeflag) { - } - ArenaMem() { } -}; - -// This class aggregates virtual memory by its memory type -class VMMem VALUE_OBJ_CLASS_SPEC { - private: - MEMFLAGS _type; - - size_t _count; - size_t _reserved_amount; - size_t _committed_amount; - - public: - VMMem() { - _type = mtNone; - _count = 0; - _reserved_amount = 0; - _committed_amount = 0; - } - - VMMem(MEMFLAGS flags) { - assert(HAS_VALID_MEMORY_TYPE(flags), "no type"); - _type = FLAGS_TO_MEMORY_TYPE(flags); - _count = 0; - _reserved_amount = 0; - _committed_amount = 0; - } - - inline void clear() { - _type = mtNone; - _count = 0; - _reserved_amount = 0; - _committed_amount = 0; - } - - inline void set_type(MEMFLAGS flags) { - _type = FLAGS_TO_MEMORY_TYPE(flags); - } - - VMMem& operator=(const VMMem& m) { - assert(_type == m.type(), "different type"); - - _count = m.count(); - _reserved_amount = m.reserved_amount(); - _committed_amount = m.committed_amount(); - return *this; - } - - - inline MEMFLAGS type() const { - return _type; - } - - inline bool is_type(MEMFLAGS flags) const { - return FLAGS_TO_MEMORY_TYPE(flags) == _type; - } - - inline void inc(size_t reserved_amt, size_t committed_amt) { - _reserved_amount += reserved_amt; - _committed_amount += committed_amt; - _count ++; - } - - inline size_t count() const { - return _count; - } - - inline size_t reserved_amount() const { - return _reserved_amount; - } - - inline size_t committed_amount() const { - return _committed_amount; - } -}; - - - -#define NUMBER_OF_MEMORY_TYPE (mt_number_of_types + 1) - -class BaselineReporter; -class BaselineComparisonReporter; - -/* - * This class baselines current memory snapshot. - * A memory baseline summarizes memory usage by memory type, - * aggregates memory usage by callsites when detail tracking - * is on. + * Baseline a memory snapshot */ class MemBaseline VALUE_OBJ_CLASS_SPEC { - friend class BaselineReporter; - friend class BaselineComparisonReporter; + public: + enum BaselineThreshold { + SIZE_THRESHOLD = K // Only allocation size over this threshold will be baselined. + }; + + enum BaselineType { + Not_baselined, + Summary_baselined, + Detail_baselined + }; + + enum SortingOrder { + by_address, // by memory address + by_size, // by memory size + by_site // by call site where the memory is allocated from + }; private: - // overall summaries - size_t _total_malloced; - size_t _total_vm_reserved; - size_t _total_vm_committed; - size_t _number_of_classes; - size_t _number_of_threads; + // All baseline data is stored in this arena + Arena* _arena; - // if it has properly baselined - bool _baselined; + // Summary information + MallocMemorySnapshot* _malloc_memory_snapshot; + VirtualMemorySnapshot* _virtual_memory_snapshot; - // we categorize memory into three categories within the memory type - MallocMem _malloc_data[NUMBER_OF_MEMORY_TYPE]; - VMMem _vm_data[NUMBER_OF_MEMORY_TYPE]; - ArenaMem _arena_data[NUMBER_OF_MEMORY_TYPE]; + size_t _class_count; - // memory records that aggregate memory usage by callsites. - // only available when detail tracking is on. - MemPointerArray* _malloc_cs; - MemPointerArray* _vm_cs; - // virtual memory map - MemPointerArray* _vm_map; + // Allocation sites information + // Malloc allocation sites + LinkedListImpl + _malloc_sites; - private: - static MemType2Name MemType2NameMap[NUMBER_OF_MEMORY_TYPE]; + // All virtual memory allocations + LinkedListImpl + _virtual_memory_allocations; - private: - // should not use copy constructor - MemBaseline(MemBaseline& copy) { ShouldNotReachHere(); } + // Virtual memory allocations by allocation sites, always in by_address + // order + LinkedListImpl + _virtual_memory_sites; - // check and block at a safepoint - static inline void check_safepoint(JavaThread* thr); + SortingOrder _malloc_sites_order; + SortingOrder _virtual_memory_sites_order; + + BaselineType _baseline_type; public: // create a memory baseline - MemBaseline(); - - ~MemBaseline(); - - inline bool baselined() const { - return _baselined; + MemBaseline(): + _baseline_type(Not_baselined), + _class_count(0), + _arena(NULL), + _malloc_memory_snapshot(NULL), + _virtual_memory_snapshot(NULL), + _malloc_sites(NULL) { } - MemBaseline& operator=(const MemBaseline& other); + ~MemBaseline() { + reset(); + if (_arena != NULL) { + delete _arena; + } + } + + bool baseline(bool summaryOnly = true); + + BaselineType baseline_type() const { return _baseline_type; } + + MallocMemorySnapshot* malloc_memory_snapshot() const { + return _malloc_memory_snapshot; + } + + VirtualMemorySnapshot* virtual_memory_snapshot() const { + return _virtual_memory_snapshot; + } + + MallocSiteIterator malloc_sites(SortingOrder order); + VirtualMemorySiteIterator virtual_memory_sites(SortingOrder order); + + // Virtual memory allocation iterator always returns in virtual memory + // base address order. + VirtualMemoryAllocationIterator virtual_memory_allocations() { + assert(!_virtual_memory_allocations.is_empty(), "Not detail baseline"); + return VirtualMemoryAllocationIterator(_virtual_memory_allocations.head()); + } + + // Total reserved memory = total malloc'd memory + total reserved virtual + // memory + size_t total_reserved_memory() const { + assert(baseline_type() != Not_baselined, "Not yet baselined"); + assert(_virtual_memory_snapshot != NULL, "No virtual memory snapshot"); + assert(_malloc_memory_snapshot != NULL, "No malloc memory snapshot"); + size_t amount = _malloc_memory_snapshot->total() + + _virtual_memory_snapshot->total_reserved(); + return amount; + } + + // Total committed memory = total malloc'd memory + total committed + // virtual memory + size_t total_committed_memory() const { + assert(baseline_type() != Not_baselined, "Not yet baselined"); + assert(_virtual_memory_snapshot != NULL, + "Not a snapshot"); + size_t amount = _malloc_memory_snapshot->total() + + _virtual_memory_snapshot->total_committed(); + return amount; + } + + size_t total_arena_memory() const { + assert(baseline_type() != Not_baselined, "Not yet baselined"); + assert(_malloc_memory_snapshot != NULL, "Not yet baselined"); + return _malloc_memory_snapshot->total_arena(); + } + + size_t malloc_tracking_overhead() const { + assert(baseline_type() != Not_baselined, "Not yet baselined"); + return _malloc_memory_snapshot->malloc_overhead()->size(); + } + + const MallocMemory* malloc_memory(MEMFLAGS flag) const { + assert(_malloc_memory_snapshot != NULL, "Not a snapshot"); + return _malloc_memory_snapshot->by_type(flag); + } + + const VirtualMemory* virtual_memory(MEMFLAGS flag) const { + assert(_virtual_memory_snapshot != NULL, "Not a snapshot"); + return _virtual_memory_snapshot->by_type(flag); + } + + + size_t class_count() const { + assert(baseline_type() != Not_baselined, "Not yet baselined"); + return _class_count; + } + + size_t thread_count() const { + assert(baseline_type() != Not_baselined, "Not yet baselined"); + assert(_malloc_memory_snapshot != NULL, "Baselined?"); + return _malloc_memory_snapshot->thread_count(); + } // reset the baseline for reuse - void clear(); + void reset() { + _baseline_type = Not_baselined; + _malloc_memory_snapshot = NULL; + _virtual_memory_snapshot = NULL; + _class_count = 0; - // baseline the snapshot - bool baseline(MemSnapshot& snapshot, bool summary_only = true); + _malloc_sites = NULL; + _virtual_memory_sites = NULL; + _virtual_memory_allocations = NULL; - bool baseline(const MemPointerArray* malloc_records, - const MemPointerArray* vm_records, - bool summary_only = true); - - // total malloc'd memory of specified memory type - inline size_t malloc_amount(MEMFLAGS flag) const { - return _malloc_data[flag2index(flag)].amount(); + if (_arena != NULL) { + _arena->destruct_contents(); + } } - // number of malloc'd memory blocks of specified memory type - inline size_t malloc_count(MEMFLAGS flag) const { - return _malloc_data[flag2index(flag)].count(); - } - // total memory used by arenas of specified memory type - inline size_t arena_amount(MEMFLAGS flag) const { - return _arena_data[flag2index(flag)].amount(); - } - // number of arenas of specified memory type - inline size_t arena_count(MEMFLAGS flag) const { - return _arena_data[flag2index(flag)].count(); - } - // total reserved memory of specified memory type - inline size_t reserved_amount(MEMFLAGS flag) const { - return _vm_data[flag2index(flag)].reserved_amount(); - } - // total committed memory of specified memory type - inline size_t committed_amount(MEMFLAGS flag) const { - return _vm_data[flag2index(flag)].committed_amount(); - } - // total memory (malloc'd + mmap'd + arena) of specified - // memory type - inline size_t total_amount(MEMFLAGS flag) const { - int index = flag2index(flag); - return _malloc_data[index].amount() + - _vm_data[index].reserved_amount() + - _arena_data[index].amount(); - } - - /* overall summaries */ - - // total malloc'd memory in snapshot - inline size_t total_malloc_amount() const { - return _total_malloced; - } - // total mmap'd memory in snapshot - inline size_t total_reserved_amount() const { - return _total_vm_reserved; - } - // total committed memory in snapshot - inline size_t total_committed_amount() const { - return _total_vm_committed; - } - // number of loaded classes - inline size_t number_of_classes() const { - return _number_of_classes; - } - // number of running threads - inline size_t number_of_threads() const { - return _number_of_threads; - } - // lookup human readable name of a memory type - static const char* type2name(MEMFLAGS type); private: - // convert memory flag to the index to mapping table - int flag2index(MEMFLAGS flag) const; + // Baseline summary information + bool baseline_summary(); - // reset baseline values - void reset(); + // Baseline allocation sites (detail tracking only) + bool baseline_allocation_sites(); - // summarize the records in global snapshot - bool baseline_malloc_summary(const MemPointerArray* malloc_records); - bool baseline_vm_summary(const MemPointerArray* vm_records); - bool baseline_malloc_details(const MemPointerArray* malloc_records); - bool baseline_vm_details(const MemPointerArray* vm_records); + // Aggregate virtual memory allocation by allocation sites + bool aggregate_virtual_memory_allocation_sites(); - // print a line of malloc'd memory aggregated by callsite - void print_malloc_callsite(outputStream* st, address pc, size_t size, - size_t count, int diff_amt, int diff_count) const; - // print a line of mmap'd memory aggregated by callsite - void print_vm_callsite(outputStream* st, address pc, size_t rsz, - size_t csz, int diff_rsz, int diff_csz) const; + Arena* arena() { return _arena; } - // sorting functions for raw records - static int malloc_sort_by_pc(const void* p1, const void* p2); - static int malloc_sort_by_addr(const void* p1, const void* p2); + // Sorting allocation sites in different orders + // Sort allocation sites in size order + void malloc_sites_to_size_order(); + // Sort allocation sites in call site address order + void malloc_sites_to_allocation_site_order(); - private: - // sorting functions for baselined records - static int bl_malloc_sort_by_size(const void* p1, const void* p2); - static int bl_vm_sort_by_size(const void* p1, const void* p2); - static int bl_malloc_sort_by_pc(const void* p1, const void* p2); - static int bl_vm_sort_by_pc(const void* p1, const void* p2); + // Sort allocation sites in reserved size order + void virtual_memory_sites_to_size_order(); + // Sort allocation sites in call site address order + void virtual_memory_sites_to_reservation_site_order(); }; +#endif // INCLUDE_NMT #endif // SHARE_VM_SERVICES_MEM_BASELINE_HPP diff --git a/hotspot/src/share/vm/services/memPtr.hpp b/hotspot/src/share/vm/services/memPtr.hpp deleted file mode 100644 index cae454cc318..00000000000 --- a/hotspot/src/share/vm/services/memPtr.hpp +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_SERVICES_MEM_PTR_HPP -#define SHARE_VM_SERVICES_MEM_PTR_HPP - -#include "memory/allocation.hpp" -#include "runtime/os.hpp" -#include "runtime/safepoint.hpp" - -/* - * global sequence generator that generates sequence numbers to serialize - * memory records. - */ -class SequenceGenerator : AllStatic { - public: - static jint next(); - - // peek last sequence number - static jint peek() { - return _seq_number; - } - - // reset sequence number - static void reset() { - assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required"); - _seq_number = 1; - _generation ++; - }; - - static unsigned long current_generation() { return _generation; } - NOT_PRODUCT(static jint max_seq_num() { return _max_seq_number; }) - - private: - static volatile jint _seq_number; - static volatile unsigned long _generation; - NOT_PRODUCT(static jint _max_seq_number; ) -}; - -/* - * followings are the classes that are used to hold memory activity records in different stages. - * MemPointer - * |--------MemPointerRecord - * | - * |----MemPointerRecordEx - * | | - * | |-------SeqMemPointerRecordEx - * | - * |----SeqMemPointerRecord - * | - * |----VMMemRegion - * | - * |-----VMMemRegionEx - * - * - * prefix 'Seq' - sequenced, the record contains a sequence number - * surfix 'Ex' - extension, the record contains a caller's pc - * - * per-thread recorder : SeqMemPointerRecord(Ex) - * snapshot staging : SeqMemPointerRecord(Ex) - * snapshot : MemPointerRecord(Ex) and VMMemRegion(Ex) - * - */ - -/* - * class that wraps an address to a memory block, - * the memory pointer either points to a malloc'd - * memory block, or a mmap'd memory block - */ -class MemPointer VALUE_OBJ_CLASS_SPEC { - public: - MemPointer(): _addr(0) { } - MemPointer(address addr): _addr(addr) { } - - MemPointer(const MemPointer& copy_from) { - _addr = copy_from.addr(); - } - - inline address addr() const { - return _addr; - } - - inline operator address() const { - return addr(); - } - - inline bool operator == (const MemPointer& other) const { - return addr() == other.addr(); - } - - inline MemPointer& operator = (const MemPointer& other) { - _addr = other.addr(); - return *this; - } - - protected: - inline void set_addr(address addr) { _addr = addr; } - - protected: - // memory address - address _addr; -}; - -/* MemPointerRecord records an activityand associated - * attributes on a memory block. - */ -class MemPointerRecord : public MemPointer { - private: - MEMFLAGS _flags; - size_t _size; - -public: - /* extension of MemoryType enum - * see share/vm/memory/allocation.hpp for details. - * - * The tag values are associated to sorting orders, so be - * careful if changes are needed. - * The allocation records should be sorted ahead of tagging - * records, which in turn ahead of deallocation records - */ - enum MemPointerTags { - tag_alloc = 0x0001, // malloc or reserve record - tag_commit = 0x0002, // commit record - tag_type = 0x0003, // tag virtual memory to a memory type - tag_uncommit = 0x0004, // uncommit record - tag_release = 0x0005, // free or release record - tag_size = 0x0006, // arena size - tag_masks = 0x0007, // all tag bits - vmBit = 0x0008 - }; - - /* helper functions to interpret the tagging flags */ - - inline static bool is_allocation_record(MEMFLAGS flags) { - return (flags & tag_masks) == tag_alloc; - } - - inline static bool is_deallocation_record(MEMFLAGS flags) { - return (flags & tag_masks) == tag_release; - } - - inline static bool is_arena_record(MEMFLAGS flags) { - return (flags & (otArena | tag_size)) == otArena; - } - - inline static bool is_arena_memory_record(MEMFLAGS flags) { - return (flags & (otArena | tag_size)) == (otArena | tag_size); - } - - inline static bool is_virtual_memory_record(MEMFLAGS flags) { - return (flags & vmBit) != 0; - } - - inline static bool is_virtual_memory_reserve_record(MEMFLAGS flags) { - return (flags & 0x0F) == (tag_alloc | vmBit); - } - - inline static bool is_virtual_memory_commit_record(MEMFLAGS flags) { - return (flags & 0x0F) == (tag_commit | vmBit); - } - - inline static bool is_virtual_memory_uncommit_record(MEMFLAGS flags) { - return (flags & 0x0F) == (tag_uncommit | vmBit); - } - - inline static bool is_virtual_memory_release_record(MEMFLAGS flags) { - return (flags & 0x0F) == (tag_release | vmBit); - } - - inline static bool is_virtual_memory_type_record(MEMFLAGS flags) { - return (flags & 0x0F) == (tag_type | vmBit); - } - - /* tagging flags */ - inline static MEMFLAGS malloc_tag() { return tag_alloc; } - inline static MEMFLAGS free_tag() { return tag_release; } - inline static MEMFLAGS arena_size_tag() { return tag_size | otArena; } - inline static MEMFLAGS virtual_memory_tag() { return vmBit; } - inline static MEMFLAGS virtual_memory_reserve_tag() { return (tag_alloc | vmBit); } - inline static MEMFLAGS virtual_memory_commit_tag() { return (tag_commit | vmBit); } - inline static MEMFLAGS virtual_memory_uncommit_tag(){ return (tag_uncommit | vmBit); } - inline static MEMFLAGS virtual_memory_release_tag() { return (tag_release | vmBit); } - inline static MEMFLAGS virtual_memory_type_tag() { return (tag_type | vmBit); } - - public: - MemPointerRecord(): _size(0), _flags(mtNone) { } - - MemPointerRecord(address addr, MEMFLAGS memflags, size_t size = 0): - MemPointer(addr), _flags(memflags), _size(size) { } - - MemPointerRecord(const MemPointerRecord& copy_from): - MemPointer(copy_from), _flags(copy_from.flags()), - _size(copy_from.size()) { - } - - /* MemPointerRecord is not sequenced, it always return - * 0 to indicate non-sequenced - */ - virtual jint seq() const { return 0; } - - inline size_t size() const { return _size; } - inline void set_size(size_t size) { _size = size; } - - inline MEMFLAGS flags() const { return _flags; } - inline void set_flags(MEMFLAGS flags) { _flags = flags; } - - MemPointerRecord& operator= (const MemPointerRecord& ptr) { - MemPointer::operator=(ptr); - _flags = ptr.flags(); -#ifdef ASSERT - if (IS_ARENA_OBJ(_flags)) { - assert(!is_vm_pointer(), "wrong flags"); - assert((_flags & ot_masks) == otArena, "wrong flags"); - } -#endif - _size = ptr.size(); - return *this; - } - - // if the pointer represents a malloc-ed memory address - inline bool is_malloced_pointer() const { - return !is_vm_pointer(); - } - - // if the pointer represents a virtual memory address - inline bool is_vm_pointer() const { - return is_virtual_memory_record(_flags); - } - - // if this record records a 'malloc' or virtual memory - // 'reserve' call - inline bool is_allocation_record() const { - return is_allocation_record(_flags); - } - - // if this record records a size information of an arena - inline bool is_arena_memory_record() const { - return is_arena_memory_record(_flags); - } - - // if this pointer represents an address to an arena object - inline bool is_arena_record() const { - return is_arena_record(_flags); - } - - // if this record represents a size information of specific arena - inline bool is_memory_record_of_arena(const MemPointerRecord* arena_rc) { - assert(is_arena_memory_record(), "not size record"); - assert(arena_rc->is_arena_record(), "not arena record"); - return (arena_rc->addr() + sizeof(void*)) == addr(); - } - - // if this record records a 'free' or virtual memory 'free' call - inline bool is_deallocation_record() const { - return is_deallocation_record(_flags); - } - - // if this record records a virtual memory 'commit' call - inline bool is_commit_record() const { - return is_virtual_memory_commit_record(_flags); - } - - // if this record records a virtual memory 'uncommit' call - inline bool is_uncommit_record() const { - return is_virtual_memory_uncommit_record(_flags); - } - - // if this record is a tagging record of a virtual memory block - inline bool is_type_tagging_record() const { - return is_virtual_memory_type_record(_flags); - } - - // if the two memory pointer records actually represent the same - // memory block - inline bool is_same_region(const MemPointerRecord* other) const { - return (addr() == other->addr() && size() == other->size()); - } - - // if this memory region fully contains another one - inline bool contains_region(const MemPointerRecord* other) const { - return contains_region(other->addr(), other->size()); - } - - // if this memory region fully contains specified memory range - inline bool contains_region(address add, size_t sz) const { - return (addr() <= add && addr() + size() >= add + sz); - } - - inline bool contains_address(address add) const { - return (addr() <= add && addr() + size() > add); - } - - // if this memory region overlaps another region - inline bool overlaps_region(const MemPointerRecord* other) const { - assert(other != NULL, "Just check"); - assert(size() > 0 && other->size() > 0, "empty range"); - return contains_address(other->addr()) || - contains_address(other->addr() + other->size() - 1) || // exclude end address - other->contains_address(addr()) || - other->contains_address(addr() + size() - 1); // exclude end address - } - -}; - -// MemPointerRecordEx also records callsite pc, from where -// the memory block is allocated -class MemPointerRecordEx : public MemPointerRecord { - private: - address _pc; // callsite pc - - public: - MemPointerRecordEx(): _pc(0) { } - - MemPointerRecordEx(address addr, MEMFLAGS memflags, size_t size = 0, address pc = 0): - MemPointerRecord(addr, memflags, size), _pc(pc) {} - - MemPointerRecordEx(const MemPointerRecordEx& copy_from): - MemPointerRecord(copy_from), _pc(copy_from.pc()) {} - - inline address pc() const { return _pc; } - - void init(const MemPointerRecordEx* mpe) { - MemPointerRecord::operator=(*mpe); - _pc = mpe->pc(); - } - - void init(const MemPointerRecord* mp) { - MemPointerRecord::operator=(*mp); - _pc = 0; - } -}; - -// a virtual memory region. The region can represent a reserved -// virtual memory region or a committed memory region -class VMMemRegion : public MemPointerRecord { -public: - VMMemRegion() { } - - void init(const MemPointerRecord* mp) { - assert(mp->is_vm_pointer(), "Sanity check"); - _addr = mp->addr(); - set_size(mp->size()); - set_flags(mp->flags()); - } - - VMMemRegion& operator=(const VMMemRegion& other) { - MemPointerRecord::operator=(other); - return *this; - } - - inline bool is_reserved_region() const { - return is_allocation_record(); - } - - inline bool is_committed_region() const { - return is_commit_record(); - } - - /* base address of this virtual memory range */ - inline address base() const { - return addr(); - } - - /* tag this virtual memory range to the specified memory type */ - inline void tag(MEMFLAGS f) { - set_flags(flags() | (f & mt_masks)); - } - - // expand this region to also cover specified range. - // The range has to be on either end of the memory region. - void expand_region(address addr, size_t sz) { - if (addr < base()) { - assert(addr + sz == base(), "Sanity check"); - _addr = addr; - set_size(size() + sz); - } else { - assert(base() + size() == addr, "Sanity check"); - set_size(size() + sz); - } - } - - // exclude the specified address range from this region. - // The excluded memory range has to be on either end of this memory - // region. - inline void exclude_region(address add, size_t sz) { - assert(is_reserved_region() || is_committed_region(), "Sanity check"); - assert(addr() != NULL && size() != 0, "Sanity check"); - assert(add >= addr() && add < addr() + size(), "Sanity check"); - assert(add == addr() || (add + sz) == (addr() + size()), - "exclude in the middle"); - if (add == addr()) { - set_addr(add + sz); - set_size(size() - sz); - } else { - set_size(size() - sz); - } - } -}; - -class VMMemRegionEx : public VMMemRegion { - private: - jint _seq; // sequence number - - public: - VMMemRegionEx(): _pc(0) { } - - void init(const MemPointerRecordEx* mpe) { - VMMemRegion::init(mpe); - _pc = mpe->pc(); - } - - void init(const MemPointerRecord* mpe) { - VMMemRegion::init(mpe); - _pc = 0; - } - - VMMemRegionEx& operator=(const VMMemRegionEx& other) { - VMMemRegion::operator=(other); - _pc = other.pc(); - return *this; - } - - inline address pc() const { return _pc; } - private: - address _pc; -}; - -/* - * Sequenced memory record - */ -class SeqMemPointerRecord : public MemPointerRecord { - private: - jint _seq; // sequence number - - public: - SeqMemPointerRecord(): _seq(0){ } - - SeqMemPointerRecord(address addr, MEMFLAGS flags, size_t size, jint seq) - : MemPointerRecord(addr, flags, size), _seq(seq) { - } - - SeqMemPointerRecord(const SeqMemPointerRecord& copy_from) - : MemPointerRecord(copy_from) { - _seq = copy_from.seq(); - } - - SeqMemPointerRecord& operator= (const SeqMemPointerRecord& ptr) { - MemPointerRecord::operator=(ptr); - _seq = ptr.seq(); - return *this; - } - - inline jint seq() const { - return _seq; - } -}; - - - -class SeqMemPointerRecordEx : public MemPointerRecordEx { - private: - jint _seq; // sequence number - - public: - SeqMemPointerRecordEx(): _seq(0) { } - - SeqMemPointerRecordEx(address addr, MEMFLAGS flags, size_t size, - jint seq, address pc): - MemPointerRecordEx(addr, flags, size, pc), _seq(seq) { - } - - SeqMemPointerRecordEx(const SeqMemPointerRecordEx& copy_from) - : MemPointerRecordEx(copy_from) { - _seq = copy_from.seq(); - } - - SeqMemPointerRecordEx& operator= (const SeqMemPointerRecordEx& ptr) { - MemPointerRecordEx::operator=(ptr); - _seq = ptr.seq(); - return *this; - } - - inline jint seq() const { - return _seq; - } -}; - -#endif // SHARE_VM_SERVICES_MEM_PTR_HPP diff --git a/hotspot/src/share/vm/services/memPtrArray.hpp b/hotspot/src/share/vm/services/memPtrArray.hpp deleted file mode 100644 index b3e48f6868e..00000000000 --- a/hotspot/src/share/vm/services/memPtrArray.hpp +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -#ifndef SHARE_VM_UTILITIES_MEM_PTR_ARRAY_HPP -#define SHARE_VM_UTILITIES_MEM_PTR_ARRAY_HPP - -#include "memory/allocation.hpp" -#include "services/memPtr.hpp" - -class MemPtr; -class MemRecorder; -class ArenaInfo; -class MemSnapshot; - -extern "C" { - typedef int (*FN_SORT)(const void *, const void *); -} - - -// Memory pointer array interface. This array is used by NMT to hold -// various memory block information. -// The memory pointer arrays are usually walked with their iterators. - -class MemPointerArray : public CHeapObj { - public: - virtual ~MemPointerArray() { } - - // return true if it can not allocate storage for the data - virtual bool out_of_memory() const = 0; - virtual bool is_empty() const = 0; - virtual bool is_full() = 0; - virtual int length() const = 0; - virtual void clear() = 0; - virtual bool append(MemPointer* ptr) = 0; - virtual bool insert_at(MemPointer* ptr, int pos) = 0; - virtual bool remove_at(int pos) = 0; - virtual MemPointer* at(int index) const = 0; - virtual void sort(FN_SORT fn) = 0; - virtual size_t instance_size() const = 0; - virtual bool shrink() = 0; - - NOT_PRODUCT(virtual int capacity() const = 0;) -}; - -// Iterator interface -class MemPointerArrayIterator VALUE_OBJ_CLASS_SPEC { - public: - // return the pointer at current position - virtual MemPointer* current() const = 0; - // return the next pointer and advance current position - virtual MemPointer* next() = 0; - // return next pointer without advancing current position - virtual MemPointer* peek_next() const = 0; - // return previous pointer without changing current position - virtual MemPointer* peek_prev() const = 0; - // remove the pointer at current position - virtual void remove() = 0; - // insert the pointer at current position - virtual bool insert(MemPointer* ptr) = 0; - // insert specified element after current position and - // move current position to newly inserted position - virtual bool insert_after(MemPointer* ptr) = 0; -}; - -// implementation class -class MemPointerArrayIteratorImpl : public MemPointerArrayIterator { - protected: - MemPointerArray* _array; - int _pos; - - public: - MemPointerArrayIteratorImpl(MemPointerArray* arr) { - assert(arr != NULL, "Parameter check"); - _array = arr; - _pos = 0; - } - - virtual MemPointer* current() const { - if (_pos < _array->length()) { - return _array->at(_pos); - } - return NULL; - } - - virtual MemPointer* next() { - if (_pos + 1 < _array->length()) { - return _array->at(++_pos); - } - _pos = _array->length(); - return NULL; - } - - virtual MemPointer* peek_next() const { - if (_pos + 1 < _array->length()) { - return _array->at(_pos + 1); - } - return NULL; - } - - virtual MemPointer* peek_prev() const { - if (_pos > 0) { - return _array->at(_pos - 1); - } - return NULL; - } - - virtual void remove() { - if (_pos < _array->length()) { - _array->remove_at(_pos); - } - } - - virtual bool insert(MemPointer* ptr) { - return _array->insert_at(ptr, _pos); - } - - virtual bool insert_after(MemPointer* ptr) { - if (_array->insert_at(ptr, _pos + 1)) { - _pos ++; - return true; - } - return false; - } -}; - - - -// Memory pointer array implementation. -// This implementation implements expandable array -#define DEFAULT_PTR_ARRAY_SIZE 1024 - -template class MemPointerArrayImpl : public MemPointerArray { - private: - int _max_size; - int _size; - bool _init_elements; - E* _data; - - public: - MemPointerArrayImpl(int initial_size = DEFAULT_PTR_ARRAY_SIZE, bool init_elements = true): - _max_size(initial_size), _size(0), _init_elements(init_elements) { - _data = (E*)raw_allocate(sizeof(E), initial_size); - if (_init_elements) { - for (int index = 0; index < _max_size; index ++) { - ::new ((void*)&_data[index]) E(); - } - } - } - - virtual ~MemPointerArrayImpl() { - if (_data != NULL) { - raw_free(_data); - } - } - - public: - bool out_of_memory() const { - return (_data == NULL); - } - - size_t instance_size() const { - return sizeof(MemPointerArrayImpl) + _max_size * sizeof(E); - } - - bool is_empty() const { - assert(_data != NULL, "Just check"); - return _size == 0; - } - - bool is_full() { - assert(_data != NULL, "Just check"); - if (_size < _max_size) { - return false; - } else { - return !expand_array(); - } - } - - int length() const { - assert(_data != NULL, "Just check"); - return _size; - } - - NOT_PRODUCT(int capacity() const { return _max_size; }) - - void clear() { - assert(_data != NULL, "Just check"); - _size = 0; - } - - bool append(MemPointer* ptr) { - assert(_data != NULL, "Just check"); - if (is_full()) { - return false; - } - _data[_size ++] = *(E*)ptr; - return true; - } - - bool insert_at(MemPointer* ptr, int pos) { - assert(_data != NULL, "Just check"); - if (is_full()) { - return false; - } - for (int index = _size; index > pos; index --) { - _data[index] = _data[index - 1]; - } - _data[pos] = *(E*)ptr; - _size ++; - return true; - } - - bool remove_at(int pos) { - assert(_data != NULL, "Just check"); - if (_size <= pos && pos >= 0) { - return false; - } - -- _size; - - for (int index = pos; index < _size; index ++) { - _data[index] = _data[index + 1]; - } - return true; - } - - MemPointer* at(int index) const { - assert(_data != NULL, "Just check"); - assert(index >= 0 && index < _size, "illegal index"); - return &_data[index]; - } - - bool shrink() { - float used = ((float)_size) / ((float)_max_size); - if (used < 0.40) { - E* old_ptr = _data; - int new_size = ((_max_size) / (2 * DEFAULT_PTR_ARRAY_SIZE) + 1) * DEFAULT_PTR_ARRAY_SIZE; - _data = (E*)raw_reallocate(_data, sizeof(E), new_size); - if (_data == NULL) { - _data = old_ptr; - return false; - } else { - _max_size = new_size; - return true; - } - } - return false; - } - - void sort(FN_SORT fn) { - assert(_data != NULL, "Just check"); - qsort((void*)_data, _size, sizeof(E), fn); - } - - private: - bool expand_array() { - assert(_data != NULL, "Not yet allocated"); - E* old_ptr = _data; - if ((_data = (E*)raw_reallocate((void*)_data, sizeof(E), - _max_size + DEFAULT_PTR_ARRAY_SIZE)) == NULL) { - _data = old_ptr; - return false; - } else { - _max_size += DEFAULT_PTR_ARRAY_SIZE; - if (_init_elements) { - for (int index = _size; index < _max_size; index ++) { - ::new ((void*)&_data[index]) E(); - } - } - return true; - } - } - - void* raw_allocate(size_t elementSize, int items) { - return os::malloc(elementSize * items, mtNMT); - } - - void* raw_reallocate(void* ptr, size_t elementSize, int items) { - return os::realloc(ptr, elementSize * items, mtNMT); - } - - void raw_free(void* ptr) { - os::free(ptr, mtNMT); - } -}; - -#endif // SHARE_VM_UTILITIES_MEM_PTR_ARRAY_HPP diff --git a/hotspot/src/share/vm/services/memRecorder.cpp b/hotspot/src/share/vm/services/memRecorder.cpp deleted file mode 100644 index b8707f58360..00000000000 --- a/hotspot/src/share/vm/services/memRecorder.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" - -#include "runtime/atomic.inline.hpp" -#include "services/memBaseline.hpp" -#include "services/memRecorder.hpp" -#include "services/memPtr.hpp" -#include "services/memTracker.hpp" - -MemPointer* SequencedRecordIterator::next_record() { - MemPointerRecord* itr_cur = (MemPointerRecord*)_itr.current(); - if (itr_cur == NULL) { - return itr_cur; - } - - MemPointerRecord* itr_next = (MemPointerRecord*)_itr.next(); - - // don't collapse virtual memory records - while (itr_next != NULL && !itr_cur->is_vm_pointer() && - !itr_next->is_vm_pointer() && - same_kind(itr_cur, itr_next)) { - itr_cur = itr_next; - itr_next = (MemPointerRecord*)_itr.next(); - } - - return itr_cur; -} - - -volatile jint MemRecorder::_instance_count = 0; - -MemRecorder::MemRecorder() { - assert(MemTracker::is_on(), "Native memory tracking is off"); - Atomic::inc(&_instance_count); - set_generation(); - - if (MemTracker::track_callsite()) { - _pointer_records = new (std::nothrow)FixedSizeMemPointerArray(); - } else { - _pointer_records = new (std::nothrow)FixedSizeMemPointerArray(); - } - _next = NULL; - - - if (_pointer_records != NULL) { - // recode itself - address pc = CURRENT_PC; - record((address)this, (MemPointerRecord::malloc_tag()|mtNMT|otNMTRecorder), - sizeof(MemRecorder), SequenceGenerator::next(), pc); - record((address)_pointer_records, (MemPointerRecord::malloc_tag()|mtNMT|otNMTRecorder), - _pointer_records->instance_size(), SequenceGenerator::next(), pc); - } -} - -MemRecorder::~MemRecorder() { - if (_pointer_records != NULL) { - if (MemTracker::is_on()) { - MemTracker::record_free((address)_pointer_records, mtNMT); - MemTracker::record_free((address)this, mtNMT); - } - delete _pointer_records; - } - // delete all linked recorders - while (_next != NULL) { - MemRecorder* tmp = _next; - _next = _next->next(); - tmp->set_next(NULL); - delete tmp; - } - Atomic::dec(&_instance_count); -} - -// Sorting order: -// 1. memory block address -// 2. mem pointer record tags -// 3. sequence number -int MemRecorder::sort_record_fn(const void* e1, const void* e2) { - const MemPointerRecord* p1 = (const MemPointerRecord*)e1; - const MemPointerRecord* p2 = (const MemPointerRecord*)e2; - int delta = UNSIGNED_COMPARE(p1->addr(), p2->addr()); - if (delta == 0) { - int df = UNSIGNED_COMPARE((p1->flags() & MemPointerRecord::tag_masks), - (p2->flags() & MemPointerRecord::tag_masks)); - if (df == 0) { - assert(p1->seq() != p2->seq(), "dup seq"); - return p1->seq() - p2->seq(); - } else { - return df; - } - } else { - return delta; - } -} - -bool MemRecorder::record(address p, MEMFLAGS flags, size_t size, jint seq, address pc) { - assert(seq > 0, "No sequence number"); -#ifdef ASSERT - if (MemPointerRecord::is_virtual_memory_record(flags)) { - assert((flags & MemPointerRecord::tag_masks) != 0, "bad virtual memory record"); - } else { - assert((flags & MemPointerRecord::tag_masks) == MemPointerRecord::malloc_tag() || - (flags & MemPointerRecord::tag_masks) == MemPointerRecord::free_tag() || - IS_ARENA_OBJ(flags), - "bad malloc record"); - } - // a recorder should only hold records within the same generation - unsigned long cur_generation = SequenceGenerator::current_generation(); - assert(cur_generation == _generation, - "this thread did not enter sync point"); -#endif - - if (MemTracker::track_callsite()) { - SeqMemPointerRecordEx ap(p, flags, size, seq, pc); - debug_only(check_dup_seq(ap.seq());) - return _pointer_records->append(&ap); - } else { - SeqMemPointerRecord ap(p, flags, size, seq); - debug_only(check_dup_seq(ap.seq());) - return _pointer_records->append(&ap); - } -} - - // iterator for alloc pointers -SequencedRecordIterator MemRecorder::pointer_itr() { - assert(_pointer_records != NULL, "just check"); - _pointer_records->sort((FN_SORT)sort_record_fn); - return SequencedRecordIterator(_pointer_records); -} - - -void MemRecorder::set_generation() { - _generation = SequenceGenerator::current_generation(); -} - -#ifdef ASSERT - -void MemRecorder::check_dup_seq(jint seq) const { - MemPointerArrayIteratorImpl itr(_pointer_records); - MemPointerRecord* rc = (MemPointerRecord*)itr.current(); - while (rc != NULL) { - assert(rc->seq() != seq, "dup seq"); - rc = (MemPointerRecord*)itr.next(); - } -} - -#endif diff --git a/hotspot/src/share/vm/services/memRecorder.hpp b/hotspot/src/share/vm/services/memRecorder.hpp deleted file mode 100644 index 4329dad0267..00000000000 --- a/hotspot/src/share/vm/services/memRecorder.hpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_SERVICES_MEM_RECORDER_HPP -#define SHARE_VM_SERVICES_MEM_RECORDER_HPP - -#include "memory/allocation.hpp" -#include "runtime/os.hpp" -#include "services/memPtrArray.hpp" - -class MemSnapshot; -class MemTracker; -class MemTrackWorker; - -// Fixed size memory pointer array implementation -template class FixedSizeMemPointerArray : - public MemPointerArray { - // This implementation is for memory recorder only - friend class MemRecorder; - - private: - E _data[SIZE]; - int _size; - - protected: - FixedSizeMemPointerArray(bool init_elements = false): - _size(0){ - if (init_elements) { - for (int index = 0; index < SIZE; index ++) { - ::new ((void*)&_data[index]) E(); - } - } - } - - void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() { - // the instance is part of memRecorder, needs to be tagged with 'otNMTRecorder' - // to avoid recursion - return os::malloc(size, (mtNMT | otNMTRecorder)); - } - - void* operator new(size_t size) throw() { - assert(false, "use nothrow version"); - return NULL; - } - - void operator delete(void* p) { - os::free(p, (mtNMT | otNMTRecorder)); - } - - // instance size - inline size_t instance_size() const { - return sizeof(FixedSizeMemPointerArray); - } - - NOT_PRODUCT(int capacity() const { return SIZE; }) - - public: - // implementation of public interface - bool out_of_memory() const { return false; } - bool is_empty() const { return _size == 0; } - bool is_full() { return length() >= SIZE; } - int length() const { return _size; } - - void clear() { - _size = 0; - } - - bool append(MemPointer* ptr) { - if (is_full()) return false; - _data[_size ++] = *(E*)ptr; - return true; - } - - virtual bool insert_at(MemPointer* p, int pos) { - assert(false, "append only"); - return false; - } - - virtual bool remove_at(int pos) { - assert(false, "not supported"); - return false; - } - - MemPointer* at(int index) const { - assert(index >= 0 && index < length(), - "parameter check"); - return ((E*)&_data[index]); - } - - void sort(FN_SORT fn) { - qsort((void*)_data, _size, sizeof(E), fn); - } - - bool shrink() { - return false; - } -}; - - -// This iterator requires pre-sorted MemPointerArray, which is sorted by: -// 1. address -// 2. allocation type -// 3. sequence number -// During the array walking, iterator collapses pointers with the same -// address and allocation type, and only returns the one with highest -// sequence number. -// -// This is read-only iterator, update methods are asserted. -class SequencedRecordIterator : public MemPointerArrayIterator { - private: - MemPointerArrayIteratorImpl _itr; - MemPointer* _cur; - - public: - SequencedRecordIterator(const MemPointerArray* arr): - _itr(const_cast(arr)) { - _cur = next_record(); - } - - SequencedRecordIterator(const SequencedRecordIterator& itr): - _itr(itr._itr) { - _cur = next_record(); - } - - // return the pointer at current position - virtual MemPointer* current() const { - return _cur; - }; - - // return the next pointer and advance current position - virtual MemPointer* next() { - _cur = next_record(); - return _cur; - } - - // return the next pointer without advancing current position - virtual MemPointer* peek_next() const { - assert(false, "not implemented"); - return NULL; - - } - // return the previous pointer without changing current position - virtual MemPointer* peek_prev() const { - assert(false, "not implemented"); - return NULL; - } - - // remove the pointer at current position - virtual void remove() { - assert(false, "read-only iterator"); - }; - // insert the pointer at current position - virtual bool insert(MemPointer* ptr) { - assert(false, "read-only iterator"); - return false; - } - - virtual bool insert_after(MemPointer* ptr) { - assert(false, "read-only iterator"); - return false; - } - private: - // collapse the 'same kind' of records, and return this 'kind' of - // record with highest sequence number - MemPointer* next_record(); - - // Test if the two records are the same kind: the same memory block and allocation - // type. - inline bool same_kind(const MemPointerRecord* p1, const MemPointerRecord* p2) const { - assert(!p1->is_vm_pointer() && !p2->is_vm_pointer(), "malloc pointer only"); - return (p1->addr() == p2->addr() && - (p1->flags() &MemPointerRecord::tag_masks) == - (p2->flags() & MemPointerRecord::tag_masks)); - } -}; - - - -#define DEFAULT_RECORDER_PTR_ARRAY_SIZE 512 - -class MemRecorder : public CHeapObj { - friend class MemSnapshot; - friend class MemTracker; - friend class MemTrackWorker; - friend class GenerationData; - - protected: - // the array that holds memory records - MemPointerArray* _pointer_records; - - private: - // used for linked list - MemRecorder* _next; - // active recorder can only record a certain generation data - unsigned long _generation; - - protected: - _NOINLINE_ MemRecorder(); - ~MemRecorder(); - - // record a memory operation - bool record(address addr, MEMFLAGS flags, size_t size, jint seq, address caller_pc = 0); - - // linked list support - inline void set_next(MemRecorder* rec) { - _next = rec; - } - - inline MemRecorder* next() const { - return _next; - } - - // if the recorder is full - inline bool is_full() const { - assert(_pointer_records != NULL, "just check"); - return _pointer_records->is_full(); - } - - // if running out of memory when initializing recorder's internal - // data - inline bool out_of_memory() const { - return (_pointer_records == NULL || - _pointer_records->out_of_memory()); - } - - inline void clear() { - assert(_pointer_records != NULL, "Just check"); - _pointer_records->clear(); - } - - SequencedRecordIterator pointer_itr(); - - // return the generation of this recorder which it belongs to - unsigned long get_generation() const { return _generation; } - protected: - // number of MemRecorder instance - static volatile jint _instance_count; - - private: - // sorting function, sort records into following order - // 1. memory address - // 2. allocation type - // 3. sequence number - static int sort_record_fn(const void* e1, const void* e2); - - debug_only(void check_dup_seq(jint seq) const;) - void set_generation(); -}; - -#endif // SHARE_VM_SERVICES_MEM_RECORDER_HPP diff --git a/hotspot/src/share/vm/services/memReporter.cpp b/hotspot/src/share/vm/services/memReporter.cpp index 305693dad08..0269619178f 100644 --- a/hotspot/src/share/vm/services/memReporter.cpp +++ b/hotspot/src/share/vm/services/memReporter.cpp @@ -22,618 +22,595 @@ * */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" -#include "runtime/os.hpp" + +#include "memory/allocation.hpp" +#include "services/mallocTracker.hpp" #include "services/memReporter.hpp" -#include "services/memPtrArray.hpp" -#include "services/memTracker.hpp" +#include "services/virtualMemoryTracker.hpp" +#include "utilities/globalDefinitions.hpp" -PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC +size_t MemReporterBase::reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const { + return malloc->malloc_size() + malloc->arena_size() + vm->reserved(); +} -const char* BaselineOutputer::memory_unit(size_t scale) { - switch(scale) { - case K: return "KB"; - case M: return "MB"; - case G: return "GB"; +size_t MemReporterBase::committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const { + return malloc->malloc_size() + malloc->arena_size() + vm->committed(); +} + +void MemReporterBase::print_total(size_t reserved, size_t committed) const { + const char* scale = current_scale(); + output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s", + amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); +} + +void MemReporterBase::print_malloc(size_t amount, size_t count) const { + const char* scale = current_scale(); + outputStream* out = output(); + out->print("(malloc=" SIZE_FORMAT "%s", + amount_in_current_scale(amount), scale); + + if (count > 0) { + out->print(" #" SIZE_FORMAT "", count); } - ShouldNotReachHere(); - return NULL; + + out->print(")"); +} + +void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) const { + const char* scale = current_scale(); + output()->print("(mmap: reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s)", + amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); +} + +void MemReporterBase::print_malloc_line(size_t amount, size_t count) const { + output()->print("%28s", " "); + print_malloc(amount, count); + output()->print_cr(" "); +} + +void MemReporterBase::print_virtual_memory_line(size_t reserved, size_t committed) const { + output()->print("%28s", " "); + print_virtual_memory(reserved, committed); + output()->print_cr(" "); +} + +void MemReporterBase::print_arena_line(size_t amount, size_t count) const { + const char* scale = current_scale(); + output()->print_cr("%27s (arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", " ", + amount_in_current_scale(amount), scale, count); +} + +void MemReporterBase::print_virtual_memory_region(const char* type, address base, size_t size) const { + const char* scale = current_scale(); + output()->print("[" PTR_FORMAT " - " PTR_FORMAT "] %s " SIZE_FORMAT "%s", + p2i(base), p2i(base + size), type, amount_in_current_scale(size), scale); } -void BaselineReporter::report_baseline(const MemBaseline& baseline, bool summary_only) { - assert(MemTracker::is_on(), "Native memory tracking is off"); - _outputer.start(scale()); - _outputer.total_usage( - amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_reserved_amount()), - amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_committed_amount())); +void MemSummaryReporter::report() { + const char* scale = current_scale(); + outputStream* out = output(); + size_t total_reserved_amount = _malloc_snapshot->total() + + _vm_snapshot->total_reserved(); + size_t total_committed_amount = _malloc_snapshot->total() + + _vm_snapshot->total_committed(); - _outputer.num_of_classes(baseline.number_of_classes()); - _outputer.num_of_threads(baseline.number_of_threads()); + // Overall total + out->print_cr("\nNative Memory Tracking:\n"); + out->print("Total: "); + print_total(total_reserved_amount, total_committed_amount); + out->print("\n"); - report_summaries(baseline); - if (!summary_only && MemTracker::track_callsite()) { - report_virtual_memory_map(baseline); - report_callsites(baseline); + // Summary by memory type + for (int index = 0; index < mt_number_of_types; index ++) { + MEMFLAGS flag = NMTUtil::index_to_flag(index); + // thread stack is reported as part of thread category + if (flag == mtThreadStack) continue; + MallocMemory* malloc_memory = _malloc_snapshot->by_type(flag); + VirtualMemory* virtual_memory = _vm_snapshot->by_type(flag); + + report_summary_of_type(flag, malloc_memory, virtual_memory); } - _outputer.done(); } -void BaselineReporter::report_summaries(const MemBaseline& baseline) { - _outputer.start_category_summary(); - MEMFLAGS type; +void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, + MallocMemory* malloc_memory, VirtualMemory* virtual_memory) { - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - type = MemBaseline::MemType2NameMap[index]._flag; - _outputer.category_summary(type, - amount_in_current_scale(baseline.reserved_amount(type)), - amount_in_current_scale(baseline.committed_amount(type)), - amount_in_current_scale(baseline.malloc_amount(type)), - baseline.malloc_count(type), - amount_in_current_scale(baseline.arena_amount(type)), - baseline.arena_count(type)); + size_t reserved_amount = reserved_total (malloc_memory, virtual_memory); + size_t committed_amount = committed_total(malloc_memory, virtual_memory); + + // Count thread's native stack in "Thread" category + if (flag == mtThread) { + const VirtualMemory* thread_stack_usage = + (const VirtualMemory*)_vm_snapshot->by_type(mtThreadStack); + reserved_amount += thread_stack_usage->reserved(); + committed_amount += thread_stack_usage->committed(); + } else if (flag == mtNMT) { + // Count malloc headers in "NMT" category + reserved_amount += _malloc_snapshot->malloc_overhead()->size(); + committed_amount += _malloc_snapshot->malloc_overhead()->size(); } - _outputer.done_category_summary(); -} + if (amount_in_current_scale(reserved_amount) > 0) { + outputStream* out = output(); + const char* scale = current_scale(); + out->print("-%26s (", NMTUtil::flag_to_name(flag)); + print_total(reserved_amount, committed_amount); + out->print_cr(")"); -void BaselineReporter::report_virtual_memory_map(const MemBaseline& baseline) { - _outputer.start_virtual_memory_map(); - MemBaseline* pBL = const_cast(&baseline); - MemPointerArrayIteratorImpl itr = MemPointerArrayIteratorImpl(pBL->_vm_map); - VMMemRegionEx* rgn = (VMMemRegionEx*)itr.current(); - while (rgn != NULL) { - if (rgn->is_reserved_region()) { - _outputer.reserved_memory_region(FLAGS_TO_MEMORY_TYPE(rgn->flags()), - rgn->base(), rgn->base() + rgn->size(), amount_in_current_scale(rgn->size()), rgn->pc()); - } else { - _outputer.committed_memory_region(rgn->base(), rgn->base() + rgn->size(), - amount_in_current_scale(rgn->size()), rgn->pc()); + if (flag == mtClass) { + // report class count + out->print_cr("%27s (classes #" SIZE_FORMAT ")", " ", _class_count); + } else if (flag == mtThread) { + // report thread count + out->print_cr("%27s (thread #" SIZE_FORMAT ")", " ", _malloc_snapshot->thread_count()); + const VirtualMemory* thread_stack_usage = + _vm_snapshot->by_type(mtThreadStack); + out->print("%27s (stack: ", " "); + print_total(thread_stack_usage->reserved(), thread_stack_usage->committed()); + out->print_cr(")"); } - rgn = (VMMemRegionEx*)itr.next(); - } - _outputer.done_virtual_memory_map(); + // report malloc'd memory + if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) { + // We don't know how many arena chunks are in used, so don't report the count + size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count(); + print_malloc_line(malloc_memory->malloc_size(), count); + } + + if (amount_in_current_scale(virtual_memory->reserved()) > 0) { + print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed()); + } + + if (amount_in_current_scale(malloc_memory->arena_size()) > 0) { + print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count()); + } + + if (flag == mtNMT && + amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { + out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", + amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); + } + + out->print_cr(" "); + } } -void BaselineReporter::report_callsites(const MemBaseline& baseline) { - _outputer.start_callsite(); - MemBaseline* pBL = const_cast(&baseline); +void MemDetailReporter::report_detail() { + // Start detail report + outputStream* out = output(); + out->print_cr("Details:\n"); - pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_size); - pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_size); - - // walk malloc callsites - MemPointerArrayIteratorImpl malloc_itr(pBL->_malloc_cs); - MallocCallsitePointer* malloc_callsite = - (MallocCallsitePointer*)malloc_itr.current(); - while (malloc_callsite != NULL) { - _outputer.malloc_callsite(malloc_callsite->addr(), - amount_in_current_scale(malloc_callsite->amount()), malloc_callsite->count()); - malloc_callsite = (MallocCallsitePointer*)malloc_itr.next(); - } - - // walk virtual memory callsite - MemPointerArrayIteratorImpl vm_itr(pBL->_vm_cs); - VMCallsitePointer* vm_callsite = (VMCallsitePointer*)vm_itr.current(); - while (vm_callsite != NULL) { - _outputer.virtual_memory_callsite(vm_callsite->addr(), - amount_in_current_scale(vm_callsite->reserved_amount()), - amount_in_current_scale(vm_callsite->committed_amount())); - vm_callsite = (VMCallsitePointer*)vm_itr.next(); - } - pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_pc); - pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_pc); - _outputer.done_callsite(); + report_malloc_sites(); + report_virtual_memory_allocation_sites(); } -void BaselineReporter::diff_baselines(const MemBaseline& cur, const MemBaseline& prev, - bool summary_only) { - assert(MemTracker::is_on(), "Native memory tracking is off"); - _outputer.start(scale()); - size_t total_reserved = cur.total_malloc_amount() + cur.total_reserved_amount(); - size_t total_committed = cur.total_malloc_amount() + cur.total_committed_amount(); +void MemDetailReporter::report_malloc_sites() { + MallocSiteIterator malloc_itr = _baseline.malloc_sites(MemBaseline::by_size); + if (malloc_itr.is_empty()) return; - _outputer.diff_total_usage( - amount_in_current_scale(total_reserved), amount_in_current_scale(total_committed), - diff_in_current_scale(total_reserved, (prev.total_malloc_amount() + prev.total_reserved_amount())), - diff_in_current_scale(total_committed, (prev.total_committed_amount() + prev.total_malloc_amount()))); + outputStream* out = output(); - _outputer.diff_num_of_classes(cur.number_of_classes(), - diff(cur.number_of_classes(), prev.number_of_classes())); - _outputer.diff_num_of_threads(cur.number_of_threads(), - diff(cur.number_of_threads(), prev.number_of_threads())); + const MallocSite* malloc_site; + while ((malloc_site = malloc_itr.next()) != NULL) { + // Don't report if size is too small + if (amount_in_current_scale(malloc_site->size()) == 0) + continue; - diff_summaries(cur, prev); - if (!summary_only && MemTracker::track_callsite()) { - diff_callsites(cur, prev); + const NativeCallStack* stack = malloc_site->call_stack(); + stack->print_on(out); + out->print("%29s", " "); + print_malloc(malloc_site->size(), malloc_site->count()); + out->print_cr("\n"); } - _outputer.done(); } -void BaselineReporter::diff_summaries(const MemBaseline& cur, const MemBaseline& prev) { - _outputer.start_category_summary(); - MEMFLAGS type; +void MemDetailReporter::report_virtual_memory_allocation_sites() { + VirtualMemorySiteIterator virtual_memory_itr = + _baseline.virtual_memory_sites(MemBaseline::by_size); - for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) { - type = MemBaseline::MemType2NameMap[index]._flag; - _outputer.diff_category_summary(type, - amount_in_current_scale(cur.reserved_amount(type)), - amount_in_current_scale(cur.committed_amount(type)), - amount_in_current_scale(cur.malloc_amount(type)), - cur.malloc_count(type), - amount_in_current_scale(cur.arena_amount(type)), - cur.arena_count(type), - diff_in_current_scale(cur.reserved_amount(type), prev.reserved_amount(type)), - diff_in_current_scale(cur.committed_amount(type), prev.committed_amount(type)), - diff_in_current_scale(cur.malloc_amount(type), prev.malloc_amount(type)), - diff(cur.malloc_count(type), prev.malloc_count(type)), - diff_in_current_scale(cur.arena_amount(type), prev.arena_amount(type)), - diff(cur.arena_count(type), prev.arena_count(type))); + if (virtual_memory_itr.is_empty()) return; + + outputStream* out = output(); + const VirtualMemoryAllocationSite* virtual_memory_site; + + while ((virtual_memory_site = virtual_memory_itr.next()) != NULL) { + // Don't report if size is too small + if (amount_in_current_scale(virtual_memory_site->reserved()) == 0) + continue; + + const NativeCallStack* stack = virtual_memory_site->call_stack(); + stack->print_on(out); + out->print("%28s (", " "); + print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); + out->print_cr(")\n"); } - - _outputer.done_category_summary(); } -void BaselineReporter::diff_callsites(const MemBaseline& cur, const MemBaseline& prev) { - _outputer.start_callsite(); - MemBaseline* pBL_cur = const_cast(&cur); - MemBaseline* pBL_prev = const_cast(&prev); - // walk malloc callsites - MemPointerArrayIteratorImpl cur_malloc_itr(pBL_cur->_malloc_cs); - MemPointerArrayIteratorImpl prev_malloc_itr(pBL_prev->_malloc_cs); +void MemDetailReporter::report_virtual_memory_map() { + // Virtual memory map always in base address order + VirtualMemoryAllocationIterator itr = _baseline.virtual_memory_allocations(); + const ReservedMemoryRegion* rgn; - MallocCallsitePointer* cur_malloc_callsite = - (MallocCallsitePointer*)cur_malloc_itr.current(); - MallocCallsitePointer* prev_malloc_callsite = - (MallocCallsitePointer*)prev_malloc_itr.current(); + output()->print_cr("Virtual memory map:"); + while ((rgn = itr.next()) != NULL) { + report_virtual_memory_region(rgn); + } +} - while (cur_malloc_callsite != NULL || prev_malloc_callsite != NULL) { - if (prev_malloc_callsite == NULL) { - assert(cur_malloc_callsite != NULL, "sanity check"); - // this is a new callsite - _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), - amount_in_current_scale(cur_malloc_callsite->amount()), - cur_malloc_callsite->count(), - diff_in_current_scale(cur_malloc_callsite->amount(), 0), - diff(cur_malloc_callsite->count(), 0)); - cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); - } else if (cur_malloc_callsite == NULL) { - assert(prev_malloc_callsite != NULL, "Sanity check"); - // this callsite is already gone - _outputer.diff_malloc_callsite(prev_malloc_callsite->addr(), - 0, 0, - diff_in_current_scale(0, prev_malloc_callsite->amount()), - diff(0, prev_malloc_callsite->count())); - prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); +void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* reserved_rgn) { + assert(reserved_rgn != NULL, "NULL pointer"); + + // Don't report if size is too small + if (amount_in_current_scale(reserved_rgn->size()) == 0) return; + + outputStream* out = output(); + const char* scale = current_scale(); + const NativeCallStack* stack = reserved_rgn->call_stack(); + bool all_committed = reserved_rgn->all_committed(); + const char* region_type = (all_committed ? "reserved and committed" : "reserved"); + out->print_cr(" "); + print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size()); + out->print(" for %s", NMTUtil::flag_to_name(reserved_rgn->flag())); + if (stack->is_empty()) { + out->print_cr(" "); + } else { + out->print_cr(" from"); + stack->print_on(out, 4); + } + + if (all_committed) return; + + CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); + const CommittedMemoryRegion* committed_rgn; + while ((committed_rgn = itr.next()) != NULL) { + // Don't report if size is too small + if (amount_in_current_scale(committed_rgn->size()) == 0) continue; + stack = committed_rgn->call_stack(); + out->print("\n\t"); + print_virtual_memory_region("committed", committed_rgn->base(), committed_rgn->size()); + if (stack->is_empty()) { + out->print_cr(" "); } else { - assert(cur_malloc_callsite != NULL, "Sanity check"); - assert(prev_malloc_callsite != NULL, "Sanity check"); - if (cur_malloc_callsite->addr() < prev_malloc_callsite->addr()) { - // this is a new callsite - _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), - amount_in_current_scale(cur_malloc_callsite->amount()), - cur_malloc_callsite->count(), - diff_in_current_scale(cur_malloc_callsite->amount(), 0), - diff(cur_malloc_callsite->count(), 0)); - cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); - } else if (cur_malloc_callsite->addr() > prev_malloc_callsite->addr()) { - // this callsite is already gone - _outputer.diff_malloc_callsite(prev_malloc_callsite->addr(), - 0, 0, - diff_in_current_scale(0, prev_malloc_callsite->amount()), - diff(0, prev_malloc_callsite->count())); - prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); + out->print_cr(" from"); + stack->print_on(out, 12); + } + } +} + +void MemSummaryDiffReporter::report_diff() { + const char* scale = current_scale(); + outputStream* out = output(); + out->print_cr("\nNative Memory Tracking:\n"); + + // Overall diff + out->print("Total: "); + print_virtual_memory_diff(_current_baseline.total_reserved_memory(), + _current_baseline.total_committed_memory(), _early_baseline.total_reserved_memory(), + _early_baseline.total_committed_memory()); + + out->print_cr("\n"); + + // Summary diff by memory type + for (int index = 0; index < mt_number_of_types; index ++) { + MEMFLAGS flag = NMTUtil::index_to_flag(index); + // thread stack is reported as part of thread category + if (flag == mtThreadStack) continue; + diff_summary_of_type(flag, _early_baseline.malloc_memory(flag), + _early_baseline.virtual_memory(flag), _current_baseline.malloc_memory(flag), + _current_baseline.virtual_memory(flag)); + } +} + +void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, + size_t early_amount, size_t early_count) const { + const char* scale = current_scale(); + outputStream* out = output(); + + out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); + long amount_diff = diff_in_current_scale(current_amount, early_amount); + if (amount_diff != 0) { + out->print(" %+ld%s", amount_diff, scale); + } + if (current_count > 0) { + out->print(" #" SIZE_FORMAT "", current_count); + if (current_count != early_count) { + out->print(" %+d", (int)(current_count - early_count)); + } + } +} + +void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t current_count, + size_t early_amount, size_t early_count) const { + const char* scale = current_scale(); + outputStream* out = output(); + out->print("arena=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); + if (diff_in_current_scale(current_amount, early_amount) != 0) { + out->print(" %+ld", diff_in_current_scale(current_amount, early_amount)); + } + + out->print(" #" SIZE_FORMAT "", current_count); + if (current_count != early_count) { + out->print(" %+d", (int)(current_count - early_count)); + } +} + +void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, size_t current_committed, + size_t early_reserved, size_t early_committed) const { + const char* scale = current_scale(); + outputStream* out = output(); + out->print("reserved=" SIZE_FORMAT "%s", amount_in_current_scale(current_reserved), scale); + long reserved_diff = diff_in_current_scale(current_reserved, early_reserved); + if (reserved_diff != 0) { + out->print(" %+ld%s", reserved_diff, scale); + } + + out->print(", committed=" SIZE_FORMAT "%s", amount_in_current_scale(current_committed), scale); + long committed_diff = diff_in_current_scale(current_committed, early_committed); + if (committed_diff != 0) { + out->print(" %+ld%s", committed_diff, scale); + } +} + + +void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, const MallocMemory* early_malloc, + const VirtualMemory* early_vm, const MallocMemory* current_malloc, + const VirtualMemory* current_vm) const { + + outputStream* out = output(); + const char* scale = current_scale(); + + // Total reserved and committed memory in current baseline + size_t current_reserved_amount = reserved_total (current_malloc, current_vm); + size_t current_committed_amount = committed_total(current_malloc, current_vm); + + // Total reserved and committed memory in early baseline + size_t early_reserved_amount = reserved_total(early_malloc, early_vm); + size_t early_committed_amount = committed_total(early_malloc, early_vm); + + // Adjust virtual memory total + if (flag == mtThread) { + const VirtualMemory* early_thread_stack_usage = + _early_baseline.virtual_memory(mtThreadStack); + const VirtualMemory* current_thread_stack_usage = + _current_baseline.virtual_memory(mtThreadStack); + + early_reserved_amount += early_thread_stack_usage->reserved(); + early_committed_amount += early_thread_stack_usage->committed(); + + current_reserved_amount += current_thread_stack_usage->reserved(); + current_committed_amount += current_thread_stack_usage->committed(); + } else if (flag == mtNMT) { + early_reserved_amount += _early_baseline.malloc_tracking_overhead(); + early_committed_amount += _early_baseline.malloc_tracking_overhead(); + + current_reserved_amount += _current_baseline.malloc_tracking_overhead(); + current_committed_amount += _current_baseline.malloc_tracking_overhead(); + } + + if (amount_in_current_scale(current_reserved_amount) > 0 || + diff_in_current_scale(current_reserved_amount, early_reserved_amount) != 0) { + + // print summary line + out->print("-%26s (", NMTUtil::flag_to_name(flag)); + print_virtual_memory_diff(current_reserved_amount, current_committed_amount, + early_reserved_amount, early_committed_amount); + out->print_cr(")"); + + // detail lines + if (flag == mtClass) { + // report class count + out->print("%27s (classes #" SIZE_FORMAT "", " ", _current_baseline.class_count()); + int class_count_diff = (int)(_current_baseline.class_count() - + _early_baseline.class_count()); + if (_current_baseline.class_count() != _early_baseline.class_count()) { + out->print(" %+d", (int)(_current_baseline.class_count() - _early_baseline.class_count())); + } + out->print_cr(")"); + } else if (flag == mtThread) { + // report thread count + out->print("%27s (thread #" SIZE_FORMAT "", " ", _current_baseline.thread_count()); + int thread_count_diff = (int)(_current_baseline.thread_count() - + _early_baseline.thread_count()); + if (thread_count_diff != 0) { + out->print(" %+d", thread_count_diff); + } + out->print_cr(")"); + + // report thread stack + const VirtualMemory* current_thread_stack = + _current_baseline.virtual_memory(mtThreadStack); + const VirtualMemory* early_thread_stack = + _early_baseline.virtual_memory(mtThreadStack); + + out->print("%27s (stack: ", " "); + print_virtual_memory_diff(current_thread_stack->reserved(), current_thread_stack->committed(), + early_thread_stack->reserved(), early_thread_stack->committed()); + out->print_cr(")"); + } + + // Report malloc'd memory + size_t current_malloc_amount = current_malloc->malloc_size(); + size_t early_malloc_amount = early_malloc->malloc_size(); + if (amount_in_current_scale(current_malloc_amount) > 0 || + diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { + out->print("%28s(", " "); + print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), + early_malloc_amount, early_malloc->malloc_count()); + out->print_cr(")"); + } + + // Report virtual memory + if (amount_in_current_scale(current_vm->reserved()) > 0 || + diff_in_current_scale(current_vm->reserved(), early_vm->reserved()) != 0) { + out->print("%27s (mmap: ", " "); + print_virtual_memory_diff(current_vm->reserved(), current_vm->committed(), + early_vm->reserved(), early_vm->committed()); + out->print_cr(")"); + } + + // Report arena memory + if (amount_in_current_scale(current_malloc->arena_size()) > 0 || + diff_in_current_scale(current_malloc->arena_size(), early_malloc->arena_size()) != 0) { + out->print("%28s(", " "); + print_arena_diff(current_malloc->arena_size(), current_malloc->arena_count(), + early_malloc->arena_size(), early_malloc->arena_count()); + out->print_cr(")"); + } + + // Report native memory tracking overhead + if (flag == mtNMT) { + size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead()); + size_t early_tracking_overhead = amount_in_current_scale(_early_baseline.malloc_tracking_overhead()); + + out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ", + amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale); + + long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(), + _early_baseline.malloc_tracking_overhead()); + if (overhead_diff != 0) { + out->print(" %+ld%s", overhead_diff, scale); + } + out->print_cr(")"); + } + out->print_cr(" "); + } +} + +void MemDetailDiffReporter::report_diff() { + MemSummaryDiffReporter::report_diff(); + diff_malloc_sites(); + diff_virtual_memory_sites(); +} + +void MemDetailDiffReporter::diff_malloc_sites() const { + MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site); + MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site); + + const MallocSite* early_site = early_itr.next(); + const MallocSite* current_site = current_itr.next(); + + while (early_site != NULL || current_site != NULL) { + if (early_site == NULL) { + new_malloc_site(current_site); + current_site = current_itr.next(); + } else if (current_site == NULL) { + old_malloc_site(early_site); + early_site = early_itr.next(); + } else { + int compVal = current_site->call_stack()->compare(*early_site->call_stack()); + if (compVal < 0) { + new_malloc_site(current_site); + current_site = current_itr.next(); + } else if (compVal > 0) { + old_malloc_site(early_site); + early_site = early_itr.next(); } else { - // the same callsite - _outputer.diff_malloc_callsite(cur_malloc_callsite->addr(), - amount_in_current_scale(cur_malloc_callsite->amount()), - cur_malloc_callsite->count(), - diff_in_current_scale(cur_malloc_callsite->amount(), prev_malloc_callsite->amount()), - diff(cur_malloc_callsite->count(), prev_malloc_callsite->count())); - cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next(); - prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next(); + diff_malloc_site(early_site, current_site); + early_site = early_itr.next(); + current_site = current_itr.next(); } } } - - // walk virtual memory callsite - MemPointerArrayIteratorImpl cur_vm_itr(pBL_cur->_vm_cs); - MemPointerArrayIteratorImpl prev_vm_itr(pBL_prev->_vm_cs); - VMCallsitePointer* cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.current(); - VMCallsitePointer* prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.current(); - while (cur_vm_callsite != NULL || prev_vm_callsite != NULL) { - if (prev_vm_callsite == NULL || cur_vm_callsite->addr() < prev_vm_callsite->addr()) { - // this is a new callsite - _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(), - amount_in_current_scale(cur_vm_callsite->reserved_amount()), - amount_in_current_scale(cur_vm_callsite->committed_amount()), - diff_in_current_scale(cur_vm_callsite->reserved_amount(), 0), - diff_in_current_scale(cur_vm_callsite->committed_amount(), 0)); - cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next(); - } else if (cur_vm_callsite == NULL || cur_vm_callsite->addr() > prev_vm_callsite->addr()) { - // this callsite is already gone - _outputer.diff_virtual_memory_callsite(prev_vm_callsite->addr(), - amount_in_current_scale(0), - amount_in_current_scale(0), - diff_in_current_scale(0, prev_vm_callsite->reserved_amount()), - diff_in_current_scale(0, prev_vm_callsite->committed_amount())); - prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next(); - } else { // the same callsite - _outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(), - amount_in_current_scale(cur_vm_callsite->reserved_amount()), - amount_in_current_scale(cur_vm_callsite->committed_amount()), - diff_in_current_scale(cur_vm_callsite->reserved_amount(), prev_vm_callsite->reserved_amount()), - diff_in_current_scale(cur_vm_callsite->committed_amount(), prev_vm_callsite->committed_amount())); - cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next(); - prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next(); - } - } - - _outputer.done_callsite(); } -size_t BaselineReporter::amount_in_current_scale(size_t amt) const { - return (size_t)(((float)amt/(float)_scale) + 0.5); -} +void MemDetailDiffReporter::diff_virtual_memory_sites() const { + VirtualMemorySiteIterator early_itr = _early_baseline.virtual_memory_sites(MemBaseline::by_site); + VirtualMemorySiteIterator current_itr = _current_baseline.virtual_memory_sites(MemBaseline::by_site); -int BaselineReporter::diff_in_current_scale(size_t value1, size_t value2) const { - return (int)(((float)value1 - (float)value2)/((float)_scale) + 0.5); -} + const VirtualMemoryAllocationSite* early_site = early_itr.next(); + const VirtualMemoryAllocationSite* current_site = current_itr.next(); -int BaselineReporter::diff(size_t value1, size_t value2) const { - return ((int)value1 - (int)value2); -} - -void BaselineTTYOutputer::start(size_t scale, bool report_diff) { - _scale = scale; - _output->print_cr(" "); - _output->print_cr("Native Memory Tracking:"); - _output->print_cr(" "); -} - -void BaselineTTYOutputer::done() { - -} - -void BaselineTTYOutputer::total_usage(size_t total_reserved, size_t total_committed) { - const char* unit = memory_unit(_scale); - _output->print_cr("Total: reserved=%d%s, committed=%d%s", - total_reserved, unit, total_committed, unit); -} - -void BaselineTTYOutputer::start_category_summary() { - _output->print_cr(" "); -} - -/** - * report a summary of memory type - */ -void BaselineTTYOutputer::category_summary(MEMFLAGS type, - size_t reserved_amt, size_t committed_amt, size_t malloc_amt, - size_t malloc_count, size_t arena_amt, size_t arena_count) { - - // we report mtThreadStack under mtThread category - if (type == mtThreadStack) { - assert(malloc_amt == 0 && malloc_count == 0 && arena_amt == 0, - "Just check"); - _thread_stack_reserved = reserved_amt; - _thread_stack_committed = committed_amt; - } else { - const char* unit = memory_unit(_scale); - size_t total_reserved = (reserved_amt + malloc_amt + arena_amt); - size_t total_committed = (committed_amt + malloc_amt + arena_amt); - if (type == mtThread) { - total_reserved += _thread_stack_reserved; - total_committed += _thread_stack_committed; - } - - if (total_reserved > 0) { - _output->print_cr("-%26s (reserved=%d%s, committed=%d%s)", - MemBaseline::type2name(type), total_reserved, unit, - total_committed, unit); - - if (type == mtClass) { - _output->print_cr("%27s (classes #%d)", " ", _num_of_classes); - } else if (type == mtThread) { - _output->print_cr("%27s (thread #%d)", " ", _num_of_threads); - _output->print_cr("%27s (stack: reserved=%d%s, committed=%d%s)", " ", - _thread_stack_reserved, unit, _thread_stack_committed, unit); - } - - if (malloc_amt > 0) { - if (type != mtChunk) { - _output->print_cr("%27s (malloc=%d%s, #%d)", " ", malloc_amt, unit, - malloc_count); - } else { - _output->print_cr("%27s (malloc=%d%s)", " ", malloc_amt, unit); - } - } - - if (reserved_amt > 0) { - _output->print_cr("%27s (mmap: reserved=%d%s, committed=%d%s)", - " ", reserved_amt, unit, committed_amt, unit); - } - - if (arena_amt > 0) { - _output->print_cr("%27s (arena=%d%s, #%d)", " ", arena_amt, unit, arena_count); - } - - _output->print_cr(" "); - } - } -} - -void BaselineTTYOutputer::done_category_summary() { - _output->print_cr(" "); -} - - -void BaselineTTYOutputer::start_virtual_memory_map() { - _output->print_cr("Virtual memory map:"); -} - -void BaselineTTYOutputer::reserved_memory_region(MEMFLAGS type, address base, address end, - size_t size, address pc) { - const char* unit = memory_unit(_scale); - char buf[128]; - int offset; - _output->print_cr(" "); - _output->print_cr("[" PTR_FORMAT " - " PTR_FORMAT "] reserved %d%s for %s", base, end, size, unit, - MemBaseline::type2name(type)); - if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { - _output->print_cr("\t\tfrom [%s+0x%x]", buf, offset); - } -} - -void BaselineTTYOutputer::committed_memory_region(address base, address end, size_t size, address pc) { - const char* unit = memory_unit(_scale); - char buf[128]; - int offset; - _output->print("\t[" PTR_FORMAT " - " PTR_FORMAT "] committed %d%s", base, end, size, unit); - if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { - _output->print_cr(" from [%s+0x%x]", buf, offset); - } -} - -void BaselineTTYOutputer::done_virtual_memory_map() { - _output->print_cr(" "); -} - - - -void BaselineTTYOutputer::start_callsite() { - _output->print_cr("Details:"); - _output->print_cr(" "); -} - -void BaselineTTYOutputer::done_callsite() { - _output->print_cr(" "); -} - -void BaselineTTYOutputer::malloc_callsite(address pc, size_t malloc_amt, - size_t malloc_count) { - if (malloc_amt > 0) { - const char* unit = memory_unit(_scale); - char buf[128]; - int offset; - if (pc == 0) { - _output->print("[BOOTSTRAP]%18s", " "); - } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { - _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); - _output->print("%28s", " "); + while (early_site != NULL || current_site != NULL) { + if (early_site == NULL) { + new_virtual_memory_site(current_site); + current_site = current_itr.next(); + } else if (current_site == NULL) { + old_virtual_memory_site(early_site); + early_site = early_itr.next(); } else { - _output->print("[" PTR_FORMAT "]%18s", pc, " "); + int compVal = current_site->call_stack()->compare(*early_site->call_stack()); + if (compVal < 0) { + new_virtual_memory_site(current_site); + current_site = current_itr.next(); + } else if (compVal > 0) { + old_virtual_memory_site(early_site); + early_site = early_itr.next(); + } else { + diff_virtual_memory_site(early_site, current_site); + early_site = early_itr.next(); + current_site = current_itr.next(); + } } - - _output->print_cr("(malloc=%d%s #%d)", malloc_amt, unit, malloc_count); - _output->print_cr(" "); } } -void BaselineTTYOutputer::virtual_memory_callsite(address pc, size_t reserved_amt, - size_t committed_amt) { - if (reserved_amt > 0) { - const char* unit = memory_unit(_scale); - char buf[128]; - int offset; - if (pc == 0) { - _output->print("[BOOTSTRAP]%18s", " "); - } else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { - _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); - _output->print("%28s", " "); - } else { - _output->print("[" PTR_FORMAT "]%18s", pc, " "); - } - _output->print_cr("(mmap: reserved=%d%s, committed=%d%s)", - reserved_amt, unit, committed_amt, unit); - _output->print_cr(" "); - } +void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { + diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), + 0, 0); } -void BaselineTTYOutputer::diff_total_usage(size_t total_reserved, - size_t total_committed, int reserved_diff, int committed_diff) { - const char* unit = memory_unit(_scale); - _output->print_cr("Total: reserved=%d%s %+d%s, committed=%d%s %+d%s", - total_reserved, unit, reserved_diff, unit, total_committed, unit, - committed_diff, unit); +void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { + diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), + malloc_site->count()); } -void BaselineTTYOutputer::diff_category_summary(MEMFLAGS type, - size_t cur_reserved_amt, size_t cur_committed_amt, - size_t cur_malloc_amt, size_t cur_malloc_count, - size_t cur_arena_amt, size_t cur_arena_count, - int reserved_diff, int committed_diff, int malloc_diff, - int malloc_count_diff, int arena_diff, int arena_count_diff) { +void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, + const MallocSite* current) const { + diff_malloc_site(current->call_stack(), current->size(), current->count(), + early->size(), early->count()); +} - if (type == mtThreadStack) { - assert(cur_malloc_amt == 0 && cur_malloc_count == 0 && - cur_arena_amt == 0, "Just check"); - _thread_stack_reserved = cur_reserved_amt; - _thread_stack_committed = cur_committed_amt; - _thread_stack_reserved_diff = reserved_diff; - _thread_stack_committed_diff = committed_diff; - } else { - const char* unit = memory_unit(_scale); - size_t total_reserved = (cur_reserved_amt + cur_malloc_amt + cur_arena_amt); - // nothing to report in this category - if (total_reserved == 0) { +void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, + size_t current_count, size_t early_size, size_t early_count) const { + outputStream* out = output(); + + assert(stack != NULL, "NULL stack"); + + if (diff_in_current_scale(current_size, early_size) == 0) { return; - } - int diff_reserved = (reserved_diff + malloc_diff + arena_diff); - - // category summary - _output->print("-%26s (reserved=%d%s", MemBaseline::type2name(type), - total_reserved, unit); - - if (diff_reserved != 0) { - _output->print(" %+d%s", diff_reserved, unit); - } - - size_t total_committed = cur_committed_amt + cur_malloc_amt + cur_arena_amt; - _output->print(", committed=%d%s", total_committed, unit); - - int total_committed_diff = committed_diff + malloc_diff + arena_diff; - if (total_committed_diff != 0) { - _output->print(" %+d%s", total_committed_diff, unit); - } - - _output->print_cr(")"); - - // special cases - if (type == mtClass) { - _output->print("%27s (classes #%d", " ", _num_of_classes); - if (_num_of_classes_diff != 0) { - _output->print(" %+d", _num_of_classes_diff); - } - _output->print_cr(")"); - } else if (type == mtThread) { - // thread count - _output->print("%27s (thread #%d", " ", _num_of_threads); - if (_num_of_threads_diff != 0) { - _output->print_cr(" %+d)", _num_of_threads_diff); - } else { - _output->print_cr(")"); - } - _output->print("%27s (stack: reserved=%d%s", " ", _thread_stack_reserved, unit); - if (_thread_stack_reserved_diff != 0) { - _output->print(" %+d%s", _thread_stack_reserved_diff, unit); - } - - _output->print(", committed=%d%s", _thread_stack_committed, unit); - if (_thread_stack_committed_diff != 0) { - _output->print(" %+d%s",_thread_stack_committed_diff, unit); - } - - _output->print_cr(")"); - } - - // malloc'd memory - if (cur_malloc_amt > 0) { - _output->print("%27s (malloc=%d%s", " ", cur_malloc_amt, unit); - if (malloc_diff != 0) { - _output->print(" %+d%s", malloc_diff, unit); - } - if (type != mtChunk) { - _output->print(", #%d", cur_malloc_count); - if (malloc_count_diff) { - _output->print(" %+d", malloc_count_diff); - } - } - _output->print_cr(")"); - } - - // mmap'd memory - if (cur_reserved_amt > 0) { - _output->print("%27s (mmap: reserved=%d%s", " ", cur_reserved_amt, unit); - if (reserved_diff != 0) { - _output->print(" %+d%s", reserved_diff, unit); - } - - _output->print(", committed=%d%s", cur_committed_amt, unit); - if (committed_diff != 0) { - _output->print(" %+d%s", committed_diff, unit); - } - _output->print_cr(")"); - } - - // arena memory - if (cur_arena_amt > 0) { - _output->print("%27s (arena=%d%s", " ", cur_arena_amt, unit); - if (arena_diff != 0) { - _output->print(" %+d%s", arena_diff, unit); - } - _output->print(", #%d", cur_arena_count); - if (arena_count_diff != 0) { - _output->print(" %+d", arena_count_diff); - } - _output->print_cr(")"); - } - - _output->print_cr(" "); } + + stack->print_on(out); + out->print("%28s (", " "); + print_malloc_diff(current_size, current_count, + early_size, early_count); + + out->print_cr(")\n"); } -void BaselineTTYOutputer::diff_malloc_callsite(address pc, - size_t cur_malloc_amt, size_t cur_malloc_count, - int malloc_diff, int malloc_count_diff) { - if (malloc_diff != 0) { - const char* unit = memory_unit(_scale); - char buf[128]; - int offset; - if (pc == 0) { - _output->print_cr("[BOOTSTRAP]%18s", " "); - } else { - if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { - _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); - _output->print("%28s", " "); - } else { - _output->print("[" PTR_FORMAT "]%18s", pc, " "); - } - } - _output->print("(malloc=%d%s", cur_malloc_amt, unit); - if (malloc_diff != 0) { - _output->print(" %+d%s", malloc_diff, unit); - } - _output->print(", #%d", cur_malloc_count); - if (malloc_count_diff != 0) { - _output->print(" %+d", malloc_count_diff); - } - _output->print_cr(")"); - _output->print_cr(" "); - } +void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { + diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); } -void BaselineTTYOutputer::diff_virtual_memory_callsite(address pc, - size_t cur_reserved_amt, size_t cur_committed_amt, - int reserved_diff, int committed_diff) { - if (reserved_diff != 0 || committed_diff != 0) { - const char* unit = memory_unit(_scale); - char buf[64]; - int offset; - if (pc == 0) { - _output->print_cr("[BOOSTRAP]%18s", " "); - } else { - if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { - _output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset); - _output->print("%28s", " "); - } else { - _output->print("[" PTR_FORMAT "]%18s", pc, " "); - } - } - - _output->print("(mmap: reserved=%d%s", cur_reserved_amt, unit); - if (reserved_diff != 0) { - _output->print(" %+d%s", reserved_diff, unit); - } - _output->print(", committed=%d%s", cur_committed_amt, unit); - if (committed_diff != 0) { - _output->print(" %+d%s", committed_diff, unit); - } - _output->print_cr(")"); - _output->print_cr(" "); - } +void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { + diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); } + +void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, + const VirtualMemoryAllocationSite* current) const { + diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), + early->reserved(), early->committed()); +} + +void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, + size_t current_committed, size_t early_reserved, size_t early_committed) const { + outputStream* out = output(); + + // no change + if (diff_in_current_scale(current_reserved, early_reserved) == 0 && + diff_in_current_scale(current_committed, early_committed) == 0) { + return; + } + + stack->print_on(out); + out->print("%28s (mmap: ", " "); + print_virtual_memory_diff(current_reserved, current_committed, + early_reserved, early_committed); + + out->print_cr(")\n"); + } + diff --git a/hotspot/src/share/vm/services/memReporter.hpp b/hotspot/src/share/vm/services/memReporter.hpp index 805559b6fba..239fb945b33 100644 --- a/hotspot/src/share/vm/services/memReporter.hpp +++ b/hotspot/src/share/vm/services/memReporter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,262 +25,217 @@ #ifndef SHARE_VM_SERVICES_MEM_REPORTER_HPP #define SHARE_VM_SERVICES_MEM_REPORTER_HPP -#include "runtime/mutexLocker.hpp" -#include "services/memBaseline.hpp" -#include "services/memTracker.hpp" -#include "utilities/ostream.hpp" -#include "utilities/macros.hpp" - #if INCLUDE_NMT +#include "oops/instanceKlass.hpp" +#include "services/memBaseline.hpp" +#include "services/nmtCommon.hpp" +#include "services/mallocTracker.hpp" +#include "services/virtualMemoryTracker.hpp" + /* - * MemBaselineReporter reports data to this outputer class, - * ReportOutputer is responsible for format, store and redirect - * the data to the final destination. - */ -class BaselineOutputer : public StackObj { + * Base class that provides helpers +*/ +class MemReporterBase : public StackObj { + private: + size_t _scale; // report in this scale + outputStream* _output; // destination + public: - // start to report memory usage in specified scale. - // if report_diff = true, the reporter reports baseline comparison - // information. + MemReporterBase(outputStream* out = NULL, size_t scale = K) + : _scale(scale) { + _output = (out == NULL) ? tty : out; + } - virtual void start(size_t scale, bool report_diff = false) = 0; - // Done reporting - virtual void done() = 0; + protected: + inline outputStream* output() const { + return _output; + } + // Current reporting scale + inline const char* current_scale() const { + return NMTUtil::scale_name(_scale); + } + // Convert memory amount in bytes to current reporting scale + inline size_t amount_in_current_scale(size_t amount) const { + return NMTUtil::amount_in_scale(amount, _scale); + } - /* report baseline summary information */ - virtual void total_usage(size_t total_reserved, - size_t total_committed) = 0; - virtual void num_of_classes(size_t classes) = 0; - virtual void num_of_threads(size_t threads) = 0; + // Convert diff amount in bytes to current reporting scale + inline long diff_in_current_scale(size_t s1, size_t s2) const { + long amount = (long)(s1 - s2); + long scale = (long)_scale; + amount = (amount > 0) ? (amount + scale / 2) : (amount - scale / 2); + return amount / scale; + } - virtual void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) = 0; - - /* report baseline summary comparison */ - virtual void diff_total_usage(size_t total_reserved, - size_t total_committed, - int reserved_diff, - int committed_diff) = 0; - virtual void diff_num_of_classes(size_t classes, int diff) = 0; - virtual void diff_num_of_threads(size_t threads, int diff) = 0; - - virtual void diff_thread_info(size_t stack_reserved, size_t stack_committed, - int stack_reserved_diff, int stack_committed_diff) = 0; + // Helper functions + // Calculate total reserved and committed amount + size_t reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const; + size_t committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const; - /* - * memory summary by memory types. - * for each memory type, following summaries are reported: - * - reserved amount, committed amount - * - malloc'd amount, malloc count - * - arena amount, arena count - */ + // Print summary total, malloc and virtual memory + void print_total(size_t reserved, size_t committed) const; + void print_malloc(size_t amount, size_t count) const; + void print_virtual_memory(size_t reserved, size_t committed) const; - // start reporting memory summary by memory type - virtual void start_category_summary() = 0; + void print_malloc_line(size_t amount, size_t count) const; + void print_virtual_memory_line(size_t reserved, size_t committed) const; + void print_arena_line(size_t amount, size_t count) const; - virtual void category_summary(MEMFLAGS type, size_t reserved_amt, - size_t committed_amt, - size_t malloc_amt, size_t malloc_count, - size_t arena_amt, size_t arena_count) = 0; - - virtual void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt, - size_t cur_committed_amt, - size_t cur_malloc_amt, size_t cur_malloc_count, - size_t cur_arena_amt, size_t cur_arena_count, - int reserved_diff, int committed_diff, int malloc_diff, - int malloc_count_diff, int arena_diff, - int arena_count_diff) = 0; - - virtual void done_category_summary() = 0; - - virtual void start_virtual_memory_map() = 0; - virtual void reserved_memory_region(MEMFLAGS type, address base, address end, size_t size, address pc) = 0; - virtual void committed_memory_region(address base, address end, size_t size, address pc) = 0; - virtual void done_virtual_memory_map() = 0; - - /* - * Report callsite information - */ - virtual void start_callsite() = 0; - virtual void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count) = 0; - virtual void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt) = 0; - - virtual void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count, - int malloc_diff, int malloc_count_diff) = 0; - virtual void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt, - int reserved_diff, int committed_diff) = 0; - - virtual void done_callsite() = 0; - - // return current scale in "KB", "MB" or "GB" - static const char* memory_unit(size_t scale); + void print_virtual_memory_region(const char* type, address base, size_t size) const; }; /* - * This class reports processed data from a baseline or - * the changes between the two baseline. + * The class is for generating summary tracking report. */ -class BaselineReporter : public StackObj { +class MemSummaryReporter : public MemReporterBase { private: - BaselineOutputer& _outputer; - size_t _scale; + MallocMemorySnapshot* _malloc_snapshot; + VirtualMemorySnapshot* _vm_snapshot; + size_t _class_count; public: - // construct a reporter that reports memory usage - // in specified scale - BaselineReporter(BaselineOutputer& outputer, size_t scale = K): - _outputer(outputer) { - _scale = scale; + // Report summary tracking data from global snapshots directly. + // This constructor is used for final reporting and hs_err reporting. + MemSummaryReporter(MallocMemorySnapshot* malloc_snapshot, + VirtualMemorySnapshot* vm_snapshot, outputStream* output, + size_t class_count = 0, size_t scale = K) : + MemReporterBase(output, scale), + _malloc_snapshot(malloc_snapshot), + _vm_snapshot(vm_snapshot) { + if (class_count == 0) { + _class_count = InstanceKlass::number_of_instance_classes(); + } else { + _class_count = class_count; + } } - virtual void report_baseline(const MemBaseline& baseline, bool summary_only = false); - virtual void diff_baselines(const MemBaseline& cur, const MemBaseline& prev, - bool summary_only = false); + // This constructor is for normal reporting from a recent baseline. + MemSummaryReporter(MemBaseline& baseline, outputStream* output, + size_t scale = K) : MemReporterBase(output, scale), + _malloc_snapshot(baseline.malloc_memory_snapshot()), + _vm_snapshot(baseline.virtual_memory_snapshot()), + _class_count(baseline.class_count()) { } - void set_scale(size_t scale); - size_t scale() const { return _scale; } + // Generate summary report + virtual void report(); private: - void report_summaries(const MemBaseline& baseline); - void report_virtual_memory_map(const MemBaseline& baseline); - void report_callsites(const MemBaseline& baseline); - - void diff_summaries(const MemBaseline& cur, const MemBaseline& prev); - void diff_callsites(const MemBaseline& cur, const MemBaseline& prev); - - // calculate memory size in current memory scale - size_t amount_in_current_scale(size_t amt) const; - // diff two unsigned values in current memory scale - int diff_in_current_scale(size_t value1, size_t value2) const; - // diff two unsigned value - int diff(size_t value1, size_t value2) const; + // Report summary for each memory type + void report_summary_of_type(MEMFLAGS type, MallocMemory* malloc_memory, + VirtualMemory* virtual_memory); }; /* - * tty output implementation. Native memory tracking - * DCmd uses this outputer. + * The class is for generating detail tracking report. */ -class BaselineTTYOutputer : public BaselineOutputer { +class MemDetailReporter : public MemSummaryReporter { private: - size_t _scale; - - size_t _num_of_classes; - size_t _num_of_threads; - size_t _thread_stack_reserved; - size_t _thread_stack_committed; - - int _num_of_classes_diff; - int _num_of_threads_diff; - int _thread_stack_reserved_diff; - int _thread_stack_committed_diff; - - outputStream* _output; + MemBaseline& _baseline; public: - BaselineTTYOutputer(outputStream* st) { - _scale = K; - _num_of_classes = 0; - _num_of_threads = 0; - _thread_stack_reserved = 0; - _thread_stack_committed = 0; - _num_of_classes_diff = 0; - _num_of_threads_diff = 0; - _thread_stack_reserved_diff = 0; - _thread_stack_committed_diff = 0; - _output = st; + MemDetailReporter(MemBaseline& baseline, outputStream* output, size_t scale = K) : + MemSummaryReporter(baseline, output, scale), + _baseline(baseline) { } + + // Generate detail report. + // The report contains summary and detail sections. + virtual void report() { + MemSummaryReporter::report(); + report_virtual_memory_map(); + report_detail(); } - // begin reporting memory usage in specified scale - void start(size_t scale, bool report_diff = false); - // done reporting - void done(); + private: + // Report detail tracking data. + void report_detail(); + // Report virtual memory map + void report_virtual_memory_map(); + // Report malloc allocation sites + void report_malloc_sites(); + // Report virtual memory reservation sites + void report_virtual_memory_allocation_sites(); - // total memory usage - void total_usage(size_t total_reserved, - size_t total_committed); - // report total loaded classes - void num_of_classes(size_t classes) { - _num_of_classes = classes; - } - - void num_of_threads(size_t threads) { - _num_of_threads = threads; - } - - void thread_info(size_t stack_reserved_amt, size_t stack_committed_amt) { - _thread_stack_reserved = stack_reserved_amt; - _thread_stack_committed = stack_committed_amt; - } - - void diff_total_usage(size_t total_reserved, - size_t total_committed, - int reserved_diff, - int committed_diff); - - void diff_num_of_classes(size_t classes, int diff) { - _num_of_classes = classes; - _num_of_classes_diff = diff; - } - - void diff_num_of_threads(size_t threads, int diff) { - _num_of_threads = threads; - _num_of_threads_diff = diff; - } - - void diff_thread_info(size_t stack_reserved_amt, size_t stack_committed_amt, - int stack_reserved_diff, int stack_committed_diff) { - _thread_stack_reserved = stack_reserved_amt; - _thread_stack_committed = stack_committed_amt; - _thread_stack_reserved_diff = stack_reserved_diff; - _thread_stack_committed_diff = stack_committed_diff; - } - - /* - * Report memory summary categoriuzed by memory types. - * For each memory type, following summaries are reported: - * - reserved amount, committed amount - * - malloc-ed amount, malloc count - * - arena amount, arena count - */ - // start reporting memory summary by memory type - void start_category_summary(); - void category_summary(MEMFLAGS type, size_t reserved_amt, size_t committed_amt, - size_t malloc_amt, size_t malloc_count, - size_t arena_amt, size_t arena_count); - - void diff_category_summary(MEMFLAGS type, size_t cur_reserved_amt, - size_t cur_committed_amt, - size_t cur_malloc_amt, size_t cur_malloc_count, - size_t cur_arena_amt, size_t cur_arena_count, - int reserved_diff, int committed_diff, int malloc_diff, - int malloc_count_diff, int arena_diff, - int arena_count_diff); - - void done_category_summary(); - - // virtual memory map - void start_virtual_memory_map(); - void reserved_memory_region(MEMFLAGS type, address base, address end, size_t size, address pc); - void committed_memory_region(address base, address end, size_t size, address pc); - void done_virtual_memory_map(); - - - /* - * Report callsite information - */ - void start_callsite(); - void malloc_callsite(address pc, size_t malloc_amt, size_t malloc_count); - void virtual_memory_callsite(address pc, size_t reserved_amt, size_t committed_amt); - - void diff_malloc_callsite(address pc, size_t cur_malloc_amt, size_t cur_malloc_count, - int malloc_diff, int malloc_count_diff); - void diff_virtual_memory_callsite(address pc, size_t cur_reserved_amt, size_t cur_committed_amt, - int reserved_diff, int committed_diff); - - void done_callsite(); + // Report a virtual memory region + void report_virtual_memory_region(const ReservedMemoryRegion* rgn); }; +/* + * The class is for generating summary comparison report. + * It compares current memory baseline against an early baseline. + */ +class MemSummaryDiffReporter : public MemReporterBase { + protected: + MemBaseline& _early_baseline; + MemBaseline& _current_baseline; + + public: + MemSummaryDiffReporter(MemBaseline& early_baseline, MemBaseline& current_baseline, + outputStream* output, size_t scale = K) : MemReporterBase(output, scale), + _early_baseline(early_baseline), _current_baseline(current_baseline) { + assert(early_baseline.baseline_type() != MemBaseline::Not_baselined, "Not baselined"); + assert(current_baseline.baseline_type() != MemBaseline::Not_baselined, "Not baselined"); + } + + // Generate summary comparison report + virtual void report_diff(); + + private: + // report the comparison of each memory type + void diff_summary_of_type(MEMFLAGS type, + const MallocMemory* early_malloc, const VirtualMemory* early_vm, + const MallocMemory* current_malloc, const VirtualMemory* current_vm) const; + + protected: + void print_malloc_diff(size_t current_amount, size_t current_count, + size_t early_amount, size_t early_count) const; + void print_virtual_memory_diff(size_t current_reserved, size_t current_committed, + size_t early_reserved, size_t early_committed) const; + void print_arena_diff(size_t current_amount, size_t current_count, + size_t early_amount, size_t early_count) const; +}; + +/* + * The class is for generating detail comparison report. + * It compares current memory baseline against an early baseline, + * both baselines have to be detail baseline. + */ +class MemDetailDiffReporter : public MemSummaryDiffReporter { + public: + MemDetailDiffReporter(MemBaseline& early_baseline, MemBaseline& current_baseline, + outputStream* output, size_t scale = K) : + MemSummaryDiffReporter(early_baseline, current_baseline, output, scale) { } + + // Generate detail comparison report + virtual void report_diff(); + + // Malloc allocation site comparison + void diff_malloc_sites() const; + // Virutal memory reservation site comparison + void diff_virtual_memory_sites() const; + + // New malloc allocation site in recent baseline + void new_malloc_site (const MallocSite* site) const; + // The malloc allocation site is not in recent baseline + void old_malloc_site (const MallocSite* site) const; + // Compare malloc allocation site, it is in both baselines + void diff_malloc_site(const MallocSite* early, const MallocSite* current) const; + + // New virtual memory allocation site in recent baseline + void new_virtual_memory_site (const VirtualMemoryAllocationSite* callsite) const; + // The virtual memory allocation site is not in recent baseline + void old_virtual_memory_site (const VirtualMemoryAllocationSite* callsite) const; + // Compare virtual memory allocation site, it is in both baseline + void diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, + const VirtualMemoryAllocationSite* current) const; + + void diff_malloc_site(const NativeCallStack* stack, size_t current_size, + size_t currrent_count, size_t early_size, size_t early_count) const; + void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, + size_t current_committed, size_t early_reserved, size_t early_committed) const; +}; #endif // INCLUDE_NMT -#endif // SHARE_VM_SERVICES_MEM_REPORTER_HPP +#endif + diff --git a/hotspot/src/share/vm/services/memSnapshot.cpp b/hotspot/src/share/vm/services/memSnapshot.cpp deleted file mode 100644 index 8f5ca4f4195..00000000000 --- a/hotspot/src/share/vm/services/memSnapshot.cpp +++ /dev/null @@ -1,748 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "runtime/mutexLocker.hpp" -#include "utilities/decoder.hpp" -#include "services/memBaseline.hpp" -#include "services/memPtr.hpp" -#include "services/memPtrArray.hpp" -#include "services/memSnapshot.hpp" -#include "services/memTracker.hpp" - -PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC - -#ifdef ASSERT - -void decode_pointer_record(MemPointerRecord* rec) { - tty->print("Pointer: [" PTR_FORMAT " - " PTR_FORMAT "] size = %d bytes", rec->addr(), - rec->addr() + rec->size(), (int)rec->size()); - tty->print(" type = %s", MemBaseline::type2name(FLAGS_TO_MEMORY_TYPE(rec->flags()))); - if (rec->is_vm_pointer()) { - if (rec->is_allocation_record()) { - tty->print_cr(" (reserve)"); - } else if (rec->is_commit_record()) { - tty->print_cr(" (commit)"); - } else if (rec->is_uncommit_record()) { - tty->print_cr(" (uncommit)"); - } else if (rec->is_deallocation_record()) { - tty->print_cr(" (release)"); - } else { - tty->print_cr(" (tag)"); - } - } else { - if (rec->is_arena_memory_record()) { - tty->print_cr(" (arena size)"); - } else if (rec->is_allocation_record()) { - tty->print_cr(" (malloc)"); - } else { - tty->print_cr(" (free)"); - } - } - if (MemTracker::track_callsite()) { - char buf[1024]; - address pc = ((MemPointerRecordEx*)rec)->pc(); - if (pc != NULL && os::dll_address_to_function_name(pc, buf, sizeof(buf), NULL)) { - tty->print_cr("\tfrom %s", buf); - } else { - tty->print_cr("\tcould not decode pc = " PTR_FORMAT "", pc); - } - } -} - -void decode_vm_region_record(VMMemRegion* rec) { - tty->print("VM Region [" PTR_FORMAT " - " PTR_FORMAT "]", rec->addr(), - rec->addr() + rec->size()); - tty->print(" type = %s", MemBaseline::type2name(FLAGS_TO_MEMORY_TYPE(rec->flags()))); - if (rec->is_allocation_record()) { - tty->print_cr(" (reserved)"); - } else if (rec->is_commit_record()) { - tty->print_cr(" (committed)"); - } else { - ShouldNotReachHere(); - } - if (MemTracker::track_callsite()) { - char buf[1024]; - address pc = ((VMMemRegionEx*)rec)->pc(); - if (pc != NULL && os::dll_address_to_function_name(pc, buf, sizeof(buf), NULL)) { - tty->print_cr("\tfrom %s", buf); - } else { - tty->print_cr("\tcould not decode pc = " PTR_FORMAT "", pc); - } - - } -} - -#endif - - -bool VMMemPointerIterator::insert_record(MemPointerRecord* rec) { - VMMemRegionEx new_rec; - assert(rec->is_allocation_record() || rec->is_commit_record(), - "Sanity check"); - if (MemTracker::track_callsite()) { - new_rec.init((MemPointerRecordEx*)rec); - } else { - new_rec.init(rec); - } - return insert(&new_rec); -} - -bool VMMemPointerIterator::insert_record_after(MemPointerRecord* rec) { - VMMemRegionEx new_rec; - assert(rec->is_allocation_record() || rec->is_commit_record(), - "Sanity check"); - if (MemTracker::track_callsite()) { - new_rec.init((MemPointerRecordEx*)rec); - } else { - new_rec.init(rec); - } - return insert_after(&new_rec); -} - -// we don't consolidate reserved regions, since they may be categorized -// in different types. -bool VMMemPointerIterator::add_reserved_region(MemPointerRecord* rec) { - assert(rec->is_allocation_record(), "Sanity check"); - VMMemRegion* reserved_region = (VMMemRegion*)current(); - - // we don't have anything yet - if (reserved_region == NULL) { - return insert_record(rec); - } - - assert(reserved_region->is_reserved_region(), "Sanity check"); - // duplicated records - if (reserved_region->is_same_region(rec)) { - return true; - } - // Overlapping stack regions indicate that a JNI thread failed to - // detach from the VM before exiting. This leaks the JavaThread object. - if (CheckJNICalls) { - guarantee(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) != mtThreadStack || - !reserved_region->overlaps_region(rec), - "Attached JNI thread exited without being detached"); - } - // otherwise, we should not have overlapping reserved regions - assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack || - reserved_region->base() > rec->addr(), "Just check: locate()"); - assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack || - !reserved_region->overlaps_region(rec), "overlapping reserved regions"); - - return insert_record(rec); -} - -// we do consolidate committed regions -bool VMMemPointerIterator::add_committed_region(MemPointerRecord* rec) { - assert(rec->is_commit_record(), "Sanity check"); - VMMemRegion* reserved_rgn = (VMMemRegion*)current(); - assert(reserved_rgn->is_reserved_region() && reserved_rgn->contains_region(rec), - "Sanity check"); - - // thread's native stack is always marked as "committed", ignore - // the "commit" operation for creating stack guard pages - if (FLAGS_TO_MEMORY_TYPE(reserved_rgn->flags()) == mtThreadStack && - FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { - return true; - } - - // if the reserved region has any committed regions - VMMemRegion* committed_rgn = (VMMemRegion*)next(); - while (committed_rgn != NULL && committed_rgn->is_committed_region()) { - // duplicated commit records - if(committed_rgn->contains_region(rec)) { - return true; - } else if (committed_rgn->overlaps_region(rec)) { - // overlaps front part - if (rec->addr() < committed_rgn->addr()) { - committed_rgn->expand_region(rec->addr(), - committed_rgn->addr() - rec->addr()); - } else { - // overlaps tail part - address committed_rgn_end = committed_rgn->addr() + - committed_rgn->size(); - assert(committed_rgn_end < rec->addr() + rec->size(), - "overlap tail part"); - committed_rgn->expand_region(committed_rgn_end, - (rec->addr() + rec->size()) - committed_rgn_end); - } - } else if (committed_rgn->base() + committed_rgn->size() == rec->addr()) { - // adjunct each other - committed_rgn->expand_region(rec->addr(), rec->size()); - VMMemRegion* next_reg = (VMMemRegion*)next(); - // see if we can consolidate next committed region - if (next_reg != NULL && next_reg->is_committed_region() && - next_reg->base() == committed_rgn->base() + committed_rgn->size()) { - committed_rgn->expand_region(next_reg->base(), next_reg->size()); - // delete merged region - remove(); - } - return true; - } else if (committed_rgn->base() > rec->addr()) { - // found the location, insert this committed region - return insert_record(rec); - } - committed_rgn = (VMMemRegion*)next(); - } - return insert_record(rec); -} - -bool VMMemPointerIterator::remove_uncommitted_region(MemPointerRecord* rec) { - assert(rec->is_uncommit_record(), "sanity check"); - VMMemRegion* cur; - cur = (VMMemRegion*)current(); - assert(cur->is_reserved_region() && cur->contains_region(rec), - "Sanity check"); - // thread's native stack is always marked as "committed", ignore - // the "commit" operation for creating stack guard pages - if (FLAGS_TO_MEMORY_TYPE(cur->flags()) == mtThreadStack && - FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { - return true; - } - - cur = (VMMemRegion*)next(); - while (cur != NULL && cur->is_committed_region()) { - // region already uncommitted, must be due to duplicated record - if (cur->addr() >= rec->addr() + rec->size()) { - break; - } else if (cur->contains_region(rec)) { - // uncommit whole region - if (cur->is_same_region(rec)) { - remove(); - break; - } else if (rec->addr() == cur->addr() || - rec->addr() + rec->size() == cur->addr() + cur->size()) { - // uncommitted from either end of current memory region. - cur->exclude_region(rec->addr(), rec->size()); - break; - } else { // split the committed region and release the middle - address high_addr = cur->addr() + cur->size(); - size_t sz = high_addr - rec->addr(); - cur->exclude_region(rec->addr(), sz); - sz = high_addr - (rec->addr() + rec->size()); - if (MemTracker::track_callsite()) { - MemPointerRecordEx tmp(rec->addr() + rec->size(), cur->flags(), sz, - ((VMMemRegionEx*)cur)->pc()); - return insert_record_after(&tmp); - } else { - MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz); - return insert_record_after(&tmp); - } - } - } - cur = (VMMemRegion*)next(); - } - - // we may not find committed record due to duplicated records - return true; -} - -bool VMMemPointerIterator::remove_released_region(MemPointerRecord* rec) { - assert(rec->is_deallocation_record(), "Sanity check"); - VMMemRegion* cur = (VMMemRegion*)current(); - assert(cur->is_reserved_region() && cur->contains_region(rec), - "Sanity check"); - if (rec->is_same_region(cur)) { - - // In snapshot, the virtual memory records are sorted in following orders: - // 1. virtual memory's base address - // 2. virtual memory reservation record, followed by commit records within this reservation. - // The commit records are also in base address order. - // When a reserved region is released, we want to remove the reservation record and all - // commit records following it. -#ifdef ASSERT - address low_addr = cur->addr(); - address high_addr = low_addr + cur->size(); -#endif - // remove virtual memory reservation record - remove(); - // remove committed regions within above reservation - VMMemRegion* next_region = (VMMemRegion*)current(); - while (next_region != NULL && next_region->is_committed_region()) { - assert(next_region->addr() >= low_addr && - next_region->addr() + next_region->size() <= high_addr, - "Range check"); - remove(); - next_region = (VMMemRegion*)current(); - } - } else if (rec->addr() == cur->addr() || - rec->addr() + rec->size() == cur->addr() + cur->size()) { - // released region is at either end of this region - cur->exclude_region(rec->addr(), rec->size()); - assert(check_reserved_region(), "Integrity check"); - } else { // split the reserved region and release the middle - address high_addr = cur->addr() + cur->size(); - size_t sz = high_addr - rec->addr(); - cur->exclude_region(rec->addr(), sz); - sz = high_addr - rec->addr() - rec->size(); - if (MemTracker::track_callsite()) { - MemPointerRecordEx tmp(rec->addr() + rec->size(), cur->flags(), sz, - ((VMMemRegionEx*)cur)->pc()); - bool ret = insert_reserved_region(&tmp); - assert(!ret || check_reserved_region(), "Integrity check"); - return ret; - } else { - MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz); - bool ret = insert_reserved_region(&tmp); - assert(!ret || check_reserved_region(), "Integrity check"); - return ret; - } - } - return true; -} - -bool VMMemPointerIterator::insert_reserved_region(MemPointerRecord* rec) { - // skip all 'commit' records associated with previous reserved region - VMMemRegion* p = (VMMemRegion*)next(); - while (p != NULL && p->is_committed_region() && - p->base() + p->size() < rec->addr()) { - p = (VMMemRegion*)next(); - } - return insert_record(rec); -} - -bool VMMemPointerIterator::split_reserved_region(VMMemRegion* rgn, address new_rgn_addr, size_t new_rgn_size) { - assert(rgn->contains_region(new_rgn_addr, new_rgn_size), "Not fully contained"); - address pc = (MemTracker::track_callsite() ? ((VMMemRegionEx*)rgn)->pc() : NULL); - if (rgn->base() == new_rgn_addr) { // new region is at the beginning of the region - size_t sz = rgn->size() - new_rgn_size; - // the original region becomes 'new' region - rgn->exclude_region(new_rgn_addr + new_rgn_size, sz); - // remaining becomes next region - MemPointerRecordEx next_rgn(new_rgn_addr + new_rgn_size, rgn->flags(), sz, pc); - return insert_reserved_region(&next_rgn); - } else if (rgn->base() + rgn->size() == new_rgn_addr + new_rgn_size) { - rgn->exclude_region(new_rgn_addr, new_rgn_size); - MemPointerRecordEx next_rgn(new_rgn_addr, rgn->flags(), new_rgn_size, pc); - return insert_reserved_region(&next_rgn); - } else { - // the orginal region will be split into three - address rgn_high_addr = rgn->base() + rgn->size(); - // first region - rgn->exclude_region(new_rgn_addr, (rgn_high_addr - new_rgn_addr)); - // the second region is the new region - MemPointerRecordEx new_rgn(new_rgn_addr, rgn->flags(), new_rgn_size, pc); - if (!insert_reserved_region(&new_rgn)) return false; - // the remaining region - MemPointerRecordEx rem_rgn(new_rgn_addr + new_rgn_size, rgn->flags(), - rgn_high_addr - (new_rgn_addr + new_rgn_size), pc); - return insert_reserved_region(&rem_rgn); - } -} - -static int sort_in_seq_order(const void* p1, const void* p2) { - assert(p1 != NULL && p2 != NULL, "Sanity check"); - const MemPointerRecord* mp1 = (MemPointerRecord*)p1; - const MemPointerRecord* mp2 = (MemPointerRecord*)p2; - return (mp1->seq() - mp2->seq()); -} - -bool StagingArea::init() { - if (MemTracker::track_callsite()) { - _malloc_data = new (std::nothrow)MemPointerArrayImpl(); - _vm_data = new (std::nothrow)MemPointerArrayImpl(); - } else { - _malloc_data = new (std::nothrow)MemPointerArrayImpl(); - _vm_data = new (std::nothrow)MemPointerArrayImpl(); - } - - if (_malloc_data != NULL && _vm_data != NULL && - !_malloc_data->out_of_memory() && - !_vm_data->out_of_memory()) { - return true; - } else { - if (_malloc_data != NULL) delete _malloc_data; - if (_vm_data != NULL) delete _vm_data; - _malloc_data = NULL; - _vm_data = NULL; - return false; - } -} - - -VMRecordIterator StagingArea::virtual_memory_record_walker() { - MemPointerArray* arr = vm_data(); - // sort into seq number order - arr->sort((FN_SORT)sort_in_seq_order); - return VMRecordIterator(arr); -} - - -MemSnapshot::MemSnapshot() { - if (MemTracker::track_callsite()) { - _alloc_ptrs = new (std::nothrow) MemPointerArrayImpl(); - _vm_ptrs = new (std::nothrow)MemPointerArrayImpl(64, true); - } else { - _alloc_ptrs = new (std::nothrow) MemPointerArrayImpl(); - _vm_ptrs = new (std::nothrow)MemPointerArrayImpl(64, true); - } - - _staging_area.init(); - _lock = new (std::nothrow) Mutex(Monitor::max_nonleaf - 1, "memSnapshotLock"); - NOT_PRODUCT(_untracked_count = 0;) - _number_of_classes = 0; -} - -MemSnapshot::~MemSnapshot() { - assert(MemTracker::shutdown_in_progress(), "native memory tracking still on"); - { - MutexLockerEx locker(_lock); - if (_alloc_ptrs != NULL) { - delete _alloc_ptrs; - _alloc_ptrs = NULL; - } - - if (_vm_ptrs != NULL) { - delete _vm_ptrs; - _vm_ptrs = NULL; - } - } - - if (_lock != NULL) { - delete _lock; - _lock = NULL; - } -} - - -void MemSnapshot::copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src) { - assert(dest != NULL && src != NULL, "Just check"); - assert(dest->addr() == src->addr(), "Just check"); - assert(dest->seq() > 0 && src->seq() > 0, "not sequenced"); - - if (MemTracker::track_callsite()) { - *(SeqMemPointerRecordEx*)dest = *(SeqMemPointerRecordEx*)src; - } else { - *(SeqMemPointerRecord*)dest = *(SeqMemPointerRecord*)src; - } -} - -void MemSnapshot::assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src) { - assert(src != NULL && dest != NULL, "Just check"); - assert(dest->seq() == 0 && src->seq() >0, "cast away sequence"); - - if (MemTracker::track_callsite()) { - *(MemPointerRecordEx*)dest = *(MemPointerRecordEx*)src; - } else { - *(MemPointerRecord*)dest = *(MemPointerRecord*)src; - } -} - -// merge a recorder to the staging area -bool MemSnapshot::merge(MemRecorder* rec) { - assert(rec != NULL && !rec->out_of_memory(), "Just check"); - - SequencedRecordIterator itr(rec->pointer_itr()); - - MutexLockerEx lock(_lock, true); - MemPointerIterator malloc_staging_itr(_staging_area.malloc_data()); - MemPointerRecord* incoming_rec = (MemPointerRecord*) itr.current(); - MemPointerRecord* matched_rec; - - while (incoming_rec != NULL) { - if (incoming_rec->is_vm_pointer()) { - // we don't do anything with virtual memory records during merge - if (!_staging_area.vm_data()->append(incoming_rec)) { - return false; - } - } else { - // locate matched record and/or also position the iterator to proper - // location for this incoming record. - matched_rec = (MemPointerRecord*)malloc_staging_itr.locate(incoming_rec->addr()); - // we have not seen this memory block in this generation, - // so just add to staging area - if (matched_rec == NULL) { - if (!malloc_staging_itr.insert(incoming_rec)) { - return false; - } - } else if (incoming_rec->addr() == matched_rec->addr()) { - // whoever has higher sequence number wins - if (incoming_rec->seq() > matched_rec->seq()) { - copy_seq_pointer(matched_rec, incoming_rec); - } - } else if (incoming_rec->addr() < matched_rec->addr()) { - if (!malloc_staging_itr.insert(incoming_rec)) { - return false; - } - } else { - ShouldNotReachHere(); - } - } - incoming_rec = (MemPointerRecord*)itr.next(); - } - NOT_PRODUCT(void check_staging_data();) - return true; -} - - -// promote data to next generation -bool MemSnapshot::promote(int number_of_classes) { - assert(_alloc_ptrs != NULL && _vm_ptrs != NULL, "Just check"); - assert(_staging_area.malloc_data() != NULL && _staging_area.vm_data() != NULL, - "Just check"); - MutexLockerEx lock(_lock, true); - - MallocRecordIterator malloc_itr = _staging_area.malloc_record_walker(); - bool promoted = false; - if (promote_malloc_records(&malloc_itr)) { - VMRecordIterator vm_itr = _staging_area.virtual_memory_record_walker(); - if (promote_virtual_memory_records(&vm_itr)) { - promoted = true; - } - } - - NOT_PRODUCT(check_malloc_pointers();) - _staging_area.clear(); - _number_of_classes = number_of_classes; - return promoted; -} - -bool MemSnapshot::promote_malloc_records(MemPointerArrayIterator* itr) { - MemPointerIterator malloc_snapshot_itr(_alloc_ptrs); - MemPointerRecord* new_rec = (MemPointerRecord*)itr->current(); - MemPointerRecord* matched_rec; - while (new_rec != NULL) { - matched_rec = (MemPointerRecord*)malloc_snapshot_itr.locate(new_rec->addr()); - // found matched memory block - if (matched_rec != NULL && new_rec->addr() == matched_rec->addr()) { - // snapshot already contains 'live' records - assert(matched_rec->is_allocation_record() || matched_rec->is_arena_memory_record(), - "Sanity check"); - // update block states - if (new_rec->is_allocation_record()) { - assign_pointer(matched_rec, new_rec); - } else if (new_rec->is_arena_memory_record()) { - if (new_rec->size() == 0) { - // remove size record once size drops to 0 - malloc_snapshot_itr.remove(); - } else { - assign_pointer(matched_rec, new_rec); - } - } else { - // a deallocation record - assert(new_rec->is_deallocation_record(), "Sanity check"); - // an arena record can be followed by a size record, we need to remove both - if (matched_rec->is_arena_record()) { - MemPointerRecord* next = (MemPointerRecord*)malloc_snapshot_itr.peek_next(); - if (next != NULL && next->is_arena_memory_record() && - next->is_memory_record_of_arena(matched_rec)) { - malloc_snapshot_itr.remove(); - } - } - // the memory is deallocated, remove related record(s) - malloc_snapshot_itr.remove(); - } - } else { - // don't insert size 0 record - if (new_rec->is_arena_memory_record() && new_rec->size() == 0) { - new_rec = NULL; - } - - if (new_rec != NULL) { - if (new_rec->is_allocation_record() || new_rec->is_arena_memory_record()) { - if (matched_rec != NULL && new_rec->addr() > matched_rec->addr()) { - if (!malloc_snapshot_itr.insert_after(new_rec)) { - return false; - } - } else { - if (!malloc_snapshot_itr.insert(new_rec)) { - return false; - } - } - } -#ifndef PRODUCT - else if (!has_allocation_record(new_rec->addr())) { - // NMT can not track some startup memory, which is allocated before NMT is on - _untracked_count ++; - } -#endif - } - } - new_rec = (MemPointerRecord*)itr->next(); - } - return true; -} - -bool MemSnapshot::promote_virtual_memory_records(MemPointerArrayIterator* itr) { - VMMemPointerIterator vm_snapshot_itr(_vm_ptrs); - MemPointerRecord* new_rec = (MemPointerRecord*)itr->current(); - VMMemRegion* reserved_rec; - while (new_rec != NULL) { - assert(new_rec->is_vm_pointer(), "Sanity check"); - - // locate a reserved region that contains the specified address, or - // the nearest reserved region has base address just above the specified - // address - reserved_rec = (VMMemRegion*)vm_snapshot_itr.locate(new_rec->addr()); - if (reserved_rec != NULL && reserved_rec->contains_region(new_rec)) { - // snapshot can only have 'live' records - assert(reserved_rec->is_reserved_region(), "Sanity check"); - if (new_rec->is_allocation_record()) { - if (!reserved_rec->is_same_region(new_rec)) { - // only deal with split a bigger reserved region into smaller regions. - // So far, CDS is the only use case. - if (!vm_snapshot_itr.split_reserved_region(reserved_rec, new_rec->addr(), new_rec->size())) { - return false; - } - } - } else if (new_rec->is_uncommit_record()) { - if (!vm_snapshot_itr.remove_uncommitted_region(new_rec)) { - return false; - } - } else if (new_rec->is_commit_record()) { - // insert or expand existing committed region to cover this - // newly committed region - if (!vm_snapshot_itr.add_committed_region(new_rec)) { - return false; - } - } else if (new_rec->is_deallocation_record()) { - // release part or all memory region - if (!vm_snapshot_itr.remove_released_region(new_rec)) { - return false; - } - } else if (new_rec->is_type_tagging_record()) { - // tag this reserved virtual memory range to a memory type. Can not re-tag a memory range - // to different type. - assert(FLAGS_TO_MEMORY_TYPE(reserved_rec->flags()) == mtNone || - FLAGS_TO_MEMORY_TYPE(reserved_rec->flags()) == FLAGS_TO_MEMORY_TYPE(new_rec->flags()), - "Sanity check"); - reserved_rec->tag(new_rec->flags()); - } else { - ShouldNotReachHere(); - } - } else { - /* - * The assertion failure indicates mis-matched virtual memory records. The likely - * scenario is, that some virtual memory operations are not going through os::xxxx_memory() - * api, which have to be tracked manually. (perfMemory is an example). - */ - assert(new_rec->is_allocation_record(), "Sanity check"); - if (!vm_snapshot_itr.add_reserved_region(new_rec)) { - return false; - } - } - new_rec = (MemPointerRecord*)itr->next(); - } - return true; -} - -#ifndef PRODUCT -void MemSnapshot::print_snapshot_stats(outputStream* st) { - st->print_cr("Snapshot:"); - st->print_cr("\tMalloced: %d/%d [%5.2f%%] %dKB", _alloc_ptrs->length(), _alloc_ptrs->capacity(), - (100.0 * (float)_alloc_ptrs->length()) / (float)_alloc_ptrs->capacity(), _alloc_ptrs->instance_size()/K); - - st->print_cr("\tVM: %d/%d [%5.2f%%] %dKB", _vm_ptrs->length(), _vm_ptrs->capacity(), - (100.0 * (float)_vm_ptrs->length()) / (float)_vm_ptrs->capacity(), _vm_ptrs->instance_size()/K); - - st->print_cr("\tMalloc staging Area: %d/%d [%5.2f%%] %dKB", _staging_area.malloc_data()->length(), - _staging_area.malloc_data()->capacity(), - (100.0 * (float)_staging_area.malloc_data()->length()) / (float)_staging_area.malloc_data()->capacity(), - _staging_area.malloc_data()->instance_size()/K); - - st->print_cr("\tVirtual memory staging Area: %d/%d [%5.2f%%] %dKB", _staging_area.vm_data()->length(), - _staging_area.vm_data()->capacity(), - (100.0 * (float)_staging_area.vm_data()->length()) / (float)_staging_area.vm_data()->capacity(), - _staging_area.vm_data()->instance_size()/K); - - st->print_cr("\tUntracked allocation: %d", _untracked_count); -} - -void MemSnapshot::check_malloc_pointers() { - MemPointerArrayIteratorImpl mItr(_alloc_ptrs); - MemPointerRecord* p = (MemPointerRecord*)mItr.current(); - MemPointerRecord* prev = NULL; - while (p != NULL) { - if (prev != NULL) { - assert(p->addr() >= prev->addr(), "sorting order"); - } - prev = p; - p = (MemPointerRecord*)mItr.next(); - } -} - -bool MemSnapshot::has_allocation_record(address addr) { - MemPointerArrayIteratorImpl itr(_staging_area.malloc_data()); - MemPointerRecord* cur = (MemPointerRecord*)itr.current(); - while (cur != NULL) { - if (cur->addr() == addr && cur->is_allocation_record()) { - return true; - } - cur = (MemPointerRecord*)itr.next(); - } - return false; -} -#endif // PRODUCT - -#ifdef ASSERT -void MemSnapshot::check_staging_data() { - MemPointerArrayIteratorImpl itr(_staging_area.malloc_data()); - MemPointerRecord* cur = (MemPointerRecord*)itr.current(); - MemPointerRecord* next = (MemPointerRecord*)itr.next(); - while (next != NULL) { - assert((next->addr() > cur->addr()) || - ((next->flags() & MemPointerRecord::tag_masks) > - (cur->flags() & MemPointerRecord::tag_masks)), - "sorting order"); - cur = next; - next = (MemPointerRecord*)itr.next(); - } - - MemPointerArrayIteratorImpl vm_itr(_staging_area.vm_data()); - cur = (MemPointerRecord*)vm_itr.current(); - while (cur != NULL) { - assert(cur->is_vm_pointer(), "virtual memory pointer only"); - cur = (MemPointerRecord*)vm_itr.next(); - } -} - -void MemSnapshot::dump_all_vm_pointers() { - MemPointerArrayIteratorImpl itr(_vm_ptrs); - VMMemRegion* ptr = (VMMemRegion*)itr.current(); - tty->print_cr("dump virtual memory pointers:"); - while (ptr != NULL) { - if (ptr->is_committed_region()) { - tty->print("\t"); - } - tty->print("[" PTR_FORMAT " - " PTR_FORMAT "] [%x]", ptr->addr(), - (ptr->addr() + ptr->size()), ptr->flags()); - - if (MemTracker::track_callsite()) { - VMMemRegionEx* ex = (VMMemRegionEx*)ptr; - if (ex->pc() != NULL) { - char buf[1024]; - if (os::dll_address_to_function_name(ex->pc(), buf, sizeof(buf), NULL)) { - tty->print_cr("\t%s", buf); - } else { - tty->cr(); - } - } - } - - ptr = (VMMemRegion*)itr.next(); - } - tty->flush(); -} -#endif // ASSERT - diff --git a/hotspot/src/share/vm/services/memSnapshot.hpp b/hotspot/src/share/vm/services/memSnapshot.hpp deleted file mode 100644 index f7d07568c6d..00000000000 --- a/hotspot/src/share/vm/services/memSnapshot.hpp +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_SERVICES_MEM_SNAPSHOT_HPP -#define SHARE_VM_SERVICES_MEM_SNAPSHOT_HPP - -#include "memory/allocation.hpp" -#include "runtime/mutex.hpp" -#include "runtime/mutexLocker.hpp" -#include "services/memBaseline.hpp" -#include "services/memPtrArray.hpp" - -// Snapshot pointer array iterator - -// The pointer array contains malloc-ed pointers -class MemPointerIterator : public MemPointerArrayIteratorImpl { - public: - MemPointerIterator(MemPointerArray* arr): - MemPointerArrayIteratorImpl(arr) { - assert(arr != NULL, "null array"); - } - -#ifdef ASSERT - virtual bool is_dup_pointer(const MemPointer* ptr1, - const MemPointer* ptr2) const { - MemPointerRecord* p1 = (MemPointerRecord*)ptr1; - MemPointerRecord* p2 = (MemPointerRecord*)ptr2; - - if (p1->addr() != p2->addr()) return false; - if ((p1->flags() & MemPointerRecord::tag_masks) != - (p2->flags() & MemPointerRecord::tag_masks)) { - return false; - } - // we do see multiple commit/uncommit on the same memory, it is ok - return (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_alloc || - (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_release; - } - - virtual bool insert(MemPointer* ptr) { - if (_pos > 0) { - MemPointer* p1 = (MemPointer*)ptr; - MemPointer* p2 = (MemPointer*)_array->at(_pos - 1); - assert(!is_dup_pointer(p1, p2), - err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); - } - if (_pos < _array->length() -1) { - MemPointer* p1 = (MemPointer*)ptr; - MemPointer* p2 = (MemPointer*)_array->at(_pos + 1); - assert(!is_dup_pointer(p1, p2), - err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); - } - return _array->insert_at(ptr, _pos); - } - - virtual bool insert_after(MemPointer* ptr) { - if (_pos > 0) { - MemPointer* p1 = (MemPointer*)ptr; - MemPointer* p2 = (MemPointer*)_array->at(_pos - 1); - assert(!is_dup_pointer(p1, p2), - err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); - } - if (_pos < _array->length() - 1) { - MemPointer* p1 = (MemPointer*)ptr; - MemPointer* p2 = (MemPointer*)_array->at(_pos + 1); - - assert(!is_dup_pointer(p1, p2), - err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); - } - if (_array->insert_at(ptr, _pos + 1)) { - _pos ++; - return true; - } - return false; - } -#endif - - virtual MemPointer* locate(address addr) { - MemPointer* cur = current(); - while (cur != NULL && cur->addr() < addr) { - cur = next(); - } - return cur; - } -}; - -class VMMemPointerIterator : public MemPointerIterator { - public: - VMMemPointerIterator(MemPointerArray* arr): - MemPointerIterator(arr) { - } - - // locate an existing reserved memory region that contains specified address, - // or the reserved region just above this address, where the incoming - // reserved region should be inserted. - virtual MemPointer* locate(address addr) { - reset(); - VMMemRegion* reg = (VMMemRegion*)current(); - while (reg != NULL) { - if (reg->is_reserved_region()) { - if (reg->contains_address(addr) || addr < reg->base()) { - return reg; - } - } - reg = (VMMemRegion*)next(); - } - return NULL; - } - - // following methods update virtual memory in the context - // of 'current' position, which is properly positioned by - // callers via locate method. - bool add_reserved_region(MemPointerRecord* rec); - bool add_committed_region(MemPointerRecord* rec); - bool remove_uncommitted_region(MemPointerRecord* rec); - bool remove_released_region(MemPointerRecord* rec); - - // split a reserved region to create a new memory region with specified base and size - bool split_reserved_region(VMMemRegion* rgn, address new_rgn_addr, size_t new_rgn_size); - private: - bool insert_record(MemPointerRecord* rec); - bool insert_record_after(MemPointerRecord* rec); - - bool insert_reserved_region(MemPointerRecord* rec); - - // reset current position - inline void reset() { _pos = 0; } -#ifdef ASSERT - // check integrity of records on current reserved memory region. - bool check_reserved_region() { - VMMemRegion* reserved_region = (VMMemRegion*)current(); - assert(reserved_region != NULL && reserved_region->is_reserved_region(), - "Sanity check"); - // all committed regions that follow current reserved region, should all - // belong to the reserved region. - VMMemRegion* next_region = (VMMemRegion*)next(); - for (; next_region != NULL && next_region->is_committed_region(); - next_region = (VMMemRegion*)next() ) { - if(!reserved_region->contains_region(next_region)) { - return false; - } - } - return true; - } - - virtual bool is_dup_pointer(const MemPointer* ptr1, - const MemPointer* ptr2) const { - VMMemRegion* p1 = (VMMemRegion*)ptr1; - VMMemRegion* p2 = (VMMemRegion*)ptr2; - - if (p1->addr() != p2->addr()) return false; - if ((p1->flags() & MemPointerRecord::tag_masks) != - (p2->flags() & MemPointerRecord::tag_masks)) { - return false; - } - // we do see multiple commit/uncommit on the same memory, it is ok - return (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_alloc || - (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_release; - } -#endif -}; - -class MallocRecordIterator : public MemPointerArrayIterator { - private: - MemPointerArrayIteratorImpl _itr; - - - - public: - MallocRecordIterator(MemPointerArray* arr) : _itr(arr) { - } - - virtual MemPointer* current() const { -#ifdef ASSERT - MemPointer* cur_rec = _itr.current(); - if (cur_rec != NULL) { - MemPointer* prev_rec = _itr.peek_prev(); - MemPointer* next_rec = _itr.peek_next(); - assert(prev_rec == NULL || prev_rec->addr() < cur_rec->addr(), "Sorting order"); - assert(next_rec == NULL || next_rec->addr() > cur_rec->addr(), "Sorting order"); - } -#endif - return _itr.current(); - } - virtual MemPointer* next() { - MemPointerRecord* next_rec = (MemPointerRecord*)_itr.next(); - // arena memory record is a special case, which we have to compare - // sequence number against its associated arena record. - if (next_rec != NULL && next_rec->is_arena_memory_record()) { - MemPointerRecord* prev_rec = (MemPointerRecord*)_itr.peek_prev(); - // if there is an associated arena record, it has to be previous - // record because of sorting order (by address) - NMT generates a pseudo address - // for arena's size record by offsetting arena's address, that guarantees - // the order of arena record and it's size record. - if (prev_rec != NULL && prev_rec->is_arena_record() && - next_rec->is_memory_record_of_arena(prev_rec)) { - if (prev_rec->seq() > next_rec->seq()) { - // Skip this arena memory record - // Two scenarios: - // - if the arena record is an allocation record, this early - // size record must be leftover by previous arena, - // and the last size record should have size = 0. - // - if the arena record is a deallocation record, this - // size record should be its cleanup record, which should - // also have size = 0. In other world, arena alway reset - // its size before gone (see Arena's destructor) - assert(next_rec->size() == 0, "size not reset"); - return _itr.next(); - } else { - assert(prev_rec->is_allocation_record(), - "Arena size record ahead of allocation record"); - } - } - } - return next_rec; - } - - MemPointer* peek_next() const { ShouldNotReachHere(); return NULL; } - MemPointer* peek_prev() const { ShouldNotReachHere(); return NULL; } - void remove() { ShouldNotReachHere(); } - bool insert(MemPointer* ptr) { ShouldNotReachHere(); return false; } - bool insert_after(MemPointer* ptr) { ShouldNotReachHere(); return false; } -}; - -// collapse duplicated records. Eliminating duplicated records here, is much -// cheaper than during promotion phase. However, it does have limitation - it -// can only eliminate duplicated records within the generation, there are -// still chances seeing duplicated records during promotion. -// We want to use the record with higher sequence number, because it has -// more accurate callsite pc. -class VMRecordIterator : public MemPointerArrayIterator { - private: - MemPointerArrayIteratorImpl _itr; - - public: - VMRecordIterator(MemPointerArray* arr) : _itr(arr) { - MemPointerRecord* cur = (MemPointerRecord*)_itr.current(); - MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next(); - while (next != NULL) { - assert(cur != NULL, "Sanity check"); - assert(((SeqMemPointerRecord*)next)->seq() > ((SeqMemPointerRecord*)cur)->seq(), - "pre-sort order"); - - if (is_duplicated_record(cur, next)) { - _itr.next(); - next = (MemPointerRecord*)_itr.peek_next(); - } else { - break; - } - } - } - - virtual MemPointer* current() const { - return _itr.current(); - } - - // get next record, but skip the duplicated records - virtual MemPointer* next() { - MemPointerRecord* cur = (MemPointerRecord*)_itr.next(); - MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next(); - while (next != NULL) { - assert(cur != NULL, "Sanity check"); - assert(((SeqMemPointerRecord*)next)->seq() > ((SeqMemPointerRecord*)cur)->seq(), - "pre-sort order"); - - if (is_duplicated_record(cur, next)) { - _itr.next(); - cur = next; - next = (MemPointerRecord*)_itr.peek_next(); - } else { - break; - } - } - return cur; - } - - MemPointer* peek_next() const { ShouldNotReachHere(); return NULL; } - MemPointer* peek_prev() const { ShouldNotReachHere(); return NULL; } - void remove() { ShouldNotReachHere(); } - bool insert(MemPointer* ptr) { ShouldNotReachHere(); return false; } - bool insert_after(MemPointer* ptr) { ShouldNotReachHere(); return false; } - - private: - bool is_duplicated_record(MemPointerRecord* p1, MemPointerRecord* p2) const { - bool ret = (p1->addr() == p2->addr() && p1->size() == p2->size() && p1->flags() == p2->flags()); - assert(!(ret && FLAGS_TO_MEMORY_TYPE(p1->flags()) == mtThreadStack), "dup on stack record"); - return ret; - } -}; - -class StagingArea VALUE_OBJ_CLASS_SPEC { - private: - MemPointerArray* _malloc_data; - MemPointerArray* _vm_data; - - public: - StagingArea() : _malloc_data(NULL), _vm_data(NULL) { - init(); - } - - ~StagingArea() { - if (_malloc_data != NULL) delete _malloc_data; - if (_vm_data != NULL) delete _vm_data; - } - - MallocRecordIterator malloc_record_walker() { - return MallocRecordIterator(malloc_data()); - } - - VMRecordIterator virtual_memory_record_walker(); - - bool init(); - void clear() { - assert(_malloc_data != NULL && _vm_data != NULL, "Just check"); - _malloc_data->shrink(); - _malloc_data->clear(); - _vm_data->clear(); - } - - inline MemPointerArray* malloc_data() { return _malloc_data; } - inline MemPointerArray* vm_data() { return _vm_data; } -}; - -class MemBaseline; -class MemSnapshot : public CHeapObj { - private: - // the following two arrays contain records of all known lived memory blocks - // live malloc-ed memory pointers - MemPointerArray* _alloc_ptrs; - // live virtual memory pointers - MemPointerArray* _vm_ptrs; - - StagingArea _staging_area; - - // the lock to protect this snapshot - Monitor* _lock; - - // the number of instance classes - int _number_of_classes; - - NOT_PRODUCT(size_t _untracked_count;) - friend class MemBaseline; - - public: - MemSnapshot(); - virtual ~MemSnapshot(); - - // if we are running out of native memory - bool out_of_memory() { - return (_alloc_ptrs == NULL || - _staging_area.malloc_data() == NULL || - _staging_area.vm_data() == NULL || - _vm_ptrs == NULL || _lock == NULL || - _alloc_ptrs->out_of_memory() || - _vm_ptrs->out_of_memory()); - } - - // merge a per-thread memory recorder into staging area - bool merge(MemRecorder* rec); - // promote staged data to snapshot - bool promote(int number_of_classes); - - int number_of_classes() const { return _number_of_classes; } - - void wait(long timeout) { - assert(_lock != NULL, "Just check"); - MonitorLockerEx locker(_lock); - locker.wait(true, timeout); - } - - NOT_PRODUCT(void print_snapshot_stats(outputStream* st);) - NOT_PRODUCT(void check_staging_data();) - NOT_PRODUCT(void check_malloc_pointers();) - NOT_PRODUCT(bool has_allocation_record(address addr);) - // dump all virtual memory pointers in snapshot - DEBUG_ONLY( void dump_all_vm_pointers();) - - private: - // copy sequenced pointer from src to dest - void copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src); - // assign a sequenced pointer to non-sequenced pointer - void assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src); - - bool promote_malloc_records(MemPointerArrayIterator* itr); - bool promote_virtual_memory_records(MemPointerArrayIterator* itr); -}; - -#endif // SHARE_VM_SERVICES_MEM_SNAPSHOT_HPP diff --git a/hotspot/src/share/vm/services/memTrackWorker.cpp b/hotspot/src/share/vm/services/memTrackWorker.cpp deleted file mode 100644 index 7bf18eb273c..00000000000 --- a/hotspot/src/share/vm/services/memTrackWorker.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "runtime/threadCritical.hpp" -#include "services/memTracker.hpp" -#include "services/memTrackWorker.hpp" -#include "utilities/decoder.hpp" -#include "utilities/vmError.hpp" - - -void GenerationData::reset() { - _number_of_classes = 0; - while (_recorder_list != NULL) { - MemRecorder* tmp = _recorder_list; - _recorder_list = _recorder_list->next(); - MemTracker::release_thread_recorder(tmp); - } -} - -MemTrackWorker::MemTrackWorker(MemSnapshot* snapshot): _snapshot(snapshot) { - // create thread uses cgc thread type for now. We should revisit - // the option, or create new thread type. - _has_error = !os::create_thread(this, os::cgc_thread); - set_name("MemTrackWorker"); - - // initial generation circuit buffer - if (!has_error()) { - _head = _tail = 0; - for(int index = 0; index < MAX_GENERATIONS; index ++) { - ::new ((void*)&_gen[index]) GenerationData(); - } - } - NOT_PRODUCT(_sync_point_count = 0;) - NOT_PRODUCT(_merge_count = 0;) - NOT_PRODUCT(_last_gen_in_use = 0;) -} - -MemTrackWorker::~MemTrackWorker() { - for (int index = 0; index < MAX_GENERATIONS; index ++) { - _gen[index].reset(); - } -} - -void* MemTrackWorker::operator new(size_t size) throw() { - assert(false, "use nothrow version"); - return NULL; -} - -void* MemTrackWorker::operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() { - return allocate(size, false, mtNMT); -} - -void MemTrackWorker::start() { - os::start_thread(this); -} - -/* - * Native memory tracking worker thread loop: - * 1. merge one generation of memory recorders to staging area - * 2. promote staging data to memory snapshot - * - * This thread can run through safepoint. - */ - -void MemTrackWorker::run() { - assert(MemTracker::is_on(), "native memory tracking is off"); - this->initialize_thread_local_storage(); - this->record_stack_base_and_size(); - assert(_snapshot != NULL, "Worker should not be started"); - MemRecorder* rec; - unsigned long processing_generation = 0; - bool worker_idle = false; - - while (!MemTracker::shutdown_in_progress()) { - NOT_PRODUCT(_last_gen_in_use = generations_in_use();) - { - // take a recorder from earliest generation in buffer - ThreadCritical tc; - rec = _gen[_head].next_recorder(); - } - if (rec != NULL) { - if (rec->get_generation() != processing_generation || worker_idle) { - processing_generation = rec->get_generation(); - worker_idle = false; - MemTracker::set_current_processing_generation(processing_generation); - } - - // merge the recorder into staging area - if (!_snapshot->merge(rec)) { - MemTracker::shutdown(MemTracker::NMT_out_of_memory); - } else { - NOT_PRODUCT(_merge_count ++;) - } - MemTracker::release_thread_recorder(rec); - } else { - // no more recorder to merge, promote staging area - // to snapshot - if (_head != _tail) { - long number_of_classes; - { - ThreadCritical tc; - if (_gen[_head].has_more_recorder() || _head == _tail) { - continue; - } - number_of_classes = _gen[_head].number_of_classes(); - _gen[_head].reset(); - - // done with this generation, increment _head pointer - _head = (_head + 1) % MAX_GENERATIONS; - } - // promote this generation data to snapshot - if (!_snapshot->promote(number_of_classes)) { - // failed to promote, means out of memory - MemTracker::shutdown(MemTracker::NMT_out_of_memory); - } - } else { - // worker thread is idle - worker_idle = true; - MemTracker::report_worker_idle(); - _snapshot->wait(1000); - ThreadCritical tc; - // check if more data arrived - if (!_gen[_head].has_more_recorder()) { - _gen[_head].add_recorders(MemTracker::get_pending_recorders()); - } - } - } - } - assert(MemTracker::shutdown_in_progress(), "just check"); - - // transits to final shutdown - MemTracker::final_shutdown(); -} - -// at synchronization point, where 'safepoint visible' Java threads are blocked -// at a safepoint, and the rest of threads are blocked on ThreadCritical lock. -// The caller MemTracker::sync() already takes ThreadCritical before calling this -// method. -// -// Following tasks are performed: -// 1. add all recorders in pending queue to current generation -// 2. increase generation - -void MemTrackWorker::at_sync_point(MemRecorder* rec, int number_of_classes) { - NOT_PRODUCT(_sync_point_count ++;) - assert(count_recorder(rec) <= MemRecorder::_instance_count, - "pending queue has infinite loop"); - - bool out_of_generation_buffer = false; - // check shutdown state inside ThreadCritical - if (MemTracker::shutdown_in_progress()) return; - - _gen[_tail].set_number_of_classes(number_of_classes); - // append the recorders to the end of the generation - _gen[_tail].add_recorders(rec); - assert(count_recorder(_gen[_tail].peek()) <= MemRecorder::_instance_count, - "after add to current generation has infinite loop"); - // we have collected all recorders for this generation. If there is data, - // we need to increment _tail to start a new generation. - if (_gen[_tail].has_more_recorder() || _head == _tail) { - _tail = (_tail + 1) % MAX_GENERATIONS; - out_of_generation_buffer = (_tail == _head); - } - - if (out_of_generation_buffer) { - MemTracker::shutdown(MemTracker::NMT_out_of_generation); - } -} - -#ifndef PRODUCT -int MemTrackWorker::count_recorder(const MemRecorder* head) { - int count = 0; - while(head != NULL) { - count ++; - head = head->next(); - } - return count; -} - -int MemTrackWorker::count_pending_recorders() const { - int count = 0; - for (int index = 0; index < MAX_GENERATIONS; index ++) { - MemRecorder* head = _gen[index].peek(); - if (head != NULL) { - count += count_recorder(head); - } - } - return count; -} -#endif diff --git a/hotspot/src/share/vm/services/memTrackWorker.hpp b/hotspot/src/share/vm/services/memTrackWorker.hpp deleted file mode 100644 index ee45244e324..00000000000 --- a/hotspot/src/share/vm/services/memTrackWorker.hpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP -#define SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP - -#include "memory/allocation.hpp" -#include "runtime/thread.hpp" -#include "services/memRecorder.hpp" - -// Maximum MAX_GENERATIONS generation data can be tracked. -#define MAX_GENERATIONS 512 - -class GenerationData VALUE_OBJ_CLASS_SPEC { - private: - int _number_of_classes; - MemRecorder* _recorder_list; - - public: - GenerationData(): _number_of_classes(0), _recorder_list(NULL) { } - - inline int number_of_classes() const { return _number_of_classes; } - inline void set_number_of_classes(long num) { _number_of_classes = num; } - - inline MemRecorder* next_recorder() { - if (_recorder_list == NULL) { - return NULL; - } else { - MemRecorder* tmp = _recorder_list; - _recorder_list = _recorder_list->next(); - return tmp; - } - } - - inline bool has_more_recorder() const { - return (_recorder_list != NULL); - } - - // add recorders to this generation - void add_recorders(MemRecorder* head) { - if (head != NULL) { - if (_recorder_list == NULL) { - _recorder_list = head; - } else { - MemRecorder* tmp = _recorder_list; - for (; tmp->next() != NULL; tmp = tmp->next()); - tmp->set_next(head); - } - } - } - - void reset(); - - NOT_PRODUCT(MemRecorder* peek() const { return _recorder_list; }) -}; - -class MemTrackWorker : public NamedThread { - private: - // circular buffer. This buffer contains generation data to be merged into global - // snaphsot. - // Each slot holds a generation - GenerationData _gen[MAX_GENERATIONS]; - int _head, _tail; // head and tail pointers to above circular buffer - - bool _has_error; - - MemSnapshot* _snapshot; - - public: - MemTrackWorker(MemSnapshot* snapshot); - ~MemTrackWorker(); - _NOINLINE_ void* operator new(size_t size) throw(); - _NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw(); - - void start(); - void run(); - - inline bool has_error() const { return _has_error; } - - // task at synchronization point - void at_sync_point(MemRecorder* pending_recorders, int number_of_classes); - - // for debugging purpose, they are not thread safe. - NOT_PRODUCT(static int count_recorder(const MemRecorder* head);) - NOT_PRODUCT(int count_pending_recorders() const;) - - NOT_PRODUCT(int _sync_point_count;) - NOT_PRODUCT(int _merge_count;) - NOT_PRODUCT(int _last_gen_in_use;) - - // how many generations are queued - inline int generations_in_use() const { - return (_tail >= _head ? (_tail - _head + 1) : (MAX_GENERATIONS - (_head - _tail) + 1)); - } -}; - -#endif // SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP diff --git a/hotspot/src/share/vm/services/memTracker.cpp b/hotspot/src/share/vm/services/memTracker.cpp index 190c004b374..e66d6fe6be6 100644 --- a/hotspot/src/share/vm/services/memTracker.cpp +++ b/hotspot/src/share/vm/services/memTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,862 +23,308 @@ */ #include "precompiled.hpp" -#include "oops/instanceKlass.hpp" -#include "runtime/atomic.inline.hpp" -#include "runtime/interfaceSupport.hpp" -#include "runtime/mutexLocker.hpp" -#include "runtime/safepoint.hpp" -#include "runtime/threadCritical.hpp" -#include "runtime/thread.inline.hpp" -#include "runtime/vm_operations.hpp" -#include "services/memPtr.hpp" +#include "runtime/mutex.hpp" +#include "services/memBaseline.hpp" #include "services/memReporter.hpp" +#include "services/mallocTracker.inline.hpp" #include "services/memTracker.hpp" -#include "utilities/decoder.hpp" #include "utilities/defaultStream.hpp" -#include "utilities/globalDefinitions.hpp" -bool NMT_track_callsite = false; +#ifdef SOLARIS + volatile bool NMT_stack_walkable = false; +#else + volatile bool NMT_stack_walkable = true; +#endif -// walk all 'known' threads at NMT sync point, and collect their recorders -void SyncThreadRecorderClosure::do_thread(Thread* thread) { - assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required"); - if (thread->is_Java_thread()) { - JavaThread* javaThread = (JavaThread*)thread; - MemRecorder* recorder = javaThread->get_recorder(); - if (recorder != NULL) { - MemTracker::enqueue_pending_recorder(recorder); - javaThread->set_recorder(NULL); +volatile NMT_TrackingLevel MemTracker::_tracking_level = NMT_unknown; +NMT_TrackingLevel MemTracker::_cmdline_tracking_level = NMT_unknown; + +NativeCallStack emptyStack(0, false); + +MemBaseline MemTracker::_baseline; +Mutex* MemTracker::_query_lock = NULL; +bool MemTracker::_is_nmt_env_valid = true; + + +NMT_TrackingLevel MemTracker::init_tracking_level() { + NMT_TrackingLevel level = NMT_off; + char buf[64]; + char nmt_option[64]; + jio_snprintf(buf, sizeof(buf), "NMT_LEVEL_%d", os::current_process_id()); + if (os::getenv(buf, nmt_option, sizeof(nmt_option))) { + if (strcmp(nmt_option, "summary") == 0) { + level = NMT_summary; + } else if (strcmp(nmt_option, "detail") == 0) { +#if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED + level = NMT_detail; +#else + level = NMT_summary; +#endif // PLATFORM_NATIVE_STACK_WALKING_SUPPORTED + } else if (strcmp(nmt_option, "off") != 0) { + // The option value is invalid + _is_nmt_env_valid = false; } + + // Remove the environment variable to avoid leaking to child processes + os::unsetenv(buf); } - _thread_count ++; + + if (!MallocTracker::initialize(level) || + !VirtualMemoryTracker::initialize(level)) { + level = NMT_off; + } + return level; } +void MemTracker::init() { + if (tracking_level() >= NMT_summary) { + _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock"); + // Already OOM. It is unlikely, but still have to handle it. + if (_query_lock == NULL) { + shutdown(); + } + } +} -MemRecorder* volatile MemTracker::_global_recorder = NULL; -MemSnapshot* MemTracker::_snapshot = NULL; -MemBaseline MemTracker::_baseline; -Mutex* MemTracker::_query_lock = NULL; -MemRecorder* volatile MemTracker::_merge_pending_queue = NULL; -MemRecorder* volatile MemTracker::_pooled_recorders = NULL; -MemTrackWorker* MemTracker::_worker_thread = NULL; -int MemTracker::_sync_point_skip_count = 0; -MemTracker::NMTLevel MemTracker::_tracking_level = MemTracker::NMT_off; -volatile MemTracker::NMTStates MemTracker::_state = NMT_uninited; -MemTracker::ShutdownReason MemTracker::_reason = NMT_shutdown_none; -int MemTracker::_thread_count = 255; -volatile jint MemTracker::_pooled_recorder_count = 0; -volatile unsigned long MemTracker::_processing_generation = 0; -volatile bool MemTracker::_worker_thread_idle = false; -volatile jint MemTracker::_pending_op_count = 0; -volatile bool MemTracker::_slowdown_calling_thread = false; -debug_only(intx MemTracker::_main_thread_tid = 0;) -NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;) - -void MemTracker::init_tracking_options(const char* option_line) { - _tracking_level = NMT_off; - if (strcmp(option_line, "=summary") == 0) { - _tracking_level = NMT_summary; - } else if (strcmp(option_line, "=detail") == 0) { - // detail relies on a stack-walking ability that may not - // be available depending on platform and/or compiler flags -#if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED - _tracking_level = NMT_detail; -#else +bool MemTracker::check_launcher_nmt_support(const char* value) { + if (strcmp(value, "=detail") == 0) { +#if !PLATFORM_NATIVE_STACK_WALKING_SUPPORTED jio_fprintf(defaultStream::error_stream(), "NMT detail is not supported on this platform. Using NMT summary instead.\n"); - _tracking_level = NMT_summary; + if (MemTracker::tracking_level() != NMT_summary) { + return false; + } +#else + if (MemTracker::tracking_level() != NMT_detail) { + return false; + } #endif - } else if (strcmp(option_line, "=off") != 0) { - vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); - } -} - -// first phase of bootstrapping, when VM is still in single-threaded mode. -void MemTracker::bootstrap_single_thread() { - if (_tracking_level > NMT_off) { - assert(_state == NMT_uninited, "wrong state"); - - // NMT is not supported with UseMallocOnly is on. NMT can NOT - // handle the amount of malloc data without significantly impacting - // runtime performance when this flag is on. - if (UseMallocOnly) { - shutdown(NMT_use_malloc_only); - return; + } else if (strcmp(value, "=summary") == 0) { + if (MemTracker::tracking_level() != NMT_summary) { + return false; } - - _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock"); - if (_query_lock == NULL) { - shutdown(NMT_out_of_memory); - return; + } else if (strcmp(value, "=off") == 0) { + if (MemTracker::tracking_level() != NMT_off) { + return false; } - - debug_only(_main_thread_tid = os::current_thread_id();) - _state = NMT_bootstrapping_single_thread; - NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack()); - } -} - -// second phase of bootstrapping, when VM is about to or already entered multi-theaded mode. -void MemTracker::bootstrap_multi_thread() { - if (_tracking_level > NMT_off && _state == NMT_bootstrapping_single_thread) { - // create nmt lock for multi-thread execution - assert(_main_thread_tid == os::current_thread_id(), "wrong thread"); - _state = NMT_bootstrapping_multi_thread; - NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack()); - } -} - -// fully start nmt -void MemTracker::start() { - // Native memory tracking is off from command line option - if (_tracking_level == NMT_off || shutdown_in_progress()) return; - - assert(_main_thread_tid == os::current_thread_id(), "wrong thread"); - assert(_state == NMT_bootstrapping_multi_thread, "wrong state"); - - _snapshot = new (std::nothrow)MemSnapshot(); - if (_snapshot != NULL) { - if (!_snapshot->out_of_memory() && start_worker(_snapshot)) { - _state = NMT_started; - NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack()); - return; - } - - delete _snapshot; - _snapshot = NULL; - } - - // fail to start native memory tracking, shut it down - shutdown(NMT_initialization); -} - -/** - * Shutting down native memory tracking. - * We can not shutdown native memory tracking immediately, so we just - * setup shutdown pending flag, every native memory tracking component - * should orderly shut itself down. - * - * The shutdown sequences: - * 1. MemTracker::shutdown() sets MemTracker to shutdown pending state - * 2. Worker thread calls MemTracker::final_shutdown(), which transites - * MemTracker to final shutdown state. - * 3. At sync point, MemTracker does final cleanup, before sets memory - * tracking level to off to complete shutdown. - */ -void MemTracker::shutdown(ShutdownReason reason) { - if (_tracking_level == NMT_off) return; - - if (_state <= NMT_bootstrapping_single_thread) { - // we still in single thread mode, there is not contention - _state = NMT_shutdown_pending; - _reason = reason; } else { - // we want to know who initialized shutdown - if ((jint)NMT_started == Atomic::cmpxchg((jint)NMT_shutdown_pending, - (jint*)&_state, (jint)NMT_started)) { - _reason = reason; - } - } -} - -// final phase of shutdown -void MemTracker::final_shutdown() { - // delete all pending recorders and pooled recorders - delete_all_pending_recorders(); - delete_all_pooled_recorders(); - - { - // shared baseline and snapshot are the only objects needed to - // create query results - MutexLockerEx locker(_query_lock, true); - // cleanup baseline data and snapshot - _baseline.clear(); - delete _snapshot; - _snapshot = NULL; + _is_nmt_env_valid = false; } - // shutdown shared decoder instance, since it is only - // used by native memory tracking so far. - Decoder::shutdown(); - - MemTrackWorker* worker = NULL; - { - ThreadCritical tc; - // can not delete worker inside the thread critical - if (_worker_thread != NULL && Thread::current() == _worker_thread) { - worker = _worker_thread; - _worker_thread = NULL; - } - } - if (worker != NULL) { - delete worker; - } - _state = NMT_final_shutdown; -} - -// delete all pooled recorders -void MemTracker::delete_all_pooled_recorders() { - // free all pooled recorders - MemRecorder* volatile cur_head = _pooled_recorders; - if (cur_head != NULL) { - MemRecorder* null_ptr = NULL; - while (cur_head != NULL && (void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr, - (void*)&_pooled_recorders, (void*)cur_head)) { - cur_head = _pooled_recorders; - } - if (cur_head != NULL) { - delete cur_head; - _pooled_recorder_count = 0; - } - } -} - -// delete all recorders in pending queue -void MemTracker::delete_all_pending_recorders() { - // free all pending recorders - MemRecorder* pending_head = get_pending_recorders(); - if (pending_head != NULL) { - delete pending_head; - } -} - -/* - * retrieve per-thread recorder of specified thread. - * if thread == NULL, it means global recorder - */ -MemRecorder* MemTracker::get_thread_recorder(JavaThread* thread) { - if (shutdown_in_progress()) return NULL; - - MemRecorder* rc; - if (thread == NULL) { - rc = _global_recorder; - } else { - rc = thread->get_recorder(); - } - - if (rc != NULL && rc->is_full()) { - enqueue_pending_recorder(rc); - rc = NULL; - } - - if (rc == NULL) { - rc = get_new_or_pooled_instance(); - if (thread == NULL) { - _global_recorder = rc; - } else { - thread->set_recorder(rc); - } - } - return rc; -} - -/* - * get a per-thread recorder from pool, or create a new one if - * there is not one available. - */ -MemRecorder* MemTracker::get_new_or_pooled_instance() { - MemRecorder* cur_head = const_cast (_pooled_recorders); - if (cur_head == NULL) { - MemRecorder* rec = new (std::nothrow)MemRecorder(); - if (rec == NULL || rec->out_of_memory()) { - shutdown(NMT_out_of_memory); - if (rec != NULL) { - delete rec; - rec = NULL; - } - } - return rec; - } else { - MemRecorder* next_head = cur_head->next(); - if ((void*)cur_head != Atomic::cmpxchg_ptr((void*)next_head, (void*)&_pooled_recorders, - (void*)cur_head)) { - return get_new_or_pooled_instance(); - } - cur_head->set_next(NULL); - Atomic::dec(&_pooled_recorder_count); - cur_head->set_generation(); - return cur_head; - } -} - -/* - * retrieve all recorders in pending queue, and empty the queue - */ -MemRecorder* MemTracker::get_pending_recorders() { - MemRecorder* cur_head = const_cast(_merge_pending_queue); - MemRecorder* null_ptr = NULL; - while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr, (void*)&_merge_pending_queue, - (void*)cur_head)) { - cur_head = const_cast(_merge_pending_queue); - } - NOT_PRODUCT(Atomic::store(0, &_pending_recorder_count)); - return cur_head; -} - -/* - * release a recorder to recorder pool. - */ -void MemTracker::release_thread_recorder(MemRecorder* rec) { - assert(rec != NULL, "null recorder"); - // we don't want to pool too many recorders - rec->set_next(NULL); - if (shutdown_in_progress() || _pooled_recorder_count > _thread_count * 2) { - delete rec; - return; - } - - rec->clear(); - MemRecorder* cur_head = const_cast(_pooled_recorders); - rec->set_next(cur_head); - while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)rec, (void*)&_pooled_recorders, - (void*)cur_head)) { - cur_head = const_cast(_pooled_recorders); - rec->set_next(cur_head); - } - Atomic::inc(&_pooled_recorder_count); -} - -// write a record to proper recorder. No lock can be taken from this method -// down. -void MemTracker::write_tracking_record(address addr, MEMFLAGS flags, - size_t size, jint seq, address pc, JavaThread* thread) { - - MemRecorder* rc = get_thread_recorder(thread); - if (rc != NULL) { - rc->record(addr, flags, size, seq, pc); - } -} - -/** - * enqueue a recorder to pending queue - */ -void MemTracker::enqueue_pending_recorder(MemRecorder* rec) { - assert(rec != NULL, "null recorder"); - - // we are shutting down, so just delete it - if (shutdown_in_progress()) { - rec->set_next(NULL); - delete rec; - return; - } - - MemRecorder* cur_head = const_cast(_merge_pending_queue); - rec->set_next(cur_head); - while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)rec, (void*)&_merge_pending_queue, - (void*)cur_head)) { - cur_head = const_cast(_merge_pending_queue); - rec->set_next(cur_head); - } - NOT_PRODUCT(Atomic::inc(&_pending_recorder_count);) -} - -/* - * The method is called at global safepoint - * during it synchronization process. - * 1. enqueue all JavaThreads' per-thread recorders - * 2. enqueue global recorder - * 3. retrieve all pending recorders - * 4. reset global sequence number generator - * 5. call worker's sync - */ -#define MAX_SAFEPOINTS_TO_SKIP 128 -#define SAFE_SEQUENCE_THRESHOLD 30 -#define HIGH_GENERATION_THRESHOLD 60 -#define MAX_RECORDER_THREAD_RATIO 30 -#define MAX_RECORDER_PER_THREAD 100 - -void MemTracker::sync() { - assert(_tracking_level > NMT_off, "NMT is not enabled"); - assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required"); - - // Some GC tests hit large number of safepoints in short period of time - // without meaningful activities. We should prevent going to - // sync point in these cases, which can potentially exhaust generation buffer. - // Here is the factots to determine if we should go into sync point: - // 1. not to overflow sequence number - // 2. if we are in danger to overflow generation buffer - // 3. how many safepoints we already skipped sync point - if (_state == NMT_started) { - // worker thread is not ready, no one can manage generation - // buffer, so skip this safepoint - if (_worker_thread == NULL) return; - - if (_sync_point_skip_count < MAX_SAFEPOINTS_TO_SKIP) { - int per_seq_in_use = SequenceGenerator::peek() * 100 / max_jint; - int per_gen_in_use = _worker_thread->generations_in_use() * 100 / MAX_GENERATIONS; - if (per_seq_in_use < SAFE_SEQUENCE_THRESHOLD && per_gen_in_use >= HIGH_GENERATION_THRESHOLD) { - _sync_point_skip_count ++; - return; - } - } - { - // This method is running at safepoint, with ThreadCritical lock, - // it should guarantee that NMT is fully sync-ed. - ThreadCritical tc; - - // We can NOT execute NMT sync-point if there are pending tracking ops. - if (_pending_op_count == 0) { - SequenceGenerator::reset(); - _sync_point_skip_count = 0; - - // walk all JavaThreads to collect recorders - SyncThreadRecorderClosure stc; - Threads::threads_do(&stc); - - _thread_count = stc.get_thread_count(); - MemRecorder* pending_recorders = get_pending_recorders(); - - if (_global_recorder != NULL) { - _global_recorder->set_next(pending_recorders); - pending_recorders = _global_recorder; - _global_recorder = NULL; - } - - // see if NMT has too many outstanding recorder instances, it usually - // means that worker thread is lagging behind in processing them. - if (!AutoShutdownNMT) { - _slowdown_calling_thread = (MemRecorder::_instance_count > MAX_RECORDER_THREAD_RATIO * _thread_count); - } else { - // If auto shutdown is on, enforce MAX_RECORDER_PER_THREAD threshold to prevent OOM - if (MemRecorder::_instance_count >= _thread_count * MAX_RECORDER_PER_THREAD) { - shutdown(NMT_out_of_memory); - } - } - - // check _worker_thread with lock to avoid racing condition - if (_worker_thread != NULL) { - _worker_thread->at_sync_point(pending_recorders, InstanceKlass::number_of_instance_classes()); - } - assert(SequenceGenerator::peek() == 1, "Should not have memory activities during sync-point"); - } else { - _sync_point_skip_count ++; - } - } - } - - // now, it is the time to shut whole things off - if (_state == NMT_final_shutdown) { - // walk all JavaThreads to delete all recorders - SyncThreadRecorderClosure stc; - Threads::threads_do(&stc); - // delete global recorder - { - ThreadCritical tc; - if (_global_recorder != NULL) { - delete _global_recorder; - _global_recorder = NULL; - } - } - MemRecorder* pending_recorders = get_pending_recorders(); - if (pending_recorders != NULL) { - delete pending_recorders; - } - // try at a later sync point to ensure MemRecorder instance drops to zero to - // completely shutdown NMT - if (MemRecorder::_instance_count == 0) { - _state = NMT_shutdown; - _tracking_level = NMT_off; - } - } -} - -/* - * Start worker thread. - */ -bool MemTracker::start_worker(MemSnapshot* snapshot) { - assert(_worker_thread == NULL && _snapshot != NULL, "Just Check"); - _worker_thread = new (std::nothrow) MemTrackWorker(snapshot); - if (_worker_thread == NULL) { - return false; - } else if (_worker_thread->has_error()) { - delete _worker_thread; - _worker_thread = NULL; - return false; - } - _worker_thread->start(); return true; } -/* - * We need to collect a JavaThread's per-thread recorder - * before it exits. - */ -void MemTracker::thread_exiting(JavaThread* thread) { - if (is_on()) { - MemRecorder* rec = thread->get_recorder(); - if (rec != NULL) { - enqueue_pending_recorder(rec); - thread->set_recorder(NULL); +bool MemTracker::verify_nmt_option() { + return _is_nmt_env_valid; +} + +void* MemTracker::malloc_base(void* memblock) { + return MallocTracker::get_base(memblock); +} + +void Tracker::record(address addr, size_t size) { + if (MemTracker::tracking_level() < NMT_summary) return; + switch(_type) { + case uncommit: + VirtualMemoryTracker::remove_uncommitted_region(addr, size); + break; + case release: + VirtualMemoryTracker::remove_released_region(addr, size); + break; + default: + ShouldNotReachHere(); + } +} + + +// Shutdown can only be issued via JCmd, and NMT JCmd is serialized +// by lock +void MemTracker::shutdown() { + // We can only shutdown NMT to minimal tracking level if it is + // ever on. + if (tracking_level () > NMT_minimal) { + transition_to(NMT_minimal); + } +} + +bool MemTracker::transition_to(NMT_TrackingLevel level) { + NMT_TrackingLevel current_level = tracking_level(); + + if (current_level == level) { + return true; + } else if (current_level > level) { + // Downgrade tracking level, we want to lower the tracking + // level first + _tracking_level = level; + // Make _tracking_level visible immediately. + OrderAccess::fence(); + VirtualMemoryTracker::transition(current_level, level); + MallocTracker::transition(current_level, level); + + if (level == NMT_minimal) _baseline.reset(); + } else { + VirtualMemoryTracker::transition(current_level, level); + MallocTracker::transition(current_level, level); + + _tracking_level = level; + // Make _tracking_level visible immediately. + OrderAccess::fence(); + } + + return true; +} + +void MemTracker::final_report(outputStream* output) { + assert(output != NULL, "No output stream"); + if (tracking_level() >= NMT_summary) { + MallocMemorySnapshot* malloc_memory_snapshot = + MallocMemorySummary::as_snapshot(); + malloc_memory_snapshot->make_adjustment(); + + VirtualMemorySnapshot* virtual_memory_snapshot = + VirtualMemorySummary::as_snapshot(); + + MemSummaryReporter rptr(malloc_memory_snapshot, + virtual_memory_snapshot, output); + rptr.report(); + // shutdown NMT, the data no longer accurate + shutdown(); + } +} + +// This is a walker to gather malloc site hashtable statistics, +// the result is used for tuning. +class StatisticsWalker : public MallocSiteWalker { + private: + enum Threshold { + // aggregates statistics over this threshold into one + // line item. + report_threshold = 20 + }; + + private: + // Number of allocation sites that have all memory freed + int _empty_entries; + // Total number of allocation sites, include empty sites + int _total_entries; + // Number of captured call stack distribution + int _stack_depth_distribution[NMT_TrackingStackDepth]; + // Hash distribution + int _hash_distribution[report_threshold]; + // Number of hash buckets that have entries over the threshold + int _bucket_over_threshold; + + // The hash bucket that walker is currently walking + int _current_hash_bucket; + // The length of current hash bucket + int _current_bucket_length; + // Number of hash buckets that are not empty + int _used_buckets; + // Longest hash bucket length + int _longest_bucket_length; + + public: + StatisticsWalker() : _empty_entries(0), _total_entries(0) { + int index = 0; + for (index = 0; index < NMT_TrackingStackDepth; index ++) { + _stack_depth_distribution[index] = 0; } + for (index = 0; index < report_threshold; index ++) { + _hash_distribution[index] = 0; + } + _bucket_over_threshold = 0; + _longest_bucket_length = 0; + _current_hash_bucket = -1; + _current_bucket_length = 0; + _used_buckets = 0; } -} -// baseline current memory snapshot -bool MemTracker::baseline() { - MutexLocker lock(_query_lock); - MemSnapshot* snapshot = get_snapshot(); - if (snapshot != NULL) { - return _baseline.baseline(*snapshot, false); - } - return false; -} + virtual bool do_malloc_site(const MallocSite* e) { + if (e->size() == 0) _empty_entries ++; + _total_entries ++; -// print memory usage from current snapshot -bool MemTracker::print_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) { - MemBaseline baseline; - MutexLocker lock(_query_lock); - MemSnapshot* snapshot = get_snapshot(); - if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) { - BaselineReporter reporter(out, unit); - reporter.report_baseline(baseline, summary_only); + // stack depth distrubution + int frames = e->call_stack()->frames(); + _stack_depth_distribution[frames - 1] ++; + + // hash distribution + int hash_bucket = e->hash() % MallocSiteTable::hash_buckets(); + if (_current_hash_bucket == -1) { + _current_hash_bucket = hash_bucket; + _current_bucket_length = 1; + } else if (_current_hash_bucket == hash_bucket) { + _current_bucket_length ++; + } else { + record_bucket_length(_current_bucket_length); + _current_hash_bucket = hash_bucket; + _current_bucket_length = 1; + } return true; } - return false; -} -// Whitebox API for blocking until the current generation of NMT data has been merged -bool MemTracker::wbtest_wait_for_data_merge() { - // NMT can't be shutdown while we're holding _query_lock - MutexLocker lock(_query_lock); - assert(_worker_thread != NULL, "Invalid query"); - // the generation at query time, so NMT will spin till this generation is processed - unsigned long generation_at_query_time = SequenceGenerator::current_generation(); - unsigned long current_processing_generation = _processing_generation; - // if generation counter overflown - bool generation_overflown = (generation_at_query_time < current_processing_generation); - long generations_to_wrap = MAX_UNSIGNED_LONG - current_processing_generation; - // spin - while (!shutdown_in_progress()) { - if (!generation_overflown) { - if (current_processing_generation > generation_at_query_time) { - return true; + // walk completed + void completed() { + record_bucket_length(_current_bucket_length); + } + + void report_statistics(outputStream* out) { + int index; + out->print_cr("Malloc allocation site table:"); + out->print_cr("\tTotal entries: %d", _total_entries); + out->print_cr("\tEmpty entries: %d (%2.2f%%)", _empty_entries, ((float)_empty_entries * 100) / _total_entries); + out->print_cr(" "); + out->print_cr("Hash distribution:"); + if (_used_buckets < MallocSiteTable::hash_buckets()) { + out->print_cr("empty bucket: %d", (MallocSiteTable::hash_buckets() - _used_buckets)); + } + for (index = 0; index < report_threshold; index ++) { + if (_hash_distribution[index] != 0) { + if (index == 0) { + out->print_cr(" %d entry: %d", 1, _hash_distribution[0]); + } else if (index < 9) { // single digit + out->print_cr(" %d entries: %d", (index + 1), _hash_distribution[index]); + } else { + out->print_cr(" %d entries: %d", (index + 1), _hash_distribution[index]); + } } + } + if (_bucket_over_threshold > 0) { + out->print_cr(" >%d entries: %d", report_threshold, _bucket_over_threshold); + } + out->print_cr("most entries: %d", _longest_bucket_length); + out->print_cr(" "); + out->print_cr("Call stack depth distribution:"); + for (index = 0; index < NMT_TrackingStackDepth; index ++) { + if (_stack_depth_distribution[index] > 0) { + out->print_cr("\t%d: %d", index + 1, _stack_depth_distribution[index]); + } + } + } + + private: + void record_bucket_length(int length) { + _used_buckets ++; + if (length <= report_threshold) { + _hash_distribution[length - 1] ++; } else { - assert(generations_to_wrap >= 0, "Sanity check"); - long current_generations_to_wrap = MAX_UNSIGNED_LONG - current_processing_generation; - assert(current_generations_to_wrap >= 0, "Sanity check"); - // to overflow an unsigned long should take long time, so to_wrap check should be sufficient - if (current_generations_to_wrap > generations_to_wrap && - current_processing_generation > generation_at_query_time) { - return true; - } + _bucket_over_threshold ++; } - - // if worker thread is idle, but generation is not advancing, that means - // there is not safepoint to let NMT advance generation, force one. - if (_worker_thread_idle) { - VM_ForceSafepoint vfs; - VMThread::execute(&vfs); - } - MemSnapshot* snapshot = get_snapshot(); - if (snapshot == NULL) { - return false; - } - snapshot->wait(1000); - current_processing_generation = _processing_generation; - } - // We end up here if NMT is shutting down before our data has been merged - return false; -} - -// compare memory usage between current snapshot and baseline -bool MemTracker::compare_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) { - MutexLocker lock(_query_lock); - if (_baseline.baselined()) { - MemBaseline baseline; - MemSnapshot* snapshot = get_snapshot(); - if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) { - BaselineReporter reporter(out, unit); - reporter.diff_baselines(baseline, _baseline, summary_only); - return true; - } - } - return false; -} - -#ifndef PRODUCT -void MemTracker::walk_stack(int toSkip, char* buf, int len) { - int cur_len = 0; - char tmp[1024]; - address pc; - - while (cur_len < len) { - pc = os::get_caller_pc(toSkip + 1); - if (pc != NULL && os::dll_address_to_function_name(pc, tmp, sizeof(tmp), NULL)) { - jio_snprintf(&buf[cur_len], (len - cur_len), "%s\n", tmp); - cur_len = (int)strlen(buf); - } else { - buf[cur_len] = '\0'; - break; - } - toSkip ++; - } -} - -void MemTracker::print_tracker_stats(outputStream* st) { - st->print_cr("\nMemory Tracker Stats:"); - st->print_cr("\tMax sequence number = %d", SequenceGenerator::max_seq_num()); - st->print_cr("\tthead count = %d", _thread_count); - st->print_cr("\tArena instance = %d", Arena::_instance_count); - st->print_cr("\tpooled recorder count = %d", _pooled_recorder_count); - st->print_cr("\tqueued recorder count = %d", _pending_recorder_count); - st->print_cr("\tmemory recorder instance count = %d", MemRecorder::_instance_count); - if (_worker_thread != NULL) { - st->print_cr("\tWorker thread:"); - st->print_cr("\t\tSync point count = %d", _worker_thread->_sync_point_count); - st->print_cr("\t\tpending recorder count = %d", _worker_thread->count_pending_recorders()); - st->print_cr("\t\tmerge count = %d", _worker_thread->_merge_count); - } else { - st->print_cr("\tWorker thread is not started"); - } - st->print_cr(" "); - - if (_snapshot != NULL) { - _snapshot->print_snapshot_stats(st); - } else { - st->print_cr("No snapshot"); - } -} -#endif - - -// Tracker Implementation - -/* - * Create a tracker. - * This is a fairly complicated constructor, as it has to make two important decisions: - * 1) Does it need to take ThreadCritical lock to write tracking record - * 2) Does it need to pre-reserve a sequence number for the tracking record - * - * The rules to determine if ThreadCritical is needed: - * 1. When nmt is in single-threaded bootstrapping mode, no lock is needed as VM - * still in single thread mode. - * 2. For all threads other than JavaThread, ThreadCritical is needed - * to write to recorders to global recorder. - * 3. For JavaThreads that are no longer visible by safepoint, also - * need to take ThreadCritical and records are written to global - * recorders, since these threads are NOT walked by Threads.do_thread(). - * 4. JavaThreads that are running in safepoint-safe states do not stop - * for safepoints, ThreadCritical lock should be taken to write - * memory records. - * 5. JavaThreads that are running in VM state do not need any lock and - * records are written to per-thread recorders. - * 6. For a thread has yet to attach VM 'Thread', they need to take - * ThreadCritical to write to global recorder. - * - * The memory operations that need pre-reserve sequence numbers: - * The memory operations that "release" memory blocks and the - * operations can fail, need to pre-reserve sequence number. They - * are realloc, uncommit and release. - * - * The reason for pre-reserve sequence number, is to prevent race condition: - * Thread 1 Thread 2 - * - * - * - * - * if Thread 2 happens to obtain the memory address Thread 1 just released, - * then NMT can mistakenly report the memory is free. - * - * Noticeably, free() does not need pre-reserve sequence number, because the call - * does not fail, so we can alway write "release" record before the memory is actaully - * freed. - * - * For realloc, uncommit and release, following coding pattern should be used: - * - * MemTracker::Tracker tkr = MemTracker::get_realloc_tracker(); - * ptr = ::realloc(...); - * if (ptr == NULL) { - * tkr.record(...) - * } else { - * tkr.discard(); - * } - * - * MemTracker::Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker(); - * if (uncommit(...)) { - * tkr.record(...); - * } else { - * tkr.discard(); - * } - * - * MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - * if (release(...)) { - * tkr.record(...); - * } else { - * tkr.discard(); - * } - * - * Since pre-reserved sequence number is only good for the generation that it is acquired, - * when there is pending Tracker that reserved sequence number, NMT sync-point has - * to be skipped to prevent from advancing generation. This is done by inc and dec - * MemTracker::_pending_op_count, when MemTracker::_pending_op_count > 0, NMT sync-point is skipped. - * Not all pre-reservation of sequence number will increment pending op count. For JavaThreads - * that honor safepoints, safepoint can not occur during the memory operations, so the - * pre-reserved sequence number won't cross the generation boundry. - */ -MemTracker::Tracker::Tracker(MemoryOperation op, Thread* thr) { - _op = NoOp; - _seq = 0; - if (MemTracker::is_on()) { - _java_thread = NULL; - _op = op; - - // figure out if ThreadCritical lock is needed to write this operation - // to MemTracker - if (MemTracker::is_single_threaded_bootstrap()) { - thr = NULL; - } else if (thr == NULL) { - // don't use Thread::current(), since it is possible that - // the calling thread has yet to attach to VM 'Thread', - // which will result assertion failure - thr = ThreadLocalStorage::thread(); - } - - if (thr != NULL) { - // Check NMT load - MemTracker::check_NMT_load(thr); - - if (thr->is_Java_thread() && ((JavaThread*)thr)->is_safepoint_visible()) { - _java_thread = (JavaThread*)thr; - JavaThreadState state = _java_thread->thread_state(); - // JavaThreads that are safepoint safe, can run through safepoint, - // so ThreadCritical is needed to ensure no threads at safepoint create - // new records while the records are being gathered and the sequence number is changing - _need_thread_critical_lock = - SafepointSynchronize::safepoint_safe(_java_thread, state); - } else { - _need_thread_critical_lock = true; - } - } else { - _need_thread_critical_lock - = !MemTracker::is_single_threaded_bootstrap(); - } - - // see if we need to pre-reserve sequence number for this operation - if (_op == Realloc || _op == Uncommit || _op == Release) { - if (_need_thread_critical_lock) { - ThreadCritical tc; - MemTracker::inc_pending_op_count(); - _seq = SequenceGenerator::next(); - } else { - // for the threads that honor safepoints, no safepoint can occur - // during the lifespan of tracker, so we don't need to increase - // pending op count. - _seq = SequenceGenerator::next(); - } - } - } -} - -void MemTracker::Tracker::discard() { - if (MemTracker::is_on() && _seq != 0) { - if (_need_thread_critical_lock) { - ThreadCritical tc; - MemTracker::dec_pending_op_count(); - } - _seq = 0; - } -} - - -void MemTracker::Tracker::record(address old_addr, address new_addr, size_t size, - MEMFLAGS flags, address pc) { - assert(old_addr != NULL && new_addr != NULL, "Sanity check"); - assert(_op == Realloc || _op == NoOp, "Wrong call"); - if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) { - assert(_seq > 0, "Need pre-reserve sequence number"); - if (_need_thread_critical_lock) { - ThreadCritical tc; - // free old address, use pre-reserved sequence number - MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(), - 0, _seq, pc, _java_thread); - MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(), - size, SequenceGenerator::next(), pc, _java_thread); - // decrement MemTracker pending_op_count - MemTracker::dec_pending_op_count(); - } else { - // free old address, use pre-reserved sequence number - MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(), - 0, _seq, pc, _java_thread); - MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(), - size, SequenceGenerator::next(), pc, _java_thread); - } - _seq = 0; - } -} - -void MemTracker::Tracker::record(address addr, size_t size, MEMFLAGS flags, address pc) { - // OOM already? - if (addr == NULL) return; - - if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) { - bool pre_reserved_seq = (_seq != 0); - address pc = CALLER_CALLER_PC; - MEMFLAGS orig_flags = flags; - - // or the tagging flags - switch(_op) { - case Malloc: - flags |= MemPointerRecord::malloc_tag(); - break; - case Free: - flags = MemPointerRecord::free_tag(); - break; - case Realloc: - fatal("Use the other Tracker::record()"); - break; - case Reserve: - case ReserveAndCommit: - flags |= MemPointerRecord::virtual_memory_reserve_tag(); - break; - case Commit: - flags = MemPointerRecord::virtual_memory_commit_tag(); - break; - case Type: - flags |= MemPointerRecord::virtual_memory_type_tag(); - break; - case Uncommit: - assert(pre_reserved_seq, "Need pre-reserve sequence number"); - flags = MemPointerRecord::virtual_memory_uncommit_tag(); - break; - case Release: - assert(pre_reserved_seq, "Need pre-reserve sequence number"); - flags = MemPointerRecord::virtual_memory_release_tag(); - break; - case ArenaSize: - // a bit of hack here, add a small postive offset to arena - // address for its size record, so the size record is sorted - // right after arena record. - flags = MemPointerRecord::arena_size_tag(); - addr += sizeof(void*); - break; - case StackRelease: - flags = MemPointerRecord::virtual_memory_release_tag(); - break; - default: - ShouldNotReachHere(); - } - - // write memory tracking record - if (_need_thread_critical_lock) { - ThreadCritical tc; - if (_seq == 0) _seq = SequenceGenerator::next(); - MemTracker::write_tracking_record(addr, flags, size, _seq, pc, _java_thread); - if (_op == ReserveAndCommit) { - MemTracker::write_tracking_record(addr, orig_flags | MemPointerRecord::virtual_memory_commit_tag(), - size, SequenceGenerator::next(), pc, _java_thread); - } - if (pre_reserved_seq) MemTracker::dec_pending_op_count(); - } else { - if (_seq == 0) _seq = SequenceGenerator::next(); - MemTracker::write_tracking_record(addr, flags, size, _seq, pc, _java_thread); - if (_op == ReserveAndCommit) { - MemTracker::write_tracking_record(addr, orig_flags | MemPointerRecord::virtual_memory_commit_tag(), - size, SequenceGenerator::next(), pc, _java_thread); - } - } - _seq = 0; + _longest_bucket_length = MAX2(_longest_bucket_length, length); } +}; + + +void MemTracker::tuning_statistics(outputStream* out) { + // NMT statistics + StatisticsWalker walker; + MallocSiteTable::walk_malloc_site(&walker); + walker.completed(); + + out->print_cr("Native Memory Tracking Statistics:"); + out->print_cr("Malloc allocation site table size: %d", MallocSiteTable::hash_buckets()); + out->print_cr(" Tracking stack depth: %d", NMT_TrackingStackDepth); + NOT_PRODUCT(out->print_cr("Peak concurrent access: %d", MallocSiteTable::access_peak_count());) + out->print_cr(" "); + walker.report_statistics(out); } diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 8573c1f6530..c256c3e1042 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,566 +25,289 @@ #ifndef SHARE_VM_SERVICES_MEM_TRACKER_HPP #define SHARE_VM_SERVICES_MEM_TRACKER_HPP -#include "utilities/macros.hpp" +#include "services/nmtCommon.hpp" + +class NativeCallStack; +extern NativeCallStack emptyStack; #if !INCLUDE_NMT -#include "utilities/ostream.hpp" +#define CURRENT_PC emptyStack +#define CALLER_PC emptyStack -class BaselineOutputer : public StackObj { - -}; - -class BaselineTTYOutputer : public BaselineOutputer { - public: - BaselineTTYOutputer(outputStream* st) { } +class Tracker : public StackObj { + public: + Tracker() { } + void record(address addr, size_t size) { } }; class MemTracker : AllStatic { - public: - enum ShutdownReason { - NMT_shutdown_none, // no shutdown requested - NMT_shutdown_user, // user requested shutdown - NMT_normal, // normal shutdown, process exit - NMT_out_of_memory, // shutdown due to out of memory - NMT_initialization, // shutdown due to initialization failure - NMT_use_malloc_only, // can not combine NMT with UseMallocOnly flag - NMT_error_reporting, // shutdown by vmError::report_and_die() - NMT_out_of_generation, // running out of generation queue - NMT_sequence_overflow // overflow the sequence number - }; + public: + static inline NMT_TrackingLevel tracking_level() { return NMT_off; } + static inline void shutdown() { } + static inline void init() { } + static bool check_launcher_nmt_support(const char* value) { return true; } + static bool verify_nmt_option() { return true; } - class Tracker { - public: - void discard() { } + static inline void* record_malloc(void* mem_base, size_t size, MEMFLAGS flag, + const NativeCallStack& stack, NMT_TrackingLevel level) { return mem_base; } + static inline size_t malloc_header_size(NMT_TrackingLevel level) { return 0; } + static inline size_t malloc_header_size(void* memblock) { return 0; } + static inline void* malloc_base(void* memblock) { return memblock; } + static inline void* record_free(void* memblock) { return memblock; } - void record(address addr, size_t size = 0, MEMFLAGS flags = mtNone, address pc = NULL) { } - void record(address old_addr, address new_addr, size_t size, - MEMFLAGS flags, address pc = NULL) { } - }; + static inline void record_new_arena(MEMFLAGS flag) { } + static inline void record_arena_free(MEMFLAGS flag) { } + static inline void record_arena_size_change(int diff, MEMFLAGS flag) { } + static inline void record_virtual_memory_reserve(void* addr, size_t size, const NativeCallStack& stack, + MEMFLAGS flag = mtNone) { } + static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size, + const NativeCallStack& stack, MEMFLAGS flag = mtNone) { } + static inline void record_virtual_memory_commit(void* addr, size_t size, const NativeCallStack& stack) { } + static inline Tracker get_virtual_memory_uncommit_tracker() { return Tracker(); } + static inline Tracker get_virtual_memory_release_tracker() { } + static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { } + static inline void record_thread_stack(void* addr, size_t size) { } + static inline void release_thread_stack(void* addr, size_t size) { } - private: - static Tracker _tkr; - - - public: - static inline void init_tracking_options(const char* option_line) { } - static inline bool is_on() { return false; } - static const char* reason() { return "Native memory tracking is not implemented"; } - static inline bool can_walk_stack() { return false; } - - static inline void bootstrap_single_thread() { } - static inline void bootstrap_multi_thread() { } - static inline void start() { } - - static inline void record_malloc(address addr, size_t size, MEMFLAGS flags, - address pc = 0, Thread* thread = NULL) { } - static inline void record_free(address addr, MEMFLAGS flags, Thread* thread = NULL) { } - static inline void record_arena_size(address addr, size_t size) { } - static inline void record_virtual_memory_reserve(address addr, size_t size, - MEMFLAGS flags, address pc = 0, Thread* thread = NULL) { } - static inline void record_virtual_memory_reserve_and_commit(address addr, size_t size, - MEMFLAGS flags, address pc = 0, Thread* thread = NULL) { } - static inline void record_virtual_memory_commit(address addr, size_t size, - address pc = 0, Thread* thread = NULL) { } - static inline void record_virtual_memory_release(address addr, size_t size, - Thread* thread = NULL) { } - static inline void record_virtual_memory_type(address base, MEMFLAGS flags, - Thread* thread = NULL) { } - static inline Tracker get_realloc_tracker() { return _tkr; } - static inline Tracker get_virtual_memory_uncommit_tracker() { return _tkr; } - static inline Tracker get_virtual_memory_release_tracker() { return _tkr; } - static inline bool baseline() { return false; } - static inline bool has_baseline() { return false; } - - static inline void set_autoShutdown(bool value) { } - static void shutdown(ShutdownReason reason) { } - static inline bool shutdown_in_progress() { return false; } - static bool print_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true) { return false; } - static bool compare_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true) { return false; } - - static bool wbtest_wait_for_data_merge() { return false; } - - static inline void sync() { } - static inline void thread_exiting(JavaThread* thread) { } + static void final_report(outputStream*) { } }; - -#else // !INCLUDE_NMT - -#include "memory/allocation.hpp" -#include "runtime/globals.hpp" -#include "runtime/mutex.hpp" -#include "runtime/os.hpp" -#include "runtime/thread.hpp" -#include "services/memPtr.hpp" -#include "services/memRecorder.hpp" -#include "services/memSnapshot.hpp" -#include "services/memTrackWorker.hpp" - -extern bool NMT_track_callsite; - -#ifndef MAX_UNSIGNED_LONG -#define MAX_UNSIGNED_LONG (unsigned long)(-1) -#endif - -#ifdef ASSERT - #define DEBUG_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0) #else - #define DEBUG_CALLER_PC 0 -#endif -// The thread closure walks threads to collect per-thread -// memory recorders at NMT sync point -class SyncThreadRecorderClosure : public ThreadClosure { - private: - int _thread_count; +#include "runtime/atomic.hpp" +#include "runtime/threadCritical.hpp" +#include "services/mallocTracker.hpp" +#include "services/virtualMemoryTracker.hpp" + +extern volatile bool NMT_stack_walkable; + +#define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \ + NativeCallStack(0, true) : emptyStack) +#define CALLER_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \ + NativeCallStack(1, true) : emptyStack) + +class MemBaseline; +class Mutex; + +// Tracker is used for guarding 'release' semantics of virtual memory operation, to avoid +// the other thread obtains and records the same region that is just 'released' by current +// thread but before it can record the operation. +class Tracker : public StackObj { + public: + enum TrackerType { + uncommit, + release + }; public: - SyncThreadRecorderClosure() { - _thread_count =0; - } - - void do_thread(Thread* thread); - int get_thread_count() const { - return _thread_count; - } + Tracker(enum TrackerType type) : _type(type) { } + void record(address addr, size_t size); + private: + enum TrackerType _type; + // Virtual memory tracking data structures are protected by ThreadCritical lock. + ThreadCritical _tc; }; -class BaselineOutputer; -class MemSnapshot; -class MemTrackWorker; -class Thread; -/* - * MemTracker is the 'gate' class to native memory tracking runtime. - */ class MemTracker : AllStatic { - friend class GenerationData; - friend class MemTrackWorker; - friend class MemSnapshot; - friend class SyncThreadRecorderClosure; - - // NMT state - enum NMTStates { - NMT_uninited, // not yet initialized - NMT_bootstrapping_single_thread, // bootstrapping, VM is in single thread mode - NMT_bootstrapping_multi_thread, // bootstrapping, VM is about to enter multi-thread mode - NMT_started, // NMT fully started - NMT_shutdown_pending, // shutdown pending - NMT_final_shutdown, // in final phase of shutdown - NMT_shutdown // shutdown - }; - public: - class Tracker : public StackObj { - friend class MemTracker; - public: - enum MemoryOperation { - NoOp, // no op - Malloc, // malloc - Realloc, // realloc - Free, // free - Reserve, // virtual memory reserve - Commit, // virtual memory commit - ReserveAndCommit, // virtual memory reserve and commit - StackAlloc = ReserveAndCommit, // allocate thread stack - Type, // assign virtual memory type - Uncommit, // virtual memory uncommit - Release, // virtual memory release - ArenaSize, // set arena size - StackRelease // release thread stack - }; - - - protected: - Tracker(MemoryOperation op, Thread* thr = NULL); - - public: - void discard(); - - void record(address addr, size_t size = 0, MEMFLAGS flags = mtNone, address pc = NULL); - void record(address old_addr, address new_addr, size_t size, - MEMFLAGS flags, address pc = NULL); - - private: - bool _need_thread_critical_lock; - JavaThread* _java_thread; - MemoryOperation _op; // memory operation - jint _seq; // reserved sequence number - }; - - - public: - // native memory tracking level - enum NMTLevel { - NMT_off, // native memory tracking is off - NMT_summary, // don't track callsite - NMT_detail // track callsite also - }; - - enum ShutdownReason { - NMT_shutdown_none, // no shutdown requested - NMT_shutdown_user, // user requested shutdown - NMT_normal, // normal shutdown, process exit - NMT_out_of_memory, // shutdown due to out of memory - NMT_initialization, // shutdown due to initialization failure - NMT_use_malloc_only, // can not combine NMT with UseMallocOnly flag - NMT_error_reporting, // shutdown by vmError::report_and_die() - NMT_out_of_generation, // running out of generation queue - NMT_sequence_overflow // overflow the sequence number - }; - - public: - // initialize NMT tracking level from command line options, called - // from VM command line parsing code - static void init_tracking_options(const char* option_line); - - // if NMT is enabled to record memory activities - static inline bool is_on() { - return (_tracking_level >= NMT_summary && - _state >= NMT_bootstrapping_single_thread); - } - - static inline enum NMTLevel tracking_level() { + static inline NMT_TrackingLevel tracking_level() { + if (_tracking_level == NMT_unknown) { + // No fencing is needed here, since JVM is in single-threaded + // mode. + _tracking_level = init_tracking_level(); + _cmdline_tracking_level = _tracking_level; + } return _tracking_level; } - // user readable reason for shutting down NMT - static const char* reason() { - switch(_reason) { - case NMT_shutdown_none: - return "Native memory tracking is not enabled"; - case NMT_shutdown_user: - return "Native memory tracking has been shutdown by user"; - case NMT_normal: - return "Native memory tracking has been shutdown due to process exiting"; - case NMT_out_of_memory: - return "Native memory tracking has been shutdown due to out of native memory"; - case NMT_initialization: - return "Native memory tracking failed to initialize"; - case NMT_error_reporting: - return "Native memory tracking has been shutdown due to error reporting"; - case NMT_out_of_generation: - return "Native memory tracking has been shutdown due to running out of generation buffer"; - case NMT_sequence_overflow: - return "Native memory tracking has been shutdown due to overflow the sequence number"; - case NMT_use_malloc_only: - return "Native memory tracking is not supported when UseMallocOnly is on"; - default: - ShouldNotReachHere(); - return NULL; + // A late initialization, for the stuff(s) can not be + // done in init_tracking_level(), which can NOT malloc + // any memory. + static void init(); + + // Shutdown native memory tracking + static void shutdown(); + + // Verify native memory tracking command line option. + // This check allows JVM to detect if compatible launcher + // is used. + // If an incompatible launcher is used, NMT may not be + // able to start, even it is enabled by command line option. + // A warning message should be given if it is encountered. + static bool check_launcher_nmt_support(const char* value); + + // This method checks native memory tracking environment + // variable value passed by launcher. + // Launcher only obligated to pass native memory tracking + // option value, but not obligated to validate the value, + // and launcher has option to discard native memory tracking + // option from the command line once it sets up the environment + // variable, so NMT has to catch the bad value here. + static bool verify_nmt_option(); + + // Transition the tracking level to specified level + static bool transition_to(NMT_TrackingLevel level); + + static inline void* record_malloc(void* mem_base, size_t size, MEMFLAGS flag, + const NativeCallStack& stack, NMT_TrackingLevel level) { + return MallocTracker::record_malloc(mem_base, size, flag, stack, level); + } + + static inline size_t malloc_header_size(NMT_TrackingLevel level) { + return MallocTracker::malloc_header_size(level); + } + + static size_t malloc_header_size(void* memblock) { + if (tracking_level() != NMT_off) { + return MallocTracker::get_header_size(memblock); + } + return 0; + } + + // To malloc base address, which is the starting address + // of malloc tracking header if tracking is enabled. + // Otherwise, it returns the same address. + static void* malloc_base(void* memblock); + + // Record malloc free and return malloc base address + static inline void* record_free(void* memblock) { + return MallocTracker::record_free(memblock); + } + + + // Record creation of an arena + static inline void record_new_arena(MEMFLAGS flag) { + if (tracking_level() < NMT_summary) return; + MallocTracker::record_new_arena(flag); + } + + // Record destruction of an arena + static inline void record_arena_free(MEMFLAGS flag) { + if (tracking_level() < NMT_summary) return; + MallocTracker::record_arena_free(flag); + } + + // Record arena size change. Arena size is the size of all arena + // chuncks that backing up the arena. + static inline void record_arena_size_change(int diff, MEMFLAGS flag) { + if (tracking_level() < NMT_summary) return; + MallocTracker::record_arena_size_change(diff, flag); + } + + static inline void record_virtual_memory_reserve(void* addr, size_t size, const NativeCallStack& stack, + MEMFLAGS flag = mtNone) { + if (tracking_level() < NMT_summary) return; + if (addr != NULL) { + ThreadCritical tc; + // Recheck to avoid potential racing during NMT shutdown + if (tracking_level() < NMT_summary) return; + VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, flag); } } - // test if we can walk native stack - static bool can_walk_stack() { - // native stack is not walkable during bootstrapping on sparc -#if defined(SPARC) - return (_state == NMT_started); -#else - return (_state >= NMT_bootstrapping_single_thread && _state <= NMT_started); -#endif - } - - // if native memory tracking tracks callsite - static inline bool track_callsite() { return _tracking_level == NMT_detail; } - - // NMT automatically shuts itself down under extreme situation by default. - // When the value is set to false, NMT will try its best to stay alive, - // even it has to slow down VM. - static inline void set_autoShutdown(bool value) { - AutoShutdownNMT = value; - if (AutoShutdownNMT && _slowdown_calling_thread) { - _slowdown_calling_thread = false; + static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size, + const NativeCallStack& stack, MEMFLAGS flag = mtNone) { + if (tracking_level() < NMT_summary) return; + if (addr != NULL) { + ThreadCritical tc; + if (tracking_level() < NMT_summary) return; + VirtualMemoryTracker::add_reserved_region((address)addr, size, + stack, flag, true); } } - // shutdown native memory tracking capability. Native memory tracking - // can be shutdown by VM when it encounters low memory scenarios. - // Memory tracker should gracefully shutdown itself, and preserve the - // latest memory statistics for post morten diagnosis. - static void shutdown(ShutdownReason reason); - - // if there is shutdown requested - static inline bool shutdown_in_progress() { - return (_state >= NMT_shutdown_pending); - } - - // bootstrap native memory tracking, so it can start to collect raw data - // before worker thread can start - - // the first phase of bootstrapping, when VM still in single-threaded mode - static void bootstrap_single_thread(); - // the second phase of bootstrapping, VM is about or already in multi-threaded mode - static void bootstrap_multi_thread(); - - - // start() has to be called when VM still in single thread mode, but after - // command line option parsing is done. - static void start(); - - // record a 'malloc' call - static inline void record_malloc(address addr, size_t size, MEMFLAGS flags, - address pc = 0, Thread* thread = NULL) { - Tracker tkr(Tracker::Malloc, thread); - tkr.record(addr, size, flags, pc); - } - // record a 'free' call - static inline void record_free(address addr, MEMFLAGS flags, Thread* thread = NULL) { - Tracker tkr(Tracker::Free, thread); - tkr.record(addr, 0, flags, DEBUG_CALLER_PC); - } - - static inline void record_arena_size(address addr, size_t size) { - Tracker tkr(Tracker::ArenaSize); - tkr.record(addr, size); - } - - // record a virtual memory 'reserve' call - static inline void record_virtual_memory_reserve(address addr, size_t size, - MEMFLAGS flags, address pc = 0, Thread* thread = NULL) { - assert(size > 0, "Sanity check"); - Tracker tkr(Tracker::Reserve, thread); - tkr.record(addr, size, flags, pc); - } - - static inline void record_thread_stack(address addr, size_t size, Thread* thr, - address pc = 0) { - Tracker tkr(Tracker::StackAlloc, thr); - tkr.record(addr, size, mtThreadStack, pc); - } - - static inline void release_thread_stack(address addr, size_t size, Thread* thr) { - Tracker tkr(Tracker::StackRelease, thr); - tkr.record(addr, size, mtThreadStack, DEBUG_CALLER_PC); - } - - // record a virtual memory 'commit' call - static inline void record_virtual_memory_commit(address addr, size_t size, - address pc, Thread* thread = NULL) { - Tracker tkr(Tracker::Commit, thread); - tkr.record(addr, size, mtNone, pc); - } - - static inline void record_virtual_memory_reserve_and_commit(address addr, size_t size, - MEMFLAGS flags, address pc, Thread* thread = NULL) { - Tracker tkr(Tracker::ReserveAndCommit, thread); - tkr.record(addr, size, flags, pc); - } - - static inline void record_virtual_memory_release(address addr, size_t size, - Thread* thread = NULL) { - if (is_on()) { - Tracker tkr(Tracker::Release, thread); - tkr.record(addr, size); + static inline void record_virtual_memory_commit(void* addr, size_t size, + const NativeCallStack& stack) { + if (tracking_level() < NMT_summary) return; + if (addr != NULL) { + ThreadCritical tc; + if (tracking_level() < NMT_summary) return; + VirtualMemoryTracker::add_committed_region((address)addr, size, stack); } } - // record memory type on virtual memory base address - static inline void record_virtual_memory_type(address base, MEMFLAGS flags, - Thread* thread = NULL) { - Tracker tkr(Tracker::Type); - tkr.record(base, 0, flags); - } - - // Get memory trackers for memory operations that can result race conditions. - // The memory tracker has to be obtained before realloc, virtual memory uncommit - // and virtual memory release, and call tracker.record() method if operation - // succeeded, or tracker.discard() to abort the tracking. - static inline Tracker get_realloc_tracker() { - return Tracker(Tracker::Realloc); - } - static inline Tracker get_virtual_memory_uncommit_tracker() { - return Tracker(Tracker::Uncommit); + assert(tracking_level() >= NMT_summary, "Check by caller"); + return Tracker(Tracker::uncommit); } static inline Tracker get_virtual_memory_release_tracker() { - return Tracker(Tracker::Release); + assert(tracking_level() >= NMT_summary, "Check by caller"); + return Tracker(Tracker::release); } - - // create memory baseline of current memory snapshot - static bool baseline(); - // is there a memory baseline - static bool has_baseline() { - return _baseline.baselined(); - } - - // print memory usage from current snapshot - static bool print_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true); - // compare memory usage between current snapshot and baseline - static bool compare_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true); - - // the version for whitebox testing support, it ensures that all memory - // activities before this method call, are reflected in the snapshot - // database. - static bool wbtest_wait_for_data_merge(); - - // sync is called within global safepoint to synchronize nmt data - static void sync(); - - // called when a thread is about to exit - static void thread_exiting(JavaThread* thread); - - // retrieve global snapshot - static MemSnapshot* get_snapshot() { - if (shutdown_in_progress()) { - return NULL; - } - return _snapshot; - } - - // print tracker stats - NOT_PRODUCT(static void print_tracker_stats(outputStream* st);) - NOT_PRODUCT(static void walk_stack(int toSkip, char* buf, int len);) - - private: - // start native memory tracking worker thread - static bool start_worker(MemSnapshot* snapshot); - - // called by worker thread to complete shutdown process - static void final_shutdown(); - - protected: - // retrieve per-thread recorder of the specified thread. - // if the recorder is full, it will be enqueued to overflow - // queue, a new recorder is acquired from recorder pool or a - // new instance is created. - // when thread == NULL, it means global recorder - static MemRecorder* get_thread_recorder(JavaThread* thread); - - // per-thread recorder pool - static void release_thread_recorder(MemRecorder* rec); - static void delete_all_pooled_recorders(); - - // pending recorder queue. Recorders are queued to pending queue - // when they are overflowed or collected at nmt sync point. - static void enqueue_pending_recorder(MemRecorder* rec); - static MemRecorder* get_pending_recorders(); - static void delete_all_pending_recorders(); - - // write a memory tracking record in recorder - static void write_tracking_record(address addr, MEMFLAGS type, - size_t size, jint seq, address pc, JavaThread* thread); - - static bool is_single_threaded_bootstrap() { - return _state == NMT_bootstrapping_single_thread; - } - - static void check_NMT_load(Thread* thr) { - assert(thr != NULL, "Sanity check"); - if (_slowdown_calling_thread && thr != _worker_thread) { -#ifdef _WINDOWS - // On Windows, os::NakedYield() does not work as well - // as short sleep. - os::naked_short_sleep(1); -#else - os::naked_yield(); -#endif + static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { + if (tracking_level() < NMT_summary) return; + if (addr != NULL) { + ThreadCritical tc; + if (tracking_level() < NMT_summary) return; + VirtualMemoryTracker::set_reserved_region_type((address)addr, flag); } } - static void inc_pending_op_count() { - Atomic::inc(&_pending_op_count); + static inline void record_thread_stack(void* addr, size_t size) { + if (tracking_level() < NMT_summary) return; + if (addr != NULL) { + // uses thread stack malloc slot for book keeping number of threads + MallocMemorySummary::record_malloc(0, mtThreadStack); + record_virtual_memory_reserve_and_commit(addr, size, CALLER_PC, mtThreadStack); + } } - static void dec_pending_op_count() { - Atomic::dec(&_pending_op_count); - assert(_pending_op_count >= 0, "Sanity check"); + static inline void release_thread_stack(void* addr, size_t size) { + if (tracking_level() < NMT_summary) return; + if (addr != NULL) { + // uses thread stack malloc slot for book keeping number of threads + MallocMemorySummary::record_free(0, mtThreadStack); + ThreadCritical tc; + if (tracking_level() < NMT_summary) return; + VirtualMemoryTracker::remove_released_region((address)addr, size); + } } + // Query lock is used to synchronize the access to tracking data. + // So far, it is only used by JCmd query, but it may be used by + // other tools. + static inline Mutex* query_lock() { return _query_lock; } + + // Make a final report and shutdown. + // This function generates summary report without creating snapshots, + // to avoid additional memory allocation. It uses native memory summary + // counters, and makes adjustment to them, once the adjustment is made, + // the counters are no longer accurate. As the result, this function + // should only be used for final reporting before shutting down. + static void final_report(outputStream*); + + // Stored baseline + static inline MemBaseline& get_baseline() { + return _baseline; + } + + static NMT_TrackingLevel cmdline_tracking_level() { + return _cmdline_tracking_level; + } + + static void tuning_statistics(outputStream* out); private: - // retrieve a pooled memory record or create new one if there is not - // one available - static MemRecorder* get_new_or_pooled_instance(); - static void create_memory_record(address addr, MEMFLAGS type, - size_t size, address pc, Thread* thread); - static void create_record_in_recorder(address addr, MEMFLAGS type, - size_t size, address pc, JavaThread* thread); - - static void set_current_processing_generation(unsigned long generation) { - _worker_thread_idle = false; - _processing_generation = generation; - } - - static void report_worker_idle() { - _worker_thread_idle = true; - } + static NMT_TrackingLevel init_tracking_level(); private: - // global memory snapshot - static MemSnapshot* _snapshot; - - // a memory baseline of snapshot + // Tracking level + static volatile NMT_TrackingLevel _tracking_level; + // If NMT option value passed by launcher through environment + // variable is valid + static bool _is_nmt_env_valid; + // command line tracking level + static NMT_TrackingLevel _cmdline_tracking_level; + // Stored baseline static MemBaseline _baseline; - - // query lock + // Query lock static Mutex* _query_lock; - - // a thread can start to allocate memory before it is attached - // to VM 'Thread', those memory activities are recorded here. - // ThreadCritical is required to guard this global recorder. - static MemRecorder* volatile _global_recorder; - - // main thread id - debug_only(static intx _main_thread_tid;) - - // pending recorders to be merged - static MemRecorder* volatile _merge_pending_queue; - - NOT_PRODUCT(static volatile jint _pending_recorder_count;) - - // pooled memory recorders - static MemRecorder* volatile _pooled_recorders; - - // memory recorder pool management, uses following - // counter to determine if a released memory recorder - // should be pooled - - // latest thread count - static int _thread_count; - // pooled recorder count - static volatile jint _pooled_recorder_count; - - - // worker thread to merge pending recorders into snapshot - static MemTrackWorker* _worker_thread; - - // how many safepoints we skipped without entering sync point - static int _sync_point_skip_count; - - // if the tracker is properly intialized - static bool _is_tracker_ready; - // tracking level (off, summary and detail) - static enum NMTLevel _tracking_level; - - // current nmt state - static volatile enum NMTStates _state; - // the reason for shutting down nmt - static enum ShutdownReason _reason; - // the generation that NMT is processing - static volatile unsigned long _processing_generation; - // although NMT is still procesing current generation, but - // there is not more recorder to process, set idle state - static volatile bool _worker_thread_idle; - - // if NMT should slow down calling thread to allow - // worker thread to catch up - static volatile bool _slowdown_calling_thread; - - // pending memory op count. - // Certain memory ops need to pre-reserve sequence number - // before memory operation can happen to avoid race condition. - // See MemTracker::Tracker for detail - static volatile jint _pending_op_count; }; -#endif // !INCLUDE_NMT +#endif // INCLUDE_NMT #endif // SHARE_VM_SERVICES_MEM_TRACKER_HPP + diff --git a/hotspot/src/share/vm/services/nmtCommon.cpp b/hotspot/src/share/vm/services/nmtCommon.cpp new file mode 100644 index 00000000000..0934e96dd7f --- /dev/null +++ b/hotspot/src/share/vm/services/nmtCommon.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#include "precompiled.hpp" +#include "services/nmtCommon.hpp" + +const char* NMTUtil::_memory_type_names[] = { + "Java Heap", + "Class", + "Thread", + "Thread Stack", + "Code", + "GC", + "Compiler", + "Internal", + "Other", + "Symbol", + "Native Memory Tracking", + "Shared class space", + "Arena Chunk", + "Test", + "Tracing", + "Unknown" +}; + + +const char* NMTUtil::scale_name(size_t scale) { + switch(scale) { + case K: return "KB"; + case M: return "MB"; + case G: return "GB"; + } + ShouldNotReachHere(); + return NULL; +} + +size_t NMTUtil::scale_from_name(const char* scale) { + assert(scale != NULL, "Null pointer check"); + if (strncmp(scale, "KB", 2) == 0 || + strncmp(scale, "kb", 2) == 0) { + return K; + } else if (strncmp(scale, "MB", 2) == 0 || + strncmp(scale, "mb", 2) == 0) { + return M; + } else if (strncmp(scale, "GB", 2) == 0 || + strncmp(scale, "gb", 2) == 0) { + return G; + } else { + return 0; // Invalid value + } + return K; +} + diff --git a/hotspot/src/share/vm/services/nmtCommon.hpp b/hotspot/src/share/vm/services/nmtCommon.hpp new file mode 100644 index 00000000000..78139411981 --- /dev/null +++ b/hotspot/src/share/vm/services/nmtCommon.hpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_NMT_COMMON_HPP +#define SHARE_VM_SERVICES_NMT_COMMON_HPP + +#include "memory/allocation.hpp" +#include "utilities/globalDefinitions.hpp" + +#define CALC_OBJ_SIZE_IN_TYPE(obj, type) (align_size_up_(sizeof(obj), sizeof(type))/sizeof(type)) + +// Data type for memory counters +#ifdef _LP64 + typedef jlong MemoryCounterType; +#else + typedef jint MemoryCounterType; +#endif + +// Native memory tracking level +enum NMT_TrackingLevel { + NMT_unknown = 0xFF, + NMT_off = 0x00, + NMT_minimal = 0x01, + NMT_summary = 0x02, + NMT_detail = 0x03 +}; + +// Number of stack frames to capture. This is a +// build time decision. +const int NMT_TrackingStackDepth = 4; + +class NativeCallStack; +extern NativeCallStack emptyStack; + +// A few common utilities for native memory tracking +class NMTUtil : AllStatic { + public: + // Map memory type to index + static inline int flag_to_index(MEMFLAGS flag) { + return (flag & 0xff); + } + + // Map memory type to human readable name + static const char* flag_to_name(MEMFLAGS flag) { + return _memory_type_names[flag_to_index(flag)]; + } + + // Map an index to memory type + static MEMFLAGS index_to_flag(int index) { + return (MEMFLAGS)index; + } + + // Memory size scale + static const char* scale_name(size_t scale); + static size_t scale_from_name(const char* scale); + + // Translate memory size in specified scale + static size_t amount_in_scale(size_t amount, size_t scale) { + return (amount + scale / 2) / scale; + } + private: + static const char* _memory_type_names[mt_number_of_types]; +}; + + +#endif diff --git a/hotspot/src/share/vm/services/nmtDCmd.cpp b/hotspot/src/share/vm/services/nmtDCmd.cpp index 8ced28772f3..fcad784f586 100644 --- a/hotspot/src/share/vm/services/nmtDCmd.cpp +++ b/hotspot/src/share/vm/services/nmtDCmd.cpp @@ -22,6 +22,8 @@ * */ #include "precompiled.hpp" + +#include "runtime/mutexLocker.hpp" #include "services/nmtDCmd.hpp" #include "services/memReporter.hpp" #include "services/memTracker.hpp" @@ -49,13 +51,8 @@ NMTDCmd::NMTDCmd(outputStream* output, _shutdown("shutdown", "request runtime to shutdown itself and free the " \ "memory used by runtime.", "BOOLEAN", false, "false"), - _auto_shutdown("autoShutdown", "automatically shutdown itself under " \ - "stress situation", - "BOOLEAN", true, "true"), -#ifndef PRODUCT - _debug("debug", "print tracker statistics. Debug only, not thread safe", \ + _statistics("statistics", "print tracker statistics for tuning purpose.", \ "BOOLEAN", false, "false"), -#endif _scale("scale", "Memory usage in which scale, KB, MB or GB", "STRING", false, "KB") { _dcmdparser.add_dcmd_option(&_summary); @@ -64,25 +61,30 @@ NMTDCmd::NMTDCmd(outputStream* output, _dcmdparser.add_dcmd_option(&_summary_diff); _dcmdparser.add_dcmd_option(&_detail_diff); _dcmdparser.add_dcmd_option(&_shutdown); - _dcmdparser.add_dcmd_option(&_auto_shutdown); -#ifndef PRODUCT - _dcmdparser.add_dcmd_option(&_debug); -#endif + _dcmdparser.add_dcmd_option(&_statistics); _dcmdparser.add_dcmd_option(&_scale); } + +size_t NMTDCmd::get_scale(const char* scale) const { + if (scale == NULL) return 0; + return NMTUtil::scale_from_name(scale); +} + void NMTDCmd::execute(DCmdSource source, TRAPS) { + // Check NMT state + // native memory tracking has to be on + if (MemTracker::tracking_level() == NMT_off) { + output()->print_cr("Native memory tracking is not enabled"); + return; + } else if (MemTracker::tracking_level() == NMT_minimal) { + output()->print_cr("Native memory tracking has been shutdown"); + return; + } + const char* scale_value = _scale.value(); - size_t scale_unit; - if (strcmp(scale_value, "KB") == 0 || strcmp(scale_value, "kb") == 0) { - scale_unit = K; - } else if (strcmp(scale_value, "MB") == 0 || - strcmp(scale_value, "mb") == 0) { - scale_unit = M; - } else if (strcmp(scale_value, "GB") == 0 || - strcmp(scale_value, "gb") == 0) { - scale_unit = G; - } else { + size_t scale_unit = get_scale(scale_value); + if (scale_unit == 0) { output()->print_cr("Incorrect scale value: %s", scale_value); return; } @@ -94,19 +96,11 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) { if (_summary_diff.is_set() && _summary_diff.value()) { ++nopt; } if (_detail_diff.is_set() && _detail_diff.value()) { ++nopt; } if (_shutdown.is_set() && _shutdown.value()) { ++nopt; } - if (_auto_shutdown.is_set()) { ++nopt; } - -#ifndef PRODUCT - if (_debug.is_set() && _debug.value()) { ++nopt; } -#endif + if (_statistics.is_set() && _statistics.value()) { ++nopt; } if (nopt > 1) { output()->print_cr("At most one of the following option can be specified: " \ - "summary, detail, baseline, summary.diff, detail.diff, shutdown" -#ifndef PRODUCT - ", debug" -#endif - ); + "summary, detail, baseline, summary.diff, detail.diff, shutdown"); return; } else if (nopt == 0) { if (_summary.is_set()) { @@ -117,53 +111,47 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) { } } -#ifndef PRODUCT - if (_debug.value()) { - output()->print_cr("debug command is NOT thread-safe, may cause crash"); - MemTracker::print_tracker_stats(output()); - return; - } -#endif - - // native memory tracking has to be on - if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) { - // if it is not on, what's the reason? - output()->print_cr("%s", MemTracker::reason()); - return; - } + // Serialize NMT query + MutexLocker locker(MemTracker::query_lock()); if (_summary.value()) { - BaselineTTYOutputer outputer(output()); - MemTracker::print_memory_usage(outputer, scale_unit, true); + report(true, scale_unit); } else if (_detail.value()) { - BaselineTTYOutputer outputer(output()); - MemTracker::print_memory_usage(outputer, scale_unit, false); + if (!check_detail_tracking_level(output())) { + return; + } + report(false, scale_unit); } else if (_baseline.value()) { - if (MemTracker::baseline()) { - output()->print_cr("Successfully baselined."); + MemBaseline& baseline = MemTracker::get_baseline(); + if (!baseline.baseline(MemTracker::tracking_level() != NMT_detail)) { + output()->print_cr("Baseline failed"); } else { - output()->print_cr("Baseline failed."); + output()->print_cr("Baseline succeeded"); } } else if (_summary_diff.value()) { - if (MemTracker::has_baseline()) { - BaselineTTYOutputer outputer(output()); - MemTracker::compare_memory_usage(outputer, scale_unit, true); + MemBaseline& baseline = MemTracker::get_baseline(); + if (baseline.baseline_type() >= MemBaseline::Summary_baselined) { + report_diff(true, scale_unit); } else { - output()->print_cr("No baseline to compare, run 'baseline' command first"); + output()->print_cr("No baseline for comparison"); } } else if (_detail_diff.value()) { - if (MemTracker::has_baseline()) { - BaselineTTYOutputer outputer(output()); - MemTracker::compare_memory_usage(outputer, scale_unit, false); + if (!check_detail_tracking_level(output())) { + return; + } + MemBaseline& baseline = MemTracker::get_baseline(); + if (baseline.baseline_type() == MemBaseline::Detail_baselined) { + report_diff(false, scale_unit); } else { - output()->print_cr("No baseline to compare to, run 'baseline' command first"); + output()->print_cr("No detail baseline for comparison"); } } else if (_shutdown.value()) { - MemTracker::shutdown(MemTracker::NMT_shutdown_user); - output()->print_cr("Shutdown is in progress, it will take a few moments to " \ - "completely shutdown"); - } else if (_auto_shutdown.is_set()) { - MemTracker::set_autoShutdown(_auto_shutdown.value()); + MemTracker::shutdown(); + output()->print_cr("Native memory tracking has been turned off"); + } else if (_statistics.value()) { + if (check_detail_tracking_level(output())) { + MemTracker::tuning_statistics(output()); + } } else { ShouldNotReachHere(); output()->print_cr("Unknown command"); @@ -181,3 +169,46 @@ int NMTDCmd::num_arguments() { } } +void NMTDCmd::report(bool summaryOnly, size_t scale_unit) { + MemBaseline baseline; + if (baseline.baseline(summaryOnly)) { + if (summaryOnly) { + MemSummaryReporter rpt(baseline, output(), scale_unit); + rpt.report(); + } else { + MemDetailReporter rpt(baseline, output(), scale_unit); + rpt.report(); + } + } +} + +void NMTDCmd::report_diff(bool summaryOnly, size_t scale_unit) { + MemBaseline& early_baseline = MemTracker::get_baseline(); + assert(early_baseline.baseline_type() != MemBaseline::Not_baselined, + "Not yet baselined"); + assert(summaryOnly || early_baseline.baseline_type() == MemBaseline::Detail_baselined, + "Not a detail baseline"); + + MemBaseline baseline; + if (baseline.baseline(summaryOnly)) { + if (summaryOnly) { + MemSummaryDiffReporter rpt(early_baseline, baseline, output(), scale_unit); + rpt.report_diff(); + } else { + MemDetailDiffReporter rpt(early_baseline, baseline, output(), scale_unit); + rpt.report_diff(); + } + } +} + +bool NMTDCmd::check_detail_tracking_level(outputStream* out) { + if (MemTracker::tracking_level() == NMT_detail) { + return true; + } else if (MemTracker::cmdline_tracking_level() == NMT_detail) { + out->print_cr("Tracking level has been downgraded due to lack of resources"); + return false; + } else { + out->print_cr("Detail tracking is not enabled"); + return false; + } +} diff --git a/hotspot/src/share/vm/services/nmtDCmd.hpp b/hotspot/src/share/vm/services/nmtDCmd.hpp index 62872c63a76..df1ab367fd1 100644 --- a/hotspot/src/share/vm/services/nmtDCmd.hpp +++ b/hotspot/src/share/vm/services/nmtDCmd.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,12 @@ #ifndef SHARE_VM_SERVICES_NMT_DCMD_HPP #define SHARE_VM_SERVICES_NMT_DCMD_HPP +#if INCLUDE_NMT + #include "services/diagnosticArgument.hpp" #include "services/diagnosticFramework.hpp" +#include "services/memBaseline.hpp" +#include "services/mallocTracker.hpp" /** * Native memory tracking DCmd implementation @@ -39,10 +43,7 @@ class NMTDCmd: public DCmdWithParser { DCmdArgument _summary_diff; DCmdArgument _detail_diff; DCmdArgument _shutdown; - DCmdArgument _auto_shutdown; -#ifndef PRODUCT - DCmdArgument _debug; -#endif + DCmdArgument _statistics; DCmdArgument _scale; public: @@ -61,6 +62,17 @@ class NMTDCmd: public DCmdWithParser { } static int num_arguments(); virtual void execute(DCmdSource source, TRAPS); + + private: + void report(bool summaryOnly, size_t scale); + void report_diff(bool summaryOnly, size_t scale); + + size_t get_scale(const char* scale) const; + + // check if NMT running at detail tracking level + bool check_detail_tracking_level(outputStream* out); }; +#endif // INCLUDE_NMT + #endif // SHARE_VM_SERVICES_NMT_DCMD_HPP diff --git a/hotspot/src/share/vm/services/virtualMemoryTracker.cpp b/hotspot/src/share/vm/services/virtualMemoryTracker.cpp new file mode 100644 index 00000000000..4e0476f9085 --- /dev/null +++ b/hotspot/src/share/vm/services/virtualMemoryTracker.cpp @@ -0,0 +1,448 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#include "precompiled.hpp" + +#include "runtime/threadCritical.hpp" +#include "services/virtualMemoryTracker.hpp" + +size_t VirtualMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(VirtualMemorySnapshot, size_t)]; + +void VirtualMemorySummary::initialize() { + assert(sizeof(_snapshot) >= sizeof(VirtualMemorySnapshot), "Sanity Check"); + // Use placement operator new to initialize static data area. + ::new ((void*)_snapshot) VirtualMemorySnapshot(); +} + +SortedLinkedList VirtualMemoryTracker::_reserved_regions; + +int compare_committed_region(const CommittedMemoryRegion& r1, const CommittedMemoryRegion& r2) { + return r1.compare(r2); +} + +int compare_reserved_region_base(const ReservedMemoryRegion& r1, const ReservedMemoryRegion& r2) { + return r1.compare(r2); +} + +bool ReservedMemoryRegion::add_committed_region(address addr, size_t size, const NativeCallStack& stack) { + assert(addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + assert(contain_region(addr, size), "Not contain this region"); + + if (all_committed()) return true; + + CommittedMemoryRegion committed_rgn(addr, size, stack); + LinkedListNode* node = _committed_regions.find_node(committed_rgn); + if (node != NULL) { + CommittedMemoryRegion* rgn = node->data(); + if (rgn->same_region(addr, size)) { + return true; + } + + if (rgn->adjacent_to(addr, size)) { + // check if the next region covers this committed region, + // the regions may not be merged due to different call stacks + LinkedListNode* next = + node->next(); + if (next != NULL && next->data()->contain_region(addr, size)) { + if (next->data()->same_region(addr, size)) { + next->data()->set_call_stack(stack); + } + return true; + } + if (rgn->call_stack()->equals(stack)) { + VirtualMemorySummary::record_uncommitted_memory(rgn->size(), flag()); + // the two adjacent regions have the same call stack, merge them + rgn->expand_region(addr, size); + VirtualMemorySummary::record_committed_memory(rgn->size(), flag()); + return true; + } + VirtualMemorySummary::record_committed_memory(size, flag()); + if (rgn->base() > addr) { + return _committed_regions.insert_before(committed_rgn, node) != NULL; + } else { + return _committed_regions.insert_after(committed_rgn, node) != NULL; + } + } + assert(rgn->contain_region(addr, size), "Must cover this region"); + return true; + } else { + // New committed region + VirtualMemorySummary::record_committed_memory(size, flag()); + return add_committed_region(committed_rgn); + } +} + +void ReservedMemoryRegion::set_all_committed(bool b) { + if (all_committed() != b) { + _all_committed = b; + if (b) { + VirtualMemorySummary::record_committed_memory(size(), flag()); + } + } +} + +bool ReservedMemoryRegion::remove_uncommitted_region(LinkedListNode* node, + address addr, size_t size) { + assert(addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + + CommittedMemoryRegion* rgn = node->data(); + assert(rgn->contain_region(addr, size), "Has to be contained"); + assert(!rgn->same_region(addr, size), "Can not be the same region"); + + if (rgn->base() == addr || + rgn->end() == addr + size) { + rgn->exclude_region(addr, size); + return true; + } else { + // split this region + address top =rgn->end(); + // use this region for lower part + size_t exclude_size = rgn->end() - addr; + rgn->exclude_region(addr, exclude_size); + + // higher part + address high_base = addr + size; + size_t high_size = top - high_base; + + CommittedMemoryRegion high_rgn(high_base, high_size, *rgn->call_stack()); + LinkedListNode* high_node = _committed_regions.add(high_rgn); + assert(high_node == NULL || node->next() == high_node, "Should be right after"); + return (high_node != NULL); + } + + return false; +} + +bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) { + // uncommit stack guard pages + if (flag() == mtThreadStack && !same_region(addr, sz)) { + return true; + } + + assert(addr != NULL, "Invalid address"); + assert(sz > 0, "Invalid size"); + + if (all_committed()) { + assert(_committed_regions.is_empty(), "Sanity check"); + assert(contain_region(addr, sz), "Reserved region does not contain this region"); + set_all_committed(false); + VirtualMemorySummary::record_uncommitted_memory(sz, flag()); + if (same_region(addr, sz)) { + return true; + } else { + CommittedMemoryRegion rgn(base(), size(), *call_stack()); + if (rgn.base() == addr || rgn.end() == (addr + sz)) { + rgn.exclude_region(addr, sz); + return add_committed_region(rgn); + } else { + // split this region + // top of the whole region + address top =rgn.end(); + // use this region for lower part + size_t exclude_size = rgn.end() - addr; + rgn.exclude_region(addr, exclude_size); + if (add_committed_region(rgn)) { + // higher part + address high_base = addr + sz; + size_t high_size = top - high_base; + CommittedMemoryRegion high_rgn(high_base, high_size, emptyStack); + return add_committed_region(high_rgn); + } else { + return false; + } + } + } + } else { + // we have to walk whole list to remove the committed regions in + // specified range + LinkedListNode* head = + _committed_regions.head(); + LinkedListNode* prev = NULL; + VirtualMemoryRegion uncommitted_rgn(addr, sz); + + while (head != NULL && !uncommitted_rgn.is_empty()) { + CommittedMemoryRegion* crgn = head->data(); + // this committed region overlaps to region to uncommit + if (crgn->overlap_region(uncommitted_rgn.base(), uncommitted_rgn.size())) { + if (crgn->same_region(uncommitted_rgn.base(), uncommitted_rgn.size())) { + // find matched region, remove the node will do + VirtualMemorySummary::record_uncommitted_memory(uncommitted_rgn.size(), flag()); + _committed_regions.remove_after(prev); + return true; + } else if (crgn->contain_region(uncommitted_rgn.base(), uncommitted_rgn.size())) { + // this committed region contains whole uncommitted region + VirtualMemorySummary::record_uncommitted_memory(uncommitted_rgn.size(), flag()); + return remove_uncommitted_region(head, uncommitted_rgn.base(), uncommitted_rgn.size()); + } else if (uncommitted_rgn.contain_region(crgn->base(), crgn->size())) { + // this committed region has been uncommitted + size_t exclude_size = crgn->end() - uncommitted_rgn.base(); + uncommitted_rgn.exclude_region(uncommitted_rgn.base(), exclude_size); + VirtualMemorySummary::record_uncommitted_memory(crgn->size(), flag()); + LinkedListNode* tmp = head; + head = head->next(); + _committed_regions.remove_after(prev); + continue; + } else if (crgn->contain_address(uncommitted_rgn.base())) { + size_t toUncommitted = crgn->end() - uncommitted_rgn.base(); + crgn->exclude_region(uncommitted_rgn.base(), toUncommitted); + uncommitted_rgn.exclude_region(uncommitted_rgn.base(), toUncommitted); + VirtualMemorySummary::record_uncommitted_memory(toUncommitted, flag()); + } else if (uncommitted_rgn.contain_address(crgn->base())) { + size_t toUncommitted = uncommitted_rgn.end() - crgn->base(); + crgn->exclude_region(crgn->base(), toUncommitted); + uncommitted_rgn.exclude_region(uncommitted_rgn.end() - toUncommitted, + toUncommitted); + VirtualMemorySummary::record_uncommitted_memory(toUncommitted, flag()); + } + } + prev = head; + head = head->next(); + } + } + + return true; +} + +void ReservedMemoryRegion::move_committed_regions(address addr, ReservedMemoryRegion& rgn) { + assert(addr != NULL, "Invalid address"); + + // split committed regions + LinkedListNode* head = + _committed_regions.head(); + LinkedListNode* prev = NULL; + + while (head != NULL) { + if (head->data()->base() >= addr) { + break; + } + prev = head; + head = head->next(); + } + + if (head != NULL) { + if (prev != NULL) { + prev->set_next(head->next()); + } else { + _committed_regions.set_head(NULL); + } + } + + rgn._committed_regions.set_head(head); +} + +size_t ReservedMemoryRegion::committed_size() const { + if (all_committed()) { + return size(); + } else { + size_t committed = 0; + LinkedListNode* head = + _committed_regions.head(); + while (head != NULL) { + committed += head->data()->size(); + head = head->next(); + } + return committed; + } +} + +void ReservedMemoryRegion::set_flag(MEMFLAGS f) { + assert((flag() == mtNone || flag() == f), "Overwrite memory type"); + if (flag() != f) { + VirtualMemorySummary::move_reserved_memory(flag(), f, size()); + VirtualMemorySummary::move_committed_memory(flag(), f, committed_size()); + _flag = f; + } +} + +bool VirtualMemoryTracker::initialize(NMT_TrackingLevel level) { + if (level >= NMT_summary) { + VirtualMemorySummary::initialize(); + } + return true; +} + +bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, + const NativeCallStack& stack, MEMFLAGS flag, bool all_committed) { + assert(base_addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + + ReservedMemoryRegion rgn(base_addr, size, stack, flag); + ReservedMemoryRegion* reserved_rgn = _reserved_regions.find(rgn); + LinkedListNode* node; + if (reserved_rgn == NULL) { + VirtualMemorySummary::record_reserved_memory(size, flag); + node = _reserved_regions.add(rgn); + if (node != NULL) { + node->data()->set_all_committed(all_committed); + return true; + } else { + return false; + } + } else { + if (reserved_rgn->same_region(base_addr, size)) { + reserved_rgn->set_call_stack(stack); + reserved_rgn->set_flag(flag); + return true; + } else if (reserved_rgn->adjacent_to(base_addr, size)) { + VirtualMemorySummary::record_reserved_memory(size, flag); + reserved_rgn->expand_region(base_addr, size); + reserved_rgn->set_call_stack(stack); + return true; + } else { + // Overlapped reservation. + // It can happen when the regions are thread stacks, as JNI + // thread does not detach from VM before exits, and leads to + // leak JavaThread object + if (reserved_rgn->flag() == mtThreadStack) { + guarantee(!CheckJNICalls, "Attached JNI thread exited without being detached"); + // Overwrite with new region + + // Release old region + VirtualMemorySummary::record_uncommitted_memory(reserved_rgn->committed_size(), reserved_rgn->flag()); + VirtualMemorySummary::record_released_memory(reserved_rgn->size(), reserved_rgn->flag()); + + // Add new region + VirtualMemorySummary::record_reserved_memory(rgn.size(), flag); + + *reserved_rgn = rgn; + return true; + } else { + ShouldNotReachHere(); + return false; + } + } + } +} + +void VirtualMemoryTracker::set_reserved_region_type(address addr, MEMFLAGS flag) { + assert(addr != NULL, "Invalid address"); + + ReservedMemoryRegion rgn(addr, 1); + ReservedMemoryRegion* reserved_rgn = _reserved_regions.find(rgn); + if (reserved_rgn != NULL) { + assert(reserved_rgn->contain_address(addr), "Containment"); + if (reserved_rgn->flag() != flag) { + assert(reserved_rgn->flag() == mtNone, "Overwrite memory type"); + reserved_rgn->set_flag(flag); + } + } +} + +bool VirtualMemoryTracker::add_committed_region(address addr, size_t size, + const NativeCallStack& stack) { + assert(addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + ReservedMemoryRegion rgn(addr, size); + ReservedMemoryRegion* reserved_rgn = _reserved_regions.find(rgn); + + assert(reserved_rgn != NULL, "No reserved region"); + assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); + return reserved_rgn->add_committed_region(addr, size, stack); +} + +bool VirtualMemoryTracker::remove_uncommitted_region(address addr, size_t size) { + assert(addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + ReservedMemoryRegion rgn(addr, size); + ReservedMemoryRegion* reserved_rgn = _reserved_regions.find(rgn); + assert(reserved_rgn != NULL, "No reserved region"); + assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); + return reserved_rgn->remove_uncommitted_region(addr, size); +} + +bool VirtualMemoryTracker::remove_released_region(address addr, size_t size) { + assert(addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + + ReservedMemoryRegion rgn(addr, size); + ReservedMemoryRegion* reserved_rgn = _reserved_regions.find(rgn); + + assert(reserved_rgn != NULL, "No reserved region"); + + // uncommit regions within the released region + if (!reserved_rgn->remove_uncommitted_region(addr, size)) { + return false; + } + + + VirtualMemorySummary::record_released_memory(size, reserved_rgn->flag()); + + if (reserved_rgn->same_region(addr, size)) { + return _reserved_regions.remove(rgn); + } else { + assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); + if (reserved_rgn->base() == addr || + reserved_rgn->end() == addr + size) { + reserved_rgn->exclude_region(addr, size); + return true; + } else { + address top = reserved_rgn->end(); + address high_base = addr + size; + ReservedMemoryRegion high_rgn(high_base, top - high_base, + *reserved_rgn->call_stack(), reserved_rgn->flag()); + + // use original region for lower region + reserved_rgn->exclude_region(addr, top - addr); + LinkedListNode* new_rgn = _reserved_regions.add(high_rgn); + if (new_rgn == NULL) { + return false; + } else { + reserved_rgn->move_committed_regions(addr, *new_rgn->data()); + return true; + } + } + } +} + + +bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { + ThreadCritical tc; + LinkedListNode* head = _reserved_regions.head(); + while (head != NULL) { + const ReservedMemoryRegion* rgn = head->peek(); + if (!walker->do_allocation_site(rgn)) { + return false; + } + head = head->next(); + } + return true; +} + +// Transition virtual memory tracking level. +bool VirtualMemoryTracker::transition(NMT_TrackingLevel from, NMT_TrackingLevel to) { + if (from == NMT_minimal) { + assert(to == NMT_summary || to == NMT_detail, "Just check"); + VirtualMemorySummary::reset(); + } else if (to == NMT_minimal) { + assert(from == NMT_summary || from == NMT_detail, "Just check"); + // Clean up virtual memory tracking data structures. + ThreadCritical tc; + _reserved_regions.clear(); + } + + return true; +} + + diff --git a/hotspot/src/share/vm/services/virtualMemoryTracker.hpp b/hotspot/src/share/vm/services/virtualMemoryTracker.hpp new file mode 100644 index 00000000000..982b1531fc9 --- /dev/null +++ b/hotspot/src/share/vm/services/virtualMemoryTracker.hpp @@ -0,0 +1,437 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_VIRTUAL_MEMORY_TRACKER_HPP +#define SHARE_VM_SERVICES_VIRTUAL_MEMORY_TRACKER_HPP + +#if INCLUDE_NMT + +#include "memory/allocation.hpp" +#include "services/allocationSite.hpp" +#include "services/nmtCommon.hpp" +#include "utilities/linkedlist.hpp" +#include "utilities/nativeCallStack.hpp" +#include "utilities/ostream.hpp" + + +/* + * Virtual memory counter + */ +class VirtualMemory VALUE_OBJ_CLASS_SPEC { + private: + size_t _reserved; + size_t _committed; + + public: + VirtualMemory() : _reserved(0), _committed(0) { } + + inline void reserve_memory(size_t sz) { _reserved += sz; } + inline void commit_memory (size_t sz) { + _committed += sz; + assert(_committed <= _reserved, "Sanity check"); + } + + inline void release_memory (size_t sz) { + assert(_reserved >= sz, "Negative amount"); + _reserved -= sz; + } + + inline void uncommit_memory(size_t sz) { + assert(_committed >= sz, "Negative amount"); + _committed -= sz; + } + + void reset() { + _reserved = 0; + _committed = 0; + } + + inline size_t reserved() const { return _reserved; } + inline size_t committed() const { return _committed; } +}; + +// Virtual memory allocation site, keeps track where the virtual memory is reserved. +class VirtualMemoryAllocationSite : public AllocationSite { + public: + VirtualMemoryAllocationSite(const NativeCallStack& stack) : + AllocationSite(stack) { } + + inline void reserve_memory(size_t sz) { data()->reserve_memory(sz); } + inline void commit_memory (size_t sz) { data()->commit_memory(sz); } + inline void uncommit_memory(size_t sz) { data()->uncommit_memory(sz); } + inline void release_memory(size_t sz) { data()->release_memory(sz); } + inline size_t reserved() const { return peek()->reserved(); } + inline size_t committed() const { return peek()->committed(); } +}; + +class VirtualMemorySummary; + +// This class represents a snapshot of virtual memory at a given time. +// The latest snapshot is saved in a static area. +class VirtualMemorySnapshot : public ResourceObj { + friend class VirtualMemorySummary; + + private: + VirtualMemory _virtual_memory[mt_number_of_types]; + + public: + inline VirtualMemory* by_type(MEMFLAGS flag) { + int index = NMTUtil::flag_to_index(flag); + return &_virtual_memory[index]; + } + + inline VirtualMemory* by_index(int index) { + assert(index >= 0, "Index out of bound"); + assert(index < mt_number_of_types, "Index out of bound"); + return &_virtual_memory[index]; + } + + inline size_t total_reserved() const { + size_t amount = 0; + for (int index = 0; index < mt_number_of_types; index ++) { + amount += _virtual_memory[index].reserved(); + } + return amount; + } + + inline size_t total_committed() const { + size_t amount = 0; + for (int index = 0; index < mt_number_of_types; index ++) { + amount += _virtual_memory[index].committed(); + } + return amount; + } + + inline void reset() { + for (int index = 0; index < mt_number_of_types; index ++) { + _virtual_memory[index].reset(); + } + } + + void copy_to(VirtualMemorySnapshot* s) { + for (int index = 0; index < mt_number_of_types; index ++) { + s->_virtual_memory[index] = _virtual_memory[index]; + } + } +}; + +class VirtualMemorySummary : AllStatic { + public: + static void initialize(); + + static inline void record_reserved_memory(size_t size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->reserve_memory(size); + } + + static inline void record_committed_memory(size_t size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->commit_memory(size); + } + + static inline void record_uncommitted_memory(size_t size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->uncommit_memory(size); + } + + static inline void record_released_memory(size_t size, MEMFLAGS flag) { + as_snapshot()->by_type(flag)->release_memory(size); + } + + // Move virtual memory from one memory type to another. + // Virtual memory can be reserved before it is associated with a memory type, and tagged + // as 'unknown'. Once the memory is tagged, the virtual memory will be moved from 'unknown' + // type to specified memory type. + static inline void move_reserved_memory(MEMFLAGS from, MEMFLAGS to, size_t size) { + as_snapshot()->by_type(from)->release_memory(size); + as_snapshot()->by_type(to)->reserve_memory(size); + } + + static inline void move_committed_memory(MEMFLAGS from, MEMFLAGS to, size_t size) { + as_snapshot()->by_type(from)->uncommit_memory(size); + as_snapshot()->by_type(to)->commit_memory(size); + } + + static inline void snapshot(VirtualMemorySnapshot* s) { + as_snapshot()->copy_to(s); + } + + static inline void reset() { + as_snapshot()->reset(); + } + + static VirtualMemorySnapshot* as_snapshot() { + return (VirtualMemorySnapshot*)_snapshot; + } + + private: + static size_t _snapshot[CALC_OBJ_SIZE_IN_TYPE(VirtualMemorySnapshot, size_t)]; +}; + + + +/* + * A virtual memory region + */ +class VirtualMemoryRegion VALUE_OBJ_CLASS_SPEC { + private: + address _base_address; + size_t _size; + + public: + VirtualMemoryRegion(address addr, size_t size) : + _base_address(addr), _size(size) { + assert(addr != NULL, "Invalid address"); + assert(size > 0, "Invalid size"); + } + + inline address base() const { return _base_address; } + inline address end() const { return base() + size(); } + inline size_t size() const { return _size; } + + inline bool is_empty() const { return size() == 0; } + + inline bool contain_address(address addr) const { + return (addr >= base() && addr < end()); + } + + + inline bool contain_region(address addr, size_t size) const { + return contain_address(addr) && contain_address(addr + size - 1); + } + + inline bool same_region(address addr, size_t sz) const { + return (addr == base() && sz == size()); + } + + + inline bool overlap_region(address addr, size_t sz) const { + VirtualMemoryRegion rgn(addr, sz); + return contain_address(addr) || + contain_address(addr + sz - 1) || + rgn.contain_address(base()) || + rgn.contain_address(end() - 1); + } + + inline bool adjacent_to(address addr, size_t sz) const { + return (addr == end() || (addr + sz) == base()); + } + + void exclude_region(address addr, size_t sz) { + assert(contain_region(addr, sz), "Not containment"); + assert(addr == base() || addr + sz == end(), "Can not exclude from middle"); + size_t new_size = size() - sz; + + if (addr == base()) { + set_base(addr + sz); + } + set_size(new_size); + } + + void expand_region(address addr, size_t sz) { + assert(adjacent_to(addr, sz), "Not adjacent regions"); + if (base() == addr + sz) { + set_base(addr); + } + set_size(size() + sz); + } + + protected: + void set_base(address base) { + assert(base != NULL, "Sanity check"); + _base_address = base; + } + + void set_size(size_t size) { + assert(size > 0, "Sanity check"); + _size = size; + } +}; + + +class CommittedMemoryRegion : public VirtualMemoryRegion { + private: + NativeCallStack _stack; + + public: + CommittedMemoryRegion(address addr, size_t size, const NativeCallStack& stack) : + VirtualMemoryRegion(addr, size), _stack(stack) { } + + inline int compare(const CommittedMemoryRegion& rgn) const { + if (overlap_region(rgn.base(), rgn.size()) || + adjacent_to (rgn.base(), rgn.size())) { + return 0; + } else { + if (base() == rgn.base()) { + return 0; + } else if (base() > rgn.base()) { + return 1; + } else { + return -1; + } + } + } + + inline bool equals(const CommittedMemoryRegion& rgn) const { + return compare(rgn) == 0; + } + + inline void set_call_stack(const NativeCallStack& stack) { _stack = stack; } + inline const NativeCallStack* call_stack() const { return &_stack; } +}; + + +typedef LinkedListIterator CommittedRegionIterator; + +int compare_committed_region(const CommittedMemoryRegion&, const CommittedMemoryRegion&); +class ReservedMemoryRegion : public VirtualMemoryRegion { + private: + SortedLinkedList + _committed_regions; + + NativeCallStack _stack; + MEMFLAGS _flag; + + bool _all_committed; + + public: + ReservedMemoryRegion(address base, size_t size, const NativeCallStack& stack, + MEMFLAGS flag = mtNone) : + VirtualMemoryRegion(base, size), _stack(stack), _flag(flag), + _all_committed(false) { } + + + ReservedMemoryRegion(address base, size_t size) : + VirtualMemoryRegion(base, size), _stack(emptyStack), _flag(mtNone), + _all_committed(false) { } + + // Copy constructor + ReservedMemoryRegion(const ReservedMemoryRegion& rr) : + VirtualMemoryRegion(rr.base(), rr.size()) { + *this = rr; + } + + inline void set_call_stack(const NativeCallStack& stack) { _stack = stack; } + inline const NativeCallStack* call_stack() const { return &_stack; } + + void set_flag(MEMFLAGS flag); + inline MEMFLAGS flag() const { return _flag; } + + inline int compare(const ReservedMemoryRegion& rgn) const { + if (overlap_region(rgn.base(), rgn.size())) { + return 0; + } else { + if (base() == rgn.base()) { + return 0; + } else if (base() > rgn.base()) { + return 1; + } else { + return -1; + } + } + } + + inline bool equals(const ReservedMemoryRegion& rgn) const { + return compare(rgn) == 0; + } + + bool add_committed_region(address addr, size_t size, const NativeCallStack& stack); + bool remove_uncommitted_region(address addr, size_t size); + + size_t committed_size() const; + + // move committed regions that higher than specified address to + // the new region + void move_committed_regions(address addr, ReservedMemoryRegion& rgn); + + inline bool all_committed() const { return _all_committed; } + void set_all_committed(bool b); + + CommittedRegionIterator iterate_committed_regions() const { + return CommittedRegionIterator(_committed_regions.head()); + } + + ReservedMemoryRegion& operator= (const ReservedMemoryRegion& other) { + set_base(other.base()); + set_size(other.size()); + + _stack = *other.call_stack(); + _flag = other.flag(); + _all_committed = other.all_committed(); + if (other.all_committed()) { + set_all_committed(true); + } else { + CommittedRegionIterator itr = other.iterate_committed_regions(); + const CommittedMemoryRegion* rgn = itr.next(); + while (rgn != NULL) { + _committed_regions.add(*rgn); + rgn = itr.next(); + } + } + return *this; + } + + private: + // The committed region contains the uncommitted region, subtract the uncommitted + // region from this committed region + bool remove_uncommitted_region(LinkedListNode* node, + address addr, size_t sz); + + bool add_committed_region(const CommittedMemoryRegion& rgn) { + assert(rgn.base() != NULL, "Invalid base address"); + assert(size() > 0, "Invalid size"); + return _committed_regions.add(rgn) != NULL; + } +}; + +int compare_reserved_region_base(const ReservedMemoryRegion& r1, const ReservedMemoryRegion& r2); + +class VirtualMemoryWalker : public StackObj { + public: + virtual bool do_allocation_site(const ReservedMemoryRegion* rgn) { return false; } +}; + +// Main class called from MemTracker to track virtual memory allocations, commits and releases. +class VirtualMemoryTracker : AllStatic { + public: + static bool initialize(NMT_TrackingLevel level); + + static bool add_reserved_region (address base_addr, size_t size, const NativeCallStack& stack, + MEMFLAGS flag = mtNone, bool all_committed = false); + + static bool add_committed_region (address base_addr, size_t size, const NativeCallStack& stack); + static bool remove_uncommitted_region (address base_addr, size_t size); + static bool remove_released_region (address base_addr, size_t size); + static void set_reserved_region_type (address addr, MEMFLAGS flag); + + // Walk virtual memory data structure for creating baseline, etc. + static bool walk_virtual_memory(VirtualMemoryWalker* walker); + + static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to); + + private: + static SortedLinkedList _reserved_regions; +}; + + +#endif // INCLUDE_NMT + +#endif // SHARE_VM_SERVICES_VIRTUAL_MEMORY_TRACKER_HPP diff --git a/hotspot/src/share/vm/shark/sharkBuilder.cpp b/hotspot/src/share/vm/shark/sharkBuilder.cpp index 34de2737d15..329a94aa83c 100644 --- a/hotspot/src/share/vm/shark/sharkBuilder.cpp +++ b/hotspot/src/share/vm/shark/sharkBuilder.cpp @@ -413,7 +413,7 @@ CallInst* SharkBuilder::CreateDump(Value* value) { const char *name; if (value->hasName()) // XXX this leaks, but it's only debug code - name = strdup(value->getName().str().c_str()); + name = os::strdup(value->getName().str().c_str()); else name = "unnamed_value"; diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 2bbd31afb76..269853ee674 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -558,6 +558,27 @@ inline double fabsd(double value) { return fabs(value); } +//---------------------------------------------------------------------------------------------------- +// Special casts +// Cast floats into same-size integers and vice-versa w/o changing bit-pattern +typedef union { + jfloat f; + jint i; +} FloatIntConv; + +typedef union { + jdouble d; + jlong l; + julong ul; +} DoubleLongConv; + +inline jint jint_cast (jfloat x) { return ((FloatIntConv*)&x)->i; } +inline jfloat jfloat_cast (jint x) { return ((FloatIntConv*)&x)->f; } + +inline jlong jlong_cast (jdouble x) { return ((DoubleLongConv*)&x)->l; } +inline julong julong_cast (jdouble x) { return ((DoubleLongConv*)&x)->ul; } +inline jdouble jdouble_cast (jlong x) { return ((DoubleLongConv*)&x)->d; } + inline jint low (jlong value) { return jint(value); } inline jint high(jlong value) { return jint(value >> 32); } diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp index 22e5d277c81..576b0235af4 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp @@ -167,17 +167,6 @@ typedef uint16_t jushort; typedef uint32_t juint; typedef uint64_t julong; -//---------------------------------------------------------------------------------------------------- -// Special (possibly not-portable) casts -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern -// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar - -inline jint jint_cast (jfloat x) { return *(jint* )&x; } -inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; } -inline julong julong_cast (jdouble x) { return *(julong* )&x; } - -inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; } -inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } //---------------------------------------------------------------------------------------------------- // Constant for jlong (specifying an long long canstant is C++ compiler specific) diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp index e91e6078098..b64bbf8da0f 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp @@ -183,15 +183,6 @@ typedef unsigned short jushort; typedef unsigned int juint; typedef unsigned long long julong; -//---------------------------------------------------------------------------------------------------- -// Special (possibly not-portable) casts -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern - -inline jint jint_cast (jfloat x) { return *(jint* )&x; } -inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; } - -inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; } -inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } //---------------------------------------------------------------------------------------------------- // Constant for jlong (specifying an long long constant is C++ compiler specific) diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp index db22cc8ada6..46e8f9e8e93 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp @@ -116,16 +116,6 @@ typedef unsigned short jushort; typedef unsigned int juint; typedef unsigned __int64 julong; -//---------------------------------------------------------------------------------------------------- -// Special (possibly not-portable) casts -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern - -inline jint jint_cast (jfloat x) { return *(jint* )&x; } -inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; } - -inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; } -inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } - //---------------------------------------------------------------------------------------------------- // Non-standard stdlib-like stuff: diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp index 8a340062129..ad71883f81d 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp @@ -114,16 +114,6 @@ typedef uint16_t jushort; typedef uint32_t juint; typedef uint64_t julong; -//---------------------------------------------------------------------------------------------------- -// Special (possibly not-portable) casts -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern -// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar - -inline jint jint_cast (jfloat x) { return *(jint* )&x; } -inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; } - -inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; } -inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; } //---------------------------------------------------------------------------------------------------- // Constant for jlong (specifying an long long canstant is C++ compiler specific) diff --git a/hotspot/src/share/vm/utilities/linkedlist.cpp b/hotspot/src/share/vm/utilities/linkedlist.cpp new file mode 100644 index 00000000000..ba96b2e247f --- /dev/null +++ b/hotspot/src/share/vm/utilities/linkedlist.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" + +/////////////// Unit tests /////////////// + +#ifndef PRODUCT + +#include "runtime/os.hpp" +#include "utilities/linkedlist.hpp" +#include "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" + +class Integer : public StackObj { + private: + int _value; + public: + Integer(int i) : _value(i) { } + + int value() const { return _value; } + bool equals(const Integer& i) const { + return _value == i.value(); + } +}; + +int compare_Integer(const Integer& i1, const Integer& i2) { + return i1.value() - i2.value(); +} + +void check_list_values(const int* expected, const LinkedList* list) { + LinkedListNode* head = list->head(); + int index = 0; + while (head != NULL) { + assert(head->peek()->value() == expected[index], "Unexpected value"); + head = head->next(); + index ++; + } +} + +void Test_linked_list() { + LinkedListImpl ll; + + + // Test regular linked list + assert(ll.is_empty(), "Start with empty list"); + Integer one(1), two(2), three(3), four(4), five(5), six(6); + + ll.add(six); + assert(!ll.is_empty(), "Should not be empty"); + + Integer* i = ll.find(six); + assert(i != NULL, "Should find it"); + + i = ll.find(three); + assert(i == NULL, "Not in the list"); + + LinkedListNode* node = ll.find_node(six); + assert(node != NULL, "6 is in the list"); + + ll.insert_after(three, node); + ll.insert_before(one, node); + int expected[3] = {1, 6, 3}; + check_list_values(expected, &ll); + + ll.add(two); + ll.add(four); + ll.add(five); + + // Test sorted linked list + SortedLinkedList sl; + assert(sl.is_empty(), "Start with empty list"); + + size_t ll_size = ll.size(); + sl.move(&ll); + size_t sl_size = sl.size(); + + assert(ll_size == sl_size, "Should be the same size"); + assert(ll.is_empty(), "No more entires"); + + // sorted result + int sorted_result[] = {1, 2, 3, 4, 5, 6}; + check_list_values(sorted_result, &sl); + + node = sl.find_node(four); + assert(node != NULL, "4 is in the list"); + sl.remove_before(node); + sl.remove_after(node); + int remains[] = {1, 2, 4, 6}; + check_list_values(remains, &sl); +} +#endif // PRODUCT + diff --git a/hotspot/src/share/vm/utilities/linkedlist.hpp b/hotspot/src/share/vm/utilities/linkedlist.hpp new file mode 100644 index 00000000000..a76c15cca0e --- /dev/null +++ b/hotspot/src/share/vm/utilities/linkedlist.hpp @@ -0,0 +1,416 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_UTILITIES_LINKED_LIST_HPP +#define SHARE_VM_UTILITIES_LINKED_LIST_HPP + +#include "memory/allocation.hpp" + +/* + * The implementation of a generic linked list, which uses various + * backing storages, such as C heap, arena and resource, etc. + */ + + +// An entry in a linked list. It should use the same backing storage +// as the linked list that contains this entry. +template class LinkedListNode : public ResourceObj { + private: + E _data; // embedded content + LinkedListNode* _next; // next entry + + protected: + LinkedListNode() : _next(NULL) { } + + public: + LinkedListNode(const E& e): _data(e), _next(NULL) { } + + inline void set_next(LinkedListNode* node) { _next = node; } + inline LinkedListNode * next() const { return _next; } + + E* data() { return &_data; } + const E* peek() const { return &_data; } +}; + +// A linked list interface. It does not specify +// any storage type it uses, so all methods involving +// memory allocation or deallocation are pure virtual +template class LinkedList : public ResourceObj { + protected: + LinkedListNode* _head; + + public: + LinkedList() : _head(NULL) { } + + inline void set_head(LinkedListNode* h) { _head = h; } + inline LinkedListNode* head() const { return _head; } + inline bool is_empty() const { return head() == NULL; } + + inline size_t size() const { + LinkedListNode* p; + size_t count = 0; + for (p = head(); p != NULL; count++, p = p->next()); + return count; + } + + // Move all entries from specified linked list to this one + virtual void move(LinkedList* list) = 0; + + // Add an entry to this linked list + virtual LinkedListNode* add(const E& e) = 0; + // Add all entries from specified linked list to this one, + virtual void add(LinkedListNode* node) = 0; + + // Add a linked list to this linked list + virtual bool add(const LinkedList* list) = 0; + + // Search entry in the linked list + virtual LinkedListNode* find_node(const E& e) = 0; + virtual E* find(const E& e) = 0; + + // Insert entry to the linked list + virtual LinkedListNode* insert_before(const E& e, LinkedListNode* ref) = 0; + virtual LinkedListNode* insert_after (const E& e, LinkedListNode* ref) = 0; + + // Remove entry from the linked list + virtual bool remove(const E& e) = 0; + virtual bool remove(LinkedListNode* node) = 0; + virtual bool remove_before(LinkedListNode* ref) = 0; + virtual bool remove_after(LinkedListNode* ref) = 0; + + LinkedListNode* unlink_head() { + LinkedListNode* h = this->head(); + if (h != NULL) { + this->set_head(h->next()); + } + return h; + } + + DEBUG_ONLY(virtual ResourceObj::allocation_type storage_type() = 0;) +}; + +// A linked list implementation. +// The linked list can be allocated in various type of memory: C heap, arena and resource area, etc. +template + class LinkedListImpl : public LinkedList { + protected: + Arena* _arena; + public: + LinkedListImpl() : _arena(NULL) { } + LinkedListImpl(Arena* a) : _arena(a) { } + + virtual ~LinkedListImpl() { + clear(); + } + + virtual void clear() { + LinkedListNode* p = this->head(); + this->set_head(NULL); + while (p != NULL) { + LinkedListNode* to_delete = p; + p = p->next(); + delete_node(to_delete); + } + } + + // Add an entry to the linked list + virtual LinkedListNode* add(const E& e) { + LinkedListNode* node = this->new_node(e); + if (node != NULL) { + this->add(node); + } + + return node; + } + + virtual void add(LinkedListNode* node) { + assert(node != NULL, "NULL pointer"); + node->set_next(this->head()); + this->set_head(node); + } + + // Move a linked list to this linked list, both have to be allocated on the same + // storage type. + virtual void move(LinkedList* list) { + assert(list->storage_type() == this->storage_type(), "Different storage type"); + LinkedListNode* node = this->head(); + while (node != NULL && node->next() != NULL) { + node = node->next(); + } + if (node == NULL) { + this->set_head(list->head()); + } else { + node->set_next(list->head()); + } + // All entries are moved + list->set_head(NULL); + } + + virtual bool add(const LinkedList* list) { + LinkedListNode* node = list->head(); + while (node != NULL) { + if (this->add(*node->peek()) == NULL) { + return false; + } + node = node->next(); + } + return true; + } + + + virtual LinkedListNode* find_node(const E& e) { + LinkedListNode* p = this->head(); + while (p != NULL && !p->peek()->equals(e)) { + p = p->next(); + } + return p; + } + + E* find(const E& e) { + LinkedListNode* node = find_node(e); + return (node == NULL) ? NULL : node->data(); + } + + + // Add an entry in front of the reference entry + LinkedListNode* insert_before(const E& e, LinkedListNode* ref_node) { + LinkedListNode* node = this->new_node(e); + if (node == NULL) return NULL; + if (ref_node == this->head()) { + node->set_next(ref_node); + this->set_head(node); + } else { + LinkedListNode* p = this->head(); + while (p != NULL && p->next() != ref_node) { + p = p->next(); + } + assert(p != NULL, "ref_node not in the list"); + node->set_next(ref_node); + p->set_next(node); + } + return node; + } + + // Add an entry behind the reference entry + LinkedListNode* insert_after(const E& e, LinkedListNode* ref_node) { + LinkedListNode* node = this->new_node(e); + if (node == NULL) return NULL; + node->set_next(ref_node->next()); + ref_node->set_next(node); + return node; + } + + // Remove an entry from the linked list. + // Return true if the entry is successfully removed + virtual bool remove(const E& e) { + LinkedListNode* tmp = this->head(); + LinkedListNode* prev = NULL; + + while (tmp != NULL) { + if (tmp->peek()->equals(e)) { + return remove_after(prev); + } + prev = tmp; + tmp = tmp->next(); + } + return false; + } + + // Remove the node after the reference entry + virtual bool remove_after(LinkedListNode* prev) { + LinkedListNode* to_delete; + if (prev == NULL) { + to_delete = this->unlink_head(); + } else { + to_delete = prev->next(); + if (to_delete != NULL) { + prev->set_next(to_delete->next()); + } + } + + if (to_delete != NULL) { + delete_node(to_delete); + return true; + } + return false; + } + + virtual bool remove(LinkedListNode* node) { + LinkedListNode* p = this->head(); + while (p != NULL && p->next() != node) { + p = p->next(); + } + if (p != NULL) { + p->set_next(node->next()); + delete_node(node); + return true; + } else { + return false; + } + } + + virtual bool remove_before(LinkedListNode* ref) { + assert(ref != NULL, "NULL pointer"); + LinkedListNode* p = this->head(); + LinkedListNode* to_delete = NULL; // to be deleted + LinkedListNode* prev = NULL; // node before the node to be deleted + while (p != NULL && p != ref) { + prev = to_delete; + to_delete = p; + p = p->next(); + } + if (p == NULL || to_delete == NULL) return false; + assert(to_delete->next() == ref, "Wrong node to delete"); + assert(prev == NULL || prev->next() == to_delete, + "Sanity check"); + if (prev == NULL) { + assert(to_delete == this->head(), "Must be head"); + this->set_head(to_delete->next()); + } else { + prev->set_next(to_delete->next()); + } + delete_node(to_delete); + return true; + } + + DEBUG_ONLY(ResourceObj::allocation_type storage_type() { return T; }) + protected: + // Create new linked list node object in specified storage + LinkedListNode* new_node(const E& e) const { + switch(T) { + case ResourceObj::ARENA: { + assert(_arena != NULL, "Arena not set"); + return new(_arena) LinkedListNode(e); + } + case ResourceObj::RESOURCE_AREA: + case ResourceObj::C_HEAP: { + if (alloc_failmode == AllocFailStrategy::RETURN_NULL) { + return new(std::nothrow, T, F) LinkedListNode(e); + } else { + return new(T, F) LinkedListNode(e); + } + } + default: + ShouldNotReachHere(); + } + return NULL; + } + + // Delete linked list node object + void delete_node(LinkedListNode* node) { + if (T == ResourceObj::C_HEAP) { + delete node; + } + } +}; + +// Sorted linked list. The linked list maintains sorting order specified by the comparison +// function +template + class SortedLinkedList : public LinkedListImpl { + public: + SortedLinkedList() { } + SortedLinkedList(Arena* a) : LinkedListImpl(a) { } + + virtual LinkedListNode* add(const E& e) { + return LinkedListImpl::add(e); + } + + virtual void move(LinkedList* list) { + assert(list->storage_type() == this->storage_type(), "Different storage type"); + LinkedListNode* node; + while ((node = list->unlink_head()) != NULL) { + this->add(node); + } + assert(list->is_empty(), "All entries are moved"); + } + + virtual void add(LinkedListNode* node) { + assert(node != NULL, "NULL pointer"); + LinkedListNode* tmp = this->head(); + LinkedListNode* prev = NULL; + + int cmp_val; + while (tmp != NULL) { + cmp_val = FUNC(*tmp->peek(), *node->peek()); + if (cmp_val >= 0) { + break; + } + prev = tmp; + tmp = tmp->next(); + } + + if (prev != NULL) { + node->set_next(prev->next()); + prev->set_next(node); + } else { + node->set_next(this->head()); + this->set_head(node); + } + } + + virtual bool add(const LinkedList* list) { + return LinkedListImpl::add(list); + } + + virtual LinkedListNode* find_node(const E& e) { + LinkedListNode* p = this->head(); + + while (p != NULL) { + int comp_val = FUNC(*p->peek(), e); + if (comp_val == 0) { + return p; + } else if (comp_val > 0) { + return NULL; + } + p = p->next(); + } + return NULL; + } +}; + +// Iterates all entries in the list +template class LinkedListIterator : public StackObj { + private: + LinkedListNode* _p; + bool _is_empty; + public: + LinkedListIterator(LinkedListNode* head) : _p(head) { + _is_empty = (head == NULL); + } + + bool is_empty() const { return _is_empty; } + + const E* next() { + if (_p == NULL) return NULL; + const E* e = _p->peek(); + _p = _p->next(); + return e; + } +}; + +#endif diff --git a/hotspot/src/share/vm/utilities/nativeCallStack.cpp b/hotspot/src/share/vm/utilities/nativeCallStack.cpp new file mode 100644 index 00000000000..c50ff410921 --- /dev/null +++ b/hotspot/src/share/vm/utilities/nativeCallStack.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "runtime/os.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/nativeCallStack.hpp" + + +NativeCallStack::NativeCallStack(int toSkip, bool fillStack) : + _hash_value(0) { + +#if !PLATFORM_NATIVE_STACK_WALKING_SUPPORTED + fillStack = false; +#endif + + if (fillStack) { + os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip); + } else { + for (int index = 0; index < NMT_TrackingStackDepth; index ++) { + _stack[index] = NULL; + } + } +} + +NativeCallStack::NativeCallStack(address* pc, int frameCount) { + int frameToCopy = (frameCount < NMT_TrackingStackDepth) ? + frameCount : NMT_TrackingStackDepth; + int index; + for (index = 0; index < frameToCopy; index ++) { + _stack[index] = pc[index]; + } + for (; index < NMT_TrackingStackDepth; index ++) { + _stack[index] = NULL; + } +} + +// number of stack frames captured +int NativeCallStack::frames() const { + int index; + for (index = 0; index < NMT_TrackingStackDepth; index ++) { + if (_stack[index] == NULL) { + break; + } + } + return index; +} + +// Hash code. Any better algorithm? +int NativeCallStack::hash() const { + long hash_val = _hash_value; + if (hash_val == 0) { + long pc; + int index; + for (index = 0; index < NMT_TrackingStackDepth; index ++) { + pc = (long)_stack[index]; + if (pc == 0) break; + hash_val += pc; + } + + NativeCallStack* p = const_cast(this); + p->_hash_value = (int)(hash_val & 0xFFFFFFFF); + } + return _hash_value; +} + +void NativeCallStack::print_on(outputStream* out) const { + print_on(out, 0); +} + +// Decode and print this call path +void NativeCallStack::print_on(outputStream* out, int indent) const { + address pc; + char buf[1024]; + int offset; + if (is_empty()) { + for (int index = 0; index < indent; index ++) out->print(" "); +#if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED + out->print("[BOOTSTRAP]"); +#else + out->print("[No stack]"); +#endif + } else { + for (int frame = 0; frame < NMT_TrackingStackDepth; frame ++) { + pc = get_frame(frame); + if (pc == NULL) break; + // Print indent + for (int index = 0; index < indent; index ++) out->print(" "); + if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) { + out->print_cr("[" PTR_FORMAT "] %s+0x%x", p2i(pc), buf, offset); + } else { + out->print_cr("[" PTR_FORMAT "]", p2i(pc)); + } + } + } +} + diff --git a/hotspot/src/share/vm/utilities/nativeCallStack.hpp b/hotspot/src/share/vm/utilities/nativeCallStack.hpp new file mode 100644 index 00000000000..957090b61c7 --- /dev/null +++ b/hotspot/src/share/vm/utilities/nativeCallStack.hpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_UTILITIES_NATIVE_CALL_STACK_HPP +#define SHARE_VM_UTILITIES_NATIVE_CALL_STACK_HPP + +#include "memory/allocation.hpp" +#include "services/nmtCommon.hpp" +#include "utilities/ostream.hpp" + +/* + * This class represents a native call path (does not include Java frame) + * + * This class is developed in the context of native memory tracking, it can + * be an useful tool for debugging purpose. + * + * For example, following code should print out native call path: + * + * .... + * NativeCallStack here; + * here.print_on(tty); + * .... + * + * However, there are a couple of restrictions on this class. If the restrictions are + * not strictly followed, it may break native memory tracking badly. + * + * 1. Number of stack frames to capture, is defined by native memory tracking. + * This number has impacts on how much memory to be used by native + * memory tracking. + * 2. The class is strict stack object, no heap or virtual memory can be allocated + * from it. + */ +class NativeCallStack : public StackObj { + private: + address _stack[NMT_TrackingStackDepth]; + int _hash_value; + + public: + NativeCallStack(int toSkip = 0, bool fillStack = false); + NativeCallStack(address* pc, int frameCount); + + + // if it is an empty stack + inline bool is_empty() const { + return _stack[0] == NULL; + } + + // number of stack frames captured + int frames() const; + + inline int compare(const NativeCallStack& other) const { + return memcmp(_stack, other._stack, sizeof(_stack)); + } + + inline bool equals(const NativeCallStack& other) const { + // compare hash values + if (hash() != other.hash()) return false; + // compare each frame + return compare(other) == 0; + } + + inline address get_frame(int index) const { + assert(index >= 0 && index < NMT_TrackingStackDepth, "Index out of bound"); + return _stack[index]; + } + + // Hash code. Any better algorithm? + int hash() const; + + void print_on(outputStream* out) const; + void print_on(outputStream* out, int indent) const; +}; + +#endif diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index 2bff5f5c824..3678068bed9 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -774,6 +774,11 @@ void VMError::report(outputStream* st) { st->cr(); } + STEP(228, "(Native Memory Tracking)" ) + if (_verbose) { + MemTracker::final_report(st); + } + STEP(230, "" ) if (_verbose) { @@ -897,9 +902,6 @@ void VMError::report_and_die() { static bool log_done = false; // done saving error log static bool transmit_report_done = false; // done error reporting - // disble NMT to avoid further exception - MemTracker::shutdown(MemTracker::NMT_error_reporting); - if (SuppressFatalErrorMessage) { os::abort(); } diff --git a/hotspot/test/TEST.ROOT b/hotspot/test/TEST.ROOT index e646c1aa08d..6bf9e9a9009 100644 --- a/hotspot/test/TEST.ROOT +++ b/hotspot/test/TEST.ROOT @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,6 @@ # It also contains test-suite configuration information. # The list of keywords supported in this test suite -keys=cte_test jcmd nmt regression gc +keys=cte_test jcmd nmt regression gc stress groups=TEST.groups [closed/TEST.groups] diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index b88243644c0..e4f1ee32d29 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -70,21 +70,29 @@ needs_jdk = \ runtime/7194254/Test7194254.java \ runtime/Metaspace/FragmentMetaspace.java \ runtime/NMT/BaselineWithParameter.java \ + runtime/NMT/JcmdBaselineDetail.java \ + runtime/NMT/JcmdDetailDiff.java \ + runtime/NMT/JcmdScaleDetail.java \ runtime/NMT/JcmdScale.java \ + runtime/NMT/JcmdSummaryDiff.java \ runtime/NMT/JcmdWithNMTDisabled.java \ + runtime/NMT/MallocRoundingReportTest.java \ + runtime/NMT/MallocSiteHashOverflow.java \ + runtime/NMT/MallocStressTest.java \ runtime/NMT/MallocTestType.java \ runtime/NMT/ReleaseCommittedMemory.java \ + runtime/NMT/ReleaseNoCommit.java \ runtime/NMT/ShutdownTwice.java \ runtime/NMT/SummaryAfterShutdown.java \ runtime/NMT/SummarySanityCheck.java \ runtime/NMT/ThreadedMallocTestType.java \ runtime/NMT/ThreadedVirtualAllocTestType.java \ + runtime/NMT/VirtualAllocCommitUncommitRecommit.java \ runtime/NMT/VirtualAllocTestType.java \ runtime/RedefineObject/TestRedefineObject.java \ runtime/Thread/TestThreadDumpMonitorContention.java \ runtime/XCheckJniJsig/XCheckJSig.java \ serviceability/attach/AttachWithStalePidFile.java \ - serviceability/jvmti/8036666/GetObjectLockCount.java \ serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java \ serviceability/dcmd/DynLibDcmdTest.java @@ -120,16 +128,12 @@ needs_compact3 = \ gc/6581734/Test6581734.java \ gc/7072527/TestFullGCCount.java \ gc/g1/TestHumongousAllocInitialMark.java \ - gc/g1/TestHumongousShrinkHeap.java \ gc/arguments/TestG1HeapRegionSize.java \ gc/metaspace/TestMetaspaceMemoryPool.java \ gc/arguments/TestDynMinHeapFreeRatio.java \ gc/arguments/TestDynMaxHeapFreeRatio.java \ - gc/parallelScavenge/TestDynShrinkHeap.java \ runtime/InternalApi/ThreadCpuTimesDeadlock.java \ serviceability/threads/TestFalseDeadLock.java \ - serviceability/jvmti/GetObjectSizeOverflow.java \ - serviceability/jvmti/TestRedefineWithUnresolvedClass.java # Compact 2 adds full VM tests compact2 = \ @@ -217,6 +221,7 @@ needs_g1gc = \ gc/arguments/TestMaxHeapSizeTools.java \ gc/arguments/TestMaxNewSize.java \ gc/arguments/TestUseCompressedOopsErgo.java \ + gc/class_unloading/TestG1ClassUnloadingHWM.java \ gc/g1/ \ gc/metaspace/G1AddMetaspaceDependency.java \ gc/metaspace/TestMetaspacePerfCounters.java \ @@ -257,7 +262,7 @@ needs_cmsgc = \ gc/arguments/TestCMSHeapSizeFlags.java \ gc/arguments/TestMaxNewSize.java \ gc/arguments/TestUseCompressedOopsErgo.java \ - gc/class_unloading/TestCMSClassUnloadingDisabledHWM.java \ + gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java \ gc/concurrentMarkSweep/ \ gc/startup_warnings/TestCMS.java \ gc/startup_warnings/TestCMSIncrementalMode.java \ diff --git a/hotspot/test/compiler/5091921/Test7005594.sh b/hotspot/test/compiler/5091921/Test7005594.sh index 2ca434ae876..4fa458ca723 100644 --- a/hotspot/test/compiler/5091921/Test7005594.sh +++ b/hotspot/test/compiler/5091921/Test7005594.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,7 @@ cp ${TESTSRC}/Test7005594.sh . ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test7005594.java -${TESTJAVA}/bin/java ${TESTVMOPTS} -Xmx1600m -Xms1600m -XX:+IgnoreUnrecognizedVMOptions -XX:-ZapUnusedHeapArea -Xcomp -XX:CompileOnly=Test7005594.test Test7005594 > test.out 2>&1 +${TESTJAVA}/bin/java ${TESTOPTS} -Xmx1600m -Xms1600m -XX:+IgnoreUnrecognizedVMOptions -XX:-ZapUnusedHeapArea -Xcomp -XX:CompileOnly=Test7005594.test Test7005594 > test.out 2>&1 result=$? diff --git a/hotspot/test/compiler/6857159/Test6857159.sh b/hotspot/test/compiler/6857159/Test6857159.sh index e0430c43abc..cb790127c9c 100644 --- a/hotspot/test/compiler/6857159/Test6857159.sh +++ b/hotspot/test/compiler/6857159/Test6857159.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ cp ${TESTSRC}/Test6857159.sh . ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test6857159.java -${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbatch -XX:+PrintCompilation -XX:CompileOnly=Test6857159\$ct.run Test6857159 > test.out 2>&1 +${TESTJAVA}/bin/java ${TESTOPTS} -Xbatch -XX:+PrintCompilation -XX:CompileOnly=Test6857159\$ct.run Test6857159 > test.out 2>&1 grep "COMPILE SKIPPED" test.out diff --git a/hotspot/test/compiler/6894807/IsInstanceTest.java b/hotspot/test/compiler/6894807/IsInstanceTest.java index ddc3fed365a..d838c6ec662 100644 --- a/hotspot/test/compiler/6894807/IsInstanceTest.java +++ b/hotspot/test/compiler/6894807/IsInstanceTest.java @@ -1,3 +1,26 @@ +/* + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 6894807 diff --git a/hotspot/test/compiler/6894807/Test6894807.sh b/hotspot/test/compiler/6894807/Test6894807.sh index 229fb545108..609af074eda 100644 --- a/hotspot/test/compiler/6894807/Test6894807.sh +++ b/hotspot/test/compiler/6894807/Test6894807.sh @@ -1,55 +1,38 @@ #!/bin/sh +# +# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# 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. +# if [ "${TESTSRC}" = "" ] -then TESTSRC=. -fi - -if [ "${TESTJAVA}" = "" ] then - PARENT=`dirname \`which java\`` - TESTJAVA=`dirname ${PARENT}` - echo "TESTJAVA not set, selecting " ${TESTJAVA} - echo "If this is incorrect, try setting the variable manually." + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" fi +echo "TESTSRC=${TESTSRC}" -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - NULL=/dev/null - PS=":" - FS="/" - ;; - Windows_* ) - NULL=NUL - PS=";" - FS="\\" - ;; - CYGWIN_* ) - NULL=/dev/null - PS=";" - FS="/" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -JEMMYPATH=${CPAPPEND} -CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH - -THIS_DIR=`pwd` - -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version - -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} IsInstanceTest > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} IsInstanceTest > test.out 2>&1 cat test.out diff --git a/hotspot/test/compiler/6932496/Test6932496.java b/hotspot/test/compiler/6932496/Test6932496.java index 721b4e00b72..7f3c1697355 100644 --- a/hotspot/test/compiler/6932496/Test6932496.java +++ b/hotspot/test/compiler/6932496/Test6932496.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,26 +26,162 @@ * @test * @bug 6932496 * @summary incorrect deopt of jsr subroutine on 64 bit c1 - * - * @compile -source 1.5 -target 1.5 -XDjsrlimit=0 Test6932496.java - * @run main/othervm -Xcomp -XX:CompileOnly=Test6932496.m Test6932496 + * @run main/othervm -Xcomp -XX:CompileOnly=Test.test Test6932496 */ +import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.io.IOException; -public class Test6932496 { - static class A { - volatile boolean flag = false; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.FieldVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.Label; + +public class Test6932496 extends ClassLoader { + private static final int CLASS_FILE_VERSION = 49; + private static final String CLASS_TEST = "Test"; + private static final String CLASS_OBJECT = "java/lang/Object"; + private static final String METHOD_INIT = ""; + private static final String METHOD_TEST = "test"; + private static final String DESC_VOID_METHOD = "()V"; + private static final String FIELD_FLAG = "flag"; + + public static void main(String[] args) { + Test6932496 test = new Test6932496(); + test.execute(); } - static void m() { + private void execute() { + byte[] bytecode = Test6932496.generateTestClass(); + try { - } finally { - A a = new A(); - a.flag = true; + Files.write(Paths.get("Test.class.dump"), bytecode); + } catch (IOException e) { + System.err.println("classfile dump failed : " + e.getMessage()); + e.printStackTrace(); + } + try { + Class aClass = defineClass(CLASS_TEST, bytecode, 0, bytecode.length); + Method test = aClass.getDeclaredMethod(METHOD_TEST); + test.invoke(null); + } catch (ClassFormatError | IllegalArgumentException + | ReflectiveOperationException e) { + throw new RuntimeException("TESTBUG : generated class is invalid", e); } } + /* + public class Test { + volatile boolean flag = false; + public static void m() { + try { + } finally { + Test test = new Test(); + test.flag = true; + } + } + } + */ + private static byte[] generateTestClass() { + ClassWriter cw = new ClassWriter(0); + cw.visit(CLASS_FILE_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, + CLASS_TEST, null, CLASS_OBJECT, null); + // volatile boolean flag; + { + FieldVisitor fv = cw.visitField(Opcodes.ACC_VOLATILE, FIELD_FLAG, + Type.BOOLEAN_TYPE.getDescriptor(), + /* signature = */ null, /* value = */ null); + } - static public void main(String[] args) { - m(); + /* + public Test() { + flag = false; + } + */ + { + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, + METHOD_INIT, DESC_VOID_METHOD, + /* signature = */ null, /* exceptions = */ null); + + mv.visitCode(); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, CLASS_OBJECT, METHOD_INIT, + DESC_VOID_METHOD, false); + + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitInsn(Opcodes.ICONST_0); + mv.visitFieldInsn(Opcodes.PUTFIELD, CLASS_TEST, FIELD_FLAG, + Type.BOOLEAN_TYPE.getDescriptor()); + + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(/* stack = */ 2, /* locals = */ 1); + mv.visitEnd(); + } + + /* + public static void m() { + try { + } finally { + Test test = new Test(); + test.flag = true; + } + } + */ + { + MethodVisitor mv = cw.visitMethod( + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC, + METHOD_TEST, DESC_VOID_METHOD, + /* signature = */ null, /* exceptions = */ null); + Label beginLabel = new Label(); + Label block1EndLabel = new Label(); + Label handlerLabel = new Label(); + Label block2EndLabel = new Label(); + Label label = new Label(); + Label endLabel = new Label(); + + mv.visitCode(); + mv.visitTryCatchBlock(beginLabel, block1EndLabel, handlerLabel, + /* type = */ null); + mv.visitTryCatchBlock(handlerLabel, block2EndLabel, handlerLabel, + /* type = */ null); + + mv.visitLabel(beginLabel); + mv.visitJumpInsn(Opcodes.JSR, label); + mv.visitLabel(block1EndLabel); + mv.visitJumpInsn(Opcodes.GOTO, endLabel); + + mv.visitLabel(handlerLabel); + mv.visitVarInsn(Opcodes.ASTORE, 0); + mv.visitJumpInsn(Opcodes.JSR, label); + mv.visitLabel(block2EndLabel); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitInsn(Opcodes.ATHROW); + + mv.visitLabel(label); + mv.visitVarInsn(Opcodes.ASTORE, 1); + mv.visitTypeInsn(Opcodes.NEW, CLASS_TEST); + mv.visitInsn(Opcodes.DUP); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, CLASS_TEST, METHOD_INIT, + DESC_VOID_METHOD); + mv.visitVarInsn(Opcodes.ASTORE, 2); + + mv.visitVarInsn(Opcodes.ALOAD, 2); + mv.visitInsn(Opcodes.ICONST_1); + mv.visitFieldInsn(Opcodes.PUTFIELD, CLASS_TEST, FIELD_FLAG, + Type.BOOLEAN_TYPE.getDescriptor()); + + mv.visitVarInsn(Opcodes.RET, 1); + + mv.visitLabel(endLabel); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(/* stack = */ 2, /* locals = */ 3); + mv.visitEnd(); + } + + cw.visitEnd(); + return cw.toByteArray(); } } diff --git a/hotspot/test/compiler/7068051/Test7068051.sh b/hotspot/test/compiler/7068051/Test7068051.sh index e287c243163..35bc0f72efd 100644 --- a/hotspot/test/compiler/7068051/Test7068051.sh +++ b/hotspot/test/compiler/7068051/Test7068051.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -41,5 +41,5 @@ ${COMPILEJAVA}/bin/jar -uf0 foo.jar Test7068051.java ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test7068051.java -${TESTJAVA}/bin/java ${TESTVMOPTS} -showversion -Xbatch Test7068051 foo.jar +${TESTJAVA}/bin/java ${TESTOPTS} -showversion -Xbatch Test7068051 foo.jar diff --git a/hotspot/test/compiler/7070134/Test7070134.sh b/hotspot/test/compiler/7070134/Test7070134.sh index 2ef12d04b67..87618616c97 100644 --- a/hotspot/test/compiler/7070134/Test7070134.sh +++ b/hotspot/test/compiler/7070134/Test7070134.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ cp ${TESTSRC}/words . ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Stemmer.java -${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbatch Stemmer words > test.out 2>&1 +${TESTJAVA}/bin/java ${TESTOPTS} -Xbatch Stemmer words > test.out 2>&1 exit $? diff --git a/hotspot/test/compiler/7200264/Test7200264.sh b/hotspot/test/compiler/7200264/Test7200264.sh index da1a59a29d7..5e7e508a5f2 100644 --- a/hotspot/test/compiler/7200264/Test7200264.sh +++ b/hotspot/test/compiler/7200264/Test7200264.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ echo "TESTSRC=${TESTSRC}" ## Adding common setup Variables for running shell tests. . ${TESTSRC}/../../test_env.sh -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion | sed 's/amd64/x86/' | grep "x86" | grep "Server VM" | grep "debug" +${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -Xinternalversion | sed 's/amd64/x86/' | grep "x86" | grep "Server VM" | grep "debug" # Only test fastdebug Server VM on x86 if [ $? != 0 ] @@ -43,7 +43,7 @@ then fi # grep for support integer multiply vectors (cpu with SSE4.1) -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -XX:+PrintMiscellaneous -XX:+Verbose -version | grep "cores per cpu" | grep "sse4.1" +${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -XX:+PrintMiscellaneous -XX:+Verbose -version | grep "cores per cpu" | grep "sse4.1" if [ $? != 0 ] then @@ -55,7 +55,7 @@ fi cp ${TESTSRC}${FS}TestIntVect.java . ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} -d . TestIntVect.java -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+PrintCompilation -XX:+TraceNewVectors TestIntVect > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+PrintCompilation -XX:+TraceNewVectors TestIntVect > test.out 2>&1 COUNT=`grep AddVI test.out | wc -l | awk '{print $1}'` if [ $COUNT -lt 4 ] diff --git a/hotspot/test/compiler/ciReplay/TestSA.sh b/hotspot/test/compiler/ciReplay/TestSA.sh index 56736c7807e..cc5f5037e7a 100644 --- a/hotspot/test/compiler/ciReplay/TestSA.sh +++ b/hotspot/test/compiler/ciReplay/TestSA.sh @@ -68,7 +68,7 @@ then fi echo "dumpreplaydata -a > ${replay_data}" | \ - ${JAVA} ${TESTVMOPTS} \ + ${JAVA} ${TESTOPTS} \ -cp ${TESTJAVA}${FS}lib${FS}sa-jdi.jar \ sun.jvm.hotspot.CLHSDB ${JAVA} ${core_file} diff --git a/hotspot/test/compiler/ciReplay/common.sh b/hotspot/test/compiler/ciReplay/common.sh index b7c5b7b4292..c7b656d26aa 100644 --- a/hotspot/test/compiler/ciReplay/common.sh +++ b/hotspot/test/compiler/ciReplay/common.sh @@ -22,6 +22,7 @@ # questions. # # +set -x # $1 - error code # $2 - test name @@ -56,7 +57,7 @@ positive_test() { shift name=$1 shift - VMOPTS="${TESTVMOPTS} $@" + VMOPTS="${TESTOPTS} $@" echo "POSITIVE TEST [$name]" start_test ${VMOPTS} exit_code=$? @@ -75,7 +76,7 @@ negative_test() { shift name=$1 shift - VMOPTS="${TESTVMOPTS} $@" + VMOPTS="${TESTOPTS} $@" echo "NEGATIVE TEST [$name]" start_test ${VMOPTS} exit_code=$? @@ -149,7 +150,7 @@ JAVA=${TESTJAVA}${FS}bin${FS}java replay_data=test_replay.txt -${JAVA} ${TESTVMOPTS} -Xinternalversion 2>&1 | grep debug +${JAVA} ${TESTOPTS} -Xinternalversion 2>&1 | grep debug # Only test fastdebug if [ $? -ne 0 ] @@ -158,7 +159,7 @@ then exit 0 fi -is_int=`${JAVA} ${TESTVMOPTS} -version 2>&1 | grep -c "interpreted mode"` +is_int=`${JAVA} ${TESTOPTS} -version 2>&1 | grep -c "interpreted mode"` # Not applicable for Xint if [ $is_int -ne 0 ] then @@ -168,14 +169,14 @@ fi cleanup -client_available=`${JAVA} ${TESTVMOPTS} -client -Xinternalversion 2>&1 | \ +client_available=`${JAVA} ${TESTOPTS} -client -Xinternalversion 2>&1 | \ grep -c Client` -server_available=`${JAVA} ${TESTVMOPTS} -server -Xinternalversion 2>&1 | \ +server_available=`${JAVA} ${TESTOPTS} -server -Xinternalversion 2>&1 | \ grep -c Server` -tiered_available=`${JAVA} ${TESTVMOPTS} -XX:+TieredCompilation -XX:+PrintFlagsFinal -version | \ +tiered_available=`${JAVA} ${TESTOPTS} -XX:+TieredCompilation -XX:+PrintFlagsFinal -version | \ grep TieredCompilation | \ grep -c true` -is_tiered=`${JAVA} ${TESTVMOPTS} -XX:+PrintFlagsFinal -version | \ +is_tiered=`${JAVA} ${TESTOPTS} -XX:+PrintFlagsFinal -version | \ grep TieredCompilation | \ grep -c true` # CompLevel_simple -- C1 @@ -207,7 +208,7 @@ generate_replay() { fi fi - cmd="${JAVA} ${TESTVMOPTS} $@ \ + cmd="${JAVA} ${TESTOPTS} $@ \ -Xms8m \ -Xmx32m \ -XX:MetaspaceSize=4m \ diff --git a/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java new file mode 100644 index 00000000000..5e0c58fed93 --- /dev/null +++ b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 sun.hotspot.WhiteBox; + +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +/* + * @test MethodUnloadingTest + * @bug 8029443 + * @summary "Tests the unloading of methods to to class unloading" + * @library /testlibrary /testlibrary/whitebox + * @build TestMethodUnloading + * @build WorkerClass + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-BackgroundCompilation -XX:-UseCompressedOops -XX:+UseParallelGC -XX:CompileOnly=TestMethodUnloading::doWork TestMethodUnloading + */ +public class TestMethodUnloading { + private static final String workerClassName = "WorkerClass"; + private static int work = -1; + + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static int COMP_LEVEL_SIMPLE = 1; + private static int COMP_LEVEL_FULL_OPTIMIZATION = 4; + + /** + * Does some work by either using the workerClass or locally producing values. + * @param workerClass Class performing some work (will be unloaded) + * @param useWorker If true the workerClass is used + */ + static private void doWork(Class workerClass, boolean useWorker) throws InstantiationException, IllegalAccessException { + if (useWorker) { + // Create a new instance + Object worker = workerClass.newInstance(); + // We would like to call a method of WorkerClass here but we cannot cast to WorkerClass + // because the class was loaded by a different class loader. One solution would be to use + // reflection but since we want C2 to implement the call as an optimized IC we call + // Object::hashCode() here which actually calls WorkerClass::hashCode(). + // C2 will then implement this call as an optimized IC that points to a to-interpreter stub + // referencing the Method* for WorkerClass::hashCode(). + work = worker.hashCode(); + if (work != 42) { + new RuntimeException("Work not done"); + } + } else { + // Do some important work here + work = 1; + } + } + + /** + * Makes sure that method is compiled by forcing compilation if not yet compiled. + * @param m Method to be checked + */ + static private void makeSureIsCompiled(Method m) { + // Make sure background compilation is disabled + if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { + throw new RuntimeException("Background compilation enabled"); + } + + // Check if already compiled + if (!WHITE_BOX.isMethodCompiled(m)) { + // If not, try to compile it with C2 + if(!WHITE_BOX.enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION)) { + // C2 compiler not available, try to compile with C1 + WHITE_BOX.enqueueMethodForCompilation(m, COMP_LEVEL_SIMPLE); + } + // Because background compilation is disabled, method should now be compiled + if(!WHITE_BOX.isMethodCompiled(m)) { + throw new RuntimeException(m + " not compiled"); + } + } + } + + /** + * This test creates stale Method* metadata in a to-interpreter stub of an optimized IC. + * + * The following steps are performed: + * (1) A workerClass is loaded by a custom class loader + * (2) The method doWork that calls a method of the workerClass is compiled. The call + * is implemented as an optimized IC calling a to-interpreted stub. The to-interpreter + * stub contains a Method* to a workerClass method. + * (3) Unloading of the workerClass is enforced. The to-interpreter stub now contains a dead Method*. + * (4) Depending on the implementation of the IC, the compiled version of doWork should still be + * valid. We call it again without using the workerClass. + */ + static public void main(String[] args) throws Exception { + // (1) Create a custom class loader with no parent class loader + URL url = TestMethodUnloading.class.getProtectionDomain().getCodeSource().getLocation(); + URLClassLoader loader = new URLClassLoader(new URL[] {url}, null); + + // Load worker class with custom class loader + Class workerClass = Class.forName(workerClassName, true, loader); + + // (2) Make sure all paths of doWork are profiled and compiled + for (int i = 0; i < 100000; ++i) { + doWork(workerClass, true); + doWork(workerClass, false); + } + + // Make sure doWork is compiled now + Method doWork = TestMethodUnloading.class.getDeclaredMethod("doWork", Class.class, boolean.class); + makeSureIsCompiled(doWork); + + // (3) Throw away class loader and reference to workerClass to allow unloading + loader.close(); + loader = null; + workerClass = null; + + // Force garbage collection to trigger unloading of workerClass + // Dead reference to WorkerClass::hashCode triggers JDK-8029443 + WHITE_BOX.fullGC(); + + // (4) Depending on the implementation of the IC, the compiled version of doWork + // may still be valid here. Execute it without a workerClass. + doWork(null, false); + if (work != 1) { + throw new RuntimeException("Work not done"); + } + + doWork(Object.class, false); + } +} diff --git a/jdk/src/share/classes/sun/audio/AudioSecurityExceptionAction.java b/hotspot/test/compiler/classUnloading/methodUnloading/WorkerClass.java similarity index 67% rename from jdk/src/share/classes/sun/audio/AudioSecurityExceptionAction.java rename to hotspot/test/compiler/classUnloading/methodUnloading/WorkerClass.java index ed174c0f3a1..c67154f2c80 100644 --- a/jdk/src/share/classes/sun/audio/AudioSecurityExceptionAction.java +++ b/hotspot/test/compiler/classUnloading/methodUnloading/WorkerClass.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. + * 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 @@ -23,8 +21,17 @@ * questions. */ -package sun.audio; - -public interface AudioSecurityExceptionAction { - Object run() throws Exception; +/** + * Worker class that is dynamically loaded/unloaded by TestMethodUnloading. + */ +public class WorkerClass { + /** + * We override hashCode here to be able to access this implementation + * via an Object reference (we cannot cast to WorkerClass). + */ + @Override + public int hashCode() { + return 42; + } } + diff --git a/hotspot/test/compiler/macronodes/TestEliminateAllocationPhi.java b/hotspot/test/compiler/macronodes/TestEliminateAllocationPhi.java new file mode 100644 index 00000000000..e9a5154e7c7 --- /dev/null +++ b/hotspot/test/compiler/macronodes/TestEliminateAllocationPhi.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8046698 + * @summary PhiNode inserted between AllocateNode and Initialization node confuses allocation elimination + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestEliminateAllocationPhi + * + */ + +public class TestEliminateAllocationPhi { + + // This will return I when called from m(0 and once optimized will + // go away but this will confuse escape analysis in m(): it will + // find I as non escaping but non scalar replaceable. In its own + // method so that we can make the profile of the if() branch look + // like it's taken sometimes. + static Integer m2(Integer I, int i) { + for (; i < 10; i=(i+2)*(i+2)) { + } + if (i == 121) { + return II; + } + return I; + } + + static Integer II = new Integer(42); + + static int m(int[] integers, boolean flag) { + int j = 0; + while(true) { + try { + int k = integers[j++]; + // A branch that will cause loop unswitching + if (flag) { + k += 42; + } + if (k < 1000) { + throw new Exception(); + } + // Because of the try/catch the Allocate node for this + // new will be in the loop while the Initialization + // node will be outside the loop. When loop + // unswitching happens, the Allocate node will be + // cloned and the results of both will be inputs to a + // Phi that will be between the Allocate nodes and the + // Initialization nodes. + Integer I = new Integer(k); + + I = m2(I, 0); + + int i = I.intValue(); + return i; + } catch(Exception e) { + } + } + } + + static public void main(String[] args) { + for (int i = 0; i < 5000; i++) { + m2(null, 1); + } + + int[] integers = { 2000 }; + for (int i = 0; i < 6000; i++) { + m(integers, (i%2) == 0); + } + int[] integers2 = { 1, 2, 3, 4, 5, 2000 }; + for (int i = 0; i < 10000; i++) { + m(integers2, (i%2) == 0); + } + } +} diff --git a/hotspot/test/compiler/osr/TestOSRWithNonEmptyStack.java b/hotspot/test/compiler/osr/TestOSRWithNonEmptyStack.java new file mode 100644 index 00000000000..82bbfc2ae4c --- /dev/null +++ b/hotspot/test/compiler/osr/TestOSRWithNonEmptyStack.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import static jdk.internal.org.objectweb.asm.Opcodes.*; + +/** + * @test + * @bug 8051344 + * @summary Force OSR compilation with non-empty stack at the OSR entry point. + * @compile -XDignore.symbol.file TestOSRWithNonEmptyStack.java + * @run main/othervm -XX:CompileOnly=TestCase.test TestOSRWithNonEmptyStack + */ +public class TestOSRWithNonEmptyStack extends ClassLoader { + private static final int CLASS_FILE_VERSION = 52; + private static final String CLASS_NAME = "TestCase"; + private static final String METHOD_NAME = "test"; + private static final int ITERATIONS = 1_000_000; + + private static byte[] generateTestClass() { + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + + cw.visit(TestOSRWithNonEmptyStack.CLASS_FILE_VERSION, ACC_PUBLIC, + TestOSRWithNonEmptyStack.CLASS_NAME, null, "java/lang/Object", + null); + + TestOSRWithNonEmptyStack.generateConstructor(cw); + TestOSRWithNonEmptyStack.generateTestMethod(cw); + + cw.visitEnd(); + return cw.toByteArray(); + } + + private static void generateConstructor(ClassWriter classWriter) { + MethodVisitor mv = classWriter.visitMethod(ACC_PUBLIC, "", "()V", + null, null); + + mv.visitCode(); + + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", + false); + mv.visitInsn(RETURN); + + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private static void generateTestMethod(ClassWriter classWriter) { + MethodVisitor mv = classWriter.visitMethod(ACC_PUBLIC, + TestOSRWithNonEmptyStack.METHOD_NAME, "()V", null, null); + Label osrEntryPoint = new Label(); + + mv.visitCode(); + // Push 'this' into stack before OSR entry point to bail out compilation + mv.visitVarInsn(ALOAD, 0); + // Setup loop counter + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 1); + // Begin loop + mv.visitLabel(osrEntryPoint); + // Increment loop counter + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + // Duplicate it for loop condition check + mv.visitInsn(DUP); + mv.visitVarInsn(ISTORE, 1); + // Check loop condition + mv.visitLdcInsn(TestOSRWithNonEmptyStack.ITERATIONS); + mv.visitJumpInsn(IF_ICMPLT, osrEntryPoint); + // Pop 'this'. + mv.visitInsn(POP); + mv.visitInsn(RETURN); + + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private void run() { + byte[] bytecode = TestOSRWithNonEmptyStack.generateTestClass(); + + try { + Class klass = defineClass(TestOSRWithNonEmptyStack.CLASS_NAME, + bytecode, 0, bytecode.length); + + Constructor ctor = klass.getConstructor(); + Method method = klass.getDeclaredMethod( + TestOSRWithNonEmptyStack.METHOD_NAME); + + Object testCase = ctor.newInstance(); + method.invoke(testCase); + } catch (Exception e) { + throw new RuntimeException( + "Test bug: generated class should be valid.", e); + } + } + + public static void main(String args[]) { + new TestOSRWithNonEmptyStack().run(); + } +} diff --git a/hotspot/test/gc/class_unloading/AllocateBeyondMetaspaceSize.java b/hotspot/test/gc/class_unloading/AllocateBeyondMetaspaceSize.java new file mode 100644 index 00000000000..4998fa8e562 --- /dev/null +++ b/hotspot/test/gc/class_unloading/AllocateBeyondMetaspaceSize.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 sun.hotspot.WhiteBox; + +class AllocateBeyondMetaspaceSize { + public static Object dummy; + + public static void main(String [] args) { + if (args.length != 2) { + throw new IllegalArgumentException("Usage: "); + } + + long metaspaceSize = Long.parseLong(args[0]); + long youngGenSize = Long.parseLong(args[1]); + + run(metaspaceSize, youngGenSize); + } + + private static void run(long metaspaceSize, long youngGenSize) { + WhiteBox wb = WhiteBox.getWhiteBox(); + + long allocationBeyondMetaspaceSize = metaspaceSize * 2; + long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize); + + triggerYoungGC(youngGenSize); + + wb.freeMetaspace(null, metaspace, metaspace); + } + + private static void triggerYoungGC(long youngGenSize) { + long approxAllocSize = 32 * 1024; + long numAllocations = 2 * youngGenSize / approxAllocSize; + + for (long i = 0; i < numAllocations; i++) { + dummy = new byte[(int)approxAllocSize]; + } + } +} diff --git a/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java b/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java new file mode 100644 index 00000000000..508407923f6 --- /dev/null +++ b/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key gc + * @bug 8049831 + * @library /testlibrary /testlibrary/whitebox + * @build TestCMSClassUnloadingEnabledHWM AllocateBeyondMetaspaceSize + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver TestCMSClassUnloadingEnabledHWM + * @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +import java.util.ArrayList; +import java.util.Arrays; + +public class TestCMSClassUnloadingEnabledHWM { + private static long MetaspaceSize = 32 * 1024 * 1024; + private static long YoungGenSize = 32 * 1024 * 1024; + + private static OutputAnalyzer run(boolean enableUnloading) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+WhiteBoxAPI", + "-XX:MetaspaceSize=" + MetaspaceSize, + "-Xmn" + YoungGenSize, + "-XX:+UseConcMarkSweepGC", + "-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled", + "-XX:+PrintHeapAtGC", + "-XX:+PrintGCDetails", + "AllocateBeyondMetaspaceSize", + "" + MetaspaceSize, + "" + YoungGenSize); + return new OutputAnalyzer(pb.start()); + } + + public static OutputAnalyzer runWithCMSClassUnloading() throws Exception { + return run(true); + } + + public static OutputAnalyzer runWithoutCMSClassUnloading() throws Exception { + return run(false); + } + + public static void testWithoutCMSClassUnloading() throws Exception { + // -XX:-CMSClassUnloadingEnabled is used, so we expect a full GC instead of a concurrent cycle. + OutputAnalyzer out = runWithoutCMSClassUnloading(); + + out.shouldMatch(".*Full GC.*"); + out.shouldNotMatch(".*CMS Initial Mark.*"); + } + + public static void testWithCMSClassUnloading() throws Exception { + // -XX:+CMSClassUnloadingEnabled is used, so we expect a concurrent cycle instead of a full GC. + OutputAnalyzer out = runWithCMSClassUnloading(); + + out.shouldMatch(".*CMS Initial Mark.*"); + out.shouldNotMatch(".*Full GC.*"); + } + + public static void main(String args[]) throws Exception { + testWithCMSClassUnloading(); + testWithoutCMSClassUnloading(); + } +} + diff --git a/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java b/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java new file mode 100644 index 00000000000..66142a1db3f --- /dev/null +++ b/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key gc + * @bug 8049831 + * @library /testlibrary /testlibrary/whitebox + * @build TestG1ClassUnloadingHWM AllocateBeyondMetaspaceSize + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver TestG1ClassUnloadingHWM + * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +import java.util.ArrayList; +import java.util.Arrays; + +public class TestG1ClassUnloadingHWM { + private static long MetaspaceSize = 32 * 1024 * 1024; + private static long YoungGenSize = 32 * 1024 * 1024; + + private static OutputAnalyzer run(boolean enableUnloading) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+WhiteBoxAPI", + "-XX:MetaspaceSize=" + MetaspaceSize, + "-Xmn" + YoungGenSize, + "-XX:+UseG1GC", + "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark", + "-XX:+PrintHeapAtGC", + "-XX:+PrintGCDetails", + "AllocateBeyondMetaspaceSize", + "" + MetaspaceSize, + "" + YoungGenSize); + return new OutputAnalyzer(pb.start()); + } + + public static OutputAnalyzer runWithG1ClassUnloading() throws Exception { + return run(true); + } + + public static OutputAnalyzer runWithoutG1ClassUnloading() throws Exception { + return run(false); + } + + public static void testWithoutG1ClassUnloading() throws Exception { + // -XX:-ClassUnloadingWithConcurrentMark is used, so we expect a full GC instead of a concurrent cycle. + OutputAnalyzer out = runWithoutG1ClassUnloading(); + + out.shouldMatch(".*Full GC.*"); + out.shouldNotMatch(".*initial-mark.*"); + } + + public static void testWithG1ClassUnloading() throws Exception { + // -XX:+ClassUnloadingWithConcurrentMark is used, so we expect a concurrent cycle instead of a full GC. + OutputAnalyzer out = runWithG1ClassUnloading(); + + out.shouldMatch(".*initial-mark.*"); + out.shouldNotMatch(".*Full GC.*"); + } + + public static void main(String args[]) throws Exception { + testWithG1ClassUnloading(); + testWithoutG1ClassUnloading(); + } +} + diff --git a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions2.java b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions2.java new file mode 100644 index 00000000000..147dc48ef7b --- /dev/null +++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions2.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 TestEagerReclaimHumongousRegions2 + * @bug 8051973 + * @summary Test to make sure that eager reclaim of humongous objects correctly clears + * mark bitmaps at reclaim. + * @key gc + * @library /testlibrary + */ + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.Random; + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +// An object that has a few references to other instances to slow down marking. +class ObjectWithSomeRefs { + public ObjectWithSomeRefs other1; + public ObjectWithSomeRefs other2; + public ObjectWithSomeRefs other3; + public ObjectWithSomeRefs other4; +} + +class ReclaimRegionFast { + public static final int M = 1024*1024; + + public static LinkedList garbageList = new LinkedList(); + + public static void genGarbage(Object large) { + for (int i = 0; i < 64*1024; i++) { + Object[] garbage = new Object[50]; + garbage[0] = large; + garbageList.add(garbage); + } + garbageList.clear(); + } + + public static ArrayList longList = new ArrayList(); + + public static void main(String[] args) { + + for (int i = 0; i < 16*1024; i++) { + longList.add(new ObjectWithSomeRefs()); + } + + Random rnd = new Random(); + for (int i = 0; i < longList.size(); i++) { + int len = longList.size(); + longList.get(i).other1 = longList.get(rnd.nextInt(len)); + longList.get(i).other2 = longList.get(rnd.nextInt(len)); + longList.get(i).other3 = longList.get(rnd.nextInt(len)); + longList.get(i).other4 = longList.get(rnd.nextInt(len)); + } + + int[] large1 = new int[M]; + int[] large2 = null; + int[] large3 = null; + int[] large4 = null; + + Object ref_from_stack = large1; + + for (int i = 0; i < 20; i++) { + // A set of large objects that will be reclaimed eagerly - and hopefully marked. + large1 = new int[M - 20]; + large2 = new int[M - 20]; + large3 = new int[M - 20]; + large4 = new int[M - 20]; + genGarbage(large1); + // Make sure that the compiler cannot completely remove + // the allocation of the large object until here. + System.out.println(large1 + " " + large2 + " " + large3 + " " + large4); + } + + // Keep the reference to the first object alive. + System.out.println(ref_from_stack); + } +} + +public class TestEagerReclaimHumongousRegions2 { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UseG1GC", + "-Xms128M", + "-Xmx128M", + "-Xmn2M", + "-XX:G1HeapRegionSize=1M", + "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks. + "-XX:+PrintGC", + "-XX:+VerifyAfterGC", + "-XX:ConcGCThreads=1", // Want to make marking as slow as possible. + "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only. + "-XX:+G1VerifyBitmaps", + ReclaimRegionFast.class.getName()); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + } +} + diff --git a/hotspot/test/runtime/6626217/Test6626217.sh b/hotspot/test/runtime/6626217/Test6626217.sh index 99ee83a06ec..a697191293a 100644 --- a/hotspot/test/runtime/6626217/Test6626217.sh +++ b/hotspot/test/runtime/6626217/Test6626217.sh @@ -69,7 +69,7 @@ ${MV} many_loader.class many_loader.impl2 ${MV} many_loader.impl1 many_loader.class ${RM} many_loader.java -${JAVA} ${TESTVMOPTS} -Xverify -Xint -cp . bug_21227 >test.out 2>&1 +${JAVA} ${TESTOPTS} -Xverify -Xint -cp . bug_21227 >test.out 2>&1 grep "loader constraint" test.out exit $? diff --git a/hotspot/test/runtime/6888954/vmerrors.sh b/hotspot/test/runtime/6888954/vmerrors.sh index 0fdd4ca0be4..28f6eea0fec 100644 --- a/hotspot/test/runtime/6888954/vmerrors.sh +++ b/hotspot/test/runtime/6888954/vmerrors.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,16 @@ # export TESTJAVA TESTVMOPTS # sh test/runtime/6888954/vmerrors.sh +if [ "${TESTSRC}" = "" ] +then + TESTSRC=${PWD} + echo "TESTSRC not set. Using "${TESTSRC}" as default" +fi +echo "TESTSRC=${TESTSRC}" + +## Adding common setup Variables for running shell tests. +. ${TESTSRC}/../../test_env.sh + ulimit -c 0 # no core files i=1 @@ -84,7 +94,7 @@ do i2=$i [ $i -lt 10 ] && i2=0$i - "$TESTJAVA/bin/java" $TESTVMOPTS -XX:+IgnoreUnrecognizedVMOptions \ + "$TESTJAVA/bin/java" $TESTOPTS -XX:+IgnoreUnrecognizedVMOptions \ -XX:-TransmitErrorReport -XX:-CreateMinidumpOnCrash \ -XX:ErrorHandlerTest=${i} -version > ${i2}.out 2>&1 diff --git a/hotspot/test/runtime/7162488/Test7162488.sh b/hotspot/test/runtime/7162488/Test7162488.sh index fa47ad94746..b87d92b8d0c 100644 --- a/hotspot/test/runtime/7162488/Test7162488.sh +++ b/hotspot/test/runtime/7162488/Test7162488.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -45,14 +45,14 @@ JAVA=${TESTJAVA}${FS}bin${FS}java # OPTION=this_is_not_an_option -${JAVA} ${TESTVMOPTS} -showversion -XX:${OPTION} 2>&1 | grep "Unrecognized VM option" +${JAVA} -showversion -XX:${OPTION} 2>&1 | grep "Unrecognized VM option" if [ "$?" != "0" ] then printf "FAILED: option not flagged as unrecognized.\n" exit 1 fi -${JAVA} ${TESTVMOPTS} -showversion -XX:${OPTION} 2>&1 | grep ${OPTION} +${JAVA} -showversion -XX:${OPTION} 2>&1 | grep ${OPTION} if [ "$?" != "0" ] then printf "FAILED: bad option not named as being bad.\n" diff --git a/hotspot/test/runtime/NMT/BaselineWithParameter.java b/hotspot/test/runtime/NMT/BaselineWithParameter.java index ff10b28a060..ef34a11a416 100644 --- a/hotspot/test/runtime/NMT/BaselineWithParameter.java +++ b/hotspot/test/runtime/NMT/BaselineWithParameter.java @@ -27,6 +27,7 @@ * @key nmt jcmd regression * @summary Regression test for invoking a jcmd with baseline=false, result was that the target VM crashed * @library /testlibrary + * @ignore * @run main/othervm -XX:NativeMemoryTracking=detail BaselineWithParameter */ diff --git a/hotspot/test/runtime/NMT/CommandLineDetail.java b/hotspot/test/runtime/NMT/CommandLineDetail.java index 01b0d0d3fae..b3ff104207f 100644 --- a/hotspot/test/runtime/NMT/CommandLineDetail.java +++ b/hotspot/test/runtime/NMT/CommandLineDetail.java @@ -26,6 +26,7 @@ * @key nmt * @summary Running with NMT detail should not result in an error * @library /testlibrary + * @ignore */ import com.oracle.java.testlibrary.*; diff --git a/hotspot/test/runtime/NMT/CommandLineEmptyArgument.java b/hotspot/test/runtime/NMT/CommandLineEmptyArgument.java index 956cdd26006..1c05a195d44 100644 --- a/hotspot/test/runtime/NMT/CommandLineEmptyArgument.java +++ b/hotspot/test/runtime/NMT/CommandLineEmptyArgument.java @@ -26,6 +26,7 @@ * @key nmt * @summary Empty argument to NMT should result in an informative error message * @library /testlibrary + * @ignore */ import com.oracle.java.testlibrary.*; diff --git a/hotspot/test/runtime/NMT/CommandLineInvalidArgument.java b/hotspot/test/runtime/NMT/CommandLineInvalidArgument.java index 79cc2de9442..6cc45102397 100644 --- a/hotspot/test/runtime/NMT/CommandLineInvalidArgument.java +++ b/hotspot/test/runtime/NMT/CommandLineInvalidArgument.java @@ -26,6 +26,7 @@ * @key nmt * @summary Invalid argument to NMT should result in an informative error message * @library /testlibrary + * @ignore */ import com.oracle.java.testlibrary.*; diff --git a/hotspot/test/runtime/NMT/CommandLineSummary.java b/hotspot/test/runtime/NMT/CommandLineSummary.java index d07bc7eae63..bef1ab9cb38 100644 --- a/hotspot/test/runtime/NMT/CommandLineSummary.java +++ b/hotspot/test/runtime/NMT/CommandLineSummary.java @@ -26,6 +26,7 @@ * @key nmt * @summary Running with NMT summary should not result in an error * @library /testlibrary + * @ignore */ import com.oracle.java.testlibrary.*; diff --git a/hotspot/test/runtime/NMT/CommandLineTurnOffNMT.java b/hotspot/test/runtime/NMT/CommandLineTurnOffNMT.java index 4193c9775d4..a33e2ca4aa3 100644 --- a/hotspot/test/runtime/NMT/CommandLineTurnOffNMT.java +++ b/hotspot/test/runtime/NMT/CommandLineTurnOffNMT.java @@ -26,6 +26,7 @@ * @key nmt * @summary Turning off NMT should not result in an error * @library /testlibrary + * @ignore */ import com.oracle.java.testlibrary.*; diff --git a/hotspot/test/runtime/NMT/JcmdScale.java b/hotspot/test/runtime/NMT/JcmdScale.java index e57d27b59a3..42b7393df62 100644 --- a/hotspot/test/runtime/NMT/JcmdScale.java +++ b/hotspot/test/runtime/NMT/JcmdScale.java @@ -26,6 +26,7 @@ * @key nmt jcmd * @summary Test the NMT scale parameter * @library /testlibrary + * @ignore * @run main/othervm -XX:NativeMemoryTracking=summary JcmdScale */ @@ -41,15 +42,15 @@ public class JcmdScale { pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"}); output = new OutputAnalyzer(pb.start()); - output.shouldContain("KB, committed="); + output.shouldContain("KB, committed="); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=MB"}); output = new OutputAnalyzer(pb.start()); - output.shouldContain("MB, committed="); + output.shouldContain("MB, committed="); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=GB"}); output = new OutputAnalyzer(pb.start()); - output.shouldContain("GB, committed="); + output.shouldContain("GB, committed="); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=apa"}); output = new OutputAnalyzer(pb.start()); @@ -57,7 +58,7 @@ public class JcmdScale { pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB"}); output = new OutputAnalyzer(pb.start()); - output.shouldContain("GB, committed="); + output.shouldContain("GB, committed="); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=apa"}); output = new OutputAnalyzer(pb.start()); diff --git a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java index 9ef37434937..086038eb233 100644 --- a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java +++ b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java @@ -26,6 +26,7 @@ * @key nmt jcmd * @summary Verify that jcmd correctly reports that NMT is not enabled * @library /testlibrary + * @ignore * @run main JcmdWithNMTDisabled 1 */ diff --git a/hotspot/test/runtime/NMT/MallocTestType.java b/hotspot/test/runtime/NMT/MallocTestType.java index 8a39af790e4..444dfda646f 100644 --- a/hotspot/test/runtime/NMT/MallocTestType.java +++ b/hotspot/test/runtime/NMT/MallocTestType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @key nmt jcmd * @library /testlibrary /testlibrary/whitebox * @build MallocTestType + * @ignore * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType */ @@ -51,11 +52,6 @@ public class MallocTestType { long memAlloc1 = wb.NMTMalloc(512 * 1024); wb.NMTFree(memAlloc2); - // Use WB API to ensure that all data has been merged before we continue - if (!wb.NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); - } - // Run 'jcmd VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); @@ -64,10 +60,6 @@ public class MallocTestType { // Free the memory allocated by NMTAllocTest wb.NMTFree(memAlloc1); - // Use WB API to ensure that all data has been merged before we continue - if (!wb.NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); - } output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } diff --git a/hotspot/test/runtime/NMT/PrintNMTStatistics.java b/hotspot/test/runtime/NMT/PrintNMTStatistics.java index 534fe7ae421..a09007b366d 100644 --- a/hotspot/test/runtime/NMT/PrintNMTStatistics.java +++ b/hotspot/test/runtime/NMT/PrintNMTStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ * @summary Make sure PrintNMTStatistics works on normal JVM exit * @library /testlibrary /testlibrary/whitebox * @build PrintNMTStatistics + * @ignore * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main PrintNMTStatistics */ @@ -45,10 +46,6 @@ public class PrintNMTStatistics { // We start a new java process running with an argument and use WB API to ensure // we have data for NMT on VM exit if (args.length > 0) { - // Use WB API to ensure that all data has been merged before we continue - if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); - } return; } diff --git a/hotspot/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java b/hotspot/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java index 1c25f284d4b..cdc3ded942a 100644 --- a/hotspot/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java +++ b/hotspot/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java @@ -26,6 +26,7 @@ * @key nmt * @summary Trying to enable PrintNMTStatistics should result in a warning * @library /testlibrary + * @ignore */ import com.oracle.java.testlibrary.*; diff --git a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java index 66bc3b18969..1f8592a3605 100644 --- a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java +++ b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ * @key nmt regression * @library /testlibrary /testlibrary/whitebox * @build ReleaseCommittedMemory + * @ignore * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ReleaseCommittedMemory */ @@ -44,7 +45,6 @@ public class ReleaseCommittedMemory { addr = wb.NMTReserveMemory(reserveSize); wb.NMTCommitMemory(addr, 128*1024); wb.NMTReleaseMemory(addr, reserveSize); - wb.NMTWaitForDataMerge(); } } diff --git a/hotspot/test/runtime/NMT/ShutdownTwice.java b/hotspot/test/runtime/NMT/ShutdownTwice.java index 1bb327aedb1..d6dcf8013e9 100644 --- a/hotspot/test/runtime/NMT/ShutdownTwice.java +++ b/hotspot/test/runtime/NMT/ShutdownTwice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @key nmt jcmd * @summary Run shutdown twice * @library /testlibrary + * @ignore * @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice */ @@ -45,12 +46,12 @@ public class ShutdownTwice { output = new OutputAnalyzer(pb.start()); // Verify that jcmd reports that NMT is shutting down - output.shouldContain("Shutdown is in progress, it will take a few moments to completely shutdown"); + output.shouldContain("Native memory tracking has been turned off"); // Run shutdown again output = new OutputAnalyzer(pb.start()); // Verify that jcmd reports that NMT has been shutdown already - output.shouldContain("Native memory tracking has been shutdown by user"); + output.shouldContain("Native memory tracking has been shutdown"); } } diff --git a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java index 96061f3f004..1baa484aa25 100644 --- a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java +++ b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @key nmt jcmd * @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown * @library /testlibrary + * @ignore * @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown */ @@ -44,13 +45,13 @@ public class SummaryAfterShutdown { output = new OutputAnalyzer(pb.start()); // Verify that jcmd reports that NMT is shutting down - output.shouldContain("Shutdown is in progress, it will take a few moments to completely shutdown"); + output.shouldContain("Native memory tracking has been turned off"); // Run 'jcmd VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); // Verify that jcmd reports that NMT has been shutdown - output.shouldContain("Native memory tracking has been shutdown by user"); + output.shouldContain("Native memory tracking has been shutdown"); } } diff --git a/hotspot/test/runtime/NMT/SummarySanityCheck.java b/hotspot/test/runtime/NMT/SummarySanityCheck.java index 221ad9365e5..1f37e470749 100644 --- a/hotspot/test/runtime/NMT/SummarySanityCheck.java +++ b/hotspot/test/runtime/NMT/SummarySanityCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @summary Sanity check the output of NMT * @library /testlibrary /testlibrary/whitebox * @build SummarySanityCheck + * @ignore * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck */ @@ -44,11 +45,6 @@ public class SummarySanityCheck { // Grab my own PID String pid = Integer.toString(ProcessTools.getProcessId()); - // Use WB API to ensure that all data has been merged before we continue - if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); - } - ProcessBuilder pb = new ProcessBuilder(); // Run 'jcmd VM.native_memory summary scale=KB' @@ -69,13 +65,13 @@ public class SummarySanityCheck { // Match '- (reserved=KB, committed=KB) Pattern mtTypePattern = Pattern.compile("-\\s+(?[\\w\\s]+)\\(reserved=(?\\d+)KB,\\scommitted=(?\\d+)KB\\)"); // Match 'Total: reserved=KB, committed=KB' - Pattern totalMemoryPattern = Pattern.compile("Total\\:\\s\\sreserved=(?\\d+)KB,\\s\\scommitted=(?\\d+)KB"); + Pattern totalMemoryPattern = Pattern.compile("Total\\:\\sreserved=(?\\d+)KB,\\scommitted=(?\\d+)KB"); for (int i = 0; i < lines.length; i++) { if (lines[i].startsWith("Total")) { Matcher totalMemoryMatcher = totalMemoryPattern.matcher(lines[i]); - if (totalMemoryMatcher.matches() && totalMemoryMatcher.groupCount() == 2) { + if (totalMemoryMatcher.matches()) { totalCommitted = Integer.parseInt(totalMemoryMatcher.group("committed")); totalReserved = Integer.parseInt(totalMemoryMatcher.group("reserved")); } else { diff --git a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java index eadb719d50d..82d98c523b3 100644 --- a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java +++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @key nmt jcmd * @library /testlibrary /testlibrary/whitebox * @build ThreadedMallocTestType + * @ignore * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedMallocTestType */ @@ -58,11 +59,6 @@ public class ThreadedMallocTestType { allocThread.start(); allocThread.join(); - // Use WB API to ensure that all data has been merged before we continue - if (!wb.NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); - } - // Run 'jcmd VM.native_memory summary' pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); output = new OutputAnalyzer(pb.start()); @@ -80,11 +76,6 @@ public class ThreadedMallocTestType { freeThread.start(); freeThread.join(); - // Use WB API to ensure that all data has been merged before we continue - if (!wb.NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); - } - output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); } diff --git a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java index 1a7b929f0d6..3f9ab7ce98d 100644 --- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java +++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @key nmt jcmd * @library /testlibrary /testlibrary/whitebox * @build ThreadedVirtualAllocTestType + * @ignore * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType */ @@ -60,8 +61,6 @@ public class ThreadedVirtualAllocTestType { reserveThread.start(); reserveThread.join(); - mergeData(); - pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=0KB)"); @@ -77,8 +76,6 @@ public class ThreadedVirtualAllocTestType { commitThread.start(); commitThread.join(); - mergeData(); - output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=128KB)"); if (has_nmt_detail) { @@ -93,8 +90,6 @@ public class ThreadedVirtualAllocTestType { uncommitThread.start(); uncommitThread.join(); - mergeData(); - output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=512KB, committed=0KB)"); output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed"); @@ -107,17 +102,9 @@ public class ThreadedVirtualAllocTestType { releaseThread.start(); releaseThread.join(); - mergeData(); - output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved"); } - public static void mergeData() throws Exception { - // Use WB API to ensure that all data has been merged before we continue - if (!wb.NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } - } -} diff --git a/hotspot/test/runtime/NMT/VirtualAllocTestType.java b/hotspot/test/runtime/NMT/VirtualAllocTestType.java index 86e751c6b31..f69f5ba6d9b 100644 --- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java +++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @summary Test Reserve/Commit/Uncommit/Release of virtual memory and that we track it correctly * @key nmt jcmd * @library /testlibrary /testlibrary/whitebox + * @ignore * @build VirtualAllocTestType * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocTestType @@ -54,7 +55,6 @@ public class VirtualAllocTestType { } addr = wb.NMTReserveMemory(reserveSize); - mergeData(); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); output = new OutputAnalyzer(pb.start()); @@ -65,7 +65,6 @@ public class VirtualAllocTestType { wb.NMTCommitMemory(addr, commitSize); - mergeData(); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=256KB, committed=128KB)"); @@ -75,24 +74,15 @@ public class VirtualAllocTestType { wb.NMTUncommitMemory(addr, commitSize); - mergeData(); output = new OutputAnalyzer(pb.start()); output.shouldContain("Test (reserved=256KB, committed=0KB)"); output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed"); wb.NMTReleaseMemory(addr, reserveSize); - mergeData(); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Test (reserved="); output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved"); } - - public static void mergeData() throws Exception { - // Use WB API to ensure that all data has been merged before we continue - if (!wb.NMTWaitForDataMerge()) { - throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); } - } -} diff --git a/hotspot/test/test_env.sh b/hotspot/test/test_env.sh index fa912dde237..e9fc3abb0ff 100644 --- a/hotspot/test/test_env.sh +++ b/hotspot/test/test_env.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -50,6 +50,9 @@ then fi echo "TESTCLASSES=${TESTCLASSES}" +TESTOPTS="${TESTVMOPTS} ${TESTJAVAOPTS}" +echo "TESTOPTS=${TESTOPTS}" + # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -101,14 +104,14 @@ THIS_DIR=. echo "THIS_DIR=${THIS_DIR}" # Check to ensure the java defined actually works -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version +${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -version if [ $? != 0 ]; then - echo "Wrong TESTJAVA or TESTVMOPTS:" - echo $TESTJAVA TESTVMOPTS + echo "Wrong TESTJAVA or TESTJAVAOPTS or TESTVMOPTS:" + echo ''$TESTJAVA'' ''$TESTJAVAOPTS'' ''$TESTVMOPTS'' exit 1 fi -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -Xinternalversion > vm_version.out 2>&1 VM_TYPE="unknown" grep "Server" vm_version.out > ${NULL} diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java index bb58361ffda..9bc28bf227f 100644 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java @@ -95,7 +95,8 @@ public class WhiteBox { public native void NMTCommitMemory(long addr, long size); public native void NMTUncommitMemory(long addr, long size); public native void NMTReleaseMemory(long addr, long size); - public native boolean NMTWaitForDataMerge(); + public native void NMTOverflowHashBucket(long num); + public native long NMTMallocWithPseudoStack(long size, int index); public native boolean NMTIsDetailSupported(); // Compiler diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 964da1c7094..63f10acd85e 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -266,3 +266,5 @@ f9c82769a6bc2b219a8f01c24afe5c91039267d7 jdk9-b19 7eb0ab676ea75cb1dd31c613e77008a7d8cb0af7 jdk9-b21 82b94ff002c6e007a03bf0f364ca94b381e09135 jdk9-b22 2e5b63006187bfc64d8eace374dbc2806267a160 jdk9-b23 +345af113f57206711f75089c3ebf84a36a789122 jdk9-b24 +73757f4b8aa353ca8937abc07e79e7ece4c011a1 jdk9-b25 diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java index 45b91dc9aa2..39b6929379b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -385,8 +386,18 @@ public class CoreDOMImplementationImpl * reference to the default error handler. */ public LSSerializer createLSSerializer() { - return new DOMSerializerImpl(); - } + try { + Class serializerClass = ObjectFactory.findProviderClass( + "com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl", + ObjectFactory.findClassLoader(), true); + return (LSSerializer) serializerClass.newInstance(); + } + catch (Exception e) {} + // Fall back to Xerces' deprecated serializer if + // the Xalan based serializer is unavailable. + return new DOMSerializerImpl(); + } + /** * DOM Level 3 LS CR - Experimental. * Create a new empty input source. diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java index 63123391ca3..23289a7b55f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java @@ -54,6 +54,7 @@ import com.sun.org.apache.xerces.internal.util.Status; import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.util.XMLSymbols; import com.sun.org.apache.xerces.internal.utils.SecuritySupport; +import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; import com.sun.org.apache.xerces.internal.xni.XNIException; import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; @@ -982,6 +983,18 @@ XSLoader, DOMConfiguration { */ public void reset(XMLComponentManager componentManager) throws XMLConfigurationException { + XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER); + if (spm == null) { + spm = new XMLSecurityPropertyManager(); + setProperty(XML_SECURITY_PROPERTY_MANAGER, spm); + } + + XMLSecurityManager sm = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER); + if (sm == null) + setProperty(SECURITY_MANAGER,new XMLSecurityManager(true)); + + faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA); + fGrammarBucket.reset(); fSubGroupHandler.reset(); @@ -1065,9 +1078,6 @@ XSLoader, DOMConfiguration { // get generate-synthetic-annotations feature fSchemaHandler.setGenerateSyntheticAnnotations(componentManager.getFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false)); fSchemaHandler.reset(componentManager); - - XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER); - faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA); } private void initGrammarBucket(){ diff --git a/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java b/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java index 526f5e1b5f0..ea0e9b7a9a4 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java @@ -3145,7 +3145,11 @@ public class SAX2DTM2 extends SAX2DTM m_data.elementAt(-dataIndex+1)); } } - else if (DTM.ELEMENT_NODE == type || DTM.DOCUMENT_FRAGMENT_NODE == type + else if (DTM.ELEMENT_NODE == type) + { + return getStringValueX(nodeHandle); + } + else if (DTM.DOCUMENT_FRAGMENT_NODE == type || DTM.DOCUMENT_NODE == type) { return null; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java index 3150b10d860..2c9a4988fca 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/BaseMarkupSerializer.java @@ -123,6 +123,11 @@ import org.xml.sax.ext.LexicalHandler; * @author Sunitha Reddy, Sun Microsystems * @see Serializer * @see org.w3c.dom.ls.LSSerializer + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public abstract class BaseMarkupSerializer implements ContentHandler, DocumentHandler, LexicalHandler, diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java index 40566616ed9..408b35cd9ba 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializer.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -35,6 +36,11 @@ import org.w3c.dom.DocumentFragment; * * @author Scott Boag * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public interface DOMSerializer { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java index eae65068d82..dc9378b39e5 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java @@ -72,6 +72,9 @@ import org.w3c.dom.ls.LSSerializerFilter; * @author Gopal Sharma, Sun Microsystems * @author Arun Yadav, Sun Microsystems * @author Sunitha Reddy, Sun Microsystems + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, replaced by + * {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl} */ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/ElementState.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/ElementState.java index d6b412e50fe..8b556f93431 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/ElementState.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/ElementState.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -28,9 +29,13 @@ import java.util.Hashtable; /** * Holds the state of the currently serialized element. * - * * @author Assaf Arkin * @see BaseMarkupSerializer + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class ElementState { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java index 252483fc53d..6756daf410b 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2000-2002,2004,2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -29,6 +30,10 @@ import com.sun.org.apache.xerces.internal.util.EncodingMap; /** * This class represents an encoding. * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class EncodingInfo { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Encodings.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Encodings.java index 711b217b87d..adc8c3c86ba 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Encodings.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Encodings.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -36,6 +37,11 @@ import com.sun.org.apache.xerces.internal.util.EncodingMap; * for each encoding. * * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class Encodings { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java index 17e3964bfa5..6b50dcd1567 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -45,8 +46,12 @@ import java.util.Locale; * from value to name. A small entities resource is loaded into memory the * first time any of these methods is called for fast and efficient access. * - * * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public final class HTMLdtd { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java index efc7af1248d..34e03138974 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/IndentPrinter.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -32,6 +33,11 @@ import java.io.IOException; * wrapping. * * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class IndentPrinter extends Printer diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/LineSeparator.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/LineSeparator.java index bb4b1b9ae18..1886ac44055 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/LineSeparator.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/LineSeparator.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -25,6 +26,11 @@ package com.sun.org.apache.xml.internal.serialize; /** * @author Assaf Arkin * @see OutputFormat + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public final class LineSeparator { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Method.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Method.java index c6cfff09d7d..99b97d0572a 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Method.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Method.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -25,6 +26,11 @@ package com.sun.org.apache.xml.internal.serialize; /** * @author Assaf Arkin * @see OutputFormat + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public final class Method { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/OutputFormat.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/OutputFormat.java index 505a8996df3..1d0db3fa57d 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/OutputFormat.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/OutputFormat.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -59,6 +60,11 @@ import org.w3c.dom.html.HTMLDocument; * @see Serializer * @see Method * @see LineSeparator + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class OutputFormat { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Printer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Printer.java index ab9d8e4a0e5..2e966809094 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Printer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Printer.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -40,6 +41,11 @@ import java.io.IOException; * extending this class. * * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class Printer { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Serializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Serializer.java index 5aecb4ffe43..3bb0fd6de90 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/Serializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/Serializer.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -60,6 +61,11 @@ import org.xml.sax.DocumentHandler; * @see ContentHandler * @see OutputFormat * @see DOMSerializer + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public interface Serializer { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java index 2150e31a0b5..d1af445b11d 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -34,6 +35,11 @@ import java.util.StringTokenizer; * * @author Scott Boag * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public abstract class SerializerFactory { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java index dd27e57ceec..8883a820dfb 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactoryImpl.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -34,6 +35,11 @@ import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter; * * @author Scott Boag * @author Assaf Arkin + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ final class SerializerFactoryImpl extends SerializerFactory diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/TextSerializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/TextSerializer.java index 789f6368cfd..09ceaf0f3f5 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/TextSerializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/TextSerializer.java @@ -3,11 +3,12 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -58,6 +59,11 @@ import org.xml.sax.SAXException; * * @author Assaf Arkin * @see Serializer + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class TextSerializer extends BaseMarkupSerializer diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java index ced3ef5c4d5..514e417acb3 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/XML11Serializer.java @@ -73,10 +73,16 @@ import org.xml.sax.SAXException; * boundaries, indent lines, and serialize elements on separate * lines. Line terminators will be regarded as spaces, and * spaces at beginning of line will be stripped. + * * @author Assaf Arkin * @author Rahul Srivastava * @author Elena Litani IBM * @see Serializer + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class XML11Serializer extends XMLSerializer { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java index 884fd4b5fe5..0c39d3eeaf8 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/XMLSerializer.java @@ -84,10 +84,16 @@ import org.xml.sax.helpers.AttributesImpl; * boundaries, indent lines, and serialize elements on separate * lines. Line terminators will be regarded as spaces, and * spaces at beginning of line will be stripped. + * * @author Assaf Arkin * @author Rahul Srivastava * @author Elena Litani IBM * @see Serializer + * + * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation + * is replaced by that of Xalan. Main class + * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced + * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}. */ public class XMLSerializer extends BaseMarkupSerializer { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/DOM3Serializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/DOM3Serializer.java new file mode 100644 index 00000000000..a31c68b9ec3 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/DOM3Serializer.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer; + +import java.io.IOException; + +import org.w3c.dom.Node; +import org.w3c.dom.DOMErrorHandler; +import org.w3c.dom.ls.LSSerializerFilter; + +/** + * Interface for a DOM serializer capable of serializing DOMs as specified in + * the DOM Level 3 Save Recommendation. + *

+ * The DOM3Serializer is a facet of a serializer and is obtained from the + * asDOM3Serializer() method of the org.apache.xml.serializer.Serializer interface. + * A serializer may or may not support a level 3 DOM serializer, if it does not then the + * return value from asDOM3Serializer() is null. + *

+ * Example: + *

+ * Document     doc;
+ * Serializer   ser;
+ * OutputStream os;
+ * DOMErrorHandler handler;
+ *
+ * ser = ...;
+ * os = ...;
+ * handler = ...;
+ *
+ * ser.setOutputStream( os );
+ * DOM3Serialzier dser = (DOM3Serialzier)ser.asDOM3Serializer();
+ * dser.setErrorHandler(handler);
+ * dser.serialize(doc);
+ * 
+ * + * @see org.apache.xml.serializer.Serializer + * + * @xsl.usage general + * + */ +public interface DOM3Serializer { + /** + * Serializes the Level 3 DOM node. Throws an exception only if an I/O + * exception occured while serializing. + * + * This interface is a public API. + * + * @param node the Level 3 DOM node to serialize + * @throws IOException if an I/O exception occured while serializing + */ + public void serializeDOM3(Node node) throws IOException; + + /** + * Sets a DOMErrorHandler on the DOM Level 3 Serializer. + * + * This interface is a public API. + * + * @param handler the Level 3 DOMErrorHandler + */ + public void setErrorHandler(DOMErrorHandler handler); + + /** + * Returns a DOMErrorHandler set on the DOM Level 3 Serializer. + * + * This interface is a public API. + * + * @return A Level 3 DOMErrorHandler + */ + public DOMErrorHandler getErrorHandler(); + + /** + * Sets a LSSerializerFilter on the DOM Level 3 Serializer to filter nodes + * during serialization. + * + * This interface is a public API. + * + * @param filter the Level 3 LSSerializerFilter + */ + public void setNodeFilter(LSSerializerFilter filter); + + /** + * Returns a LSSerializerFilter set on the DOM Level 3 Serializer to filter nodes + * during serialization. + * + * This interface is a public API. + * + * @return The Level 3 LSSerializerFilter + */ + public LSSerializerFilter getNodeFilter(); + + /** + * Sets the new line character to be used during serialization + * @param newLine a String that is the end-of-line character sequence to be + * used in serialization. + */ + public void setNewLine(String newLine); +} diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java index 09a13dace09..35952c88d0c 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/EmptySerializer.java @@ -786,4 +786,13 @@ public class EmptySerializer implements SerializationHandler aMethodIsCalled(); } + + /** + * @see org.apache.xml.serializer.Serializer#asDOM3Serializer() + */ + public Object asDOM3Serializer() throws IOException + { + couldThrowIOException(); + return null; + } } diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java index 80eb8a5d969..18e76134891 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java @@ -152,6 +152,24 @@ public final class Encodings extends Object return ei; } + /** + * Determines if the encoding specified was recognized by the + * serializer or not. + * + * @param encoding The encoding + * @return boolean - true if the encoding was recognized else false + */ + public static boolean isRecognizedEncoding(String encoding) + { + EncodingInfo ei; + + String normalizedEncoding = toUpperCaseFast(encoding); + ei = _encodingInfos.findEncoding(normalizedEncoding); + if (ei != null) + return true; + return false; + } + /** * A fast and cheap way to uppercase a String that is * only made of printable ASCII characters. diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java index 1e918553be7..93331efc589 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializationHandler.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2003-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -110,9 +112,29 @@ public interface SerializationHandler public void setNamespaceMappings(NamespaceMappings mappings); /** - * Flush any pending events currently queued up in the serializer. This will - * flush any input that the serializer has which it has not yet sent as - * output. + * A SerializationHandler accepts SAX-like events, so + * it can accumulate attributes or namespace nodes after + * a startElement(). + *

+ * If the SerializationHandler has a Writer or OutputStream, + * a call to this method will flush such accumulated + * events as a closed start tag for an element. + *

+ * If the SerializationHandler wraps a ContentHandler, + * a call to this method will flush such accumulated + * events as a SAX (not SAX-like) calls to + * startPrefixMapping() and startElement(). + *

+ * If one calls endDocument() then one need not call + * this method since a call to endDocument() will + * do what this method does. However, in some + * circumstances, such as with document fragments, + * endDocument() is not called and it may be + * necessary to call this method to flush + * any pending events. + *

+ * For performance reasons this method should not be called + * very often. */ public void flushPending() throws SAXException; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Serializer.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Serializer.java index 9cae2d22d0b..b855659a226 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Serializer.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Serializer.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -220,4 +222,20 @@ public interface Serializer { * @return True if serializer has been reset and can be reused */ public boolean reset(); + + /** + * Return an Object into this serializer to be cast to a DOM3Serializer. + * Through the returned object the document to be serialized, + * a DOM (Level 3), can be provided to the serializer. + * If the serializer does not support casting to a {@link DOM3Serializer} + * interface, it should return null. + *

+ * In principle only one of asDOM3Serializer() or asContentHander() + * should be called. + * + * @return An Object to be cast to a DOM3Serializer interface into this serializer, + * or null if the serializer is not DOM capable + * @throws IOException An I/O exception occured + */ + public Object asDOM3Serializer() throws IOException; } diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java index fb80d771f00..5d706e2f5ab 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerBase.java @@ -1558,6 +1558,21 @@ public abstract class SerializerBase return getProp(name,false); } + /** + * Return a {@link DOM3Serializer} interface into this serializer. If the + * serializer does not support the {@link DOM3Serializer} interface, it should + * return null. + * + * @return A {@link DOM3Serializer} interface into this serializer, or null + * if the serializer is not DOM capable + * @throws IOException An I/O exception occured + * @see org.apache.xml.serializer.Serializer#asDOM3Serializer() + */ + public Object asDOM3Serializer() throws IOException + { + return new com.sun.org.apache.xml.internal.serializer.dom3.DOM3SerializerImpl(this); + } + /** * Get the default value of an xsl:output property, * which would be null only if no default value exists diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java index 358c4f25bb6..d2c5f264b18 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/SerializerFactory.java @@ -136,7 +136,7 @@ public final class SerializerFactory if (obj instanceof SerializationHandler) { // this is one of the supplied serializers - ser = (Serializer) cls.newInstance(); + ser = (Serializer) obj; ser.setOutputFormat(format); } else diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToStream.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToStream.java index 2195e71f8b0..0e0efe7c2e2 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToStream.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToStream.java @@ -537,7 +537,7 @@ abstract public class ToStream extends SerializerBase if (OutputPropertiesFactory.S_KEY_INDENT_AMOUNT.equals(name)) { setIndentAmount(Integer.parseInt(val)); } else if (OutputKeys.INDENT.equals(name)) { - boolean b = "yes".equals(val) ? true : false; + boolean b = val.endsWith("yes") ? true : false; m_doIndent = b; } @@ -556,7 +556,7 @@ abstract public class ToStream extends SerializerBase break; case 'o': if (OutputKeys.OMIT_XML_DECLARATION.equals(name)) { - boolean b = "yes".equals(val) ? true : false; + boolean b = val.endsWith("yes") ? true : false; this.m_shouldNotWriteXMLHeader = b; } break; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java index a68382c4160..9583dd5d30f 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToUnknownStream.java @@ -1335,4 +1335,12 @@ public final class ToUnknownStream extends SerializerBase ch.length); } } + + /** + * @see org.apache.xml.serializer.Serializer#asDOM3Serializer() + */ + public Object asDOM3Serializer() throws IOException + { + return m_handler.asDOM3Serializer(); + } } diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOM3SerializerImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOM3SerializerImpl.java new file mode 100644 index 00000000000..0d4509c2a97 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOM3SerializerImpl.java @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import java.io.IOException; + +import com.sun.org.apache.xml.internal.serializer.DOM3Serializer; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; +import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException; +import org.w3c.dom.DOMErrorHandler; +import org.w3c.dom.Node; +import org.w3c.dom.ls.LSSerializerFilter; + +/** + * This class implements the DOM3Serializer interface. + * + * @xsl.usage internal + */ +public final class DOM3SerializerImpl implements DOM3Serializer { + + /** + * Private class members + */ + // The DOMErrorHandler + private DOMErrorHandler fErrorHandler; + + // A LSSerializerFilter + private LSSerializerFilter fSerializerFilter; + + // The end-of-line character sequence + private String fNewLine; + + // A SerializationHandler ex. an instance of ToXMLStream + private SerializationHandler fSerializationHandler; + + /** + * Constructor + * + * @param handler An instance of the SerializationHandler interface. + */ + public DOM3SerializerImpl(SerializationHandler handler) { + fSerializationHandler = handler; + } + + // Public memebers + + /** + * Returns a DOMErrorHandler set on the DOM Level 3 Serializer. + * + * This interface is a public API. + * + * @return A Level 3 DOMErrorHandler + */ + public DOMErrorHandler getErrorHandler() { + return fErrorHandler; + } + + /** + * Returns a LSSerializerFilter set on the DOM Level 3 Serializer to filter nodes + * during serialization. + * + * This interface is a public API. + * + * @return The Level 3 LSSerializerFilter + */ + public LSSerializerFilter getNodeFilter() { + return fSerializerFilter; + } + + + /** + * Serializes the Level 3 DOM node by creating an instance of DOM3TreeWalker + * which traverses the DOM tree and invokes handler events to serialize + * the DOM NOde. Throws an exception only if an I/O exception occured + * while serializing. + * This interface is a public API. + * + * @param node the Level 3 DOM node to serialize + * @throws IOException if an I/O exception occured while serializing + */ + public void serializeDOM3(Node node) throws IOException { + try { + DOM3TreeWalker walker = new DOM3TreeWalker(fSerializationHandler, + fErrorHandler, fSerializerFilter, fNewLine); + + walker.traverse(node); + } catch (org.xml.sax.SAXException se) { + throw new WrappedRuntimeException(se); + } + } + + /** + * Sets a DOMErrorHandler on the DOM Level 3 Serializer. + * + * This interface is a public API. + * + * @param handler the Level 3 DOMErrorHandler + */ + public void setErrorHandler(DOMErrorHandler handler) { + fErrorHandler = handler; + } + + /** + * Sets a LSSerializerFilter on the DOM Level 3 Serializer to filter nodes + * during serialization. + * + * This interface is a public API. + * + * @param filter the Level 3 LSSerializerFilter + */ + public void setNodeFilter(LSSerializerFilter filter) { + fSerializerFilter = filter; + } + + /** + * Sets a SerializationHandler on the DOM Serializer. + * + * This interface is a public API. + * + * @param handler An instance of SerializationHandler + */ + public void setSerializationHandler(SerializationHandler handler) { + fSerializationHandler = handler; + } + + /** + * Sets the new line character to be used during serialization + * @param newLine a String that is the end-of-line character sequence to be + * used in serialization. + */ + public void setNewLine(String newLine) { + fNewLine = newLine; + } +} diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOM3TreeWalker.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOM3TreeWalker.java new file mode 100644 index 00000000000..b83d2ebde50 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOM3TreeWalker.java @@ -0,0 +1,2145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Properties; + +import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; +import com.sun.org.apache.xml.internal.serializer.SerializationHandler; +import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; +import com.sun.org.apache.xml.internal.serializer.utils.Utils; +import com.sun.org.apache.xerces.internal.util.XML11Char; +import com.sun.org.apache.xerces.internal.util.XMLChar; +import org.w3c.dom.Attr; +import org.w3c.dom.CDATASection; +import org.w3c.dom.Comment; +import org.w3c.dom.DOMError; +import org.w3c.dom.DOMErrorHandler; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; +import org.w3c.dom.Entity; +import org.w3c.dom.EntityReference; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.ProcessingInstruction; +import org.w3c.dom.Text; +import org.w3c.dom.ls.LSSerializerFilter; +import org.w3c.dom.traversal.NodeFilter; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.ext.LexicalHandler; +import org.xml.sax.helpers.LocatorImpl; + +/** + * Built on org.apache.xml.serializer.TreeWalker and adds functionality to + * traverse and serialize a DOM Node (Level 2 or Level 3) as specified in + * the DOM Level 3 LS Recommedation by evaluating and applying DOMConfiguration + * parameters and filters if any during serialization. + * + * @xsl.usage internal + */ +final class DOM3TreeWalker { + + /** + * The SerializationHandler, it extends ContentHandler and when + * this class is instantiated via the constructor provided, a + * SerializationHandler object is passed to it. + */ + private SerializationHandler fSerializer = null; + + /** We do not need DOM2Helper since DOM Level 3 LS applies to DOM Level 2 or newer */ + + /** Locator object for this TreeWalker */ + private LocatorImpl fLocator = new LocatorImpl(); + + /** ErrorHandler */ + private DOMErrorHandler fErrorHandler = null; + + /** LSSerializerFilter */ + private LSSerializerFilter fFilter = null; + + /** If the serializer is an instance of a LexicalHandler */ + private LexicalHandler fLexicalHandler = null; + + private int fWhatToShowFilter; + + /** New Line character to use in serialization */ + private String fNewLine = null; + + /** DOMConfiguration Properties */ + private Properties fDOMConfigProperties = null; + + /** Keeps track if we are in an entity reference when entities=true */ + private boolean fInEntityRef = false; + + /** Stores the version of the XML document to be serialize */ + private String fXMLVersion = null; + + /** XML Version, default 1.0 */ + private boolean fIsXMLVersion11 = false; + + /** Is the Node a Level 3 DOM node */ + private boolean fIsLevel3DOM = false; + + /** DOM Configuration Parameters */ + private int fFeatures = 0; + + /** Flag indicating whether following text to be processed is raw text */ + boolean fNextIsRaw = false; + + // + private static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; + + // + private static final String XMLNS_PREFIX = "xmlns"; + + // + private static final String XML_URI = "http://www.w3.org/XML/1998/namespace"; + + // + private static final String XML_PREFIX = "xml"; + + /** stores namespaces in scope */ + protected NamespaceSupport fNSBinder; + + /** stores all namespace bindings on the current element */ + protected NamespaceSupport fLocalNSBinder; + + /** stores the current element depth */ + private int fElementDepth = 0; + + // *********************************************************************** + // DOMConfiguration paramter settings + // *********************************************************************** + // Parameter canonical-form, true [optional] - NOT SUPPORTED + private final static int CANONICAL = 0x1 << 0; + + // Parameter cdata-sections, true [required] (default) + private final static int CDATA = 0x1 << 1; + + // Parameter check-character-normalization, true [optional] - NOT SUPPORTED + private final static int CHARNORMALIZE = 0x1 << 2; + + // Parameter comments, true [required] (default) + private final static int COMMENTS = 0x1 << 3; + + // Parameter datatype-normalization, true [optional] - NOT SUPPORTED + private final static int DTNORMALIZE = 0x1 << 4; + + // Parameter element-content-whitespace, true [required] (default) - value - false [optional] NOT SUPPORTED + private final static int ELEM_CONTENT_WHITESPACE = 0x1 << 5; + + // Parameter entities, true [required] (default) + private final static int ENTITIES = 0x1 << 6; + + // Parameter infoset, true [required] (default), false has no effect --> True has no effect for the serializer + private final static int INFOSET = 0x1 << 7; + + // Parameter namespaces, true [required] (default) + private final static int NAMESPACES = 0x1 << 8; + + // Parameter namespace-declarations, true [required] (default) + private final static int NAMESPACEDECLS = 0x1 << 9; + + // Parameter normalize-characters, true [optional] - NOT SUPPORTED + private final static int NORMALIZECHARS = 0x1 << 10; + + // Parameter split-cdata-sections, true [required] (default) + private final static int SPLITCDATA = 0x1 << 11; + + // Parameter validate, true [optional] - NOT SUPPORTED + private final static int VALIDATE = 0x1 << 12; + + // Parameter validate-if-schema, true [optional] - NOT SUPPORTED + private final static int SCHEMAVALIDATE = 0x1 << 13; + + // Parameter split-cdata-sections, true [required] (default) + private final static int WELLFORMED = 0x1 << 14; + + // Parameter discard-default-content, true [required] (default) + // Not sure how this will be used in level 2 Documents + private final static int DISCARDDEFAULT = 0x1 << 15; + + // Parameter format-pretty-print, true [optional] + private final static int PRETTY_PRINT = 0x1 << 16; + + // Parameter ignore-unknown-character-denormalizations, true [required] (default) + // We currently do not support XML 1.1 character normalization + private final static int IGNORE_CHAR_DENORMALIZE = 0x1 << 17; + + // Parameter discard-default-content, true [required] (default) + private final static int XMLDECL = 0x1 << 18; + + /** + * Constructor. + * @param contentHandler serialHandler The implemention of the SerializationHandler interface + */ + DOM3TreeWalker( + SerializationHandler serialHandler, + DOMErrorHandler errHandler, + LSSerializerFilter filter, + String newLine) { + fSerializer = serialHandler; + //fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default? + fErrorHandler = errHandler; + fFilter = filter; + fLexicalHandler = null; + fNewLine = newLine; + + fNSBinder = new NamespaceSupport(); + fLocalNSBinder = new NamespaceSupport(); + + fDOMConfigProperties = fSerializer.getOutputFormat(); + fSerializer.setDocumentLocator(fLocator); + initProperties(fDOMConfigProperties); + + try { + // Bug see Bugzilla 26741 + fLocator.setSystemId( + System.getProperty("user.dir") + File.separator + "dummy.xsl"); + } catch (SecurityException se) { // user.dir not accessible from applet + + } + } + + /** + * Perform a pre-order traversal non-recursive style. + * + * Note that TreeWalker assumes that the subtree is intended to represent + * a complete (though not necessarily well-formed) document and, during a + * traversal, startDocument and endDocument will always be issued to the + * SAX listener. + * + * @param pos Node in the tree where to start traversal + * + * @throws TransformerException + */ + public void traverse(Node pos) throws org.xml.sax.SAXException { + this.fSerializer.startDocument(); + + // Determine if the Node is a DOM Level 3 Core Node. + if (pos.getNodeType() != Node.DOCUMENT_NODE) { + Document ownerDoc = pos.getOwnerDocument(); + if (ownerDoc != null + && ownerDoc.getImplementation().hasFeature("Core", "3.0")) { + fIsLevel3DOM = true; + } + } else { + if (((Document) pos) + .getImplementation() + .hasFeature("Core", "3.0")) { + fIsLevel3DOM = true; + } + } + + if (fSerializer instanceof LexicalHandler) { + fLexicalHandler = ((LexicalHandler) this.fSerializer); + } + + if (fFilter != null) + fWhatToShowFilter = fFilter.getWhatToShow(); + + Node top = pos; + + while (null != pos) { + startNode(pos); + + Node nextNode = null; + + nextNode = pos.getFirstChild(); + + while (null == nextNode) { + endNode(pos); + + if (top.equals(pos)) + break; + + nextNode = pos.getNextSibling(); + + if (null == nextNode) { + pos = pos.getParentNode(); + + if ((null == pos) || (top.equals(pos))) { + if (null != pos) + endNode(pos); + + nextNode = null; + + break; + } + } + } + + pos = nextNode; + } + this.fSerializer.endDocument(); + } + + /** + * Perform a pre-order traversal non-recursive style. + + * Note that TreeWalker assumes that the subtree is intended to represent + * a complete (though not necessarily well-formed) document and, during a + * traversal, startDocument and endDocument will always be issued to the + * SAX listener. + * + * @param pos Node in the tree where to start traversal + * @param top Node in the tree where to end traversal + * + * @throws TransformerException + */ + public void traverse(Node pos, Node top) throws org.xml.sax.SAXException { + + this.fSerializer.startDocument(); + + // Determine if the Node is a DOM Level 3 Core Node. + if (pos.getNodeType() != Node.DOCUMENT_NODE) { + Document ownerDoc = pos.getOwnerDocument(); + if (ownerDoc != null + && ownerDoc.getImplementation().hasFeature("Core", "3.0")) { + fIsLevel3DOM = true; + } + } else { + if (((Document) pos) + .getImplementation() + .hasFeature("Core", "3.0")) { + fIsLevel3DOM = true; + } + } + + if (fSerializer instanceof LexicalHandler) { + fLexicalHandler = ((LexicalHandler) this.fSerializer); + } + + if (fFilter != null) + fWhatToShowFilter = fFilter.getWhatToShow(); + + while (null != pos) { + startNode(pos); + + Node nextNode = null; + + nextNode = pos.getFirstChild(); + + while (null == nextNode) { + endNode(pos); + + if ((null != top) && top.equals(pos)) + break; + + nextNode = pos.getNextSibling(); + + if (null == nextNode) { + pos = pos.getParentNode(); + + if ((null == pos) || ((null != top) && top.equals(pos))) { + nextNode = null; + + break; + } + } + } + + pos = nextNode; + } + this.fSerializer.endDocument(); + } + + /** + * Optimized dispatch of characters. + */ + private final void dispatachChars(Node node) + throws org.xml.sax.SAXException { + if (fSerializer != null) { + this.fSerializer.characters(node); + } else { + String data = ((Text) node).getData(); + this.fSerializer.characters(data.toCharArray(), 0, data.length()); + } + } + + /** + * Start processing given node + * + * @param node Node to process + * + * @throws org.xml.sax.SAXException + */ + protected void startNode(Node node) throws org.xml.sax.SAXException { + if (node instanceof Locator) { + Locator loc = (Locator) node; + fLocator.setColumnNumber(loc.getColumnNumber()); + fLocator.setLineNumber(loc.getLineNumber()); + fLocator.setPublicId(loc.getPublicId()); + fLocator.setSystemId(loc.getSystemId()); + } else { + fLocator.setColumnNumber(0); + fLocator.setLineNumber(0); + } + + switch (node.getNodeType()) { + case Node.DOCUMENT_TYPE_NODE : + serializeDocType((DocumentType) node, true); + break; + case Node.COMMENT_NODE : + serializeComment((Comment) node); + break; + case Node.DOCUMENT_FRAGMENT_NODE : + // Children are traversed + break; + case Node.DOCUMENT_NODE : + break; + case Node.ELEMENT_NODE : + serializeElement((Element) node, true); + break; + case Node.PROCESSING_INSTRUCTION_NODE : + serializePI((ProcessingInstruction) node); + break; + case Node.CDATA_SECTION_NODE : + serializeCDATASection((CDATASection) node); + break; + case Node.TEXT_NODE : + serializeText((Text) node); + break; + case Node.ENTITY_REFERENCE_NODE : + serializeEntityReference((EntityReference) node, true); + break; + default : + } + } + + /** + * End processing of given node + * + * + * @param node Node we just finished processing + * + * @throws org.xml.sax.SAXException + */ + protected void endNode(Node node) throws org.xml.sax.SAXException { + + switch (node.getNodeType()) { + case Node.DOCUMENT_NODE : + break; + case Node.DOCUMENT_TYPE_NODE : + serializeDocType((DocumentType) node, false); + break; + case Node.ELEMENT_NODE : + serializeElement((Element) node, false); + break; + case Node.CDATA_SECTION_NODE : + break; + case Node.ENTITY_REFERENCE_NODE : + serializeEntityReference((EntityReference) node, false); + break; + default : + } + } + + // *********************************************************************** + // Node serialization methods + // *********************************************************************** + /** + * Applies a filter on the node to serialize + * + * @param node The Node to serialize + * @return True if the node is to be serialized else false if the node + * is to be rejected or skipped. + */ + protected boolean applyFilter(Node node, int nodeType) { + if (fFilter != null && (fWhatToShowFilter & nodeType) != 0) { + + short code = fFilter.acceptNode(node); + switch (code) { + case NodeFilter.FILTER_REJECT : + case NodeFilter.FILTER_SKIP : + return false; // skip the node + default : // fall through.. + } + } + return true; + } + + /** + * Serializes a Document Type Node. + * + * @param node The Docuemnt Type Node to serialize + * @param bStart Invoked at the start or end of node. Default true. + */ + protected void serializeDocType(DocumentType node, boolean bStart) + throws SAXException { + // The DocType and internalSubset can not be modified in DOM and is + // considered to be well-formed as the outcome of successful parsing. + String docTypeName = node.getNodeName(); + String publicId = node.getPublicId(); + String systemId = node.getSystemId(); + String internalSubset = node.getInternalSubset(); + + //DocumentType nodes are never passed to the filter + + if (internalSubset != null && !"".equals(internalSubset)) { + + if (bStart) { + try { + // The Serializer does not provide a way to write out the + // DOCTYPE internal subset via an event call, so we write it + // out here. + Writer writer = fSerializer.getWriter(); + StringBuffer dtd = new StringBuffer(); + + dtd.append(""); + dtd.append(fNewLine); + + writer.write(dtd.toString()); + writer.flush(); + + } catch (IOException e) { + throw new SAXException(Utils.messages.createMessage( + MsgKey.ER_WRITING_INTERNAL_SUBSET, null), e); + } + } // else if !bStart do nothing + + } else { + + if (bStart) { + if (fLexicalHandler != null) { + fLexicalHandler.startDTD(docTypeName, publicId, systemId); + } + } else { + if (fLexicalHandler != null) { + fLexicalHandler.endDTD(); + } + } + } + } + + /** + * Serializes a Comment Node. + * + * @param node The Comment Node to serialize + */ + protected void serializeComment(Comment node) throws SAXException { + // comments=true + if ((fFeatures & COMMENTS) != 0) { + String data = node.getData(); + + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isCommentWellFormed(data); + } + + if (fLexicalHandler != null) { + // apply the LSSerializer filter after the operations requested by the + // DOMConfiguration parameters have been applied + if (!applyFilter(node, NodeFilter.SHOW_COMMENT)) { + return; + } + + fLexicalHandler.comment(data.toCharArray(), 0, data.length()); + } + } + } + + /** + * Serializes an Element Node. + * + * @param node The Element Node to serialize + * @param bStart Invoked at the start or end of node. + */ + protected void serializeElement(Element node, boolean bStart) + throws SAXException { + if (bStart) { + fElementDepth++; + + // We use the Xalan specific startElement and starPrefixMapping calls + // (and addAttribute and namespaceAfterStartElement) as opposed to + // SAX specific, for performance reasons as they reduce the overhead + // of creating an AttList object upfront. + + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isElementWellFormed(node); + } + + // REVISIT: We apply the LSSerializer filter for elements before + // namesapce fixup + if (!applyFilter(node, NodeFilter.SHOW_ELEMENT)) { + return; + } + + // namespaces=true, record and fixup namspaced element + if ((fFeatures & NAMESPACES) != 0) { + fNSBinder.pushContext(); + fLocalNSBinder.reset(); + + recordLocalNSDecl(node); + fixupElementNS(node); + } + + // Namespace normalization + fSerializer.startElement( + node.getNamespaceURI(), + node.getLocalName(), + node.getNodeName()); + + serializeAttList(node); + + } else { + fElementDepth--; + + // apply the LSSerializer filter + if (!applyFilter(node, NodeFilter.SHOW_ELEMENT)) { + return; + } + + this.fSerializer.endElement( + node.getNamespaceURI(), + node.getLocalName(), + node.getNodeName()); + // since endPrefixMapping was not used by SerializationHandler it was removed + // for performance reasons. + + if ((fFeatures & NAMESPACES) != 0 ) { + fNSBinder.popContext(); + } + + } + } + + /** + * Serializes the Attr Nodes of an Element. + * + * @param node The OwnerElement whose Attr Nodes are to be serialized. + */ + protected void serializeAttList(Element node) throws SAXException { + NamedNodeMap atts = node.getAttributes(); + int nAttrs = atts.getLength(); + + for (int i = 0; i < nAttrs; i++) { + Node attr = atts.item(i); + + String localName = attr.getLocalName(); + String attrName = attr.getNodeName(); + String attrPrefix = attr.getPrefix() == null ? "" : attr.getPrefix(); + String attrValue = attr.getNodeValue(); + + // Determine the Attr's type. + String type = null; + if (fIsLevel3DOM) { + type = ((Attr) attr).getSchemaTypeInfo().getTypeName(); + } + type = type == null ? "CDATA" : type; + + String attrNS = attr.getNamespaceURI(); + if (attrNS !=null && attrNS.length() == 0) { + attrNS=null; + // we must remove prefix for this attribute + attrName=attr.getLocalName(); + } + + boolean isSpecified = ((Attr) attr).getSpecified(); + boolean addAttr = true; + boolean applyFilter = false; + boolean xmlnsAttr = + attrName.equals("xmlns") || attrName.startsWith("xmlns:"); + + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isAttributeWellFormed(attr); + } + + //----------------------------------------------------------------- + // start Attribute namespace fixup + //----------------------------------------------------------------- + // namespaces=true, normalize all non-namespace attributes + // Step 3. Attribute + if ((fFeatures & NAMESPACES) != 0 && !xmlnsAttr) { + + // If the Attr has a namespace URI + if (attrNS != null) { + attrPrefix = attrPrefix == null ? "" : attrPrefix; + + String declAttrPrefix = fNSBinder.getPrefix(attrNS); + String declAttrNS = fNSBinder.getURI(attrPrefix); + + // attribute has no prefix (default namespace decl does not apply to + // attributes) + // OR + // attribute prefix is not declared + // OR + // conflict: attribute has a prefix that conflicts with a binding + if ("".equals(attrPrefix) || "".equals(declAttrPrefix) + || !attrPrefix.equals(declAttrPrefix)) { + + // namespaceURI matches an in scope declaration of one or + // more prefixes + if (declAttrPrefix != null && !"".equals(declAttrPrefix)) { + // pick the prefix that was found and change attribute's + // prefix and nodeName. + attrPrefix = declAttrPrefix; + + if (declAttrPrefix.length() > 0 ) { + attrName = declAttrPrefix + ":" + localName; + } else { + attrName = localName; + } + } else { + // The current prefix is not null and it has no in scope + // declaration + if (attrPrefix != null && !"".equals(attrPrefix) + && declAttrNS == null) { + // declare this prefix + if ((fFeatures & NAMESPACEDECLS) != 0) { + fSerializer.addAttribute(XMLNS_URI, attrPrefix, + XMLNS_PREFIX + ":" + attrPrefix, "CDATA", + attrNS); + fNSBinder.declarePrefix(attrPrefix, attrNS); + fLocalNSBinder.declarePrefix(attrPrefix, attrNS); + } + } else { + // find a prefix following the pattern "NS" +index + // (starting at 1) + // make sure this prefix is not declared in the current + // scope. + int counter = 1; + attrPrefix = "NS" + counter++; + + while (fLocalNSBinder.getURI(attrPrefix) != null) { + attrPrefix = "NS" + counter++; + } + // change attribute's prefix and Name + attrName = attrPrefix + ":" + localName; + + // create a local namespace declaration attribute + // Add the xmlns declaration attribute + if ((fFeatures & NAMESPACEDECLS) != 0) { + + fSerializer.addAttribute(XMLNS_URI, attrPrefix, + XMLNS_PREFIX + ":" + attrPrefix, "CDATA", + attrNS); + fNSBinder.declarePrefix(attrPrefix, attrNS); + fLocalNSBinder.declarePrefix(attrPrefix, attrNS); + } + } + } + } + + } else { // if the Attr has no namespace URI + // Attr has no localName + if (localName == null) { + // DOM Level 1 node! + String msg = Utils.messages.createMessage( + MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + new Object[] { attrName }); + + if (fErrorHandler != null) { + fErrorHandler + .handleError(new DOMErrorImpl( + DOMError.SEVERITY_ERROR, msg, + MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, null, + null, null)); + } + + } else { // uri=null and no colon + // attr has no namespace URI and no prefix + // no action is required, since attrs don't use default + } + } + + } + + + // discard-default-content=true + // Default attr's are not passed to the filter and this contraint + // is applied only when discard-default-content=true + // What about default xmlns attributes???? check for xmlnsAttr + if ((((fFeatures & DISCARDDEFAULT) != 0) && isSpecified) + || ((fFeatures & DISCARDDEFAULT) == 0)) { + applyFilter = true; + } else { + addAttr = false; + } + + if (applyFilter) { + // apply the filter for Attributes that are not default attributes + // or namespace decl attributes + if (fFilter != null + && (fFilter.getWhatToShow() & NodeFilter.SHOW_ATTRIBUTE) + != 0) { + + if (!xmlnsAttr) { + short code = fFilter.acceptNode(attr); + switch (code) { + case NodeFilter.FILTER_REJECT : + case NodeFilter.FILTER_SKIP : + addAttr = false; + break; + default : //fall through.. + } + } + } + } + + // if the node is a namespace node + if (addAttr && xmlnsAttr) { + // If namespace-declarations=true, add the node , else don't add it + if ((fFeatures & NAMESPACEDECLS) != 0) { + // The namespace may have been fixed up, in that case don't add it. + if (localName != null && !"".equals(localName)) { + fSerializer.addAttribute(attrNS, localName, attrName, type, attrValue); + } + } + } else if ( + addAttr && !xmlnsAttr) { // if the node is not a namespace node + // If namespace-declarations=true, add the node with the Attr nodes namespaceURI + // else add the node setting it's namespace to null or else the serializer will later + // attempt to add a xmlns attr for the prefixed attribute + if (((fFeatures & NAMESPACEDECLS) != 0) && (attrNS != null)) { + fSerializer.addAttribute( + attrNS, + localName, + attrName, + type, + attrValue); + } else { + fSerializer.addAttribute( + "", + localName, + attrName, + type, + attrValue); + } + } + + // + if (xmlnsAttr && ((fFeatures & NAMESPACEDECLS) != 0)) { + int index; + // Use "" instead of null, as Xerces likes "" for the + // name of the default namespace. Fix attributed + // to "Steven Murray" . + String prefix = + (index = attrName.indexOf(":")) < 0 + ? "" + : attrName.substring(index + 1); + + if (!"".equals(prefix)) { + fSerializer.namespaceAfterStartElement(prefix, attrValue); + } + } + } + + } + + /** + * Serializes an ProcessingInstruction Node. + * + * @param node The ProcessingInstruction Node to serialize + */ + protected void serializePI(ProcessingInstruction node) + throws SAXException { + ProcessingInstruction pi = node; + String name = pi.getNodeName(); + + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isPIWellFormed(node); + } + + // apply the LSSerializer filter + if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) { + return; + } + + // String data = pi.getData(); + if (name.equals("xslt-next-is-raw")) { + fNextIsRaw = true; + } else { + this.fSerializer.processingInstruction(name, pi.getData()); + } + } + + /** + * Serializes an CDATASection Node. + * + * @param node The CDATASection Node to serialize + */ + protected void serializeCDATASection(CDATASection node) + throws SAXException { + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isCDATASectionWellFormed(node); + } + + // cdata-sections = true + if ((fFeatures & CDATA) != 0) { + + // split-cdata-sections = true + // Assumption: This parameter has an effect only when + // cdata-sections=true + // ToStream, by default splits cdata-sections. Hence the check + // below. + String nodeValue = node.getNodeValue(); + int endIndex = nodeValue.indexOf("]]>"); + if ((fFeatures & SPLITCDATA) != 0) { + if (endIndex >= 0) { + // The first node split will contain the ]] markers + String relatedData = nodeValue.substring(0, endIndex + 2); + + String msg = + Utils.messages.createMessage( + MsgKey.ER_CDATA_SECTIONS_SPLIT, + null); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_WARNING, + msg, + MsgKey.ER_CDATA_SECTIONS_SPLIT, + null, + relatedData, + null)); + } + } + } else { + if (endIndex >= 0) { + // The first node split will contain the ]] markers + String relatedData = nodeValue.substring(0, endIndex + 2); + + String msg = + Utils.messages.createMessage( + MsgKey.ER_CDATA_SECTIONS_SPLIT, + null); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_ERROR, + msg, + MsgKey.ER_CDATA_SECTIONS_SPLIT)); + } + // Report an error and return. What error??? + return; + } + } + + // apply the LSSerializer filter + if (!applyFilter(node, NodeFilter.SHOW_CDATA_SECTION)) { + return; + } + + // splits the cdata-section + if (fLexicalHandler != null) { + fLexicalHandler.startCDATA(); + } + dispatachChars(node); + if (fLexicalHandler != null) { + fLexicalHandler.endCDATA(); + } + } else { + dispatachChars(node); + } + } + + /** + * Serializes an Text Node. + * + * @param node The Text Node to serialize + */ + protected void serializeText(Text node) throws SAXException { + if (fNextIsRaw) { + fNextIsRaw = false; + fSerializer.processingInstruction( + javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, + ""); + dispatachChars(node); + fSerializer.processingInstruction( + javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, + ""); + } else { + // keep track of dispatch or not to avoid duplicaiton of filter code + boolean bDispatch = false; + + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isTextWellFormed(node); + } + + // if the node is whitespace + // Determine the Attr's type. + boolean isElementContentWhitespace = false; + if (fIsLevel3DOM) { + isElementContentWhitespace = + node.isElementContentWhitespace(); + } + + if (isElementContentWhitespace) { + // element-content-whitespace=true + if ((fFeatures & ELEM_CONTENT_WHITESPACE) != 0) { + bDispatch = true; + } + } else { + bDispatch = true; + } + + // apply the LSSerializer filter + if (!applyFilter(node, NodeFilter.SHOW_TEXT)) { + return; + } + + if (bDispatch) { + dispatachChars(node); + } + } + } + + /** + * Serializes an EntityReference Node. + * + * @param node The EntityReference Node to serialize + * @param bStart Inicates if called from start or endNode + */ + protected void serializeEntityReference( + EntityReference node, + boolean bStart) + throws SAXException { + if (bStart) { + EntityReference eref = node; + // entities=true + if ((fFeatures & ENTITIES) != 0) { + + // perform well-formedness and other checking only if + // entities = true + + // well-formed=true + if ((fFeatures & WELLFORMED) != 0) { + isEntityReferneceWellFormed(node); + } + + // check "unbound-prefix-in-entity-reference" [fatal] + // Raised if the configuration parameter "namespaces" is set to true + if ((fFeatures & NAMESPACES) != 0) { + checkUnboundPrefixInEntRef(node); + } + + // The filter should not apply in this case, since the + // EntityReference is not being expanded. + // should we pass entity reference nodes to the filter??? + } + + if (fLexicalHandler != null) { + + // startEntity outputs only Text but not Element, Attr, Comment + // and PI child nodes. It does so by setting the m_inEntityRef + // in ToStream and using this to decide if a node is to be + // serialized or not. + fLexicalHandler.startEntity(eref.getNodeName()); + } + + } else { + EntityReference eref = node; + // entities=true or false, + if (fLexicalHandler != null) { + fLexicalHandler.endEntity(eref.getNodeName()); + } + } + } + + + // *********************************************************************** + // Methods to check well-formedness + // *********************************************************************** + /** + * Taken from org.apache.xerces.dom.CoreDocumentImpl + * + * Check the string against XML's definition of acceptable names for + * elements and attributes and so on using the XMLCharacterProperties + * utility class + */ + protected boolean isXMLName(String s, boolean xml11Version) { + + if (s == null) { + return false; + } + if (!xml11Version) + return XMLChar.isValidName(s); + else + return XML11Char.isXML11ValidName(s); + } + + /** + * Taken from org.apache.xerces.dom.CoreDocumentImpl + * + * Checks if the given qualified name is legal with respect + * to the version of XML to which this document must conform. + * + * @param prefix prefix of qualified name + * @param local local part of qualified name + */ + protected boolean isValidQName( + String prefix, + String local, + boolean xml11Version) { + + // check that both prefix and local part match NCName + if (local == null) + return false; + boolean validNCName = false; + + if (!xml11Version) { + validNCName = + (prefix == null || XMLChar.isValidNCName(prefix)) + && XMLChar.isValidNCName(local); + } else { + validNCName = + (prefix == null || XML11Char.isXML11ValidNCName(prefix)) + && XML11Char.isXML11ValidNCName(local); + } + + return validNCName; + } + + /** + * Checks if a XML character is well-formed + * + * @param characters A String of characters to be checked for Well-Formedness + * @param refInvalidChar A reference to the character to be returned that was determined invalid. + */ + protected boolean isWFXMLChar(String chardata, Character refInvalidChar) { + if (chardata == null || (chardata.length() == 0)) { + return true; + } + + char[] dataarray = chardata.toCharArray(); + int datalength = dataarray.length; + + // version of the document is XML 1.1 + if (fIsXMLVersion11) { + //we need to check all characters as per production rules of XML11 + int i = 0; + while (i < datalength) { + if (XML11Char.isXML11Invalid(dataarray[i++])) { + // check if this is a supplemental character + char ch = dataarray[i - 1]; + if (XMLChar.isHighSurrogate(ch) && i < datalength) { + char ch2 = dataarray[i++]; + if (XMLChar.isLowSurrogate(ch2) + && XMLChar.isSupplemental( + XMLChar.supplemental(ch, ch2))) { + continue; + } + } + // Reference to invalid character which is returned + refInvalidChar = new Character(ch); + return false; + } + } + } // version of the document is XML 1.0 + else { + // we need to check all characters as per production rules of XML 1.0 + int i = 0; + while (i < datalength) { + if (XMLChar.isInvalid(dataarray[i++])) { + // check if this is a supplemental character + char ch = dataarray[i - 1]; + if (XMLChar.isHighSurrogate(ch) && i < datalength) { + char ch2 = dataarray[i++]; + if (XMLChar.isLowSurrogate(ch2) + && XMLChar.isSupplemental( + XMLChar.supplemental(ch, ch2))) { + continue; + } + } + // Reference to invalid character which is returned + refInvalidChar = new Character(ch); + return false; + } + } + } // end-else fDocument.isXMLVersion() + + return true; + } // isXMLCharWF + + /** + * Checks if a XML character is well-formed. If there is a problem with + * the character a non-null Character is returned else null is returned. + * + * @param characters A String of characters to be checked for Well-Formedness + * @return Character A reference to the character to be returned that was determined invalid. + */ + protected Character isWFXMLChar(String chardata) { + Character refInvalidChar; + if (chardata == null || (chardata.length() == 0)) { + return null; + } + + char[] dataarray = chardata.toCharArray(); + int datalength = dataarray.length; + + // version of the document is XML 1.1 + if (fIsXMLVersion11) { + //we need to check all characters as per production rules of XML11 + int i = 0; + while (i < datalength) { + if (XML11Char.isXML11Invalid(dataarray[i++])) { + // check if this is a supplemental character + char ch = dataarray[i - 1]; + if (XMLChar.isHighSurrogate(ch) && i < datalength) { + char ch2 = dataarray[i++]; + if (XMLChar.isLowSurrogate(ch2) + && XMLChar.isSupplemental( + XMLChar.supplemental(ch, ch2))) { + continue; + } + } + // Reference to invalid character which is returned + refInvalidChar = new Character(ch); + return refInvalidChar; + } + } + } // version of the document is XML 1.0 + else { + // we need to check all characters as per production rules of XML 1.0 + int i = 0; + while (i < datalength) { + if (XMLChar.isInvalid(dataarray[i++])) { + // check if this is a supplemental character + char ch = dataarray[i - 1]; + if (XMLChar.isHighSurrogate(ch) && i < datalength) { + char ch2 = dataarray[i++]; + if (XMLChar.isLowSurrogate(ch2) + && XMLChar.isSupplemental( + XMLChar.supplemental(ch, ch2))) { + continue; + } + } + // Reference to invalid character which is returned + refInvalidChar = new Character(ch); + return refInvalidChar; + } + } + } // end-else fDocument.isXMLVersion() + + return null; + } // isXMLCharWF + + /** + * Checks if a comment node is well-formed + * + * @param data The contents of the comment node + * @return a boolean indiacating if the comment is well-formed or not. + */ + protected void isCommentWellFormed(String data) { + if (data == null || (data.length() == 0)) { + return; + } + + char[] dataarray = data.toCharArray(); + int datalength = dataarray.length; + + // version of the document is XML 1.1 + if (fIsXMLVersion11) { + // we need to check all chracters as per production rules of XML11 + int i = 0; + while (i < datalength) { + char c = dataarray[i++]; + if (XML11Char.isXML11Invalid(c)) { + // check if this is a supplemental character + if (XMLChar.isHighSurrogate(c) && i < datalength) { + char c2 = dataarray[i++]; + if (XMLChar.isLowSurrogate(c2) + && XMLChar.isSupplemental( + XMLChar.supplemental(c, c2))) { + continue; + } + } + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + new Object[] { new Character(c)}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } else if (c == '-' && i < datalength && dataarray[i] == '-') { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_DASH_IN_COMMENT, + null); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } + } + } // version of the document is XML 1.0 + else { + // we need to check all chracters as per production rules of XML 1.0 + int i = 0; + while (i < datalength) { + char c = dataarray[i++]; + if (XMLChar.isInvalid(c)) { + // check if this is a supplemental character + if (XMLChar.isHighSurrogate(c) && i < datalength) { + char c2 = dataarray[i++]; + if (XMLChar.isLowSurrogate(c2) + && XMLChar.isSupplemental( + XMLChar.supplemental(c, c2))) { + continue; + } + } + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + new Object[] { new Character(c)}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } else if (c == '-' && i < datalength && dataarray[i] == '-') { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_DASH_IN_COMMENT, + null); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } + } + } + return; + } + + /** + * Checks if an element node is well-formed, by checking its Name for well-formedness. + * + * @param data The contents of the comment node + * @return a boolean indiacating if the comment is well-formed or not. + */ + protected void isElementWellFormed(Node node) { + boolean isNameWF = false; + if ((fFeatures & NAMESPACES) != 0) { + isNameWF = + isValidQName( + node.getPrefix(), + node.getLocalName(), + fIsXMLVersion11); + } else { + isNameWF = isXMLName(node.getNodeName(), fIsXMLVersion11); + } + + if (!isNameWF) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + new Object[] { "Element", node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + null, + null, + null)); + } + } + } + + /** + * Checks if an attr node is well-formed, by checking it's Name and value + * for well-formedness. + * + * @param data The contents of the comment node + * @return a boolean indiacating if the comment is well-formed or not. + */ + protected void isAttributeWellFormed(Node node) { + boolean isNameWF = false; + if ((fFeatures & NAMESPACES) != 0) { + isNameWF = + isValidQName( + node.getPrefix(), + node.getLocalName(), + fIsXMLVersion11); + } else { + isNameWF = isXMLName(node.getNodeName(), fIsXMLVersion11); + } + + if (!isNameWF) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + new Object[] { "Attr", node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + null, + null, + null)); + } + } + + // Check the Attr's node value + // WFC: No < in Attribute Values + String value = node.getNodeValue(); + if (value.indexOf('<') >= 0) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_LT_IN_ATTVAL, + new Object[] { + ((Attr) node).getOwnerElement().getNodeName(), + node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_LT_IN_ATTVAL, + null, + null, + null)); + } + } + + // we need to loop through the children of attr nodes and check their values for + // well-formedness + NodeList children = node.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + // An attribute node with no text or entity ref child for example + // doc.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:ns"); + // followes by + // element.setAttributeNodeNS(attribute); + // can potentially lead to this situation. If the attribute + // was a prefix Namespace attribute declaration then then DOM Core + // should have some exception defined for this. + if (child == null) { + // we should probably report an error + continue; + } + switch (child.getNodeType()) { + case Node.TEXT_NODE : + isTextWellFormed((Text) child); + break; + case Node.ENTITY_REFERENCE_NODE : + isEntityReferneceWellFormed((EntityReference) child); + break; + default : + } + } + + // TODO: + // WFC: Check if the attribute prefix is bound to + // http://www.w3.org/2000/xmlns/ + + // WFC: Unique Att Spec + // Perhaps pass a seen boolean value to this method. serializeAttList will determine + // if the attr was seen before. + } + + /** + * Checks if a PI node is well-formed, by checking it's Name and data + * for well-formedness. + * + * @param data The contents of the comment node + */ + protected void isPIWellFormed(ProcessingInstruction node) { + // Is the PI Target a valid XML name + if (!isXMLName(node.getNodeName(), fIsXMLVersion11)) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + new Object[] { "ProcessingInstruction", node.getTarget()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + null, + null, + null)); + } + } + + // Does the PI Data carry valid XML characters + + // REVISIT: Should we check if the PI DATA contains a ?> ??? + Character invalidChar = isWFXMLChar(node.getData()); + if (invalidChar != null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) }); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } + } + + /** + * Checks if an CDATASection node is well-formed, by checking it's data + * for well-formedness. Note that the presence of a CDATA termination mark + * in the contents of a CDATASection is handled by the parameter + * spli-cdata-sections + * + * @param data The contents of the comment node + */ + protected void isCDATASectionWellFormed(CDATASection node) { + // Does the data valid XML character data + Character invalidChar = isWFXMLChar(node.getData()); + //if (!isWFXMLChar(node.getData(), invalidChar)) { + if (invalidChar != null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) }); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } + } + + /** + * Checks if an Text node is well-formed, by checking if it contains invalid + * XML characters. + * + * @param data The contents of the comment node + */ + protected void isTextWellFormed(Text node) { + // Does the data valid XML character data + Character invalidChar = isWFXMLChar(node.getData()); + if (invalidChar != null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) }); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER, + null, + null, + null)); + } + } + } + + /** + * Checks if an EntityRefernece node is well-formed, by checking it's node name. Then depending + * on whether it is referenced in Element content or in an Attr Node, checks if the EntityReference + * references an unparsed entity or a external entity and if so throws raises the + * appropriate well-formedness error. + * + * @param data The contents of the comment node + * @parent The parent of the EntityReference Node + */ + protected void isEntityReferneceWellFormed(EntityReference node) { + // Is the EntityReference name a valid XML name + if (!isXMLName(node.getNodeName(), fIsXMLVersion11)) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + new Object[] { "EntityReference", node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + null, + null, + null)); + } + } + + // determine the parent node + Node parent = node.getParentNode(); + + // Traverse the declared entities and check if the nodeName and namespaceURI + // of the EntityReference matches an Entity. If so, check the if the notationName + // is not null, if so, report an error. + DocumentType docType = node.getOwnerDocument().getDoctype(); + if (docType != null) { + NamedNodeMap entities = docType.getEntities(); + for (int i = 0; i < entities.getLength(); i++) { + Entity ent = (Entity) entities.item(i); + + String nodeName = + node.getNodeName() == null ? "" : node.getNodeName(); + String nodeNamespaceURI = + node.getNamespaceURI() == null + ? "" + : node.getNamespaceURI(); + String entName = + ent.getNodeName() == null ? "" : ent.getNodeName(); + String entNamespaceURI = + ent.getNamespaceURI() == null ? "" : ent.getNamespaceURI(); + // If referenced in Element content + // WFC: Parsed Entity + if (parent.getNodeType() == Node.ELEMENT_NODE) { + if (entNamespaceURI.equals(nodeNamespaceURI) + && entName.equals(nodeName)) { + + if (ent.getNotationName() != null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + new Object[] { node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + null, + null, + null)); + } + } + } + } // end if WFC: Parsed Entity + + // If referenced in an Attr value + // WFC: No External Entity References + if (parent.getNodeType() == Node.ATTRIBUTE_NODE) { + if (entNamespaceURI.equals(nodeNamespaceURI) + && entName.equals(nodeName)) { + + if (ent.getPublicId() != null + || ent.getSystemId() != null + || ent.getNotationName() != null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + new Object[] { node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + null, + null, + null)); + } + } + } + } //end if WFC: No External Entity References + } + } + } // isEntityReferneceWellFormed + + /** + * If the configuration parameter "namespaces" is set to true, this methods + * checks if an entity whose replacement text contains unbound namespace + * prefixes is referenced in a location where there are no bindings for + * the namespace prefixes and if so raises a LSException with the error-type + * "unbound-prefix-in-entity-reference" + * + * @param Node, The EntityReference nodes whose children are to be checked + */ + protected void checkUnboundPrefixInEntRef(Node node) { + Node child, next; + for (child = node.getFirstChild(); child != null; child = next) { + next = child.getNextSibling(); + + if (child.getNodeType() == Node.ELEMENT_NODE) { + + //If a NamespaceURI is not declared for the current + //node's prefix, raise a fatal error. + String prefix = child.getPrefix(); + if (prefix != null + && fNSBinder.getURI(prefix) == null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + new Object[] { + node.getNodeName(), + child.getNodeName(), + prefix }); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + null, + null, + null)); + } + } + + NamedNodeMap attrs = child.getAttributes(); + + for (int i = 0; i < attrs.getLength(); i++) { + String attrPrefix = attrs.item(i).getPrefix(); + if (attrPrefix != null + && fNSBinder.getURI(attrPrefix) == null) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + new Object[] { + node.getNodeName(), + child.getNodeName(), + attrs.item(i)}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, + msg, + MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + null, + null, + null)); + } + } + } + } + + if (child.hasChildNodes()) { + checkUnboundPrefixInEntRef(child); + } + } + } + + // *********************************************************************** + // Namespace normalization + // *********************************************************************** + /** + * Records local namespace declarations, to be used for normalization later + * + * @param Node, The element node, whose namespace declarations are to be recorded + */ + protected void recordLocalNSDecl(Node node) { + NamedNodeMap atts = ((Element) node).getAttributes(); + int length = atts.getLength(); + + for (int i = 0; i < length; i++) { + Node attr = atts.item(i); + + String localName = attr.getLocalName(); + String attrPrefix = attr.getPrefix(); + String attrValue = attr.getNodeValue(); + String attrNS = attr.getNamespaceURI(); + + localName = + localName == null + || XMLNS_PREFIX.equals(localName) ? "" : localName; + attrPrefix = attrPrefix == null ? "" : attrPrefix; + attrValue = attrValue == null ? "" : attrValue; + attrNS = attrNS == null ? "" : attrNS; + + // check if attribute is a namespace decl + if (XMLNS_URI.equals(attrNS)) { + + // No prefix may be bound to http://www.w3.org/2000/xmlns/. + if (XMLNS_URI.equals(attrValue)) { + String msg = + Utils.messages.createMessage( + MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + new Object[] { attrPrefix, XMLNS_URI }); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_ERROR, + msg, + MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + null, + null, + null)); + } + } else { + // store the namespace-declaration + if (XMLNS_PREFIX.equals(attrPrefix) ) { + // record valid decl + if (attrValue.length() != 0) { + fNSBinder.declarePrefix(localName, attrValue); + } else { + // Error; xmlns:prefix="" + } + } else { // xmlns + // empty prefix is always bound ("" or some string) + fNSBinder.declarePrefix("", attrValue); + } + } + + } + } + } + + /** + * Fixes an element's namespace + * + * @param Node, The element node, whose namespace is to be fixed + */ + protected void fixupElementNS(Node node) throws SAXException { + String namespaceURI = ((Element) node).getNamespaceURI(); + String prefix = ((Element) node).getPrefix(); + String localName = ((Element) node).getLocalName(); + + if (namespaceURI != null) { + //if ( Element's prefix/namespace pair (or default namespace, + // if no prefix) are within the scope of a binding ) + prefix = prefix == null ? "" : prefix; + String inScopeNamespaceURI = fNSBinder.getURI(prefix); + + if ((inScopeNamespaceURI != null + && inScopeNamespaceURI.equals(namespaceURI))) { + // do nothing, declaration in scope is inherited + + } else { + // Create a local namespace declaration attr for this namespace, + // with Element's current prefix (or a default namespace, if + // no prefix). If there's a conflicting local declaration + // already present, change its value to use this namespace. + + // Add the xmlns declaration attribute + //fNSBinder.pushNamespace(prefix, namespaceURI, fElementDepth); + if ((fFeatures & NAMESPACEDECLS) != 0) { + if ("".equals(prefix) || "".equals(namespaceURI)) { + ((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX, namespaceURI); + } else { + ((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX + ":" + prefix, namespaceURI); + } + } + fLocalNSBinder.declarePrefix(prefix, namespaceURI); + fNSBinder.declarePrefix(prefix, namespaceURI); + + } + } else { + // Element has no namespace + // DOM Level 1 + if (localName == null || "".equals(localName)) { + // DOM Level 1 node! + String msg = + Utils.messages.createMessage( + MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + new Object[] { node.getNodeName()}); + + if (fErrorHandler != null) { + fErrorHandler.handleError( + new DOMErrorImpl( + DOMError.SEVERITY_ERROR, + msg, + MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + null, + null, + null)); + } + } else { + namespaceURI = fNSBinder.getURI(""); + if (namespaceURI !=null && namespaceURI.length() > 0) { + ((Element)node).setAttributeNS(XMLNS_URI, XMLNS_PREFIX, ""); + fLocalNSBinder.declarePrefix("", ""); + fNSBinder.declarePrefix("", ""); + } + } + } + } + /** + * This table is a quick lookup of a property key (String) to the integer that + * is the bit to flip in the fFeatures field, so the integers should have + * values 1,2,4,8,16... + * + */ + private static final Hashtable s_propKeys = new Hashtable(); + static { + + // Initialize the mappings of property keys to bit values (Integer objects) + // or mappings to a String object "", which indicates we are interested + // in the property, but it does not have a simple bit value to flip + + // cdata-sections + int i = CDATA; + Integer val = new Integer(i); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + DOMConstants.DOM_CDATA_SECTIONS, + val); + + // comments + int i1 = COMMENTS; + val = new Integer(i1); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + DOMConstants.DOM_COMMENTS, + val); + + // element-content-whitespace + int i2 = ELEM_CONTENT_WHITESPACE; + val = new Integer(i2); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, + val); + int i3 = ENTITIES; + + // entities + val = new Integer(i3); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + DOMConstants.DOM_ENTITIES, + val); + + // namespaces + int i4 = NAMESPACES; + val = new Integer(i4); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + DOMConstants.DOM_NAMESPACES, + val); + + // namespace-declarations + int i5 = NAMESPACEDECLS; + val = new Integer(i5); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACE_DECLARATIONS, + val); + + // split-cdata-sections + int i6 = SPLITCDATA; + val = new Integer(i6); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + DOMConstants.DOM_SPLIT_CDATA, + val); + + // discard-default-content + int i7 = WELLFORMED; + val = new Integer(i7); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + DOMConstants.DOM_WELLFORMED, + val); + + // discard-default-content + int i8 = DISCARDDEFAULT; + val = new Integer(i8); + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DISCARD_DEFAULT_CONTENT, + val); + + // We are interested in these properties, but they don't have a simple + // bit value to deal with. + s_propKeys.put( + DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_FORMAT_PRETTY_PRINT, + ""); + s_propKeys.put(DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, ""); + s_propKeys.put( + DOMConstants.S_XERCES_PROPERTIES_NS + DOMConstants.S_XML_VERSION, + ""); + s_propKeys.put(DOMConstants.S_XSL_OUTPUT_ENCODING, ""); + s_propKeys.put(OutputPropertiesFactory.S_KEY_ENTITIES, ""); + } + + /** + * Initializes fFeatures based on the DOMConfiguration Parameters set. + * + * @param properties DOMConfiguraiton properties that were set and which are + * to be used while serializing the DOM. + */ + protected void initProperties(Properties properties) { + + for (Enumeration keys = properties.keys(); keys.hasMoreElements();) { + + final String key = (String) keys.nextElement(); + + // caonical-form + // Other features will be enabled or disabled when this is set to true or false. + + // error-handler; set via the constructor + + // infoset + // Other features will be enabled or disabled when this is set to true + + // A quick lookup for the given set of properties (cdata-sections ...) + final Object iobj = s_propKeys.get(key); + if (iobj != null) { + if (iobj instanceof Integer) { + // Dealing with a property that has a simple bit value that + // we need to set + + // cdata-sections + // comments + // element-content-whitespace + // entities + // namespaces + // namespace-declarations + // split-cdata-sections + // well-formed + // discard-default-content + final int BITFLAG = ((Integer) iobj).intValue(); + if ((properties.getProperty(key).endsWith("yes"))) { + fFeatures = fFeatures | BITFLAG; + } else { + fFeatures = fFeatures & ~BITFLAG; + } + } else { + // We are interested in the property, but it is not + // a simple bit that we need to set. + + if ((DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_FORMAT_PRETTY_PRINT) + .equals(key)) { + // format-pretty-print; set internally on the serializers via xsl:output properties in LSSerializer + if ((properties.getProperty(key).endsWith("yes"))) { + fSerializer.setIndent(true); + fSerializer.setIndentAmount(4); + } else { + fSerializer.setIndent(false); + } + } else if ( + (DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL).equals( + key)) { + // omit-xml-declaration; set internally on the serializers via xsl:output properties in LSSerializer + if ((properties.getProperty(key).endsWith("yes"))) { + fSerializer.setOmitXMLDeclaration(true); + } else { + fSerializer.setOmitXMLDeclaration(false); + } + } else if ( + ( + DOMConstants.S_XERCES_PROPERTIES_NS + + DOMConstants.S_XML_VERSION).equals( + key)) { + // Retreive the value of the XML Version attribute via the xml-version + String version = properties.getProperty(key); + if ("1.1".equals(version)) { + fIsXMLVersion11 = true; + fSerializer.setVersion(version); + } else { + fSerializer.setVersion("1.0"); + } + } else if ( + (DOMConstants.S_XSL_OUTPUT_ENCODING).equals(key)) { + // Retreive the value of the XML Encoding attribute + String encoding = properties.getProperty(key); + if (encoding != null) { + fSerializer.setEncoding(encoding); + } + } else if ((OutputPropertiesFactory.S_KEY_ENTITIES).equals(key)) { + // Retreive the value of the XML Encoding attribute + String entities = properties.getProperty(key); + if (DOMConstants.S_XSL_VALUE_ENTITIES.equals(entities)) { + fSerializer.setDTDEntityExpansion(false); + } + } else { + // We shouldn't get here, ever, now what? + } + } + } + } + // Set the newLine character to use + if (fNewLine != null) { + fSerializer.setOutputProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR, fNewLine); + } + } + +} //TreeWalker diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMConstants.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMConstants.java new file mode 100644 index 00000000000..07f19b29d1f --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMConstants.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +/** + * DOM Constants used by the DOM Level 3 LSSerializer implementation. + * + * @xsl.usage internal + */ +final class DOMConstants { + // + // Constants: DOM Level 3 feature ids + // + public static final String DOM3_REC_URL = "http://www.w3.org/TR/DOM-Level-3-LS"; + + public static final String XERCES_URL = "http://xml.apache.org/xerces-2j"; + + // The namespace used to qualified DOM Level 3 DOMConfiguration parameters + public static final String S_DOM3_PROPERTIES_NS = "{" + + DOMConstants.DOM3_REC_URL + "}"; + + public static final String S_XERCES_PROPERTIES_NS = "{" + + DOMConstants.XERCES_URL + "}"; + + // xmlns namespaces + private static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; + + // namespace prefix + private static final String XMLNS_PREFIX = "xmlns"; + + // ************************************************************************ + // DOM Level 3 DOM Configuration parameter names + // ************************************************************************ + // DOM Level 3 parameters defined in Core + public static final String DOM_CANONICAL_FORM = "canonical-form"; // Unsupported, we only appear to support this + + public static final String DOM_CDATA_SECTIONS = "cdata-sections"; + + public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization"; // Unsupported + + public static final String DOM_COMMENTS = "comments"; + + public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization"; // Unsupported + + public static final String DOM_ELEMENT_CONTENT_WHITESPACE = "element-content-whitespace"; + + public static final String DOM_ENTITIES = "entities"; + + public static final String DOM_INFOSET = "infoset"; + + public static final String DOM_NAMESPACES = "namespaces"; + + public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations"; + + public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters"; // Unsupported + + public static final String DOM_SPLIT_CDATA = "split-cdata-sections"; + + public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema"; // Unsopported + + public static final String DOM_VALIDATE = "validate"; // Unsopported + + public static final String DOM_WELLFORMED = "well-formed"; + + // DOM Level 3 Save + public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content"; + + public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print"; + + public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations"; // Unsupported + + public static final String DOM_XMLDECL = "xml-declaration"; + + // DOM Properties + public static final String DOM_ERROR_HANDLER = "error-handler"; + + public static final String DOM_SCHEMA_TYPE = "schema-type"; // Unsupported + + public static final String DOM_SCHEMA_LOCATION = "schema-location"; // Unsupported + + // ************************************************************************ + + // XSL Output properties + // The xsl:output 'indent' property used in LSSerializer + public static final String S_XSL_OUTPUT_INDENT = "indent"; + + // The xsl:output 'indent' property used in LSSerializer + public static final String S_XSL_OUTPUT_ENCODING = "encoding"; + + // The xsl:output 'omit-xml-declaration' property used in LSSerializer + public static final String S_XSL_OUTPUT_OMIT_XML_DECL = "omit-xml-declaration"; + + // The xerces serializer specific 'omit-xml-declaration' property used in LSSerializer + public static final String S_XML_VERSION = "xml-version"; + + // + public static final String S_XSL_VALUE_ENTITIES = "com/sun/org/apache/xml/internal/serializer/XMLEntities"; + + // Parameter values + public static final String DOM3_EXPLICIT_TRUE = "explicit:yes"; + + public static final String DOM3_DEFAULT_TRUE = "default:yes"; + + public static final String DOM3_EXPLICIT_FALSE = "explicit:no"; + + public static final String DOM3_DEFAULT_FALSE = "default:no"; + + // DOM Exceptions + public static final String DOM_EXCEPTION_FEATURE_NOT_FOUND = "FEATURE_NOT_FOUND"; + + public static final String DOM_EXCEPTION_FEATURE_NOT_SUPPORTED = "FEATURE_NOT_SUPPORTED"; + + public static final String DOM_LSEXCEPTION_SERIALIZER_ERR = "SERIALIZER_ERROR"; + +} diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorHandlerImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorHandlerImpl.java new file mode 100644 index 00000000000..e1b577ffaa9 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorHandlerImpl.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import org.w3c.dom.DOMError; +import org.w3c.dom.DOMErrorHandler; + +/** + * This is the default implementation of the ErrorHandler interface and is + * used if one is not provided. The default implementation simply reports + * DOMErrors to System.err. + * + * @xsl.usage internal + */ +final class DOMErrorHandlerImpl implements DOMErrorHandler { + + /** + * Default Constructor + */ + DOMErrorHandlerImpl() { + } + + /** + * Implementation of DOMErrorHandler.handleError that + * adds copy of error to list for later retrieval. + * + */ + public boolean handleError(DOMError error) { + boolean fail = true; + String severity = null; + if (error.getSeverity() == DOMError.SEVERITY_WARNING) { + fail = false; + severity = "[Warning]"; + } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) { + severity = "[Error]"; + } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) { + severity = "[Fatal Error]"; + } + + System.err.println(severity + ": " + error.getMessage() + "\t"); + System.err.println("Type : " + error.getType() + "\t" + "Related Data: " + + error.getRelatedData() + "\t" + "Related Exception: " + + error.getRelatedException() ); + + return fail; + } +} diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorImpl.java new file mode 100644 index 00000000000..a143f65491e --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMErrorImpl.java @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import org.w3c.dom.DOMError; +import org.w3c.dom.DOMLocator; + +/** + * Implementation of the DOM Level 3 DOMError interface. + * + *

See also the DOMError Interface definition from Document Object Model (DOM) Level 3 Core Specification. + * + * @xsl.usage internal + */ + +final class DOMErrorImpl implements DOMError { + + /** private data members */ + + // The DOMError Severity + private short fSeverity = DOMError.SEVERITY_WARNING; + + // The Error message + private String fMessage = null; + + // A String indicating which related data is expected in relatedData. + private String fType; + + // The platform related exception + private Exception fException = null; + + // + private Object fRelatedData; + + // The location of the exception + private DOMLocatorImpl fLocation = new DOMLocatorImpl(); + + + // + // Constructors + // + + /** + * Default constructor. + */ + DOMErrorImpl () { + } + + /** + * @param severity + * @param message + * @param type + */ + DOMErrorImpl(short severity, String message, String type) { + fSeverity = severity; + fMessage = message; + fType = type; + } + + /** + * @param severity + * @param message + * @param type + * @param exception + */ + DOMErrorImpl(short severity, String message, String type, + Exception exception) { + fSeverity = severity; + fMessage = message; + fType = type; + fException = exception; + } + + /** + * @param severity + * @param message + * @param type + * @param exception + * @param relatedData + * @param location + */ + DOMErrorImpl(short severity, String message, String type, + Exception exception, Object relatedData, DOMLocatorImpl location) { + fSeverity = severity; + fMessage = message; + fType = type; + fException = exception; + fRelatedData = relatedData; + fLocation = location; + } + + + /** + * The severity of the error, either SEVERITY_WARNING, + * SEVERITY_ERROR, or SEVERITY_FATAL_ERROR. + * + * @return A short containing the DOMError severity + */ + public short getSeverity() { + return fSeverity; + } + + /** + * The DOMError message string. + * + * @return String + */ + public String getMessage() { + return fMessage; + } + + /** + * The location of the DOMError. + * + * @return A DOMLocator object containing the DOMError location. + */ + public DOMLocator getLocation() { + return fLocation; + } + + /** + * The related platform dependent exception if any. + * + * @return A java.lang.Exception + */ + public Object getRelatedException(){ + return fException; + } + + /** + * Returns a String indicating which related data is expected in relatedData. + * + * @return A String + */ + public String getType(){ + return fType; + } + + /** + * The related DOMError.type dependent data if any. + * + * @return java.lang.Object + */ + public Object getRelatedData(){ + return fRelatedData; + } + + public void reset(){ + fSeverity = DOMError.SEVERITY_WARNING; + fException = null; + fMessage = null; + fType = null; + fRelatedData = null; + fLocation = null; + } + +}// class DOMErrorImpl diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMLocatorImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMLocatorImpl.java new file mode 100644 index 00000000000..f0e87c340f4 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMLocatorImpl.java @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import org.w3c.dom.DOMLocator; +import org.w3c.dom.Node; + + +/** + * DOMLocatorImpl is an implementaion that describes a location (e.g. + * where an error occured). + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * This class is a copy of the Xerces-2J class org.apache.xerces.dom.DOMLocatorImpl.java v 1.10 + * + * @author Gopal Sharma, SUN Microsystems Inc. + * @version $Id: + * + * @xsl.usage internal + */ +final class DOMLocatorImpl implements DOMLocator { + + // + // Data + // + + /** + * The column number where the error occured, + * or -1 if there is no column number available. + */ + private final int fColumnNumber; + + /** + * The line number where the error occured, + * or -1 if there is no line number available. + */ + private final int fLineNumber; + + /** related data node*/ + private final Node fRelatedNode; + + /** + * The URI where the error occured, + * or null if there is no URI available. + */ + private final String fUri; + + /** + * The byte offset into the input source this locator is pointing to or -1 + * if there is no byte offset available + */ + private final int fByteOffset; + + /** + * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], + * offset into the input source this locator is pointing to or -1 if there + * is no UTF-16 offset available. + */ + private final int fUtf16Offset; + + // + // Constructors + // + + DOMLocatorImpl(){ + fColumnNumber = -1; + fLineNumber = -1; + fRelatedNode = null; + fUri = null; + fByteOffset = -1; + fUtf16Offset = -1; + } + + DOMLocatorImpl (int lineNumber, int columnNumber, String uri ){ + fLineNumber = lineNumber ; + fColumnNumber = columnNumber ; + fUri = uri; + + fRelatedNode = null; + fByteOffset = -1; + fUtf16Offset = -1; + } // DOMLocatorImpl (int lineNumber, int columnNumber, String uri ) + + DOMLocatorImpl (int lineNumber, int columnNumber, int utf16Offset, String uri ){ + fLineNumber = lineNumber ; + fColumnNumber = columnNumber ; + fUri = uri; + fUtf16Offset = utf16Offset; + + + fRelatedNode = null; + fByteOffset = -1; + } // DOMLocatorImpl (int lineNumber, int columnNumber, int utf16Offset, String uri ) + + DOMLocatorImpl (int lineNumber, int columnNumber, int byteoffset, Node relatedData, String uri ){ + fLineNumber = lineNumber ; + fColumnNumber = columnNumber ; + fByteOffset = byteoffset ; + fRelatedNode = relatedData ; + fUri = uri; + + fUtf16Offset = -1; + } // DOMLocatorImpl (int lineNumber, int columnNumber, int offset, Node errorNode, String uri ) + + DOMLocatorImpl (int lineNumber, int columnNumber, int byteoffset, Node relatedData, String uri, int utf16Offset ){ + fLineNumber = lineNumber ; + fColumnNumber = columnNumber ; + fByteOffset = byteoffset ; + fRelatedNode = relatedData ; + fUri = uri; + fUtf16Offset = utf16Offset; + } // DOMLocatorImpl (int lineNumber, int columnNumber, int offset, Node errorNode, String uri ) + + + /** + * The line number where the error occured, or -1 if there is no line + * number available. + */ + public int getLineNumber(){ + return fLineNumber; + } + + /** + * The column number where the error occured, or -1 if there is no column + * number available. + */ + public int getColumnNumber(){ + return fColumnNumber; + } + + + /** + * The URI where the error occured, or null if there is no URI available. + */ + public String getUri(){ + return fUri; + } + + + public Node getRelatedNode(){ + return fRelatedNode; + } + + + /** + * The byte offset into the input source this locator is pointing to or -1 + * if there is no byte offset available + */ + public int getByteOffset(){ + return fByteOffset; + } + + /** + * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], + * offset into the input source this locator is pointing to or -1 if there + * is no UTF-16 offset available. + */ + public int getUtf16Offset(){ + return fUtf16Offset; + } + +}// class DOMLocatorImpl diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMOutputImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMOutputImpl.java new file mode 100644 index 00000000000..d6c0a5d59a8 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMOutputImpl.java @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import org.w3c.dom.ls.LSOutput; + +import java.io.Writer; +import java.io.OutputStream; + +/** + * This is a copy of the Xerces-2J class org.apache.xerces.dom.DOMOutputImpl.java + * + * This class represents an output destination for data. + * This interface allows an application to encapsulate information about an + * output destination in a single object, which may include a URI, a byte stream + * (possibly with a specifiedencoding), a base URI, and/or a character stream. + * The exact definitions of a byte stream and a character stream are binding + * dependent. + * The application is expected to provide objects that implement this interface + * whenever such objects are needed. The application can either provide its + * own objects that implement this interface, or it can use the generic factory + * method DOMImplementationLS.createLSOutput() to create objects that + * implement this interface. + * The DOMSerializer will use the LSOutput object to determine where to + * serialize the output to. The DOMSerializer will look at the different + * outputs specified in the LSOutput in the following order to know which one + * to output to, the first one that data can be output to will be used: + * 1.LSOutput.characterStream + * 2.LSOutput.byteStream + * 3.LSOutput.systemId + * LSOutput objects belong to the application. The DOM implementation will + * never modify them (though it may make copies and modify the copies, + * if necessary). + * + * + * @author Arun Yadav, Sun Microsytems + * @author Gopal Sharma, Sun Microsystems + * @version $Id : + * @xsl.usage internal + */ + +final class DOMOutputImpl implements LSOutput { + + private Writer fCharStream = null; + private OutputStream fByteStream = null; + private String fSystemId = null; + private String fEncoding = null; + + /** + * Default Constructor + */ + DOMOutputImpl() {} + + /** + * An attribute of a language and binding dependent type that represents a + * writable stream of bytes. If the application knows the character encoding + * of the byte stream, it should set the encoding attribute. Setting the + * encoding in this way will override any encoding specified in an XML + * declaration in the data. + */ + + public Writer getCharacterStream(){ + return fCharStream; + }; + + /** + * An attribute of a language and binding dependent type that represents a + * writable stream of bytes. If the application knows the character encoding + * of the byte stream, it should set the encoding attribute. Setting the + * encoding in this way will override any encoding specified in an XML + * declaration in the data. + */ + + public void setCharacterStream(Writer characterStream){ + fCharStream = characterStream; + }; + + /** + * Depending on the language binding in use, this attribute may not be + * available. An attribute of a language and binding dependent type that + * represents a writable stream to which 16-bit units can be output. The + * application must encode the stream using UTF-16 (defined in [Unicode] and + * Amendment 1 of [ISO/IEC 10646]). + */ + + public OutputStream getByteStream(){ + return fByteStream; + }; + + /** + * Depending on the language binding in use, this attribute may not be + * available. An attribute of a language and binding dependent type that + * represents a writable stream to which 16-bit units can be output. The + * application must encode the stream using UTF-16 (defined in [Unicode] and + * Amendment 1 of [ISO/IEC 10646]). + */ + + public void setByteStream(OutputStream byteStream){ + fByteStream = byteStream; + }; + + /** + * The system identifier, a URI reference [IETF RFC 2396], for this output + * destination. If the application knows the character encoding of the + * object pointed to by the system identifier, it can set the encoding + * using the encoding attribute. If the system ID is a relative URI + * reference (see section 5 in [IETF RFC 2396]), the behavior is + * implementation dependent. + */ + + public String getSystemId(){ + return fSystemId; + }; + + /** + * The system identifier, a URI reference [IETF RFC 2396], for this output + * destination. If the application knows the character encoding of the + * object pointed to by the system identifier, it can set the encoding + * using the encoding attribute. If the system ID is a relative URI + * reference (see section 5 in [IETF RFC 2396]), the behavior is + * implementation dependent. + */ + + public void setSystemId(String systemId){ + fSystemId = systemId; + }; + + /** + * The character encoding, if known. The encoding must be a string + * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3 + * "Character Encoding in Entities"). This attribute has no effect when the + * application provides a character stream or string data. For other sources + * of input, an encoding specified by means of this attribute will override + * any encoding specified in the XML declaration or the Text declaration, or + * an encoding obtained from a higher level protocol, such as HTTP + * [IETF RFC 2616]. + */ + + public String getEncoding(){ + return fEncoding; + }; + + /** + * The character encoding, if known. The encoding must be a string + * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3 + * "Character Encoding in Entities"). This attribute has no effect when the + * application provides a character stream or string data. For other sources + * of input, an encoding specified by means of this attribute will override + * any encoding specified in the XML declaration or the Text declaration, or + * an encoding obtained from a higher level protocol, such as HTTP + * [IETF RFC 2616]. + */ + + public void setEncoding(String encoding){ + fEncoding = encoding; + }; + +}//DOMOutputImpl diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMStringListImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMStringListImpl.java new file mode 100644 index 00000000000..11eac2aa2e8 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/DOMStringListImpl.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ +package com.sun.org.apache.xml.internal.serializer.dom3; + +import java.util.Vector; + +//import org.apache.xerces.dom3.DOMStringList; +import org.w3c.dom.DOMStringList; + +/** + * This class implemets the DOM Level 3 Core interface DOMStringList. + * + * @xsl.usage internal + */ +final class DOMStringListImpl implements DOMStringList { + + //A collection of DOMString values + private Vector fStrings; + + /** + * Construct an empty list of DOMStringListImpl + */ + DOMStringListImpl() { + fStrings = new Vector(); + } + + /** + * Construct an empty list of DOMStringListImpl + */ + DOMStringListImpl(Vector params) { + fStrings = params; + } + + /** + * Construct an empty list of DOMStringListImpl + */ + DOMStringListImpl(String[] params ) { + fStrings = new Vector(); + if (params != null) { + for (int i=0; i < params.length; i++) { + fStrings.add(params[i]); + } + } + } + + /** + * @see org.apache.xerces.dom3.DOMStringList#item(int) + */ + public String item(int index) { + try { + return (String) fStrings.elementAt(index); + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + + /** + * @see org.apache.xerces.dom3.DOMStringList#getLength() + */ + public int getLength() { + return fStrings.size(); + } + + /** + * @see org.apache.xerces.dom3.DOMStringList#contains(String) + */ + public boolean contains(String param) { + return fStrings.contains(param) ; + } + + /** + * DOM Internal: + * Add a DOMString to the list. + * + * @param domString A string to add to the list + */ + public void add(String param) { + fStrings.add(param); + } + +} diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java new file mode 100644 index 00000000000..5ab43abad0e --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java @@ -0,0 +1,1405 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.Properties; + +import com.sun.org.apache.xml.internal.serializer.DOM3Serializer; +import com.sun.org.apache.xml.internal.serializer.Encodings; +import com.sun.org.apache.xml.internal.serializer.Serializer; +import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory; +import com.sun.org.apache.xml.internal.serializer.SerializerFactory; +import com.sun.org.apache.xml.internal.serializer.utils.MsgKey; +import com.sun.org.apache.xml.internal.serializer.utils.Utils; +import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver; +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.DOMError; +import org.w3c.dom.DOMErrorHandler; +import org.w3c.dom.DOMException; +import org.w3c.dom.DOMStringList; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.ls.LSException; +import org.w3c.dom.ls.LSOutput; +import org.w3c.dom.ls.LSSerializer; +import org.w3c.dom.ls.LSSerializerFilter; + + +/** + * Implemenatation of DOM Level 3 org.w3c.ls.LSSerializer and + * org.w3c.dom.ls.DOMConfiguration. Serialization is achieved by delegating + * serialization calls to org.apache.xml.serializer.ToStream or + * one of its derived classes depending on the serialization method, while walking + * the DOM in DOM3TreeWalker. + * @see org.w3c.dom.ls.LSSerializer + * @see org.w3c.dom.DOMConfiguration + * + * @version $Id: + * + * @xsl.usage internal + */ +final public class LSSerializerImpl implements DOMConfiguration, LSSerializer { + + /** private data members */ + private Serializer fXMLSerializer = null; + + // Tracks DOMConfiguration features. + protected int fFeatures = 0; + + // Common DOM serializer + private DOM3Serializer fDOMSerializer = null; + + // A filter set on the LSSerializer + private LSSerializerFilter fSerializerFilter = null; + + // Stores the nodeArg parameter to speed up multiple writes of the same node. + private Node fVisitedNode = null; + + // The end-of-line character sequence used in serialization. "\n" is whats used on the web. + private String fEndOfLine = "\n"; + + // The DOMErrorhandler. + private DOMErrorHandler fDOMErrorHandler = null; + + // The Configuration parameter to pass to the Underlying serilaizer. + private Properties fDOMConfigProperties = null; + + // The encoding to use during serialization. + private String fEncoding; + + // ************************************************************************ + // DOM Level 3 DOM Configuration parameter names + // ************************************************************************ + // Parameter canonical-form, true [optional] - NOT SUPPORTED + private final static int CANONICAL = 0x1 << 0; + + // Parameter cdata-sections, true [required] (default) + private final static int CDATA = 0x1 << 1; + + // Parameter check-character-normalization, true [optional] - NOT SUPPORTED + private final static int CHARNORMALIZE = 0x1 << 2; + + // Parameter comments, true [required] (default) + private final static int COMMENTS = 0x1 << 3; + + // Parameter datatype-normalization, true [optional] - NOT SUPPORTED + private final static int DTNORMALIZE = 0x1 << 4; + + // Parameter element-content-whitespace, true [required] (default) - value - false [optional] NOT SUPPORTED + private final static int ELEM_CONTENT_WHITESPACE = 0x1 << 5; + + // Parameter entities, true [required] (default) + private final static int ENTITIES = 0x1 << 6; + + // Parameter infoset, true [required] (default), false has no effect --> True has no effect for the serializer + private final static int INFOSET = 0x1 << 7; + + // Parameter namespaces, true [required] (default) + private final static int NAMESPACES = 0x1 << 8; + + // Parameter namespace-declarations, true [required] (default) + private final static int NAMESPACEDECLS = 0x1 << 9; + + // Parameter normalize-characters, true [optional] - NOT SUPPORTED + private final static int NORMALIZECHARS = 0x1 << 10; + + // Parameter split-cdata-sections, true [required] (default) + private final static int SPLITCDATA = 0x1 << 11; + + // Parameter validate, true [optional] - NOT SUPPORTED + private final static int VALIDATE = 0x1 << 12; + + // Parameter validate-if-schema, true [optional] - NOT SUPPORTED + private final static int SCHEMAVALIDATE = 0x1 << 13; + + // Parameter split-cdata-sections, true [required] (default) + private final static int WELLFORMED = 0x1 << 14; + + // Parameter discard-default-content, true [required] (default) + // Not sure how this will be used in level 2 Documents + private final static int DISCARDDEFAULT = 0x1 << 15; + + // Parameter format-pretty-print, true [optional] + private final static int PRETTY_PRINT = 0x1 << 16; + + // Parameter ignore-unknown-character-denormalizations, true [required] (default) + // We currently do not support XML 1.1 character normalization + private final static int IGNORE_CHAR_DENORMALIZE = 0x1 << 17; + + // Parameter discard-default-content, true [required] (default) + private final static int XMLDECL = 0x1 << 18; + // ************************************************************************ + + // Recognized parameters for which atleast one value can be set + private String fRecognizedParameters [] = { + DOMConstants.DOM_CANONICAL_FORM, + DOMConstants.DOM_CDATA_SECTIONS, + DOMConstants.DOM_CHECK_CHAR_NORMALIZATION, + DOMConstants.DOM_COMMENTS, + DOMConstants.DOM_DATATYPE_NORMALIZATION, + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, + DOMConstants.DOM_ENTITIES, + DOMConstants.DOM_INFOSET, + DOMConstants.DOM_NAMESPACES, + DOMConstants.DOM_NAMESPACE_DECLARATIONS, + //DOMConstants.DOM_NORMALIZE_CHARACTERS, + DOMConstants.DOM_SPLIT_CDATA, + DOMConstants.DOM_VALIDATE, + DOMConstants.DOM_VALIDATE_IF_SCHEMA, + DOMConstants.DOM_WELLFORMED, + DOMConstants.DOM_DISCARD_DEFAULT_CONTENT, + DOMConstants.DOM_FORMAT_PRETTY_PRINT, + DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS, + DOMConstants.DOM_XMLDECL, + DOMConstants.DOM_ERROR_HANDLER + }; + + + /** + * Constructor: Creates a LSSerializerImpl object. The underlying + * XML 1.0 or XML 1.1 org.apache.xml.serializer.Serializer object is + * created and initialized the first time any of the write methods are + * invoked to serialize the Node. Subsequent write methods on the same + * LSSerializerImpl object will use the previously created Serializer object. + */ + public LSSerializerImpl () { + // set default parameters + fFeatures |= CDATA; + fFeatures |= COMMENTS; + fFeatures |= ELEM_CONTENT_WHITESPACE; + fFeatures |= ENTITIES; + fFeatures |= NAMESPACES; + fFeatures |= NAMESPACEDECLS; + fFeatures |= SPLITCDATA; + fFeatures |= WELLFORMED; + fFeatures |= DISCARDDEFAULT; + fFeatures |= XMLDECL; + + // New OutputFormat properties + fDOMConfigProperties = new Properties(); + + // Initialize properties to be passed on the underlying serializer + initializeSerializerProps(); + + // Read output_xml.properties and System Properties to initialize properties + Properties configProps = OutputPropertiesFactory.getDefaultMethodProperties("xml"); + + // change xml version from 1.0 to 1.1 + //configProps.setProperty("version", "1.1"); + + // Get a serializer that seriailizes according to the properties, + // which in this case is to xml + fXMLSerializer = SerializerFactory.getSerializer(configProps); + + // Initialize Serializer + fXMLSerializer.setOutputFormat(fDOMConfigProperties); + } + + /** + * Initializes the underlying serializer's configuration depending on the + * default DOMConfiguration parameters. This method must be called before a + * node is to be serialized. + * + * @xsl.usage internal + */ + public void initializeSerializerProps () { + // canonical-form + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CANONICAL_FORM, DOMConstants.DOM3_DEFAULT_FALSE); + + // cdata-sections + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CDATA_SECTIONS, DOMConstants.DOM3_DEFAULT_TRUE); + + // "check-character-normalization" + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CHECK_CHAR_NORMALIZATION, + DOMConstants.DOM3_DEFAULT_FALSE); + + // comments + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_COMMENTS, DOMConstants.DOM3_DEFAULT_TRUE); + + // datatype-normalization + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DATATYPE_NORMALIZATION, + DOMConstants.DOM3_DEFAULT_FALSE); + + // element-content-whitespace + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, + DOMConstants.DOM3_DEFAULT_TRUE); + + // entities + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ENTITIES, DOMConstants.DOM3_DEFAULT_TRUE); + // preserve entities + fDOMConfigProperties.setProperty( + OutputPropertiesFactory.S_KEY_ENTITIES, DOMConstants.S_XSL_VALUE_ENTITIES); + + // error-handler + // Should we set our default ErrorHandler + /* + * if (fDOMConfig.getParameter(Constants.DOM_ERROR_HANDLER) != null) { + * fDOMErrorHandler = + * (DOMErrorHandler)fDOMConfig.getParameter(Constants.DOM_ERROR_HANDLER); } + */ + + // infoset + if ((fFeatures & INFOSET) != 0) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACES, DOMConstants.DOM3_DEFAULT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACE_DECLARATIONS, + DOMConstants.DOM3_DEFAULT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_COMMENTS, DOMConstants.DOM3_DEFAULT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, + DOMConstants.DOM3_DEFAULT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_WELLFORMED, DOMConstants.DOM3_DEFAULT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ENTITIES, DOMConstants.DOM3_DEFAULT_FALSE); + // preserve entities + fDOMConfigProperties.setProperty( + OutputPropertiesFactory.S_KEY_ENTITIES, ""); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CDATA_SECTIONS, + DOMConstants.DOM3_DEFAULT_FALSE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_VALIDATE_IF_SCHEMA, + DOMConstants.DOM3_DEFAULT_FALSE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DATATYPE_NORMALIZATION, + DOMConstants.DOM3_DEFAULT_FALSE); + } + + // namespaces + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACES, DOMConstants.DOM3_DEFAULT_TRUE); + + // namespace-declarations + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACE_DECLARATIONS, + DOMConstants.DOM3_DEFAULT_TRUE); + + // normalize-characters + /* + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NORMALIZE_CHARACTERS, + DOMConstants.DOM3_DEFAULT_FALSE); + */ + + // split-cdata-sections + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_SPLIT_CDATA, DOMConstants.DOM3_DEFAULT_TRUE); + + // validate + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_VALIDATE, DOMConstants.DOM3_DEFAULT_FALSE); + + // validate-if-schema + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_VALIDATE_IF_SCHEMA, + DOMConstants.DOM3_DEFAULT_FALSE); + + // well-formed + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_WELLFORMED, DOMConstants.DOM3_DEFAULT_TRUE); + + // pretty-print + fDOMConfigProperties.setProperty( + DOMConstants.S_XSL_OUTPUT_INDENT, + DOMConstants.DOM3_DEFAULT_FALSE); + fDOMConfigProperties.setProperty( + OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, Integer.toString(4)); + + // + + // discard-default-content + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DISCARD_DEFAULT_CONTENT, + DOMConstants.DOM3_DEFAULT_TRUE); + + // xml-declaration + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, "no"); + + } + + // ************************************************************************ + // DOMConfiguraiton implementation + // ************************************************************************ + + /** + * Checks if setting a parameter to a specific value is supported. + * + * @see org.w3c.dom.DOMConfiguration#canSetParameter(java.lang.String, java.lang.Object) + * @since DOM Level 3 + * @param name A String containing the DOMConfiguration parameter name. + * @param value An Object specifying the value of the corresponding parameter. + */ + public boolean canSetParameter(String name, Object value) { + if (value instanceof Boolean){ + if ( name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS) + || name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS) + || name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES) + || name.equalsIgnoreCase(DOMConstants.DOM_INFOSET) + || name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE) + || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES) + || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS) + || name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA) + || name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED) + || name.equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT) + || name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT) + || name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)){ + // both values supported + return true; + } + else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM) + || name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION) + || name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION) + || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA) + || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE) + // || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS) + ) { + // true is not supported + return !((Boolean)value).booleanValue(); + } + else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) { + // false is not supported + return ((Boolean)value).booleanValue(); + } + } + else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER) && + value == null || value instanceof DOMErrorHandler){ + return true; + } + return false; + } + /** + * This method returns the value of a parameter if known. + * + * @see org.w3c.dom.DOMConfiguration#getParameter(java.lang.String) + * + * @param name A String containing the DOMConfiguration parameter name + * whose value is to be returned. + * @return Object The value of the parameter if known. + */ + public Object getParameter(String name) throws DOMException { + + if(name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)){ + return null; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS)) { + return ((fFeatures & COMMENTS) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS)) { + return ((fFeatures & CDATA) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES)) { + return ((fFeatures & ENTITIES) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES)) { + return ((fFeatures & NAMESPACES) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS)) { + return ((fFeatures & NAMESPACEDECLS) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA)) { + return ((fFeatures & SPLITCDATA) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED)) { + return ((fFeatures & WELLFORMED) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT)) { + return ((fFeatures & DISCARDDEFAULT) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT)) { + return ((fFeatures & PRETTY_PRINT) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)) { + return ((fFeatures & XMLDECL) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE)) { + return ((fFeatures & ELEM_CONTENT_WHITESPACE) != 0) ? Boolean.TRUE : Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) { + return Boolean.TRUE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM) + || name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION) + || name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION) + // || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS) + || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE) + || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)) { + return Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_INFOSET)){ + if ((fFeatures & ENTITIES) == 0 && + (fFeatures & CDATA) == 0 && + (fFeatures & ELEM_CONTENT_WHITESPACE) != 0 && + (fFeatures & NAMESPACES) != 0 && + (fFeatures & NAMESPACEDECLS) != 0 && + (fFeatures & WELLFORMED) != 0 && + (fFeatures & COMMENTS) != 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER)) { + return fDOMErrorHandler; + } else if ( + name.equalsIgnoreCase(DOMConstants.DOM_SCHEMA_LOCATION) + || name.equalsIgnoreCase(DOMConstants.DOM_SCHEMA_TYPE)) { + return null; + } else { + // Here we have to add the Xalan specific DOM Message Formatter + String msg = Utils.messages.createMessage( + MsgKey.ER_FEATURE_NOT_FOUND, + new Object[] { name }); + throw new DOMException(DOMException.NOT_FOUND_ERR, msg); + } + } + + /** + * This method returns a of the parameters supported by this DOMConfiguration object + * and for which at least one value can be set by the application + * + * @see org.w3c.dom.DOMConfiguration#getParameterNames() + * + * @return DOMStringList A list of DOMConfiguration parameters recognized + * by the serializer + */ + public DOMStringList getParameterNames() { + return new DOMStringListImpl(fRecognizedParameters); + } + + /** + * This method sets the value of the named parameter. + * + * @see org.w3c.dom.DOMConfiguration#setParameter(java.lang.String, java.lang.Object) + * + * @param name A String containing the DOMConfiguration parameter name. + * @param value An Object contaiing the parameters value to set. + */ + public void setParameter(String name, Object value) throws DOMException { + // If the value is a boolean + if (value instanceof Boolean) { + boolean state = ((Boolean) value).booleanValue(); + + if (name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS)) { + fFeatures = state ? fFeatures | COMMENTS : fFeatures + & ~COMMENTS; + // comments + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_COMMENTS, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_COMMENTS, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS)) { + fFeatures = state ? fFeatures | CDATA : fFeatures + & ~CDATA; + // cdata-sections + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CDATA_SECTIONS, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CDATA_SECTIONS, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES)) { + fFeatures = state ? fFeatures | ENTITIES : fFeatures + & ~ENTITIES; + // entities + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ENTITIES, DOMConstants.DOM3_EXPLICIT_TRUE); + fDOMConfigProperties.setProperty( + OutputPropertiesFactory.S_KEY_ENTITIES, DOMConstants.S_XSL_VALUE_ENTITIES); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ENTITIES, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES)) { + fFeatures = state ? fFeatures | NAMESPACES : fFeatures + & ~NAMESPACES; + // namespaces + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACES, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACES, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name + .equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS)) { + fFeatures = state ? fFeatures | NAMESPACEDECLS + : fFeatures & ~NAMESPACEDECLS; + // namespace-declarations + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACE_DECLARATIONS, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACE_DECLARATIONS, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA)) { + fFeatures = state ? fFeatures | SPLITCDATA : fFeatures + & ~SPLITCDATA; + // split-cdata-sections + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_SPLIT_CDATA, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_SPLIT_CDATA, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED)) { + fFeatures = state ? fFeatures | WELLFORMED : fFeatures + & ~WELLFORMED; + // well-formed + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_WELLFORMED, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_WELLFORMED, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name + .equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT)) { + fFeatures = state ? fFeatures | DISCARDDEFAULT + : fFeatures & ~DISCARDDEFAULT; + // discard-default-content + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DISCARD_DEFAULT_CONTENT, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DISCARD_DEFAULT_CONTENT, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT)) { + fFeatures = state ? fFeatures | PRETTY_PRINT : fFeatures + & ~PRETTY_PRINT; + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_INDENT,DOMConstants.DOM3_EXPLICIT_TRUE); + fDOMConfigProperties.setProperty(OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, Integer.toString(4)); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_INDENT,DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)) { + fFeatures = state ? fFeatures | XMLDECL : fFeatures + & ~XMLDECL; + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, "no"); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, "yes"); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE)) { + fFeatures = state ? fFeatures | ELEM_CONTENT_WHITESPACE : fFeatures + & ~ELEM_CONTENT_WHITESPACE; + // element-content-whitespace + if (state) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, DOMConstants.DOM3_EXPLICIT_TRUE); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, DOMConstants.DOM3_EXPLICIT_FALSE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) { + // false is not supported + if (!state) { + // Here we have to add the Xalan specific DOM Message Formatter + String msg = Utils.messages.createMessage( + MsgKey.ER_FEATURE_NOT_SUPPORTED, + new Object[] { name }); + throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + } else { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS, DOMConstants.DOM3_EXPLICIT_TRUE); + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM) + || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA) + || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE) + || name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION) + || name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION) + // || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS) + ) { + // true is not supported + if (state) { + String msg = Utils.messages.createMessage( + MsgKey.ER_FEATURE_NOT_SUPPORTED, + new Object[] { name }); + throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + } else { + if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM)) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CANONICAL_FORM, DOMConstants.DOM3_EXPLICIT_FALSE); + } else if (name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_VALIDATE_IF_SCHEMA, DOMConstants.DOM3_EXPLICIT_FALSE); + } else if (name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE)) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_VALIDATE, DOMConstants.DOM3_EXPLICIT_FALSE); + } else if (name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)) { + fDOMConfigProperties.setProperty(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION + + DOMConstants.DOM_CHECK_CHAR_NORMALIZATION, DOMConstants.DOM3_EXPLICIT_FALSE); + } else if (name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION)) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DATATYPE_NORMALIZATION, DOMConstants.DOM3_EXPLICIT_FALSE); + } /* else if (name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)) { + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NORMALIZE_CHARACTERS, DOMConstants.DOM3_EXPLICIT_FALSE); + } */ + } + } else if (name.equalsIgnoreCase(DOMConstants.DOM_INFOSET)) { + if (state) { + fFeatures &= ~ENTITIES; + fFeatures &= ~CDATA; + fFeatures &= ~SCHEMAVALIDATE; + fFeatures &= ~DTNORMALIZE; + fFeatures |= NAMESPACES; + fFeatures |= NAMESPACEDECLS; + fFeatures |= WELLFORMED; + fFeatures |= ELEM_CONTENT_WHITESPACE; + fFeatures |= COMMENTS; + } + + // infoset + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACES, DOMConstants.DOM3_EXPLICIT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_NAMESPACE_DECLARATIONS, DOMConstants.DOM3_EXPLICIT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_COMMENTS, DOMConstants.DOM3_EXPLICIT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE, DOMConstants.DOM3_EXPLICIT_TRUE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_WELLFORMED, DOMConstants.DOM3_EXPLICIT_TRUE); + + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_ENTITIES, DOMConstants.DOM3_EXPLICIT_FALSE); + fDOMConfigProperties.setProperty( + OutputPropertiesFactory.S_KEY_ENTITIES, ""); + + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_CDATA_SECTIONS, DOMConstants.DOM3_EXPLICIT_FALSE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_VALIDATE_IF_SCHEMA, DOMConstants.DOM3_EXPLICIT_FALSE); + fDOMConfigProperties.setProperty(DOMConstants.S_DOM3_PROPERTIES_NS + + DOMConstants.DOM_DATATYPE_NORMALIZATION, DOMConstants.DOM3_EXPLICIT_FALSE); + } else if (name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)) { + String msg = Utils.messages.createMessage( + MsgKey.ER_FEATURE_NOT_SUPPORTED, + new Object[] { name }); + throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + } else { + // Setting this to false has no effect + } + } // If the parameter value is not a boolean + else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER)) { + if (value == null || value instanceof DOMErrorHandler) { + fDOMErrorHandler = (DOMErrorHandler)value; + } else { + String msg = Utils.messages.createMessage( + MsgKey.ER_TYPE_MISMATCH_ERR, + new Object[] { name }); + throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + } + } else if ( + name.equalsIgnoreCase(DOMConstants.DOM_SCHEMA_LOCATION) + || name.equalsIgnoreCase(DOMConstants.DOM_SCHEMA_TYPE) + || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS) + && value != null) { + String msg = Utils.messages.createMessage( + MsgKey.ER_FEATURE_NOT_SUPPORTED, + new Object[] { name }); + throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + } else { + String msg = Utils.messages.createMessage( + MsgKey.ER_FEATURE_NOT_FOUND, + new Object[] { name }); + throw new DOMException(DOMException.NOT_FOUND_ERR, msg); + } + } + // ************************************************************************ + + + // ************************************************************************ + // DOMConfiguraiton implementation + // ************************************************************************ + + /** + * Returns the DOMConfiguration of the LSSerializer. + * + * @see org.w3c.dom.ls.LSSerializer#getDomConfig() + * @since DOM Level 3 + * @return A DOMConfiguration object. + */ + public DOMConfiguration getDomConfig() { + return (DOMConfiguration)this; + } + + /** + * Returns the DOMConfiguration of the LSSerializer. + * + * @see org.w3c.dom.ls.LSSerializer#getFilter() + * @since DOM Level 3 + * @return A LSSerializerFilter object. + */ + public LSSerializerFilter getFilter() { + return fSerializerFilter; + } + + /** + * Returns the End-Of-Line sequence of characters to be used in the XML + * being serialized. If none is set a default "\n" is returned. + * + * @see org.w3c.dom.ls.LSSerializer#getNewLine() + * @since DOM Level 3 + * @return A String containing the end-of-line character sequence used in + * serialization. + */ + public String getNewLine() { + return fEndOfLine; + } + + /** + * Set a LSSerilizerFilter on the LSSerializer. When set, the filter is + * called before each node is serialized which depending on its implemention + * determines if the node is to be serialized or not. + * + * @see org.w3c.dom.ls.LSSerializer#setFilter + * @since DOM Level 3 + * @param filter A LSSerializerFilter to be applied to the stream to serialize. + */ + public void setFilter(LSSerializerFilter filter) { + fSerializerFilter = filter; + } + + /** + * Sets the End-Of-Line sequence of characters to be used in the XML + * being serialized. Setting this attribute to null will reset its + * value to the default value i.e. "\n". + * + * @see org.w3c.dom.ls.LSSerializer#setNewLine + * @since DOM Level 3 + * @param newLine a String that is the end-of-line character sequence to be used in + * serialization. + */ + public void setNewLine(String newLine) { + fEndOfLine = newLine !=null? newLine: fEndOfLine; + } + + /** + * Serializes the specified node to the specified LSOutput and returns true if the Node + * was successfully serialized. + * + * @see org.w3c.dom.ls.LSSerializer#write(org.w3c.dom.Node, org.w3c.dom.ls.LSOutput) + * @since DOM Level 3 + * @param nodeArg The Node to serialize. + * @throws org.w3c.dom.ls.LSException SERIALIZE_ERR: Raised if the + * LSSerializer was unable to serialize the node. + * + */ + public boolean write(Node nodeArg, LSOutput destination) throws LSException { + // If the destination is null + if (destination == null) { + String msg = Utils.messages + .createMessage( + MsgKey.ER_NO_OUTPUT_SPECIFIED, + null); + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, msg, + MsgKey.ER_NO_OUTPUT_SPECIFIED)); + } + throw new LSException(LSException.SERIALIZE_ERR, msg); + } + + // If nodeArg is null, return false. Should we throw and LSException instead? + if (nodeArg == null ) { + return false; + } + + // Obtain a reference to the serializer to use + // Serializer serializer = getXMLSerializer(xmlVersion); + Serializer serializer = fXMLSerializer; + serializer.reset(); + + // If the node has not been seen + if ( nodeArg != fVisitedNode) { + // Determine the XML Document version of the Node + String xmlVersion = getXMLVersion(nodeArg); + + // Determine the encoding: 1.LSOutput.encoding, 2.Document.inputEncoding, 3.Document.xmlEncoding. + fEncoding = destination.getEncoding(); + if (fEncoding == null ) { + fEncoding = getInputEncoding(nodeArg); + fEncoding = fEncoding != null ? fEncoding : getXMLEncoding(nodeArg) == null? "UTF-8": getXMLEncoding(nodeArg); + } + + // If the encoding is not recognized throw an exception. + // Note: The serializer defaults to UTF-8 when created + if (!Encodings.isRecognizedEncoding(fEncoding)) { + String msg = Utils.messages + .createMessage( + MsgKey.ER_UNSUPPORTED_ENCODING, + null); + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, msg, + MsgKey.ER_UNSUPPORTED_ENCODING)); + } + throw new LSException(LSException.SERIALIZE_ERR, msg); + } + + serializer.getOutputFormat().setProperty("version", xmlVersion); + + // Set the output encoding and xml version properties + fDOMConfigProperties.setProperty(DOMConstants.S_XERCES_PROPERTIES_NS + DOMConstants.S_XML_VERSION, xmlVersion); + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_ENCODING, fEncoding); + + // If the node to be serialized is not a Document, Element, or Entity + // node + // then the XML declaration, or text declaration, should be never be + // serialized. + if ( (nodeArg.getNodeType() != Node.DOCUMENT_NODE + || nodeArg.getNodeType() != Node.ELEMENT_NODE + || nodeArg.getNodeType() != Node.ENTITY_NODE) + && ((fFeatures & XMLDECL) != 0)) { + fDOMConfigProperties.setProperty( + DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, + DOMConstants.DOM3_DEFAULT_FALSE); + } + + fVisitedNode = nodeArg; + } + + // Update the serializer properties + fXMLSerializer.setOutputFormat(fDOMConfigProperties); + + // + try { + + // The LSSerializer will use the LSOutput object to determine + // where to serialize the output to in the following order the + // first one that is not null and not an empty string will be + // used: 1.LSOutput.characterStream, 2.LSOutput.byteStream, + // 3. LSOutput.systemId + // 1.LSOutput.characterStream + Writer writer = destination.getCharacterStream(); + if (writer == null ) { + + // 2.LSOutput.byteStream + OutputStream outputStream = destination.getByteStream(); + if ( outputStream == null) { + + // 3. LSOutput.systemId + String uri = destination.getSystemId(); + if (uri == null) { + String msg = Utils.messages + .createMessage( + MsgKey.ER_NO_OUTPUT_SPECIFIED, + null); + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, msg, + MsgKey.ER_NO_OUTPUT_SPECIFIED)); + } + throw new LSException(LSException.SERIALIZE_ERR, msg); + + } else { + // Expand the System Id and obtain an absolute URI for it. + String absoluteURI = SystemIDResolver.getAbsoluteURI(uri); + + URL url = new URL(absoluteURI); + OutputStream urlOutStream = null; + String protocol = url.getProtocol(); + String host = url.getHost(); + + // For file protocols, there is no need to use a URL to get its + // corresponding OutputStream + + // Scheme names consist of a sequence of characters. The lower case + // letters "a"--"z", digits, and the characters plus ("+"), period + // ("."), and hyphen ("-") are allowed. For resiliency, programs + // interpreting URLs should treat upper case letters as equivalent to + // lower case in scheme names (e.g., allow "HTTP" as well as "http"). + if (protocol.equalsIgnoreCase("file") + && (host == null || host.length() == 0 || host.equals("localhost"))) { + // do we also need to check for host.equals(hostname) + urlOutStream = new FileOutputStream(new File(url.getPath())); + + } else { + // This should support URL's whose schemes are mentioned in + // RFC1738 other than file + + URLConnection urlCon = url.openConnection(); + urlCon.setDoInput(false); + urlCon.setDoOutput(true); + urlCon.setUseCaches(false); + urlCon.setAllowUserInteraction(false); + + // When writing to a HTTP URI, a HTTP PUT is performed. + if (urlCon instanceof HttpURLConnection) { + HttpURLConnection httpCon = (HttpURLConnection) urlCon; + httpCon.setRequestMethod("PUT"); + } + urlOutStream = urlCon.getOutputStream(); + } + // set the OutputStream to that obtained from the systemId + serializer.setWriter(new OutputStreamWriter(urlOutStream)); + } + } else { + // 2.LSOutput.byteStream + serializer.setWriter(new OutputStreamWriter(outputStream, fEncoding)); + } + } else { + // 1.LSOutput.characterStream + serializer.setWriter(writer); + } + + // The associated media type by default is set to text/xml on + // org.apache.xml.serializer.SerializerBase. + + // Get a reference to the serializer then lets you serilize a DOM + // Use this hack till Xalan support JAXP1.3 + if (fDOMSerializer == null) { + fDOMSerializer = (DOM3Serializer)serializer.asDOM3Serializer(); + } + + // Set the error handler on the DOM3Serializer interface implementation + if (fDOMErrorHandler != null) { + fDOMSerializer.setErrorHandler(fDOMErrorHandler); + } + + // Set the filter on the DOM3Serializer interface implementation + if (fSerializerFilter != null) { + fDOMSerializer.setNodeFilter(fSerializerFilter); + } + + // Set the NewLine character to be used + fDOMSerializer.setNewLine(fEndOfLine); + + // Serializer your DOM, where node is an org.w3c.dom.Node + // Assuming that Xalan's serializer can serialize any type of DOM node + fDOMSerializer.serializeDOM3(nodeArg); + + } catch( UnsupportedEncodingException ue) { + + String msg = Utils.messages + .createMessage( + MsgKey.ER_UNSUPPORTED_ENCODING, + null); + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, msg, + MsgKey.ER_UNSUPPORTED_ENCODING, ue)); + } + throw new LSException(LSException.SERIALIZE_ERR, ue.getMessage()); + } catch (LSException lse) { + // Rethrow LSException. + throw lse; + } catch (RuntimeException e) { + e.printStackTrace(); + throw new LSException(LSException.SERIALIZE_ERR, e!=null?e.getMessage():"NULL Exception") ; + } catch (Exception e) { + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, e.getMessage(), + null, e)); + } + e.printStackTrace(); + throw new LSException(LSException.SERIALIZE_ERR, e.toString()); + } + return true; + } + + /** + * Serializes the specified node and returns a String with the serialized + * data to the caller. + * + * @see org.w3c.dom.ls.LSSerializer#writeToString(org.w3c.dom.Node) + * @since DOM Level 3 + * @param nodeArg The Node to serialize. + * @throws org.w3c.dom.ls.LSException SERIALIZE_ERR: Raised if the + * LSSerializer was unable to serialize the node. + * + */ + public String writeToString(Node nodeArg) throws DOMException, LSException { + // return null is nodeArg is null. Should an Exception be thrown instead? + if (nodeArg == null) { + return null; + } + + // Should we reset the serializer configuration before each write operation? + // Obtain a reference to the serializer to use + Serializer serializer = fXMLSerializer; + serializer.reset(); + + if (nodeArg != fVisitedNode){ + // Determine the XML Document version of the Node + String xmlVersion = getXMLVersion(nodeArg); + + serializer.getOutputFormat().setProperty("version", xmlVersion); + + // Set the output encoding and xml version properties + fDOMConfigProperties.setProperty(DOMConstants.S_XERCES_PROPERTIES_NS + DOMConstants.S_XML_VERSION, xmlVersion); + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_ENCODING, "UTF-16"); + + // If the node to be serialized is not a Document, Element, or Entity + // node + // then the XML declaration, or text declaration, should be never be + // serialized. + if ((nodeArg.getNodeType() != Node.DOCUMENT_NODE + || nodeArg.getNodeType() != Node.ELEMENT_NODE + || nodeArg.getNodeType() != Node.ENTITY_NODE) + && ((fFeatures & XMLDECL) != 0)) { + fDOMConfigProperties.setProperty( + DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, + DOMConstants.DOM3_DEFAULT_FALSE); + } + + fVisitedNode = nodeArg; + } + // Update the serializer properties + fXMLSerializer.setOutputFormat(fDOMConfigProperties); + + // StringWriter to Output to + StringWriter output = new StringWriter(); + + // + try { + + // Set the Serializer's Writer to a StringWriter + serializer.setWriter(output); + + // Get a reference to the serializer then lets you serilize a DOM + // Use this hack till Xalan support JAXP1.3 + if (fDOMSerializer == null) { + fDOMSerializer = (DOM3Serializer)serializer.asDOM3Serializer(); + } + + // Set the error handler on the DOM3Serializer interface implementation + if (fDOMErrorHandler != null) { + fDOMSerializer.setErrorHandler(fDOMErrorHandler); + } + + // Set the filter on the DOM3Serializer interface implementation + if (fSerializerFilter != null) { + fDOMSerializer.setNodeFilter(fSerializerFilter); + } + + // Set the NewLine character to be used + fDOMSerializer.setNewLine(fEndOfLine); + + // Serializer your DOM, where node is an org.w3c.dom.Node + fDOMSerializer.serializeDOM3(nodeArg); + } catch (LSException lse) { + // Rethrow LSException. + throw lse; + } catch (RuntimeException e) { + e.printStackTrace(); + throw new LSException(LSException.SERIALIZE_ERR, e.toString()); + } catch (Exception e) { + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, e.getMessage(), + null, e)); + } + e.printStackTrace(); + throw new LSException(LSException.SERIALIZE_ERR, e.toString()); + } + + // return the serialized string + return output.toString(); + } + + /** + * Serializes the specified node to the specified URI and returns true if the Node + * was successfully serialized. + * + * @see org.w3c.dom.ls.LSSerializer#writeToURI(org.w3c.dom.Node, String) + * @since DOM Level 3 + * @param nodeArg The Node to serialize. + * @throws org.w3c.dom.ls.LSException SERIALIZE_ERR: Raised if the + * LSSerializer was unable to serialize the node. + * + */ + public boolean writeToURI(Node nodeArg, String uri) throws LSException { + // If nodeArg is null, return false. Should we throw and LSException instead? + if (nodeArg == null ) { + return false; + } + + // Obtain a reference to the serializer to use + Serializer serializer = fXMLSerializer; + serializer.reset(); + + if (nodeArg != fVisitedNode) { + // Determine the XML Document version of the Node + String xmlVersion = getXMLVersion(nodeArg); + + // Determine the encoding: 1.LSOutput.encoding, + // 2.Document.inputEncoding, 3.Document.xmlEncoding. + fEncoding = getInputEncoding(nodeArg); + if (fEncoding == null ) { + fEncoding = fEncoding != null ? fEncoding : getXMLEncoding(nodeArg) == null? "UTF-8": getXMLEncoding(nodeArg); + } + + serializer.getOutputFormat().setProperty("version", xmlVersion); + + // Set the output encoding and xml version properties + fDOMConfigProperties.setProperty(DOMConstants.S_XERCES_PROPERTIES_NS + DOMConstants.S_XML_VERSION, xmlVersion); + fDOMConfigProperties.setProperty(DOMConstants.S_XSL_OUTPUT_ENCODING, fEncoding); + + // If the node to be serialized is not a Document, Element, or Entity + // node + // then the XML declaration, or text declaration, should be never be + // serialized. + if ( (nodeArg.getNodeType() != Node.DOCUMENT_NODE + || nodeArg.getNodeType() != Node.ELEMENT_NODE + || nodeArg.getNodeType() != Node.ENTITY_NODE) + && ((fFeatures & XMLDECL) != 0)) { + fDOMConfigProperties.setProperty( + DOMConstants.S_XSL_OUTPUT_OMIT_XML_DECL, + DOMConstants.DOM3_DEFAULT_FALSE); + } + + fVisitedNode = nodeArg; + } + + // Update the serializer properties + fXMLSerializer.setOutputFormat(fDOMConfigProperties); + + // + try { + // If the specified encoding is not supported an + // "unsupported-encoding" fatal error is raised. ?? + if (uri == null) { + String msg = Utils.messages.createMessage( + MsgKey.ER_NO_OUTPUT_SPECIFIED, null); + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, msg, + MsgKey.ER_NO_OUTPUT_SPECIFIED)); + } + throw new LSException(LSException.SERIALIZE_ERR, msg); + + } else { + // REVISIT: Can this be used to get an absolute expanded URI + String absoluteURI = SystemIDResolver.getAbsoluteURI(uri); + + URL url = new URL(absoluteURI); + OutputStream urlOutStream = null; + String protocol = url.getProtocol(); + String host = url.getHost(); + + // For file protocols, there is no need to use a URL to get its + // corresponding OutputStream + + // Scheme names consist of a sequence of characters. The lower + // case letters "a"--"z", digits, and the characters plus ("+"), + // period ("."), and hyphen ("-") are allowed. For resiliency, + // programs interpreting URLs should treat upper case letters as + // equivalent to lower case in scheme names + // (e.g., allow "HTTP" as well as "http"). + if (protocol.equalsIgnoreCase("file") + && (host == null || host.length() == 0 || host + .equals("localhost"))) { + // do we also need to check for host.equals(hostname) + urlOutStream = new FileOutputStream(new File(url.getPath())); + + } else { + // This should support URL's whose schemes are mentioned in + // RFC1738 other than file + + URLConnection urlCon = url.openConnection(); + urlCon.setDoInput(false); + urlCon.setDoOutput(true); + urlCon.setUseCaches(false); + urlCon.setAllowUserInteraction(false); + + // When writing to a HTTP URI, a HTTP PUT is performed. + if (urlCon instanceof HttpURLConnection) { + HttpURLConnection httpCon = (HttpURLConnection) urlCon; + httpCon.setRequestMethod("PUT"); + } + urlOutStream = urlCon.getOutputStream(); + } + // set the OutputStream to that obtained from the systemId + serializer.setWriter(new OutputStreamWriter(urlOutStream, fEncoding)); + } + + // Get a reference to the serializer then lets you serilize a DOM + // Use this hack till Xalan support JAXP1.3 + if (fDOMSerializer == null) { + fDOMSerializer = (DOM3Serializer)serializer.asDOM3Serializer(); + } + + // Set the error handler on the DOM3Serializer interface implementation + if (fDOMErrorHandler != null) { + fDOMSerializer.setErrorHandler(fDOMErrorHandler); + } + + // Set the filter on the DOM3Serializer interface implementation + if (fSerializerFilter != null) { + fDOMSerializer.setNodeFilter(fSerializerFilter); + } + + // Set the NewLine character to be used + fDOMSerializer.setNewLine(fEndOfLine); + + // Serializer your DOM, where node is an org.w3c.dom.Node + // Assuming that Xalan's serializer can serialize any type of DOM + // node + fDOMSerializer.serializeDOM3(nodeArg); + + } catch (LSException lse) { + // Rethrow LSException. + throw lse; + } catch (RuntimeException e) { + e.printStackTrace(); + throw new LSException(LSException.SERIALIZE_ERR, e.toString()); + } catch (Exception e) { + if (fDOMErrorHandler != null) { + fDOMErrorHandler.handleError(new DOMErrorImpl( + DOMError.SEVERITY_FATAL_ERROR, e.getMessage(), + null, e)); + } + e.printStackTrace(); + throw new LSException(LSException.SERIALIZE_ERR, e.toString()); + } + + return true; + } + // ************************************************************************ + + + // ************************************************************************ + // Implementaion methods + // ************************************************************************ + + /** + * Determines the XML Version of the Document Node to serialize. If the Document Node + * is not a DOM Level 3 Node, then the default version returned is 1.0. + * + * @param nodeArg The Node to serialize + * @return A String containing the version pseudo-attribute of the XMLDecl. + * @throws Throwable if the DOM implementation does not implement Document.getXmlVersion() + */ + //protected String getXMLVersion(Node nodeArg) throws Throwable { + protected String getXMLVersion(Node nodeArg) { + Document doc = null; + + // Determine the XML Version of the document + if (nodeArg != null) { + if (nodeArg.getNodeType() == Node.DOCUMENT_NODE) { + // The Document node is the Node argument + doc = (Document)nodeArg; + } else { + // The Document node is the Node argument's ownerDocument + doc = nodeArg.getOwnerDocument(); + } + + // Determine the DOM Version. + if (doc != null && doc.getImplementation().hasFeature("Core","3.0")) { + try { + return doc.getXmlVersion(); + } catch (AbstractMethodError e) { + //ignore, impl does not support the method + } + } + } + // The version will be treated as "1.0" which may result in + // an ill-formed document being serialized. + // If nodeArg does not have an ownerDocument, treat this as XML 1.0 + return "1.0"; + } + + /** + * Determines the XML Encoding of the Document Node to serialize. If the Document Node + * is not a DOM Level 3 Node, then the default encoding "UTF-8" is returned. + * + * @param nodeArg The Node to serialize + * @return A String containing the encoding pseudo-attribute of the XMLDecl. + * @throws Throwable if the DOM implementation does not implement Document.getXmlEncoding() + */ + protected String getXMLEncoding(Node nodeArg) { + Document doc = null; + + // Determine the XML Encoding of the document + if (nodeArg != null) { + if (nodeArg.getNodeType() == Node.DOCUMENT_NODE) { + // The Document node is the Node argument + doc = (Document)nodeArg; + } else { + // The Document node is the Node argument's ownerDocument + doc = nodeArg.getOwnerDocument(); + } + + // Determine the XML Version. + if (doc != null && doc.getImplementation().hasFeature("Core","3.0")) { + return doc.getXmlEncoding(); + } + } + // The default encoding is UTF-8 except for the writeToString method + return "UTF-8"; + } + + /** + * Determines the Input Encoding of the Document Node to serialize. If the Document Node + * is not a DOM Level 3 Node, then null is returned. + * + * @param nodeArg The Node to serialize + * @return A String containing the input encoding. + */ + protected String getInputEncoding(Node nodeArg) { + Document doc = null; + + // Determine the Input Encoding of the document + if (nodeArg != null) { + if (nodeArg.getNodeType() == Node.DOCUMENT_NODE) { + // The Document node is the Node argument + doc = (Document)nodeArg; + } else { + // The Document node is the Node argument's ownerDocument + doc = nodeArg.getOwnerDocument(); + } + + // Determine the DOM Version. + if (doc != null && doc.getImplementation().hasFeature("Core","3.0")) { + return doc.getInputEncoding(); + } + } + // The default encoding returned is null + return null; + } + + /** + * This method returns the LSSerializer's error handler. + * + * @return Returns the fDOMErrorHandler. + */ + public DOMErrorHandler getErrorHandler() { + return fDOMErrorHandler; + } + +} diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/NamespaceSupport.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/NamespaceSupport.java new file mode 100644 index 00000000000..611b984f05a --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/dom3/NamespaceSupport.java @@ -0,0 +1,315 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * $Id: $ + */ + +package com.sun.org.apache.xml.internal.serializer.dom3; + +import java.util.Enumeration; +import java.util.NoSuchElementException; + +/** + * Namespace support for XML document handlers. This class doesn't + * perform any error checking and assumes that all strings passed + * as arguments to methods are unique symbols. The SymbolTable class + * can be used for this purpose. + * + * Derived from org.apache.xerces.util.NamespaceSupport + * + * @author Andy Clark, IBM + * + * @version $Id: Exp $ + */ +public class NamespaceSupport { + + static final String PREFIX_XML = "xml".intern(); + + static final String PREFIX_XMLNS = "xmlns".intern(); + + /** + * The XML Namespace ("http://www.w3.org/XML/1998/namespace"). This is + * the Namespace URI that is automatically mapped to the "xml" prefix. + */ + public final static String XML_URI = "http://www.w3.org/XML/1998/namespace".intern(); + + /** + * XML Information Set REC + * all namespace attributes (including those named xmlns, + * whose [prefix] property has no value) have a namespace URI of http://www.w3.org/2000/xmlns/ + */ + public final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/".intern(); + + // + // Data + // + + /** + * Namespace binding information. This array is composed of a + * series of tuples containing the namespace binding information: + * <prefix, uri>. The default size can be set to anything + * as long as it is a power of 2 greater than 1. + * + * @see #fNamespaceSize + * @see #fContext + */ + protected String[] fNamespace = new String[16 * 2]; + + /** The top of the namespace information array. */ + protected int fNamespaceSize; + + // NOTE: The constructor depends on the initial context size + // being at least 1. -Ac + + /** + * Context indexes. This array contains indexes into the namespace + * information array. The index at the current context is the start + * index of declared namespace bindings and runs to the size of the + * namespace information array. + * + * @see #fNamespaceSize + */ + protected int[] fContext = new int[8]; + + /** The current context. */ + protected int fCurrentContext; + + protected String[] fPrefixes = new String[16]; + + // + // Constructors + // + + /** Default constructor. */ + public NamespaceSupport() { + } // () + + // + // Public methods + // + + /** + * @see org.apache.xerces.xni.NamespaceContext#reset() + */ + public void reset() { + + // reset namespace and context info + fNamespaceSize = 0; + fCurrentContext = 0; + fContext[fCurrentContext] = fNamespaceSize; + + // bind "xml" prefix to the XML uri + fNamespace[fNamespaceSize++] = PREFIX_XML; + fNamespace[fNamespaceSize++] = XML_URI; + // bind "xmlns" prefix to the XMLNS uri + fNamespace[fNamespaceSize++] = PREFIX_XMLNS; + fNamespace[fNamespaceSize++] = XMLNS_URI; + ++fCurrentContext; + + } // reset(SymbolTable) + + + /** + * @see org.apache.xerces.xni.NamespaceContext#pushContext() + */ + public void pushContext() { + + // extend the array, if necessary + if (fCurrentContext + 1 == fContext.length) { + int[] contextarray = new int[fContext.length * 2]; + System.arraycopy(fContext, 0, contextarray, 0, fContext.length); + fContext = contextarray; + } + + // push context + fContext[++fCurrentContext] = fNamespaceSize; + + } // pushContext() + + + /** + * @see org.apache.xerces.xni.NamespaceContext#popContext() + */ + public void popContext() { + fNamespaceSize = fContext[fCurrentContext--]; + } // popContext() + + /** + * @see org.apache.xerces.xni.NamespaceContext#declarePrefix(String, String) + */ + public boolean declarePrefix(String prefix, String uri) { + // ignore "xml" and "xmlns" prefixes + if (prefix == PREFIX_XML || prefix == PREFIX_XMLNS) { + return false; + } + + // see if prefix already exists in current context + for (int i = fNamespaceSize; i > fContext[fCurrentContext]; i -= 2) { + //if (fNamespace[i - 2] == prefix) { + if (fNamespace[i - 2].equals(prefix) ) { + // REVISIT: [Q] Should the new binding override the + // previously declared binding or should it + // it be ignored? -Ac + // NOTE: The SAX2 "NamespaceSupport" helper allows + // re-bindings with the new binding overwriting + // the previous binding. -Ac + fNamespace[i - 1] = uri; + return true; + } + } + + // resize array, if needed + if (fNamespaceSize == fNamespace.length) { + String[] namespacearray = new String[fNamespaceSize * 2]; + System.arraycopy(fNamespace, 0, namespacearray, 0, fNamespaceSize); + fNamespace = namespacearray; + } + + // bind prefix to uri in current context + fNamespace[fNamespaceSize++] = prefix; + fNamespace[fNamespaceSize++] = uri; + + return true; + + } // declarePrefix(String,String):boolean + + /** + * @see org.apache.xerces.xni.NamespaceContext#getURI(String) + */ + public String getURI(String prefix) { + + // find prefix in current context + for (int i = fNamespaceSize; i > 0; i -= 2) { + //if (fNamespace[i - 2] == prefix) { + if (fNamespace[i - 2].equals(prefix) ) { + return fNamespace[i - 1]; + } + } + + // prefix not found + return null; + + } // getURI(String):String + + + /** + * @see org.apache.xerces.xni.NamespaceContext#getPrefix(String) + */ + public String getPrefix(String uri) { + + // find uri in current context + for (int i = fNamespaceSize; i > 0; i -= 2) { + //if (fNamespace[i - 1] == uri) { + if (fNamespace[i - 1].equals(uri) ) { + //if (getURI(fNamespace[i - 2]) == uri) + if (getURI(fNamespace[i - 2]).equals(uri) ) + return fNamespace[i - 2]; + } + } + + // uri not found + return null; + + } // getPrefix(String):String + + + /** + * @see org.apache.xerces.xni.NamespaceContext#getDeclaredPrefixCount() + */ + public int getDeclaredPrefixCount() { + return (fNamespaceSize - fContext[fCurrentContext]) / 2; + } // getDeclaredPrefixCount():int + + /** + * @see org.apache.xerces.xni.NamespaceContext#getDeclaredPrefixAt(int) + */ + public String getDeclaredPrefixAt(int index) { + return fNamespace[fContext[fCurrentContext] + index * 2]; + } // getDeclaredPrefixAt(int):String + + /** + * @see org.apache.xerces.xni.NamespaceContext#getAllPrefixes() + */ + public Enumeration getAllPrefixes() { + int count = 0; + if (fPrefixes.length < (fNamespace.length/2)) { + // resize prefix array + String[] prefixes = new String[fNamespaceSize]; + fPrefixes = prefixes; + } + String prefix = null; + boolean unique = true; + for (int i = 2; i < (fNamespaceSize-2); i += 2) { + prefix = fNamespace[i + 2]; + for (int k=0;k'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "An instance of the Well-Formedness checker could not be created. The well-formed parameter was set to true but well-formedness checking can not be performed." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "The node ''{0}'' contains invalid XML characters." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "An invalid XML character (Unicode: 0x{0}) was found in the comment." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "An invalid XML character (Unicode: 0x{0}) was found in the processing instructiondata." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "An invalid XML character (Unicode: 0x{0}) was found in the contents of the CDATASection." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "An invalid XML character (Unicode: 0x{0}) was found in the node''s character data content." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "An invalid XML character(s) was found in the {0} node named ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "The string \"--\" is not permitted within comments." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "The value of attribute \"{1}\" associated with an element type \"{0}\" must not contain the ''<'' character." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "The unparsed entity reference \"&{0};\" is not permitted." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "The external entity reference \"&{0};\" is not permitted in an attribute value." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "The prefix \"{0}\" can not be bound to namespace \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "The local name of element \"{0}\" is null." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "The local name of attr \"{0}\" is null." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "The replacement text of the entity node \"{0}\" contains an element node \"{1}\" with an unbound prefix \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "The replacement text of the entity node \"{0}\" contains an attribute node \"{1}\" with an unbound prefix \"{2}\"." + }, + + { MsgKey.ER_WRITING_INTERNAL_SUBSET, + "An error occured while writing the internal subset." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ca.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ca.java index 55337933552..5dd866b8bbb 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ca.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ca.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -122,7 +124,106 @@ public class SerializerMessages_ca extends ListResourceBundle { "Userinfo may not be specified if host is not specified"}, { MsgKey.ER_SCHEME_REQUIRED, - "Scheme is required!"} + "Scheme is required!"}, + + /* + * Note to translators: The words 'Properties' and + * 'SerializerFactory' in this message are Java class names + * and should not be translated. + */ + { MsgKey.ER_FACTORY_PROPERTY_MISSING, + "L''objecte de propietats passat a SerializerFactory no t\u00e9 cap propietat ''{0}''." }, + + { MsgKey.ER_ENCODING_NOT_SUPPORTED, + "Av\u00eds: el temps d''execuci\u00f3 de Java no d\u00f3na suport a la codificaci\u00f3 ''{0}''." }, + + {MsgKey.ER_FEATURE_NOT_FOUND, + "El par\u00e0metre ''{0}'' no es reconeix."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "El par\u00e0metre ''{0}'' es reconeix per\u00f2 el valor sol\u00b7licitat no es pot establir."}, + + {MsgKey.ER_STRING_TOO_LONG, + "La cadena resultant \u00e9s massa llarga per cabre en una DOMString: ''{0}''."}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "El tipus de valor per a aquest nom de par\u00e0metre \u00e9s incompatible amb el tipus de valor esperat."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "La destinaci\u00f3 de sortida per a les dades que s'ha d'escriure era nul\u00b7la."}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "S'ha trobat una codificaci\u00f3 no suportada."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "El node no s'ha pogut serialitzat."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "La secci\u00f3 CDATA cont\u00e9 un o m\u00e9s marcadors d'acabament ']]>'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "No s'ha pogut crear cap inst\u00e0ncia per comprovar si t\u00e9 un format correcte o no. El par\u00e0metre del tipus ben format es va establir en cert, per\u00f2 la comprovaci\u00f3 de format no s'ha pogut realitzar." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "El node ''{0}'' cont\u00e9 car\u00e0cters XML no v\u00e0lids." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "S''ha trobat un car\u00e0cter XML no v\u00e0lid (Unicode: 0x{0}) en el comentari." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "S''ha trobat un car\u00e0cter XML no v\u00e0lid (Unicode: 0x{0}) en les dades d''instrucci\u00f3 de proc\u00e9s." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "S''ha trobat un car\u00e0cter XML no v\u00e0lid (Unicode: 0x''{0})'' en els continguts de la CDATASection." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "S''ha trobat un car\u00e0cter XML no v\u00e0lid (Unicode: 0x''{0})'' en el contingut de dades de car\u00e0cter del node." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "S''han trobat car\u00e0cters XML no v\u00e0lids al node {0} anomenat ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "La cadena \"--\" no est\u00e0 permesa dins dels comentaris." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "El valor d''atribut \"{1}\" associat amb un tipus d''element \"{0}\" no pot contenir el car\u00e0cter ''<''." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "La refer\u00e8ncia de l''entitat no analitzada \"&{0};\" no est\u00e0 permesa." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "La refer\u00e8ncia externa de l''entitat \"&{0};\" no est\u00e0 permesa en un valor d''atribut." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "El prefix \"{0}\" no es pot vincular a l''espai de noms \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "El nom local de l''element \"{0}\" \u00e9s nul." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "El nom local d''atr \"{0}\" \u00e9s nul." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "El text de recanvi del node de l''entitat \"{0}\" cont\u00e9 un node d''element \"{1}\" amb un prefix de no enlla\u00e7at \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "El text de recanvi del node de l''entitat \"{0}\" cont\u00e9 un node d''atribut \"{1}\" amb un prefix de no enlla\u00e7at \"{2}\"." + }, }; return contents; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_cs.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_cs.java index 5c6977c79dd..ef7c3236b1c 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_cs.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_cs.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 1999-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -114,7 +116,106 @@ public class SerializerMessages_cs extends ListResourceBundle { "Nen\u00ed-li ur\u010den hostitel, nelze zadat \u00fadaje o u\u017eivateli."}, { MsgKey.ER_SCHEME_REQUIRED, - "Je vy\u017eadov\u00e1no sch\u00e9ma!"} + "Je vy\u017eadov\u00e1no sch\u00e9ma!"}, + + /* + * Note to translators: The words 'Properties' and + * 'SerializerFactory' in this message are Java class names + * and should not be translated. + */ + { MsgKey.ER_FACTORY_PROPERTY_MISSING, + "Objekt vlastnost\u00ed p\u0159edan\u00fd faktorii SerializerFactory neobsahuje vlastnost ''{0}''. " }, + + { MsgKey.ER_ENCODING_NOT_SUPPORTED, + "Varov\u00e1n\u00ed: K\u00f3dov\u00e1n\u00ed ''{0}'' nen\u00ed v b\u011bhov\u00e9m prost\u0159ed\u00ed Java podporov\u00e1no." }, + + {MsgKey.ER_FEATURE_NOT_FOUND, + "Parametr ''{0}'' nebyl rozpozn\u00e1n."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "Parametr ''{0}'' byl rozpozn\u00e1n, ale nelze nastavit po\u017eadovanou hodnotu."}, + + {MsgKey.ER_STRING_TOO_LONG, + "V\u00fdsledn\u00fd \u0159et\u011bzec je p\u0159\u00edli\u0161 dlouh\u00fd pro \u0159et\u011bzec DOMString: ''{0}''."}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "Typ hodnoty pro tento n\u00e1zev parametru nen\u00ed kompatibiln\u00ed s o\u010dek\u00e1van\u00fdm typem hodnoty."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "C\u00edlov\u00e9 um\u00edst\u011bn\u00ed v\u00fdstupu pro data ur\u010den\u00e1 k z\u00e1pisu je rovno hodnot\u011b Null. "}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "Bylo nalezeno nepodporovan\u00e9 k\u00f3dov\u00e1n\u00ed."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "Nelze prov\u00e9st serializaci uzlu. "}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "Sekce CDATA obsahuje jednu nebo v\u00edce ukon\u010dovac\u00edch zna\u010dek ']]>'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "Nelze vytvo\u0159it instanci modulu pro kontrolu spr\u00e1vn\u00e9ho utvo\u0159en\u00ed. Parametr spr\u00e1vn\u00e9ho utvo\u0159en\u00ed byl nastaven na hodnotu true, nepoda\u0159ilo se v\u0161ak zkontrolovat spr\u00e1vnost utvo\u0159en\u00ed. " + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "Uzel ''{0}'' obsahuje neplatn\u00e9 znaky XML. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "V pozn\u00e1mce byl zji\u0161t\u011bn neplatn\u00fd znak XML (Unicode: 0x{0})." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "V datech instrukce zpracov\u00e1n\u00ed byl nalezen neplatn\u00fd znak XML (Unicode: 0x{0})." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "V odd\u00edlu CDATASection byl nalezen neplatn\u00fd znak XML (Unicode: 0x{0})." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "V obsahu znakov\u00fdch dat uzlu byl nalezen neplatn\u00fd znak XML (Unicode: 0x{0})." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "V objektu {0} s n\u00e1zvem ''{1}'' byl nalezen neplatn\u00fd znak XML. " + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "V pozn\u00e1mk\u00e1ch nen\u00ed povolen \u0159et\u011bzec \"--\"." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "Hodnota atributu \"{1}\" souvisej\u00edc\u00edho s typem prvku \"{0}\" nesm\u00ed obsahovat znak ''<''." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "Odkaz na neanalyzovanou entitu \"&{0};\" nen\u00ed povolen." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "Extern\u00ed odkaz na entitu \"&{0};\" nen\u00ed v hodnot\u011b atributu povolen." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "P\u0159edpona \"{0}\" nesm\u00ed b\u00fdt v\u00e1zan\u00e1 k oboru n\u00e1zv\u016f \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "Lok\u00e1ln\u00ed n\u00e1zev prvku \"{0}\" m\u00e1 hodnotu Null. " + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "Lok\u00e1ln\u00ed n\u00e1zev atributu \"{0}\" m\u00e1 hodnotu Null. " + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "Nov\u00fd text uzlu entity \"{0}\" obsahuje uzel prvku \"{1}\" s nesv\u00e1zanou p\u0159edponou \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "Nov\u00fd text uzlu entity \"{0}\" obsahuje uzel atributu \"{1}\" s nesv\u00e1zanou p\u0159edponou \"{2}\". " + }, }; return contents; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_de.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_de.java index 20e8a4de7b8..6d3fea66a20 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_de.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_de.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_de extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "Warnung: Die Codierung \"{0}\" wird nicht von der Java-Laufzeit unterst\u00FCtzt." }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "Der Parameter ''{0}'' wird nicht erkannt."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "Der Parameter ''{0}'' wird erkannt, der angeforderte Wert kann jedoch nicht festgelegt werden."}, + + {MsgKey.ER_STRING_TOO_LONG, + "Die Ergebniszeichenfolge ist zu lang f\u00fcr eine DOM-Zeichenfolge: ''{0}''."}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "Der Werttyp f\u00fcr diesen Parameternamen ist nicht kompatibel mit dem erwarteten Werttyp."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "Das Ausgabeziel f\u00fcr die zu schreibenden Daten war leer."}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "Eine nicht unterst\u00fctzte Codierung wurde festgestellt."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "Der Knoten konnte nicht serialisiert werden."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "Der Abschnitt CDATA enth\u00e4lt mindestens eine Beendigungsmarkierung ']]>'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "Eine Instanz des Pr\u00fcfprogramms f\u00fcr korrekte Formatierung konnte nicht erstellt werden. F\u00fcr den korrekt formatierten Parameter wurde der Wert 'True' festgelegt, die Pr\u00fcfung auf korrekte Formatierung kann jedoch nicht durchgef\u00fchrt werden." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "Der Knoten ''{0}'' enth\u00e4lt ung\u00fcltige XML-Zeichen." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "Im Kommentar wurde ein ung\u00fcltiges XML-Zeichen (Unicode: 0x{0}) gefunden." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "In der Verarbeitungsanweisung wurde ein ung\u00fcltiges XML-Zeichen (Unicode: 0x{0}) gefunden." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "Im Inhalt von CDATASection wurde ein ung\u00fcltiges XML-Zeichen (Unicode: 0x{0}) gefunden." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "Ein ung\u00fcltiges XML-Zeichen (Unicode: 0x{0}) wurde im Inhalt der Zeichendaten des Knotens gefunden." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "Ung\u00fcltige XML-Zeichen wurden gefunden in {0} im Knoten ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "Die Zeichenfolge \"--\" ist innerhalb von Kommentaren nicht zul\u00e4ssig." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "Der Wert des Attributs \"{1}\" mit einem Elementtyp \"{0}\" darf nicht das Zeichen ''<'' enthalten." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "Der syntaktisch nicht analysierte Entit\u00e4tenverweis \"&{0};\" ist nicht zul\u00e4ssig." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "Der externe Entit\u00e4tenverweis \"&{0};\" ist in einem Attributwert nicht zul\u00e4ssig." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "Das Pr\u00e4fix \"{0}\" kann nicht an den Namensbereich \"{1}\" gebunden werden." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "Der lokale Name von Element \"{0}\" ist nicht angegeben." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "Der lokale Name des Attributs \"{0}\" ist nicht angegeben." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "Der Ersatztext des Entit\u00e4tenknotens \"{0}\" enth\u00e4lt einen Elementknoten \"{1}\" mit einem nicht gebundenen Pr\u00e4fix \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "Der Ersatztext des Entit\u00e4tenknotens \"{0}\" enth\u00e4lt einen Attributknoten \"{1}\" mit einem nicht gebundenen Pr\u00e4fix \"{2}\"." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_es.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_es.java index 4628321c2a0..c942361102b 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_es.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_es.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -198,8 +200,95 @@ public class SerializerMessages_es extends ListResourceBundle { "El objeto de propiedades transferido a SerializerFactory no tiene una propiedad ''{0}''." }, { MsgKey.ER_ENCODING_NOT_SUPPORTED, - "Advertencia: el tiempo de ejecuci\u00F3n de Java no soporta la codificaci\u00F3n ''{0}''." }, + "Aviso: La codificaci\u00f3n ''{0}'' no est\u00e1 soportada por Java Runtime." }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "El par\u00e1metro ''{0}'' no se reconoce."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "Se reconoce el par\u00e1metro ''{0}'' pero no puede establecerse el valor solicitado."}, + + {MsgKey.ER_STRING_TOO_LONG, + "La serie producida es demasiado larga para ajustarse a DOMString: ''{0}''."}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "El tipo de valor para este nombre de par\u00e1metro es incompatible con el tipo de valor esperado."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "El destino de salida de escritura de los datos es nulo."}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "Se ha encontrado una codificaci\u00f3n no soportada."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "No se ha podido serializar el nodo."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "La secci\u00f3n CDATA contiene uno o m\u00e1s marcadores ']]>' de terminaci\u00f3n."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "No se ha podido crear una instancia del comprobador de gram\u00e1tica correcta. El par\u00e1metro well-formed se ha establecido en true pero no se puede realizar la comprobaci\u00f3n de gram\u00e1tica correcta." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "El nodo ''{0}'' contiene caracteres XML no v\u00e1lidos." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "Se ha encontrado un car\u00e1cter XML no v\u00e1lido (Unicode: 0x{0}) en el comentario." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "Se ha encontrado un car\u00e1cter XML no v\u00e1lido (Unicode: 0x{0}) en los datos de la instrucci\u00f3n de proceso." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "Se ha encontrado un car\u00e1cter XML no v\u00e1lido (Unicode: 0x{0}) en el contenido de CDATASection." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "Se ha encontrado un car\u00e1cter XML no v\u00e1lido (Unicode: 0x{0}) en el contenido de datos de caracteres del nodo." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "Se ha encontrado un car\u00e1cter o caracteres XML no v\u00e1lidos en el nodo {0} denominado ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "No se permite la serie \"--\" dentro de los comentarios." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "El valor del atributo \"{1}\" asociado a un tipo de elemento \"{0}\" no debe contener el car\u00e1cter ''''<''''." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "No se permite la referencia de entidad no analizada \"&{0};\"." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "La referencia de entidad externa \"&{0};\" no est\u00e1 permitida en un valor de atributo." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "No se puede encontrar el prefijo \"{0}\" en el espacio de nombres \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "El nombre local del elemento \"{0}\" es null." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "El nombre local del atributo \"{0}\" es null." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "El texto de sustituci\u00f3n del nodo de entidad \"{0}\" contiene un nodo de elemento \"{1}\" con un prefijo no enlazado \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "El texto de sustituci\u00f3n del nodo de entidad \"{0}\" contiene un nodo de atributo \"{1}\" con un prefijo no enlazado \"{2}\"." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_fr.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_fr.java index 97fb91fea96..0998038064e 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_fr.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_fr.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_fr extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "Avertissement : l''encodage ''{0}'' n''est pas pris en charge par l''ex\u00E9cution Java." }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "Le param\u00e8tre ''{0}'' n''est pas reconnu."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "Le param\u00e8tre ''{0}'' est reconnu mas la valeur demand\u00e9e ne peut pas \u00eatre d\u00e9finie."}, + + {MsgKey.ER_STRING_TOO_LONG, + "La cha\u00eene obtenue est trop longue pour un DOMString : ''{0}''."}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "Le type de valeur de ce param\u00e8tre est incompatible avec le type de valeur attendu."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "La sortie de destination des donn\u00e9es \u00e0 \u00e9crire \u00e9tait vide."}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "Codage non pris en charge."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "Le noeud ne peut pas \u00eatre s\u00e9rialis\u00e9."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "La section CDATA contient un ou plusieurs marqueurs de fin ']]>'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "Aucune instance du programme de v\u00e9rification de la formation n'a pu \u00eatre cr\u00e9\u00e9e. La valeur true a \u00e9t\u00e9 attribu\u00e9e au param\u00e8tre well-formed mais la v\u00e9rification de la formation n'a pas pu \u00eatre effectu\u00e9e." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "Le noeud ''{0}'' contient des caract\u00e8res XML non valides." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "Un caract\u00e8re XML non valide (Unicode : 0x{0}) a \u00e9t\u00e9 trouv\u00e9 dans le commentaire." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "Un caract\u00e8re XML non valide (Unicode : 0x{0}) a \u00e9t\u00e9 trouv\u00e9 dans les donn\u00e9es de l''instruction de traitement." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "Un caract\u00e8re XML non valide (Unicode: 0x{0}) a \u00e9t\u00e9 trouv\u00e9 dans le contenu de la CDATASection" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "Un caract\u00e8re XML non valide (Unicode : 0x{0}) a \u00e9t\u00e9 trouv\u00e9 dans le contenu des donn\u00e9es de type caract\u00e8res du noeud." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "Un ou plusieurs caract\u00e8res non valides ont \u00e9t\u00e9 trouv\u00e9s dans le noeud {0} nomm\u00e9 ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "La cha\u00eene \"--\" est interdite dans des commentaires." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "La valeur de l''attribut \"{1}\" associ\u00e9 \u00e0 un type d''\u00e9l\u00e9ment \"{0}\" ne doit pas contenir le caract\u00e8re ''<''." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "La r\u00e9f\u00e9rence d''entit\u00e9 non analys\u00e9e \"&{0};\" n''est pas admise." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "La r\u00e9f\u00e9rence d''entit\u00e9 externe \"&{0};\" n''est pas admise dans une valeur d''attribut." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "Le pr\u00e9fixe \"{0}\" ne peut pas \u00eatre li\u00e9 \u00e0 l''espace de noms \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "Le nom local de l''\u00e9l\u00e9ment \"{0}\" a une valeur null." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "Le nom local de l''attribut \"{0}\" a une valeur null." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "le texte de remplacement du noeud de l''entit\u00e9 \"{0}\" contaient un noeud d''\u00e9l\u00e9ment \"{1}\" avec un pr\u00e9fixe non li\u00e9 \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "Le texte de remplacement du noeud de l''entit\u00e9 \"{0}\" contient un noeud d''attribut \"{1}\" avec un pr\u00e9fixe non li\u00e9 \"{2}\"." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_it.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_it.java index 6d3977af38c..37556dfccfd 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_it.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_it.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_it extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "Avvertenza: la codifica ''{0}'' non \u00E8 supportata da Java Runtime." }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "Il parametro ''{0}'' non \u00e8 riconosciuto."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "Il parametro ''{0}'' \u00e8 riconosciuto ma non \u00e8 possibile impostare il valore richiesto."}, + + {MsgKey.ER_STRING_TOO_LONG, + "La stringa risultante \u00e8 troppo lunga per essere inserita in DOMString: ''{0}''."}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "Il tipo di valore per questo nome di parametro non \u00e8 compatibile con il tipo di valore previsto."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "La destinazione di output in cui scrivere i dati era nulla."}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "\u00c8 stata rilevata una codifica non supportata."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "Impossibile serializzare il nodo."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "La Sezione CDATA contiene uno o pi\u00f9 markers di termine ']]>'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "Impossibile creare un'istanza del controllore Well-Formedness. Il parametro well-formed \u00e8 stato impostato su true ma non \u00e8 possibile eseguire i controlli well-formedness." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "Il nodo ''{0}'' contiene caratteri XML non validi." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "Trovato un carattere XML non valido (Unicode: 0x{0}) nel commento." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "Carattere XML non valido (Unicode: 0x{0}) rilevato nell''elaborazione di instructiondata." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "Carattere XML non valido (Unicode: 0x{0}) rilevato nel contenuto di CDATASection." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "Carattere XML non valido (Unicode: 0x{0}) rilevato nel contenuto dati di caratteri del nodo. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "Carattere XML non valido rilevato nel nodo {0} denominato ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "La stringa \"--\" non \u00e8 consentita nei commenti." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "Il valore dell''''attributo \"{1}\" associato con un tipo di elemento \"{0}\" non deve contenere il carattere ''<''." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "Il riferimento entit\u00e0 non analizzata \"&{0};\" non \u00e8 permesso." + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "Il riferimento all''''entit\u00e0 esterna \"&{0};\" non \u00e8 permesso in un valore attributo." + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "Il prefisso \"{0}\" non pu\u00f2 essere associato allo spazio nome \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "Il nome locale dell''''elemento \"{0}\" \u00e8 null." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "Il nome locale dell''''attributo \"{0}\" \u00e8 null." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "Il testo di sostituzione del nodo di entit\u00e0 \"{0}\" contiene un nodo di elemento \"{1}\" con un prefisso non associato \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "Il testo di sostituzione del nodo di entit\u00e0 \"{0}\" contiene un nodo di attributo \"{1}\" con un prefisso non associato \"{2}\"." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ja.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ja.java index 069c9f8b2d7..0c3612f820a 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ja.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ja.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_ja extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "\u8B66\u544A: \u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0''{0}''\u306F\u3001Java\u30E9\u30F3\u30BF\u30A4\u30E0\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002" }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc ''{0}'' \u306f\u8a8d\u8b58\u3055\u308c\u307e\u305b\u3093\u3002"}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc ''{0}'' \u306f\u8a8d\u8b58\u3055\u308c\u307e\u3059\u304c\u3001\u8981\u6c42\u3055\u308c\u305f\u5024\u306f\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002"}, + + {MsgKey.ER_STRING_TOO_LONG, + "\u7d50\u679c\u306e\u30b9\u30c8\u30ea\u30f3\u30b0\u304c\u9577\u3059\u304e\u308b\u305f\u3081\u3001DOMString \u5185\u306b\u53ce\u307e\u308a\u307e\u305b\u3093: ''{0}''\u3002"}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "\u3053\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u540d\u306e\u5024\u306e\u578b\u306f\u3001\u671f\u5f85\u3055\u308c\u308b\u5024\u306e\u578b\u3068\u4e0d\u9069\u5408\u3067\u3059\u3002"}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "\u66f8\u304d\u8fbc\u307e\u308c\u308b\u30c7\u30fc\u30bf\u306e\u51fa\u529b\u5b9b\u5148\u304c\u30cc\u30eb\u3067\u3059\u3002"}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u306a\u3044\u30a8\u30f3\u30b3\u30fc\u30c9\u304c\u691c\u51fa\u3055\u308c\u307e\u3057\u305f\u3002"}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "\u30ce\u30fc\u30c9\u3092\u76f4\u5217\u5316\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002"}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "CDATA \u30bb\u30af\u30b7\u30e7\u30f3\u306b 1 \u3064\u4ee5\u4e0a\u306e\u7d42\u4e86\u30de\u30fc\u30ab\u30fc ']]>' \u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002"}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "\u6574\u5f62\u5f0f\u6027\u30c1\u30a7\u30c3\u30ab\u30fc\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 well-formed \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u8a2d\u5b9a\u306f true \u3067\u3057\u305f\u304c\u3001\u6574\u5f62\u5f0f\u6027\u306e\u691c\u67fb\u306f\u5b9f\u884c\u3067\u304d\u307e\u305b\u3093\u3002" + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "\u30ce\u30fc\u30c9 ''{0}'' \u306b\u7121\u52b9\u306a XML \u6587\u5b57\u304c\u3042\u308a\u307e\u3059\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "\u30b3\u30e1\u30f3\u30c8\u306e\u4e2d\u306b\u7121\u52b9\u306a XML \u6587\u5b57 (Unicode: 0x{0}) \u304c\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "\u51e6\u7406\u547d\u4ee4\u30c7\u30fc\u30bf\u306e\u4e2d\u306b\u7121\u52b9\u306a XML \u6587\u5b57 (Unicode: 0x{0}) \u304c\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "CDATA \u30bb\u30af\u30b7\u30e7\u30f3\u306e\u4e2d\u306b\u7121\u52b9\u306a XML \u6587\u5b57 (Unicode: 0x{0}) \u304c\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "\u30ce\u30fc\u30c9\u306e\u6587\u5b57\u30c7\u30fc\u30bf\u306e\u5185\u5bb9\u306b\u7121\u52b9\u306a XML \u6587\u5b57 (Unicode: 0x{0}) \u304c\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "''{1}'' \u3068\u3044\u3046\u540d\u524d\u306e {0} \u30ce\u30fc\u30c9\u306e\u4e2d\u306b\u7121\u52b9\u306a XML \u6587\u5b57\u304c\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002" + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "\u30b9\u30c8\u30ea\u30f3\u30b0 \"--\" \u306f\u30b3\u30e1\u30f3\u30c8\u5185\u3067\u306f\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002" + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "\u8981\u7d20\u578b \"{0}\" \u306b\u95a2\u9023\u3057\u305f\u5c5e\u6027 \"{1}\" \u306e\u5024\u306b\u306f ''<'' \u6587\u5b57\u3092\u542b\u3081\u3066\u306f\u3044\u3051\u307e\u305b\u3093\u3002" + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "\u89e3\u6790\u5bfe\u8c61\u5916\u5b9f\u4f53\u53c2\u7167 \"&{0};\" \u306f\u8a31\u53ef\u3055\u308c\u307e\u305b\u3093\u3002" + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "\u5c5e\u6027\u5024\u3067\u306e\u5916\u90e8\u5b9f\u4f53\u53c2\u7167 \"&{0};\" \u306f\u8a31\u53ef\u3055\u308c\u307e\u305b\u3093\u3002" + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "\u63a5\u982d\u90e8 \"{0}\" \u306f\u540d\u524d\u7a7a\u9593 \"{1}\" \u306b\u7d50\u5408\u3067\u304d\u307e\u305b\u3093\u3002" + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "\u8981\u7d20 \"{0}\" \u306e\u30ed\u30fc\u30ab\u30eb\u540d\u304c\u30cc\u30eb\u3067\u3059\u3002" + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "\u5c5e\u6027 \"{0}\" \u306e\u30ed\u30fc\u30ab\u30eb\u540d\u304c\u30cc\u30eb\u3067\u3059\u3002" + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "\u5b9f\u4f53\u30ce\u30fc\u30c9 \"{0}\" \u306e\u7f6e\u63db\u30c6\u30ad\u30b9\u30c8\u306b\u3001\u672a\u7d50\u5408\u306e\u63a5\u982d\u90e8 \"{2}\" \u3092\u6301\u3064\u8981\u7d20\u30ce\u30fc\u30c9 \"{1}\" \u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002" + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "\u5b9f\u4f53\u30ce\u30fc\u30c9 \"{0}\" \u306e\u7f6e\u63db\u30c6\u30ad\u30b9\u30c8\u306b\u3001\u672a\u7d50\u5408\u306e\u63a5\u982d\u90e8 \"{2}\" \u3092\u6301\u3064\u5c5e\u6027\u30ce\u30fc\u30c9 \"{1}\" \u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002" + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ko.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ko.java index 90750d5245e..410dcadf72c 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ko.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_ko.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_ko extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "\uACBD\uACE0: \uC778\uCF54\uB529 ''{0}''\uC740(\uB294) Java \uB7F0\uD0C0\uC784\uC5D0 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "''{0}'' \ub9e4\uac1c\ubcc0\uc218\ub97c \uc778\uc2dd\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "''{0}'' \ub9e4\uac1c\ubcc0\uc218\ub294 \uc778\uc2dd\ud560 \uc218 \uc788\uc73c\ub098 \uc694\uccad\ub41c \uac12\uc744 \uc124\uc815\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4."}, + + {MsgKey.ER_STRING_TOO_LONG, + "\uacb0\uacfc \ubb38\uc790\uc5f4\uc774 \ub108\ubb34 \uae38\uc5b4 DOMString\uc5d0 \ub9de\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4: ''{0}'' "}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "\uc774 \ub9e4\uac1c\ubcc0\uc218 \uc774\ub984\uc5d0 \ub300\ud55c \uac12 \uc720\ud615\uc774 \uc608\uc0c1 \uac12 \uc720\ud615\uacfc \ud638\ud658\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4."}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "\ub370\uc774\ud130\ub97c \uae30\ub85d\ud560 \ucd9c\ub825 \ub300\uc0c1\uc774 \ub110(null)\uc785\ub2c8\ub2e4."}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "\uc9c0\uc6d0\ub418\uc9c0 \uc54a\ub294 \uc778\ucf54\ub529\uc774 \ubc1c\uacac\ub418\uc5c8\uc2b5\ub2c8\ub2e4."}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "\ub178\ub4dc\ub97c \uc9c1\ub82c\ud654\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "CDATA \uc139\uc158\uc5d0 \uc885\ub8cc \ud45c\uc2dc \ubb38\uc790\uc778 ']]>'\uac00 \ud558\ub098 \uc774\uc0c1 \ud3ec\ud568\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "Well-Formedness \uac80\uc0ac\uae30\uc758 \uc778\uc2a4\ud134\uc2a4\ub97c \uc791\uc131\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. Well-Formed \ub9e4\uac1c\ubcc0\uc218\uac00 true\ub85c \uc124\uc815\ub418\uc5c8\uc9c0\ub9cc Well-Formedness \uac80\uc0ac\ub97c \uc218\ud589\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "''{0}'' \ub178\ub4dc\uc5d0 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 XML \ubb38\uc790\uac00 \uc788\uc2b5\ub2c8\ub2e4." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "\uc124\uba85\uc5d0 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 XML \ubb38\uc790(Unicode: 0x{0})\uac00 \uc788\uc2b5\ub2c8\ub2e4. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "\ucc98\ub9ac \uba85\ub839\uc5b4 \ub370\uc774\ud130\uc5d0 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 XML \ubb38\uc790(Unicode: 0x{0})\uac00 \uc788\uc2b5\ub2c8\ub2e4 " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "CDATASection\uc758 \ub0b4\uc6a9\uc5d0 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 XML \ubb38\uc790(Unicode: 0x{0})\uac00 \uc788\uc2b5\ub2c8\ub2e4. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "\ub178\ub4dc\uc758 \ubb38\uc790 \ub370\uc774\ud130 \ub0b4\uc6a9\uc5d0 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 XML \ubb38\uc790(Unicode: 0x{0})\uac00 \uc788\uc2b5\ub2c8\ub2e4. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "\uc774\ub984\uc774 ''{1}''\uc778 {0} \ub178\ub4dc\uc5d0 \uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 XML \ubb38\uc790\uac00 \uc788\uc2b5\ub2c8\ub2e4. " + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "\uc124\uba85 \ub0b4\uc5d0\uc11c\ub294 \"--\" \ubb38\uc790\uc5f4\uc774 \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4." + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "\"{0}\" \uc694\uc18c \uc720\ud615\uacfc \uc5f0\uad00\ub41c \"{1}\" \uc18d\uc131\uac12\uc5d0 ''<'' \ubb38\uc790\uac00 \ud3ec\ud568\ub418\uba74 \uc548\ub429\ub2c8\ub2e4." + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "\"&{0};\"\uc758 \uad6c\ubd84 \ubd84\uc11d\ub418\uc9c0 \uc54a\uc740 \uc5d4\ud2f0\ud2f0 \ucc38\uc870\ub294 \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. " + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "\uc18d\uc131\uac12\uc5d0\ub294 \"&{0};\" \uc678\ubd80 \uc5d4\ud2f0\ud2f0 \ucc38\uc870\uac00 \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. " + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "\"{0}\" \uc811\ub450\ubd80\ub97c \"{1}\" \uc774\ub984 \uacf5\uac04\uc5d0 \ubc14\uc778\ub4dc\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "\"{0}\" \uc694\uc18c\uc758 \ub85c\uceec \uc774\ub984\uc774 \ub110(null)\uc785\ub2c8\ub2e4." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "\"{0}\" \uc18d\uc131\uc758 \ub85c\uceec \uc774\ub984\uc774 \ub110(null)\uc785\ub2c8\ub2e4." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "\"{0}\" \uc5d4\ud2f0\ud2f0 \ub178\ub4dc\uc758 \ub300\uccb4 \ud14d\uc2a4\ud2b8\uc5d0 \ubc14\uc778\ub4dc\ub418\uc9c0 \uc54a\uc740 \uc811\ub450\ubd80 \"{2}\"\uc744(\ub97c) \uac16\ub294 \"{1}\" \uc694\uc18c \ub178\ub4dc\uac00 \uc788\uc2b5\ub2c8\ub2e4." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "\"{0}\" \uc5d4\ud2f0\ud2f0 \ub178\ub4dc\uc758 \ub300\uccb4 \ud14d\uc2a4\ud2b8\uc5d0 \ubc14\uc778\ub4dc\ub418\uc9c0 \uc54a\uc740 \uc811\ub450\ubd80 \"{2}\"\uc744(\ub97c) \uac16\ub294 \"{1}\" \uc18d\uc131 \ub178\ub4dc\uac00 \uc788\uc2b5\ub2c8\ub2e4." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_pt_BR.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_pt_BR.java index 41949ddbf55..a65026f3d51 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_pt_BR.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_pt_BR.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_pt_BR extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "Advert\u00EAncia: a codifica\u00E7\u00E3o ''{0}'' n\u00E3o \u00E9 suportada pelo Java runtime." }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "O par\u00e2metro ''{0}'' n\u00e3o \u00e9 reconhecido."}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "O par\u00e2metro ''{0}'' \u00e9 reconhecido, mas o valor pedido n\u00e3o pode ser definido. "}, + + {MsgKey.ER_STRING_TOO_LONG, + "A cadeia resultante \u00e9 muito longa para caber em uma DOMString: ''{0}''. "}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "O tipo de valor para este nome de par\u00e2metro \u00e9 incompat\u00edvel com o tipo de valor esperado. "}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "O destino de sa\u00edda para os dados a serem gravados era nulo. "}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "Uma codifica\u00e7\u00e3o n\u00e3o suportada foi encontrada. "}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "O n\u00f3 n\u00e3o p\u00f4de ser serializado."}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "A Se\u00e7\u00e3o CDATA cont\u00e9m um ou mais marcadores de t\u00e9rmino ']]>'."}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "Uma inst\u00e2ncia do verificador Well-Formedness n\u00e3o p\u00f4de ser criada. O par\u00e2metro well-formed foi definido como true, mas a verifica\u00e7\u00e3o well-formedness n\u00e3o pode ser executada." + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "O n\u00f3 ''{0}'' cont\u00e9m caracteres XML inv\u00e1lidos. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "Um caractere XML inv\u00e1lido (Unicode: 0x{0}) foi encontrado no coment\u00e1rio. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "Um caractere XML inv\u00e1lido (Unicode: 0x{0}) foi encontrado no processo instructiondata." + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "Um caractere XML inv\u00e1lido (Unicode: 0x{0}) foi encontrado nos conte\u00fados do CDATASection. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "Um caractere XML inv\u00e1lido (Unicode: 0x{0}) foi encontrado no conte\u00fado dos dados de caractere dos n\u00f3s. " + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "Um caractere inv\u00e1lido foi encontrado no {0} do n\u00f3 denominado ''{1}''." + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "A cadeia \"--\" n\u00e3o \u00e9 permitida dentro dos coment\u00e1rios. " + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "O valor do atributo \"{1}\" associado a um tipo de elemento \"{0}\" n\u00e3o deve conter o caractere ''<''. " + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "A refer\u00eancia de entidade n\u00e3o analisada \"&{0};\" n\u00e3o \u00e9 permitida. " + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "A refer\u00eancia de entidade externa \"&{0};\" n\u00e3o \u00e9 permitida em um valor de atributo. " + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "O prefixo \"{0}\" n\u00e3o pode ser vinculado ao espa\u00e7o de nomes \"{1}\"." + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "O nome local do elemento \"{0}\" \u00e9 nulo." + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "O nome local do atributo \"{0}\" \u00e9 nulo." + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "O texto de substitui\u00e7\u00e3o do n\u00f3 de entidade \"{0}\" cont\u00e9m um n\u00f3 de elemento \"{1}\" com um prefixo n\u00e3o vinculado \"{2}\"." + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "O texto de substitui\u00e7\u00e3o do n\u00f3 de entidade \"{0}\" cont\u00e9m um n\u00f3 de atributo \"{1}\" com um prefixo n\u00e3o vinculado \"{2}\"." + }, }; diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_zh_TW.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_zh_TW.java index f1f64f1acb4..9d3e4996846 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_zh_TW.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/SerializerMessages_zh_TW.java @@ -3,9 +3,11 @@ * DO NOT REMOVE OR ALTER! */ /* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -200,6 +202,93 @@ public class SerializerMessages_zh_TW extends ListResourceBundle { { MsgKey.ER_ENCODING_NOT_SUPPORTED, "\u8B66\u544A: Java Runtime \u4E0D\u652F\u63F4\u7DE8\u78BC ''{0}''\u3002" }, + {MsgKey.ER_FEATURE_NOT_FOUND, + "\u7121\u6cd5\u8fa8\u8b58\u53c3\u6578 ''{0}''\u3002"}, + + {MsgKey.ER_FEATURE_NOT_SUPPORTED, + "\u53ef\u8fa8\u8b58 ''{0}'' \u53c3\u6578\uff0c\u4f46\u6240\u8981\u6c42\u7684\u503c\u7121\u6cd5\u8a2d\u5b9a\u3002"}, + + {MsgKey.ER_STRING_TOO_LONG, + "\u7d50\u679c\u5b57\u4e32\u904e\u9577\uff0c\u7121\u6cd5\u7f6e\u5165 DOMString: ''{0}'' \u4e2d\u3002"}, + + {MsgKey.ER_TYPE_MISMATCH_ERR, + "\u9019\u500b\u53c3\u6578\u540d\u7a31\u7684\u503c\u985e\u578b\u8207\u671f\u671b\u503c\u985e\u578b\u4e0d\u76f8\u5bb9\u3002"}, + + {MsgKey.ER_NO_OUTPUT_SPECIFIED, + "\u8cc7\u6599\u8981\u5beb\u5165\u7684\u8f38\u51fa\u76ee\u7684\u5730\u70ba\u7a7a\u503c\u3002"}, + + {MsgKey.ER_UNSUPPORTED_ENCODING, + "\u767c\u73fe\u4e0d\u652f\u63f4\u7684\u7de8\u78bc\u3002"}, + + {MsgKey.ER_UNABLE_TO_SERIALIZE_NODE, + "\u7bc0\u9ede\u7121\u6cd5\u5e8f\u5217\u5316\u3002"}, + + {MsgKey.ER_CDATA_SECTIONS_SPLIT, + "CDATA \u5340\u6bb5\u5305\u542b\u4e00\u6216\u591a\u500b\u7d42\u6b62\u6a19\u8a18 ']]>'\u3002"}, + + {MsgKey.ER_WARNING_WF_NOT_CHECKED, + "\u7121\u6cd5\u5efa\u7acb\u300c\u5f62\u5f0f\u5b8c\u6574\u300d\u6aa2\u67e5\u7a0b\u5f0f\u7684\u5be6\u4f8b\u3002Well-formed \u53c3\u6578\u96d6\u8a2d\u70ba true\uff0c\u4f46\u7121\u6cd5\u57f7\u884c\u5f62\u5f0f\u5b8c\u6574\u6aa2\u67e5\u3002" + }, + + {MsgKey.ER_WF_INVALID_CHARACTER, + "\u7bc0\u9ede ''{0}'' \u5305\u542b\u7121\u6548\u7684 XML \u5b57\u5143\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_COMMENT, + "\u5728\u8a3b\u89e3\u4e2d\u767c\u73fe\u7121\u6548\u7684 XML \u5b57\u5143 (Unicode: 0x{0})\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_PI, + "\u5728\u8655\u7406\u7a0b\u5e8f instructiondata \u4e2d\u767c\u73fe\u7121\u6548\u7684 XML \u5b57\u5143 (Unicode: 0x{0})\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA, + "\u5728 CDATASection \u7684\u5167\u5bb9\u4e2d\u767c\u73fe\u7121\u6548\u7684 XML \u5b57\u5143 (Unicode: 0x{0})\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT, + "\u5728\u7bc0\u9ede\u7684\u5b57\u5143\u8cc7\u6599\u5167\u5bb9\u4e2d\u767c\u73fe\u7121\u6548\u7684 XML \u5b57\u5143 (Unicode: 0x{0})\u3002" + }, + + { MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, + "\u5728\u540d\u70ba ''{1}'' \u7684 ''{0}'' \u4e2d\u767c\u73fe\u7121\u6548\u7684 XML \u5b57\u5143\u3002" + }, + + { MsgKey.ER_WF_DASH_IN_COMMENT, + "\u8a3b\u89e3\u4e2d\u4e0d\u5141\u8a31\u4f7f\u7528\u5b57\u4e32 \"--\"\u3002" + }, + + {MsgKey.ER_WF_LT_IN_ATTVAL, + "\u8207\u5143\u7d20\u985e\u578b \"{0}\" \u76f8\u95dc\u806f\u7684\u5c6c\u6027 \"{1}\" \u503c\u4e0d\u53ef\u5305\u542b ''<'' \u5b57\u5143\u3002" + }, + + {MsgKey.ER_WF_REF_TO_UNPARSED_ENT, + "\u4e0d\u5141\u8a31\u4f7f\u7528\u672a\u5256\u6790\u7684\u5be6\u9ad4\u53c3\u7167 \"&{0};\"\u3002" + }, + + {MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, + "\u5c6c\u6027\u503c\u4e2d\u4e0d\u5141\u8a31\u4f7f\u7528\u5916\u90e8\u5be6\u9ad4\u53c3\u7167 \"&{0};\"\u3002" + }, + + {MsgKey.ER_NS_PREFIX_CANNOT_BE_BOUND, + "\u5b57\u9996 \"{0}\" \u7121\u6cd5\u9023\u7d50\u5230\u540d\u7a31\u7a7a\u9593 \"{1}\"\u3002" + }, + + {MsgKey.ER_NULL_LOCAL_ELEMENT_NAME, + "\u5143\u7d20 \"{0}\" \u7684\u672c\u7aef\u540d\u7a31\u662f\u7a7a\u503c\u3002" + }, + + {MsgKey.ER_NULL_LOCAL_ATTR_NAME, + "\u5c6c\u6027 \"{0}\" \u7684\u672c\u7aef\u540d\u7a31\u662f\u7a7a\u503c\u3002" + }, + + { MsgKey.ER_ELEM_UNBOUND_PREFIX_IN_ENTREF, + "\u5be6\u9ad4\u7bc0\u9ede \"{0}\" \u7684\u53d6\u4ee3\u6587\u5b57\u5305\u542b\u9644\u6709\u5df2\u5207\u65b7\u9023\u7d50\u5b57\u9996 \"{2}\" \u7684\u5143\u7d20\u7bc0\u9ede \"{1}\"\u3002" + }, + + { MsgKey.ER_ATTR_UNBOUND_PREFIX_IN_ENTREF, + "\u5be6\u9ad4\u7bc0\u9ede \"{0}\" \u7684\u53d6\u4ee3\u6587\u5b57\u5305\u542b\u9644\u6709\u5df2\u5207\u65b7\u9023\u7d50\u5b57\u9996 \"{2}\" \u7684\u5c6c\u6027\u7bc0\u9ede \"{1}\"\u3002" + }, }; diff --git a/jaxp/src/org/w3c/dom/ranges/DocumentRange.java b/jaxp/src/org/w3c/dom/ranges/DocumentRange.java index 342f9e3ace8..ed51624fc11 100644 --- a/jaxp/src/org/w3c/dom/ranges/DocumentRange.java +++ b/jaxp/src/org/w3c/dom/ranges/DocumentRange.java @@ -43,7 +43,7 @@ package org.w3c.dom.ranges; /** *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public interface DocumentRange { /** diff --git a/jaxp/src/org/w3c/dom/ranges/Range.java b/jaxp/src/org/w3c/dom/ranges/Range.java index d42fad0c0fe..0efefe21945 100644 --- a/jaxp/src/org/w3c/dom/ranges/Range.java +++ b/jaxp/src/org/w3c/dom/ranges/Range.java @@ -47,7 +47,7 @@ import org.w3c.dom.DocumentFragment; /** *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public interface Range { /** diff --git a/jaxp/src/org/w3c/dom/ranges/RangeException.java b/jaxp/src/org/w3c/dom/ranges/RangeException.java index 198a135111c..69551a81c95 100644 --- a/jaxp/src/org/w3c/dom/ranges/RangeException.java +++ b/jaxp/src/org/w3c/dom/ranges/RangeException.java @@ -45,7 +45,7 @@ package org.w3c.dom.ranges; * Range operations may throw a RangeException as specified in * their method descriptions. *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public class RangeException extends RuntimeException { public RangeException(short code, String message) { diff --git a/jaxp/src/org/w3c/dom/traversal/DocumentTraversal.java b/jaxp/src/org/w3c/dom/traversal/DocumentTraversal.java index 80938886afe..bbb53740235 100644 --- a/jaxp/src/org/w3c/dom/traversal/DocumentTraversal.java +++ b/jaxp/src/org/w3c/dom/traversal/DocumentTraversal.java @@ -53,7 +53,7 @@ import org.w3c.dom.DOMException; * Traversal feature, DocumentTraversal will be implemented by * the same objects that implement the Document interface. *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public interface DocumentTraversal { /** diff --git a/jaxp/src/org/w3c/dom/traversal/NodeFilter.java b/jaxp/src/org/w3c/dom/traversal/NodeFilter.java index e6f22b2b917..5cc8177eeac 100644 --- a/jaxp/src/org/w3c/dom/traversal/NodeFilter.java +++ b/jaxp/src/org/w3c/dom/traversal/NodeFilter.java @@ -59,7 +59,7 @@ import org.w3c.dom.Node; * filter may be used with a number of different kinds of traversals, * encouraging code reuse. *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public interface NodeFilter { // Constants returned by acceptNode diff --git a/jaxp/src/org/w3c/dom/traversal/NodeIterator.java b/jaxp/src/org/w3c/dom/traversal/NodeIterator.java index 0f6aebf0821..70ef322254f 100644 --- a/jaxp/src/org/w3c/dom/traversal/NodeIterator.java +++ b/jaxp/src/org/w3c/dom/traversal/NodeIterator.java @@ -55,7 +55,7 @@ import org.w3c.dom.DOMException; * NodeIterators are created by calling * DocumentTraversal.createNodeIterator(). *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public interface NodeIterator { /** diff --git a/jaxp/src/org/w3c/dom/traversal/TreeWalker.java b/jaxp/src/org/w3c/dom/traversal/TreeWalker.java index f0876e5206d..262fd96d167 100644 --- a/jaxp/src/org/w3c/dom/traversal/TreeWalker.java +++ b/jaxp/src/org/w3c/dom/traversal/TreeWalker.java @@ -60,7 +60,7 @@ import org.w3c.dom.DOMException; * nodes will be siblings and appear as direct children of the root node, no * matter how deeply nested the structure of the original document. *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. - * @since DOM Level 2 + * @since 1.9, DOM Level 2 */ public interface TreeWalker { /** diff --git a/jaxws/.hgtags b/jaxws/.hgtags index fdc0137241f..26347e69cbf 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -269,3 +269,5 @@ e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15 4a099451fd7e17b6cc4772fe9547907576a45b6f jdk9-b21 7f5e5902cde75fd9335c52f469491f061fe0239e jdk9-b22 ce19e0403ec8a80223cc47320c905b2a4d45881d jdk9-b23 +0b35542d6bf32af23a9fc59a37c52aa091fee388 jdk9-b24 +ab8726a0fcde897e4cfd1ea581ed90b0d8a7cbb7 jdk9-b25 diff --git a/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java b/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java index 93393377a06..acc194b5248 100644 --- a/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java +++ b/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,10 +93,11 @@ public abstract class CommandMap { // otherwise, we also allow it if this code and the // factory come from the same (non-system) class loader (e.g., // the JAF classes were loaded with the applet classes). - if (CommandMap.class.getClassLoader() == null || - CommandMap.class.getClassLoader() != - commandMap.getClass().getClassLoader()) + ClassLoader cl = CommandMap.class.getClassLoader(); + if (cl == null || cl.getParent() == null || + cl != commandMap.getClass().getClassLoader()) { throw ex; + } } } // remove any per-thread-context-class-loader CommandMap @@ -126,7 +127,7 @@ public abstract class CommandMap { * @param mimeType the MIME type * @param ds a DataSource for the data * @return the CommandInfo classes that represent the command Beans. - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public CommandInfo[] getPreferredCommands(String mimeType, DataSource ds) { return getPreferredCommands(mimeType); @@ -154,7 +155,7 @@ public abstract class CommandMap { * @param mimeType the MIME type * @param ds a DataSource for the data * @return the CommandInfo objects representing all the commands. - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public CommandInfo[] getAllCommands(String mimeType, DataSource ds) { return getAllCommands(mimeType); @@ -182,7 +183,7 @@ public abstract class CommandMap { * @param cmdName the command name * @param ds a DataSource for the data * @return the CommandInfo corresponding to the command. - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public CommandInfo getCommand(String mimeType, String cmdName, DataSource ds) { @@ -214,7 +215,7 @@ public abstract class CommandMap { * @param mimeType the MIME type * @param ds a DataSource for the data * @return the DataContentHandler for the MIME type - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public DataContentHandler createDataContentHandler(String mimeType, DataSource ds) { @@ -227,7 +228,7 @@ public abstract class CommandMap { * null is returned. * * @return array of MIME types as strings, or null if not supported - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public String[] getMimeTypes() { return null; diff --git a/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java b/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java index a7c41185273..313998a6aec 100644 --- a/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java +++ b/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,9 +96,9 @@ public abstract class FileTypeMap { // otherwise, we also allow it if this code and the // factory come from the same (non-system) class loader (e.g., // the JAF classes were loaded with the applet classes). - if (FileTypeMap.class.getClassLoader() == null || - FileTypeMap.class.getClassLoader() != - fileTypeMap.getClass().getClassLoader()) + ClassLoader cl = FileTypeMap.class.getClassLoader(); + if (cl == null || cl.getParent() == null || + cl != fileTypeMap.getClass().getClassLoader()) throw ex; } } diff --git a/jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java b/jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java index 91df5fe9afb..7d13a9b506f 100644 --- a/jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java +++ b/jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java @@ -603,7 +603,7 @@ public class MailcapCommandMap extends CommandMap { * Get all the MIME types known to this command map. * * @return array of MIME types as strings - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public synchronized String[] getMimeTypes() { List mtList = new ArrayList(); @@ -639,7 +639,7 @@ public class MailcapCommandMap extends CommandMap { * MIME type are returned. * * @return array of native command entries - * @since JAF 1.1 + * @since 1.6, JAF 1.1 */ public synchronized String[] getNativeCommands(String mimeType) { List cmdList = new ArrayList(); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java index 7f58b05f24f..8f5c7e66585 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java @@ -58,7 +58,7 @@ import javax.xml.stream.XMLStreamWriter; * This class is responsible for whitespace normalization. * * @author

  • Ryan Shoemaker, Martin Grebac
- * @since JAXB1.0 + * @since JAXB 1.0 * @deprecated in JAXB 2.2.4 - use javax.xml.bind.DatatypeConverterImpl instead * or let us know why you can't */ diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/api/Messages.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/api/Messages.java index 13e42bb6328..50554b51c15 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/api/Messages.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/api/Messages.java @@ -31,7 +31,7 @@ import java.util.ResourceBundle; /** * Formats error messages. * - * @since JAXB2.1.10 + * @since JAXB 2.1.10 */ enum Messages { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/Messages.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/Messages.java index 97c98af4835..b736fd9cb45 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/Messages.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/Messages.java @@ -31,7 +31,7 @@ import java.util.ResourceBundle; /** * Formats error messages. * - * @since JAXB1.0 + * @since JAXB 1.0 */ public class Messages { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/XMLWriter.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/XMLWriter.java index 6e1dd7b2359..3fbd954efa6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/XMLWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/marshaller/XMLWriter.java @@ -249,7 +249,7 @@ import org.xml.sax.helpers.XMLFilterImpl; * * @author David Megginson, david@megginson.com * @version 0.2 - * @since JAXB1.0 + * @since JAXB 1.0 * @see org.xml.sax.XMLFilter * @see org.xml.sax.ContentHandler */ diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/DOMScanner.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/DOMScanner.java index c43a3d9a402..8be5e51a980 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/DOMScanner.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/DOMScanner.java @@ -55,7 +55,7 @@ import org.xml.sax.helpers.NamespaceSupport; * classes like this. * * @author
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
- * @since JAXB1.0 + * @since JAXB 1.0 */ public class DOMScanner implements LocatorEx,InfosetScanner/* --- but can't do this to protect 1.0 clients, or can I? */ { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/Messages.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/Messages.java index 730fb17ddaa..b199f76a844 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/Messages.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/unmarshaller/Messages.java @@ -31,7 +31,7 @@ import java.util.ResourceBundle; /** * Formats error messages. * - * @since JAXB1.0 + * @since JAXB 1.0 */ public class Messages { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/util/AttributesImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/util/AttributesImpl.java index c0f345aaf2d..26a328556dc 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/util/AttributesImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/util/AttributesImpl.java @@ -62,7 +62,7 @@ import org.xml.sax.Attributes; * AttributeList} interface, it also includes a much more efficient * implementation using a single array rather than a set of Vectors.

* - * @since JAXB1.0 + * @since JAXB 1.0 * @since SAX 2.0 * @author David Megginson * @version 2.0.1 (sax2r2) diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java index 7f25c89d688..7d86d087ffc 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java @@ -35,6 +35,8 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Arrays; import java.util.Collection; @@ -264,20 +266,38 @@ import com.sun.xml.internal.bind.v2.runtime.Location; return clazz.getSimpleName(); } - public Collection getDeclaredFields(Class clazz) { - return Arrays.asList(clazz.getDeclaredFields()); + public Collection getDeclaredFields(final Class clazz) { + Field[] fields = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Field[] run() { + return clazz.getDeclaredFields(); + } + }); + return Arrays.asList(fields); } - public Field getDeclaredField(Class clazz, String fieldName) { - try { - return clazz.getDeclaredField(fieldName); - } catch (NoSuchFieldException e) { - return null; - } + public Field getDeclaredField(final Class clazz, final String fieldName) { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Field run() { + try { + return clazz.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + return null; + } + } + }); } - public Collection getDeclaredMethods(Class clazz) { - return Arrays.asList(clazz.getDeclaredMethods()); + public Collection getDeclaredMethods(final Class clazz) { + Method[] methods = + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Method[] run() { + return clazz.getDeclaredMethods(); + } + }); + return Arrays.asList(methods); } public Class getDeclaringClassForField(Field field) { @@ -565,7 +585,7 @@ import com.sun.xml.internal.bind.v2.runtime.Location; return method.isBridge(); } - public boolean isOverriding(Method method, Class base) { + public boolean isOverriding(Method method, final Class base) { // this isn't actually correct, // as the JLS considers // class Derived extends Base { @@ -576,22 +596,30 @@ import com.sun.xml.internal.bind.v2.runtime.Location; // } // to be overrided. Handling this correctly needs a careful implementation - String name = method.getName(); - Class[] params = method.getParameterTypes(); + final String name = method.getName(); + final Class[] params = method.getParameterTypes(); - while (base != null) { - try { - if (base.getDeclaredMethod(name, params) != null) { - return true; + return AccessController.doPrivileged( + new PrivilegedAction() { + + @Override + public Boolean run() { + Class clazz = base; + while (clazz != null) { + try { + Method m = clazz.getDeclaredMethod(name, params); + if (m != null) { + return Boolean.TRUE; + } + } catch (NoSuchMethodException ignored) { + // recursively go into the base class + } + clazz = clazz.getSuperclass(); + } + return Boolean.FALSE; + } } - } catch (NoSuchMethodException e) { - // recursively go into the base class - } - - base = base.getSuperclass(); - } - - return false; + ); } public boolean isInterface(Class clazz) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java index 059d9e32018..eaf696c4f29 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,8 @@ package com.sun.xml.internal.bind.v2.runtime; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -415,6 +417,15 @@ public abstract class JaxBeanInfo { private static final Class[] unmarshalEventParams = { Unmarshaller.class, Object.class }; private static Class[] marshalEventParams = { Marshaller.class }; + private Method[] getDeclaredMethods(final Class c) { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Method[] run() { + return c.getDeclaredMethods(); + } + }); + } + /** * use reflection to determine which of the 4 object lifecycle methods exist on * the JAXB bound type. @@ -428,7 +439,7 @@ public abstract class JaxBeanInfo { } while (jt != null) { - for (Method m : jt.getDeclaredMethods()) { + for (Method m : getDeclaredMethods(jt)) { String name = m.getName(); if (lcm.beforeUnmarshal == null) { @@ -468,7 +479,7 @@ public abstract class JaxBeanInfo { } catch (SecurityException e) { // this happens when we don't have enough permission. logger.log(Level.WARNING, Messages.UNABLE_TO_DISCOVER_EVENTHANDLER.format( - jaxbType.getName(), e)); + jaxbType.getName(), e), e); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java index 7923cab28d7..e005de2e538 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java @@ -229,8 +229,7 @@ public abstract class Accessor implements Receiver { if (!Modifier.isPublic(mod) || Modifier.isFinal(mod) || !Modifier.isPublic(f.getDeclaringClass().getModifiers())) { try { // attempt to make it accessible, but do so in the security context of the calling application. - // don't do this in the doPrivilege block, as that would create a security hole for anyone - // to make any field accessible. + // don't do this in the doPrivilege block f.setAccessible(true); } catch (SecurityException e) { if ((!accessWarned) && (!supressAccessorWarnings)) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java index 78f4746abea..17c99557d9f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,26 +146,31 @@ final class Injector { private static final Method findLoadedClass; static { + Method[] m = AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public Method[] run() { + return new Method[]{ + getMethod(ClassLoader.class, "defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE), + getMethod(ClassLoader.class, "resolveClass", Class.class), + getMethod(ClassLoader.class, "findLoadedClass", String.class) + }; + } + } + ); + defineClass = m[0]; + resolveClass = m[1]; + findLoadedClass = m[2]; + } + + private static Method getMethod(final Class c, final String methodname, final Class... params) { try { - defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE); - resolveClass = ClassLoader.class.getDeclaredMethod("resolveClass", Class.class); - findLoadedClass = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class); + Method m = c.getDeclaredMethod(methodname, params); + m.setAccessible(true); + return m; } catch (NoSuchMethodException e) { - // impossible throw new NoSuchMethodError(e.getMessage()); } - AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Void run() { - // TODO: check security implication - // do these setAccessible allow anyone to call these methods freely?s - defineClass.setAccessible(true); - resolveClass.setAccessible(true); - findLoadedClass.setAccessible(true); - return null; - } - }); } private Injector(ClassLoader parent) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/txw2/output/XMLWriter.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/txw2/output/XMLWriter.java index 5ea7a6842f9..fe1d274df36 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/txw2/output/XMLWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/txw2/output/XMLWriter.java @@ -262,7 +262,7 @@ import java.util.Map; * * @author David Megginson, david@megginson.com * @version 0.2 - * @since JAXB1.0 + * @since JAXB 1.0 * @see org.xml.sax.XMLFilter * @see org.xml.sax.ContentHandler */ diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java index 6cff489ba7b..fa52778a9f1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java @@ -42,6 +42,8 @@ import java.io.OutputStream; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.logging.Level; import java.util.logging.Logger; @@ -91,8 +93,6 @@ public abstract class XMLStreamWriterFactory { } } catch (XMLStreamException ex) { Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); - } catch (NoSuchMethodException ex) { - Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); } } @@ -282,17 +282,31 @@ public abstract class XMLStreamWriterFactory { return new Zephyr(xof,clazz); } catch (XMLStreamException e) { return null; // impossible - } catch (NoSuchMethodException e) { - return null; // this xof wasn't Zephyr } } - private Zephyr(XMLOutputFactory xof, Class clazz) throws NoSuchMethodException { + private Zephyr(XMLOutputFactory xof, Class clazz) { this.xof = xof; zephyrClass = clazz; - setOutputMethod = clazz.getMethod("setOutput", StreamResult.class, String.class); - resetMethod = clazz.getMethod("reset"); + setOutputMethod = getMethod(clazz, "setOutput", StreamResult.class, String.class); + resetMethod = getMethod(clazz, "reset"); + } + + private static Method getMethod(final Class c, final String methodname, final Class... params) { + return AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public Method run() { + try { + return c.getMethod(methodname, params); + } catch (NoSuchMethodException e) { + // impossible + throw new NoSuchMethodError(e.getMessage()); + } + } + } + ); } /** diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java index 1e33628b0c1..966e1736aac 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,13 +42,12 @@ import javax.xml.bind.Unmarshaller; import javax.xml.stream.XMLInputFactory; import javax.xml.ws.WebServiceException; import java.lang.reflect.Method; -import java.lang.reflect.ReflectPermission; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.security.*; -import java.util.PropertyPermission; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; import java.util.logging.Level; /** @@ -258,24 +257,13 @@ class MetroConfigLoader { public JAXBContext run() throws Exception { return JAXBContext.newInstance(MetroConfig.class.getPackage().getName()); } - }, createSecurityContext() - ); + }); } else { // usage from JAX-WS/Metro/Glassfish return JAXBContext.newInstance(MetroConfig.class.getPackage().getName()); } } - private static AccessControlContext createSecurityContext() { - PermissionCollection perms = new Permissions(); - perms.add(new RuntimePermission("accessClassInPackage.com" + ".sun.xml.internal.ws.runtime.config")); // avoid repackaging - perms.add(new ReflectPermission("suppressAccessChecks")); - return new AccessControlContext( - new ProtectionDomain[]{ - new ProtectionDomain(null, perms), - }); - } - private static boolean isJDKInternal() { // avoid "string repackaging" return MetroConfigLoader.class.getName().startsWith("com." + "sun.xml.internal.ws"); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java index d0e980ce937..d68f854c38f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ final class TubeCreator { try { Class factoryClass; if (isJDKInternal(className)) { - factoryClass = Class.forName(className, true, null); + factoryClass = Class.forName(className, true, TubeCreator.class.getClassLoader()); } else { factoryClass = Class.forName(className, true, tubeFactoryClassLoader); } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java index 3f925581a85..a82c491e7fc 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,11 +109,12 @@ final class TubelineAssemblyController { } private Collection initializeTubeCreators(TubeFactoryList tfl) { - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + ClassLoader classLoader = tccl != null ? tccl : TubelineAssemblyController.class.getClassLoader(); LinkedList tubeCreators = new LinkedList(); for (TubeFactoryConfig tubeFactoryConfig : tfl.getTubeFactoryConfigs()) { - tubeCreators.addFirst(new TubeCreator(tubeFactoryConfig, contextClassLoader)); + tubeCreators.addFirst(new TubeCreator(tubeFactoryConfig, classLoader)); } return tubeCreators; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java index 7805320d90a..1c054547a4e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,7 +91,8 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.net.MalformedURLException; import java.net.URL; -import java.security.*; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -715,11 +716,6 @@ public class WSServiceDelegate extends WSService { final ClassLoader loader = getDelegatingLoader(portInterface.getClassLoader(), WSServiceDelegate.class.getClassLoader()); - // accessClassInPackage privilege needs to be granted ... - RuntimePermission perm = new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.*"); - PermissionCollection perms = perm.newPermissionCollection(); - perms.add(perm); - return AccessController.doPrivileged( new PrivilegedAction() { @Override @@ -728,12 +724,8 @@ public class WSServiceDelegate extends WSService { new Class[]{portInterface, WSBindingProvider.class, Closeable.class}, pis); return portInterface.cast(proxy); } - }, - new AccessControlContext( - new ProtectionDomain[]{ - new ProtectionDomain(null, perms) - }) - ); + }); + } private WSDLService getWSDLModelfromSEI(final Class sei) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java index 92bd3b26167..bf258021c33 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,12 +58,8 @@ import javax.xml.ws.soap.SOAPFaultException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.ReflectPermission; -import java.security.AccessControlContext; import java.security.AccessController; -import java.security.Permissions; import java.security.PrivilegedAction; -import java.security.ProtectionDomain; import java.util.Iterator; import java.util.Map; import java.util.logging.Level; @@ -569,9 +565,6 @@ public abstract class SOAPFaultBuilder { // in jdk runtime doPrivileged is necessary since JAX-WS internal classes are in restricted packages if (isJDKRuntime()) { - Permissions permissions = new Permissions(); - permissions.add(new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.ws.fault")); - permissions.add(new ReflectPermission("suppressAccessChecks")); return AccessController.doPrivileged( new PrivilegedAction() { @Override @@ -582,9 +575,7 @@ public abstract class SOAPFaultBuilder { throw new Error(e); } } - }, - new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain(null, permissions)}) - ); + }); } else { try { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java index 9d07e99b7c7..158e0a9f8ef 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,28 +50,36 @@ final class Injector { private static final Method definePackage; static { + Method[] m = AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public Method[] run() { + return new Method[]{ + getMethod(ClassLoader.class, "defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE), + getMethod(ClassLoader.class, "resolveClass", Class.class), + getMethod(ClassLoader.class, "getPackage", String.class), + getMethod(ClassLoader.class, "definePackage", + String.class, String.class, String.class, String.class, + String.class, String.class, String.class, URL.class) + }; + } + } + ); + defineClass = m[0]; + resolveClass = m[1]; + getPackage = m[2]; + definePackage = m[3]; + } + + private static Method getMethod(final Class c, final String methodname, final Class... params) { try { - defineClass = ClassLoader.class.getDeclaredMethod("defineClass",String.class,byte[].class,Integer.TYPE,Integer.TYPE); - resolveClass = ClassLoader.class.getDeclaredMethod("resolveClass",Class.class); - getPackage = ClassLoader.class.getDeclaredMethod("getPackage", String.class); - definePackage = ClassLoader.class.getDeclaredMethod("definePackage", - String.class, String.class, String.class, String.class, - String.class, String.class, String.class, URL.class); + Method m = c.getDeclaredMethod(methodname, params); + m.setAccessible(true); + return m; } catch (NoSuchMethodException e) { // impossible throw new NoSuchMethodError(e.getMessage()); } - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - // TODO: check security implication - // do these setAccessible allow anyone to call these methods freely?s - defineClass.setAccessible(true); - resolveClass.setAccessible(true); - getPackage.setAccessible(true); - definePackage.setAccessible(true); - return null; - } - }); } static synchronized Class inject(ClassLoader cl, String className, byte[] image) { diff --git a/jaxws/src/share/jaxws_classes/javax/annotation/Generated.java b/jaxws/src/share/jaxws_classes/javax/annotation/Generated.java index f9d34e4a398..b59595f98f8 100644 --- a/jaxws/src/share/jaxws_classes/javax/annotation/Generated.java +++ b/jaxws/src/share/jaxws_classes/javax/annotation/Generated.java @@ -43,7 +43,7 @@ import static java.lang.annotation.RetentionPolicy.*; *

The comment element is a place holder for any comments that the code * generator may want to include in the generated code.

* - * @since Common Annotations 1.0 + * @since 1.6, Common Annotations 1.0 */ @Documented diff --git a/jaxws/src/share/jaxws_classes/javax/annotation/PostConstruct.java b/jaxws/src/share/jaxws_classes/javax/annotation/PostConstruct.java index 4f2976ca617..fbe226ca42e 100644 --- a/jaxws/src/share/jaxws_classes/javax/annotation/PostConstruct.java +++ b/jaxws/src/share/jaxws_classes/javax/annotation/PostConstruct.java @@ -70,9 +70,10 @@ import static java.lang.annotation.RetentionPolicy.*; *
  • If the method throws an unchecked exception the class MUST NOT be put into * service except in the case of EJBs where the EJB can handle exceptions and * even recover from them.
  • - * @since Common Annotations 1.0 + * * @see javax.annotation.PreDestroy * @see javax.annotation.Resource + * @since 1.6, Common Annotations 1.0 */ @Documented @Retention (RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/annotation/PreDestroy.java b/jaxws/src/share/jaxws_classes/javax/annotation/PreDestroy.java index d24cd3f70ad..eff974a5e4a 100644 --- a/jaxws/src/share/jaxws_classes/javax/annotation/PreDestroy.java +++ b/jaxws/src/share/jaxws_classes/javax/annotation/PreDestroy.java @@ -72,7 +72,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * @see javax.annotation.PostConstruct * @see javax.annotation.Resource - * @since Common Annotations 1.0 + * @since 1.6, Common Annotations 1.0 */ @Documented diff --git a/jaxws/src/share/jaxws_classes/javax/annotation/Resource.java b/jaxws/src/share/jaxws_classes/javax/annotation/Resource.java index 7c6541139fa..0f29fa5e6b8 100644 --- a/jaxws/src/share/jaxws_classes/javax/annotation/Resource.java +++ b/jaxws/src/share/jaxws_classes/javax/annotation/Resource.java @@ -48,7 +48,7 @@ import static java.lang.annotation.RetentionPolicy.*; * appear on private fields and methods of superclasses; the container * is required to perform injection in these cases as well. * - * @since Common Annotations 1.0 + * @since 1.6, Common Annotations 1.0 */ @Target({TYPE, FIELD, METHOD}) @Retention(RUNTIME) @@ -66,7 +66,7 @@ public @interface Resource { * The name of the resource that the reference points to. It can * link to any compatible resource using the global JNDI names. * - * @since Common Annotations 1.1 + * @since 1.7, Common Annotations 1.1 */ String lookup() default ""; diff --git a/jaxws/src/share/jaxws_classes/javax/annotation/Resources.java b/jaxws/src/share/jaxws_classes/javax/annotation/Resources.java index 6bbe04e01c7..7b6e1dec589 100644 --- a/jaxws/src/share/jaxws_classes/javax/annotation/Resources.java +++ b/jaxws/src/share/jaxws_classes/javax/annotation/Resources.java @@ -32,7 +32,7 @@ import static java.lang.annotation.RetentionPolicy.*; * This class is used to allow multiple resources declarations. * * @see javax.annotation.Resource - * @since Common Annotations 1.0 + * @since 1.6, Common Annotations 1.0 */ @Documented diff --git a/jaxws/src/share/jaxws_classes/javax/jws/HandlerChain.java b/jaxws/src/share/jaxws_classes/javax/jws/HandlerChain.java index 497f8b5aa69..cb52ff235d3 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/HandlerChain.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/HandlerChain.java @@ -28,6 +28,9 @@ package javax.jws; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({TYPE, METHOD, FIELD}) public @interface HandlerChain { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/Oneway.java b/jaxws/src/share/jaxws_classes/javax/jws/Oneway.java index f5a4823211d..613e0940c8b 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/Oneway.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/Oneway.java @@ -27,6 +27,9 @@ package javax.jws; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({METHOD}) public @interface Oneway { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/WebMethod.java b/jaxws/src/share/jaxws_classes/javax/jws/WebMethod.java index ae3f3156140..f2eeaf08b03 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/WebMethod.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/WebMethod.java @@ -27,6 +27,9 @@ package javax.jws; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({METHOD}) public @interface WebMethod { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/WebParam.java b/jaxws/src/share/jaxws_classes/javax/jws/WebParam.java index ac7752fdbf0..df9f3d9bd58 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/WebParam.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/WebParam.java @@ -27,6 +27,9 @@ package javax.jws; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({PARAMETER}) public @interface WebParam { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/WebResult.java b/jaxws/src/share/jaxws_classes/javax/jws/WebResult.java index 800fa659029..c878433a077 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/WebResult.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/WebResult.java @@ -27,6 +27,9 @@ package javax.jws; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({METHOD}) public @interface WebResult { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/WebService.java b/jaxws/src/share/jaxws_classes/javax/jws/WebService.java index 8d29d21c947..c133f583547 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/WebService.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/WebService.java @@ -27,6 +27,9 @@ package javax.jws; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({TYPE}) public @interface WebService { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/soap/InitParam.java b/jaxws/src/share/jaxws_classes/javax/jws/soap/InitParam.java index 83acb8b4254..43088e25e20 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/soap/InitParam.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/soap/InitParam.java @@ -25,7 +25,8 @@ package javax.jws.soap; -/* +/** + * @since 1.6 * @Deprecated */ @Deprecated public @interface InitParam { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPBinding.java b/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPBinding.java index 5966f11032a..5fb23ba09bb 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPBinding.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPBinding.java @@ -27,6 +27,9 @@ package javax.jws.soap; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; +/** + * @since 1.6 + */ @Retention(value=RetentionPolicy.RUNTIME) @Target({TYPE,METHOD}) public @interface SOAPBinding { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandler.java b/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandler.java index b586c875e89..fe974e3e090 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandler.java @@ -25,7 +25,8 @@ package javax.jws.soap; -/* +/** + * @since 1.6 * @Deprecated */ @Deprecated public @interface SOAPMessageHandler { diff --git a/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandlers.java b/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandlers.java index 068df03cce3..c255f756c1a 100644 --- a/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandlers.java +++ b/jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPMessageHandlers.java @@ -27,7 +27,8 @@ package javax.jws.soap; import java.lang.annotation.*; import static java.lang.annotation.ElementType.*; -/* +/** + * @since 1.6 * @Deprecated */ @Retention(value=RetentionPolicy.RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/Binder.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/Binder.java index a243aaaa1a9..70ec8ea8af0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/Binder.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/Binder.java @@ -76,7 +76,7 @@ import javax.xml.validation.Schema; * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) * Joseph Fialli * - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public abstract class Binder { /** @@ -153,7 +153,7 @@ public abstract class Binder { * binding. * @throws IllegalArgumentException * If any of the input parameters are null - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public abstract JAXBElement unmarshal( XmlNode xmlNode, Class declaredType ) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/DataBindingException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/DataBindingException.java index 2d0461ef16c..26c0e4e28ce 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/DataBindingException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/DataBindingException.java @@ -34,7 +34,7 @@ package javax.xml.bind; * is a checked exception. * * @see JAXB - * @since JAXB2.1 + * @since 1.6, JAXB 2.1 */ public class DataBindingException extends RuntimeException { public DataBindingException(String message, Throwable cause) { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverter.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverter.java index c7cc50943b0..a5c8e13dbc0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverter.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverter.java @@ -88,7 +88,7 @@ import javax.xml.namespace.NamespaceContext; * @see DatatypeConverterInterface * @see ParseConversionEvent * @see PrintConversionEvent - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ final public class DatatypeConverter { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterImpl.java index a2358500ae8..093c2899200 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterImpl.java @@ -49,7 +49,7 @@ import javax.xml.datatype.DatatypeConfigurationException; * This class is responsible for whitespace normalization. * * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    - * @since JAXB2.1 + * @since JAXB 2.1 */ final class DatatypeConverterImpl implements DatatypeConverterInterface { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterInterface.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterInterface.java index 228673bc764..0f4796e0db5 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterInterface.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/DatatypeConverterInterface.java @@ -78,7 +78,7 @@ package javax.xml.bind; * @see DatatypeConverter * @see ParseConversionEvent * @see PrintConversionEvent - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface DatatypeConverterInterface { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/Element.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/Element.java index 6e576d05548..9e2c7b99eeb 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/Element.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/Element.java @@ -35,7 +35,7 @@ package javax.xml.bind; * and 5.7.1 "Bind to Java Element Interface" of the specification. * * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    • Joe Fialli, Sun Microsystems, Inc.
    - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface Element { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXB.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXB.java index 3c16454697b..b6a16de0d18 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXB.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXB.java @@ -92,7 +92,7 @@ import java.net.URLConnection; * a non-null value. * * @author Kohsuke Kawaguchi - * @since 2.1 + * @since 1.6, JAXB 2.1 */ public final class JAXB { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBContext.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBContext.java index 2d3c1255cba..77d84390c93 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBContext.java @@ -257,7 +257,7 @@ import java.io.InputStream; * @see Marshaller * @see Unmarshaller * @see S 7.4.1 "Named Packages" in Java Language Specification - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public abstract class JAXBContext { @@ -423,7 +423,7 @@ public abstract class JAXBContext { *
  • failure to locate a value for the context factory provider property
  • *
  • mixing schema derived packages from different providers on the same contextPath
  • * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public static JAXBContext newInstance( String contextPath, ClassLoader classLoader, Map properties ) throws JAXBException { @@ -497,7 +497,7 @@ public abstract class JAXBContext { // * @throws IllegalArgumentException // * if the parameter contains {@code null} (i.e., {@code newInstance(null);}) // * -// * @since JAXB2.0 +// * @since JAXB 2.0 // */ // public static JAXBContext newInstance( Source[] externalBindings, Class... classesToBeBound ) // throws JAXBException { @@ -576,7 +576,7 @@ public abstract class JAXBContext { * @throws IllegalArgumentException * if the parameter contains {@code null} (i.e., {@code newInstance(null);}) * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public static JAXBContext newInstance( Class... classesToBeBound ) throws JAXBException { @@ -622,7 +622,7 @@ public abstract class JAXBContext { * @throws IllegalArgumentException * if the parameter contains {@code null} (i.e., {@code newInstance(null,someMap);}) * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public static JAXBContext newInstance( Class[] classesToBeBound, Map properties ) throws JAXBException { @@ -692,7 +692,7 @@ public abstract class JAXBContext { * if DOM API corresponding to domType is not supported by * the implementation. * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public Binder createBinder(Class domType) { // to make JAXB 1.0 implementations work, this method must not be @@ -705,7 +705,7 @@ public abstract class JAXBContext { * * @return always a new valid Binder object. * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public Binder createBinder() { return createBinder(Node.class); @@ -722,7 +722,7 @@ public abstract class JAXBContext { * Calling this method on JAXB 1.0 implementations will throw * an UnsupportedOperationException. * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public JAXBIntrospector createJAXBIntrospector() { // to make JAXB 1.0 implementations work, this method must not be @@ -744,7 +744,7 @@ public abstract class JAXBContext { * Calling this method on JAXB 1.0 implementations will throw * an UnsupportedOperationException. * - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public void generateSchema(SchemaOutputResolver outputResolver) throws IOException { // to make JAXB 1.0 implementations work, this method must not be diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBElement.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBElement.java index fa240af7b0d..bc0b5281d5a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBElement.java @@ -58,7 +58,7 @@ import java.io.Serializable; *

    * * @author Kohsuke Kawaguchi, Joe Fialli - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public class JAXBElement implements Serializable { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBException.java index 218dceb7ae3..432f0531d39 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBException.java @@ -34,7 +34,7 @@ import java.io.PrintWriter; * @see JAXBContext * @see Marshaller * @see Unmarshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class JAXBException extends Exception { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBIntrospector.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBIntrospector.java index 18a70ff6a3f..ed75427b442 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBIntrospector.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBIntrospector.java @@ -41,7 +41,7 @@ import javax.xml.namespace.QName; * {@link JAXBContext#createJAXBIntrospector()}. * * @see JAXBContext#createJAXBIntrospector() - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public abstract class JAXBIntrospector { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBPermission.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBPermission.java index 05b83450798..42dedafaaa6 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBPermission.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/JAXBPermission.java @@ -73,7 +73,7 @@ import java.security.BasicPermission; * @see java.lang.SecurityManager * * @author Joe Fialli - * @since JAXB 2.2 + * @since 1.7, JAXB 2.2 */ /* code was borrowed originally from java.lang.RuntimePermission. */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/MarshalException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/MarshalException.java index f944d1d05af..e1f2cad20b8 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/MarshalException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/MarshalException.java @@ -38,7 +38,7 @@ package javax.xml.bind; * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    * @see JAXBException * @see Marshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class MarshalException extends JAXBException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/Marshaller.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/Marshaller.java index 6a469039a06..abb41042479 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/Marshaller.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/Marshaller.java @@ -311,7 +311,7 @@ import java.io.File; * @see JAXBContext * @see Validator * @see Unmarshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface Marshaller { @@ -421,7 +421,7 @@ public interface Marshaller { * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null - * @since JAXB2.1 + * @since 1.6, JAXB 2.1 */ public void marshal( Object jaxbElement, File output ) throws JAXBException; @@ -515,7 +515,7 @@ public interface Marshaller { * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public void marshal( Object jaxbElement, javax.xml.stream.XMLStreamWriter writer ) throws JAXBException; @@ -539,7 +539,7 @@ public interface Marshaller { * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public void marshal( Object jaxbElement, javax.xml.stream.XMLEventWriter writer ) throws JAXBException; @@ -655,7 +655,7 @@ public interface Marshaller { * if the adapter parameter is null. * @throws UnsupportedOperationException * if invoked agains a JAXB 1.0 implementation. - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public void setAdapter( XmlAdapter adapter ); @@ -684,7 +684,7 @@ public interface Marshaller { * if the type parameter is null. * @throws UnsupportedOperationException * if invoked agains a JAXB 1.0 implementation. - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public void setAdapter( Class type, A adapter ); @@ -697,7 +697,7 @@ public interface Marshaller { * if the type parameter is null. * @throws UnsupportedOperationException * if invoked agains a JAXB 1.0 implementation. - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public A getAdapter( Class type ); @@ -730,7 +730,7 @@ public interface Marshaller { * @throws UnsupportedOperationException could be thrown if this method is * invoked on an Marshaller created from a JAXBContext referencing * JAXB 1.0 mapped classes - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public void setSchema( Schema schema ); @@ -745,7 +745,7 @@ public interface Marshaller { * @throws UnsupportedOperationException could be thrown if this method is * invoked on an Marshaller created from a JAXBContext referencing * JAXB 1.0 mapped classes - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public Schema getSchema(); @@ -766,7 +766,7 @@ public interface Marshaller { * * @see Marshaller#setListener(Listener) * @see Marshaller#getListener() - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public static abstract class Listener { /** @@ -807,7 +807,7 @@ public interface Marshaller { * One can unregister current Listener by setting listener to null. * * @param listener an instance of a class that implements {@link Listener} - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public void setListener(Listener listener); @@ -815,7 +815,7 @@ public interface Marshaller { *

    Return {@link Listener} registered with this {@link Marshaller}. * * @return registered {@link Listener} or null if no Listener is registered with this Marshaller. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public Listener getListener(); } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/NotIdentifiableEvent.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/NotIdentifiableEvent.java index f4820c96da1..e2f547ed9c7 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/NotIdentifiableEvent.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/NotIdentifiableEvent.java @@ -32,7 +32,7 @@ package javax.xml.bind; * @author

    • Ryan Shoemaker, Sun Microsystems, Inc.
    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    • Joe Fialli, Sun Microsystems, Inc.
    * @see Validator * @see ValidationEventHandler - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface NotIdentifiableEvent extends ValidationEvent { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/ParseConversionEvent.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/ParseConversionEvent.java index b6ee5e69399..4c900b49184 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/ParseConversionEvent.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/ParseConversionEvent.java @@ -33,7 +33,7 @@ package javax.xml.bind; * @see ValidationEvent * @see ValidationEventHandler * @see Unmarshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface ParseConversionEvent extends ValidationEvent { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/PrintConversionEvent.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/PrintConversionEvent.java index c630cf62b08..b9146f4e310 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/PrintConversionEvent.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/PrintConversionEvent.java @@ -33,7 +33,7 @@ package javax.xml.bind; * @see ValidationEvent * @see ValidationEventHandler * @see Marshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface PrintConversionEvent extends ValidationEvent { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/PropertyException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/PropertyException.java index 65613b84bd1..60860e9bac7 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/PropertyException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/PropertyException.java @@ -35,7 +35,7 @@ package javax.xml.bind; * @see JAXBContext * @see Validator * @see Unmarshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class PropertyException extends JAXBException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/SchemaOutputResolver.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/SchemaOutputResolver.java index f911107ba99..c39b78c870d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/SchemaOutputResolver.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/SchemaOutputResolver.java @@ -42,6 +42,7 @@ import java.io.IOException; * * @author * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) + * @since 1.6 */ public abstract class SchemaOutputResolver { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/TypeConstraintException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/TypeConstraintException.java index 24a295b8d02..fa9ae393635 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/TypeConstraintException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/TypeConstraintException.java @@ -42,7 +42,7 @@ package javax.xml.bind; * * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    • Joe Fialli, Sun Microsystems, Inc.
    * @see ValidationEvent - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class TypeConstraintException extends java.lang.RuntimeException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshalException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshalException.java index 88746597953..239675fce2b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshalException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshalException.java @@ -40,7 +40,7 @@ package javax.xml.bind; * @see JAXBException * @see Unmarshaller * @see ValidationEventHandler - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class UnmarshalException extends JAXBException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/Unmarshaller.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/Unmarshaller.java index eb3090ab57b..19dfb6e6f4b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/Unmarshaller.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/Unmarshaller.java @@ -404,7 +404,7 @@ import java.io.Reader; * @see JAXBContext * @see Marshaller * @see Validator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface Unmarshaller { @@ -474,7 +474,7 @@ public interface Unmarshaller { * binding. See
    Unmarshalling XML Data * @throws IllegalArgumentException * If the InputStream parameter is null - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public Object unmarshal( Reader reader ) throws JAXBException; @@ -571,7 +571,7 @@ public interface Unmarshaller { * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public JAXBElement unmarshal( org.w3c.dom.Node node, Class declaredType ) throws JAXBException; @@ -660,7 +660,7 @@ public interface Unmarshaller { * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public JAXBElement unmarshal( javax.xml.transform.Source source, Class declaredType ) throws JAXBException; @@ -696,7 +696,7 @@ public interface Unmarshaller { * @throws IllegalStateException * If reader is not pointing to a START_DOCUMENT or * START_ELEMENT event. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see #unmarshal(javax.xml.stream.XMLStreamReader, Class) */ public Object unmarshal( javax.xml.stream.XMLStreamReader reader ) @@ -731,7 +731,7 @@ public interface Unmarshaller { * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public JAXBElement unmarshal( javax.xml.stream.XMLStreamReader reader, Class declaredType ) throws JAXBException; @@ -766,7 +766,7 @@ public interface Unmarshaller { * @throws IllegalStateException * If reader is not pointing to a START_DOCUMENT or * START_ELEMENT event. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see #unmarshal(javax.xml.stream.XMLEventReader, Class) */ public Object unmarshal( javax.xml.stream.XMLEventReader reader ) @@ -802,7 +802,7 @@ public interface Unmarshaller { * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public JAXBElement unmarshal( javax.xml.stream.XMLEventReader reader, Class declaredType ) throws JAXBException; @@ -962,7 +962,7 @@ public interface Unmarshaller { * @throws UnsupportedOperationException could be thrown if this method is * invoked on an Unmarshaller created from a JAXBContext referencing * JAXB 1.0 mapped classes - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public void setSchema( javax.xml.validation.Schema schema ); @@ -986,7 +986,7 @@ public interface Unmarshaller { * @throws UnsupportedOperationException could be thrown if this method is * invoked on an Unmarshaller created from a JAXBContext referencing * JAXB 1.0 mapped classes - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public javax.xml.validation.Schema getSchema(); @@ -1001,7 +1001,7 @@ public interface Unmarshaller { * if the adapter parameter is null. * @throws UnsupportedOperationException * if invoked agains a JAXB 1.0 implementation. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public void setAdapter( XmlAdapter adapter ); @@ -1030,7 +1030,7 @@ public interface Unmarshaller { * if the type parameter is null. * @throws UnsupportedOperationException * if invoked agains a JAXB 1.0 implementation. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public void setAdapter( Class type, A adapter ); @@ -1043,7 +1043,7 @@ public interface Unmarshaller { * if the type parameter is null. * @throws UnsupportedOperationException * if invoked agains a JAXB 1.0 implementation. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public A getAdapter( Class type ); @@ -1081,7 +1081,7 @@ public interface Unmarshaller { * (@link #setListener(Listener)} * (@link #getListener()} * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public static abstract class Listener { /** @@ -1128,7 +1128,7 @@ public interface Unmarshaller { * One can unregister current Listener by setting listener to null. * * @param listener provides unmarshal event callbacks for this {@link Unmarshaller} - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public void setListener(Listener listener); @@ -1136,7 +1136,7 @@ public interface Unmarshaller { *

    Return {@link Listener} registered with this {@link Unmarshaller}. * * @return registered {@link Listener} or null if no Listener is registered with this Unmarshaller. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public Listener getListener(); } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshallerHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshallerHandler.java index 0f2c7954ad0..cf7f7452996 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshallerHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/UnmarshallerHandler.java @@ -57,7 +57,7 @@ import org.xml.sax.ContentHandler; * * @author

    • Kohsuke KAWAGUCHI, Sun Microsystems, Inc.
    * @see Unmarshaller#getUnmarshallerHandler() - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface UnmarshallerHandler extends ContentHandler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEvent.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEvent.java index 5395904c234..9f21bf6c5e6 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEvent.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEvent.java @@ -34,7 +34,7 @@ package javax.xml.bind; * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    • Joe Fialli, Sun Microsystems, Inc.
    * @see Validator * @see ValidationEventHandler - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface ValidationEvent { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventHandler.java index 76ed5842416..1161fe89ba9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventHandler.java @@ -65,7 +65,7 @@ package javax.xml.bind; * @see Marshaller * @see ValidationEvent * @see javax.xml.bind.util.ValidationEventCollector - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface ValidationEventHandler { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventLocator.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventLocator.java index c45327eae7e..e9b325d0f63 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventLocator.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationEventLocator.java @@ -40,7 +40,7 @@ package javax.xml.bind; * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    • Joe Fialli, Sun Microsystems, Inc.
    * @see Validator * @see ValidationEvent - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public interface ValidationEventLocator { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationException.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationException.java index 32f2223ba2b..b06feb7777e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/ValidationException.java @@ -38,7 +38,7 @@ package javax.xml.bind; * @author
    • Ryan Shoemaker, Sun Microsystems, Inc.
    * @see JAXBException * @see Validator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class ValidationException extends JAXBException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/Validator.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/Validator.java index 830c30aecbd..18f7d6166c9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/Validator.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/Validator.java @@ -154,7 +154,7 @@ package javax.xml.bind; * @see ValidationEventHandler * @see ValidationEvent * @see javax.xml.bind.util.ValidationEventCollector - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 * @deprecated since JAXB 2.0 */ public interface Validator { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/DomHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/DomHandler.java index e9ab331101c..97d7ccbe909 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/DomHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/DomHandler.java @@ -49,7 +49,7 @@ import javax.xml.transform.Source; * be called from applications. * * @author Kohsuke Kawaguchi - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public interface DomHandler { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/W3CDomHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/W3CDomHandler.java index 113780e27f7..b5d973860f6 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/W3CDomHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/W3CDomHandler.java @@ -40,7 +40,7 @@ import javax.xml.transform.dom.DOMSource; * {@link DomHandler} implementation for W3C DOM (org.w3c.dom package.) * * @author Kohsuke Kawaguchi - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public class W3CDomHandler implements DomHandler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessOrder.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessOrder.java index 2235678ae0d..ec38d4e29c0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessOrder.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessOrder.java @@ -30,7 +30,7 @@ package javax.xml.bind.annotation; * fields in a JAXB bound class. * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see XmlAccessorOrder */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessType.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessType.java index c53213a49cd..821c2244610 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessType.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessType.java @@ -32,7 +32,7 @@ package javax.xml.bind.annotation; * properties. * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see XmlAccessorType */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorOrder.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorOrder.java index a72a9d2a7d2..483849c16e3 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorOrder.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorOrder.java @@ -70,7 +70,7 @@ import static java.lang.annotation.RetentionPolicy.*; * following annotations at the package level: {@link XmlJavaTypeAdapter}. * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see XmlAccessOrder */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorType.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorType.java index e8f044f97c4..a4e5525c151 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorType.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAccessorType.java @@ -84,7 +84,7 @@ import static java.lang.annotation.RetentionPolicy.*; * following annotations at the package level: {@link XmlJavaTypeAdapter}. * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see XmlAccessType */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyAttribute.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyAttribute.java index bf1a6ad2075..ff9c13778de 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyAttribute.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyAttribute.java @@ -66,7 +66,7 @@ import static java.lang.annotation.ElementType.METHOD; * map's key. The key's value is the String value of the attribute. * * @author Kohsuke Kawaguchi, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyElement.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyElement.java index 9613547c1dc..3ca62ccd61b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAnyElement.java @@ -243,7 +243,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * * * @author Kohsuke Kawaguchi - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttachmentRef.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttachmentRef.java index d15dc3691ef..e6cd4fcee93 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttachmentRef.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttachmentRef.java @@ -66,7 +66,7 @@ import java.lang.annotation.Target; * The above binding supports WS-I AP 1.0
    WS-I Attachments Profile Version 1.0. * * @author Kohsuke Kawaguchi - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD,PARAMETER}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttribute.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttribute.java index 13f52547e3c..b37ca5d2898 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttribute.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlAttribute.java @@ -122,7 +122,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlType - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD, METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElement.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElement.java index 6f2c7e5afb9..5254769d26f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElement.java @@ -134,7 +134,7 @@ import static java.lang.annotation.RetentionPolicy.*; * *

    * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD, METHOD, PARAMETER}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementDecl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementDecl.java index d5c558de122..00b6782d8e8 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementDecl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementDecl.java @@ -130,7 +130,7 @@ import static java.lang.annotation.ElementType.METHOD; * name "foo". * * @see XmlRegistry - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRef.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRef.java index 0f5c7219d4e..00be7a5cc15 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRef.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRef.java @@ -216,7 +216,7 @@ import static java.lang.annotation.ElementType.METHOD; * * @author

    • Kohsuke Kawaguchi, Sun Microsystems,Inc.
    • Sekhar Vajjhala, Sun Microsystems, Inc.
    * @see XmlElementRefs - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD}) @@ -284,7 +284,7 @@ public @interface XmlElementRef { * For compatibility with JAXB 2.1, this property defaults to true, * despite the fact that {@link XmlElement#required()} defaults to false. * - * @since 2.2 + * @since 1.7, JAXB 2.2 */ boolean required() default true; } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRefs.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRefs.java index bb3633ed876..5f9b66c361b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRefs.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementRefs.java @@ -50,7 +50,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * * @see XmlElementWrapper * @see XmlElementRef - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementWrapper.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementWrapper.java index c6bebb2775f..71aeec1141a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementWrapper.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElementWrapper.java @@ -87,7 +87,7 @@ import java.lang.annotation.Target; * @see XmlElements * @see XmlElementRef * @see XmlElementRefs - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * */ @@ -139,7 +139,7 @@ public @interface XmlElementWrapper { * simply a mechanism to let users express their application constraints * better. * - * @since JAXB 2.1 + * @since 1.6, JAXB 2.1 */ boolean required() default false; } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElements.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElements.java index 2e5384600cc..4d52a73c037 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElements.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlElements.java @@ -166,7 +166,7 @@ import java.lang.annotation.Target; * @see XmlElementRef * @see XmlElementRefs * @see XmlJavaTypeAdapter - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD}) public @interface XmlElements { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnum.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnum.java index 544a21e12bb..f6059ffed9c 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnum.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnum.java @@ -62,7 +62,7 @@ import java.lang.annotation.Target; * *

    Examples: See examples in {@link XmlEnumValue} * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({TYPE}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnumValue.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnumValue.java index ea656abd7bb..1948f3670a2 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnumValue.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlEnumValue.java @@ -114,7 +114,7 @@ import static java.lang.annotation.ElementType.FIELD; * </xs:simpleType> * * - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlID.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlID.java index 13ce41d5ed1..8fc3542a5f8 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlID.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlID.java @@ -87,7 +87,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlIDREF - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD, METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlIDREF.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlIDREF.java index ef9e2c6bb9d..5789dcc3d33 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlIDREF.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlIDREF.java @@ -243,7 +243,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlID - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD, METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlInlineBinaryData.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlInlineBinaryData.java index 9390b0e3de6..d6beedba4a2 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlInlineBinaryData.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlInlineBinaryData.java @@ -51,7 +51,7 @@ import javax.activation.DataHandler; * ever called for the property. The binary data will always be inlined. * * @author Joseph Fialli - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD,TYPE}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlList.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlList.java index ef11b5b15f3..0576e7f61da 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlList.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlList.java @@ -104,7 +104,7 @@ import static java.lang.annotation.ElementType.PARAMETER; * * * @author

    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    • Sekhar Vajjhala, Sun Microsystems, Inc.
    - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD,PARAMETER}) public @interface XmlList { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMimeType.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMimeType.java index 09506aae260..c7fabf524c4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMimeType.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMimeType.java @@ -47,7 +47,7 @@ import javax.xml.transform.Source; * the value of the attribute takes precedence and that will control the marshalling. * * @author Kohsuke Kawaguchi - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD,PARAMETER}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMixed.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMixed.java index 7b0462e61c0..8259b59540f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMixed.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlMixed.java @@ -124,7 +124,7 @@ import javax.xml.bind.JAXBElement; *

    See "Package Specification" in javax.xml.bind.package javadoc for * additional common information.

    * @author Kohsuke Kawaguchi - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNs.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNs.java index dc92cc55a66..7625b5175cc 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNs.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNs.java @@ -42,7 +42,7 @@ import java.lang.annotation.Target; * *

    Example:See XmlSchema annotation type for an example. * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNsForm.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNsForm.java index 68670a9c1b3..769df76146a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNsForm.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlNsForm.java @@ -61,6 +61,6 @@ package javax.xml.bind.annotation; * * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ public enum XmlNsForm {UNQUALIFIED, QUALIFIED, UNSET} diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRegistry.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRegistry.java index 1218061c051..61f5b520fb4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRegistry.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRegistry.java @@ -34,7 +34,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * Marks a class that has {@link XmlElementDecl}s. * * @author

    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    • Sekhar Vajjhala, Sun Microsystems, Inc.
    - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 * @see XmlElementDecl */ @Retention(RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRootElement.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRootElement.java index 4216d4a8c9f..80506a4d05a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRootElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlRootElement.java @@ -155,7 +155,7 @@ import static java.lang.annotation.ElementType.TYPE; * * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({TYPE}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchema.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchema.java index 80756f387ee..756c5f298e1 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchema.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchema.java @@ -114,7 +114,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target(PACKAGE) @@ -191,7 +191,7 @@ public @interface XmlSchema { * such attribute), for example so that the user can specify a local * copy of the resource through the command line interface. * - * @since JAXB2.1 + * @since 1.6, JAXB 2.1 */ String location() default NO_LOCATION; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaType.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaType.java index 7484cc1cbc8..eac31a6533f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaType.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaType.java @@ -83,7 +83,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * } * * - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD,METHOD,PACKAGE}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaTypes.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaTypes.java index d32a6218ed0..deee2d408d6 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaTypes.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchemaTypes.java @@ -50,7 +50,7 @@ import java.lang.annotation.Target; * * @author
    • Sekhar Vajjhala, Sun Microsystems, Inc.
    * @see XmlSchemaType - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({PACKAGE}) public @interface XmlSchemaTypes { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSeeAlso.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSeeAlso.java index 41bf41e3b26..02053ff2502 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSeeAlso.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlSeeAlso.java @@ -70,7 +70,7 @@ import java.lang.annotation.Target; * correctly bind Dog and Cat. * * @author Kohsuke Kawaguchi - * @since JAXB2.1 + * @since 1.6, JAXB 2.1 */ @Target({ElementType.TYPE}) @Retention(RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlTransient.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlTransient.java index 730dea19228..fbd4d6eaa3c 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlTransient.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlTransient.java @@ -88,7 +88,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * * @author Sekhar Vajjhala, Sun Microsystems, Inc. - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD, METHOD, TYPE}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlType.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlType.java index 3802f978c3a..0f4b2506927 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlType.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlType.java @@ -379,7 +379,7 @@ import java.lang.annotation.Target; * @see XmlAttribute * @see XmlValue * @see XmlSchema - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({TYPE}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlValue.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlValue.java index dc18c2fcfe4..ecf23aceb49 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlValue.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/XmlValue.java @@ -124,7 +124,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * @author Sekhar Vajjhala, Sun Microsystems, Inc. * @see XmlType - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({FIELD, METHOD}) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java index b9c1b7d314b..9a589653c12 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java @@ -35,7 +35,7 @@ package javax.xml.bind.annotation.adapters; * sequnce of tab, CR, LF, and SP by a single whitespace character ' '. * * @author Kohsuke Kawaguchi - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public class CollapsedStringAdapter extends XmlAdapter { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/HexBinaryAdapter.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/HexBinaryAdapter.java index 84704a68831..153378a788d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/HexBinaryAdapter.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/HexBinaryAdapter.java @@ -34,7 +34,7 @@ import javax.xml.bind.DatatypeConverter; * This {@link XmlAdapter} binds byte[] to the hexBinary representation in XML. * * @author Kohsuke Kawaguchi - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public final class HexBinaryAdapter extends XmlAdapter { public byte[] unmarshal(String s) { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/NormalizedStringAdapter.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/NormalizedStringAdapter.java index 1ec0b11ca0f..3c64dd48bb2 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/NormalizedStringAdapter.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/NormalizedStringAdapter.java @@ -35,7 +35,7 @@ package javax.xml.bind.annotation.adapters; * as specified in the whitespace facet 'replace' * * @author Kohsuke Kawaguchi, Martin Grebac - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public final class NormalizedStringAdapter extends XmlAdapter { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlAdapter.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlAdapter.java index 8a047de8847..4ca79b0358d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlAdapter.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlAdapter.java @@ -160,7 +160,7 @@ package javax.xml.bind.annotation.adapters; * * @author
    • Sekhar Vajjhala, Sun Microsystems Inc.
    • Kohsuke Kawaguchi, Sun Microsystems Inc.
    * @see XmlJavaTypeAdapter - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 */ public abstract class XmlAdapter { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java index ab0cf949323..a296ae8e50e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java @@ -86,7 +86,7 @@ import static java.lang.annotation.ElementType.PACKAGE; *

    Example: See example in {@link XmlAdapter} * * @author

    • Sekhar Vajjhala, Sun Microsystems Inc.
    • Kohsuke Kawaguchi, Sun Microsystems Inc.
    - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 * @see XmlAdapter */ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java index c29493b42c8..6cebcf89dc9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java @@ -51,7 +51,7 @@ import java.lang.annotation.Target; * * @author
    • Sekhar Vajjhala, Sun Microsystems, Inc.
    * @see XmlJavaTypeAdapter - * @since JAXB2.0 + * @since 1.6, JAXB 2.0 */ @Retention(RUNTIME) @Target({PACKAGE}) public @interface XmlJavaTypeAdapters { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/package.html b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/package.html index 5e6a2a3d650..57f80e44acd 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/package.html +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/annotation/package.html @@ -279,7 +279,7 @@ - @since JAXB 2.0 + @since 1.6, JAXB 2.0 diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentMarshaller.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentMarshaller.java index 8d4892b61a5..dd291917a70 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentMarshaller.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentMarshaller.java @@ -50,7 +50,7 @@ import javax.xml.bind.Marshaller; * @author Marc Hadley * @author Kohsuke Kawaguchi * @author Joseph Fialli - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 * * @see Marshaller#setAttachmentMarshaller(AttachmentMarshaller) * diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java index 23d87215889..548f3c9bafe 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java @@ -56,7 +56,7 @@ import javax.activation.DataHandler; * @author Kohsuke Kawaguchi * @author Joseph Fialli * - * @since JAXB 2.0 + * @since 1.6, JAXB 2.0 * * @see javax.xml.bind.Unmarshaller#setAttachmentUnmarshaller(AttachmentUnmarshaller) * diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/package.html b/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/package.html index 5dca81dbd1a..c452cb9ad7f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/package.html +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/attachment/package.html @@ -61,7 +61,7 @@ - @since JAXB 2.0 + @since 1.6, JAXB 2.0 diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractMarshallerImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractMarshallerImpl.java index c2506d23a31..35d47b6c1c3 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractMarshallerImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractMarshallerImpl.java @@ -62,7 +62,7 @@ import java.io.IOException; * * @author
    • Kohsuke Kawaguchi, Sun Microsystems, Inc.
    * @see javax.xml.bind.Marshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public abstract class AbstractMarshallerImpl implements Marshaller { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java index 37e040881c0..e51d6338a8e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java @@ -68,7 +68,7 @@ import java.net.URL; *
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
  • * * @see javax.xml.bind.Unmarshaller - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public abstract class AbstractUnmarshallerImpl implements Unmarshaller { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/DefaultValidationEventHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/DefaultValidationEventHandler.java index 7fe68ef8c4c..b188eeaf1f3 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/DefaultValidationEventHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/DefaultValidationEventHandler.java @@ -52,7 +52,7 @@ import java.net.URL; * @see javax.xml.bind.Unmarshaller * @see javax.xml.bind.Validator * @see javax.xml.bind.ValidationEventHandler - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class DefaultValidationEventHandler implements ValidationEventHandler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/NotIdentifiableEventImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/NotIdentifiableEventImpl.java index e34c7889cac..c6e5311761d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/NotIdentifiableEventImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/NotIdentifiableEventImpl.java @@ -41,7 +41,7 @@ import javax.xml.bind.ValidationEventLocator; * @see javax.xml.bind.ValidationEventHandler * @see javax.xml.bind.ValidationEvent * @see javax.xml.bind.ValidationEventLocator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class NotIdentifiableEventImpl extends ValidationEventImpl diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ParseConversionEventImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ParseConversionEventImpl.java index 92b504848b2..4cfa28e0309 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ParseConversionEventImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ParseConversionEventImpl.java @@ -42,7 +42,7 @@ import javax.xml.bind.ValidationEventLocator; * @see javax.xml.bind.ValidationEventHandler * @see javax.xml.bind.ValidationEvent * @see javax.xml.bind.ValidationEventLocator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class ParseConversionEventImpl extends ValidationEventImpl diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/PrintConversionEventImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/PrintConversionEventImpl.java index 00de3b15a53..37d63a02e8d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/PrintConversionEventImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/PrintConversionEventImpl.java @@ -42,7 +42,7 @@ import javax.xml.bind.ValidationEventLocator; * @see javax.xml.bind.ValidationEventHandler * @see javax.xml.bind.ValidationEvent * @see javax.xml.bind.ValidationEventLocator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class PrintConversionEventImpl extends ValidationEventImpl diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventImpl.java index c357000617d..3b58bc5c9f0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventImpl.java @@ -43,7 +43,7 @@ import javax.xml.bind.ValidationEventLocator; * @see javax.xml.bind.ValidationEventHandler * @see javax.xml.bind.ValidationEvent * @see javax.xml.bind.ValidationEventLocator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class ValidationEventImpl implements ValidationEvent { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventLocatorImpl.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventLocatorImpl.java index 36da72658ee..306b9777358 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventLocatorImpl.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/helpers/ValidationEventLocatorImpl.java @@ -47,7 +47,7 @@ import org.xml.sax.SAXParseException; * @see javax.xml.bind.ValidationEventHandler * @see javax.xml.bind.ValidationEvent * @see javax.xml.bind.ValidationEventLocator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class ValidationEventLocatorImpl implements ValidationEventLocator { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBResult.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBResult.java index fbf7caac727..7dabf4fab56 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBResult.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBResult.java @@ -71,6 +71,7 @@ import javax.xml.transform.sax.SAXResult; * * @author * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) + * @since 1.6 */ public class JAXBResult extends SAXResult { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBSource.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBSource.java index 515894615fd..11b6c495c82 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBSource.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBSource.java @@ -87,6 +87,7 @@ import org.xml.sax.XMLFilter; * * @author * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) + * @since 1.6 */ public class JAXBSource extends SAXSource { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/bind/util/ValidationEventCollector.java b/jaxws/src/share/jaxws_classes/javax/xml/bind/util/ValidationEventCollector.java index 9cfd2abba16..48dfeea2f5c 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/bind/util/ValidationEventCollector.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/bind/util/ValidationEventCollector.java @@ -45,7 +45,7 @@ import java.util.List; * @see javax.xml.bind.ValidationEventHandler * @see javax.xml.bind.ValidationEvent * @see javax.xml.bind.ValidationEventLocator - * @since JAXB1.0 + * @since 1.6, JAXB 1.0 */ public class ValidationEventCollector implements ValidationEventHandler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/AttachmentPart.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/AttachmentPart.java index aa0f8565b4f..ae3390c82c1 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/AttachmentPart.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/AttachmentPart.java @@ -114,6 +114,8 @@ import javax.activation.DataHandler; *
      *     ap1.clearContent();
      * 
    + * + * @since 1.6 */ public abstract class AttachmentPart { @@ -190,7 +192,7 @@ public abstract class AttachmentPart { * AttachmentPart object or if there was a data * transformation error. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 * @see #getRawContentBytes */ public abstract InputStream getRawContent() throws SOAPException; @@ -208,7 +210,7 @@ public abstract class AttachmentPart { * AttachmentPart object or if there was a data * transformation error. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract byte[] getRawContentBytes() throws SOAPException; @@ -225,7 +227,7 @@ public abstract class AttachmentPart { * AttachmentPart object or if there was a data * transformation error. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract InputStream getBase64Content() throws SOAPException; @@ -267,7 +269,7 @@ public abstract class AttachmentPart { * * @exception SOAPException if an there is an error in setting the content * @exception NullPointerException if content is null - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract void setRawContent(InputStream content, String contentType) throws SOAPException; @@ -285,7 +287,7 @@ public abstract class AttachmentPart { * * @exception SOAPException if an there is an error in setting the content * or content is null - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract void setRawContentBytes( byte[] content, int offset, int len, String contentType) @@ -309,7 +311,7 @@ public abstract class AttachmentPart { * @exception SOAPException if an there is an error in setting the content * @exception NullPointerException if content is null * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract void setBase64Content( InputStream content, String contentType) throws SOAPException; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/Detail.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/Detail.java index 62f9973702b..d7d09bc34dc 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/Detail.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/Detail.java @@ -56,6 +56,8 @@ import javax.xml.namespace.QName; * d.addDetailEntry(name); * Iterator it = d.getDetailEntries(); * + * + * @since 1.6 */ public interface Detail extends SOAPFaultElement { @@ -85,7 +87,7 @@ public interface Detail extends SOAPFaultElement { * DetailEntry object to this Detail object. * * @see Detail#addDetailEntry(Name name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public DetailEntry addDetailEntry(QName qname) throws SOAPException; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/DetailEntry.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/DetailEntry.java index 6523ff660f3..6643dcbf7a2 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/DetailEntry.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/DetailEntry.java @@ -30,6 +30,8 @@ package javax.xml.soap; * a SOAPFault object. A DetailEntry object, * which carries information about errors related to the SOAPBody * object that contains it, is application-specific. + * + * @since 1.6 */ public interface DetailEntry extends SOAPElement { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/MessageFactory.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/MessageFactory.java index 8501297f3dc..f2094daaa1b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/MessageFactory.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/MessageFactory.java @@ -63,6 +63,8 @@ import java.io.InputStream; * This method can be used internally by a service implementation to * create a message that is a response to a request. * + * + * @since 1.6 */ public abstract class MessageFactory { @@ -140,7 +142,7 @@ public abstract class MessageFactory { * @exception SOAPException if there was an error in creating the * specified implementation of MessageFactory. * @see SAAJMetaFactory - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static MessageFactory newInstance(String protocol) throws SOAPException { return SAAJMetaFactory.getInstance().newMessageFactory(protocol); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeader.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeader.java index fa792036e37..b1416e7f813 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeader.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeader.java @@ -32,6 +32,7 @@ package javax.xml.soap; * object. * * @see MimeHeaders + * @since 1.6 */ public class MimeHeader { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeaders.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeaders.java index 282d5b30e18..b3ffa768137 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeaders.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/MimeHeaders.java @@ -39,6 +39,7 @@ import java.util.Vector; * API. * @see SOAPMessage#getAttachments * @see AttachmentPart + * @since 1.6 */ public class MimeHeaders { private Vector headers; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/Name.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/Name.java index 6ef60c2f6ec..7c227f19eb3 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/Name.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/Name.java @@ -73,6 +73,7 @@ package javax.xml.soap; * in favor of javax.xml.namespace.QName * @see SOAPEnvelope#createName(String, String, String) SOAPEnvelope.createName * @see SOAPFactory#createName(String, String, String) SOAPFactory.createName + * @since 1.6 */ public interface Name { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/Node.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/Node.java index 4488d92f3f2..1db693187cd 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/Node.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/Node.java @@ -30,6 +30,8 @@ package javax.xml.soap; * This interface extnends the standard DOM Node interface with methods for * getting and setting the value of a node, for * getting and setting the parent of a node, and for removing a node. + * + * @since 1.6 */ public interface Node extends org.w3c.dom.Node { /** @@ -61,7 +63,7 @@ public interface Node extends org.w3c.dom.Node { * node and either has more than one child node or has a child * node that is not a Text node. * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public void setValue(String value); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJMetaFactory.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJMetaFactory.java index e7fcf813aeb..d6516fd33de 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJMetaFactory.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJMetaFactory.java @@ -38,7 +38,7 @@ package javax.xml.soap; * class. * * @author SAAJ RI Development Team -* @since SAAJ 1.3 +* @since 1.6, SAAJ 1.3 */ public abstract class SAAJMetaFactory { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJResult.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJResult.java index 9899c81dd4a..f540940c102 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJResult.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SAAJResult.java @@ -35,7 +35,7 @@ import javax.xml.transform.dom.DOMResult; * * @author XWS-Security Development Team * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public class SAAJResult extends DOMResult { @@ -53,7 +53,7 @@ public class SAAJResult extends DOMResult { * * @throws SOAPException if there is a problem creating a SOAPMessage * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SAAJResult() throws SOAPException { this(MessageFactory.newInstance().createMessage()); @@ -79,7 +79,7 @@ public class SAAJResult extends DOMResult { * @throws SOAPException if a SOAPMessage supporting the * specified protocol cannot be created * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SAAJResult(String protocol) throws SOAPException { this(MessageFactory.newInstance(protocol).createMessage()); @@ -99,7 +99,7 @@ public class SAAJResult extends DOMResult { * populated as a result of some transformation or * marshalling operation * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SAAJResult(SOAPMessage message) { super(message.getSOAPPart()); @@ -116,7 +116,7 @@ public class SAAJResult extends DOMResult { * * @param rootNode - the root to which the results will be appended * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SAAJResult(SOAPElement rootNode) { super(rootNode); @@ -125,7 +125,7 @@ public class SAAJResult extends DOMResult { /** * @return the resulting Tree that was created under the specified root Node. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public javax.xml.soap.Node getResult() { return (javax.xml.soap.Node)super.getNode().getFirstChild(); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBody.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBody.java index 7ef27aed41c..ca4a9210f30 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBody.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBody.java @@ -42,6 +42,7 @@ import javax.xml.namespace.QName; * error information, is an example of a SOAPBodyElement object. * * @see SOAPFault + * @since 1.6 */ public interface SOAPBody extends SOAPElement { @@ -90,7 +91,7 @@ public interface SOAPBody extends SOAPElement { * @exception SOAPException if there is a SOAP error * @see SOAPFault#setFaultCode * @see SOAPFault#setFaultString - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public SOAPFault addFault(Name faultCode, String faultString, Locale locale) throws SOAPException; @@ -127,7 +128,7 @@ public interface SOAPBody extends SOAPElement { * @see SOAPFault#setFaultString * @see SOAPBody#addFault(Name faultCode, String faultString, Locale locale) * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPFault addFault(QName faultCode, String faultString, Locale locale) throws SOAPException; @@ -164,7 +165,7 @@ public interface SOAPBody extends SOAPElement { * if there is a SOAP error * @see SOAPFault#setFaultCode * @see SOAPFault#setFaultString - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public SOAPFault addFault(Name faultCode, String faultString) throws SOAPException; @@ -202,7 +203,7 @@ public interface SOAPBody extends SOAPElement { * @see SOAPFault#setFaultCode * @see SOAPFault#setFaultString * @see SOAPBody#addFault(Name faultCode, String faultString) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPFault addFault(QName faultCode, String faultString) throws SOAPException; @@ -252,7 +253,7 @@ public interface SOAPBody extends SOAPElement { * @exception SOAPException * if a SOAP error occurs * @see SOAPBody#addBodyElement(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPBodyElement addBodyElement(QName qname) throws SOAPException; @@ -272,7 +273,7 @@ public interface SOAPBody extends SOAPElement { * that was added. * @exception SOAPException * if the Document cannot be added - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public SOAPBodyElement addDocument(org.w3c.dom.Document document) throws SOAPException; @@ -290,7 +291,7 @@ public interface SOAPBody extends SOAPElement { * if there is not exactly one child SOAPElement of the * SOAPBody. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public org.w3c.dom.Document extractContentAsDocument() throws SOAPException; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBodyElement.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBodyElement.java index 7f0eb8db86a..2fcec639180 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBodyElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBodyElement.java @@ -38,6 +38,8 @@ package javax.xml.soap; *
      *    SOAPBodyElement sbe = sb.addBodyElement(myName);
      * 
    + * + * @since 1.6 */ public interface SOAPBodyElement extends SOAPElement { } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnection.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnection.java index ca06b1e7951..0151359b2af 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnection.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnection.java @@ -45,6 +45,8 @@ package javax.xml.soap; * directly to a URL following the request/response paradigm. That is, * messages are sent using the method call, which sends the * message and then waits until it gets a reply. + * + * @since 1.6 */ public abstract class SOAPConnection { @@ -78,7 +80,7 @@ public abstract class SOAPConnection { * @return the SOAPMessage object that is the response to the * get message request * @throws SOAPException if there is a SOAP error - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPMessage get(Object to) throws SOAPException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnectionFactory.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnectionFactory.java index c1e51f098c1..849b5dc8be3 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnectionFactory.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConnectionFactory.java @@ -32,6 +32,8 @@ package javax.xml.soap; * SAAJ communication infrastructure. Otherwise {@link SOAPConnection} objects * can be created by calling createConnection() on the newly * created SOAPConnectionFactory object. + * + * @since 1.6 */ public abstract class SOAPConnectionFactory { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConstants.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConstants.java index 8f5ae0b2dec..fe84fcfa2e6 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConstants.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPConstants.java @@ -29,6 +29,8 @@ import javax.xml.namespace.QName; /** * The definition of constants pertaining to the SOAP protocol. + * + * @since 1.6 */ public interface SOAPConstants { /** @@ -41,7 +43,7 @@ public interface SOAPConstants { * argument version of createMessage, an * UnsupportedOperationException. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String DYNAMIC_SOAP_PROTOCOL = "Dynamic Protocol"; @@ -49,7 +51,7 @@ public interface SOAPConstants { * Used to create MessageFactory instances that create * SOAPMessages whose behavior supports the SOAP 1.1 specification. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String SOAP_1_1_PROTOCOL = "SOAP 1.1 Protocol"; @@ -58,26 +60,26 @@ public interface SOAPConstants { * SOAPMessages whose behavior supports the SOAP 1.2 * specification * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String SOAP_1_2_PROTOCOL = "SOAP 1.2 Protocol"; /** * The default protocol: SOAP 1.1 for backwards compatibility. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String DEFAULT_SOAP_PROTOCOL = SOAP_1_1_PROTOCOL; /** * The namespace identifier for the SOAP 1.1 envelope. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String URI_NS_SOAP_1_1_ENVELOPE = "http://schemas.xmlsoap.org/soap/envelope/"; /** * The namespace identifier for the SOAP 1.2 envelope. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String URI_NS_SOAP_1_2_ENVELOPE = "http://www.w3.org/2003/05/soap-envelope"; @@ -102,21 +104,21 @@ public interface SOAPConstants { /** * The namespace identifier for the SOAP 1.2 encoding. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String URI_NS_SOAP_1_2_ENCODING = "http://www.w3.org/2003/05/soap-encoding"; /** * The media type of the Content-Type MIME header in SOAP 1.1. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String SOAP_1_1_CONTENT_TYPE = "text/xml"; /** * The media type of the Content-Type MIME header in SOAP 1.2. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String SOAP_1_2_CONTENT_TYPE = "application/soap+xml"; @@ -137,21 +139,21 @@ public interface SOAPConstants { * The URI identifying the next application processing a SOAP request as the intended * role for a SOAP 1.2 header entry (see section 2.2 of part 1 of the SOAP 1.2 * specification). - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String URI_SOAP_1_2_ROLE_NEXT = URI_NS_SOAP_1_2_ENVELOPE + "/role/next"; /** * The URI specifying the role None in SOAP 1.2. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String URI_SOAP_1_2_ROLE_NONE = URI_NS_SOAP_1_2_ENVELOPE + "/role/none"; /** * The URI identifying the ultimate receiver of the SOAP 1.2 message. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER = @@ -159,41 +161,41 @@ public interface SOAPConstants { /** * The default namespace prefix for http://www.w3.org/2003/05/soap-envelope - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final String SOAP_ENV_PREFIX = "env"; /** * SOAP 1.2 VersionMismatch Fault - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final QName SOAP_VERSIONMISMATCH_FAULT = new QName(URI_NS_SOAP_1_2_ENVELOPE, "VersionMismatch", SOAP_ENV_PREFIX); /** * SOAP 1.2 MustUnderstand Fault - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final QName SOAP_MUSTUNDERSTAND_FAULT = new QName(URI_NS_SOAP_1_2_ENVELOPE, "MustUnderstand", SOAP_ENV_PREFIX); /** * SOAP 1.2 DataEncodingUnknown Fault - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final QName SOAP_DATAENCODINGUNKNOWN_FAULT = new QName(URI_NS_SOAP_1_2_ENVELOPE, "DataEncodingUnknown", SOAP_ENV_PREFIX); /** * SOAP 1.2 Sender Fault - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final QName SOAP_SENDER_FAULT = new QName(URI_NS_SOAP_1_2_ENVELOPE, "Sender", SOAP_ENV_PREFIX); /** * SOAP 1.2 Receiver Fault - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static final QName SOAP_RECEIVER_FAULT = new QName(URI_NS_SOAP_1_2_ENVELOPE, "Receiver", SOAP_ENV_PREFIX); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElement.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElement.java index 4a55a60b22c..b4d8bca6006 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElement.java @@ -40,6 +40,8 @@ import javax.xml.namespace.QName; * objects of the correct type. See {@link #getChildElements()} and * {@link javax.xml.soap} * for details. + * + * @since 1.6 */ public interface SOAPElement extends Node, org.w3c.dom.Element { @@ -74,7 +76,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * @exception SOAPException if there is an error in creating the * SOAPElement object * @see SOAPElement#addChildElement(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPElement addChildElement(QName qname) throws SOAPException; @@ -173,7 +175,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * is also useful for recycling portions of a document within a SOAP * message. * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public abstract void removeContents(); @@ -224,7 +226,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { an attribute with QName qname on this SOAPElement. * @see SOAPElement#addAttribute(Name, String) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPElement addAttribute(QName qname, String value) throws SOAPException; @@ -261,7 +263,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * @return a String giving the value of the specified * attribute, Null if there is no such attribute * @see SOAPElement#getAttributeValue(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public String getAttributeValue(QName qname); @@ -287,7 +289,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * * @return an iterator over the QNames of the attributes * @see SOAPElement#getAllAttributes() - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public Iterator getAllAttributesAsQNames(); @@ -322,7 +324,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * @return an iterator over the namespace prefixes are within scope of this * SOAPElement object * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Iterator getVisibleNamespacePrefixes(); @@ -348,7 +350,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * * @exception SOAPException if the QName cannot be created. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public QName createQName(String localName, String prefix) throws SOAPException; @@ -366,7 +368,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * @return a QName object with the qname of this * SOAPElement object * @see SOAPElement#getElementName() - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public QName getElementQName(); @@ -386,7 +388,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * is not allowed. * @return The renamed Node * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPElement setElementQName(QName newName) throws SOAPException; @@ -409,7 +411,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * @return true if the attribute was * removed successfully; false if it was not * @see SOAPElement#removeAttribute(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public boolean removeAttribute(QName qname); @@ -496,7 +498,7 @@ public interface SOAPElement extends Node, org.w3c.dom.Element { * in this SOAPElement object with the * specified qname * @see SOAPElement#getChildElements(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public Iterator getChildElements(QName qname); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElementFactory.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElementFactory.java index ff6a8ddf314..a45a3db59e8 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElementFactory.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPElementFactory.java @@ -37,6 +37,7 @@ package javax.xml.soap; * inserted. * @deprecated - Use javax.xml.soap.SOAPFactory for creating SOAPElements. * @see javax.xml.soap.SOAPFactory + * @since 1.6 */ public class SOAPElementFactory { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPEnvelope.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPEnvelope.java index 0839e7fbe23..a32d535f3ec 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPEnvelope.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPEnvelope.java @@ -93,6 +93,8 @@ package javax.xml.soap; * Name name = se.createName("GetLastTradePrice", "WOMBAT", * "http://www.wombat.org/trader"); * + * + * @since 1.6 */ public interface SOAPEnvelope extends SOAPElement { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPException.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPException.java index 333c772e9e0..669130204e9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPException.java @@ -39,6 +39,8 @@ package javax.xml.soap; * the provider. Reasons for embedding a Throwable * object include problems such as input/output errors or a parsing * problem, such as an error in parsing a header. + * + * @since 1.6 */ public class SOAPException extends Exception { private Throwable cause; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFactory.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFactory.java index 5f8778e7e5b..c32f6926519 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFactory.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFactory.java @@ -43,6 +43,7 @@ import org.w3c.dom.Element; * javax.xml.soap.Detail objects as well as * java.xml.soap.Name objects. * + * @since 1.6 */ public abstract class SOAPFactory { @@ -77,7 +78,7 @@ public abstract class SOAPFactory { * @exception SOAPException if there is an error in creating the * SOAPElement object * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPElement createElement(Element domElement) throws SOAPException { throw new UnsupportedOperationException("createElement(org.w3c.dom.Element) must be overridden by all subclasses of SOAPFactory."); @@ -120,7 +121,7 @@ public abstract class SOAPFactory { * @exception SOAPException if there is an error in creating the * SOAPElement object * @see SOAPFactory#createElement(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPElement createElement(QName qname) throws SOAPException { throw new UnsupportedOperationException("createElement(QName) must be overridden by all subclasses of SOAPFactory."); @@ -188,7 +189,7 @@ public abstract class SOAPFactory { *@param faultCode the FaultCode for the fault *@return a SOAPFault object *@throws SOAPException if there is a SOAP error - *@since SAAJ 1.3 + *@since 1.6, SAAJ 1.3 */ public abstract SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException; @@ -196,7 +197,7 @@ public abstract class SOAPFactory { *Creates a new default SOAPFault object *@return a SOAPFault object *@throws SOAPException if there is a SOAP error - *@since SAAJ 1.3 + *@since 1.6, SAAJ 1.3 */ public abstract SOAPFault createFault() throws SOAPException; @@ -290,7 +291,7 @@ public abstract class SOAPFactory { * @exception SOAPException if there was an error creating the * specified SOAPFactory * @see SAAJMetaFactory - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public static SOAPFactory newInstance(String protocol) throws SOAPException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFault.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFault.java index ee05dfc2d6d..67d3c6004d3 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFault.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFault.java @@ -42,6 +42,8 @@ import javax.xml.namespace.QName; * Depending on the protocol specified while creating the * MessageFactory instance, a SOAPFault has * sub-elements as defined in the SOAP 1.1/SOAP 1.2 specification. + * + * @since 1.6 */ public interface SOAPFault extends SOAPBodyElement { @@ -72,7 +74,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception SOAPException if there was an error in adding the * faultcode element to the underlying XML tree. * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public void setFaultCode(Name faultCodeQName) throws SOAPException; @@ -91,7 +93,7 @@ public interface SOAPFault extends SOAPBodyElement { * @see #setFaultCode(Name) * @see #getFaultCodeAsQName() * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void setFaultCode(QName faultCodeQName) throws SOAPException; @@ -128,7 +130,7 @@ public interface SOAPFault extends SOAPBodyElement { * @return a Name representing the faultcode * @see #setFaultCode(Name) * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Name getFaultCodeAsName(); @@ -141,7 +143,7 @@ public interface SOAPFault extends SOAPBodyElement { * * @see #setFaultCode(QName) * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public QName getFaultCodeAsQName(); @@ -158,7 +160,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Subcode. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public Iterator getFaultSubcodes(); @@ -171,7 +173,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Subcode. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void removeAllFaultSubcodes(); @@ -187,7 +189,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Subcode. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void appendFaultSubcode(QName subcode) throws SOAPException; @@ -270,7 +272,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception SOAPException if there was an error in adding the * faultString to the underlying XML tree. * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public void setFaultString(String faultString, Locale locale) throws SOAPException; @@ -315,7 +317,7 @@ public interface SOAPFault extends SOAPBodyElement { * the fault string or null if no locale was specified * @see #setFaultString(String, Locale) * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Locale getFaultStringLocale(); @@ -327,7 +329,7 @@ public interface SOAPFault extends SOAPBodyElement { * @return true if this SOAPFault has a Detail * subelement and false otherwise. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public boolean hasDetail(); @@ -377,7 +379,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Reason. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public Iterator getFaultReasonLocales() throws SOAPException; @@ -393,7 +395,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Reason. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public Iterator getFaultReasonTexts() throws SOAPException; @@ -414,7 +416,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Reason. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public String getFaultReasonText(Locale locale) throws SOAPException; @@ -441,7 +443,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Reason. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void addFaultReasonText(String text, java.util.Locale locale) throws SOAPException; @@ -457,7 +459,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Node. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public String getFaultNode(); @@ -472,7 +474,7 @@ public interface SOAPFault extends SOAPBodyElement { * support the SOAP 1.2 concept of Fault Node. * * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void setFaultNode(String uri) throws SOAPException; @@ -487,7 +489,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Role. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public String getFaultRole(); @@ -504,7 +506,7 @@ public interface SOAPFault extends SOAPBodyElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Role. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void setFaultRole(String uri) throws SOAPException; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFaultElement.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFaultElement.java index f89b4c04393..fcf3a02f80d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFaultElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFaultElement.java @@ -32,6 +32,8 @@ package javax.xml.soap; *

    * Content is added to a SOAPFaultElement using the * SOAPElement method addTextNode. + * + * @since 1.6 */ public interface SOAPFaultElement extends SOAPElement { } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeader.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeader.java index dd10957f0ed..870b423c70b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeader.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeader.java @@ -66,6 +66,7 @@ import javax.xml.namespace.QName; * * * @see SOAPHeaderElement + * @since 1.6 */ public interface SOAPHeader extends SOAPElement { /** @@ -92,7 +93,7 @@ public interface SOAPHeader extends SOAPElement { * inserted into this SOAPHeader object * @exception SOAPException if a SOAP error occurs * @see SOAPHeader#addHeaderElement(Name) - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPHeaderElement addHeaderElement(QName qname) throws SOAPException; @@ -115,7 +116,7 @@ public interface SOAPHeader extends SOAPElement { * @see #extractHeaderElements * @see SOAPConstants#URI_SOAP_ACTOR_NEXT * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Iterator examineMustUnderstandHeaderElements(String actor); @@ -180,7 +181,7 @@ public interface SOAPHeader extends SOAPElement { * inserted into this SOAPHeader object * @exception SOAPException if a SOAP error occurs. * @exception UnsupportedOperationException if this is a SOAP 1.1 Header. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPHeaderElement addNotUnderstoodHeaderElement(QName name) throws SOAPException; @@ -196,7 +197,7 @@ public interface SOAPHeader extends SOAPElement { * @return the new SOAPHeaderElement object that was * inserted into this SOAPHeader object * @exception SOAPException if a SOAP error occurs. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSOAPURIs) throws SOAPException; @@ -211,7 +212,7 @@ public interface SOAPHeader extends SOAPElement { * @return the new SOAPHeaderElement object that was * inserted into this SOAPHeader object * @exception SOAPException if a SOAP error occurs. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) throws SOAPException; @@ -226,7 +227,7 @@ public interface SOAPHeader extends SOAPElement { * @return the new SOAPHeaderElement object that was * inserted into this SOAPHeader object * @exception SOAPException if a SOAP error occurs. - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public SOAPHeaderElement addUpgradeHeaderElement(String supportedSoapUri) throws SOAPException; @@ -240,7 +241,7 @@ public interface SOAPHeader extends SOAPElement { * SOAPHeader * @see #extractAllHeaderElements * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Iterator examineAllHeaderElements(); @@ -255,7 +256,7 @@ public interface SOAPHeader extends SOAPElement { * * @see #examineAllHeaderElements * - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Iterator extractAllHeaderElements(); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeaderElement.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeaderElement.java index 29f331964fc..f6755f1c372 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeaderElement.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPHeaderElement.java @@ -33,6 +33,8 @@ package javax.xml.soap; *

    * A SOAPHeaderElement object can have other * SOAPElement objects as its children. + * + * @since 1.6 */ public interface SOAPHeaderElement extends SOAPElement { @@ -65,7 +67,7 @@ public interface SOAPHeaderElement extends SOAPElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Role. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void setRole(String uri) throws SOAPException; @@ -89,7 +91,7 @@ public interface SOAPHeaderElement extends SOAPElement { * @exception UnsupportedOperationException if this message does not * support the SOAP 1.2 concept of Fault Role. * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public String getRole(); @@ -143,7 +145,7 @@ public interface SOAPHeaderElement extends SOAPElement { * @see #setMustUnderstand * @see #getRelay * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public void setRelay(boolean relay) throws SOAPException; @@ -160,7 +162,7 @@ public interface SOAPHeaderElement extends SOAPElement { * @see #getMustUnderstand * @see #setRelay * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public boolean getRelay(); } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPMessage.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPMessage.java index a86f73865b1..821c64817e9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPMessage.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPMessage.java @@ -100,6 +100,7 @@ import javax.activation.DataHandler; * * @see MessageFactory * @see AttachmentPart + * @since 1.6 */ public abstract class SOAPMessage { /** @@ -108,7 +109,7 @@ public abstract class SOAPMessage { * supported values. The default is "utf-8". * * @see SOAPMessage#setProperty(String, Object) SOAPMessage.setProperty - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public static final String CHARACTER_SET_ENCODING = "javax.xml.soap.character-set-encoding"; @@ -119,7 +120,7 @@ public abstract class SOAPMessage { * "false". * * @see SOAPMessage#setProperty(String, Object) SOAPMessage.setProperty - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public static final String WRITE_XML_DECLARATION = "javax.xml.soap.write-xml-declaration"; @@ -163,7 +164,7 @@ public abstract class SOAPMessage { * object * @exception SOAPException * if the SOAP Body does not exist or cannot be retrieved - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public SOAPBody getSOAPBody() throws SOAPException { throw new UnsupportedOperationException("getSOAPBody must be overridden by all subclasses of SOAPMessage"); @@ -178,7 +179,7 @@ public abstract class SOAPMessage { * object * @exception SOAPException * if the SOAP Header does not exist or cannot be retrieved - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public SOAPHeader getSOAPHeader() throws SOAPException { throw new UnsupportedOperationException("getSOAPHeader must be overridden by all subclasses of SOAPMessage"); @@ -230,7 +231,7 @@ public abstract class SOAPMessage { * @param headers * a MimeHeaders object containing the MIME * headers for which to search - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract void removeAttachments(MimeHeaders headers); @@ -258,7 +259,7 @@ public abstract class SOAPMessage { * @throws SOAPException if there is an error in the attempt to access the * attachment * - * @since SAAJ 1.3 + * @since 1.6, SAAJ 1.3 */ public abstract AttachmentPart getAttachment(SOAPElement element) throws SOAPException; @@ -432,7 +433,7 @@ public abstract class SOAPMessage { * the value to be associated with the specified property * @exception SOAPException * if the property name is not recognized. - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public void setProperty(String property, Object value) throws SOAPException { @@ -448,7 +449,7 @@ public abstract class SOAPMessage { * if no such property exists. * @exception SOAPException * if the property name is not recognized. - * @since SAAJ 1.2 + * @since 1.6, SAAJ 1.2 */ public Object getProperty(String property) throws SOAPException { throw new UnsupportedOperationException("getProperty must be overridden by all subclasses of SOAPMessage"); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPPart.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPPart.java index ab605b6f757..dc280fab60e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPPart.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPPart.java @@ -64,6 +64,8 @@ import javax.xml.transform.Source; * The SOAPPart method getEnvelope can be used * to retrieve the SOAPEnvelope object. *

    + * + * @since 1.6 */ public abstract class SOAPPart implements org.w3c.dom.Document, Node { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/soap/Text.java b/jaxws/src/share/jaxws_classes/javax/xml/soap/Text.java index c385e1646d5..49f0e2cb19f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/soap/Text.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/soap/Text.java @@ -29,6 +29,7 @@ package javax.xml.soap; * A representation of a node whose value is text. A Text object * may represent text that is content or text that is a comment. * + * @since 1.6 */ public interface Text extends Node, org.w3c.dom.Text { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Action.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Action.java index daadc48d1f6..f42190b295e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Action.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Action.java @@ -118,7 +118,7 @@ import java.lang.annotation.Target; * * @see FaultAction * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @Documented diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/AsyncHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/AsyncHandler.java index 6f553b0a5c6..66acc97af26 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/AsyncHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/AsyncHandler.java @@ -29,7 +29,7 @@ package javax.xml.ws; * clients that wish to receive callback notification of the completion of * service endpoint operations invoked asynchronously. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface AsyncHandler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Binding.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Binding.java index 9c92f1eed96..24be0222c67 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Binding.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Binding.java @@ -29,7 +29,7 @@ package javax.xml.ws; /** The Binding interface is the base interface * for JAX-WS protocol bindings. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface Binding { @@ -61,7 +61,7 @@ public interface Binding { * @return String The binding identifier for the port. * Never returns null * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ String getBindingID(); } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingProvider.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingProvider.java index bac4d26ccd9..11194fd5078 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingProvider.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingProvider.java @@ -33,7 +33,7 @@ import javax.xml.ws.wsaddressing.W3CEndpointReference; * protocol binding and associated context objects for request and * response message processing. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * * @see javax.xml.ws.Binding **/ @@ -154,7 +154,7 @@ public interface BindingProvider { * * @see W3CEndpointReference * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public EndpointReference getEndpointReference(); @@ -176,7 +176,7 @@ public interface BindingProvider { * @throws java.lang.UnsupportedOperationException If this * BindingProvider uses the XML/HTTP binding. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public T getEndpointReference(Class clazz); } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingType.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingType.java index 29ce8757287..0976add7606 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingType.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/BindingType.java @@ -39,7 +39,7 @@ import java.lang.annotation.RetentionPolicy; * This annotation may be overriden programmatically or via * deployment descriptors, depending on the platform in use. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * **/ @Target(ElementType.TYPE) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Dispatch.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Dispatch.java index f1f38a35883..7c96bab57d8 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Dispatch.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Dispatch.java @@ -33,7 +33,7 @@ import java.util.concurrent.Future; * class acts as a factory for the creation of Dispatch * instances. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface Dispatch extends BindingProvider { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Endpoint.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Endpoint.java index 484c6510e43..1cb19ea1590 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Endpoint.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Endpoint.java @@ -61,7 +61,7 @@ import org.w3c.dom.Element; * as possible instead of generating new ones based on the annotations * present on the implementor. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * * @see javax.xml.ws.Binding * @see javax.xml.ws.BindingType @@ -119,7 +119,7 @@ public abstract class Endpoint { * * * @return The newly created endpoint. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 * */ public static Endpoint create(Object implementor, WebServiceFeature ... features) { @@ -166,7 +166,7 @@ public abstract class Endpoint { * parameter will have their default values. * * @return The newly created endpoint. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public static Endpoint create(String bindingId, Object implementor, WebServiceFeature ... features) { return Provider.provider().createEndpoint(bindingId, implementor, features); @@ -266,7 +266,7 @@ public abstract class Endpoint { * If a java.lang.SecurityManger * is being used and the application doesn't have the * WebServicePermission("publishEndpoint") permission. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public static Endpoint publish(String address, Object implementor, WebServiceFeature ... features) { return Provider.provider().createAndPublishEndpoint(address, implementor, features); @@ -330,7 +330,7 @@ public abstract class Endpoint { * If a java.lang.SecurityManger * is being used and the application doesn't have the * WebServicePermission("publishEndpoint") permission. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public void publish(HttpContext serverContext) { throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour."); @@ -446,7 +446,7 @@ public abstract class Endpoint { * * @see W3CEndpointReference * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract EndpointReference getEndpointReference(Element... referenceParameters); @@ -472,7 +472,7 @@ public abstract class Endpoint { * uses the XML/HTTP binding. * * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract T getEndpointReference(Class clazz, Element... referenceParameters); @@ -490,7 +490,7 @@ public abstract class Endpoint { * @throws java.lang.IllegalStateException * If the endpoint has been published already or it has been stopped. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public void setEndpointContext(EndpointContext ctxt) { throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour."); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointContext.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointContext.java index 13bc527fc21..b1a4b49db59 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointContext.java @@ -42,7 +42,7 @@ import java.util.Set; * before {@link Endpoint#publish} methods. * * @author Jitendra Kotamraju - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public abstract class EndpointContext { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointReference.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointReference.java index 6ef626b4d17..3ed68c0511f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointReference.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointReference.java @@ -81,7 +81,7 @@ import java.io.StringWriter; * * @see W3CEndpointReference * @see Service - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @XmlTransient // to treat this class like Object as far as databinding is concerned (proposed JAXB 2.1 feature) public abstract class EndpointReference { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java index 0e29a0aa858..43e37f608ea 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java @@ -145,7 +145,7 @@ import java.lang.annotation.Target; * </definitions> * * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @Documented diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Holder.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Holder.java index 8eddf0575f9..8f58f34eda1 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Holder.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Holder.java @@ -30,7 +30,7 @@ import java.io.Serializable; /** * Holds a value of type T. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 */ public final class Holder implements Serializable { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/LogicalMessage.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/LogicalMessage.java index 19b5be1dfd0..4f50c1604b5 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/LogicalMessage.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/LogicalMessage.java @@ -32,7 +32,7 @@ import javax.xml.bind.JAXBContext; * protocol agnostic XML message and contains methods that * provide access to the payload of the message. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface LogicalMessage { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/ProtocolException.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/ProtocolException.java index 16ba0dae50d..5ea3926db9f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/ProtocolException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/ProtocolException.java @@ -30,7 +30,7 @@ package javax.xml.ws; * are used to communicate protocol level fault information to clients and may * be used on the server to control the protocol specific fault representation. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public class ProtocolException extends WebServiceException { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Provider.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Provider.java index 79d26450baa..78c7b717948 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Provider.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Provider.java @@ -38,7 +38,7 @@ package javax.xml.ws; * the Provider instance will receive entire protocol messages * or just message payloads. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * * @see javax.xml.transform.Source * @see javax.xml.soap.SOAPMessage diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/RequestWrapper.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/RequestWrapper.java index a33af7c3d33..34b6b6a33d4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/RequestWrapper.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/RequestWrapper.java @@ -40,7 +40,7 @@ import java.lang.annotation.RetentionPolicy; * overloading conflicts in document literal mode. Only the className * is required in this case. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ @Target(ElementType.METHOD) @@ -65,7 +65,7 @@ public @interface RequestWrapper { /** * wsdl:part name for the wrapper part * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public String partName() default ""; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBinding.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBinding.java index c71a3215e9a..e5357873ec1 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBinding.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBinding.java @@ -54,7 +54,7 @@ import javax.xml.ws.spi.WebServiceFeatureAnnotation; * * @see RespectBindingFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBindingFeature.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBindingFeature.java index 51320734bc4..5bf7bdd7ec0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBindingFeature.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBindingFeature.java @@ -80,7 +80,7 @@ import javax.xml.ws.soap.AddressingFeature; * * @see AddressingFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public final class RespectBindingFeature extends WebServiceFeature { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Response.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Response.java index 8d5451f3be2..e98ae8b20a0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Response.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Response.java @@ -39,7 +39,7 @@ import java.util.concurrent.Future; * {@link WebServiceException} that represents the error that occured during the * asynchronous method invocation.

    * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface Response extends Future { /** Gets the contained response context. diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/ResponseWrapper.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/ResponseWrapper.java index 3d7bb75051b..0bb891a9c66 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/ResponseWrapper.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/ResponseWrapper.java @@ -39,7 +39,7 @@ import java.lang.annotation.RetentionPolicy; * overloading conflicts in document literal mode. Only the className * is required in this case. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ @Target(ElementType.METHOD) @@ -65,7 +65,7 @@ public @interface ResponseWrapper { /** * wsdl:part name for the wrapper part * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public String partName() default ""; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/Service.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/Service.java index 77b77e23c63..a31df76c9df 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/Service.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/Service.java @@ -57,7 +57,7 @@ import javax.xml.ws.spi.Provider; * can be enabled by creating a ThreadPoolExecutor and * registering it with the service. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * * @see javax.xml.ws.spi.Provider * @see javax.xml.ws.handler.HandlerResolver @@ -153,7 +153,7 @@ public class Service { * @see java.lang.reflect.InvocationHandler * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public T getPort(QName portName, Class serviceEndpointInterface, WebServiceFeature... features) { @@ -219,7 +219,7 @@ public class Service { * * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public T getPort(Class serviceEndpointInterface, WebServiceFeature... features) { @@ -297,7 +297,7 @@ public class Service { * with this port or is unsupported. * * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public T getPort(EndpointReference endpointReference, Class serviceEndpointInterface, WebServiceFeature... features) { @@ -381,7 +381,7 @@ public class Service { * @see javax.xml.soap.SOAPMessage * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public Dispatch createDispatch(QName portName, Class type, Service.Mode mode, WebServiceFeature... features) { @@ -456,7 +456,7 @@ public class Service { * @see javax.xml.soap.SOAPMessage * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public Dispatch createDispatch(EndpointReference endpointReference, Class type, Service.Mode mode, @@ -514,7 +514,7 @@ public class Service { * @see javax.xml.bind.JAXBContext * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public Dispatch createDispatch(QName portName, JAXBContext context, Service.Mode mode, WebServiceFeature... features) { @@ -587,7 +587,7 @@ public class Service { * @see javax.xml.bind.JAXBContext * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public Dispatch createDispatch(EndpointReference endpointReference, JAXBContext context, Service.Mode mode, @@ -722,7 +722,7 @@ public class Service { * it must throw a WebServiceException. * @throws WebServiceException If any error in creation of the * specified service. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 **/ public static Service create( java.net.URL wsdlDocumentLocation, @@ -752,7 +752,7 @@ public class Service { * @throws WebServiceException If any error in creation of the * specified service * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public static Service create(QName serviceName, WebServiceFeature ... features) { return new Service(null, serviceName, features); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/ServiceMode.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/ServiceMode.java index a451cd5fbae..84624794734 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/ServiceMode.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/ServiceMode.java @@ -36,7 +36,7 @@ import java.lang.annotation.Inherited; * Used to indicate whether a {@link Provider} implementation wishes to work * with entire protocol messages or just with protocol message payloads. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebEndpoint.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebEndpoint.java index ebff61a1abc..3654ef202d0 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebEndpoint.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebEndpoint.java @@ -41,7 +41,7 @@ import java.lang.annotation.RetentionPolicy; * determined based on the value of the WebServiceClient * annotation on the generated service interface itself. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * * @see javax.xml.ws.WebServiceClient **/ diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebFault.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebFault.java index 7135c26f96b..f3abbee0358 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebFault.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebFault.java @@ -36,7 +36,7 @@ import java.lang.annotation.RetentionPolicy; * to the local and namespace name of the fault element and the name * of the fault bean. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @@ -60,7 +60,7 @@ public @interface WebFault { /** * wsdl:Message's name. Default name is the exception's class name. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public String messageName() default ""; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceClient.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceClient.java index d1e84128915..0d40a1fb47d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceClient.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceClient.java @@ -40,7 +40,7 @@ import java.lang.annotation.RetentionPolicy; * element represents the Web service for which the generated * service interface provides a client view. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceContext.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceContext.java index 618592ddbef..8ba63ab75a4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceContext.java @@ -41,7 +41,7 @@ import org.w3c.dom.Element; * into an endpoint implementation class using the * Resource annotation. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * * @see javax.annotation.Resource **/ @@ -120,7 +120,7 @@ public interface WebServiceContext { * * @see W3CEndpointReference * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public EndpointReference getEndpointReference(Element... referenceParameters); @@ -144,7 +144,7 @@ public interface WebServiceContext { * @throws WebServiceException If the clazz type of * EndpointReference is not supported. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public T getEndpointReference(Class clazz, Element... referenceParameters); diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceException.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceException.java index aaf116bf143..acd122b3a91 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceException.java @@ -28,7 +28,7 @@ package javax.xml.ws; /** The WebServiceException class is the base * exception class for all JAX-WS API runtime exceptions. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public class WebServiceException extends java.lang.RuntimeException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceFeature.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceFeature.java index a08f95dbbff..ea60d367ff5 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceFeature.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceFeature.java @@ -44,7 +44,7 @@ package javax.xml.ws; * @see javax.xml.ws.soap.AddressingFeature * @see javax.xml.ws.soap.MTOMFeature * - * @since 2.1 + * @since 1.6, JAX-WS 2.1 */ public abstract class WebServiceFeature { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServicePermission.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServicePermission.java index d0ecad9aa21..743243f22f6 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServicePermission.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServicePermission.java @@ -55,6 +55,7 @@ import java.security.BasicPermission; * @see java.security.Permissions * @see java.lang.SecurityManager * @see java.net.SocketPermission + * @since 1.6 */ public final class WebServicePermission extends BasicPermission { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceProvider.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceProvider.java index 4dfcaad9590..c2d48d2f5b9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceProvider.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceProvider.java @@ -33,7 +33,7 @@ import java.lang.annotation.RetentionPolicy; /** * Used to annotate a Provider implementation class. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * @see javax.xml.ws.Provider */ @Target(ElementType.TYPE) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java index fe01112906c..4d5c70e0a64 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java @@ -75,7 +75,7 @@ import java.lang.annotation.RetentionPolicy; * @see javax.annotation.Resource * @see WebServiceFeatureAnnotation * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 * **/ @@ -143,7 +143,7 @@ public @interface WebServiceRef { * A portable JNDI lookup name that resolves to the target * web service reference. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ String lookup() default ""; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRefs.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRefs.java index c77749bb510..10104f35d3e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRefs.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRefs.java @@ -69,7 +69,7 @@ import static java.lang.annotation.RetentionPolicy.*; * * * @see WebServiceRef - * @since 2.0 + * @since 1.6, JAX-WS 2.0 */ @Documented diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/Handler.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/Handler.java index ec278114012..dfd972b705c 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/Handler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/Handler.java @@ -31,7 +31,7 @@ import javax.xml.ws.handler.MessageContext; /** The Handler interface * is the base interface for JAX-WS handlers. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface Handler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/HandlerResolver.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/HandlerResolver.java index 3c3e04f8ce6..c0f2f97361b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/HandlerResolver.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/HandlerResolver.java @@ -39,7 +39,7 @@ package javax.xml.ws.handler; * * @see javax.xml.ws.Service#setHandlerResolver * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface HandlerResolver { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalHandler.java index cc95233c938..c5e9589d24b 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalHandler.java @@ -28,7 +28,7 @@ package javax.xml.ws.handler; /** The LogicalHandler extends * Handler to provide typesafety for the message context parameter. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface LogicalHandler extends Handler { } diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalMessageContext.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalMessageContext.java index 24c09dae3a5..0ae213ba063 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalMessageContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/LogicalMessageContext.java @@ -32,7 +32,7 @@ import javax.xml.ws.LogicalMessage; * provide access to a the contained message as a protocol neutral * LogicalMessage * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface LogicalMessageContext extends MessageContext { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/MessageContext.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/MessageContext.java index a893c749651..35525fc0440 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/MessageContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/MessageContext.java @@ -36,7 +36,7 @@ import java.util.Map; * enable handlers in a handler chain to share processing related * state. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 */ public interface MessageContext extends Map { @@ -168,7 +168,7 @@ public interface MessageContext extends Map { * wsa:IsReferenceParameter="true" attribute. *

    Type: List<Element> * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public static final String REFERENCE_PARAMETERS = "javax.xml.ws.reference.parameters"; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/PortInfo.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/PortInfo.java index ee91456abdf..5f1b2c2dad9 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/PortInfo.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/PortInfo.java @@ -35,7 +35,7 @@ import javax.xml.namespace.QName; * This interface is never implemented by an application, * only by a JAX-WS implementation. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface PortInfo { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPHandler.java index ba9232726c2..98a43cd181a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPHandler.java @@ -33,7 +33,7 @@ import java.util.Set; * to provide typesafety for the message context parameter and add a method * to obtain access to the headers that may be processed by the handler. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface SOAPHandler extends Handler { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPMessageContext.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPMessageContext.java index 2df709f7721..cf75e7d13fa 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPMessageContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/handler/soap/SOAPMessageContext.java @@ -38,7 +38,7 @@ import java.util.Set; * * @see javax.xml.soap.SOAPMessage * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface SOAPMessageContext extends javax.xml.ws.handler.MessageContext { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPBinding.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPBinding.java index 8d4e0d0de33..233a0a702f4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPBinding.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPBinding.java @@ -31,7 +31,7 @@ import javax.xml.ws.Binding; /** The HTTPBinding interface is an * abstraction for the XML/HTTP binding. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface HTTPBinding extends Binding { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPException.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPException.java index 4796394eb39..592e302f054 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/http/HTTPException.java @@ -32,7 +32,7 @@ package javax.xml.ws.http; *

    Since there is no standard format for faults or exceptions * in XML/HTTP messaging, only the HTTP status code is captured. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public class HTTPException extends javax.xml.ws.ProtocolException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/Addressing.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/Addressing.java index 163d0f538b1..5dbb42d26da 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/Addressing.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/Addressing.java @@ -57,7 +57,7 @@ import javax.xml.ws.spi.WebServiceFeatureAnnotation; * This annotation's behaviour is defined by the corresponding feature * {@link AddressingFeature}. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @@ -106,7 +106,7 @@ public @interface Addressing { * * 3.1.3 NonAnonymousResponses Assertion in the generated WSDL. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ Responses responses() default Responses.ALL; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/AddressingFeature.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/AddressingFeature.java index dfd95c739f0..8f9d730d797 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/AddressingFeature.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/AddressingFeature.java @@ -112,7 +112,7 @@ import javax.xml.ws.Service; * for more information on WS-Addressing. * * @see Addressing - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public final class AddressingFeature extends WebServiceFeature { @@ -151,7 +151,7 @@ public final class AddressingFeature extends WebServiceFeature { * * 3.1.3 NonAnonymousResponses Assertion in the generated WSDL. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public enum Responses { /** @@ -229,7 +229,7 @@ public final class AddressingFeature extends WebServiceFeature { * @param required true means requires the use of ws-addressing . * @param responses specifies what type of responses are required * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public AddressingFeature(boolean enabled, boolean required, Responses responses) { this.enabled = enabled; @@ -268,7 +268,7 @@ public final class AddressingFeature extends WebServiceFeature { * {@link Responses#NON_ANONYMOUS} when endpoint requires the use * of only non-anonymous responses * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public Responses getResponses() { return responses; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOM.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOM.java index 995727497dd..da6714e9a7e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOM.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOM.java @@ -54,7 +54,7 @@ import javax.xml.ws.WebServiceProvider; * This annotation's behaviour is defined by the corresponding feature * {@link MTOMFeature}. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOMFeature.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOMFeature.java index a9581070088..232f98f91c2 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOMFeature.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOMFeature.java @@ -54,7 +54,7 @@ import javax.xml.ws.Service; * The {@link #threshold} property can be used to set the threshold * value used to determine when binary data should be XOP encoded. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public final class MTOMFeature extends WebServiceFeature { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPBinding.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPBinding.java index 104de2c1e35..4b9d88887f4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPBinding.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPBinding.java @@ -34,7 +34,7 @@ import javax.xml.soap.MessageFactory; /** The SOAPBinding interface is an abstraction for * the SOAP binding. * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public interface SOAPBinding extends Binding { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPFaultException.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPFaultException.java index 0ac01421bc6..575f840801c 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPFaultException.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/soap/SOAPFaultException.java @@ -48,7 +48,7 @@ import javax.xml.soap.SOAPFault; * @see javax.xml.ws.soap.SOAPBinding#getSOAPFactory * @see javax.xml.ws.ProtocolException * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 **/ public class SOAPFaultException extends javax.xml.ws.ProtocolException { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Invoker.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Invoker.java index b581fba1919..de719cabf53 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Invoker.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Invoker.java @@ -43,7 +43,7 @@ import java.lang.reflect.InvocationTargetException; * * @see Provider#createEndpoint(String, Class, Invoker, WebServiceFeature...) * @author Jitendra Kotamraju - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public abstract class Invoker { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java index f881048ed20..8c8b802130f 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java @@ -41,7 +41,7 @@ import org.w3c.dom.Element; * Endpoint objects. *

    * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 */ public abstract class Provider { @@ -161,7 +161,7 @@ public abstract class Provider { * it must throw a WebServiceException. * @return The newly created service delegate. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public ServiceDelegate createServiceDelegate( java.net.URL wsdlDocumentLocation, @@ -218,7 +218,7 @@ public abstract class Provider { * @throws NullPointerException If the null * eprInfoset value is given. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract EndpointReference readEndpointReference(javax.xml.transform.Source eprInfoset); @@ -271,7 +271,7 @@ public abstract class Provider { * * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract T getPort(EndpointReference endpointReference, Class serviceEndpointInterface, @@ -333,7 +333,7 @@ public abstract class Provider { * @throws WebServiceException If an error occurs while creating the * W3CEndpointReference. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public abstract W3CEndpointReference createW3CEndpointReference(String address, QName serviceName, QName portName, List metadata, String wsdlDocumentLocation, List referenceParameters); @@ -407,7 +407,7 @@ public abstract class Provider { * * @throws WebServiceException If an error occurs while creating the * W3CEndpointReference. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public W3CEndpointReference createW3CEndpointReference(String address, QName interfaceName, QName serviceName, QName portName, @@ -434,7 +434,7 @@ public abstract class Provider { * endpoint. Supported features not in the features * parameter will have their default values. * @return The newly created endpoint. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public Endpoint createAndPublishEndpoint(String address, Object implementor, WebServiceFeature ... features) { @@ -455,7 +455,7 @@ public abstract class Provider { * endpoint. Supported features not in the features * parameter will have their default values. * @return The newly created endpoint. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public Endpoint createEndpoint(String bindingId, Object implementor, WebServiceFeature ... features) { @@ -478,7 +478,7 @@ public abstract class Provider { * endpoint. Supported features not in the features * parameter will have their default values. * @return The newly created endpoint. - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public Endpoint createEndpoint(String bindingId, Class implementorClass, Invoker invoker, WebServiceFeature ... features) { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/ServiceDelegate.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/ServiceDelegate.java index dd181754e36..1c47536cf3a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/ServiceDelegate.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/ServiceDelegate.java @@ -47,7 +47,7 @@ import javax.xml.ws.WebServiceException; * @see javax.xml.ws.Service * @see javax.xml.ws.spi.Provider * - * @since JAX-WS 2.0 + * @since 1.6, JAX-WS 2.0 */ public abstract class ServiceDelegate { @@ -119,7 +119,7 @@ public abstract class ServiceDelegate { * @see java.lang.reflect.InvocationHandler * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract T getPort(QName portName, Class serviceEndpointInterface, WebServiceFeature... features); @@ -194,7 +194,7 @@ public abstract class ServiceDelegate { * with this port or is unsupported. * * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract T getPort(EndpointReference endpointReference, Class serviceEndpointInterface, WebServiceFeature... features); @@ -256,7 +256,7 @@ public abstract class ServiceDelegate { * * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract T getPort(Class serviceEndpointInterface, WebServiceFeature... features); @@ -334,7 +334,7 @@ public abstract class ServiceDelegate { * @see javax.xml.soap.SOAPMessage * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract Dispatch createDispatch(QName portName, Class type, Service.Mode mode, WebServiceFeature... features); @@ -406,7 +406,7 @@ public abstract class ServiceDelegate { * @see javax.xml.soap.SOAPMessage * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract Dispatch createDispatch(EndpointReference endpointReference, Class type, Service.Mode mode, @@ -462,7 +462,7 @@ public abstract class ServiceDelegate { * @see javax.xml.bind.JAXBContext * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract Dispatch createDispatch(QName portName, JAXBContext context, Service.Mode mode, WebServiceFeature... features); @@ -532,7 +532,7 @@ public abstract class ServiceDelegate { * @see javax.xml.bind.JAXBContext * @see WebServiceFeature * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 **/ public abstract Dispatch createDispatch(EndpointReference endpointReference, JAXBContext context, Service.Mode mode, diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/WebServiceFeatureAnnotation.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/WebServiceFeatureAnnotation.java index c99a4e88260..39c0f25e3c4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/WebServiceFeatureAnnotation.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/WebServiceFeatureAnnotation.java @@ -65,7 +65,7 @@ import javax.xml.ws.soap.MTOM; * @see MTOM * @see RespectBinding * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ @Target(ElementType.ANNOTATION_TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpContext.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpContext.java index aca0e3fb487..f62458455ac 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpContext.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpContext.java @@ -37,7 +37,7 @@ import java.util.Set; * web service requests to corresponding HttpContext objects. * * @author Jitendra Kotamraju - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public abstract class HttpContext { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpExchange.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpExchange.java index 233a48d084d..7b275ffb176 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpExchange.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpExchange.java @@ -46,7 +46,7 @@ import java.security.Principal; * is undefined. * * @author Jitendra Kotamraju - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public abstract class HttpExchange { diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpHandler.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpHandler.java index 8d11ea35c83..cafc48ee47e 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpHandler.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/HttpHandler.java @@ -36,7 +36,7 @@ import java.io.IOException; * {@link Endpoint#publish(HttpContext) } * * @author Jitendra Kotamraju - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public abstract class HttpHandler { /** diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/package-info.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/package-info.java index 87f37c76bb9..d105948e7f4 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/package-info.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/spi/http/package-info.java @@ -90,6 +90,6 @@ @author Jitendra Kotamraju - @since JAX-WS 2.2 + @since 1.7, JAX-WS 2.2 */ package javax.xml.ws.spi.http; diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java index a1bc3e2b9c2..3d58a30159d 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java @@ -61,7 +61,7 @@ import java.util.Map; * WS-Addressing * for more information on WS-Addressing EndpointReferences. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ // XmlRootElement allows this class to be marshalled on its own diff --git a/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java b/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java index 5538a1e0261..fb33746531a 100644 --- a/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java +++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java @@ -62,7 +62,7 @@ import javax.xml.ws.spi.Provider; * endpointName (if specified) MUST match a service and port * in the WSDL document. * - * @since JAX-WS 2.1 + * @since 1.6, JAX-WS 2.1 */ public final class W3CEndpointReferenceBuilder { /** @@ -110,6 +110,7 @@ public final class W3CEndpointReferenceBuilder { * @return A W3CEndpointReferenceBuilder instance with * the interfaceName as wsam:InterfaceName * element added to the wsa:Metadata element + * @since 1.7 */ public W3CEndpointReferenceBuilder interfaceName(QName interfaceName) { this.interfaceName = interfaceName; @@ -253,7 +254,7 @@ public final class W3CEndpointReferenceBuilder { * @throws java.lang.IllegalArgumentException if element * is null. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public W3CEndpointReferenceBuilder element(Element element) { if (element == null) { @@ -277,7 +278,7 @@ public final class W3CEndpointReferenceBuilder { * @throws java.lang.IllegalArgumentException if name * or value is null. * - * @since JAX-WS 2.2 + * @since 1.7, JAX-WS 2.2 */ public W3CEndpointReferenceBuilder attribute(QName name, String value) { if (name == null || value == null) { diff --git a/jdk/.hgtags b/jdk/.hgtags index d8119ddf45f..d5928939618 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -266,3 +266,5 @@ f87c5be90e01a7ffb47947108eb3e0b0b1920880 jdk9-b20 2df45ac1bf491278f38c12e0dfbeebadb6c54c8c jdk9-b21 85bcf0f99edc08873614afbe5a5563e13ce13c83 jdk9-b22 9febf9dbc0a4b15323f2dbd29931cfbf086332b4 jdk9-b23 +875450e7ef8dde8f59db662ec1351ea30b8cb35d jdk9-b24 +a31efe49556a7c12f9ea2c9ee8b4fae8aa67723a jdk9-b25 diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk index acab2541256..7666fcd2dd5 100644 --- a/jdk/make/CopyFiles.gmk +++ b/jdk/make/CopyFiles.gmk @@ -122,7 +122,7 @@ COPY_FILES += $(PSFONTPROPFILE_TARGET_FILES) ########################################################################################## # -# Copy flavormap.properties, cursor.properties and cursors gif files to LIBDIR +# Copy cursor.properties and cursors gif files to LIBDIR # ifneq ($(OPENJDK_TARGET_OS), macosx) OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib @@ -130,11 +130,6 @@ else OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/macosx/lib endif -$(LIBDIR)/flavormap.properties: $(OPENJDK_TARGET_OS_LIB_SRC)/flavormap.properties - $(call install-file) - -COPY_FILES += $(LIBDIR)/flavormap.properties - CURSORS_DEST_DIR = $(LIBDIR)/images/cursors CURSORS_OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib/images/cursors diff --git a/jdk/make/CopyIntoClasses.gmk b/jdk/make/CopyIntoClasses.gmk index fdf2a173aca..a80c661ace9 100644 --- a/jdk/make/CopyIntoClasses.gmk +++ b/jdk/make/CopyIntoClasses.gmk @@ -163,6 +163,19 @@ $(foreach R, $(JAVAX_SOUND_RULES), $(eval $(call addto_meta-inf_services, $R))) ################################################################################ +ifneq ($(OPENJDK_TARGET_OS), macosx) + OPENJDK_TARGET_OS_FLAVORMAP_PROPERTIES = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/awt/datatransfer/flavormap.properties +else + OPENJDK_TARGET_OS_FLAVORMAP_PROPERTIES = $(JDK_TOPDIR)/src/macosx/classes/sun/awt/datatransfer/flavormap.properties +endif + +$(JDK_OUTPUTDIR)/classes/sun/awt/datatransfer/flavormap.properties: $(OPENJDK_TARGET_OS_FLAVORMAP_PROPERTIES) + $(install-file) + +COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/sun/awt/datatransfer/flavormap.properties + +################################################################################ + CLEAN_FILES := $(wildcard \ $(JDK_TOPDIR)/src/share/classes/com/sun/imageio/plugins/common/*.properties \ $(JDK_TOPDIR)/src/share/classes/com/sun/java/util/jar/pack/*.properties \ diff --git a/jdk/make/Setup.gmk b/jdk/make/Setup.gmk index 485c3b72b13..c4f204cf6af 100644 --- a/jdk/make/Setup.gmk +++ b/jdk/make/Setup.gmk @@ -27,7 +27,7 @@ DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,- # To build with all warnings enabled, do the following: # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000" -JAVAC_WARNINGS := -Xlint:all,-deprecation,-rawtypes,-unchecked -Werror +JAVAC_WARNINGS := -Xlint:all,-deprecation -Werror # Any java code executed during a JDK build to build other parts of the JDK must be # executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this diff --git a/jdk/make/data/swingbeaninfo/SwingBeanInfo.template b/jdk/make/data/swingbeaninfo/SwingBeanInfo.template index 1bfe54530e2..9c1a133f67f 100644 --- a/jdk/make/data/swingbeaninfo/SwingBeanInfo.template +++ b/jdk/make/data/swingbeaninfo/SwingBeanInfo.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ import sun.swing.BeanInfoUtils; */ public class @(BeanClassName)BeanInfo extends javax.swing.SwingBeanInfoBase { - private static final Class class@(BeanClassName) = @(BeanClassObject); + private static final Class class@(BeanClassName) = @(BeanClassObject); /** * @return a @(BeanClassName) BeanDescriptor diff --git a/jdk/make/data/swingbeaninfo/javax/swing/SwingBeanInfoBase.java b/jdk/make/data/swingbeaninfo/javax/swing/SwingBeanInfoBase.java index 08e55122f5f..d6167b448e5 100644 --- a/jdk/make/data/swingbeaninfo/javax/swing/SwingBeanInfoBase.java +++ b/jdk/make/data/swingbeaninfo/javax/swing/SwingBeanInfoBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,7 @@ public class SwingBeanInfoBase extends SimpleBeanInfo * its PropertyDescriptors will be included. */ public BeanInfo[] getAdditionalBeanInfo() { - Class superClass = getBeanDescriptor().getBeanClass().getSuperclass(); + Class superClass = getBeanDescriptor().getBeanClass().getSuperclass(); BeanInfo superBeanInfo = null; try { superBeanInfo = Introspector.getBeanInfo(superClass); diff --git a/jdk/make/data/swingbeaninfo/sun/swing/BeanInfoUtils.java b/jdk/make/data/swingbeaninfo/sun/swing/BeanInfoUtils.java index fbcc2995dd5..037615ad63a 100644 --- a/jdk/make/data/swingbeaninfo/sun/swing/BeanInfoUtils.java +++ b/jdk/make/data/swingbeaninfo/sun/swing/BeanInfoUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,7 +122,7 @@ public class BeanInfoUtils * @see java.beans#PropertyDescriptor * @see java.beans#FeatureDescriptor */ - public static PropertyDescriptor createPropertyDescriptor(Class cls, String name, Object[] args) + public static PropertyDescriptor createPropertyDescriptor(Class cls, String name, Object[] args) { PropertyDescriptor pd = null; try { @@ -156,7 +156,7 @@ public class BeanInfoUtils String methodName = (String)value; Method method; try { - method = cls.getMethod(methodName, new Class[0]); + method = cls.getMethod(methodName, new Class[0]); pd.setReadMethod(method); } catch(Exception e) { @@ -168,8 +168,8 @@ public class BeanInfoUtils String methodName = (String)value; Method method; try { - Class type = pd.getPropertyType(); - method = cls.getMethod(methodName, new Class[]{type}); + Class type = pd.getPropertyType(); + method = cls.getMethod(methodName, new Class[]{type}); pd.setWriteMethod(method); } catch(Exception e) { @@ -215,9 +215,9 @@ public class BeanInfoUtils * @see java.beans#BeanInfo * @see java.beans#PropertyDescriptor */ - public static BeanDescriptor createBeanDescriptor(Class cls, Object[] args) + public static BeanDescriptor createBeanDescriptor(Class cls, Object[] args) { - Class customizerClass = null; + Class customizerClass = null; /* For reasons I don't understand, customizerClass is a * readOnly property. So we have to find it and pass it @@ -242,11 +242,11 @@ public class BeanInfoUtils } static private PropertyDescriptor createReadOnlyPropertyDescriptor( - String name, Class cls) throws IntrospectionException { + String name, Class cls) throws IntrospectionException { Method readMethod = null; String base = capitalize(name); - Class[] parameters = new Class[0]; + Class[] parameters = new Class[0]; // Is it a boolean? try { @@ -264,7 +264,7 @@ public class BeanInfoUtils try { // Try indexed accessor pattern. - parameters = new Class[1]; + parameters = new Class[1]; parameters[0] = int.class; readMethod = cls.getMethod("get" + base, parameters); } catch (NoSuchMethodException nsme) { diff --git a/jdk/make/lib/PlatformLibraries.gmk b/jdk/make/lib/PlatformLibraries.gmk index e3fc71c4bf9..3f0a408fab7 100644 --- a/jdk/make/lib/PlatformLibraries.gmk +++ b/jdk/make/lib/PlatformLibraries.gmk @@ -90,8 +90,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) LIBOSX_DIRS := \ $(JDK_TOPDIR)/src/macosx/native/com/apple/concurrent \ $(JDK_TOPDIR)/src/macosx/native/com/apple/eio \ - $(JDK_TOPDIR)/src/macosx/native/apple/security \ - $(JDK_TOPDIR)/src/macosx/native/apple/launcher + $(JDK_TOPDIR)/src/macosx/native/apple/security $(eval $(call SetupNativeCompilation,BUILD_LIBOSX, \ LIBRARY := osx, \ diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index b8ea1636c88..06d3ff802e1 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -204,6 +204,7 @@ SUNWprivate_1.1 { Java_sun_print_CUPSPrinter_canConnect; Java_sun_print_CUPSPrinter_getMedia; Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; diff --git a/jdk/make/mapfiles/libawt_headless/mapfile-vers b/jdk/make/mapfiles/libawt_headless/mapfile-vers index c12d07d80fa..df24e4505db 100644 --- a/jdk/make/mapfiles/libawt_headless/mapfile-vers +++ b/jdk/make/mapfiles/libawt_headless/mapfile-vers @@ -76,6 +76,7 @@ SUNWprivate_1.1 { Java_sun_print_CUPSPrinter_canConnect; Java_sun_print_CUPSPrinter_getMedia; Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; # libfontmanager entry points AWTIsHeadless; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 3ae8af3ddbf..4a891077b76 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -442,6 +442,7 @@ SUNWprivate_1.1 { Java_sun_print_CUPSPrinter_canConnect; Java_sun_print_CUPSPrinter_getMedia; Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; awt_GetDrawingSurface; awt_FreeDrawingSurface; diff --git a/jdk/make/profile-includes.txt b/jdk/make/profile-includes.txt index e252ace094a..fe069c37034 100644 --- a/jdk/make/profile-includes.txt +++ b/jdk/make/profile-includes.txt @@ -177,7 +177,6 @@ FULL_JRE_LIB_FILES := \ ext/dnsns.jar \ ext/nashorn.jar \ ext/zipfs.jar \ - flavormap.properties \ fontconfig.RedHat.5.bfc \ fontconfig.RedHat.5.properties.src \ fontconfig.RedHat.6.bfc \ diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/JavaAppLauncher.xcodeproj/project.pbxproj b/jdk/src/macosx/bundle/JavaAppLauncher/JavaAppLauncher.xcodeproj/project.pbxproj deleted file mode 100644 index b51cbefbd9b..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/JavaAppLauncher.xcodeproj/project.pbxproj +++ /dev/null @@ -1,318 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 45; - objects = { - -/* Begin PBXBuildFile section */ - 2C483E05143512EB00F2AEFD /* 1.7.0.jre in Copy PlugIns */ = {isa = PBXBuildFile; fileRef = 2C483E04143512EB00F2AEFD /* 1.7.0.jre */; }; - 89D3CD32142EEB2200A08AED /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 89D3CD29142EEB2200A08AED /* InfoPlist.strings */; }; - 89D3CD33142EEB2200A08AED /* GenericApp.icns in Resources */ = {isa = PBXBuildFile; fileRef = 89D3CD2B142EEB2200A08AED /* GenericApp.icns */; }; - 89D3CD35142EEB2200A08AED /* JVMArgs.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D3CD30142EEB2200A08AED /* JVMArgs.m */; }; - 89D3CD36142EEB2200A08AED /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D3CD31142EEB2200A08AED /* main.m */; }; - 89D3D365143041F000A08AED /* JavaAppLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D3D364143041F000A08AED /* JavaAppLauncher.m */; }; - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 2C48F06614350F0F00F2AEFD /* Copy PlugIns */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 13; - files = ( - 2C483E05143512EB00F2AEFD /* 1.7.0.jre in Copy PlugIns */, - ); - name = "Copy PlugIns"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 2C483E04143512EB00F2AEFD /* 1.7.0.jre */ = {isa = PBXFileReference; lastKnownFileType = folder; name = 1.7.0.jre; path = "../../../../../build/macosx-universal/j2sdk-bundle/1.7.0.jdk/Contents/Home/1.7.0.jre"; sourceTree = SOURCE_ROOT; }; - 2C48F06714350F8300F2AEFD /* 1.7.0.jdk */ = {isa = PBXFileReference; lastKnownFileType = folder; name = 1.7.0.jdk; path = "../../../../../build/macosx-universal/j2sdk-bundle/1.7.0.jdk"; sourceTree = SOURCE_ROOT; }; - 2CB5DA5E14355FCA00D3A656 /* classfile_constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classfile_constants.h; sourceTree = ""; }; - 2CB5DA6014355FCA00D3A656 /* jawt_md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jawt_md.h; sourceTree = ""; }; - 2CB5DA6114355FCA00D3A656 /* jni_md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_md.h; sourceTree = ""; }; - 2CB5DA6214355FCA00D3A656 /* jawt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jawt.h; sourceTree = ""; }; - 2CB5DA6314355FCA00D3A656 /* jdwpTransport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jdwpTransport.h; sourceTree = ""; }; - 2CB5DA6414355FCA00D3A656 /* jni.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni.h; sourceTree = ""; }; - 2CB5DA6514355FCA00D3A656 /* jvmti.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jvmti.h; sourceTree = ""; }; - 2CB5DA6614355FCA00D3A656 /* jvmticmlr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jvmticmlr.h; sourceTree = ""; }; - 89D3CD2A142EEB2200A08AED /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; - 89D3CD2B142EEB2200A08AED /* GenericApp.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = GenericApp.icns; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/GenericApp.icns; sourceTree = ""; }; - 89D3CD2C142EEB2200A08AED /* JavaAppLauncher-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "JavaAppLauncher-Info.plist"; sourceTree = ""; }; - 89D3CD2E142EEB2200A08AED /* JavaAppLauncher_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaAppLauncher_Prefix.pch; sourceTree = ""; }; - 89D3CD2F142EEB2200A08AED /* JVMArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JVMArgs.h; sourceTree = ""; }; - 89D3CD30142EEB2200A08AED /* JVMArgs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JVMArgs.m; sourceTree = ""; }; - 89D3CD31142EEB2200A08AED /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 89D3D363143041F000A08AED /* JavaAppLauncher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaAppLauncher.h; sourceTree = ""; }; - 89D3D364143041F000A08AED /* JavaAppLauncher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JavaAppLauncher.m; sourceTree = ""; }; - 8D1107320486CEB800E47090 /* JavaAppLauncher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JavaAppLauncher.app; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8D11072E0486CEB800E47090 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 1058C7A0FEA54F0111CA2CBB /* frameworks */ = { - isa = PBXGroup; - children = ( - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, - ); - name = frameworks; - sourceTree = ""; - }; - 19C28FACFE9D520D11CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 8D1107320486CEB800E47090 /* JavaAppLauncher.app */, - ); - name = Products; - sourceTree = ""; - }; - 29B97314FDCFA39411CA2CEA /* JavaAppLauncher */ = { - isa = PBXGroup; - children = ( - 89D3CD2D142EEB2200A08AED /* src */, - 89D3CD28142EEB2200A08AED /* resources */, - 29B97323FDCFA39411CA2CEA /* linking */, - 19C28FACFE9D520D11CA2CBB /* Products */, - ); - name = JavaAppLauncher; - sourceTree = ""; - }; - 29B97323FDCFA39411CA2CEA /* linking */ = { - isa = PBXGroup; - children = ( - 2C48F06714350F8300F2AEFD /* 1.7.0.jdk */, - 2C483E04143512EB00F2AEFD /* 1.7.0.jre */, - 2CB5DA5D14355FCA00D3A656 /* include */, - 1058C7A0FEA54F0111CA2CBB /* frameworks */, - ); - name = linking; - sourceTree = ""; - }; - 2CB5DA5D14355FCA00D3A656 /* include */ = { - isa = PBXGroup; - children = ( - 2CB5DA5E14355FCA00D3A656 /* classfile_constants.h */, - 2CB5DA5F14355FCA00D3A656 /* darwin */, - 2CB5DA6214355FCA00D3A656 /* jawt.h */, - 2CB5DA6314355FCA00D3A656 /* jdwpTransport.h */, - 2CB5DA6414355FCA00D3A656 /* jni.h */, - 2CB5DA6514355FCA00D3A656 /* jvmti.h */, - 2CB5DA6614355FCA00D3A656 /* jvmticmlr.h */, - ); - name = include; - path = "../../../../../build/macosx-universal/j2sdk-bundle/1.7.0.jdk/Contents/Home/include"; - sourceTree = ""; - }; - 2CB5DA5F14355FCA00D3A656 /* darwin */ = { - isa = PBXGroup; - children = ( - 2CB5DA6014355FCA00D3A656 /* jawt_md.h */, - 2CB5DA6114355FCA00D3A656 /* jni_md.h */, - ); - path = darwin; - sourceTree = ""; - }; - 89D3CD28142EEB2200A08AED /* resources */ = { - isa = PBXGroup; - children = ( - 89D3CD29142EEB2200A08AED /* InfoPlist.strings */, - 89D3CD2B142EEB2200A08AED /* GenericApp.icns */, - 89D3CD2C142EEB2200A08AED /* JavaAppLauncher-Info.plist */, - ); - path = resources; - sourceTree = ""; - }; - 89D3CD2D142EEB2200A08AED /* src */ = { - isa = PBXGroup; - children = ( - 89D3CD31142EEB2200A08AED /* main.m */, - 89D3D363143041F000A08AED /* JavaAppLauncher.h */, - 89D3D364143041F000A08AED /* JavaAppLauncher.m */, - 89D3CD2F142EEB2200A08AED /* JVMArgs.h */, - 89D3CD30142EEB2200A08AED /* JVMArgs.m */, - 89D3CD2E142EEB2200A08AED /* JavaAppLauncher_Prefix.pch */, - ); - path = src; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8D1107260486CEB800E47090 /* JavaAppLauncher */ = { - isa = PBXNativeTarget; - buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "JavaAppLauncher" */; - buildPhases = ( - 8D1107290486CEB800E47090 /* Resources */, - 2C48F06614350F0F00F2AEFD /* Copy PlugIns */, - 8D11072C0486CEB800E47090 /* Sources */, - 8D11072E0486CEB800E47090 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = JavaAppLauncher; - productInstallPath = "$(HOME)/Applications"; - productName = JavaAppLauncher; - productReference = 8D1107320486CEB800E47090 /* JavaAppLauncher.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 29B97313FDCFA39411CA2CEA /* Project object */ = { - isa = PBXProject; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "JavaAppLauncher" */; - compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - en, - English, - ); - mainGroup = 29B97314FDCFA39411CA2CEA /* JavaAppLauncher */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 8D1107260486CEB800E47090 /* JavaAppLauncher */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 8D1107290486CEB800E47090 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D3CD32142EEB2200A08AED /* InfoPlist.strings in Resources */, - 89D3CD33142EEB2200A08AED /* GenericApp.icns in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 8D11072C0486CEB800E47090 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D3CD35142EEB2200A08AED /* JVMArgs.m in Sources */, - 89D3CD36142EEB2200A08AED /* main.m in Sources */, - 89D3D365143041F000A08AED /* JavaAppLauncher.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 89D3CD29142EEB2200A08AED /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 89D3CD2A142EEB2200A08AED /* English */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - C01FCF4B08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = src/JavaAppLauncher_Prefix.pch; - INFOPLIST_FILE = "resources/JavaAppLauncher-Info.plist"; - INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = "$(inherited)"; - PRODUCT_NAME = JavaAppLauncher; - }; - name = Debug; - }; - C01FCF4C08A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = src/JavaAppLauncher_Prefix.pch; - INFOPLIST_FILE = "resources/JavaAppLauncher-Info.plist"; - INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = "$(inherited)"; - PRODUCT_NAME = JavaAppLauncher; - }; - name = Release; - }; - C01FCF4F08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; - SDKROOT = ""; - }; - name = Debug; - }; - C01FCF5008A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = ""; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "JavaAppLauncher" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4B08A954540054247B /* Debug */, - C01FCF4C08A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "JavaAppLauncher" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4F08A954540054247B /* Debug */, - C01FCF5008A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; -} diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/resources/English.lproj/InfoPlist.strings b/jdk/src/macosx/bundle/JavaAppLauncher/resources/English.lproj/InfoPlist.strings deleted file mode 100644 index 477b28ff8f8..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/resources/English.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/resources/JavaAppLauncher-Info.plist b/jdk/src/macosx/bundle/JavaAppLauncher/resources/JavaAppLauncher-Info.plist deleted file mode 100644 index a3268bb9f89..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/resources/JavaAppLauncher-Info.plist +++ /dev/null @@ -1,48 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - GenericApp.icns - CFBundleIdentifier - com.yourcompany.${PRODUCT_NAME:rfc1034identifier} - CFBundleDisplayName - Your Cool App - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NSHumanReadableCopyright - Copyright © 2011 Your Company Inc. All Rights Reserved. - JVMInfo - - JRE - 1.7.0.jre - ClassPath - - Properties - - apple.laf.useScreenMenuBar - true - - MainClass - com.yourcompany.yourapp.mainclass - Arguments - - - - diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.h b/jdk/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.h deleted file mode 100644 index cceb88d6e7c..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import - -#import "jni.h" - - -@interface JVMArgs : NSObject { -@public - NSBundle *jreBundle; - char *preferredJVMLib; - JavaVMInitArgs vm_args; - BOOL startOnFirstThread; - BOOL debug; - - NSDictionary *appInfo; - NSMutableDictionary *jvmInfo; - - NSString *userHome; - NSString *appPackage; - NSString *javaRoot; -} - -@property (retain, nonatomic) NSBundle *jreBundle; -@property (nonatomic) char *preferredJVMLib; -@property (nonatomic) JavaVMInitArgs vm_args; -@property (nonatomic) BOOL startOnFirstThread; -@property (nonatomic) BOOL debug; - -@property (retain, nonatomic) NSDictionary *appInfo; -@property (retain, nonatomic) NSMutableDictionary *jvmInfo; - -@property (retain, nonatomic) NSString *userHome; -@property (retain, nonatomic) NSString *appPackage; -@property (retain, nonatomic) NSString *javaRoot; - -+ (JVMArgs *)jvmArgsForBundle:(NSBundle *)appBundle argc:(int)argc argv:(char *[])argv; - -@end diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.m b/jdk/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.m deleted file mode 100644 index 1f4af016080..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.m +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "JVMArgs.h" - - -#define kArgsFailure "JVMArgsFailure" - -NSString *kArgumentsKey = @"Arguments"; - -NSString *kClassPathKey = @"ClassPath"; -#ifdef __i386__ -NSString *kArchClassPathKey = @"ClassPath.i386"; -#elif __x86_64__ -NSString *kArchClassPathKey = @"ClassPath.x86_64"; -#endif - -NSString *kVMOptionsKey = @"VMOptions"; -#ifdef __i386__ -NSString *kArchVMOptionsKey = @"VMOptions.i386"; -#elif __x86_64__ -NSString *kArchVMOptionsKey = @"VMOptions.x86_64"; -#endif - - -@implementation JVMArgs - -@synthesize jreBundle; -@synthesize preferredJVMLib; -@synthesize vm_args; -@synthesize startOnFirstThread; -@synthesize debug; - -@synthesize appInfo; -@synthesize jvmInfo; - -@synthesize userHome; -@synthesize appPackage; -@synthesize javaRoot; - -- (void) dealloc { - self.jreBundle = nil; - if (self.preferredJVMLib) free(self.preferredJVMLib); - - self.appInfo = nil; - self.jvmInfo = nil; - - self.userHome = nil; - self.appPackage = nil; - self.javaRoot = nil; - - [super dealloc]; -} - - -NSString *GetJavaRoot(NSDictionary *jvmInfoDict) { - NSObject *javaRoot = [jvmInfoDict objectForKey:@"$JAVAROOT"]; - if (![javaRoot isKindOfClass:[NSString class]]) return @"$APP_PACKAGE/Contents/Java"; - return (NSString *)javaRoot; -} - -// Replaces occurances of $JAVAROOT, $APP_PACKAGE, and $USER_HOME -- (NSString *) expandMacros:(NSString *)str { - if ([str rangeOfString:@"$JAVAROOT"].length == 0 && [str rangeOfString:@"$APP_PACKAGE"].length == 0 && [str rangeOfString:@"$USER_HOME"].length == 0) return str; - - // expand $JAVAROOT first, because it can contain $APP_PACKAGE - NSMutableString *mutable = [str mutableCopy]; - [mutable replaceOccurrencesOfString:@"$JAVAROOT" withString:javaRoot options:0 range:NSMakeRange(0, [str length])]; - [mutable replaceOccurrencesOfString:@"$APP_PACKAGE" withString:appPackage options:0 range:NSMakeRange(0, [str length])]; - [mutable replaceOccurrencesOfString:@"$USER_HOME" withString:userHome options:0 range:NSMakeRange(0, [str length])]; - return mutable; -} - -- (NSArray *) arrayFrom:(id) obj delimitedBy:(NSString *)delimiter withErrKey:(NSString *)key { - if (obj == nil) return nil; - if ([obj isKindOfClass:[NSArray class]]) return obj; - if (![obj isKindOfClass:[NSString class]]) { - [NSException raise:@kArgsFailure format:@"%@", [NSString stringWithFormat:@"Failed to find '%@' array in JVMInfo Info.plist"]]; - } - - // split - return [(NSString *)obj componentsSeparatedByString:delimiter]; -} - -- (void) buildArgsForBundle:(NSBundle *)appBundle argc:(int)argc argv:(char *[])argv { - // for verbose logging - self.debug = NULL != getenv("JAVA_LAUNCHER_VERBOSE"); - - self.appInfo = [appBundle infoDictionary]; - - // all apps must have a JVMInfo dictionary inside their Info.plist - self.jvmInfo = [[self.appInfo objectForKey:@"JVMInfo"] mutableCopy]; - if (![jvmInfo isKindOfClass:[NSDictionary class]]) { - [NSException raise:@kArgsFailure format:@"Failed to find 'JVMInfo' dictionary in Info.plist"]; - } - - // initialize macro expansion values - self.userHome = NSHomeDirectory(); - self.appPackage = [appBundle bundlePath]; - self.javaRoot = GetJavaRoot(jvmInfo); - self.javaRoot = [self expandMacros:self.javaRoot]; // dereference $APP_PACKAGE - - // if the 'Arguments' key is defined, those override the ones that came into main() - NSArray *jvmInfoArgs = [jvmInfo valueForKey:kArgumentsKey]; - if (jvmInfoArgs != nil) { - // substitute all the variables in the 'Arguments' array/string - jvmInfoArgs = [self arrayFrom:jvmInfoArgs delimitedBy:@" " withErrKey:kArgumentsKey]; - NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:[jvmInfoArgs count]]; - [jvmInfoArgs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [arguments replaceObjectAtIndex:idx withObject:[self expandMacros:[obj description]]]; - }]; - [jvmInfo setObject:arguments forKey:kArgumentsKey]; - } else if (argc != 0) { - // put the (macro expanded) args to main() in an NSArray - NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:argc]; - for (int i = 0; i < argc; i++) { - [arguments addObject:[self expandMacros:[NSString stringWithUTF8String:(argv[i])]]]; - } - [jvmInfo setObject:arguments forKey:kArgumentsKey]; - } - - // all JVMInfo's must have a JRE or JDK key - NSString *jreBundleName = [jvmInfo objectForKey:@"JRE"]; - if (!jreBundleName) jreBundleName = [jvmInfo objectForKey:@"JDK"]; - if (![jreBundleName isKindOfClass:[NSString class]]) { - [NSException raise:@kArgsFailure format:@"Failed to find 'JRE' or 'JDK' string in Info.plist JVMInfo"]; - } - - // the JRE/JDK must be loadable from the ($APP_PACKAGE)/Contents/PlugIns/ directory - NSURL *jreBundleURL = [[appBundle builtInPlugInsURL] URLByAppendingPathComponent:jreBundleName]; - self.jreBundle = [NSBundle bundleWithURL:jreBundleURL]; - if (!self.jreBundle) { - [NSException raise:@kArgsFailure format:@"Failed to find JRE/JDK at: %@", jreBundleURL]; - } - - // if the app prefers 'client' or 'server', use the JVM key - NSString *JVMLib = [jvmInfo objectForKey:@"JVM"]; - if (JVMLib != nil) self.preferredJVMLib = strdup([JVMLib UTF8String]); - - // sniff for StartOnFirstThread - if ([[jvmInfo objectForKey:@"StartOnFirstThread"] boolValue]) { - self.startOnFirstThread = YES; - } else if ([[jvmInfo objectForKey:@"StartOnMainThread"] boolValue]) { - // for key compatibility with the Apple JavaApplicationStub's 'Java' dictionary - self.startOnFirstThread = YES; - } - - // add $JAVAROOT directory to the JNI library search path - setenv("JAVA_LIBRARY_PATH", [javaRoot UTF8String], 1); - - // 'WorkingDirectory' key changes current working directory - NSString *javaWorkingDir = [jvmInfo objectForKey:@"WorkingDirectory"]; - if (javaWorkingDir == nil) javaWorkingDir = @"$APP_PACKAGE/.."; - javaWorkingDir = [self expandMacros:javaWorkingDir]; - if (chdir([javaWorkingDir UTF8String]) == -1) { - NSLog(@kArgsFailure " chdir() failed, could not change the current working directory to %s\n", [javaWorkingDir UTF8String]); - } - - NSMutableArray *classpath = [NSMutableArray array]; - - // 'Jar' key sets exactly one classpath entry - NSString *jarFile = [jvmInfo objectForKey:@"Jar"]; - if (jarFile != nil) { - [jvmInfo setObject:[self expandMacros:jarFile] forKey:@"Jar"]; - [classpath addObject:jarFile]; - } - - // 'ClassPath' key allows arbitrary classpath - [classpath addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kClassPathKey] delimitedBy:@":" withErrKey:kClassPathKey]]; - [classpath addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kArchClassPathKey] delimitedBy:@":" withErrKey:kArchClassPathKey]]; - - // Sum up all the classpath entries into one big JVM arg - NSMutableString *classpathOption = [NSMutableString stringWithString:@"-Djava.class.path="]; - [classpath enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if (idx > 1) [classpathOption appendString:@":"]; - [classpathOption appendString:obj]; - }]; - - NSMutableArray *jvmOptions = [NSMutableArray arrayWithObject:classpathOption]; - - // 'VMOptions' key allows arbitary VM start up options - [jvmOptions addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kVMOptionsKey] delimitedBy:@" " withErrKey:kVMOptionsKey]]; - [jvmOptions addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kArchVMOptionsKey] delimitedBy:@" " withErrKey:kArchVMOptionsKey]]; - - // 'Properties' key is a sub-dictionary transfered to initial System.properties - NSDictionary *properties = [jvmInfo objectForKey:@"Properties"]; - if (properties != nil) { - if (![properties isKindOfClass:[NSDictionary class]]) { - [NSException raise:@kArgsFailure format:@"Failed to find 'Properties' dictionary in Info.plist JVMInfo"]; - } - - [properties enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [jvmOptions addObject:[NSString stringWithFormat:@"-D%@=%@", key, obj]]; - }]; - } - - // build the real JVM init args struct - vm_args.version = JNI_VERSION_1_6; - vm_args.ignoreUnrecognized = JNI_TRUE; - vm_args.nOptions = [jvmOptions count]; - vm_args.options = calloc(vm_args.nOptions, sizeof(JavaVMOption)); - [jvmOptions enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - NSString *expanded = [self expandMacros:[obj description]]; // turn everything into a string, and expand macros - vm_args.options[idx].optionString = strdup([expanded UTF8String]); - }]; -} - -+ (JVMArgs *)jvmArgsForBundle:(NSBundle *)appBundle argc:(int)argc argv:(char *[])argv { - JVMArgs *args = [JVMArgs new]; - [args buildArgsForBundle:appBundle argc:argc argv:argv]; - return [args autorelease]; -} - -@end diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.m b/jdk/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.m deleted file mode 100644 index db44ab3fee7..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.m +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "JavaAppLauncher.h" - -#import - -#import "jni.h" - -#define kLaunchFailure "JavaAppLauncherFailure" - - -typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args); -typedef void (JNICALL *SetPreferredJVM_t)(const char *prefJVM); - - -@implementation JavaAppLauncher - -@synthesize args; - -- (void) findAndLoadJVM { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - @try { - // load the libjli.dylib of the embedded JRE (or JDK) bundle - NSURL *jreBundleURL = [args.jreBundle bundleURL]; - CFBundleRef jreBundle = CFBundleCreate(NULL, (CFURLRef)jreBundleURL); - - NSError *err = nil; - Boolean jreBundleLoaded = CFBundleLoadExecutableAndReturnError(jreBundle, (CFErrorRef *)&err); - if (err != nil || !jreBundleLoaded) { - [NSException raise:@kLaunchFailure format:@"could not load the JRE/JDK: %@", err]; - } - - // if there is a preferred libjvm to load, set it here - if (args.preferredJVMLib != NULL) { - SetPreferredJVM_t setPrefJVMFxnPtr = CFBundleGetFunctionPointerForName(jreBundle, CFSTR("JLI_SetPreferredJVM")); - if (setPrefJVMFxnPtr != NULL) { - setPrefJVMFxnPtr(args.preferredJVMLib); - } else { - NSLog(@"No JLI_SetPreferredJVM in JRE/JDK primary executable, failed to set preferred JVM library to: %s", args->preferredJVMLib); - } - } - - // pull the JNI_CreateJavaVM function pointer out of the primary executable of the JRE/JDK bundle - CreateJavaVM_t createJVMFxnPtr = CFBundleGetFunctionPointerForName(jreBundle, CFSTR("JNI_CreateJavaVM")); - if (createJVMFxnPtr == NULL) { - [NSException raise:@kLaunchFailure format:@"null JNI_CreateJavaVM fxn ptr from: %@", jreBundle]; - } - - // instantiate the JVM - JNIEnv *env; - jint createJVMStatus = createJVMFxnPtr(&jvm, (void **)&env, &(args->vm_args)); - if (createJVMStatus != JNI_OK) { - [NSException raise:@kLaunchFailure format:@"failed to JNI_CreateJavaVM (%d): %@", createJVMStatus, jreBundle]; - } - - // check the app needs to run the Java main() on the main thread - if (args.startOnFirstThread) { - dispatch_sync(dispatch_get_main_queue(), ^(void) { - JNIEnv *mainThreadEnv; - (*jvm)->AttachCurrentThread(jvm, (void **)&mainThreadEnv, NULL); - [self invokeBundledAppJavaLauncherWithEnv:mainThreadEnv]; - (*jvm)->DetachCurrentThread(jvm); - }); - } else { - [self invokeBundledAppJavaLauncherWithEnv:env]; - } - - } @catch (NSException *e) { - NSLog(@"%@: %@", e, [e callStackSymbols]); - } - - if (jvm) { - (*jvm)->DetachCurrentThread(jvm); - (*jvm)->DestroyJavaVM(jvm); - } - - [pool drain]; -} - -static const char kLauncherClassName[] = "apple/launcher/JavaAppLauncher"; - -- (void) invokeBundledAppJavaLauncherWithEnv:(JNIEnv *)env { - // hand off control to the apple.launcher.JavaAppLauncher class - - jclass mainClass = (*env)->FindClass(env, kLauncherClassName); - if (mainClass == NULL) { - fprintf(stderr, kLaunchFailure " FindClass() failed for class %s:\n", kLauncherClassName); - (*env)->ExceptionDescribe(env); - return; - } - - jmethodID mainMethod = (*env)->GetStaticMethodID(env, mainClass, "launch", "(JZ)V"); - if ((mainMethod == NULL) || (*env)->ExceptionOccurred(env)) { - fprintf(stderr, kLaunchFailure " GetStaticMethodID() failed for launch() method"); - (*env)->ExceptionDescribe(env); - return; - } - - CFDictionaryRef jvmInfo = CFRetain(args.jvmInfo); - - (*env)->CallStaticVoidMethod(env, mainClass, mainMethod, (jlong)jvmInfo, (jboolean)args.debug); - if ((*env)->ExceptionOccurred(env)) { - fprintf(stderr, kLaunchFailure " CallStaticVoidMethod() threw an exception\n"); - (*env)->ExceptionDescribe(env); - return; - } -} - -@end diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/src/main.m b/jdk/src/macosx/bundle/JavaAppLauncher/src/main.m deleted file mode 100644 index 019e78a7d48..00000000000 --- a/jdk/src/macosx/bundle/JavaAppLauncher/src/main.m +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import - -#import "JVMArgs.h" -#import "JavaAppLauncher.h" - - -static void dummyTimer(CFRunLoopTimerRef timer, void *info) {} -static void ParkEventLoop() { - // RunLoop needs at least one source, and 1e20 is pretty far into the future - CFRunLoopTimerRef t = CFRunLoopTimerCreate(kCFAllocatorDefault, 1.0e20, 0.0, 0, 0, dummyTimer, NULL); - CFRunLoopAddTimer(CFRunLoopGetCurrent(), t, kCFRunLoopDefaultMode); - CFRelease(t); - - // Park this thread in the main run loop. - int32_t result; - do { - result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, false); - } while (result != kCFRunLoopRunFinished); -} - -int main(int argc, char *argv[]) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - @try { - NSBundle *mainBundle = [NSBundle mainBundle]; - - // pick apart the Info.plist, and release all the temporary objects - NSAutoreleasePool *argParsingPool = [NSAutoreleasePool new]; - JVMArgs *args = [JVMArgs jvmArgsForBundle:mainBundle argc:argc argv:argv]; - JavaAppLauncher *launcher = [JavaAppLauncher new]; - launcher.args = args; - [argParsingPool drain]; - - // kick off a new thread to instantiate the JVM on - NSThread *thread = [[NSThread alloc] initWithTarget:launcher selector:@selector(findAndLoadJVM) object:nil]; - struct rlimit limit; - int err = getrlimit(RLIMIT_STACK, &limit); - if (err == 0 && limit.rlim_cur != 0LL) { - [thread setStackSize:limit.rlim_cur]; - } - [thread start]; - [thread release]; - - [launcher release]; - - ParkEventLoop(); - - } @catch (NSException *e) { - NSLog(@"%@: %@", e, [e callStackSymbols]); - } - - [pool drain]; - - return 0; -} diff --git a/jdk/src/macosx/classes/apple/launcher/JavaAppLauncher.java b/jdk/src/macosx/classes/apple/launcher/JavaAppLauncher.java deleted file mode 100644 index c701b1be63e..00000000000 --- a/jdk/src/macosx/classes/apple/launcher/JavaAppLauncher.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * 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 apple.launcher; - -import java.io.*; -import java.lang.reflect.*; -import java.text.MessageFormat; -import java.util.*; -import java.util.jar.*; - -import javax.swing.*; - -class JavaAppLauncher implements Runnable { - static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("osx"); - return null; - } - }); - } - - private static native T nativeConvertAndRelease(final long ptr); - private static native void nativeInvokeNonPublic(Class cls, Method m, String[] args); - - // entry point from native - static void launch(final long javaDictionaryPtr, final boolean verbose) { - final Map javaDictionary = nativeConvertAndRelease(javaDictionaryPtr); - (new JavaAppLauncher(javaDictionary, verbose)).run(); - } - - // these are the values for the enumeration JavaFailureMode - static final String kJavaFailureMainClassNotSpecified = "MainClassNotSpecified"; - static final String kJavaFailureMainClassNotFound = "CannotLoadMainClass"; - static final String kJavaFailureMainClassHasNoMain = "NoMainMethod"; - static final String kJavaFailureMainClassMainNotStatic = "MainNotStatic"; - static final String kJavaFailureMainThrewException = "MainThrewException"; - static final String kJavaFailureMainInitializerException = "MainInitializerException"; - - final boolean verbose; // Normally set by environment variable JAVA_LAUNCHER_VERBOSE. - final Map javaDictionary; - - JavaAppLauncher(final Map javaDictionary, final boolean verbose) { - this.verbose = verbose; - this.javaDictionary = javaDictionary; - } - - @Override - public void run() { - final Method m = loadMainMethod(getMainMethod()); - final String methodName = m.getDeclaringClass().getName() + ".main(String[])"; - try { - log("Calling " + methodName + " method"); - m.invoke(null, new Object[] { getArguments() }); - log(methodName + " has returned"); - } catch (final IllegalAccessException x) { - try { - nativeInvokeNonPublic(m.getClass(), m, getArguments()); - } catch (final Throwable excpt) { - logError(methodName + " threw an exception:"); - if ((excpt instanceof UnsatisfiedLinkError) && excpt.getMessage().equals("nativeInvokeNonPublic")) { - showFailureAlertAndKill(kJavaFailureMainThrewException, "nativeInvokeNonPublic not registered"); - } else { - excpt.printStackTrace(); - showFailureAlertAndKill(kJavaFailureMainThrewException, excpt.toString()); - } - } - } catch (final InvocationTargetException invokeExcpt) { - logError(methodName + " threw an exception:"); - invokeExcpt.getTargetException().printStackTrace(); - showFailureAlertAndKill(kJavaFailureMainThrewException, invokeExcpt.getTargetException().toString()); - } - } - - Method loadMainMethod(final String mainClassName) { - try { - final Class mainClass = Class.forName(mainClassName, true, sun.misc.Launcher.getLauncher().getClassLoader()); - final Method mainMethod = mainClass.getDeclaredMethod("main", new Class[] { String[].class }); - if ((mainMethod.getModifiers() & Modifier.STATIC) == 0) { - logError("The main(String[]) method of class " + mainClassName + " is not static!"); - showFailureAlertAndKill(kJavaFailureMainClassMainNotStatic, mainClassName); - } - return mainMethod; - } catch (final ExceptionInInitializerError x) { - logError("The main class \"" + mainClassName + "\" had a static initializer throw an exception."); - x.getException().printStackTrace(); - showFailureAlertAndKill(kJavaFailureMainInitializerException, x.getException().toString()); - } catch (final ClassNotFoundException x) { - logError("The main class \"" + mainClassName + "\" could not be found."); - showFailureAlertAndKill(kJavaFailureMainClassNotFound, mainClassName); - } catch (final NoSuchMethodException x) { - logError("The main class \"" + mainClassName + "\" has no static main(String[]) method."); - showFailureAlertAndKill(kJavaFailureMainClassHasNoMain, mainClassName); - } catch (final NullPointerException x) { - logError("No main class specified"); - showFailureAlertAndKill(kJavaFailureMainClassNotSpecified, null); - } - - return null; - } - - // get main class name from 'Jar' key, or 'MainClass' key - String getMainMethod() { - final Object javaJar = javaDictionary.get("Jar"); - if (javaJar != null) { - if (!(javaJar instanceof String)) { - logError("'Jar' key in 'Java' sub-dictionary of Info.plist requires a string value"); - return null; - } - - final String jarPath = (String)javaJar; - if (jarPath.length() == 0) { - log("'Jar' key of sub-dictionary 'Java' of Info.plist key is empty"); - } else { - // extract main class from manifest of this jar - final String main = getMainFromManifest(jarPath); - if (main == null) { - logError("jar file '" + jarPath + "' does not have Main-Class: attribute in its manifest"); - return null; - } - - log("Main class " + main + " found in jar manifest"); - return main; - } - } - - final Object javaMain = javaDictionary.get("MainClass"); - if (!(javaMain instanceof String)) { - logError("'MainClass' key in 'Java' sub-dictionary of Info.plist requires a string value"); - return null; - } - - final String main = (String)javaMain; - if (main.length() == 0) { - log("'MainClass' key of sub-dictionary 'Java' of Info.plist key is empty"); - return null; - } - - log("Main class " + (String)javaMain + " found via 'MainClass' key of sub-dictionary 'Java' of Info.plist key"); - return (String)javaMain; - } - - // get arguments for main(String[]) out of Info.plist and command line - String[] getArguments() { - // check for 'Arguments' key, which contains the main() args if not defined in Info.plist - final Object javaArguments = javaDictionary.get("Arguments"); - if (javaArguments == null) { - // no arguments - log("No arguments for main(String[]) specified"); - return new String[0]; - } - - if (javaArguments instanceof List) { - final List args = (List)javaArguments; - final int count = args.size(); - log("Arguments to main(String[" + count + "]):"); - - final String[] result = new String[count]; - for (int i = 0; i < count; ++i) { - final Object element = args.get(i); - if (element instanceof String) { - result[i] = (String)element; - } else { - logError("Found non-string in array"); - } - log(" arg[" + i + "]=" + result[i]); - } - return result; - } - - logError("'Arguments' key in 'Java' sub-dictionary of Info.plist requires a string value or an array of strings"); - return new String[0]; - } - - // returns name of main class, or null - String getMainFromManifest(final String jarpath) { - JarFile jar = null; - try { - jar = new JarFile(jarpath); - final Manifest man = jar.getManifest(); - final Attributes attr = man.getMainAttributes(); - return attr.getValue("Main-Class"); - } catch (final IOException x) { - // shrug - } finally { - if (jar != null) { - try { - jar.close(); - } catch (final IOException x) { } - } - } - return null; - } - - void log(final String s) { - if (!verbose) return; - System.out.println("[LaunchRunner] " + s); - } - - static void logError(final String s) { - System.err.println("[LaunchRunner Error] " + s); - } - - // This kills the app and does not return! - static void showFailureAlertAndKill(final String msg, String arg) { - if (arg == null) arg = "<>"; - JOptionPane.showMessageDialog(null, getMessage(msg, arg), "", JOptionPane.ERROR_MESSAGE); - System.exit(-1); - } - - static String getMessage(final String msgKey, final Object ... args) { - final String msg = ResourceBundle.getBundle("appLauncherErrors").getString(msgKey); - return MessageFormat.format(msg, args); - } -} diff --git a/jdk/src/macosx/classes/apple/launcher/appLauncherErrors.properties b/jdk/src/macosx/classes/apple/launcher/appLauncherErrors.properties deleted file mode 100644 index 9f880b7a075..00000000000 --- a/jdk/src/macosx/classes/apple/launcher/appLauncherErrors.properties +++ /dev/null @@ -1,6 +0,0 @@ -MainClassNotSpecified=No main class specified. -CannotLoadMainClass=The main class \u201C{0}\u201D could not be loaded. -NoMainMethod=The main class \u201C{0}\u201D has no \u201Cvoid main(String[])\u201D method. -MainNotStatic=The \u201Cmain(String[])\u201D method of class \u201C{0}\u201D is not static. -MainThrewException=Uncaught exception in main method: {0} -MainInitializerException=A static initializer of the main class threw an exception: {0} diff --git a/jdk/src/macosx/classes/apple/security/KeychainStore.java b/jdk/src/macosx/classes/apple/security/KeychainStore.java index 8df45d7bea7..8d04ee976f6 100644 --- a/jdk/src/macosx/classes/apple/security/KeychainStore.java +++ b/jdk/src/macosx/classes/apple/security/KeychainStore.java @@ -74,19 +74,19 @@ public final class KeychainStore extends KeyStoreSpi { * Entries that have been deleted. When something calls engineStore we'll * remove them from the keychain. */ - private Hashtable deletedEntries = new Hashtable(); + private Hashtable deletedEntries = new Hashtable<>(); /** * Entries that have been added. When something calls engineStore we'll * add them to the keychain. */ - private Hashtable addedEntries = new Hashtable(); + private Hashtable addedEntries = new Hashtable<>(); /** * Private keys and certificates are stored in a hashtable. * Hash entries are keyed by alias names. */ - private Hashtable entries = new Hashtable(); + private Hashtable entries = new Hashtable<>(); /** * Algorithm identifiers and corresponding OIDs for the contents of the PKCS12 bag we get from the Keychain. @@ -471,7 +471,7 @@ public final class KeychainStore extends KeyStoreSpi { // This will be slow, but necessary. Enumerate the values and then see if the cert matches the one in the trusted cert entry. // Security framework doesn't support the same certificate twice in a keychain. - Collection allValues = entries.values(); + Collection allValues = entries.values(); for (Object value : allValues) { if (value instanceof TrustedCertEntry) { @@ -517,7 +517,7 @@ public final class KeychainStore extends KeyStoreSpi { * * @return enumeration of the alias names */ - public Enumeration engineAliases() { + public Enumeration engineAliases() { permissionCheck(); return entries.keys(); } @@ -598,8 +598,8 @@ public final class KeychainStore extends KeyStoreSpi { permissionCheck(); Certificate certElem; - for (Enumeration e = entries.keys(); e.hasMoreElements(); ) { - String alias = (String)e.nextElement(); + for (Enumeration e = entries.keys(); e.hasMoreElements(); ) { + String alias = e.nextElement(); Object entry = entries.get(alias); if (entry instanceof TrustedCertEntry) { certElem = ((TrustedCertEntry)entry).cert; @@ -634,8 +634,8 @@ public final class KeychainStore extends KeyStoreSpi { permissionCheck(); // Delete items that do have a keychain item ref. - for (Enumeration e = deletedEntries.keys(); e.hasMoreElements(); ) { - String alias = (String)e.nextElement(); + for (Enumeration e = deletedEntries.keys(); e.hasMoreElements(); ) { + String alias = e.nextElement(); Object entry = deletedEntries.get(alias); if (entry instanceof TrustedCertEntry) { if (((TrustedCertEntry)entry).certRef != 0) { @@ -664,8 +664,8 @@ public final class KeychainStore extends KeyStoreSpi { // Add all of the certs or keys in the added entries. // No need to check for 0 refs, as they are in the added list. - for (Enumeration e = addedEntries.keys(); e.hasMoreElements(); ) { - String alias = (String)e.nextElement(); + for (Enumeration e = addedEntries.keys(); e.hasMoreElements(); ) { + String alias = e.nextElement(); Object entry = addedEntries.get(alias); if (entry instanceof TrustedCertEntry) { TrustedCertEntry tce = (TrustedCertEntry)entry; @@ -730,8 +730,8 @@ public final class KeychainStore extends KeyStoreSpi { // Release any stray keychain references before clearing out the entries. synchronized(entries) { - for (Enumeration e = entries.keys(); e.hasMoreElements(); ) { - String alias = (String)e.nextElement(); + for (Enumeration e = entries.keys(); e.hasMoreElements(); ) { + String alias = e.nextElement(); Object entry = entries.get(alias); if (entry instanceof TrustedCertEntry) { if (((TrustedCertEntry)entry).certRef != 0) { @@ -816,7 +816,7 @@ public final class KeychainStore extends KeyStoreSpi { // Next, create X.509 Certificate objects from the raw data. This is complicated // because a certificate's public key may be too long for Java's default encryption strength. - List createdCerts = new ArrayList(); + List createdCerts = new ArrayList<>(); try { CertificateFactory cf = CertificateFactory.getInstance("X.509"); @@ -842,12 +842,12 @@ public final class KeychainStore extends KeyStoreSpi { // We have our certificates in the List, so now extract them into an array of // Certificates and SecCertificateRefs. - Object[] objArray = createdCerts.toArray(); + CertKeychainItemPair[] objArray = createdCerts.toArray(new CertKeychainItemPair[0]); Certificate[] certArray = new Certificate[objArray.length]; long[] certRefArray = new long[objArray.length]; for (int i = 0; i < objArray.length; i++) { - CertKeychainItemPair addedItem = (CertKeychainItemPair)objArray[i]; + CertKeychainItemPair addedItem = objArray[i]; certArray[i] = addedItem.mCert; certRefArray[i] = addedItem.mCertificateRef; } diff --git a/jdk/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java b/jdk/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java index e91efeaa009..76dea3a7ed3 100644 --- a/jdk/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java +++ b/jdk/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java @@ -95,7 +95,7 @@ class _AppDockIconHandler { static Creator getCImageCreator() { try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {}); + final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {}); getCreatorMethod.setAccessible(true); return (Creator)getCreatorMethod.invoke(null, new Object[] {}); } catch (final Throwable e) { diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaBorder.java b/jdk/src/macosx/classes/com/apple/laf/AquaBorder.java index dfb6fddd5ce..e9eda68094c 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaBorder.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaBorder.java @@ -75,7 +75,7 @@ public abstract class AquaBorder implements Border, UIResource { protected AquaBorder deriveBorderForSize(final Size size) { try { final Class clazz = getClass(); - final AquaBorder border = clazz.getConstructor(new Class[] { clazz }).newInstance(new Object[] { this }); + final AquaBorder border = clazz.getConstructor(new Class[] { clazz }).newInstance(new Object[] { this }); border.setSize(size); return border; } catch (final Throwable e) { diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxButton.java b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxButton.java index 2867245ee1e..c87bcb78c04 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxButton.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxButton.java @@ -35,8 +35,8 @@ import apple.laf.JRSUIConstants.*; @SuppressWarnings("serial") // Superclass is not serializable across versions class AquaComboBoxButton extends JButton { - final protected JComboBox comboBox; - final protected JList list; + final protected JComboBox comboBox; + final protected JList list; final protected CellRendererPane rendererPane; final protected AquaComboBoxUI ui; @@ -45,7 +45,10 @@ class AquaComboBoxButton extends JButton { boolean isSquare; @SuppressWarnings("serial") // anonymous class - protected AquaComboBoxButton(final AquaComboBoxUI ui, final JComboBox comboBox, final CellRendererPane rendererPane, final JList list) { + protected AquaComboBoxButton(final AquaComboBoxUI ui, + final JComboBox comboBox, + final CellRendererPane rendererPane, + final JList list) { super(""); putClientProperty("JButton.buttonType", "comboboxInternal"); @@ -163,7 +166,7 @@ class AquaComboBoxButton extends JButton { } protected void doRendererPaint(final Graphics g, final ButtonModel buttonModel, final boolean editable, final Insets insets, int left, int top, int width, int height) { - final ListCellRenderer renderer = comboBox.getRenderer(); + final ListCellRenderer renderer = comboBox.getRenderer(); // fake it out! not renderPressed final Component c = renderer.getListCellRendererComponent(list, comboBox.getSelectedItem(), -1, false, false); diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java index dde9b1be337..0f466e188e6 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java @@ -43,7 +43,7 @@ class AquaComboBoxPopup extends BasicComboPopup { protected Component bottomStrut; protected boolean isPopDown = false; - public AquaComboBoxPopup(final JComboBox cBox) { + public AquaComboBoxPopup(final JComboBox cBox) { super(cBox); } @@ -93,7 +93,7 @@ class AquaComboBoxPopup extends BasicComboPopup { final int rowCount = Math.min(maxRowCount, currentElementCount); final Dimension popupSize = new Dimension(); - final ListCellRenderer renderer = list.getCellRenderer(); + final ListCellRenderer renderer = list.getCellRenderer(); for (int i = 0; i < rowCount; i++) { final Object value = list.getModel().getElementAt(i); @@ -149,8 +149,8 @@ class AquaComboBoxPopup extends BasicComboPopup { @Override @SuppressWarnings("serial") // anonymous class - protected JList createList() { - return new JList(comboBox.getModel()) { + protected JList createList() { + return new JList(comboBox.getModel()) { @Override public void processMouseEvent(MouseEvent e) { if (e.isMetaDown()) { diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java index 6161eb6447c..f4d4225efe0 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRenderer.java @@ -29,8 +29,8 @@ import javax.swing.*; import javax.swing.plaf.UIResource; @SuppressWarnings("serial") // Superclass is not serializable across versions -class AquaComboBoxRenderer extends AquaComboBoxRendererInternal implements UIResource { - public AquaComboBoxRenderer(final JComboBox comboBox) { +class AquaComboBoxRenderer extends AquaComboBoxRendererInternal implements UIResource { + public AquaComboBoxRenderer(final JComboBox comboBox) { super(comboBox); } } diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java index 2ed6dcfcf70..cf1025f6a85 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxRendererInternal.java @@ -31,8 +31,8 @@ import javax.swing.*; import java.awt.*; @SuppressWarnings("serial") // Superclass is not serializable across versions -class AquaComboBoxRendererInternal extends JLabel implements ListCellRenderer { - final JComboBox fComboBox; +class AquaComboBoxRendererInternal extends JLabel implements ListCellRenderer { + final JComboBox fComboBox; boolean fSelected; boolean fChecked; boolean fInList; @@ -40,7 +40,7 @@ class AquaComboBoxRendererInternal extends JLabel implements ListCellRenderer { boolean fDrawCheckedItem = true; // Provides space for a checkbox, and is translucent - public AquaComboBoxRendererInternal(final JComboBox comboBox) { + public AquaComboBoxRendererInternal(final JComboBox comboBox) { super(); fComboBox = comboBox; } @@ -72,7 +72,10 @@ class AquaComboBoxRendererInternal extends JLabel implements ListCellRenderer { } // Really means is the one with the mouse over it - public Component getListCellRendererComponent(final JList list, final Object value, int index, final boolean isSelected, final boolean cellHasFocus) { + public Component getListCellRendererComponent(final JList list, + final E value, int index, + final boolean isSelected, + final boolean cellHasFocus) { fInList = (index >= 0); // When the button wants the item painted, it passes in -1 fSelected = isSelected; if (index < 0) { diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java index 75c7babb58a..80ca6ff5b49 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java @@ -102,13 +102,13 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { if (now - 1000 < lastBlink) return; lastBlink = now; - final JList itemList = popup.getList(); + final JList itemList = popup.getList(); final ListUI listUI = itemList.getUI(); if (!(listUI instanceof AquaListUI)) return; final AquaListUI aquaListUI = (AquaListUI)listUI; final int selectedIndex = comboBox.getSelectedIndex(); - final ListModel dataModel = itemList.getModel(); + final ListModel dataModel = itemList.getModel(); if (dataModel == null) return; final Object value = dataModel.getElementAt(selectedIndex); @@ -125,7 +125,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { // this space intentionally left blank } - protected ListCellRenderer createRenderer() { + protected ListCellRenderer createRenderer() { return new AquaComboBoxRenderer(comboBox); } @@ -185,7 +185,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { final Object text = editor.getText(); - final ListModel model = listBox.getModel(); + final ListModel model = listBox.getModel(); final int items = model.getSize(); for (int i = 0; i < items; i++) { final Object element = model.getElementAt(i); @@ -423,7 +423,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { return; } - final JComboBox cb = (JComboBox)parent; + final JComboBox cb = (JComboBox) parent; final int width = cb.getWidth(); final int height = cb.getHeight(); @@ -450,11 +450,11 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { return Boolean.TRUE.equals(c.getClientProperty(AquaComboBoxUI.IS_TABLE_CELL_EDITOR)); } - protected static boolean isPopdown(final JComboBox c) { + protected static boolean isPopdown(final JComboBox c) { return c.isEditable() || Boolean.TRUE.equals(c.getClientProperty(AquaComboBoxUI.POPDOWN_CLIENT_PROPERTY_KEY)); } - protected static void triggerSelectionEvent(final JComboBox comboBox, final ActionEvent e) { + protected static void triggerSelectionEvent(final JComboBox comboBox, final ActionEvent e) { if (!comboBox.isEnabled()) return; final AquaComboBoxUI aquaUi = (AquaComboBoxUI)comboBox.getUI(); @@ -505,7 +505,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { @SuppressWarnings("serial") // anonymous class private static final Action toggleSelectionAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { - final JComboBox comboBox = (JComboBox)e.getSource(); + final JComboBox comboBox = (JComboBox) e.getSource(); if (!comboBox.isEnabled()) return; if (comboBox.isEditable()) return; @@ -525,7 +525,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { private final Action hideAction = new AbstractAction() { @Override public void actionPerformed(final ActionEvent e) { - final JComboBox comboBox = (JComboBox)e.getSource(); + final JComboBox comboBox = (JComboBox) e.getSource(); comboBox.firePopupMenuCanceled(); comboBox.setPopupVisible(false); } @@ -588,10 +588,11 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { } @SuppressWarnings("unchecked") - static final RecyclableSingleton> APPLICATOR = new RecyclableSingleton>() { + static final RecyclableSingleton, AquaComboBoxUI>> APPLICATOR = new + RecyclableSingleton, AquaComboBoxUI>>() { @Override - protected ClientPropertyApplicator getInstance() { - return new ClientPropertyApplicator( + protected ClientPropertyApplicator, AquaComboBoxUI> getInstance() { + return new ClientPropertyApplicator, AquaComboBoxUI>( new Property(AquaFocusHandler.FRAME_ACTIVE_PROPERTY) { public void applyProperty(final AquaComboBoxUI target, final Object value) { if (Boolean.FALSE.equals(value)) { @@ -633,7 +634,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { } } ) { - public AquaComboBoxUI convertJComponentToTarget(final JComboBox combo) { + public AquaComboBoxUI convertJComponentToTarget(final JComboBox combo) { final ComboBoxUI comboUI = combo.getUI(); if (comboUI instanceof AquaComboBoxUI) return (AquaComboBoxUI)comboUI; return null; @@ -641,7 +642,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable { }; } }; - static ClientPropertyApplicator getApplicator() { + static ClientPropertyApplicator, AquaComboBoxUI> getApplicator() { return APPLICATOR.get(); } } diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java index 3fae5e20310..ebb3b4b6433 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -724,6 +724,7 @@ public class AquaFileChooserUI extends FileChooserUI { final Transferable transferable = dtde.getTransferable(); try { + @SuppressWarnings("unchecked") final java.util.List fileList = (java.util.List)transferable.getTransferData(DataFlavor.javaFileListFlavor); dropFiles(fileList.toArray(new File[fileList.size()])); dtde.dropComplete(true); @@ -1144,11 +1145,14 @@ public class AquaFileChooserUI extends FileChooserUI { } @SuppressWarnings("serial") // anonymous class - protected ListCellRenderer createDirectoryComboBoxRenderer(final JFileChooser fc) { - return new AquaComboBoxRendererInternal(directoryComboBox) { - public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - final File directory = (File)value; + protected ListCellRenderer createDirectoryComboBoxRenderer(final JFileChooser fc) { + return new AquaComboBoxRendererInternal(directoryComboBox) { + public Component getListCellRendererComponent(final JList list, + final File directory, + final int index, + final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, directory, index, isSelected, cellHasFocus); if (directory == null) { setText(""); return this; @@ -1173,7 +1177,7 @@ public class AquaFileChooserUI extends FileChooserUI { * Data model for a type-face selection combo-box. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { + protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { Vector fDirectories = new Vector(); int topIndex = -1; int fPathCount = 0; @@ -1248,7 +1252,7 @@ public class AquaFileChooserUI extends FileChooserUI { return fDirectories.size(); } - public Object getElementAt(final int index) { + public File getElementAt(final int index) { return fDirectories.elementAt(index); } } @@ -1257,11 +1261,14 @@ public class AquaFileChooserUI extends FileChooserUI { // Renderer for Types ComboBox // @SuppressWarnings("serial") // anonymous class - protected ListCellRenderer createFilterComboBoxRenderer() { - return new AquaComboBoxRendererInternal(filterComboBox) { - public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - final FileFilter filter = (FileFilter)value; + protected ListCellRenderer createFilterComboBoxRenderer() { + return new AquaComboBoxRendererInternal(filterComboBox) { + public Component getListCellRendererComponent(final JList list, + final FileFilter filter, + final int index, + final boolean isSelected, + final boolean cellHasFocus) { + super.getListCellRendererComponent(list, filter, index, isSelected, cellHasFocus); if (filter != null) setText(filter.getDescription()); return this; } @@ -1356,7 +1363,7 @@ public class AquaFileChooserUI extends FileChooserUI { } public void actionPerformed(final ActionEvent e) { - getFileChooser().setFileFilter((FileFilter)filterComboBox.getSelectedItem()); + getFileChooser().setFileFilter((FileFilter) filterComboBox.getSelectedItem()); } } @@ -1503,7 +1510,7 @@ public class AquaFileChooserUI extends FileChooserUI { fTextfieldPanel.add(tPanel, BorderLayout.CENTER); // DirectoryComboBox, left-justified, 200x20 not including drop shadow - directoryComboBox = new JComboBox(); + directoryComboBox = new JComboBox<>(); directoryComboBox.putClientProperty("JComboBox.lightweightKeyboardNavigation", "Lightweight"); fDirectoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBox.setModel(fDirectoryComboBoxModel); @@ -1551,7 +1558,7 @@ public class AquaFileChooserUI extends FileChooserUI { // Combobox filterComboBoxModel = createFilterComboBoxModel(); fc.addPropertyChangeListener(filterComboBoxModel); - filterComboBox = new JComboBox(filterComboBoxModel); + filterComboBox = new JComboBox<>(filterComboBoxModel); formatLabel.setLabelFor(filterComboBox); filterComboBox.setRenderer(createFilterComboBoxRenderer()); d = new Dimension(220, (int)filterComboBox.getMinimumSize().getHeight()); @@ -1788,7 +1795,7 @@ public class AquaFileChooserUI extends FileChooserUI { } } - JComboBox directoryComboBox; + JComboBox directoryComboBox; DirectoryComboBoxModel fDirectoryComboBoxModel; private final Action directoryComboBoxAction = new DirectoryComboBoxAction(); @@ -1797,7 +1804,7 @@ public class AquaFileChooserUI extends FileChooserUI { JTableExtension fFileList; private FilterComboBoxModel filterComboBoxModel; - JComboBox filterComboBox; + JComboBox filterComboBox; private final Action filterComboBoxAction = new FilterComboBoxAction(); private static final Dimension hstrut10 = new Dimension(10, 1); diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaFocusHandler.java b/jdk/src/macosx/classes/com/apple/laf/AquaFocusHandler.java index d5fec4e292c..1438d2c118c 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaFocusHandler.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaFocusHandler.java @@ -131,7 +131,7 @@ public class AquaFocusHandler implements FocusListener, PropertyChangeListener { c.setSelectionBackground(UIManager.getColor(bgName)); } - static void swapSelectionColors(final String prefix, final JList c, final Object value) { + static void swapSelectionColors(final String prefix, final JList c, final Object value) { if (!isComponentValid(c)) return; final Color bg = c.getSelectionBackground(); @@ -149,7 +149,7 @@ public class AquaFocusHandler implements FocusListener, PropertyChangeListener { } } - static void setSelectionColors(final JList c, final String fgName, final String bgName) { + static void setSelectionColors(final JList c, final String fgName, final String bgName) { c.setSelectionForeground(UIManager.getColor(fgName)); c.setSelectionBackground(UIManager.getColor(bgName)); } diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaListUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaListUI.java index 85d06468912..24217af311c 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaListUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaListUI.java @@ -79,7 +79,7 @@ public class AquaListUI extends BasicListUI { * For a Home action, scrolls to the top. Otherwise, scroll to the end. */ public void actionPerformed(final ActionEvent e) { - final JList list = (JList)e.getSource(); + final JList list = (JList)e.getSource(); if (fHomeAction) { list.ensureIndexIsVisible(0); @@ -135,7 +135,7 @@ public class AquaListUI extends BasicListUI { }*/ } - JList getComponent() { + JList getComponent() { return list; } @@ -144,7 +144,7 @@ public class AquaListUI extends BasicListUI { final Rectangle rowBounds = getCellBounds(list, selectedIndex, selectedIndex); if (rowBounds == null) return; - final ListCellRenderer renderer = list.getCellRenderer(); + final ListCellRenderer renderer = list.getCellRenderer(); if (renderer == null) return; final Component rendererComponent = renderer.getListCellRendererComponent(list, value, selectedIndex, selected, true); diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java index dd65433283f..8dd4fa60d2d 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java @@ -3820,7 +3820,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing _loader = null; final Class klass = (Class)loader; try { - final java.lang.reflect.Method method = klass.getDeclaredMethod("loadActionMap", new Class[] { LazyActionMap.class }); + final java.lang.reflect.Method method = klass.getDeclaredMethod("loadActionMap", new Class[] { LazyActionMap.class }); method.invoke(klass, new Object[] { this }); } catch (final NoSuchMethodException nsme) { assert false : "LazyActionMap unable to load actions " + klass; diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaTableHeaderUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaTableHeaderUI.java index 5d847e98ef2..dbc8c8c86ad 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaTableHeaderUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaTableHeaderUI.java @@ -69,6 +69,7 @@ public class AquaTableHeaderUI extends BasicTableHeaderUI { final static RecyclableSingleton> TABLE_HEADER_APPLICATORS = new RecyclableSingleton>() { @Override + @SuppressWarnings("unchecked") protected ClientPropertyApplicator getInstance() { return new ClientPropertyApplicator( new Property("JTableHeader.selectedColumn") { diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaUtilControlSize.java b/jdk/src/macosx/classes/com/apple/laf/AquaUtilControlSize.java index b64595f4245..17b372af858 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaUtilControlSize.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaUtilControlSize.java @@ -121,7 +121,7 @@ public class AquaUtilControlSize { try { // see if this component has a "getUI" method final Class clazz = c.getClass(); - final Method getUIMethod = clazz.getMethod("getUI", new Class[0]); + final Method getUIMethod = clazz.getMethod("getUI", new Class[0]); // see if that UI is one of ours that understands sizing final Object ui = getUIMethod.invoke(c, new Object[0]); diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaUtils.java b/jdk/src/macosx/classes/com/apple/laf/AquaUtils.java index 078435b161b..faa670345c7 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaUtils.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaUtils.java @@ -82,7 +82,8 @@ final class AquaUtils { @Override public Creator run() { try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {}); + final Method getCreatorMethod = CImage.class.getDeclaredMethod( + "getCreator", new Class[] {}); getCreatorMethod.setAccessible(true); return (Creator)getCreatorMethod.invoke(null, new Object[] {}); } catch (final Exception ignored) { @@ -383,7 +384,8 @@ final class AquaUtils { @Override public Method run() { try { - final Method method = JComponent.class.getDeclaredMethod("getFlag", new Class[] { int.class }); + final Method method = JComponent.class.getDeclaredMethod( + "getFlag", new Class[] { int.class }); method.setAccessible(true); return method; } catch (final Throwable ignored) { diff --git a/jdk/src/macosx/classes/com/apple/laf/ClientPropertyApplicator.java b/jdk/src/macosx/classes/com/apple/laf/ClientPropertyApplicator.java index 665c9319cc1..908c63c2c3e 100644 --- a/jdk/src/macosx/classes/com/apple/laf/ClientPropertyApplicator.java +++ b/jdk/src/macosx/classes/com/apple/laf/ClientPropertyApplicator.java @@ -33,6 +33,7 @@ import javax.swing.JComponent; public class ClientPropertyApplicator implements PropertyChangeListener { private final Map> properties = new HashMap>(); + @SuppressWarnings("unchecked") public ClientPropertyApplicator(final Property... propertyList) { for (final Property p : propertyList) { properties.put(p.name, p); diff --git a/jdk/src/macosx/classes/com/apple/laf/ScreenMenuBar.java b/jdk/src/macosx/classes/com/apple/laf/ScreenMenuBar.java index 1735b444ea5..2d56499ebb3 100644 --- a/jdk/src/macosx/classes/com/apple/laf/ScreenMenuBar.java +++ b/jdk/src/macosx/classes/com/apple/laf/ScreenMenuBar.java @@ -25,6 +25,9 @@ package com.apple.laf; +import sun.awt.AWTAccessor; +import sun.lwawt.macosx.CMenuBar; + import java.awt.*; import java.awt.event.*; import java.lang.reflect.*; @@ -243,54 +246,25 @@ public class ScreenMenuBar extends MenuBar implements ContainerListener, ScreenM fSubmenus.remove(menu); } - private static Field[] stolenFields = null; - - static { - stolenFields = AccessController.doPrivileged(new PrivilegedAction() { - public Field[] run() { - try { - final Field[] localFields = new Field[2]; - localFields[0] = MenuBar.class.getDeclaredField("menus"); - localFields[1] = MenuComponent.class.getDeclaredField("parent"); - AccessibleObject.setAccessible(localFields, true); - return localFields; - } catch (final NoSuchFieldException nsf) { - // If this happens, Sun changed the definition of MenuBar and MenuComponent! - nsf.printStackTrace(System.err); - return null; - } - } - }); - }; - public Menu add(final Menu m, final int index) { synchronized (getTreeLock()) { if (m.getParent() != null) { m.getParent().remove(m); } - // Use nasty reflection to get at the menus array and parent fields. - try { - if (stolenFields == null) return m; + final Vector menus = AWTAccessor.getMenuBarAccessor().getMenus(this); + menus.insertElementAt(m, index); + AWTAccessor.getMenuComponentAccessor().setParent(m, this); - final Vector menus = (Vector)stolenFields[0].get(this); - menus.insertElementAt(m, index); + final CMenuBar peer = (CMenuBar)getPeer(); + if (peer == null) return m; - stolenFields[1].set(m, this); - - final sun.lwawt.macosx.CMenuBar peer = (sun.lwawt.macosx.CMenuBar)getPeer(); - if (peer == null) return m; - - peer.setNextInsertionIndex(index); - if (m.getPeer() == null) { - m.addNotify(); - } - - peer.setNextInsertionIndex(-1); - } catch (final IllegalAccessException iae) { - iae.printStackTrace(System.err); + peer.setNextInsertionIndex(index); + if (m.getPeer() == null) { + m.addNotify(); } + peer.setNextInsertionIndex(-1); return m; } } diff --git a/jdk/src/macosx/lib/flavormap.properties b/jdk/src/macosx/classes/sun/awt/datatransfer/flavormap.properties similarity index 86% rename from jdk/src/macosx/lib/flavormap.properties rename to jdk/src/macosx/classes/sun/awt/datatransfer/flavormap.properties index 8f17d95fa20..b50c523279e 100644 --- a/jdk/src/macosx/lib/flavormap.properties +++ b/jdk/src/macosx/classes/sun/awt/datatransfer/flavormap.properties @@ -2,19 +2,12 @@ # This properties file is used to initialize the default # java.awt.datatransfer.SystemFlavorMap. It contains the Mac OS X platform-specific, # default mappings between common Mac OS X selection atoms and platform-independent -# MIME type strings, which will be converted into +# MIME type strings, which will be converted into # java.awt.datatransfer.DataFlavors. # -# These default mappings may be augmented by specifying the -# -# AWT.DnD.flavorMapFileURL -# -# property in the appropriate awt.properties file. The specified properties URL -# will be loaded into the SystemFlavorMap. -# # The standard format is: # -# = +# =,, ... # # should be a string identifier that the native platform will # recognize as a valid data format. should specify both a MIME @@ -23,9 +16,9 @@ # where each parameter to the MIME type is separated by a ';'. # # Because SystemFlavorMap implements FlavorTable, developers are free to -# duplicate both native keys and DataFlavor values. If a mapping contains a -# duplicate key or value, earlier mappings which included this key or value -# will be preferred. +# duplicate DataFlavor values and set multiple values for a single native by +# separating them with ",". If a mapping contains a duplicate key or value, +# earlier mappings which included this key or value will be preferred. # # Mappings whose values specify DataFlavors with primary MIME types of # "text", and which support the charset parameter, should specify the exact @@ -79,5 +72,5 @@ JFIF=image/x-java-image;class=java.awt.Image TIFF=image/x-java-image;class=java.awt.Image RICH_TEXT=text/rtf HTML=text/html;charset=utf-8;eoln="\r\n";terminators=1 -URL=application/x-java-url;class=java.net.URL -URL=text/uri-list;eoln="\r\n";terminators=1 +URL=application/x-java-url;class=java.net.URL,\ + text/uri-list;eoln="\r\n";terminators=1 diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java index 67570c18a6f..c6c75bc82c6 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java @@ -88,7 +88,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { super.startDrag(dsc, cursor, dragImage, dragImageOffset); } - protected void startDrag(Transferable transferable, long[] formats, Map formatMap) { + protected void startDrag(Transferable transferable, long[] formats, Map formatMap) { DragGestureEvent trigger = getTrigger(); InputEvent triggerEvent = trigger.getTriggerEvent(); @@ -311,7 +311,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { } } - private void setDefaultDragImage(JList component) { + private void setDefaultDragImage(JList component) { Rectangle selectedOutline = null; // This code actually works, even under the (non-existant) multiple-selections, because we only draw a union outline @@ -485,7 +485,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { private native long createNativeDragSource(Component component, long nativePeer, Transferable transferable, InputEvent triggerEvent, int dragPosX, int dragPosY, int extModifiers, int clickCount, long timestamp, long nsDragImagePtr, int dragImageOffsetX, int dragImageOffsetY, - int sourceActions, long[] formats, Map formatMap); + int sourceActions, long[] formats, Map formatMap); private native void doDragging(long nativeDragSource); diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethod.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethod.java index eef5284175b..077b156d806 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethod.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethod.java @@ -44,13 +44,14 @@ import sun.lwawt.*; public class CInputMethod extends InputMethodAdapter { private InputMethodContext fIMContext; private Component fAwtFocussedComponent; - private LWComponentPeer fAwtFocussedComponentPeer; + private LWComponentPeer fAwtFocussedComponentPeer; private boolean isActive; private static Map[] sHighlightStyles; // Intitalize highlight mapping table and its mapper. static { + @SuppressWarnings({"rawtypes", "unchecked"}) Map styles[] = new Map[4]; HashMap map; @@ -242,7 +243,7 @@ public class CInputMethod extends InputMethodAdapter { public void hideWindows() { } - long getNativeViewPtr(LWComponentPeer peer) { + long getNativeViewPtr(LWComponentPeer peer) { if (peer.getPlatformWindow() instanceof CPlatformWindow) { CPlatformWindow platformWindow = (CPlatformWindow) peer.getPlatformWindow(); CPlatformView platformView = platformWindow.getContentView(); @@ -272,7 +273,7 @@ public class CInputMethod extends InputMethodAdapter { * to talk to when responding to key events. */ protected void setAWTFocussedComponent(Component component) { - LWComponentPeer peer = null; + LWComponentPeer peer = null; long modelPtr = 0; CInputMethod imInstance = this; @@ -305,7 +306,7 @@ public class CInputMethod extends InputMethodAdapter { /** * @see java.awt.Toolkit#mapInputMethodHighlight */ - public static Map mapInputMethodHighlight(InputMethodHighlight highlight) { + public static Map mapInputMethodHighlight(InputMethodHighlight highlight) { int index; int state = highlight.getState(); if (state == InputMethodHighlight.RAW_TEXT) { @@ -384,7 +385,7 @@ public class CInputMethod extends InputMethodAdapter { // java.awt.Toolkit#getNativeContainer() is not available // from this package - private LWComponentPeer getNearestNativePeer(Component comp) { + private LWComponentPeer getNearestNativePeer(Component comp) { if (comp==null) return null; @@ -796,7 +797,7 @@ public class CInputMethod extends InputMethodAdapter { // these calls will be ignored. private native void nativeNotifyPeer(long nativePeer, CInputMethod imInstance); private native void nativeEndComposition(long nativePeer); - private native void nativeHandleEvent(LWComponentPeer peer, AWTEvent event); + private native void nativeHandleEvent(LWComponentPeer peer, AWTEvent event); // Returns the locale of the active input method. static native Locale getNativeLocale(); diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java index d922d029b33..3deba1e33f9 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java @@ -57,7 +57,7 @@ public class CInputMethodDescriptor implements InputMethodDescriptor { } static Object[] getAvailableLocalesInternal() { - List workList = nativeGetAvailableLocales(); + List workList = nativeGetAvailableLocales(); if (workList != null) { return workList.toArray(); @@ -119,5 +119,5 @@ public class CInputMethodDescriptor implements InputMethodDescriptor { } private static native void nativeInit(); - private static native List nativeGetAvailableLocales(); + private static native List nativeGetAvailableLocales(); } diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 534cf0dd744..5af2cdfe1d0 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -151,7 +151,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo return (bits & mask) != 0; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) static ClientPropertyApplicator CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator(new Property[] { new Property(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) { c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString())); diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index edbebbacb67..768086220c3 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -32,6 +32,7 @@ import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.event.InputEvent; import java.awt.event.InvocationEvent; import java.awt.event.KeyEvent; +import java.awt.font.TextAttribute; import java.awt.im.InputMethodHighlight; import java.awt.im.spi.InputMethodDescriptor; import java.awt.peer.*; @@ -543,9 +544,9 @@ public final class LWCToolkit extends LWToolkit { return super.getImage(filename); } - String fileneame2x = getScaledImageName(filename); - return (imageExists(fileneame2x)) - ? getImageWithResolutionVariant(filename, fileneame2x) + String filename2x = getScaledImageName(filename); + return (imageExists(filename2x)) + ? getImageWithResolutionVariant(filename, filename2x) : super.getImage(filename); } @@ -691,6 +692,7 @@ public final class LWCToolkit extends LWToolkit { } @Override + @SuppressWarnings("unchecked") public T createDragGestureRecognizer( Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) { @@ -743,7 +745,7 @@ public final class LWCToolkit extends LWToolkit { * @since 1.3 */ @Override - public Map mapInputMethodHighlight(InputMethodHighlight highlight) { + public Map mapInputMethodHighlight(InputMethodHighlight highlight) { return CInputMethod.mapInputMethodHighlight(highlight); } @@ -906,6 +908,9 @@ public final class LWCToolkit extends LWToolkit { } private static boolean isValidPath(String path) { - return !path.isEmpty() && !path.endsWith("/") && !path.endsWith("."); + return path != null && + !path.isEmpty() && + !path.endsWith("/") && + !path.endsWith("."); } } diff --git a/jdk/src/macosx/native/apple/launcher/JavaAppLauncher.m b/jdk/src/macosx/native/apple/launcher/JavaAppLauncher.m deleted file mode 100644 index 11f98dbdde7..00000000000 --- a/jdk/src/macosx/native/apple/launcher/JavaAppLauncher.m +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "apple_launcher_JavaAppLauncher.h" - -#import -#import - - -/* - * Class: apple_launcher_JavaAppLauncher - * Method: nativeConvertAndRelease - * Signature: (J)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_apple_launcher_JavaAppLauncher_nativeConvertAndRelease -(JNIEnv *env, jclass clazz, jlong nsObjectPtr) { - - jobject value = NULL; - -JNF_COCOA_ENTER(env); - - id obj = jlong_to_ptr(nsObjectPtr); - value = [[JNFDefaultCoercions defaultCoercer] coerceNSObject:obj withEnv:env]; - CFRelease(obj); - -JNF_COCOA_EXIT(env); - - return value; -} - -/* - * Class: apple_launcher_JavaAppLauncher - * Method: nativeInvokeNonPublic - * Signature: (Ljava/lang/Class;Ljava/lang/reflect/Method;[Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_apple_launcher_JavaAppLauncher_nativeInvokeNonPublic -(JNIEnv *env, jclass clazz, jclass targetClass, jobject targetMethod, jobjectArray args) { - jmethodID mainMethodID = (*env)->FromReflectedMethod(env, targetMethod); - if ((*env)->ExceptionOccurred(env)) return; - (*env)->CallStaticVoidMethod(env, targetClass, mainMethodID, args); -} diff --git a/jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m b/jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m index affb6577d64..25b00545a74 100644 --- a/jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m +++ b/jdk/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m @@ -45,6 +45,7 @@ #include #include +#import "ThreadUtilities.h" static NSScreen* SplashNSScreen() { @@ -130,8 +131,12 @@ char* SplashGetScaledImageName(const char* jar, const char* file, NSAutoreleasePool *pool = [NSAutoreleasePool new]; *scaleFactor = 1; char* scaledFile = nil; - float screenScaleFactor = [SplashNSScreen() backingScaleFactor]; - + __block float screenScaleFactor = 1; + + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ + screenScaleFactor = [SplashNSScreen() backingScaleFactor]; + }]; + if (screenScaleFactor > 1) { NSString *fileName = [NSString stringWithUTF8String: file]; NSUInteger length = [fileName length]; diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c index df1f832cef8..c71f4c26fab 100644 --- a/jdk/src/share/bin/java.c +++ b/jdk/src/share/bin/java.c @@ -98,6 +98,7 @@ static int numOptions, maxOptions; */ static void SetClassPath(const char *s); static void SelectVersion(int argc, char **argv, char **main_class); +static void SetJvmEnvironment(int argc, char **argv); static jboolean ParseArguments(int *pargc, char ***pargv, int *pmode, char **pwhat, int *pret, const char *jrepath); @@ -238,6 +239,10 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ jvmpath, sizeof(jvmpath), jvmcfg, sizeof(jvmcfg)); + if (!IsJavaArgs()) { + SetJvmEnvironment(argc,argv); + } + ifn.CreateJavaVM = 0; ifn.GetDefaultJavaVMInitArgs = 0; @@ -640,6 +645,67 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { return jvmtype; } +/* + * static void SetJvmEnvironment(int argc, char **argv); + * Is called just before the JVM is loaded. We can set env variables + * that are consumed by the JVM. This function is non-destructive, + * leaving the arg list intact. The first use is for the JVM flag + * -XX:NativeMemoryTracking=value. + */ +static void +SetJvmEnvironment(int argc, char **argv) { + + static const char* NMT_Env_Name = "NMT_LEVEL_"; + + int i; + for (i = 0; i < argc; i++) { + /* + * The following case checks for "-XX:NativeMemoryTracking=value". + * If value is non null, an environmental variable set to this value + * will be created to be used by the JVM. + * The argument is passed to the JVM, which will check validity. + * The JVM is responsible for removing the env variable. + */ + char *arg = argv[i]; + if (JLI_StrCCmp(arg, "-XX:NativeMemoryTracking=") == 0) { + int retval; + // get what follows this parameter, include "=" + size_t pnlen = JLI_StrLen("-XX:NativeMemoryTracking="); + if (JLI_StrLen(arg) > pnlen) { + char* value = arg + pnlen; + size_t pbuflen = pnlen + JLI_StrLen(value) + 10; // 10 max pid digits + + /* + * ensures that malloc successful + * DONT JLI_MemFree() pbuf. JLI_PutEnv() uses system call + * that could store the address. + */ + char * pbuf = (char*)JLI_MemAlloc(pbuflen); + + JLI_Snprintf(pbuf, pbuflen, "%s%d=%s", NMT_Env_Name, JLI_GetPid(), value); + retval = JLI_PutEnv(pbuf); + if (JLI_IsTraceLauncher()) { + char* envName; + char* envBuf; + + // ensures that malloc successful + envName = (char*)JLI_MemAlloc(pbuflen); + JLI_Snprintf(envName, pbuflen, "%s%d", NMT_Env_Name, JLI_GetPid()); + + printf("TRACER_MARKER: NativeMemoryTracking: env var is %s\n",envName); + printf("TRACER_MARKER: NativeMemoryTracking: putenv arg %s\n",pbuf); + envBuf = getenv(envName); + printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf); + free(envName); + } + + } + + } + + } +} + /* copied from HotSpot function "atomll()" */ static int parse_size(const char *s, jlong *result) { diff --git a/jdk/src/share/bin/jli_util.h b/jdk/src/share/bin/jli_util.h index d3c9f0ff8f2..579972278b3 100644 --- a/jdk/src/share/bin/jli_util.h +++ b/jdk/src/share/bin/jli_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,17 +64,22 @@ int JLI_GetStdArgc(); #ifdef _WIN32 #include #include +#include #define JLI_StrCaseCmp(p1, p2) stricmp((p1), (p2)) #define JLI_StrNCaseCmp(p1, p2, p3) strnicmp((p1), (p2), (p3)) int JLI_Snprintf(char *buffer, size_t size, const char *format, ...); void JLI_CmdToArgs(char *cmdline); #define JLI_Lseek _lseeki64 +#define JLI_PutEnv _putenv +#define JLI_GetPid _getpid #else /* NIXES */ #include #include #define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2)) #define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3)) #define JLI_Snprintf snprintf +#define JLI_PutEnv putenv +#define JLI_GetPid getpid #ifdef __solaris__ #define JLI_Lseek llseek #endif diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java index 03d649907e2..c22415b7575 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java @@ -126,18 +126,18 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants { new IIOMetadataNode(nativeMetadataFormatName); addChildNode(root, "BMPVersion", bmpVersion); - addChildNode(root, "Width", new Integer(width)); - addChildNode(root, "Height", new Integer(height)); + addChildNode(root, "Width", width); + addChildNode(root, "Height", height); addChildNode(root, "BitsPerPixel", new Short(bitsPerPixel)); - addChildNode(root, "Compression", new Integer(compression)); - addChildNode(root, "ImageSize", new Integer(imageSize)); + addChildNode(root, "Compression", compression); + addChildNode(root, "ImageSize", imageSize); IIOMetadataNode node = addChildNode(root, "PixelsPerMeter", null); - addChildNode(node, "X", new Integer(xPixelsPerMeter)); - addChildNode(node, "Y", new Integer(yPixelsPerMeter)); + addChildNode(node, "X", xPixelsPerMeter); + addChildNode(node, "Y", yPixelsPerMeter); - addChildNode(root, "ColorsUsed", new Integer(colorsUsed)); - addChildNode(root, "ColorsImportant", new Integer(colorsImportant)); + addChildNode(root, "ColorsUsed", colorsUsed); + addChildNode(root, "ColorsImportant", colorsImportant); int version = 0; for (int i = 0; i < bmpVersion.length(); i++) @@ -146,19 +146,19 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants { if (version >= 4) { node = addChildNode(root, "Mask", null); - addChildNode(node, "Red", new Integer(redMask)); - addChildNode(node, "Green", new Integer(greenMask)); - addChildNode(node, "Blue", new Integer(blueMask)); - addChildNode(node, "Alpha", new Integer(alphaMask)); + addChildNode(node, "Red", redMask); + addChildNode(node, "Green", greenMask); + addChildNode(node, "Blue", blueMask); + addChildNode(node, "Alpha", alphaMask); - addChildNode(root, "ColorSpaceType", new Integer(colorSpace)); + addChildNode(root, "ColorSpaceType", colorSpace); node = addChildNode(root, "CIEXYZEndPoints", null); addXYZPoints(node, "Red", redX, redY, redZ); addXYZPoints(node, "Green", greenX, greenY, greenZ); addXYZPoints(node, "Blue", blueX, blueY, blueZ); - node = addChildNode(root, "Intent", new Integer(intent)); + node = addChildNode(root, "Intent", intent); } // Palette diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java index 51f1234d74d..f25863955ec 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java @@ -2323,7 +2323,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable { SOSMarkerSegment sos = (SOSMarkerSegment) seg; SOSMarkerSegment.ScanComponentSpec [] specs = sos.componentSpecs; for (int i = 0; i < specs.length; i++) { - Integer id = new Integer(specs[i].componentSelector); + Integer id = specs[i].componentSelector; if (!ids.contains(id)) { ids.add(id); } diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index 3b2a081d860..d3f489b7ee2 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -639,7 +639,7 @@ public class PNGImageReader extends ImageReader { metadata.zTXt_keyword.add(keyword); int method = stream.readUnsignedByte(); - metadata.zTXt_compressionMethod.add(new Integer(method)); + metadata.zTXt_compressionMethod.add(method); byte[] b = new byte[chunkLength - keyword.length() - 2]; stream.readFully(b); diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java index 11018ec4015..f02dd4391f0 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java @@ -1254,8 +1254,11 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { if (name.equals("IHDR")) { IHDR_width = getIntAttribute(node, "width"); IHDR_height = getIntAttribute(node, "height"); - IHDR_bitDepth = getEnumeratedAttribute(node, "bitDepth", - IHDR_bitDepths); + IHDR_bitDepth = + Integer.valueOf(IHDR_bitDepths[ + getEnumeratedAttribute(node, + "bitDepth", + IHDR_bitDepths)]); IHDR_colorType = getEnumeratedAttribute(node, "colorType", IHDR_colorTypeNames); IHDR_compressionMethod = @@ -1644,7 +1647,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { int compressionMethod = getEnumeratedAttribute(zTXt_node, "compressionMethod", zTXt_compressionMethodNames); - zTXt_compressionMethod.add(new Integer(compressionMethod)); + zTXt_compressionMethod.add(compressionMethod); String text = getAttribute(zTXt_node, "text"); zTXt_text.add(text); diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPMetadata.java index c28046f0b58..28ad467eadd 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPMetadata.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPMetadata.java @@ -75,9 +75,9 @@ public class WBMPMetadata extends IIOMetadata { IIOMetadataNode root = new IIOMetadataNode(nativeMetadataFormatName); - addChildNode(root, "WBMPType", new Integer(wbmpType)); - addChildNode(root, "Width", new Integer(width)); - addChildNode(root, "Height", new Integer(height)); + addChildNode(root, "WBMPType", wbmpType); + addChildNode(root, "Width", width); + addChildNode(root, "Height", height); return root; } diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java index b35e60d7ec6..cfdd8672303 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java @@ -812,12 +812,12 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "OptionPane.setButtonMargin", Boolean.FALSE, "OptionPane.sameSizeButtons", Boolean.TRUE, - "OptionPane.buttonOrientation", new Integer(SwingConstants.RIGHT), + "OptionPane.buttonOrientation", SwingConstants.RIGHT, "OptionPane.minimumSize", new DimensionUIResource(262, 90), - "OptionPane.buttonPadding", new Integer(10), + "OptionPane.buttonPadding", 10, "OptionPane.windowBindings", new Object[] { "ESCAPE", "close" }, - "OptionPane.buttonClickThreshhold", new Integer(500), + "OptionPane.buttonClickThreshhold", 500, "OptionPane.isYesLast", Boolean.TRUE, "OptionPane.font", new FontLazyValue(Region.OPTION_PANE), diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java index 116fe475be3..79ebfbc8cff 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java @@ -567,7 +567,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "ProgressBar.selectionForeground", table.get("control"), "ProgressBar.selectionBackground", table.get("controlText"), "ProgressBar.border", loweredBevelBorder, - "ProgressBar.cellLength", new Integer(6), + "ProgressBar.cellLength", 6, "ProgressBar.cellSpacing", Integer.valueOf(0), // Buttons @@ -582,7 +582,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "released SPACE", "released" }), - "CheckBox.textIconGap", new Integer(8), + "CheckBox.textIconGap", 8, "CheckBox.margin", new InsetsUIResource(4, 2, 4, 2), "CheckBox.icon", checkBoxIcon, "CheckBox.focus", table.get("activeCaptionBorder"), @@ -593,7 +593,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel }), "RadioButton.margin", new InsetsUIResource(4, 2, 4, 2), - "RadioButton.textIconGap", new Integer(8), + "RadioButton.textIconGap", 8, "RadioButton.background", table.get("control"), "RadioButton.foreground", table.get("controlText"), "RadioButton.icon", radioButtonIcon, @@ -627,10 +627,10 @@ public class MotifLookAndFeel extends BasicLookAndFeel "Menu.selectionBackground", menuItemPressedBackground, "Menu.checkIcon", menuItemCheckIcon, "Menu.arrowIcon", menuArrowIcon, - "Menu.menuPopupOffsetX", new Integer(0), - "Menu.menuPopupOffsetY", new Integer(0), - "Menu.submenuPopupOffsetX", new Integer(-2), - "Menu.submenuPopupOffsetY", new Integer(3), + "Menu.menuPopupOffsetX", 0, + "Menu.menuPopupOffsetY", 0, + "Menu.submenuPopupOffsetX", -2, + "Menu.submenuPopupOffsetY", 3, "Menu.shortcutKeys", new int[]{ SwingUtilities2.getSystemMnemonicKeyMask(), KeyEvent.META_MASK @@ -938,7 +938,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "Tree.collapsedIcon", treeCollapsedIcon, "Tree.editorBorder", focusBorder, "Tree.editorBorderSelectionColor", table.get("activeCaptionBorder"), - "Tree.rowHeight", new Integer(18), + "Tree.rowHeight", 18, "Tree.drawsFocusBorderAroundIcon", Boolean.TRUE, "Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "COPY", "copy", diff --git a/jdk/src/share/classes/com/sun/jndi/cosnaming/CNCtx.java b/jdk/src/share/classes/com/sun/jndi/cosnaming/CNCtx.java index 800c0a53643..6a4d3dea7da 100644 --- a/jdk/src/share/classes/com/sun/jndi/cosnaming/CNCtx.java +++ b/jdk/src/share/classes/com/sun/jndi/cosnaming/CNCtx.java @@ -1145,7 +1145,7 @@ public class CNCtx implements javax.naming.Context { // Never destroy an orb in CNCtx. // The orb we have is either the shared/default orb, or one passed in to a constructor - // from elsewhere, so that orb is somebody else's reponsibility. + // from elsewhere, so that orb is somebody else's responsibility. } protected void finalize() { diff --git a/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java b/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java index 18654c87808..db1f907182a 100644 --- a/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java +++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java @@ -376,7 +376,7 @@ public class DnsClient { /** - * Tries to retreive an UDP packet matching the given xid + * Tries to retrieve a UDP packet matching the given xid * received within the timeout. * If a packet with different xid is received, the received packet * is enqueued with the corresponding xid in 'resps'. diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java b/jdk/src/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java index 241105bf1ce..be3315674fa 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java @@ -137,7 +137,7 @@ abstract class AbstractLdapNamingEnumeration limit = (entries == null) ? 0 : entries.size(); // handle empty set posn = 0; // reset - // mimimize the number of calls to processReturnCode() + // minimize the number of calls to processReturnCode() // (expensive when batchSize is small and there are many results) if ((res.status != LdapClient.LDAP_SUCCESS) || ((res.status == LdapClient.LDAP_SUCCESS) && diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java b/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java index 5095823dc23..aa535a2b995 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/ClientId.java @@ -196,7 +196,7 @@ class ClientId { System.out.println("ClientId received an exception"); e.printStackTrace(); } - // Failed to invoke the comparator; flag unequality + // Failed to invoke the comparator; flag inequality return false; } if (((Integer) ret) == 0) { diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/EventQueue.java b/jdk/src/share/classes/com/sun/jndi/ldap/EventQueue.java index db335f7acc9..85bc38076f5 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/EventQueue.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/EventQueue.java @@ -75,7 +75,7 @@ final class EventQueue implements Runnable { * Enqueue an event. * @param event Either a NamingExceptionEvent or a subclass * of NamingEvent or - * UnsolicitedNotificatoniEvent. + * UnsolicitedNotificationEvent. * If it is a subclass of NamingEvent, all listeners must implement * the corresponding subinterface of NamingListener. * For example, for a ObjectAddedEvent, all listeners must @@ -141,7 +141,7 @@ final class EventQueue implements Runnable { // it is interested in. (No need to check mask or // instanceof subinterfaces.) // It is the responsibility of the enqueuer to - // only enqueue events with listseners of the correct type. + // only enqueue events with listeners of the correct type. if (e instanceof NamingEvent) { ((NamingEvent)e).dispatch(v.elementAt(i)); diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/EventSupport.java b/jdk/src/share/classes/com/sun/jndi/ldap/EventSupport.java index a9d45a23c17..86006ff714b 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/EventSupport.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/EventSupport.java @@ -83,7 +83,7 @@ import javax.naming.ldap.UnsolicitedNotification; *a new notifier is created for the listener. * *

    Deregistration

    - *When a deregistration request is made, this class attemps to find its + *When a deregistration request is made, this class attempts to find its *corresponding notifier. If the notifier is found, the listener is removed *from the notifier's list. If the listener is the last listener on the list, *the notifier's thread is terminated and removed from this class's hashtable. diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapAttribute.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapAttribute.java index 50f6ac69f5f..36c7dad4611 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapAttribute.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapAttribute.java @@ -34,7 +34,7 @@ import javax.naming.directory.*; /** * This subclass is used by LDAP to implement the schema calls. * Basically, it keeps track of which context it is an attribute of - * so it can get the schema for that cotnext. + * so it can get the schema for that context. * * @author Jon Ruiz */ @@ -134,7 +134,7 @@ final class LdapAttribute extends BasicAttribute { // setup internal state this.setBaseCtxInfo(); - // let the ObjectOutpurStream do the real work of serialization + // let the ObjectOutputStream do the real work of serialization out.defaultWriteObject(); } diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java index e5821adea6e..c163dce796a 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java @@ -1651,7 +1651,7 @@ final public class LdapCtx extends ComponentDirContext * * This function is called regardless of the server's version, since * an administrator may have setup the server to support client schema - * queries. If this function trys a serarch on a v2 server that + * queries. If this function tries a search on a v2 server that * doesn't support schema, one of these two things will happen: * 1) It will get an exception when querying the root DSE * 2) It will not find a subschemasubentry on the root DSE @@ -2016,7 +2016,7 @@ final public class LdapCtx extends ComponentDirContext * - the returning attributes list is present but empty */ - // returns true if a search can be caried out as a compare, and sets + // returns true if a search can be carried out as a compare, and sets // tokens[0] and tokens[1] to the type and value respectively. // e.g. filter "cn=Jon Ruiz" becomes, type "cn" and value "Jon Ruiz" // This function uses the documents JNDI Compare example as a model @@ -2083,7 +2083,7 @@ final public class LdapCtx extends ComponentDirContext return false; // unbalanced } - // make sure the left and right half are not expresions themselves + // make sure the left and right half are not expressions themselves StringTokenizer illegalCharsTokenizer = new StringTokenizer(tokens[0], "()&|!=~><*", true); @@ -2443,7 +2443,7 @@ final public class LdapCtx extends ComponentDirContext } /** - * Set whether aliases are derefereced during resolution and searches. + * Set whether aliases are dereferenced during resolution and searches. */ private void setDerefAliases(String deref) { if (deref != null) { diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapName.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapName.java index d29e408cdec..b3f76d9ab0b 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapName.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapName.java @@ -346,8 +346,8 @@ public final class LdapName implements Name { } /** - * Given an attribute value formated according to RFC 2253, - * returns the unformated value. Returns a string value as + * Given an attribute value formatted according to RFC 2253, + * returns the unformatted value. Returns a string value as * a string, and a binary value as a byte array. */ public static Object unescapeAttributeValue(String val) { @@ -687,7 +687,7 @@ public final class LdapName implements Name { private final boolean binary; private final boolean valueCaseSensitive; - // If non-null, a canonical represention of the value suitable + // If non-null, a canonical representation of the value suitable // for comparison using String.compareTo(). private String comparable = null; @@ -842,8 +842,8 @@ public final class LdapName implements Name { } /* - * Given an attribute value formated according to RFC 2253, - * returns the unformated value. Escapes and quotes are + * Given an attribute value formatted according to RFC 2253, + * returns the unformatted value. Escapes and quotes are * stripped away, and hex-encoded UTF-8 is converted to 16-bit * Unicode chars. Returns a string value as a String, and a * binary value as a byte array. diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java index 0a09e0fda69..b810187c649 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java @@ -679,7 +679,7 @@ final class LdapReferralContext implements DirContext, LdapContext { } catch (LdapReferralException e) { - // %%% VR - setNameResolved(true); + // %%% setNameResolved(true); // append (referrals from) the exception that generated this // context to the new exception, so that referral processing @@ -897,7 +897,7 @@ final class LdapReferralContext implements DirContext, LdapContext { /* * Use the attributes and scope components from the LDAP URL (if present) - * to override the corrpesonding components supplied in SearchControls. + * to override the corresponding components supplied in SearchControls. */ private SearchControls overrideAttributesAndScope(SearchControls cons) { SearchControls urlCons; diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapRequest.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapRequest.java index 23347ac5dc8..6e7e3e6544b 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapRequest.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapRequest.java @@ -62,7 +62,7 @@ final class LdapRequest { cancelled = true; // Unblock reader of pending request - // Should only ever have atmost one waiter + // Should only ever have at most one waiter notify(); } diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java index 7fddd7799f5..ae3d2bd4881 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapSchemaParser.java @@ -84,7 +84,7 @@ final class LdapSchemaParser { // Object Class specific IDs private static final String ABSTRACT_ID = "ABSTRACT"; private static final String STRUCTURAL_ID = "STRUCTURAL"; - private static final String AUXILARY_ID = "AUXILIARY"; + private static final String AUXILIARY_ID = "AUXILIARY"; private static final String MUST_ID = "MUST"; private static final String MAY_ID = "MAY"; @@ -300,8 +300,8 @@ final class LdapSchemaParser { return new Object[] {currentName, attrs}; } - // returns the index of the first whitespace char of a linear whitspace - // sequince ending at the given position. + // returns the index of the first whitespace char of a linear whitespace + // sequence ending at the given position. final private static int findTrailingWhitespace(String string, int pos) { for(int i = pos; i > 0; i--) { if(string.charAt(i) != WHSP) { @@ -423,7 +423,7 @@ final class LdapSchemaParser { if (tag.equals(OBSOLETE_ID) || tag.equals(ABSTRACT_ID) || tag.equals(STRUCTURAL_ID) || - tag.equals(AUXILARY_ID) || + tag.equals(AUXILIARY_ID) || tag.equals(SINGLE_VAL_ID) || tag.equals(COLLECTIVE_ID) || tag.equals(NO_USER_MOD_ID)) { @@ -819,7 +819,7 @@ final class LdapSchemaParser { count++; } - attr = attrs.get(AUXILARY_ID); + attr = attrs.get(AUXILIARY_ID); if (attr != null) { objectDesc.append(writeBoolean(attr)); count++; @@ -856,7 +856,7 @@ final class LdapSchemaParser { attrId.equals(MUST_ID) || attrId.equals(STRUCTURAL_ID) || attrId.equals(DESC_ID) || - attrId.equals(AUXILARY_ID) || + attrId.equals(AUXILIARY_ID) || attrId.equals(ABSTRACT_ID) || attrId.equals(OBSOLETE_ID)) { continue; diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java index 329b1d249af..4af58a8b0dd 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapSearchEnumeration.java @@ -156,7 +156,7 @@ final class LdapSearchEnumeration String[] reqAttrs; if ((reqAttrs = searchArgs.reqAttrs) != null) { // create an attribute set for those requested - Attributes rattrs = new BasicAttributes(true); // caseignore + Attributes rattrs = new BasicAttributes(true); // ignore case for (int i = 0; i < reqAttrs.length; i++) { rattrs.put(reqAttrs[i], null); } @@ -213,8 +213,6 @@ final class LdapSearchEnumeration // Update search-specific variables LdapSearchEnumeration se = (LdapSearchEnumeration)ne; startName = se.startName; -//VR - keep original args, don't overwite with current args -// searchArgs = se.searchArgs; } void setStartName(Name nm) { diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapURL.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapURL.java index ada02f6f3bc..40b2b56cf42 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapURL.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapURL.java @@ -162,7 +162,7 @@ final public class LdapURL extends Uri { } /** - * Derermines whether an LDAP URL has query components. + * Determines whether an LDAP URL has query components. */ public static boolean hasQueryComponents(String url) { return (url.lastIndexOf('?') != -1); diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java b/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java index 05df1bbd6b7..a7bf61d9494 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/ServiceLocator.java @@ -62,7 +62,7 @@ class ServiceLocator { * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. - * @throw InvalidNameException If the distinugished name is invalid. + * @throw InvalidNameException If the distinguished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper.java b/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper.java index 0a696bd4ff2..17e7bc13779 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper.java @@ -25,32 +25,77 @@ package com.sun.jndi.ldap; +import sun.misc.SharedSecrets; + import java.net.MalformedURLException; import java.net.URL; +import java.net.URLClassLoader; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; -abstract class VersionHelper { +public final class VersionHelper { - private static final VersionHelper helper = new VersionHelper12(); + private static final VersionHelper helper = new VersionHelper(); - VersionHelper() {} // Disallow anyone from creating one of these. + /** + * Determines whether classes may be loaded from an arbitrary URL code base. + */ + private static final boolean trustURLCodebase; + + static { + // System property to control whether classes may be loaded from an + // arbitrary URL code base + PrivilegedAction act = + () -> System.getProperty("com.sun.jndi.ldap.object.trustURLCodebase", "false"); + String trust = AccessController.doPrivileged(act); + trustURLCodebase = "true".equalsIgnoreCase(trust); + } + + private VersionHelper() { } static VersionHelper getVersionHelper() { return helper; } - abstract ClassLoader getURLClassLoader(String[] url) - throws MalformedURLException; + ClassLoader getURLClassLoader(String[] url) throws MalformedURLException { + ClassLoader parent = getContextClassLoader(); + /* + * Classes may only be loaded from an arbitrary URL code base when + * the system property com.sun.jndi.ldap.object.trustURLCodebase + * has been set to "true". + */ + if (url != null && trustURLCodebase) { + return URLClassLoader.newInstance(getUrlArray(url), parent); + } else { + return parent; + } + } + Class loadClass(String className) throws ClassNotFoundException { + return Class.forName(className, true, getContextClassLoader()); + } - static protected URL[] getUrlArray(String[] url) throws MalformedURLException { + Thread createThread(Runnable r) { + AccessControlContext acc = AccessController.getContext(); + // 4290486: doPrivileged is needed to create a thread in + // an environment that restricts "modifyThreadGroup". + PrivilegedAction act = + () -> SharedSecrets.getJavaLangAccess().newThreadWithAcc(r, acc); + return AccessController.doPrivileged(act); + } + + private ClassLoader getContextClassLoader() { + PrivilegedAction act = + Thread.currentThread()::getContextClassLoader; + return AccessController.doPrivileged(act); + } + + private static URL[] getUrlArray(String[] url) throws MalformedURLException { URL[] urlArray = new URL[url.length]; for (int i = 0; i < urlArray.length; i++) { urlArray[i] = new URL(url[i]); } return urlArray; } - - abstract Class loadClass(String className) throws ClassNotFoundException; - - abstract Thread createThread(Runnable r); } diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java b/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java deleted file mode 100644 index 468273ede97..00000000000 --- a/jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 com.sun.jndi.ldap; - -import java.net.URLClassLoader; -import java.net.MalformedURLException; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import sun.misc.SharedSecrets; - -final class VersionHelper12 extends VersionHelper { - - // System property to control whether classes may be loaded from an - // arbitrary URL code base. - private static final String TRUST_URL_CODEBASE_PROPERTY = - "com.sun.jndi.ldap.object.trustURLCodebase"; - - // Determine whether classes may be loaded from an arbitrary URL code base. - private static final String trustURLCodebase = - AccessController.doPrivileged( - new PrivilegedAction() { - public String run() { - return System.getProperty(TRUST_URL_CODEBASE_PROPERTY, - "false"); - } - } - ); - - VersionHelper12() {} // Disallow external from creating one of these. - - ClassLoader getURLClassLoader(String[] url) - throws MalformedURLException { - ClassLoader parent = getContextClassLoader(); - /* - * Classes may only be loaded from an arbitrary URL code base when - * the system property com.sun.jndi.ldap.object.trustURLCodebase - * has been set to "true". - */ - if (url != null && "true".equalsIgnoreCase(trustURLCodebase)) { - return URLClassLoader.newInstance(getUrlArray(url), parent); - } else { - return parent; - } - } - - Class loadClass(String className) throws ClassNotFoundException { - ClassLoader cl = getContextClassLoader(); - return Class.forName(className, true, cl); - } - - private ClassLoader getContextClassLoader() { - return AccessController.doPrivileged( - new PrivilegedAction() { - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - } - ); - } - - Thread createThread(final Runnable r) { - final AccessControlContext acc = AccessController.getContext(); - // 4290486: doPrivileged is needed to create a thread in - // an environment that restricts "modifyThreadGroup". - return AccessController.doPrivileged( - new PrivilegedAction() { - public Thread run() { - return SharedSecrets.getJavaLangAccess() - .newThreadWithAcc(r, acc); - } - } - ); - } -} diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/pool/Connections.java b/jdk/src/share/classes/com/sun/jndi/ldap/pool/Connections.java index 2df13459570..0e3e1094d67 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/pool/Connections.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/pool/Connections.java @@ -254,7 +254,7 @@ final class Connections implements PoolCallback { /** * Removes PooledConnection from list of connections. * The closing of the connection is separate from this method. - * This method is called usually when the caller encouters an error + * This method is called usually when the caller encounters an error * when using the connection and wants it removed from the pool. * * @return true if conn removed; false if it was not in pool diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/pool/Pool.java b/jdk/src/share/classes/com/sun/jndi/ldap/pool/Pool.java index f9786cad213..723f11a8783 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/pool/Pool.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/pool/Pool.java @@ -68,8 +68,8 @@ import javax.naming.NamingException; * whenever a pooled connection is requested or a call to remove the expired * connections is made. The monitoring is done regularly when idle connection * timeout is set as the PoolCleaner removes expired connections periodically. - * As determined by the experiements, cleanup of resources using the - * ReferenceQueue mechanism is reliable and has immidiate effect than the + * As determined by experimentation, cleanup of resources using the + * ReferenceQueue mechanism is reliable and has more immediate effect than the * finalizer approach. * * @author Rosanna Lee diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java b/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java index d1ea853a9b4..3802f5f106c 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java @@ -55,7 +55,6 @@ public class CorbaUtils { * Returns the CORBA object reference associated with a Remote * object by using the javax.rmi.CORBA package. *

    - * Use reflection to avoid hard dependencies on javax.rmi.CORBA package. * This method effective does the following: *

           * java.lang.Object stub;
    @@ -166,6 +165,7 @@ public class CorbaUtils {
     
             // Get Applet from environment
             if (env != null) {
    +            @SuppressWarnings("deprecation")
                 Applet applet = (Applet) env.get(Context.APPLET);
                 if (applet != null) {
                 // Create ORBs using applet and orbProp
    diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java
    index f8f41d598f9..606f38005cf 100644
    --- a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java
    +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java
    @@ -96,7 +96,7 @@ public abstract class AtomicContext extends ComponentContext {
           * Resolves the nns for 'name' when the named context is acting
           * as an intermediate context.
           *
    -      * For a system that supports junctions, this would be equilvalent to
    +      * For a system that supports junctions, this would be equivalent to
           *         a_lookup(name, cont);
           * because for junctions, an intermediate slash simply signifies
           * a syntactic separator.
    @@ -487,7 +487,7 @@ public abstract class AtomicContext extends ComponentContext {
                     resolve_to_nns_and_continue(name, cont);
                     return null;
                 } else {
    -                // use COmponentContext
    +                // use ComponentContext
                     return super.c_getNameParser_nns(name, cont);
                 }
             }
    diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/ComponentContext.java b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/ComponentContext.java
    index 351d6d7d0f7..24e65fa104a 100644
    --- a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/ComponentContext.java
    +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/ComponentContext.java
    @@ -137,7 +137,7 @@ public abstract class ComponentContext extends PartialCompositeContext {
           * as an intermediate context.
           *
           * For a system that supports only junctions, this would be
    -      * equilvalent to
    +      * equivalent to
           *         c_lookup(name, cont);
           * because for junctions, an intermediate slash simply signifies
           * a syntactic separator.
    diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java
    index 6c09f935f97..44bc245bad4 100644
    --- a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java
    +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java
    @@ -172,7 +172,7 @@ public class Continuation extends ResolveResult {
          *
          * This method is typically called by _nns methods that have been
          * given a name to process. It might process part of that name but
    -     * encountered some error. Consequenetly, it would call setErrorNNS()
    +     * encountered some error. Consequently, it would call setErrorNNS()
          * with the remaining name. Since the _nns method was expected to
          * operate upon the "nns" of the original name, the remaining name
          * must include the "nns". That's why this method adds a trailing "/".
    @@ -219,7 +219,7 @@ public class Continuation extends ResolveResult {
          *
          * This method is typically called by methods that have been
          * given a name to process. It might process part of that name but
    -     * encountered some error. Consequenetly, it would call setError()
    +     * encountered some error. Consequently, it would call setError()
          * with the resolved object and the remaining name.
          *

    * After this method is called, isContinuing() returns false. diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/ContextEnumerator.java b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/ContextEnumerator.java index cafd047b144..176e3392b02 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/ContextEnumerator.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/ContextEnumerator.java @@ -182,14 +182,14 @@ public class ContextEnumerator implements NamingEnumeration { if (!currentReturned) { // returning parent - if(debug) {System.out.println("getNextDescedant: simple case");} + if(debug) {System.out.println("getNextDescendant: simple case");} currentReturned = true; return currentChild; } else if (currentChildExpanded && currentChildEnum.hasMore()) { - if(debug) {System.out.println("getNextDescedant: expanded case");} + if(debug) {System.out.println("getNextDescendant: expanded case");} // if the current child is expanded, use it's enumerator return currentChildEnum.next(); @@ -197,7 +197,7 @@ public class ContextEnumerator implements NamingEnumeration { } else { // Ready to go onto next child - if(debug) {System.out.println("getNextDescedant: next case");} + if(debug) {System.out.println("getNextDescendant: next case");} prepNextChild(); return getNextDescendant(); diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java index e10ee2aec41..35895db2395 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java @@ -881,8 +881,8 @@ public class HierMemDirCtx implements DirContext { } } - // CompundNames's HashCode() method isn't good enough for many string. - // The only prupose of this subclass is to have a more discerning + // CompoundNames's HashCode() method isn't good enough for many strings. + // The only purpose of this subclass is to have a more discerning // hash function. We'll make up for the performance hit by caching // the hash value. diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java index b6efbedfa4b..8871e0f051c 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java @@ -152,7 +152,7 @@ final public class LazySearchEnumerationImpl } else if (useFactory) { try { // Give name only if context non-null, - // otherewise, name will be interpreted relative + // otherwise, name will be interpreted relative // to initial context (not what we want) Name nm = (context != null ? new CompositeName(next.getName()) : null); diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java index cf23c3dd2e4..695238309f3 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java @@ -256,7 +256,7 @@ public class SearchFilter implements AttrFilter { static final int LESS_MATCH = 4; /** - * A class for dealing wtih atomic filters + * A class for dealing with atomic filters */ final class AtomicFilter implements StringFilter { private String attrID; @@ -369,7 +369,7 @@ public class SearchFilter implements AttrFilter { } break; default: - if (debug) {System.out.println("AtomicFilter: unkown " + + if (debug) {System.out.println("AtomicFilter: unknown " + "matchType");} } } @@ -434,7 +434,7 @@ public class SearchFilter implements AttrFilter { /** - * Creates an LDAP filter as a conjuction of the attributes supplied. + * Creates an LDAP filter as a conjunction of the attributes supplied. */ public static String format(Attributes attrs) throws NamingException { if (attrs == null || attrs.size() == 0) { diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java b/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java index cb5255d0a7b..8493330135b 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java @@ -168,7 +168,7 @@ abstract public class GenericURLContext implements Context { } } - // else 0 or 1 iniitial slashes; start is unchanged + // else 0 or 1 initial slashes; start is unchanged return url.substring(0, start); } diff --git a/jdk/src/share/classes/com/sun/jndi/url/ldap/ldapURLContext.java b/jdk/src/share/classes/com/sun/jndi/url/ldap/ldapURLContext.java index 6143363284a..af88b606e21 100644 --- a/jdk/src/share/classes/com/sun/jndi/url/ldap/ldapURLContext.java +++ b/jdk/src/share/classes/com/sun/jndi/url/ldap/ldapURLContext.java @@ -562,7 +562,7 @@ final public class ldapURLContext } // Search using the LDAP URL in name. - // LDAP URL query components override the search argments. + // LDAP URL query components override the search arguments. private NamingEnumeration searchUsingURL(String name) throws NamingException { diff --git a/jdk/src/share/classes/com/sun/management/GcInfo.java b/jdk/src/share/classes/com/sun/management/GcInfo.java index 0a7eda76a51..7257b6c6f62 100644 --- a/jdk/src/share/classes/com/sun/management/GcInfo.java +++ b/jdk/src/share/classes/com/sun/management/GcInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -267,7 +267,7 @@ public class GcInfo implements CompositeData, CompositeDataView { return cdata.toString(); } - public Collection values() { + public Collection values() { return cdata.values(); } diff --git a/jdk/src/share/classes/com/sun/naming/internal/ResourceManager.java b/jdk/src/share/classes/com/sun/naming/internal/ResourceManager.java index a735b4342ee..09be7ca7cd1 100644 --- a/jdk/src/share/classes/com/sun/naming/internal/ResourceManager.java +++ b/jdk/src/share/classes/com/sun/naming/internal/ResourceManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,6 @@ package com.sun.naming.internal; import java.io.InputStream; import java.io.IOException; import java.lang.ref.WeakReference; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; @@ -126,52 +124,6 @@ public final class ResourceManager { private static final WeakReference NO_FACTORY = new WeakReference<>(null); - /** - * A class to allow JNDI properties be specified as applet parameters - * without creating a static dependency on java.applet. - */ - private static class AppletParameter { - private static final Class clazz = getClass("java.applet.Applet"); - private static final Method getMethod = - getMethod(clazz, "getParameter", String.class); - private static Class getClass(String name) { - try { - return Class.forName(name, true, null); - } catch (ClassNotFoundException e) { - return null; - } - } - private static Method getMethod(Class clazz, - String name, - Class... paramTypes) - { - if (clazz != null) { - try { - return clazz.getMethod(name, paramTypes); - } catch (NoSuchMethodException e) { - throw new AssertionError(e); - } - } else { - return null; - } - } - - /** - * Returns the value of the applet's named parameter. - */ - static Object get(Object applet, String name) { - // if clazz is null then applet cannot be an Applet. - if (clazz == null || !clazz.isInstance(applet)) - throw new ClassCastException(applet.getClass().getName()); - try { - return getMethod.invoke(applet, name); - } catch (InvocationTargetException | - IllegalAccessException e) { - throw new AssertionError(e); - } - } - } - // There should be no instances of this class. private ResourceManager() { } @@ -179,12 +131,11 @@ public final class ResourceManager { // ---------- Public methods ---------- - /* + /** * Given the environment parameter passed to the initial context * constructor, returns the full environment for that initial * context (never null). This is based on the environment - * parameter, the applet parameters (where appropriate), the - * system properties, and all application resource files. + * parameter, the system properties, and all application resource files. * *

    This method will modify env and save * a reference to it. The caller may no longer modify it. @@ -196,18 +147,16 @@ public final class ResourceManager { * resource file */ @SuppressWarnings("unchecked") - public static Hashtable getInitialEnvironment( - Hashtable env) + public static Hashtable getInitialEnvironment(Hashtable env) throws NamingException { - String[] props = VersionHelper.PROPS; // system/applet properties + String[] props = VersionHelper.PROPS; // system properties if (env == null) { env = new Hashtable<>(11); } - Object applet = env.get(Context.APPLET); - // Merge property values from env param, applet params, and system - // properties. The first value wins: there's no concatenation of + // Merge property values from env param, and system properties. + // The first value wins: there's no concatenation of // colon-separated lists. // Read system properties by first trying System.getProperties(), // and then trying System.getProperty() if that fails. The former @@ -217,18 +166,13 @@ public final class ResourceManager { for (int i = 0; i < props.length; i++) { Object val = env.get(props[i]); if (val == null) { - if (applet != null) { - val = AppletParameter.get(applet, props[i]); - } - if (val == null) { - // Read system property. - val = (jndiSysProps != null) + // Read system property. + val = (jndiSysProps != null) ? jndiSysProps[i] : helper.getJndiProperty(i); - } - if (val != null) { - ((Hashtable)env).put(props[i], val); - } + } + if (val != null) { + ((Hashtable)env).put(props[i], val); } } @@ -248,8 +192,8 @@ public final class ResourceManager { /** * Retrieves the property from the environment, or from the provider * resource file associated with the given context. The environment - * may in turn contain values that come from applet parameters, - * system properties, or application resource files. + * may in turn contain values that come from system properties, + * or application resource files. * * If concat is true and both the environment and the provider * resource file contain the property, the two values are concatenated @@ -289,7 +233,7 @@ public final class ResourceManager { * property. * * The property is gotten from the environment and the provider - * resource file associated with the given context and concantenated. + * resource file associated with the given context and concatenated. * See getProperty(). The resulting property value is a list of class names. *

    * This method then loads each class using the current thread's context diff --git a/jdk/src/share/classes/com/sun/naming/internal/VersionHelper.java b/jdk/src/share/classes/com/sun/naming/internal/VersionHelper.java index 63590be93aa..2a9db220af0 100644 --- a/jdk/src/share/classes/com/sun/naming/internal/VersionHelper.java +++ b/jdk/src/share/classes/com/sun/naming/internal/VersionHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,19 @@ package com.sun.naming.internal; -import java.io.InputStream; +import javax.naming.NamingEnumeration; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import java.util.StringTokenizer; -import java.util.Vector; - -import javax.naming.NamingEnumeration; +import java.net.URLClassLoader; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.*; /** * VersionHelper was used by JNDI to accommodate differences between @@ -45,10 +50,10 @@ import javax.naming.NamingEnumeration; * @author Scott Seligman */ -public abstract class VersionHelper { - private static VersionHelper helper = null; +public final class VersionHelper { + private static final VersionHelper helper = new VersionHelper(); - final static String[] PROPS = new String[] { + final static String[] PROPS = new String[]{ javax.naming.Context.INITIAL_CONTEXT_FACTORY, javax.naming.Context.OBJECT_FACTORIES, javax.naming.Context.URL_PKG_PREFIXES, @@ -67,31 +72,57 @@ public abstract class VersionHelper { public final static int DNS_URL = 5; public final static int CONTROL_FACTORIES = 6; - VersionHelper() {} // Disallow anyone from creating one of these. - - static { - helper = new VersionHelper12(); - } + private VersionHelper() {} // Disallow anyone from creating one of these. public static VersionHelper getVersionHelper() { return helper; } - public abstract Class loadClass(String className) - throws ClassNotFoundException; + public Class loadClass(String className) throws ClassNotFoundException { + return loadClass(className, getContextClassLoader()); + } - abstract Class loadClass(String className, ClassLoader cl) - throws ClassNotFoundException; + /** + * @param className A non-null fully qualified class name. + * @param codebase A non-null, space-separated list of URL strings. + */ + public Class loadClass(String className, String codebase) + throws ClassNotFoundException, MalformedURLException { - public abstract Class loadClass(String className, String codebase) - throws ClassNotFoundException, MalformedURLException; + ClassLoader parent = getContextClassLoader(); + ClassLoader cl = + URLClassLoader.newInstance(getUrlArray(codebase), parent); + + return loadClass(className, cl); + } + + /** + * Package private. + *

    + * This internal method is used with Thread Context Class Loader (TCCL), + * please don't expose this method as public. + */ + Class loadClass(String className, ClassLoader cl) + throws ClassNotFoundException { + Class cls = Class.forName(className, true, cl); + return cls; + } /* - * Returns a JNDI property from the system properties. Returns + * Returns a JNDI property from the system properties. Returns * null if the property is not set, or if there is no permission * to read it. */ - abstract String getJndiProperty(int i); + String getJndiProperty(int i) { + PrivilegedAction act = () -> { + try { + return System.getProperty(PROPS[i]); + } catch (SecurityException e) { + return null; + } + }; + return AccessController.doPrivileged(act); + } /* * Reads each property in PROPS from the system properties, and @@ -99,13 +130,33 @@ public abstract class VersionHelper { * unset property, the corresponding array element is set to null. * Returns null if there is no permission to call System.getProperties(). */ - abstract String[] getJndiProperties(); + String[] getJndiProperties() { + PrivilegedAction act = () -> { + try { + return System.getProperties(); + } catch (SecurityException e) { + return null; + } + }; + Properties sysProps = AccessController.doPrivileged(act); + if (sysProps == null) { + return null; + } + String[] jProps = new String[PROPS.length]; + for (int i = 0; i < PROPS.length; i++) { + jProps[i] = sysProps.getProperty(PROPS[i]); + } + return jProps; + } /* * Returns the resource of a given name associated with a particular * class (never null), or null if none can be found. */ - abstract InputStream getResourceAsStream(Class c, String name); + InputStream getResourceAsStream(Class c, String name) { + PrivilegedAction act = () -> c.getResourceAsStream(name); + return AccessController.doPrivileged(act); + } /* * Returns an input stream for a file in /lib, @@ -113,7 +164,22 @@ public abstract class VersionHelper { * * @param filename The file name, sans directory. */ - abstract InputStream getJavaHomeLibStream(String filename); + InputStream getJavaHomeLibStream(String filename) { + PrivilegedAction act = () -> { + try { + String javahome = System.getProperty("java.home"); + if (javahome == null) { + return null; + } + String pathname = javahome + File.separator + + "lib" + File.separator + filename; + return new FileInputStream(pathname); + } catch (Exception e) { + return null; + } + }; + return AccessController.doPrivileged(act); + } /* * Returns an enumeration (never null) of InputStreams of the @@ -121,29 +187,55 @@ public abstract class VersionHelper { * loader. Null represents the bootstrap class loader in some * Java implementations. */ - abstract NamingEnumeration getResources( - ClassLoader cl, String name) - throws IOException; + NamingEnumeration getResources(ClassLoader cl, + String name) throws IOException { + Enumeration urls; + PrivilegedExceptionAction> act = () -> + (cl == null) + ? ClassLoader.getSystemResources(name) + : cl.getResources(name); + try { + urls = AccessController.doPrivileged(act); + } catch (PrivilegedActionException e) { + throw (IOException) e.getException(); + } + return new InputStreamEnumeration(urls); + } - /* - * Returns the context class loader associated with the current thread. - * Null indicates the bootstrap class loader in some Java implementations. - * - * @throws SecurityException if the class loader is not accessible. + + /** + * Package private. + *

    + * This internal method returns Thread Context Class Loader (TCCL), + * if null, returns the system Class Loader. + *

    + * Please don't expose this method as public. + * @throws SecurityException if the class loader is not accessible */ - abstract ClassLoader getContextClassLoader(); + ClassLoader getContextClassLoader() { - static protected URL[] getUrlArray(String codebase) - throws MalformedURLException { + PrivilegedAction act = () -> { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + if (loader == null) { + // Don't use bootstrap class loader directly! + loader = ClassLoader.getSystemClassLoader(); + } + return loader; + }; + return AccessController.doPrivileged(act); + } + + private static URL[] getUrlArray(String codebase) + throws MalformedURLException { // Parse codebase into separate URLs StringTokenizer parser = new StringTokenizer(codebase); - Vector vec = new Vector<>(10); + List list = new ArrayList<>(); while (parser.hasMoreTokens()) { - vec.addElement(parser.nextToken()); + list.add(parser.nextToken()); } - String[] url = new String[vec.size()]; + String[] url = new String[list.size()]; for (int i = 0; i < url.length; i++) { - url[i] = vec.elementAt(i); + url[i] = list.get(i); } URL[] urlArray = new URL[url.length]; @@ -152,4 +244,70 @@ public abstract class VersionHelper { } return urlArray; } + + /** + * Given an enumeration of URLs, an instance of this class represents + * an enumeration of their InputStreams. Each operation on the URL + * enumeration is performed within a doPrivileged block. + * This is used to enumerate the resources under a foreign codebase. + * This class is not MT-safe. + */ + private class InputStreamEnumeration implements + NamingEnumeration { + + private final Enumeration urls; + + private InputStream nextElement; + + InputStreamEnumeration(Enumeration urls) { + this.urls = urls; + } + + /* + * Returns the next InputStream, or null if there are no more. + * An InputStream that cannot be opened is skipped. + */ + private InputStream getNextElement() { + PrivilegedAction act = () -> { + while (urls.hasMoreElements()) { + try { + return urls.nextElement().openStream(); + } catch (IOException e) { + // skip this URL + } + } + return null; + }; + return AccessController.doPrivileged(act); + } + + public boolean hasMore() { + if (nextElement != null) { + return true; + } + nextElement = getNextElement(); + return (nextElement != null); + } + + public boolean hasMoreElements() { + return hasMore(); + } + + public InputStream next() { + if (hasMore()) { + InputStream res = nextElement; + nextElement = null; + return res; + } else { + throw new NoSuchElementException(); + } + } + + public InputStream nextElement() { + return next(); + } + + public void close() { + } + } } diff --git a/jdk/src/share/classes/com/sun/naming/internal/VersionHelper12.java b/jdk/src/share/classes/com/sun/naming/internal/VersionHelper12.java deleted file mode 100644 index bf4586e7ebc..00000000000 --- a/jdk/src/share/classes/com/sun/naming/internal/VersionHelper12.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 com.sun.naming.internal; - -import java.io.InputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URLClassLoader; -import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.Enumeration; -import java.util.NoSuchElementException; -import java.util.Properties; - -import javax.naming.*; - -/** - * VersionHelper was used by JNDI to accommodate differences between - * JDK 1.1.x and the Java 2 platform. As this is no longer necessary - * since JNDI's inclusion in the platform, this class currently - * serves as a set of utilities for performing system-level things, - * such as class-loading and reading system properties. - * - * @author Rosanna Lee - * @author Scott Seligman - */ - -final class VersionHelper12 extends VersionHelper { - - // Disallow external from creating one of these. - VersionHelper12() { - } - - public Class loadClass(String className) throws ClassNotFoundException { - return loadClass(className, getContextClassLoader()); - } - - /** - * Package private. - * - * This internal method is used with Thread Context Class Loader (TCCL), - * please don't expose this method as public. - */ - Class loadClass(String className, ClassLoader cl) - throws ClassNotFoundException { - Class cls = Class.forName(className, true, cl); - return cls; - } - - /** - * @param className A non-null fully qualified class name. - * @param codebase A non-null, space-separated list of URL strings. - */ - public Class loadClass(String className, String codebase) - throws ClassNotFoundException, MalformedURLException { - - ClassLoader parent = getContextClassLoader(); - ClassLoader cl = - URLClassLoader.newInstance(getUrlArray(codebase), parent); - - return loadClass(className, cl); - } - - String getJndiProperty(final int i) { - return AccessController.doPrivileged( - new PrivilegedAction() { - public String run() { - try { - return System.getProperty(PROPS[i]); - } catch (SecurityException e) { - return null; - } - } - } - ); - } - - String[] getJndiProperties() { - Properties sysProps = AccessController.doPrivileged( - new PrivilegedAction() { - public Properties run() { - try { - return System.getProperties(); - } catch (SecurityException e) { - return null; - } - } - } - ); - if (sysProps == null) { - return null; - } - String[] jProps = new String[PROPS.length]; - for (int i = 0; i < PROPS.length; i++) { - jProps[i] = sysProps.getProperty(PROPS[i]); - } - return jProps; - } - - InputStream getResourceAsStream(final Class c, final String name) { - return AccessController.doPrivileged( - new PrivilegedAction() { - public InputStream run() { - return c.getResourceAsStream(name); - } - } - ); - } - - InputStream getJavaHomeLibStream(final String filename) { - return AccessController.doPrivileged( - new PrivilegedAction() { - public InputStream run() { - try { - String javahome = System.getProperty("java.home"); - if (javahome == null) { - return null; - } - String pathname = javahome + java.io.File.separator + - "lib" + java.io.File.separator + filename; - return new java.io.FileInputStream(pathname); - } catch (Exception e) { - return null; - } - } - } - ); - } - - NamingEnumeration getResources(final ClassLoader cl, - final String name) throws IOException { - Enumeration urls; - try { - urls = AccessController.doPrivileged( - new PrivilegedExceptionAction>() { - public Enumeration run() throws IOException { - return (cl == null) - ? ClassLoader.getSystemResources(name) - : cl.getResources(name); - } - } - ); - } catch (PrivilegedActionException e) { - throw (IOException)e.getException(); - } - return new InputStreamEnumeration(urls); - } - - /** - * Package private. - * - * This internal method returns Thread Context Class Loader (TCCL), - * if null, returns the system Class Loader. - * - * Please don't expose this method as public. - */ - ClassLoader getContextClassLoader() { - - return AccessController.doPrivileged( - new PrivilegedAction() { - public ClassLoader run() { - ClassLoader loader = - Thread.currentThread().getContextClassLoader(); - if (loader == null) { - // Don't use bootstrap class loader directly! - loader = ClassLoader.getSystemClassLoader(); - } - - return loader; - } - } - ); - } - - /** - * Given an enumeration of URLs, an instance of this class represents - * an enumeration of their InputStreams. Each operation on the URL - * enumeration is performed within a doPrivileged block. - * This is used to enumerate the resources under a foreign codebase. - * This class is not MT-safe. - */ - class InputStreamEnumeration implements NamingEnumeration { - - private final Enumeration urls; - - private InputStream nextElement = null; - - InputStreamEnumeration(Enumeration urls) { - this.urls = urls; - } - - /* - * Returns the next InputStream, or null if there are no more. - * An InputStream that cannot be opened is skipped. - */ - private InputStream getNextElement() { - return AccessController.doPrivileged( - new PrivilegedAction() { - public InputStream run() { - while (urls.hasMoreElements()) { - try { - return urls.nextElement().openStream(); - } catch (IOException e) { - // skip this URL - } - } - return null; - } - } - ); - } - - public boolean hasMore() { - if (nextElement != null) { - return true; - } - nextElement = getNextElement(); - return (nextElement != null); - } - - public boolean hasMoreElements() { - return hasMore(); - } - - public InputStream next() { - if (hasMore()) { - InputStream res = nextElement; - nextElement = null; - return res; - } else { - throw new NoSuchElementException(); - } - } - - public InputStream nextElement() { - return next(); - } - - public void close() { - } - } -} diff --git a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java index 8539a266ee5..12ee20b126b 100644 --- a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java +++ b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java @@ -33,7 +33,10 @@ import java.text.MessageFormat; import java.util.*; import javax.security.auth.*; -import javax.security.auth.kerberos.*; +import javax.security.auth.kerberos.KerberosTicket; +import javax.security.auth.kerberos.KerberosPrincipal; +import javax.security.auth.kerberos.KerberosKey; +import javax.security.auth.kerberos.KeyTab; import javax.security.auth.callback.*; import javax.security.auth.login.*; import javax.security.auth.spi.*; diff --git a/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java b/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java index 2733c7b08f8..0f3a27dfac9 100644 --- a/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java +++ b/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java @@ -36,33 +36,7 @@ import org.ietf.jgss.*; public interface ExtendedGSSContext extends GSSContext { /** * Return the mechanism-specific attribute associated with {@code type}. - *

    - * For each supported attribute type, the type for the output are - * defined below. - *

      - *
    1. {@code KRB5_GET_TKT_FLAGS}: - * the returned object is a boolean array for the service ticket flags, - * which is long enough to contain all true bits. This means if - * the user wants to get the n'th bit but the length of the - * returned array is less than n, it is regarded as false. - *
    2. {@code KRB5_GET_SESSION_KEY}: - * the returned object is an instance of {@link java.security.Key}, - * which has the following properties: - *
        - *
      • Algorithm: enctype as a string, where - * enctype is defined in RFC 3961, section 8. - *
      • Format: "RAW" - *
      • Encoded form: the raw key bytes, not in any ASN.1 encoding - *
      - *
    3. {@code KRB5_GET_AUTHZ_DATA}: - * the returned object is an array of - * {@link com.sun.security.jgss.AuthorizationDataEntry}, or null if the - * optional field is missing in the service ticket. - *
    4. {@code KRB5_GET_AUTHTIME}: - * the returned object is a String object in the standard KerberosTime - * format defined in RFC 4120 5.2.3 - *
    - * + *

    * If there is a security manager, an {@link InquireSecContextPermission} * with the name {@code type.mech} must be granted. Otherwise, this could * result in a {@link SecurityException}.

    @@ -97,6 +71,7 @@ public interface ExtendedGSSContext extends GSSContext { * @throws SecurityException if a security manager exists and a proper * {@link InquireSecContextPermission} is not granted. * @see InquireSecContextPermission + * @see InquireType */ public Object inquireSecContext(InquireType type) throws GSSException; diff --git a/jdk/src/share/classes/com/sun/security/jgss/InquireType.java b/jdk/src/share/classes/com/sun/security/jgss/InquireType.java index 9dfc83abf7c..440a85c178f 100644 --- a/jdk/src/share/classes/com/sun/security/jgss/InquireType.java +++ b/jdk/src/share/classes/com/sun/security/jgss/InquireType.java @@ -32,13 +32,38 @@ package com.sun.security.jgss; @jdk.Exported public enum InquireType { /** - * Attribute type for retrieving the session key of an - * established Kerberos 5 security context. + * Attribute type for retrieving the session key of an established + * Kerberos 5 security context. The returned object is an instance of + * {@link java.security.Key}, which has the following properties: + *

      + *
    • Algorithm: enctype as a string, where + * enctype is defined in RFC 3961, section 8. + *
    • Format: "RAW" + *
    • Encoded form: the raw key bytes, not in any ASN.1 encoding + *
    + * @deprecated as of 1.9, replaced by {@link #KRB5_GET_SESSION_KEY_EX} + * which returns an instance of + * {@link sun.security.jgss.krb5.Krb5Context.EncryptionKey} + * that implements the {@link javax.crypto.SecretKey} interface and + * has similar methods with {@link javax.security.auth.kerberos.KerberosKey}. */ + @Deprecated KRB5_GET_SESSION_KEY, + /** + * Attribute type for retrieving the session key of an + * established Kerberos 5 security context. The return value is an + * instance of {@link javax.security.auth.kerberos.EncryptionKey}. + * + * @since 1.9 + */ + KRB5_GET_SESSION_KEY_EX, /** * Attribute type for retrieving the service ticket flags of an - * established Kerberos 5 security context. + * established Kerberos 5 security context. The returned object is + * a boolean array for the service ticket flags, which is long enough + * to contain all true bits. This means if the user wants to get the + * n'th bit but the length of the returned array is less than + * n, it is regarded as false. */ KRB5_GET_TKT_FLAGS, /** @@ -49,7 +74,17 @@ public enum InquireType { KRB5_GET_AUTHZ_DATA, /** * Attribute type for retrieving the authtime in the service ticket - * of an established Kerberos 5 security context. + * of an established Kerberos 5 security context. The returned object + * is a String object in the standard KerberosTime format defined in + * RFC 4120 Section 5.2.3. */ - KRB5_GET_AUTHTIME + KRB5_GET_AUTHTIME, + /** + * Attribute type for retrieving the KRB_CRED message that an initiator + * is about to send to an acceptor. The return type is an instance of + * {@link javax.security.auth.kerberos.KerberosCredMessage}. + * + * @since 1.9 + */ + KRB5_GET_KRB_CRED, } diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java b/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java index 5f0c12086d6..4005adc4262 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/expr/ExpressionParser.java @@ -33,18 +33,18 @@ import java.util.ArrayList; public class ExpressionParser implements ExpressionParserConstants { - Stack stack = new Stack(); + Stack stack = new Stack<>(); VirtualMachine vm = null; GetFrame frameGetter = null; private static GetFrame lastFrameGetter; private static LValue lastLValue; LValue peek() { - return (LValue)stack.peek(); + return stack.peek(); } LValue pop() { - return (LValue)stack.pop(); + return stack.pop(); } void push(LValue lval) { @@ -915,7 +915,7 @@ public class ExpressionParser implements ExpressionParserConstants { } final public void PrimarySuffix() throws ParseException { - List argList; + List argList; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: jj_consume_token(LBRACKET); @@ -993,8 +993,8 @@ public class ExpressionParser implements ExpressionParserConstants { jj_consume_token(NULL); } - final public List Arguments() throws ParseException { - List argList = new ArrayList(); + final public List Arguments() throws ParseException { + List argList = new ArrayList<>(); jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FALSE: @@ -1026,7 +1026,7 @@ public class ExpressionParser implements ExpressionParserConstants { throw new Error("Missing return statement in function"); } - final public void ArgumentList(List argList) throws ParseException { + final public void ArgumentList(List argList) throws ParseException { Expression(); argList.add(pop().interiorGetValue()); label_17: @@ -1046,7 +1046,7 @@ public class ExpressionParser implements ExpressionParserConstants { } final public void AllocationExpression() throws ParseException { - List argList; String className; + List argList; String className; if (jj_2_7(2)) { jj_consume_token(NEW); PrimitiveType(); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaClass.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaClass.java index e7a59b3a4d6..3ad56be2d2c 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaClass.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -229,9 +229,9 @@ public class JavaClass extends JavaHeapObject { return name.indexOf('[') != -1; } - public Enumeration getInstances(boolean includeSubclasses) { + public Enumeration getInstances(boolean includeSubclasses) { if (includeSubclasses) { - Enumeration res = instances.elements(); + Enumeration res = instances.elements(); for (int i = 0; i < subclasses.length; i++) { res = new CompositeEnumeration(res, subclasses[i].getInstances(true)); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaHeapObject.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaHeapObject.java index 508e0c0d4a3..471a77b595b 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaHeapObject.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaHeapObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -166,11 +166,11 @@ public abstract class JavaHeapObject extends JavaThing { * * @return an Enumeration of JavaHeapObject instances */ - public Enumeration getReferers() { + public Enumeration getReferers() { if (referersLen != -1) { throw new RuntimeException("not resolved: " + getIdString()); } - return new Enumeration() { + return new Enumeration() { private int num = 0; @@ -178,7 +178,7 @@ public abstract class JavaHeapObject extends JavaThing { return referers != null && num < referers.length; } - public Object nextElement() { + public JavaThing nextElement() { return referers[num++]; } }; diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableExcludesImpl.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableExcludesImpl.java index 46978cfaf90..c20d54b7392 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableExcludesImpl.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableExcludesImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public class ReachableExcludesImpl implements ReachableExcludes { private File excludesFile; private long lastModified; - private Hashtable methods; // Hashtable, used as a bag + private Hashtable methods; // Used as a bag /** * Create a new ReachableExcludesImpl over the given file. The file will be diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableObjects.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableObjects.java index 831e8245873..43f4c03aa91 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableObjects.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/ReachableObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,7 +86,7 @@ public class ReachableObjects { // Now grab the elements into a vector, and sort it in decreasing size JavaThing[] things = new JavaThing[bag.size()]; int i = 0; - for (Enumeration e = bag.elements(); e.hasMoreElements(); ) { + for (Enumeration e = bag.elements(); e.hasMoreElements(); ) { things[i++] = (JavaThing) e.nextElement(); } ArraySorter.sort(things, new Comparer() { @@ -131,7 +131,7 @@ public class ReachableObjects { return usedFields; } - private String[] getElements(Hashtable ht) { + private String[] getElements(Hashtable ht) { Object[] keys = ht.keySet().toArray(); int len = keys.length; String[] res = new String[len]; diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java b/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java index 9c00ce05e18..77613c08e41 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,7 @@ public class Snapshot { new HashMap(); // soft cache of finalizeable objects - lazily initialized - private SoftReference finalizablesCache; + private SoftReference> finalizablesCache; // represents null reference private JavaThing nullThing; @@ -383,7 +383,7 @@ public class Snapshot { /** * Return an Iterator of all of the classes in this snapshot. **/ - public Iterator getClasses() { + public Iterator getClasses() { // note that because classes is a TreeMap // classes are already sorted by name return classes.values().iterator(); @@ -395,8 +395,8 @@ public class Snapshot { return res; } - public synchronized Enumeration getFinalizerObjects() { - Vector obj; + public synchronized Enumeration getFinalizerObjects() { + Vector obj; if (finalizablesCache != null && (obj = finalizablesCache.get()) != null) { return obj.elements(); @@ -418,7 +418,7 @@ public class Snapshot { finalizables.add(referent); } } - finalizablesCache = new SoftReference(finalizables); + finalizablesCache = new SoftReference>(finalizables); return finalizables.elements(); } @@ -455,7 +455,7 @@ public class Snapshot { // Even though curr is in the rootset, we want to explore its // referers, because they might be more interesting. } - Enumeration referers = curr.getReferers(); + Enumeration referers = curr.getReferers(); while (referers.hasMoreElements()) { JavaHeapObject t = (JavaHeapObject) referers.nextElement(); if (t != null && !visited.containsKey(t)) { diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/oql/OQLEngine.java b/jdk/src/share/classes/com/sun/tools/hat/internal/oql/OQLEngine.java index c69335d9798..c393b445ec6 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/oql/OQLEngine.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/oql/OQLEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public class OQLEngine { // create JavaScript engine Method getEngineMethod = managerClass.getMethod("getEngineByName", - new Class[] { String.class }); + new Class[] { String.class }); Object jse = getEngineMethod.invoke(manager, new Object[] {"js"}); oqlSupported = (jse != null); } catch (Exception exp) { @@ -205,9 +205,9 @@ public class OQLEngine { } if (q.className != null) { - Enumeration objects = clazz.getInstances(q.isInstanceOf); + Enumeration objects = clazz.getInstances(q.isInstanceOf); while (objects.hasMoreElements()) { - JavaHeapObject obj = (JavaHeapObject) objects.nextElement(); + JavaHeapObject obj = objects.nextElement(); Object[] args = new Object[] { wrapJavaObject(obj) }; boolean b = (whereCode == null); if (!b) { @@ -265,14 +265,14 @@ public class OQLEngine { // create JavaScript engine Method getEngineMethod = managerClass.getMethod("getEngineByName", - new Class[] { String.class }); + new Class[] { String.class }); engine = getEngineMethod.invoke(manager, new Object[] {"js"}); // initialize engine with init file (hat.js) InputStream strm = getInitStream(); Class engineClass = Class.forName("javax.script.ScriptEngine"); evalMethod = engineClass.getMethod("eval", - new Class[] { Reader.class }); + new Class[] { Reader.class }); evalMethod.invoke(engine, new Object[] {new InputStreamReader(strm)}); // initialize ScriptEngine.eval(String) and @@ -280,13 +280,13 @@ public class OQLEngine { Class invocableClass = Class.forName("javax.script.Invocable"); evalMethod = engineClass.getMethod("eval", - new Class[] { String.class }); + new Class[] { String.class }); invokeMethod = invocableClass.getMethod("invokeFunction", - new Class[] { String.class, Object[].class }); + new Class[] { String.class, Object[].class }); // initialize ScriptEngine.put(String, Object) method Method putMethod = engineClass.getMethod("put", - new Class[] { String.class, Object.class }); + new Class[] { String.class, Object.class }); // call ScriptEngine.put to initialize built-in heap object putMethod.invoke(engine, new Object[] { diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java index d453d82c38c..cd08b1bf0da 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,10 +58,10 @@ class AllClassesQuery extends QueryHandler { startHtml("All Classes (including platform)"); } - Iterator classes = snapshot.getClasses(); + Iterator classes = snapshot.getClasses(); String lastPackage = null; while (classes.hasNext()) { - JavaClass clazz = (JavaClass) classes.next(); + JavaClass clazz = classes.next(); if (excludePlatform && PlatformClasses.isPlatformClass(clazz)) { // skip this.. continue; diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java index dde9640b4a7..824501381f7 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,7 +151,7 @@ class ClassQuery extends QueryHandler { } out.println("

    References to this object:

    "); out.flush(); - Enumeration referers = obj.getReferers(); + Enumeration referers = obj.getReferers(); while (referers.hasMoreElements()) { JavaHeapObject ref = (JavaHeapObject) referers.nextElement(); printThing(ref); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerObjectsQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerObjectsQuery.java index 91f7017ebf2..a717c7aa38c 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerObjectsQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerObjectsQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import java.util.*; public class FinalizerObjectsQuery extends QueryHandler { public void run() { - Enumeration objs = snapshot.getFinalizerObjects(); + Enumeration objs = snapshot.getFinalizerObjects(); startHtml("Objects pending finalization"); out.println("Finalizer summary"); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerSummaryQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerSummaryQuery.java index 916cda738a4..c1aa35bce55 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerSummaryQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/FinalizerSummaryQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import java.util.*; public class FinalizerSummaryQuery extends QueryHandler { public void run() { - Enumeration objs = snapshot.getFinalizerObjects(); + Enumeration objs = snapshot.getFinalizerObjects(); startHtml("Finalizer Summary"); out.println("

    "); @@ -74,7 +74,7 @@ public class FinalizerSummaryQuery extends QueryHandler { private long count; } - private void printFinalizerSummary(Enumeration objs) { + private void printFinalizerSummary(Enumeration objs) { int count = 0; Map map = new HashMap(); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java index 1b466a49a4f..311df7bbb26 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,10 +111,10 @@ class InstancesCountQuery extends QueryHandler { } out.print(" "); if (snapshot.getHasNewSet()) { - Enumeration objects = clazz.getInstances(false); + Enumeration objects = clazz.getInstances(false); int newInst = 0; while (objects.hasMoreElements()) { - JavaHeapObject obj = (JavaHeapObject)objects.nextElement(); + JavaHeapObject obj = objects.nextElement(); if (obj.isNew()) { newInst++; } diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesQuery.java index ff1f60f7be5..7532b0b2e62 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,11 +73,11 @@ class InstancesQuery extends QueryHandler { out.print(""); printClass(clazz); out.print("

    "); - Enumeration objects = clazz.getInstances(includeSubclasses); + Enumeration objects = clazz.getInstances(includeSubclasses); long totalSize = 0; long instances = 0; while (objects.hasMoreElements()) { - JavaHeapObject obj = (JavaHeapObject) objects.nextElement(); + JavaHeapObject obj = objects.nextElement(); if (newObjects && !obj.isNew()) continue; printThing(obj); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java index 73755c2e523..15f7ae8b492 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,15 +47,15 @@ public class RefsByTypeQuery extends QueryHandler { } else { Map referrersStat = new HashMap(); final Map refereesStat = new HashMap(); - Enumeration instances = clazz.getInstances(false); + Enumeration instances = clazz.getInstances(false); while (instances.hasMoreElements()) { - JavaHeapObject instance = (JavaHeapObject) instances.nextElement(); + JavaHeapObject instance = instances.nextElement(); if (instance.getId() == -1) { continue; } - Enumeration e = instance.getReferers(); + Enumeration e = instance.getReferers(); while (e.hasMoreElements()) { - JavaHeapObject ref = (JavaHeapObject) e.nextElement(); + JavaHeapObject ref = (JavaHeapObject)e.nextElement(); JavaClass cl = ref.getClazz(); if (cl == null) { System.out.println("null class for " + ref); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/util/CompositeEnumeration.java b/jdk/src/share/classes/com/sun/tools/hat/internal/util/CompositeEnumeration.java index 6663d8ff894..c20afb22339 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/util/CompositeEnumeration.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/util/CompositeEnumeration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,12 +34,13 @@ package com.sun.tools.hat.internal.util; import java.util.Enumeration; import java.util.NoSuchElementException; +import com.sun.tools.hat.internal.model.JavaHeapObject; -public class CompositeEnumeration implements Enumeration { - Enumeration e1; - Enumeration e2; +public class CompositeEnumeration implements Enumeration { + Enumeration e1; + Enumeration e2; - public CompositeEnumeration(Enumeration e1, Enumeration e2) { + public CompositeEnumeration(Enumeration e1, Enumeration e2) { this.e1 = e1; this.e2 = e2; } @@ -48,7 +49,7 @@ public class CompositeEnumeration implements Enumeration { return e1.hasMoreElements() || e2.hasMoreElements(); } - public Object nextElement() { + public JavaHeapObject nextElement() { if (e1.hasMoreElements()) { return e1.nextElement(); } diff --git a/jdk/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java b/jdk/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java index 11572160825..93c10f0b00f 100644 --- a/jdk/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java +++ b/jdk/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.util.*; // Warnings from List filters and List[] requestLists is hard to fix. // Remove SuppressWarning when we fix the warnings from List filters // and List[] requestLists. The generic array is not supported. -@SuppressWarnings("unchecked") +@SuppressWarnings({"unchecked", "rawtypes"}) class EventRequestManagerImpl extends MirrorImpl implements EventRequestManager { diff --git a/jdk/src/share/classes/java/awt/Color.java b/jdk/src/share/classes/java/awt/Color.java index e80e991aa15..3a94d73ac74 100644 --- a/jdk/src/share/classes/java/awt/Color.java +++ b/jdk/src/share/classes/java/awt/Color.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ import java.awt.color.ColorSpace; * see * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html * . - *

    + * * @version 10 Feb 1997 * @author Sami Shaio * @author Arthur van Hoff diff --git a/jdk/src/share/classes/java/awt/Font.java b/jdk/src/share/classes/java/awt/Font.java index 41d143522dc..d9faf3d3e80 100644 --- a/jdk/src/share/classes/java/awt/Font.java +++ b/jdk/src/share/classes/java/awt/Font.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -542,7 +542,6 @@ public class Font implements java.io.Serializable * compatible alternative, then the font system will map the Font * instance to "Dialog", such that for example, the family as reported * by {@link #getFamily() getFamily} will be "Dialog". - *

    * * @param name the font name. This can be a font face name or a font * family name, and may represent either a logical font or a physical diff --git a/jdk/src/share/classes/java/awt/Graphics.java b/jdk/src/share/classes/java/awt/Graphics.java index 4f03e1c61dd..3be860cab31 100644 --- a/jdk/src/share/classes/java/awt/Graphics.java +++ b/jdk/src/share/classes/java/awt/Graphics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,7 +151,7 @@ public abstract class Graphics { * is specified by the width and height * arguments. * - *

    + * * @param x the x coordinate. * @param y the y coordinate. * @param width the width of the clipping rectangle. diff --git a/jdk/src/share/classes/java/awt/MenuComponent.java b/jdk/src/share/classes/java/awt/MenuComponent.java index 4ea95bf5969..64b1db9bf06 100644 --- a/jdk/src/share/classes/java/awt/MenuComponent.java +++ b/jdk/src/share/classes/java/awt/MenuComponent.java @@ -132,16 +132,24 @@ public abstract class MenuComponent implements java.io.Serializable { static { AWTAccessor.setMenuComponentAccessor( new AWTAccessor.MenuComponentAccessor() { + @Override public AppContext getAppContext(MenuComponent menuComp) { return menuComp.appContext; } + @Override public void setAppContext(MenuComponent menuComp, AppContext appContext) { menuComp.appContext = appContext; } + @Override public MenuContainer getParent(MenuComponent menuComp) { return menuComp.parent; } + @Override + public void setParent(MenuComponent menuComp, MenuContainer menuContainer) { + menuComp.parent = menuContainer; + } + @Override public Font getFont_NoClientCode(MenuComponent menuComp) { return menuComp.getFont_NoClientCode(); } diff --git a/jdk/src/share/classes/java/awt/Polygon.java b/jdk/src/share/classes/java/awt/Polygon.java index e714428c0d1..0d89e6045be 100644 --- a/jdk/src/share/classes/java/awt/Polygon.java +++ b/jdk/src/share/classes/java/awt/Polygon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -351,7 +351,7 @@ public class Polygon implements Shape, java.io.Serializable { /** * Determines whether the specified coordinates are inside this * Polygon. - *

    + * * @param x the specified X coordinate to be tested * @param y the specified Y coordinate to be tested * @return {@code true} if this {@code Polygon} contains diff --git a/jdk/src/share/classes/java/awt/Rectangle.java b/jdk/src/share/classes/java/awt/Rectangle.java index d64deaf2f0e..727fe8e7ba8 100644 --- a/jdk/src/share/classes/java/awt/Rectangle.java +++ b/jdk/src/share/classes/java/awt/Rectangle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,14 +41,13 @@ import java.beans.Transient; *

    * * A {@code Rectangle} whose width or height is exactly zero has location - * along those axes with zero dimension, but is otherwise considered empty. + * along those axes with zero dimension, but is otherwise considered empty. * The {@link #isEmpty} method will return true for such a {@code Rectangle}. * Methods which test if an empty {@code Rectangle} contains or intersects * a point or rectangle will always return false if either dimension is zero. * Methods which combine such a {@code Rectangle} with a point or rectangle * will include the location of the {@code Rectangle} on that axis in the * result as if the {@link #add(Point)} method were being called. - * *

    * * A {@code Rectangle} whose width or height is negative has neither @@ -422,7 +421,7 @@ public class Rectangle extends Rectangle2D * Rectangle to the specified * x, y, width, * and height. - *

    + * * @param x the new X coordinate for the upper-left * corner of this Rectangle * @param y the new Y coordinate for the upper-left @@ -488,7 +487,7 @@ public class Rectangle extends Rectangle2D /** * Moves this Rectangle to the specified location. - *

    + * * @param x the X coordinate of the new location * @param y the Y coordinate of the new location * @deprecated As of JDK version 1.1, @@ -629,7 +628,7 @@ public class Rectangle extends Rectangle2D /** * Sets the size of this Rectangle to the specified * width and height. - *

    + * * @param width the new width for this Rectangle * @param height the new height for this Rectangle * @deprecated As of JDK version 1.1, diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 65b494ba52d..2fc0910cc96 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -1241,10 +1241,9 @@ public abstract class Toolkit { * clipboard enables data transfer between Java programs and native * applications which use native clipboard facilities. *

    - * In addition to any and all formats specified in the flavormap.properties - * file, or other file specified by the AWT.DnD.flavorMapFileURL - * Toolkit property, text returned by the system Clipboard's - * getTransferData() method is available in the following flavors: + * In addition to any and all default formats text returned by the system + * Clipboard's getTransferData() method is available in the + * following flavors: *

    * *

    Summary of attributes

    - * * diff --git a/jdk/src/share/classes/java/awt/geom/Arc2D.java b/jdk/src/share/classes/java/awt/geom/Arc2D.java index 3d92306f618..be51e8a4bc3 100644 --- a/jdk/src/share/classes/java/awt/geom/Arc2D.java +++ b/jdk/src/share/classes/java/awt/geom/Arc2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,8 +35,8 @@ import java.io.Serializable; *

    * * The arc is a partial section of a full ellipse which - * inscribes the framing rectangle of its parent {@link RectangularShape}. - * + * inscribes the framing rectangle of its parent {@link RectangularShape}. + * * * The angles are specified relative to the non-square * framing rectangle such that 45 degrees always falls on the line from diff --git a/jdk/src/share/classes/java/awt/image/AffineTransformOp.java b/jdk/src/share/classes/java/awt/image/AffineTransformOp.java index 9e6a66eea5c..d9216606b73 100644 --- a/jdk/src/share/classes/java/awt/image/AffineTransformOp.java +++ b/jdk/src/share/classes/java/awt/image/AffineTransformOp.java @@ -324,7 +324,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp { * this part of the rectangle is not drawn. If the coordinates * of the rectangle are positive then the filtered image is drawn at * that position in the destination Raster. - *

    + * * @param src The Raster to transform. * @param dst The Raster in which to store the results of the * transformation. diff --git a/jdk/src/share/classes/java/awt/image/BufferedImageFilter.java b/jdk/src/share/classes/java/awt/image/BufferedImageFilter.java index bac63a8f066..e848fd9c206 100644 --- a/jdk/src/share/classes/java/awt/image/BufferedImageFilter.java +++ b/jdk/src/share/classes/java/awt/image/BufferedImageFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ public class BufferedImageFilter extends ImageFilter implements Cloneable { * an image should avoid calling this method directly since that * operation could result in problems with retrieving the requested * pixels. - *

    + * * @param width the width to which to set the width of this * BufferedImageFilter * @param height the height to which to set the height of this diff --git a/jdk/src/share/classes/java/awt/image/ImageFilter.java b/jdk/src/share/classes/java/awt/image/ImageFilter.java index 33198346e03..04077b6d6a5 100644 --- a/jdk/src/share/classes/java/awt/image/ImageFilter.java +++ b/jdk/src/share/classes/java/awt/image/ImageFilter.java @@ -225,7 +225,7 @@ public class ImageFilter implements ImageConsumer, Cloneable { * *

  • * Override the method to simply send the data. - * This is appropriate if the filter can handle the request itself — + * This is appropriate if the filter can handle the request itself — * for example, * if the generated pixels have been saved in some sort of buffer. * diff --git a/jdk/src/share/classes/java/awt/image/WritableRaster.java b/jdk/src/share/classes/java/awt/image/WritableRaster.java index 6ad950288ee..65ff74aa4f9 100644 --- a/jdk/src/share/classes/java/awt/image/WritableRaster.java +++ b/jdk/src/share/classes/java/awt/image/WritableRaster.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -394,7 +394,7 @@ public class WritableRaster extends Raster { * is first converted to a 32-bit int (if necessary), using the above * rules for integral types, and then the int is cast to float or * double. - *

    + * * @param srcRaster The Raster from which to copy pixels. * * @throws NullPointerException if srcRaster is null. diff --git a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java index e6b923dda0e..b08e13481ee 100644 --- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java +++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java @@ -370,7 +370,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock add(int i) { - return add(new Integer(i)); + return add(i); } /** @@ -489,7 +489,7 @@ public class ParameterBlock implements Cloneable, Serializable { * the specified parameter. */ public ParameterBlock set(int i, int index) { - return set(new Integer(i), index); + return set(i, index); } /** diff --git a/jdk/src/share/classes/java/awt/print/PrinterJob.java b/jdk/src/share/classes/java/awt/print/PrinterJob.java index 0c80d1490d4..41d39ce10ec 100644 --- a/jdk/src/share/classes/java/awt/print/PrinterJob.java +++ b/jdk/src/share/classes/java/awt/print/PrinterJob.java @@ -546,7 +546,6 @@ public abstract class PrinterJob { * user settings returned from * printDialog(PrintRequestAttributeSet attributes to * this print() method. - *

    * * @param attributes a set of attributes for the job * @exception PrinterException an error in the print system diff --git a/jdk/src/share/classes/java/beans/EventHandler.java b/jdk/src/share/classes/java/beans/EventHandler.java index dd41750f2f1..be0f95d8ede 100644 --- a/jdk/src/share/classes/java/beans/EventHandler.java +++ b/jdk/src/share/classes/java/beans/EventHandler.java @@ -437,7 +437,7 @@ public class EventHandler implements InvocationHandler { if (method.getDeclaringClass() == Object.class) { // Handle the Object public methods. if (methodName.equals("hashCode")) { - return new Integer(System.identityHashCode(proxy)); + return System.identityHashCode(proxy); } else if (methodName.equals("equals")) { return (proxy == arguments[0] ? Boolean.TRUE : Boolean.FALSE); } else if (methodName.equals("toString")) { diff --git a/jdk/src/share/classes/java/beans/MetaData.java b/jdk/src/share/classes/java/beans/MetaData.java index d0e7108179d..ee64475b8c4 100644 --- a/jdk/src/share/classes/java/beans/MetaData.java +++ b/jdk/src/share/classes/java/beans/MetaData.java @@ -123,13 +123,13 @@ static final class ArrayPersistenceDelegate extends PersistenceDelegate { Class oldClass = oldInstance.getClass(); return new Expression(oldInstance, Array.class, "newInstance", new Object[]{oldClass.getComponentType(), - new Integer(Array.getLength(oldInstance))}); + Array.getLength(oldInstance)}); } protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) { int n = Array.getLength(oldInstance); for (int i = 0; i < n; i++) { - Object index = new Integer(i); + Object index = i; // Expression oldGetExp = new Expression(Array.class, "get", new Object[]{oldInstance, index}); // Expression newGetExp = new Expression(Array.class, "get", new Object[]{newInstance, index}); Expression oldGetExp = new Expression(oldInstance, "get", new Object[]{index}); @@ -635,7 +635,7 @@ static class java_util_List_PersistenceDelegate extends DefaultPersistenceDelega newSize = 0; } for (int i = 0; i < newSize; i++) { - Object index = new Integer(i); + Object index = i; Expression oldGetExp = new Expression(oldInstance, "get", new Object[]{index}); Expression newGetExp = new Expression(newInstance, "get", new Object[]{index}); @@ -892,7 +892,7 @@ static final class java_awt_MenuShortcut_PersistenceDelegate extends Persistence protected Expression instantiate(Object oldInstance, Encoder out) { java.awt.MenuShortcut m = (java.awt.MenuShortcut)oldInstance; return new Expression(oldInstance, m.getClass(), "new", - new Object[]{new Integer(m.getKey()), Boolean.valueOf(m.usesShiftModifier())}); + new Object[]{m.getKey(), Boolean.valueOf(m.usesShiftModifier())}); } } diff --git a/jdk/src/share/classes/java/beans/NameGenerator.java b/jdk/src/share/classes/java/beans/NameGenerator.java index 61dd9339853..fc1db4d0fb7 100644 --- a/jdk/src/share/classes/java/beans/NameGenerator.java +++ b/jdk/src/share/classes/java/beans/NameGenerator.java @@ -107,7 +107,7 @@ class NameGenerator { Integer size = nameToCount.get(className); int instanceNumber = (size == null) ? 0 : (size).intValue() + 1; - nameToCount.put(className, new Integer(instanceNumber)); + nameToCount.put(className, instanceNumber); result = className + instanceNumber; valueToName.put(instance, result); diff --git a/jdk/src/share/classes/java/lang/Integer.java b/jdk/src/share/classes/java/lang/Integer.java index a6a06bc3510..94b0aff7970 100644 --- a/jdk/src/share/classes/java/lang/Integer.java +++ b/jdk/src/share/classes/java/lang/Integer.java @@ -26,6 +26,7 @@ package java.lang; import java.lang.annotation.Native; +import java.util.Objects; /** * The {@code Integer} class wraps a value of the primitive type @@ -319,24 +320,27 @@ public final class Integer extends Number implements Comparable { } /** - * Format a long (treated as unsigned) into a character buffer. + * Format an {@code int} (treated as unsigned) into a character buffer. If + * {@code len} exceeds the formatted ASCII representation of {@code val}, + * {@code buf} will be padded with leading zeroes. + * * @param val the unsigned int to format * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) * @param buf the character buffer to write to * @param offset the offset in the destination buffer to start at * @param len the number of characters to write - * @return the lowest character location used */ - static int formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) { - int charPos = len; + static void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) { + // assert shift > 0 && shift <=5 : "Illegal shift value"; + // assert offset >= 0 && offset < buf.length : "illegal offset"; + // assert len > 0 && (offset + len) <= buf.length : "illegal length"; + int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; do { - buf[offset + --charPos] = Integer.digits[val & mask]; + buf[--charPos] = Integer.digits[val & mask]; val >>>= shift; - } while (val != 0 && charPos > 0); - - return charPos; + } while (charPos > offset); } final static char [] DigitTens = { @@ -549,12 +553,9 @@ public final class Integer extends Number implements Comparable { " greater than Character.MAX_RADIX"); } - int result = 0; boolean negative = false; int i = 0, len = s.length(); int limit = -Integer.MAX_VALUE; - int multmin; - int digit; if (len > 0) { char firstChar = s.charAt(0); @@ -562,21 +563,21 @@ public final class Integer extends Number implements Comparable { if (firstChar == '-') { negative = true; limit = Integer.MIN_VALUE; - } else if (firstChar != '+') - throw NumberFormatException.forInputString(s); - - if (len == 1) // Cannot have lone "+" or "-" - throw NumberFormatException.forInputString(s); - i++; - } - multmin = limit / radix; - while (i < len) { - // Accumulating negatively avoids surprises near MAX_VALUE - digit = Character.digit(s.charAt(i++),radix); - if (digit < 0) { + } else if (firstChar != '+') { throw NumberFormatException.forInputString(s); } - if (result < multmin) { + + if (len == 1) { // Cannot have lone "+" or "-" + throw NumberFormatException.forInputString(s); + } + i++; + } + int multmin = limit / radix; + int result = 0; + while (i < len) { + // Accumulating negatively avoids surprises near MAX_VALUE + int digit = Character.digit(s.charAt(i++), radix); + if (digit < 0 || result < multmin) { throw NumberFormatException.forInputString(s); } result *= radix; @@ -585,10 +586,126 @@ public final class Integer extends Number implements Comparable { } result -= digit; } + return negative ? result : -result; } else { throw NumberFormatException.forInputString(s); } - return negative ? result : -result; + } + + /** + * Parses the {@link CharSequence} argument as a signed {@code int} in the + * specified {@code radix}, beginning at the specified {@code beginIndex} + * and extending to the end of the sequence. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the {@code int} + * representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @return the signed {@code int} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable {@code int} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static int parseInt(CharSequence s, int radix, int beginIndex) + throws NumberFormatException { + // forces an implicit null check of s + return parseInt(s, radix, beginIndex, s.length()); + } + + /** + * Parses the {@link CharSequence} argument as a signed {@code int} in the + * specified {@code radix}, beginning at the specified {@code beginIndex} + * and extending to {@code endIndex - 1}. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the {@code int} + * representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @param endIndex the ending index, exclusive. + * @return the signed {@code int} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code endIndex} or if {@code endIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable {@code int} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static int parseInt(CharSequence s, int radix, int beginIndex, int endIndex) + throws NumberFormatException { + s = Objects.requireNonNull(s); + + if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { + throw new IndexOutOfBoundsException(); + } + if (radix < Character.MIN_RADIX) { + throw new NumberFormatException("radix " + radix + + " less than Character.MIN_RADIX"); + } + if (radix > Character.MAX_RADIX) { + throw new NumberFormatException("radix " + radix + + " greater than Character.MAX_RADIX"); + } + + boolean negative = false; + int i = beginIndex; + int limit = -Integer.MAX_VALUE; + + if (i < endIndex) { + char firstChar = s.charAt(i); + if (firstChar < '0') { // Possible leading "+" or "-" + if (firstChar == '-') { + negative = true; + limit = Integer.MIN_VALUE; + } else if (firstChar != '+') { + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + i++; + if (i == endIndex) { // Cannot have lone "+" or "-" + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + } + int multmin = limit / radix; + int result = 0; + while (i < endIndex) { + // Accumulating negatively avoids surprises near MAX_VALUE + int digit = Character.digit(s.charAt(i++), radix); + if (digit < 0 || result < multmin) { + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + result *= radix; + if (result < limit + digit) { + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + result -= digit; + } + return negative ? result : -result; + } else { + throw NumberFormatException.forInputString(""); + } } /** @@ -688,6 +805,99 @@ public final class Integer extends Number implements Comparable { } } + /** + * Parses the {@link CharSequence} argument as an unsigned {@code int} in + * the specified {@code radix}, beginning at the specified + * {@code beginIndex} and extending to the end of the sequence. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the unsigned + * {@code int} representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @return the unsigned {@code int} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable unsigned {@code int} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static int parseUnsignedInt(CharSequence s, int radix, int beginIndex) + throws NumberFormatException { + // forces an implicit null check of s + return parseUnsignedInt(s, radix, beginIndex, s.length()); + } + + /** + * Parses the {@link CharSequence} argument as an unsigned {@code int} in + * the specified {@code radix}, beginning at the specified + * {@code beginIndex} and extending to {@code endIndex - 1}. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the unsigned + * {@code int} representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @param endIndex the ending index, exclusive. + * @return the unsigned {@code int} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code endIndex} or if {@code endIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable unsigned {@code int} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static int parseUnsignedInt(CharSequence s, int radix, int beginIndex, int endIndex) + throws NumberFormatException { + s = Objects.requireNonNull(s); + + if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { + throw new IndexOutOfBoundsException(); + } + int start = beginIndex, len = endIndex - beginIndex; + + if (len > 0) { + char firstChar = s.charAt(start); + if (firstChar == '-') { + throw new + NumberFormatException(String.format("Illegal leading minus sign " + + "on unsigned string %s.", s)); + } else { + if (len <= 5 || // Integer.MAX_VALUE in Character.MAX_RADIX is 6 digits + (radix == 10 && len <= 9)) { // Integer.MAX_VALUE in base 10 is 10 digits + return parseInt(s, radix, start, start + len); + } else { + long ell = Long.parseLong(s, radix, start, start + len); + if ((ell & 0xffff_ffff_0000_0000L) == 0) { + return (int) ell; + } else { + throw new + NumberFormatException(String.format("String value %s exceeds " + + "range of unsigned int.", s)); + } + } + } + } else { + throw new NumberFormatException(""); + } + } + /** * Parses the string argument as an unsigned decimal integer. The * characters in the string must all be decimal digits, except diff --git a/jdk/src/share/classes/java/lang/Long.java b/jdk/src/share/classes/java/lang/Long.java index 63a7cb3654a..76caa77fac7 100644 --- a/jdk/src/share/classes/java/lang/Long.java +++ b/jdk/src/share/classes/java/lang/Long.java @@ -27,6 +27,7 @@ package java.lang; import java.lang.annotation.Native; import java.math.*; +import java.util.Objects; /** @@ -360,24 +361,27 @@ public final class Long extends Number implements Comparable { } /** - * Format a long (treated as unsigned) into a character buffer. + * Format a long (treated as unsigned) into a character buffer. If + * {@code len} exceeds the formatted ASCII representation of {@code val}, + * {@code buf} will be padded with leading zeroes. + * * @param val the unsigned long to format * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) * @param buf the character buffer to write to * @param offset the offset in the destination buffer to start at * @param len the number of characters to write - * @return the lowest character location used */ - static int formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) { - int charPos = len; + static void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) { + // assert shift > 0 && shift <=5 : "Illegal shift value"; + // assert offset >= 0 && offset < buf.length : "illegal offset"; + // assert len > 0 && (offset + len) <= buf.length : "illegal length"; + int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; do { - buf[offset + --charPos] = Integer.digits[((int) val) & mask]; + buf[--charPos] = Integer.digits[((int) val) & mask]; val >>>= shift; - } while (val != 0 && charPos > 0); - - return charPos; + } while (charPos > offset); } /** @@ -561,12 +565,9 @@ public final class Long extends Number implements Comparable { " greater than Character.MAX_RADIX"); } - long result = 0; boolean negative = false; int i = 0, len = s.length(); long limit = -Long.MAX_VALUE; - long multmin; - int digit; if (len > 0) { char firstChar = s.charAt(0); @@ -574,21 +575,21 @@ public final class Long extends Number implements Comparable { if (firstChar == '-') { negative = true; limit = Long.MIN_VALUE; - } else if (firstChar != '+') - throw NumberFormatException.forInputString(s); - - if (len == 1) // Cannot have lone "+" or "-" - throw NumberFormatException.forInputString(s); - i++; - } - multmin = limit / radix; - while (i < len) { - // Accumulating negatively avoids surprises near MAX_VALUE - digit = Character.digit(s.charAt(i++),radix); - if (digit < 0) { + } else if (firstChar != '+') { throw NumberFormatException.forInputString(s); } - if (result < multmin) { + + if (len == 1) { // Cannot have lone "+" or "-" + throw NumberFormatException.forInputString(s); + } + i++; + } + long multmin = limit / radix; + long result = 0; + while (i < len) { + // Accumulating negatively avoids surprises near MAX_VALUE + int digit = Character.digit(s.charAt(i++),radix); + if (digit < 0 || result < multmin) { throw NumberFormatException.forInputString(s); } result *= radix; @@ -597,10 +598,126 @@ public final class Long extends Number implements Comparable { } result -= digit; } + return negative ? result : -result; } else { throw NumberFormatException.forInputString(s); } - return negative ? result : -result; + } + + /** + * Parses the {@link CharSequence} argument as a signed {@code long} in + * the specified {@code radix}, beginning at the specified {@code beginIndex} + * and extending to the end of the sequence. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the {@code long} + * representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @return the signed {@code long} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable {@code long} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static long parseLong(CharSequence s, int radix, int beginIndex) + throws NumberFormatException { + // forces a null check of s + return parseLong(s, radix, beginIndex, s.length()); + } + + /** + * Parses the {@link CharSequence} argument as a signed {@code long} in + * the specified {@code radix}, beginning at the specified + * {@code beginIndex} and extending to {@code endIndex - 1}. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the {@code long} + * representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @param endIndex the ending index, exclusive. + * @return the signed {@code long} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code endIndex} or if {@code endIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable {@code int} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static long parseLong(CharSequence s, int radix, int beginIndex, int endIndex) + throws NumberFormatException { + s = Objects.requireNonNull(s); + + if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { + throw new IndexOutOfBoundsException(); + } + if (radix < Character.MIN_RADIX) { + throw new NumberFormatException("radix " + radix + + " less than Character.MIN_RADIX"); + } + if (radix > Character.MAX_RADIX) { + throw new NumberFormatException("radix " + radix + + " greater than Character.MAX_RADIX"); + } + + boolean negative = false; + int i = beginIndex; + long limit = -Long.MAX_VALUE; + + if (i < endIndex) { + char firstChar = s.charAt(i); + if (firstChar < '0') { // Possible leading "+" or "-" + if (firstChar == '-') { + negative = true; + limit = Long.MIN_VALUE; + } else if (firstChar != '+') { + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + i++; + } + if (i >= endIndex) { // Cannot have lone "+", "-" or "" + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + long multmin = limit / radix; + long result = 0; + while (i < endIndex) { + // Accumulating negatively avoids surprises near MAX_VALUE + int digit = Character.digit(s.charAt(i++), radix); + if (digit < 0 || result < multmin) { + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + result *= radix; + if (result < limit + digit) { + throw NumberFormatException.forCharSequence(s, beginIndex, + endIndex, i); + } + result -= digit; + } + return negative ? result : -result; + } else { + throw new NumberFormatException(""); + } } /** @@ -694,7 +811,7 @@ public final class Long extends Number implements Comparable { } // No need for range checks on len due to testing above. - long first = parseLong(s.substring(0, len - 1), radix); + long first = parseLong(s, radix, 0, len - 1); int second = Character.digit(s.charAt(len - 1), radix); if (second < 0) { throw new NumberFormatException("Bad digit at end of " + s); @@ -763,6 +880,155 @@ public final class Long extends Number implements Comparable { } } + /** + * Parses the {@link CharSequence} argument as an unsigned {@code long} in + * the specified {@code radix}, beginning at the specified + * {@code beginIndex} and extending to the end of the sequence. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the unsigned + * {@code long} representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @return the unsigned {@code long} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable unsigned {@code long} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static long parseUnsignedLong(CharSequence s, int radix, int beginIndex) + throws NumberFormatException { + // forces a null check of s + return parseUnsignedLong(s, radix, beginIndex, s.length()); + } + + /** + * Parses the {@link CharSequence} argument as an unsigned {@code long} in + * the specified {@code radix}, beginning at the specified + * {@code beginIndex} and extending to {@code endIndex - 1}. + * + *

    The method does not take steps to guard against the + * {@code CharSequence} being mutated while parsing. + * + * @param s the {@code CharSequence} containing the unsigned + * {@code long} representation to be parsed + * @param radix the radix to be used while parsing {@code s}. + * @param beginIndex the beginning index, inclusive. + * @param endIndex the ending index, exclusive. + * @return the unsigned {@code long} represented by the subsequence in + * the specified radix. + * @throws NullPointerException if {@code s} is null. + * @throws IndexOutOfBoundsException if {@code beginIndex} is + * negative, or if {@code beginIndex} is greater than + * {@code endIndex} or if {@code endIndex} is greater than + * {@code s.length()}. + * @throws NumberFormatException if the {@code CharSequence} does not + * contain a parsable unsigned {@code long} in the specified + * {@code radix}, or if {@code radix} is either smaller than + * {@link java.lang.Character#MIN_RADIX} or larger than + * {@link java.lang.Character#MAX_RADIX}. + * @since 1.9 + */ + public static long parseUnsignedLong(CharSequence s, int radix, int beginIndex, int endIndex) + throws NumberFormatException { + s = Objects.requireNonNull(s); + + if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { + throw new IndexOutOfBoundsException(); + } + int start = beginIndex, len = endIndex - beginIndex; + + if (len > 0) { + char firstChar = s.charAt(start); + if (firstChar == '-') { + throw new NumberFormatException(String.format("Illegal leading minus sign " + + "on unsigned string %s.", s.subSequence(start, start + len))); + } else { + if (len <= 12 || // Long.MAX_VALUE in Character.MAX_RADIX is 13 digits + (radix == 10 && len <= 18) ) { // Long.MAX_VALUE in base 10 is 19 digits + return parseLong(s, radix, start, start + len); + } + + // No need for range checks on end due to testing above. + long first = parseLong(s, radix, start, start + len - 1); + int second = Character.digit(s.charAt(start + len - 1), radix); + if (second < 0) { + throw new NumberFormatException("Bad digit at end of " + + s.subSequence(start, start + len)); + } + long result = first * radix + second; + + /* + * Test leftmost bits of multiprecision extension of first*radix + * for overflow. The number of bits needed is defined by + * GUARD_BIT = ceil(log2(Character.MAX_RADIX)) + 1 = 7. Then + * int guard = radix*(int)(first >>> (64 - GUARD_BIT)) and + * overflow is tested by splitting guard in the ranges + * guard < 92, 92 <= guard < 128, and 128 <= guard, where + * 92 = 128 - Character.MAX_RADIX. Note that guard cannot take + * on a value which does not include a prime factor in the legal + * radix range. + */ + int guard = radix * (int) (first >>> 57); + if (guard >= 128 || + (result >= 0 && guard >= 128 - Character.MAX_RADIX)) { + /* + * For purposes of exposition, the programmatic statements + * below should be taken to be multi-precision, i.e., not + * subject to overflow. + * + * A) Condition guard >= 128: + * If guard >= 128 then first*radix >= 2^7 * 2^57 = 2^64 + * hence always overflow. + * + * B) Condition guard < 92: + * Define left7 = first >>> 57. + * Given first = (left7 * 2^57) + (first & (2^57 - 1)) then + * result <= (radix*left7)*2^57 + radix*(2^57 - 1) + second. + * Thus if radix*left7 < 92, radix <= 36, and second < 36, + * then result < 92*2^57 + 36*(2^57 - 1) + 36 = 2^64 hence + * never overflow. + * + * C) Condition 92 <= guard < 128: + * first*radix + second >= radix*left7*2^57 + second + * so that first*radix + second >= 92*2^57 + 0 > 2^63 + * + * D) Condition guard < 128: + * radix*first <= (radix*left7) * 2^57 + radix*(2^57 - 1) + * so + * radix*first + second <= (radix*left7) * 2^57 + radix*(2^57 - 1) + 36 + * thus + * radix*first + second < 128 * 2^57 + 36*2^57 - radix + 36 + * whence + * radix*first + second < 2^64 + 2^6*2^57 = 2^64 + 2^63 + * + * E) Conditions C, D, and result >= 0: + * C and D combined imply the mathematical result + * 2^63 < first*radix + second < 2^64 + 2^63. The lower + * bound is therefore negative as a signed long, but the + * upper bound is too small to overflow again after the + * signed long overflows to positive above 2^64 - 1. Hence + * result >= 0 implies overflow given C and D. + */ + throw new NumberFormatException(String.format("String value %s exceeds " + + "range of unsigned long.", s.subSequence(start, start + len))); + } + return result; + } + } else { + throw NumberFormatException.forInputString(""); + } + } + /** * Parses the string argument as an unsigned decimal {@code long}. The * characters in the string must all be decimal digits, except diff --git a/jdk/src/share/classes/java/lang/NumberFormatException.java b/jdk/src/share/classes/java/lang/NumberFormatException.java index 1774ce52e5c..7c6345dcd07 100644 --- a/jdk/src/share/classes/java/lang/NumberFormatException.java +++ b/jdk/src/share/classes/java/lang/NumberFormatException.java @@ -56,7 +56,7 @@ class NumberFormatException extends IllegalArgumentException { } /** - * Factory method for making a NumberFormatException + * Factory method for making a {@code NumberFormatException} * given the specified input which caused the error. * * @param s the input causing the error @@ -64,4 +64,20 @@ class NumberFormatException extends IllegalArgumentException { static NumberFormatException forInputString(String s) { return new NumberFormatException("For input string: \"" + s + "\""); } + + /** + * Factory method for making a {@code NumberFormatException} + * given the specified input which caused the error. + * + * @param s the input causing the error + * @param beginIndex the beginning index, inclusive. + * @param endIndex the ending index, exclusive. + * @param errorIndex the index of the first error in s + */ + static NumberFormatException forCharSequence(CharSequence s, + int beginIndex, int endIndex, int errorIndex) { + return new NumberFormatException("Error at index " + + (errorIndex - beginIndex) + " in: \"" + + s.subSequence(beginIndex, endIndex) + "\""); + } } diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java index c4f67778d42..ce673fba2d4 100644 --- a/jdk/src/share/classes/java/lang/String.java +++ b/jdk/src/share/classes/java/lang/String.java @@ -2580,7 +2580,8 @@ public final class String } for (int i = first; i < len; i++) { int cp = (int)value[i]; - if (cp == '\u03A3') { // GREEK CAPITAL LETTER SIGMA + if (cp == '\u03A3' || // GREEK CAPITAL LETTER SIGMA + Character.isSurrogate((char)cp)) { return toLowerCaseEx(result, i, locale, false); } if (cp == '\u0130') { // LATIN CAPITAL LETTER I WITH DOT ABOVE @@ -2742,7 +2743,11 @@ public final class String return toUpperCaseEx(result, first, locale, false); } for (int i = first; i < len; i++) { - int cp = Character.toUpperCaseEx((int)value[i]); + int cp = (int)value[i]; + if (Character.isSurrogate((char)cp)) { + return toUpperCaseEx(result, i, locale, false); + } + cp = Character.toUpperCaseEx(cp); if (!Character.isBmpCodePoint(cp)) { // Character.ERROR is not bmp return toUpperCaseEx(result, i, locale, false); } diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java index e96bd3b6f14..fbac697c245 100644 --- a/jdk/src/share/classes/java/lang/System.java +++ b/jdk/src/share/classes/java/lang/System.java @@ -1263,6 +1263,12 @@ public final class System { public void invokeFinalize(Object o) throws Throwable { o.finalize(); } + public void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) { + Long.formatUnsignedLong(val, shift, buf, offset, len); + } + public void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) { + Integer.formatUnsignedInt(val, shift, buf, offset, len); + } }); } } diff --git a/jdk/src/share/classes/java/lang/reflect/Modifier.java b/jdk/src/share/classes/java/lang/reflect/Modifier.java index 7387bbeaa75..f84a35166a9 100644 --- a/jdk/src/share/classes/java/lang/reflect/Modifier.java +++ b/jdk/src/share/classes/java/lang/reflect/Modifier.java @@ -26,6 +26,7 @@ package java.lang.reflect; import java.security.AccessController; +import java.util.StringJoiner; import sun.reflect.LangReflectAccess; import sun.reflect.ReflectionFactory; @@ -232,27 +233,24 @@ public class Modifier { * represented by {@code mod} */ public static String toString(int mod) { - StringBuilder sb = new StringBuilder(); - int len; + StringJoiner sj = new StringJoiner(" "); - if ((mod & PUBLIC) != 0) sb.append("public "); - if ((mod & PROTECTED) != 0) sb.append("protected "); - if ((mod & PRIVATE) != 0) sb.append("private "); + if ((mod & PUBLIC) != 0) sj.add("public"); + if ((mod & PROTECTED) != 0) sj.add("protected"); + if ((mod & PRIVATE) != 0) sj.add("private"); /* Canonical order */ - if ((mod & ABSTRACT) != 0) sb.append("abstract "); - if ((mod & STATIC) != 0) sb.append("static "); - if ((mod & FINAL) != 0) sb.append("final "); - if ((mod & TRANSIENT) != 0) sb.append("transient "); - if ((mod & VOLATILE) != 0) sb.append("volatile "); - if ((mod & SYNCHRONIZED) != 0) sb.append("synchronized "); - if ((mod & NATIVE) != 0) sb.append("native "); - if ((mod & STRICT) != 0) sb.append("strictfp "); - if ((mod & INTERFACE) != 0) sb.append("interface "); + if ((mod & ABSTRACT) != 0) sj.add("abstract"); + if ((mod & STATIC) != 0) sj.add("static"); + if ((mod & FINAL) != 0) sj.add("final"); + if ((mod & TRANSIENT) != 0) sj.add("transient"); + if ((mod & VOLATILE) != 0) sj.add("volatile"); + if ((mod & SYNCHRONIZED) != 0) sj.add("synchronized"); + if ((mod & NATIVE) != 0) sj.add("native"); + if ((mod & STRICT) != 0) sj.add("strictfp"); + if ((mod & INTERFACE) != 0) sj.add("interface"); - if ((len = sb.length()) > 0) /* trim trailing space */ - return sb.toString().substring(0, len-1); - return ""; + return sj.toString(); } /* diff --git a/jdk/src/share/classes/java/nio/StringCharBuffer.java b/jdk/src/share/classes/java/nio/StringCharBuffer.java index 0c20fa669c5..4a5f0517691 100644 --- a/jdk/src/share/classes/java/nio/StringCharBuffer.java +++ b/jdk/src/share/classes/java/nio/StringCharBuffer.java @@ -100,7 +100,7 @@ class StringCharBuffer // package-private } final String toString(int start, int end) { - return str.toString().substring(start + offset, end + offset); + return str.subSequence(start + offset, end + offset).toString(); } public final CharBuffer subSequence(int start, int end) { diff --git a/jdk/src/share/classes/java/time/chrono/JapaneseEra.java b/jdk/src/share/classes/java/time/chrono/JapaneseEra.java index 0187565869f..0c9e3e81e1d 100644 --- a/jdk/src/share/classes/java/time/chrono/JapaneseEra.java +++ b/jdk/src/share/classes/java/time/chrono/JapaneseEra.java @@ -127,7 +127,7 @@ public final class JapaneseEra // the number of defined JapaneseEra constants. // There could be an extra era defined in its configuration. - private static final int N_ERA_CONSTANTS = HEISEI.getValue() + ERA_OFFSET + 1; + private static final int N_ERA_CONSTANTS = HEISEI.getValue() + ERA_OFFSET; /** * Serialization version. @@ -148,7 +148,7 @@ public final class JapaneseEra for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) { CalendarDate date = ERA_CONFIG[i].getSinceDate(); LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth()); - KNOWN_ERAS[i] = new JapaneseEra(i - ERA_OFFSET, isoDate); + KNOWN_ERAS[i] = new JapaneseEra(i - ERA_OFFSET + 1, isoDate); } }; @@ -195,7 +195,7 @@ public final class JapaneseEra * @throws DateTimeException if the value is invalid */ public static JapaneseEra of(int japaneseEra) { - if (japaneseEra < MEIJI.eraValue || japaneseEra + ERA_OFFSET - 1 >= KNOWN_ERAS.length) { + if (japaneseEra < MEIJI.eraValue || japaneseEra + ERA_OFFSET > KNOWN_ERAS.length) { throw new DateTimeException("Invalid era: " + japaneseEra); } return KNOWN_ERAS[ordinal(japaneseEra)]; diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java index f6a65c7b106..ce4ae7d1b97 100644 --- a/jdk/src/share/classes/java/util/Collections.java +++ b/jdk/src/share/classes/java/util/Collections.java @@ -2342,7 +2342,7 @@ public class Collections { public NavigableSet tailSet(E fromElement, boolean inclusive) { synchronized (mutex) { - return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, inclusive)); + return new SynchronizedNavigableSet<>(ns.tailSet(fromElement, inclusive), mutex); } } } @@ -3486,6 +3486,7 @@ public class Collections { */ @Override public void replaceAll(UnaryOperator operator) { + Objects.requireNonNull(operator); list.replaceAll(e -> typeCheck(operator.apply(e))); } diff --git a/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java b/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java index 569c35899bc..ab5f59d8a65 100644 --- a/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java +++ b/jdk/src/share/classes/java/util/DoubleSummaryStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -129,9 +129,6 @@ public class DoubleSummaryStatistics implements DoubleConsumer { * Returns the sum of values recorded, or zero if no values have been * recorded. * - * If any recorded value is a NaN or the sum is at any point a NaN - * then the sum will be NaN. - * *

    The value of a floating-point sum is a function both of the * input values as well as the order of addition operations. The * order of addition operations of this method is intentionally @@ -143,6 +140,44 @@ public class DoubleSummaryStatistics implements DoubleConsumer { * numerical sum compared to a simple summation of {@code double} * values. * + * Because of the unspecified order of operations and the + * possibility of using differing summation schemes, the output of + * this method may vary on the same input values. + * + *

    Various conditions can result in a non-finite sum being + * computed. This can occur even if the all the recorded values + * being summed are finite. If any recorded value is non-finite, + * the sum will be non-finite: + * + *

      + * + *
    • If any recorded value is a NaN, then the final sum will be + * NaN. + * + *
    • If the recorded values contain one or more infinities, the + * sum will be infinite or NaN. + * + *
        + * + *
      • If the recorded values contain infinities of opposite sign, + * the sum will be NaN. + * + *
      • If the recorded values contain infinities of one sign and + * an intermediate sum overflows to an infinity of the opposite + * sign, the sum may be NaN. + * + *
      + * + *
    + * + * It is possible for intermediate sums of finite values to + * overflow into opposite-signed infinities; if that occurs, the + * final sum will be NaN even if the recorded values are all + * finite. + * + * If all the recorded values are zero, the sign of zero is + * not guaranteed to be preserved in the final sum. + * * @apiNote Values sorted by increasing absolute magnitude tend to yield * more accurate results. * @@ -193,15 +228,9 @@ public class DoubleSummaryStatistics implements DoubleConsumer { * Returns the arithmetic mean of values recorded, or zero if no * values have been recorded. * - * If any recorded value is a NaN or the sum is at any point a NaN - * then the average will be code NaN. - * - *

    The average returned can vary depending upon the order in - * which values are recorded. - * - * This method may be implemented using compensated summation or - * other technique to reduce the error bound in the {@link #getSum - * numerical sum} used to compute the average. + *

    The computed average can vary numerically and have the + * special case behavior as computing the sum; see {@link #getSum} + * for details. * * @apiNote Values sorted by increasing absolute magnitude tend to yield * more accurate results. diff --git a/jdk/src/share/classes/java/util/UUID.java b/jdk/src/share/classes/java/util/UUID.java index b4ea41ff061..11e024678e0 100644 --- a/jdk/src/share/classes/java/util/UUID.java +++ b/jdk/src/share/classes/java/util/UUID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,9 @@ package java.util; import java.security.*; +import sun.misc.JavaLangAccess; +import sun.misc.SharedSecrets; + /** * A class that represents an immutable universally unique identifier (UUID). * A UUID represents a 128-bit value. @@ -88,6 +91,8 @@ public final class UUID implements java.io.Serializable, Comparable { */ private final long leastSigBits; + private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); + /* * The random number generator used by this class to create random * based UUIDs. In a holder class to defer initialization until needed. @@ -189,21 +194,35 @@ public final class UUID implements java.io.Serializable, Comparable { * */ public static UUID fromString(String name) { - String[] components = name.split("-"); - if (components.length != 5) - throw new IllegalArgumentException("Invalid UUID string: "+name); - for (int i=0; i<5; i++) - components[i] = "0x"+components[i]; + if (name.length() > 36) { + throw new IllegalArgumentException("UUID string too large"); + } - long mostSigBits = Long.decode(components[0]).longValue(); - mostSigBits <<= 16; - mostSigBits |= Long.decode(components[1]).longValue(); - mostSigBits <<= 16; - mostSigBits |= Long.decode(components[2]).longValue(); + int dash1 = name.indexOf('-', 0); + int dash2 = name.indexOf('-', dash1 + 1); + int dash3 = name.indexOf('-', dash2 + 1); + int dash4 = name.indexOf('-', dash3 + 1); + int dash5 = name.indexOf('-', dash4 + 1); - long leastSigBits = Long.decode(components[3]).longValue(); + // For any valid input, dash1 through dash4 will be positive and dash5 + // negative, but it's enough to check dash4 and dash5: + // - if dash1 is -1, dash4 will be -1 + // - if dash1 is positive but dash2 is -1, dash4 will be -1 + // - if dash1 and dash2 is positive, dash3 will be -1, dash4 will be + // positive, but so will dash5 + if (dash4 < 0 || dash5 >= 0) { + throw new IllegalArgumentException("Invalid UUID string: " + name); + } + + long mostSigBits = Long.parseLong(name, 16, 0, dash1) & 0xffffffffL; + mostSigBits <<= 16; + mostSigBits |= Long.parseLong(name, 16, dash1 + 1, dash2) & 0xffffL; + mostSigBits <<= 16; + mostSigBits |= Long.parseLong(name, 16, dash2 + 1, dash3) & 0xffffL; + + long leastSigBits = Long.parseLong(name, 16, dash3 + 1, dash4) & 0xffffL; leastSigBits <<= 48; - leastSigBits |= Long.decode(components[4]).longValue(); + leastSigBits |= Long.parseLong(name, 16, dash4 + 1) & 0xffffffffffffL; return new UUID(mostSigBits, leastSigBits); } @@ -373,17 +392,17 @@ public final class UUID implements java.io.Serializable, Comparable { * @return A string representation of this {@code UUID} */ public String toString() { - return (digits(mostSigBits >> 32, 8) + "-" + - digits(mostSigBits >> 16, 4) + "-" + - digits(mostSigBits, 4) + "-" + - digits(leastSigBits >> 48, 4) + "-" + - digits(leastSigBits, 12)); - } - - /** Returns val represented by the specified number of hex digits. */ - private static String digits(long val, int digits) { - long hi = 1L << (digits * 4); - return Long.toHexString(hi | (val & (hi - 1))).substring(1); + char[] chars = new char[36]; + jla.formatUnsignedLong(mostSigBits >> 32, 4, chars, 0, 8); + chars[8] = '-'; + jla.formatUnsignedLong(mostSigBits >> 16, 4, chars, 9, 4); + chars[13] = '-'; + jla.formatUnsignedLong(mostSigBits, 4, chars, 14, 4); + chars[18] = '-'; + jla.formatUnsignedLong(leastSigBits >> 48, 4, chars, 19, 4); + chars[23] = '-'; + jla.formatUnsignedLong(leastSigBits, 4, chars, 24, 12); + return jla.newStringUnsafe(chars); } /** diff --git a/jdk/src/share/classes/java/util/package.html b/jdk/src/share/classes/java/util/package.html index abcf84bef43..eb77a146b0f 100644 --- a/jdk/src/share/classes/java/util/package.html +++ b/jdk/src/share/classes/java/util/package.html @@ -43,7 +43,7 @@ classes (a string tokenizer, a random-number generator, and a bit array).

    Related Documentation

    For overviews, tutorials, examples, guides, and tool documentation, please see:

    - + +

    By default the GIF writer plug-in creates version "89a" images. This can be changed to "87a" by explicitly setting the version in the diff --git a/jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java b/jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java index f4d17c2b427..54fb8f46745 100644 --- a/jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java +++ b/jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java @@ -170,7 +170,7 @@ class PartialOrderIterator implements Iterator { while (iter.hasNext()) { DigraphNode node = iter.next(); int inDegree = node.getInDegree(); - inDegrees.put(node, new Integer(inDegree)); + inDegrees.put(node, inDegree); // Add nodes with zero in-degree to the zero list if (inDegree == 0) { @@ -191,7 +191,7 @@ class PartialOrderIterator implements Iterator { while (outNodes.hasNext()) { DigraphNode node = outNodes.next(); int inDegree = inDegrees.get(node).intValue() - 1; - inDegrees.put(node, new Integer(inDegree)); + inDegrees.put(node, inDegree); // If the in-degree has fallen to 0, place the node on the list if (inDegree == 0) { diff --git a/jdk/src/share/classes/javax/naming/Context.java b/jdk/src/share/classes/javax/naming/Context.java index db2acbde8d3..3f1b759b424 100644 --- a/jdk/src/share/classes/javax/naming/Context.java +++ b/jdk/src/share/classes/javax/naming/Context.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -203,9 +203,7 @@ import java.util.Hashtable; *

    Application Resource Files

    * * When an application is deployed, it will generally have several - * codebase directories and JARs in its classpath. Similarly, when an - * applet is deployed, it will have a codebase and archives specifying - * where to find the applet's classes. JNDI locates (using + * codebase directories and JARs in its classpath. JNDI locates (using * {@link ClassLoader#getResources ClassLoader.getResources()}) * all application resource files named jndi.properties * in the classpath. @@ -236,7 +234,7 @@ import java.util.Hashtable; * * When JNDI constructs an initial context, the context's environment * is initialized with properties defined in the environment parameter - * passed to the constructor, the system properties, the applet parameters, + * passed to the constructor, the system properties, * and the application resource files. See * InitialContext * for details. @@ -268,8 +266,8 @@ import java.util.Hashtable; *

    * In this way, each service provider developer can specify a list of * factories to use with that service provider. These can be modified by - * the application resources specified by the deployer of the application - * or applet, which in turn can be modified by the user. + * the application resources specified by the deployer of the application, + * which in turn can be modified by the user. * * @author Rosanna Lee * @author Scott Seligman @@ -822,7 +820,7 @@ public interface Context { * of the property should be the fully qualified class name * of the factory class that will create an initial context. * This property may be specified in the environment parameter - * passed to the initial context constructor, an applet parameter, + * passed to the initial context constructor, * a system property, or an application resource file. * If it is not specified in any of these sources, * NoInitialContextException is thrown when an initial @@ -837,7 +835,6 @@ public interface Context { * @see NoInitialContextException * @see #addToEnvironment(String, Object) * @see #removeFromEnvironment(String) - * @see #APPLET */ String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial"; @@ -847,8 +844,8 @@ public interface Context { * of the property should be a colon-separated list of the fully * qualified class names of factory classes that will create an object * given information about the object. - * This property may be specified in the environment, an applet - * parameter, a system property, or one or more resource files. + * This property may be specified in the environment, a system property, + * or one or more resource files. * *

    The value of this constant is "java.naming.factory.object". * @@ -856,7 +853,6 @@ public interface Context { * @see javax.naming.spi.ObjectFactory * @see #addToEnvironment(String, Object) * @see #removeFromEnvironment(String) - * @see #APPLET */ String OBJECT_FACTORIES = "java.naming.factory.object"; @@ -866,8 +862,8 @@ public interface Context { * of the property should be a colon-separated list of the fully * qualified class names of state factory classes that will be used * to get an object's state given the object itself. - * This property may be specified in the environment, an applet - * parameter, a system property, or one or more resource files. + * This property may be specified in the environment, a system property, + * or one or more resource files. * *

    The value of this constant is "java.naming.factory.state". * @@ -875,7 +871,6 @@ public interface Context { * @see javax.naming.spi.StateFactory * @see #addToEnvironment(String, Object) * @see #removeFromEnvironment(String) - * @see #APPLET * @since 1.3 */ String STATE_FACTORIES = "java.naming.factory.state"; @@ -887,9 +882,8 @@ public interface Context { * of the property should be a colon-separated list of package * prefixes for the class name of the factory class that will create * a URL context factory. - * This property may be specified in the environment, - * an applet parameter, a system property, or one or more - * resource files. + * This property may be specified in the environment, a system property, + * or one or more resource files. * The prefix com.sun.jndi.url is always appended to * the possibly empty list of package prefixes. * @@ -900,8 +894,7 @@ public interface Context { * @see javax.naming.spi.ObjectFactory * @see #addToEnvironment(String, Object) * @see #removeFromEnvironment(String) - * @see #APPLET - */ + */ String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs"; /** @@ -909,8 +902,8 @@ public interface Context { * for specifying configuration information for the service provider * to use. The value of the property should contain a URL string * (e.g. "ldap://somehost:389"). - * This property may be specified in the environment, - * an applet parameter, a system property, or a resource file. + * This property may be specified in the environment, a system property, + * or a resource file. * If it is not specified in any of these sources, * the default configuration is determined by the service provider. * @@ -918,7 +911,6 @@ public interface Context { * * @see #addToEnvironment(String, Object) * @see #removeFromEnvironment(String) - * @see #APPLET */ String PROVIDER_URL = "java.naming.provider.url"; @@ -926,8 +918,8 @@ public interface Context { * Constant that holds the name of the environment property * for specifying the DNS host and domain names to use for the * JNDI URL context (for example, "dns://somehost/wiz.com"). - * This property may be specified in the environment, - * an applet parameter, a system property, or a resource file. + * This property may be specified in the environment, a system property, + * or a resource file. * If it is not specified in any of these sources * and the program attempts to use a JNDI URL containing a DNS name, * a ConfigurationException will be thrown. @@ -1073,27 +1065,25 @@ public interface Context { String LANGUAGE = "java.naming.language"; /** - * Constant that holds the name of the environment property for - * specifying an applet for the initial context constructor to use - * when searching for other properties. - * The value of this property is the - * java.applet.Applet instance that is being executed. - * This property may be specified in the environment parameter - * passed to the initial context constructor. - * When this property is set, each property that the initial context - * constructor looks for in the system properties is first looked for - * in the applet's parameter list. - * If this property is unspecified, the initial context constructor - * will search for properties only in the environment parameter - * passed to it, the system properties, and application resource files. + * @deprecated An environment property with this name is ignored + * while constructing an initial context. + * This constant was originally used as a property name to specify an + * {@code Applet} to retrieve parameters from, when creating an initial + * context. Currently any applet properties that need to be passed to an + * initial context should be copied into the environment hashtable: + *

    {@code
    +     *     Hashtable env = new Hashtable();
    +     *     env.put(Context.INITIAL_CONTEXT_FACTORY,
    +     *       ((Applet) this).getParameter(Context.INITIAL_CONTEXT_FACTORY));
    +     *     env.put(Context.PROVIDER_URL,
    +     *       ((Applet) this).getParameter(Context.PROVIDER_URL));
    +     *     // ... other properties ...
          *
    -     * 

    The value of this constant is "java.naming.applet". - * - * @see #addToEnvironment(String, Object) - * @see #removeFromEnvironment(String) - * @see InitialContext + * Context ctx = new InitialContext(env); + * }

    * * @since 1.3 */ + @Deprecated String APPLET = "java.naming.applet"; }; diff --git a/jdk/src/share/classes/javax/naming/InitialContext.java b/jdk/src/share/classes/javax/naming/InitialContext.java index 867af4ca598..8a9792dd3b4 100644 --- a/jdk/src/share/classes/javax/naming/InitialContext.java +++ b/jdk/src/share/classes/javax/naming/InitialContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,21 +41,13 @@ import com.sun.naming.internal.ResourceManager; * is initialized with properties defined in the environment parameter * passed to the constructor, and in any * application resource files. - * In addition, a small number of standard JNDI properties may - * be specified as system properties or as applet parameters - * (through the use of {@link Context#APPLET}). - * These special properties are listed in the field detail sections of the - * Context and - * LdapContext - * interface documentation. *

    * JNDI determines each property's value by merging * the values from the following two sources, in order: *

      *
    1. * The first occurrence of the property from the constructor's - * environment parameter and (for appropriate properties) the applet - * parameters and system properties. + * environment parameter and system properties. *
    2. * The application resource files (jndi.properties). *
    diff --git a/jdk/src/share/classes/javax/naming/directory/DirContext.java b/jdk/src/share/classes/javax/naming/directory/DirContext.java index 903ccbea421..2b77486673a 100644 --- a/jdk/src/share/classes/javax/naming/directory/DirContext.java +++ b/jdk/src/share/classes/javax/naming/directory/DirContext.java @@ -723,7 +723,7 @@ public interface DirContext extends Context { * specified set of attributes. * This method returns all the attributes of such objects. * It is equivalent to supplying null as - * the atributesToReturn parameter to the method + * the attributesToReturn parameter to the method * search(Name, Attributes, String[]). *
    * See {@link #search(Name, Attributes, String[])} for a full description. diff --git a/jdk/src/share/classes/javax/naming/ldap/LdapContext.java b/jdk/src/share/classes/javax/naming/ldap/LdapContext.java index 05db4a8648b..d70b865790e 100644 --- a/jdk/src/share/classes/javax/naming/ldap/LdapContext.java +++ b/jdk/src/share/classes/javax/naming/ldap/LdapContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -334,8 +334,8 @@ public interface LdapContext extends DirContext { * qualified class names of factory classes that will create a control * given another control. See * ControlFactory.getControlInstance() for details. - * This property may be specified in the environment, an applet - * parameter, a system property, or one or more resource files. + * This property may be specified in the environment, a system property, + * or one or more resource files. *

    * The value of this constant is "java.naming.factory.control". * diff --git a/jdk/src/share/classes/javax/naming/ldap/Rdn.java b/jdk/src/share/classes/javax/naming/ldap/Rdn.java index d688e11baf8..dc001705bdd 100644 --- a/jdk/src/share/classes/javax/naming/ldap/Rdn.java +++ b/jdk/src/share/classes/javax/naming/ldap/Rdn.java @@ -421,7 +421,7 @@ public class Rdn implements Serializable, Comparable { private String type; private Object value; - // If non-null, a cannonical representation of the value suitable + // If non-null, a canonical representation of the value suitable // for comparison using String.compareTo() private String comparable = null; @@ -571,10 +571,10 @@ public class Rdn implements Serializable, Comparable { } /** - * Given an attribute value string formated according to the rules + * Given an attribute value string formatted according to the rules * specified in * RFC 2253, - * returns the unformated value. Escapes and quotes are + * returns the unformatted value. Escapes and quotes are * stripped away, and hex-encoded UTF-8 is converted to equivalent * UTF-16 characters. Returns a string value as a String, and a * binary value as a byte array. diff --git a/jdk/src/share/classes/javax/naming/ldap/SortControl.java b/jdk/src/share/classes/javax/naming/ldap/SortControl.java index b7420b987ec..aaeb7a17ad9 100644 --- a/jdk/src/share/classes/javax/naming/ldap/SortControl.java +++ b/jdk/src/share/classes/javax/naming/ldap/SortControl.java @@ -188,7 +188,7 @@ final public class SortControl extends BasicControl { /* * Encodes the sort control's value using ASN.1 BER. * The result includes the BER tag and length for the control's value but - * does not include the control's object identifer and criticality setting. + * does not include the control's object identifier and criticality setting. * * @param sortKeys A non-null list of keys to sort by. * @return A possibly null byte array representing the ASN.1 BER encoded diff --git a/jdk/src/share/classes/javax/naming/spi/NamingManager.java b/jdk/src/share/classes/javax/naming/spi/NamingManager.java index c6a99ec4c3e..6bb98ddc0ee 100644 --- a/jdk/src/share/classes/javax/naming/spi/NamingManager.java +++ b/jdk/src/share/classes/javax/naming/spi/NamingManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -491,7 +491,7 @@ public class NamingManager { * (e.g. "ftpURLContextFactory" for the "ftp" scheme-id), * in the package specified as follows. * The Context.URL_PKG_PREFIXES environment property (which - * may contain values taken from applet parameters, system properties, + * may contain values taken from system properties, * or application resource files) * contains a colon-separated list of package prefixes. * Each package prefix in @@ -661,8 +661,7 @@ public class NamingManager { if (className == null) { NoInitialContextException ne = new NoInitialContextException( "Need to specify class name in environment or system " + - "property, or as an applet parameter, or in an " + - "application resource file: " + + "property, or in an application resource file: " + Context.INITIAL_CONTEXT_FACTORY); throw ne; } diff --git a/jdk/src/share/classes/javax/print/Doc.java b/jdk/src/share/classes/javax/print/Doc.java index d28a3e565ef..873aac594a6 100644 --- a/jdk/src/share/classes/javax/print/Doc.java +++ b/jdk/src/share/classes/javax/print/Doc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -168,7 +168,7 @@ public interface Doc { * from the print data representation object. * However, if the print data representation object is itself a Reader, * then the print data representation object is simply returned. - *

    + * * @return Reader for reading the print data characters from this doc. * If a reader cannot be provided because this doc does not meet * the criteria stated above, null is returned. @@ -192,7 +192,7 @@ public interface Doc { * object as a stream of bytes is created and returned. However, if the * print data representation object is itself an input stream, then the * print data representation object is simply returned. - *

    + * * @return Input stream for reading the print data bytes from this doc. If * an input stream cannot be provided because this doc does not * meet the criteria stated above, null is returned. diff --git a/jdk/src/share/classes/javax/print/DocFlavor.java b/jdk/src/share/classes/javax/print/DocFlavor.java index eac9d38954d..cb00e00753b 100644 --- a/jdk/src/share/classes/javax/print/DocFlavor.java +++ b/jdk/src/share/classes/javax/print/DocFlavor.java @@ -381,7 +381,6 @@ import java.io.Serializable; *

  • * A line feed (LF) character standing by itself means * "go to column 1 of the next line." - *
  • * *

    * The client must itself perform all plain text print data formatting not @@ -436,7 +435,6 @@ import java.io.Serializable; * Java Print Service instance supports without having * to load the representation classes, which may be problematic for * limited-resource clients. - *

    * * @author Alan Kaminsky */ @@ -536,7 +534,7 @@ public class DocFlavor implements Serializable, Cloneable { * The charset for text types is a commonly useful example. * This convenience method will return the value of the specified * parameter if one was specified in the mime type for this flavor. - *

    + * * @param paramName the name of the paramater. This name is internally * converted to the canonical lower case format before performing * the match. @@ -638,7 +636,6 @@ public class DocFlavor implements Serializable, Cloneable { * Class DocFlavor.BYTE_ARRAY provides predefined static constant * DocFlavor objects for example doc flavors using a byte array * (byte[]) as the print data representation class. - *

    * * @author Alan Kaminsky */ @@ -836,7 +833,6 @@ public class DocFlavor implements Serializable, Cloneable { * DocFlavor objects for example doc flavors using a byte stream ({@link * java.io.InputStream java.io.InputStream}) as the print * data representation class. - *

    * * @author Alan Kaminsky */ @@ -1038,8 +1034,7 @@ public class DocFlavor implements Serializable, Cloneable { * objects. * For example doc flavors using a Uniform Resource Locator ({@link * java.net.URL java.net.URL}) as the print data - * representation class. - *

    + * representation class. * * @author Alan Kaminsky */ @@ -1229,7 +1224,6 @@ public class DocFlavor implements Serializable, Cloneable { * DocFlavor objects for example doc flavors using a character array * (char[]) as the print data representation class. As such, * the character set is Unicode. - *

    * * @author Alan Kaminsky */ @@ -1279,7 +1273,6 @@ public class DocFlavor implements Serializable, Cloneable { * objects for example doc flavors using a string ({@link java.lang.String * java.lang.String}) as the print data representation class. * As such, the character set is Unicode. - *

    * * @author Alan Kaminsky */ @@ -1327,7 +1320,6 @@ public class DocFlavor implements Serializable, Cloneable { * objects for example doc flavors using a character stream ({@link * java.io.Reader java.io.Reader}) as the print data * representation class. As such, the character set is Unicode. - *

    * * @author Alan Kaminsky */ @@ -1376,7 +1368,6 @@ public class DocFlavor implements Serializable, Cloneable { * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant * DocFlavor objects for example doc flavors for service formatted print * data. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/PrintService.java b/jdk/src/share/classes/javax/print/PrintService.java index f52eb72a0d2..a003e730880 100644 --- a/jdk/src/share/classes/javax/print/PrintService.java +++ b/jdk/src/share/classes/javax/print/PrintService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -327,7 +327,6 @@ public interface PrintService { * that indicates bounds on the legal values -- used, for example, by an * integer-valued attribute that must lie within a certain range. * - *

    * * @param category Printing attribute category to test. It must be a * {@link java.lang.Class Class} that implements diff --git a/jdk/src/share/classes/javax/print/PrintServiceLookup.java b/jdk/src/share/classes/javax/print/PrintServiceLookup.java index aece5d1205a..70695a995f8 100644 --- a/jdk/src/share/classes/javax/print/PrintServiceLookup.java +++ b/jdk/src/share/classes/javax/print/PrintServiceLookup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -199,7 +199,6 @@ public abstract class PrintServiceLookup { * available that is not part of the installation. * If the lookup service is already registered, or cannot be registered, * the method returns false. - *

    * * @param sp an implementation of a lookup service. * @return true if the new lookup service is newly @@ -305,7 +304,6 @@ public abstract class PrintServiceLookup { *

    * Locates MultiDoc print services which can be positively confirmed * to support the combination of attributes and DocFlavors specified. - *

    * * @param flavors of documents required. If null or empty it is ignored. * @param attributes required to be supported. If null this diff --git a/jdk/src/share/classes/javax/print/ServiceUI.java b/jdk/src/share/classes/javax/print/ServiceUI.java index 20b23611ed1..c6ba370a064 100644 --- a/jdk/src/share/classes/javax/print/ServiceUI.java +++ b/jdk/src/share/classes/javax/print/ServiceUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,8 +131,7 @@ public class ServiceUI { * } * } * } - *

    - + * * @param gc used to select screen. null means primary or default screen. * @param x location of dialog including border in screen coordinates * @param y location of dialog including border in screen coordinates diff --git a/jdk/src/share/classes/javax/print/ServiceUIFactory.java b/jdk/src/share/classes/javax/print/ServiceUIFactory.java index d293a8cadc7..06deb02e5e8 100644 --- a/jdk/src/share/classes/javax/print/ServiceUIFactory.java +++ b/jdk/src/share/classes/javax/print/ServiceUIFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,7 +111,7 @@ public abstract class ServiceUIFactory { /** * Get a UI object which may be cast to the requested UI type * by the application and used in its user interface. - *

    + * * @param role requested. Must be one of the standard roles or * a private role supported by this factory. * @param ui type in which the role is requested. diff --git a/jdk/src/share/classes/javax/print/SimpleDoc.java b/jdk/src/share/classes/javax/print/SimpleDoc.java index 3cf0d779086..f73d794f76b 100644 --- a/jdk/src/share/classes/javax/print/SimpleDoc.java +++ b/jdk/src/share/classes/javax/print/SimpleDoc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -176,7 +176,7 @@ public final class SimpleDoc implements Doc { * However, if the print data representation object is itself a * Reader then the print data representation object is * simply returned. - *

    + * * @return a Reader for reading the print data * characters from this doc. * If a reader cannot be provided because this doc does not meet @@ -224,7 +224,7 @@ public final class SimpleDoc implements Doc { * However, if the print data representation object is itself an * input stream then the print data representation object is simply * returned. - *

    + * * @return an InputStream for reading the print data * bytes from this doc. If an input stream cannot be * provided because this doc does not meet diff --git a/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java b/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java index dfa91a70fcb..f1f7f28c410 100644 --- a/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java +++ b/jdk/src/share/classes/javax/print/StreamPrintServiceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ public abstract class StreamPrintServiceFactory { * Although null is an acceptable value to use in the lookup of stream * printing services, it's typical to search for a particular * desired format, such as Postscript(TM). - *

    + * * @param flavor of the input document type - null means match all * types. * @param outputMimeType representing the required output format, used to @@ -153,7 +153,7 @@ public abstract class StreamPrintServiceFactory { * Implementations which allocate resources on construction should examine * the stream and may wish to only allocate resources if the stream is * non-null. - *

    + * * @param out destination stream for generated output. * @return a PrintService which will generate the format specified by the * DocFlavor supported by this Factory. diff --git a/jdk/src/share/classes/javax/print/attribute/Attribute.java b/jdk/src/share/classes/javax/print/attribute/Attribute.java index 5226f9cb80d..a6c58e6f933 100644 --- a/jdk/src/share/classes/javax/print/attribute/Attribute.java +++ b/jdk/src/share/classes/javax/print/attribute/Attribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import java.io.Serializable; * Interface Attribute is the base interface implemented by any and every * printing attribute class to indicate that the class represents a * printing attribute. All printing attributes are serializable. - *

    * * @author David Mendenhall * @author Alan Kaminsky diff --git a/jdk/src/share/classes/javax/print/attribute/DateTimeSyntax.java b/jdk/src/share/classes/javax/print/attribute/DateTimeSyntax.java index d78c8f2004a..72e583a0347 100644 --- a/jdk/src/share/classes/javax/print/attribute/DateTimeSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/DateTimeSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,6 @@ import java.util.Date; * rather than a java.util.Calendar because it typically takes * less memory to store and less time to compare a java.util.Date * than a java.util.Calendar. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/DocAttribute.java b/jdk/src/share/classes/javax/print/attribute/DocAttribute.java index e99c09d6bcb..994208f0a9e 100644 --- a/jdk/src/share/classes/javax/print/attribute/DocAttribute.java +++ b/jdk/src/share/classes/javax/print/attribute/DocAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ package javax.print.attribute; * PrintRequestAttribute} as well as DocAttribute, the client may include the * attribute in a attribute set which specifies a print job * to specify a characteristic for all the docs in that job. - *

    * * @see DocAttributeSet * @see PrintRequestAttributeSet diff --git a/jdk/src/share/classes/javax/print/attribute/DocAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/DocAttributeSet.java index b4482d2e455..bacc1074f2c 100644 --- a/jdk/src/share/classes/javax/print/attribute/DocAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/DocAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ package javax.print.attribute; * The {@link #add(Attribute) add(Attribute)}, and * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations * are respecified below to guarantee this additional invariant. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/EnumSyntax.java b/jdk/src/share/classes/javax/print/attribute/EnumSyntax.java index 85ee7d8b402..f774066e592 100644 --- a/jdk/src/share/classes/javax/print/attribute/EnumSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/EnumSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,6 @@ import java.io.Serializable; * uses some of the same integer values as the superclass. However, the * application in which the enumeration class and subclass are used may need to * have distinct integer values in the superclass and subclass. - *

    * * @author David Mendenhall * @author Alan Kaminsky diff --git a/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java index 7956794d304..e4928a8196d 100644 --- a/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/HashAttributeSet.java @@ -34,7 +34,6 @@ import java.util.HashMap; /** * Class HashAttributeSet provides an AttributeSet * implementation with characteristics of a hash map. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/HashDocAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/HashDocAttributeSet.java index d4bc20e27d3..0b915ba2ca9 100644 --- a/jdk/src/share/classes/javax/print/attribute/HashDocAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/HashDocAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.io.Serializable; * inherits its implementation from class {@link HashAttributeSet * HashAttributeSet} and enforces the semantic restrictions of interface {@link * DocAttributeSet DocAttributeSet}. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java index 980693694e6..f39c85883d5 100644 --- a/jdk/src/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.io.Serializable; * which inherits its implementation from class {@link HashAttributeSet * HashAttributeSet} and enforces the semantic restrictions of interface * {@link PrintJobAttributeSet PrintJobAttributeSet}. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java index 53708f0259c..fde4ebb6945 100644 --- a/jdk/src/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.io.Serializable; * class {@link HashAttributeSet HashAttributeSet} and enforces the * semantic restrictions of interface * {@link PrintRequestAttributeSet PrintRequestAttributeSet}. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java index 64e5b9e48f3..d98430d0d75 100644 --- a/jdk/src/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,6 @@ import java.io.Serializable; * which inherits its implementation from class {@link HashAttributeSet * HashAttributeSet} and enforces the semantic restrictions of interface * {@link PrintServiceAttributeSet PrintServiceAttributeSet}. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/IntegerSyntax.java b/jdk/src/share/classes/javax/print/attribute/IntegerSyntax.java index 7675a8327e7..1fbd3b2556d 100644 --- a/jdk/src/share/classes/javax/print/attribute/IntegerSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/IntegerSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ import java.io.Serializable; * established when it is constructed (see {@link #IntegerSyntax(int) * IntegerSyntax(int)}). Once constructed, an integer attribute's * value is immutable. - *

    * * @author David Mendenhall * @author Alan Kaminsky diff --git a/jdk/src/share/classes/javax/print/attribute/PrintJobAttribute.java b/jdk/src/share/classes/javax/print/attribute/PrintJobAttribute.java index af8258090ba..ad9a0d7217a 100644 --- a/jdk/src/share/classes/javax/print/attribute/PrintJobAttribute.java +++ b/jdk/src/share/classes/javax/print/attribute/PrintJobAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ package javax.print.attribute; * PrintRequestAttribute PrintRequestAttribute} as well as PrintJobAttribute, * the client may include the attribute in a attribute set to * specify the attribute's value for the Print Job. - *

    * * @see PrintRequestAttributeSet * @see PrintJobAttributeSet diff --git a/jdk/src/share/classes/javax/print/attribute/PrintJobAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/PrintJobAttributeSet.java index 5bce73513e9..4c920a1b48a 100644 --- a/jdk/src/share/classes/javax/print/attribute/PrintJobAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/PrintJobAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ package javax.print.attribute; * The {@link #add(Attribute) add(Attribute)}, and * {@link #addAll(AttributeSet) >addAll(AttributeSet)} operations * are respecified below to guarantee this additional invariant. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/PrintRequestAttribute.java b/jdk/src/share/classes/javax/print/attribute/PrintRequestAttribute.java index 78fe37ccb76..48249480e60 100644 --- a/jdk/src/share/classes/javax/print/attribute/PrintRequestAttribute.java +++ b/jdk/src/share/classes/javax/print/attribute/PrintRequestAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ package javax.print.attribute; * as well as PrintRequestAttribute, the client may include the * attribute in a Doc}'s attribute set to specify * a job setting which pertains just to that doc. - *

    * * @see DocAttributeSet * @see PrintRequestAttributeSet diff --git a/jdk/src/share/classes/javax/print/attribute/PrintRequestAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/PrintRequestAttributeSet.java index eac683b194c..bde6c0cce8b 100644 --- a/jdk/src/share/classes/javax/print/attribute/PrintRequestAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/PrintRequestAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ package javax.print.attribute; * The {@link #add(Attribute) add(Attribute)}, and * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations * are respecified below to guarantee this additional invariant. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/PrintServiceAttribute.java b/jdk/src/share/classes/javax/print/attribute/PrintServiceAttribute.java index 8ac2b656d18..f09b38870ed 100644 --- a/jdk/src/share/classes/javax/print/attribute/PrintServiceAttribute.java +++ b/jdk/src/share/classes/javax/print/attribute/PrintServiceAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ package javax.print.attribute; * of a Print Service or some other characteristic of a Print Service. A Print * Service instance adds a number of PrintServiceAttributes to a Print * service's attribute set to report the Print Service's status. - *

    * * @see PrintServiceAttributeSet * diff --git a/jdk/src/share/classes/javax/print/attribute/PrintServiceAttributeSet.java b/jdk/src/share/classes/javax/print/attribute/PrintServiceAttributeSet.java index badde734218..3d3296ed405 100644 --- a/jdk/src/share/classes/javax/print/attribute/PrintServiceAttributeSet.java +++ b/jdk/src/share/classes/javax/print/attribute/PrintServiceAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,6 @@ package javax.print.attribute; * The {@link #add(Attribute) add(Attribute)}, and * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations * are respecified below to guarantee this additional invariant. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java b/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java index 1089381d1c6..7e9c40835b5 100644 --- a/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/ResolutionSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,6 @@ import java.io.Serializable; * mind, there is no guarantee that the conversion factor for the client's units * will be an exact integer. If the conversion factor isn't an exact integer, * resolution values in the client's units won't be stored precisely. - *

    * * @author David Mendenhall * @author Alan Kaminsky diff --git a/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java b/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java index 0aed773fe6e..8ba9303135a 100644 --- a/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/SetOfIntegerSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,6 @@ import java.util.Vector; * Class SetOfIntegerSyntax has operations to return the set's members in * canonical array form, to test whether a given integer is a member of the * set, and to iterate through the members of the set. - *

    * * @author David Mendenhall * @author Alan Kaminsky diff --git a/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java b/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java index 0f6a5dfe6c4..76832508c94 100644 --- a/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/Size2DSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,6 @@ import java.io.Serializable; * client's units will be an exact integer. If the conversion factor isn't an * exact integer, resolution values in the client's units won't be stored * precisely. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/SupportedValuesAttribute.java b/jdk/src/share/classes/javax/print/attribute/SupportedValuesAttribute.java index 61e4bd57e62..ca8736b1315 100644 --- a/jdk/src/share/classes/javax/print/attribute/SupportedValuesAttribute.java +++ b/jdk/src/share/classes/javax/print/attribute/SupportedValuesAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ package javax.print.attribute; * which is a SupportedValuesAttribute giving the legal values a client may * specify for the {@link javax.print.attribute.standard.Copies Copies} * attribute. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/TextSyntax.java b/jdk/src/share/classes/javax/print/attribute/TextSyntax.java index 20e27fa314f..7b91de24d0f 100644 --- a/jdk/src/share/classes/javax/print/attribute/TextSyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/TextSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import java.util.Locale; * includes a locale to indicate the natural language. Thus, a text attribute * always represents a localized string. Once constructed, a text attribute's * value is immutable. - *

    * * @author David Mendenhall * @author Alan Kaminsky diff --git a/jdk/src/share/classes/javax/print/attribute/URISyntax.java b/jdk/src/share/classes/javax/print/attribute/URISyntax.java index 118b1c0cd8d..770ba8a9592 100644 --- a/jdk/src/share/classes/javax/print/attribute/URISyntax.java +++ b/jdk/src/share/classes/javax/print/attribute/URISyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.net.URI; * Class URISyntax is an abstract base class providing the common * implementation of all attributes whose value is a Uniform Resource * Identifier (URI). Once constructed, a URI attribute's value is immutable. - *

    * * @author Alan Kaminsky */ diff --git a/jdk/src/share/classes/javax/print/attribute/package.html b/jdk/src/share/classes/javax/print/attribute/package.html index fa9851655a8..aeedb0df2c2 100644 --- a/jdk/src/share/classes/javax/print/attribute/package.html +++ b/jdk/src/share/classes/javax/print/attribute/package.html @@ -3,7 +3,7 @@ javax.print.attribute package - + + service.provider="crules.CodingRulesAnalyzerPlugin"/> + + + + + plugin.options="-J-Xbootclasspath/a:${build.toolclasses.dir}/crules.jar -Xplugin:coding_rules" /> @@ -1157,7 +1171,7 @@ samevm="@{samevm}" verbose="@{verbose}" failonerror="false" resultproperty="jtreg.@{name}.result" javacoptions="-g" - vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}${build.classes.dir} @{jpda.jvmargs}"> + vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}${build.classes.dir} @{jpda.jvmargs} @{extra.jvmargs}"> diff --git a/langtools/make/intellij/ant.xml b/langtools/make/intellij/ant.xml index dee4939b60c..46b15c2941e 100644 --- a/langtools/make/intellij/ant.xml +++ b/langtools/make/intellij/ant.xml @@ -10,7 +10,7 @@ - + diff --git a/langtools/make/intellij/build.xml b/langtools/make/intellij/build.xml index 24bdb3d4654..ed1db8342df 100644 --- a/langtools/make/intellij/build.xml +++ b/langtools/make/intellij/build.xml @@ -1,18 +1,15 @@ + + + - - - - - - - - - - - @@ -32,5 +29,15 @@ + + + + + + + + + + diff --git a/langtools/make/intellij/codeStyleSettings.xml b/langtools/make/intellij/codeStyleSettings.xml index 076a0fb657c..54942ddbb48 100644 --- a/langtools/make/intellij/codeStyleSettings.xml +++ b/langtools/make/intellij/codeStyleSettings.xml @@ -5,10 +5,14 @@ + +

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +public abstract class Dependencies { + + protected static final Context.Key dependenciesKey = new Context.Key<>(); + + public static Dependencies instance(Context context) { + Dependencies instance = context.get(dependenciesKey); + if (instance == null) { + //use a do-nothing implementation in case no other implementation has been set by preRegister + instance = new DummyDependencies(context); + } + return instance; + } + + Dependencies(Context context) { + context.put(dependenciesKey, this); + } + + /** + * This enum models different kinds of attribution actions triggered during + * symbol completion. + */ + public enum AttributionKind { + /** + * Attribution of superclass (i.e. @{code extends} clause). + */ + EXTENDS { + @Override + String format(JCTree tree) { + return "extends " + super.format(tree); + } + }, + /** + * Attribution of superinterface (i.e. an type in the @{code interface} clause). + */ + IMPLEMENTS { + @Override + String format(JCTree tree) { + return "implements " + super.format(tree); + } + }, + /** + * Attribution of an import statement + */ + IMPORT, + /** + * Attribution of type-variable bound + */ + TVAR { + @Override + String format(JCTree tree) { + return "<" + super.format(tree) + ">"; + } + }; + + String format(JCTree tree) { + return tree.toString(); + } + } + + /** + * Push a new completion node on the stack. + */ + abstract public void push(ClassSymbol s); + + /** + * Push a new attribution node on the stack. + */ + abstract public void push(AttributionKind ak, JCTree t); + + /** + * Remove current dependency node from the stack. + */ + abstract public void pop(); + + /** + * This class creates a graph of all dependencies as symbols are completed; + * when compilation finishes, the resulting dependecy graph is then dumped + * onto a dot file. Several options are provided to customise the output of the graph. + */ + public static class GraphDependencies extends Dependencies implements Closeable, Completer { + + /** + * set of enabled dependencies modes + */ + private EnumSet dependenciesModes; + + /** + * file in which the dependency graph should be written + */ + private String dependenciesFile; + + /** + * Register a Context.Factory to create a Dependencies. + */ + public static void preRegister(final Context context) { + context.put(dependenciesKey, new Context.Factory() { + public Dependencies make(Context c) { + Dependencies deps = new GraphDependencies(context); + return deps; + } + }); + } + + /** + * Build a Dependencies instance. + */ + GraphDependencies(Context context) { + super(context); + Options options = Options.instance(context); + //fetch filename + String[] modes = options.get("completionDeps").split(","); + for (String mode : modes) { + if (mode.startsWith("file=")) { + dependenciesFile = mode.substring(5); + } + } + //parse modes + dependenciesModes = DependenciesMode.getDependenciesModes(modes); + //add to closeables + JavaCompiler compiler = JavaCompiler.instance(context); + compiler.closeables = compiler.closeables.prepend(this); + } + + enum DependenciesMode { + SOURCE("source"), + CLASS("class"), + REDUNDANT("redundant"), + SIDE_EFFECTS("side-effects"); + + final String opt; + + private DependenciesMode(String opt) { + this.opt = opt; + } + + /** + * This method is used to parse the {@code completionDeps} option. + * Possible modes are separated by colon; a mode can be excluded by + * prepending '-' to its name. Finally, the special mode 'all' can be used to + * add all modes to the resulting enum. + */ + static EnumSet getDependenciesModes(String[] modes) { + EnumSet res = EnumSet.noneOf(DependenciesMode.class); + Collection args = Arrays.asList(modes); + if (args.contains("all")) { + res = EnumSet.allOf(DependenciesMode.class); + } + for (DependenciesMode mode : values()) { + if (args.contains(mode.opt)) { + res.add(mode); + } else if (args.contains("-" + mode.opt)) { + res.remove(mode); + } + } + return res; + } + } + + /** + * Class representing a node in the dependency graph. Nodes are of two main + * kinds: (i) symbol nodes, corresponding to symbol completion requests + * (either from source or classfile); (ii) attribution nodes, corresponding to + * attribution actions triggered during (source) completion. + */ + static abstract class Node extends GraphUtils.AbstractNode + implements GraphUtils.DottableNode { + + /** + * Model the dependencies between nodes. + */ + enum DependencyKind implements GraphUtils.DependencyKind { + /** + * standard dependency - i.e. completion of the source node depends + * on completion of the sink node. + */ + REQUIRES("solid"), + /** + * soft dependencies - i.e. completion of the source node depends + * on side-effects of the source node. These dependencies are meant + * to capture the order in which javac processes all dependants of a given node. + */ + SIDE_EFFECTS("dashed"); + + final String dotStyle; + + DependencyKind(String dotStyle) { + this.dotStyle = dotStyle; + } + } + + /** + * dependant nodes grouped by kind + */ + EnumMap> depsByKind; + + Node(String value) { + super(value); + this.depsByKind = new EnumMap<>(DependencyKind.class); + for (DependencyKind depKind : DependencyKind.values()) { + depsByKind.put(depKind, new ArrayList()); + } + } + + void addDependency(DependencyKind depKind, Node dep) { + List deps = depsByKind.get(depKind); + if (!deps.contains(dep)) { + deps.add(dep); + } + } + + @Override + public boolean equals(Object obj) { + return obj instanceof Node && + data.equals(((Node) obj).data); + } + + @Override + public int hashCode() { + return data.hashCode(); + } + + @Override + public GraphUtils.DependencyKind[] getSupportedDependencyKinds() { + return DependencyKind.values(); + } + + @Override + public java.util.Collection getDependenciesByKind(GraphUtils.DependencyKind dk) { + List deps = depsByKind.get(dk); + if (dk == DependencyKind.REQUIRES) { + return deps; + } else { + Set temp = new HashSet<>(deps); + temp.removeAll(depsByKind.get(DependencyKind.REQUIRES)); + return temp; + } + } + + @Override + public Properties nodeAttributes() { + Properties p = new Properties(); + p.put("label", DotVisitor.wrap(toString())); + return p; + } + + @Override + public Properties dependencyAttributes(Node to, GraphUtils.DependencyKind dk) { + Properties p = new Properties(); + p.put("style", ((DependencyKind) dk).dotStyle); + return p; + } + } + + /** + * This is a dependency node used to model symbol completion requests. + * Completion requests can come from either source or class. + */ + static class CompletionNode extends Node { + + /** + * Completion kind (source vs. classfile) + */ + enum Kind { + /** + * Source completion request + */ + SOURCE("solid"), + /** + * Classfile completion request + */ + CLASS("dotted"); + + final String dotStyle; + + Kind(String dotStyle) { + this.dotStyle = dotStyle; + } + } + + final Kind ck; + + CompletionNode(ClassSymbol sym) { + super(sym.getQualifiedName().toString()); + //infer completion kind by looking at the symbol fields + boolean fromClass = (sym.classfile == null && sym.sourcefile == null) || + (sym.classfile != null && sym.classfile.getKind() == JavaFileObject.Kind.CLASS); + ck = fromClass ? + CompletionNode.Kind.CLASS : + CompletionNode.Kind.SOURCE; + } + + @Override + public Properties nodeAttributes() { + Properties p = super.nodeAttributes(); + p.put("style", ck.dotStyle); + p.put("shape", "ellipse"); + return p; + } + } + + /** + * This is a dependency node used to model attribution actions triggered during + * source symbol completion. The possible kinds of attribution actions are + * captured in {@link AttributionNode}. + */ + static class AttributionNode extends Node { + + AttributionNode(AttributionKind ak, JCTree tree) { + super(ak.format(tree)); + } + + @Override + public Properties nodeAttributes() { + Properties p = super.nodeAttributes(); + p.put("shape", "box"); + p.put("style", "solid"); + return p; + } + } + + /** + * stack of dependency nodes currently being processed + */ + Stack nodeStack = new Stack<>(); + + /** + * map containing all dependency nodes seen so far + */ + Map dependencyNodeMap = new LinkedHashMap<>(); + + @Override + public void push(ClassSymbol s) { + Node n = new CompletionNode(s); + if (n == push(n)) { + s.completer = this; + } + } + + @Override + public void push(AttributionKind ak, JCTree t) { + push(new AttributionNode(ak, t)); + } + + /** + * Push a new dependency on the stack. + */ + protected Node push(Node newNode) { + Node cachedNode = dependencyNodeMap.get(newNode.data); + if (cachedNode == null) { + dependencyNodeMap.put(newNode.data, newNode); + } else { + newNode = cachedNode; + } + if (!nodeStack.isEmpty()) { + Node currentNode = nodeStack.peek(); + currentNode.addDependency(Node.DependencyKind.REQUIRES, newNode); + } + nodeStack.push(newNode); + return newNode; + } + + @Override + public void pop() { + nodeStack.pop(); + } + + @Override + public void close() throws IOException { + if (dependenciesFile != null) { + if (!dependenciesModes.contains(DependenciesMode.REDUNDANT)) { + //prune spurious edges + new PruneVisitor().visit(dependencyNodeMap.values(), null); + } + if (!dependenciesModes.contains(DependenciesMode.CLASS)) { + //filter class completions + new FilterVisitor(CompletionNode.Kind.SOURCE).visit(dependencyNodeMap.values(), null); + } + if (!dependenciesModes.contains(DependenciesMode.SOURCE)) { + //filter source completions + new FilterVisitor(CompletionNode.Kind.CLASS).visit(dependencyNodeMap.values(), null); + } + if (dependenciesModes.contains(DependenciesMode.SIDE_EFFECTS)) { + //add side-effects edges + new SideEffectVisitor().visit(dependencyNodeMap.values(), null); + } + //write to file + try (FileWriter fw = new FileWriter(dependenciesFile)) { + fw.append(GraphUtils.toDot(dependencyNodeMap.values(), "CompletionDeps", "")); + } + } + } + + @Override + public void complete(Symbol sym) throws CompletionFailure { + push((ClassSymbol) sym); + pop(); + sym.completer = this; + } + + /** + * This visitor is used to generate the special side-effect dependencies + * given a graph containing only standard dependencies. + */ + private static class SideEffectVisitor extends NodeVisitor { + @Override + public void visitNode(Node node, Void arg) { + //do nothing + } + + @Override + public void visitDependency(GraphUtils.DependencyKind dk, Node from, Node to, Void arg) { + //if we are adding multiple dependencies to same node + //make order explicit via special 'side-effect' dependencies + List deps = from.depsByKind.get(dk); + int pos = deps.indexOf(to); + if (dk == Node.DependencyKind.REQUIRES && pos > 0) { + to.addDependency(Node.DependencyKind.SIDE_EFFECTS, deps.get(pos - 1)); + } + } + } + + /** + * This visitor is used to prune the graph from spurious edges using some heuristics. + */ + private static class PruneVisitor extends NodeVisitor { + @Override + public void visitNode(Node node, Void arg) { + //do nothing + } + + @Override + public void visitDependency(GraphUtils.DependencyKind dk, Node from, Node to, Void arg) { + //heuristic - skips dependencies that are likely to be fake + if (from.equals(to) || + from.depsByKind.get(Node.DependencyKind.REQUIRES).contains(to)) { + to.depsByKind.get(dk).remove(from); + } + } + } + + /** + * This visitor is used to retain only completion nodes with given kind. + */ + private class FilterVisitor extends NodeVisitor { + + CompletionNode.Kind ck; + + private FilterVisitor(CompletionNode.Kind ck) { + this.ck = ck; + } + + @Override + public void visitNode(Node node, Void arg) { + if (node instanceof CompletionNode) { + if (((CompletionNode) node).ck != ck) { + dependencyNodeMap.remove(node.data); + } + } + } + + @Override + public void visitDependency(GraphUtils.DependencyKind dk, Node from, Node to, Void arg) { + if (to instanceof CompletionNode) { + if (((CompletionNode) to).ck != ck) { + from.depsByKind.get(dk).remove(to); + } + } + } + } + } + + /** + * Dummy class to be used when dependencies options are not set. This keeps + * performance cost of calling push/pop methods during completion marginally low. + */ + private static class DummyDependencies extends Dependencies { + + private DummyDependencies(Context context) { + super(context); + } + + @Override + public void push(ClassSymbol s) { + //do nothing + } + + @Override + public void push(AttributionKind ak, JCTree t) { + //do nothing + } + + @Override + public void pop() { + //do nothing + } + } +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java b/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java index f1be519d6c9..b7257bbb8ff 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java @@ -25,6 +25,10 @@ package com.sun.tools.javac.util; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Properties; + /**

    This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or @@ -33,25 +37,65 @@ package com.sun.tools.javac.util; public class GraphUtils { /** - * Basic interface for defining various dependency kinds. All dependency kinds - * must at least support basic capabilities to tell the DOT engine how to render them. + * Basic interface for defining various dependency kinds. */ - public interface DependencyKind { + public interface DependencyKind { } + + /** + * Common superinterfaces to all graph nodes. + */ + public interface Node> { /** - * Returns the DOT representation (to be used in a {@code style} attribute - * that's most suited for this dependency kind. + * visitor method. */ - String getDotStyle(); + void accept(NodeVisitor visitor, A arg); + } + + /** + * Visitor for graph nodes. + */ + static abstract class NodeVisitor, A> { + /** + * Visitor action for nodes. + */ + public abstract void visitNode(N node, A arg); + /** + * Visitor action for a dependency between 'from' and 'to' with given kind. + */ + public abstract void visitDependency(DependencyKind dk, N from, N to, A arg); + + /** + * Visitor entry point. + */ + public void visit(Collection nodes, A arg) { + for (N n : new ArrayList<>(nodes)) { + n.accept(this, arg); + } + } + } + + /** + * Optional interface for nodes supporting dot-based representation. + */ + public interface DottableNode> extends Node { + /** + * Retrieves the set of dot attributes associated with the node. + */ + Properties nodeAttributes(); + /** + * Retrieves the set of dot attributes associated with a given dependency. + */ + Properties dependencyAttributes(N to, DependencyKind dk); } /** * This class is a basic abstract class for representing a node. * A node is associated with a given data. */ - public static abstract class Node { + public static abstract class AbstractNode> implements Node { public final D data; - public Node(D data) { + public AbstractNode(D data) { this.data = data; } @@ -61,26 +105,32 @@ public class GraphUtils { public abstract DependencyKind[] getSupportedDependencyKinds(); /** - * Get all dependencies, regardless of their kind. + * Get all dependencies of a given kind */ - public abstract Iterable> getAllDependencies(); - - /** - * Get a name for the dependency (of given kind) linking this node to a given node - */ - public abstract String getDependencyName(Node to, DependencyKind dk); + public abstract Collection getDependenciesByKind(DependencyKind dk); @Override public String toString() { return data.toString(); } + + @SuppressWarnings("unchecked") + public void accept(NodeVisitor visitor, A arg) { + visitor.visitNode((N)this, arg); + for (DependencyKind dk : getSupportedDependencyKinds()) { + for (N dep : new ArrayList<>(getDependenciesByKind(dk))) { + visitor.visitDependency(dk, (N)this, dep, arg); + } + } + } } /** * This class specialized Node, by adding elements that are required in order * to perform Tarjan computation of strongly connected components. */ - public static abstract class TarjanNode extends Node implements Comparable> { + public static abstract class TarjanNode> extends AbstractNode + implements Comparable { int index = -1; int lowlink; boolean active; @@ -89,11 +139,9 @@ public class GraphUtils { super(data); } - public abstract Iterable> getAllDependencies(); + public abstract Iterable getAllDependencies(); - public abstract Iterable> getDependenciesByKind(DependencyKind dk); - - public int compareTo(TarjanNode o) { + public int compareTo(N o) { return (index < o.index) ? -1 : (index == o.index) ? 0 : 1; } } @@ -102,7 +150,7 @@ public class GraphUtils { * Tarjan's algorithm to determine strongly connected components of a * directed graph in linear time. Works on TarjanNode. */ - public static > List> tarjan(Iterable nodes) { + public static > List> tarjan(Iterable nodes) { ListBuffer> cycles = new ListBuffer<>(); ListBuffer stack = new ListBuffer<>(); int index = 0; @@ -114,15 +162,13 @@ public class GraphUtils { return cycles.toList(); } - private static > int tarjan(N v, int index, ListBuffer stack, ListBuffer> cycles) { + private static > int tarjan(N v, int index, ListBuffer stack, ListBuffer> cycles) { v.index = index; v.lowlink = index; index++; stack.prepend(v); v.active = true; - for (TarjanNode nd: v.getAllDependencies()) { - @SuppressWarnings("unchecked") - N n = (N)nd; + for (N n: v.getAllDependencies()) { if (n.index == -1) { tarjan(n, index, stack, cycles); v.lowlink = Math.min(v.lowlink, n.lowlink); @@ -149,24 +195,45 @@ public class GraphUtils { * and {@code Node.printDependency} to display edge labels. The resulting * representation is also customizable with a graph name and a header. */ - public static String toDot(Iterable> nodes, String name, String header) { + public static > String toDot(Collection nodes, String name, String header) { StringBuilder buf = new StringBuilder(); buf.append(String.format("digraph %s {\n", name)); - buf.append(String.format("label = \"%s\";\n", header)); - //dump nodes - for (TarjanNode n : nodes) { - buf.append(String.format("%s [label = \"%s\"];\n", n.hashCode(), n.toString())); - } - //dump arcs - for (TarjanNode from : nodes) { - for (DependencyKind dk : from.getSupportedDependencyKinds()) { - for (TarjanNode to : from.getDependenciesByKind(dk)) { - buf.append(String.format("%s -> %s [label = \" %s \" style = %s ];\n", - from.hashCode(), to.hashCode(), from.getDependencyName(to, dk), dk.getDotStyle())); - } - } - } + buf.append(String.format("label = %s;\n", DotVisitor.wrap(header))); + DotVisitor dotVisitor = new DotVisitor<>(); + dotVisitor.visit(nodes, buf); buf.append("}\n"); return buf.toString(); } + + /** + * This visitor is used to dump the contents of a set of nodes of type {@link DottableNode} + * onto a string builder. + */ + public static class DotVisitor> extends NodeVisitor { + + @Override + public void visitDependency(DependencyKind dk, N from, N to, StringBuilder buf) { + buf.append(String.format("%s -> %s", from.hashCode(), to.hashCode())); + buf.append(formatProperties(from.dependencyAttributes(to, dk))); + buf.append('\n'); + } + + @Override + public void visitNode(N node, StringBuilder buf) { + buf.append(String.format("%s ", node.hashCode())); + buf.append(formatProperties(node.nodeAttributes())); + buf.append('\n'); + } + + protected String formatProperties(Properties p) { + return p.toString().replaceAll(",", " ") + .replaceAll("\\{", "[") + .replaceAll("\\}", "]"); + } + + protected static String wrap(String s) { + String res = "\"" + s + "\""; + return res.replaceAll("\n", ""); + } + } } diff --git a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java index da520bab6b4..d7f6e374dfd 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java +++ b/langtools/src/share/classes/com/sun/tools/javah/JavahTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor8; +import javax.lang.model.util.SimpleTypeVisitor9; import javax.lang.model.util.Types; import javax.tools.Diagnostic; @@ -738,7 +738,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask { } private TypeVisitor checkMethodParametersVisitor = - new SimpleTypeVisitor8() { + new SimpleTypeVisitor9() { @Override public Void visitArray(ArrayType t, Types types) { visit(t.getComponentType(), types); diff --git a/langtools/src/share/classes/com/sun/tools/javah/LLNI.java b/langtools/src/share/classes/com/sun/tools/javah/LLNI.java index 708ddfce79d..391ea6f457c 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/LLNI.java +++ b/langtools/src/share/classes/com/sun/tools/javah/LLNI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVisitor; import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.SimpleTypeVisitor8; +import javax.lang.model.util.SimpleTypeVisitor9; /* *

    This is NOT part of any supported API. @@ -628,7 +628,7 @@ public class LLNI extends Gen { } protected final boolean isLongOrDouble(TypeMirror t) { - TypeVisitor v = new SimpleTypeVisitor8() { + TypeVisitor v = new SimpleTypeVisitor9() { public Boolean defaultAction(TypeMirror t, Void p){ return false; } diff --git a/langtools/src/share/classes/com/sun/tools/javah/TypeSignature.java b/langtools/src/share/classes/com/sun/tools/javah/TypeSignature.java index d0f22499f5d..d8934d03d0a 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/TypeSignature.java +++ b/langtools/src/share/classes/com/sun/tools/javah/TypeSignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; import javax.lang.model.type.TypeVisitor; import javax.lang.model.util.Elements; -import javax.lang.model.util.SimpleTypeVisitor8; +import javax.lang.model.util.SimpleTypeVisitor9; /** * Returns internal type signature. @@ -248,7 +248,7 @@ public class TypeSignature { String qualifiedTypeName(TypeMirror type) { - TypeVisitor v = new SimpleTypeVisitor8() { + TypeVisitor v = new SimpleTypeVisitor9() { @Override public Name visitArray(ArrayType t, Void p) { return t.getComponentType().accept(this, p); diff --git a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java index e808989ecbe..b7b4e64cf88 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java @@ -575,6 +575,9 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { } reportError("err.ioerror", className, msg); result = EXIT_ERROR; + } catch (OutOfMemoryError e) { + reportError("err.nomem"); + result = EXIT_ERROR; } catch (Throwable t) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); diff --git a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties index 861a676a990..ec87869c75a 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties +++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties @@ -18,6 +18,7 @@ err.unknown.option=unknown option: {0} err.no.SourceFile.attribute=no SourceFile attribute err.source.file.not.found=source file not found err.bad.innerclasses.attribute=bad InnerClasses attribute for {0} +err.nomem=Insufficient memory. To increase memory use -J-Xmx option. main.usage.summary=\ Usage: {0} \n\ diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java index 2833d1258dc..c999c3c58dd 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java @@ -24,8 +24,6 @@ */ package com.sun.tools.jdeps; -import com.sun.tools.classfile.Dependency.Location; -import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -33,6 +31,10 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; + +import com.sun.tools.classfile.Dependency.Location; +import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; /** * Dependency Analyzer. @@ -110,6 +112,13 @@ public class Analyzer { return false; } + public Set dependences(Archive source) { + ArchiveDeps result = results.get(source); + return result.dependencies().stream() + .map(Dep::target) + .collect(Collectors.toSet()); + } + public interface Visitor { /** * Visits a recorded dependency from origin to target which can be diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java index 091703d2a23..621d8108b0a 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -236,6 +236,11 @@ class JdepsTask { task.options.showLabel = true; } }, + new HiddenOption(false, "-q", "-quiet") { + void process(JdepsTask task, String opt, String arg) { + task.options.nowarning = true; + } + }, new HiddenOption(true, "-depth") { void process(JdepsTask task, String opt, String arg) throws BadArgs { try { @@ -320,7 +325,9 @@ class JdepsTask { Analyzer analyzer = new Analyzer(options.verbose, new Analyzer.Filter() { @Override - public boolean accepts(Location origin, Archive originArchive, Location target, Archive targetArchive) { + public boolean accepts(Location origin, Archive originArchive, + Location target, Archive targetArchive) + { if (options.findJDKInternals) { // accepts target that is JDK class but not exported return isJDKArchive(targetArchive) && @@ -344,6 +351,10 @@ class JdepsTask { } else { printRawOutput(log, analyzer); } + + if (options.findJDKInternals && !options.nowarning) { + showReplacements(analyzer); + } return true; } @@ -693,6 +704,7 @@ class JdepsTask { boolean apiOnly; boolean showLabel; boolean findJDKInternals; + boolean nowarning; // default is to show package-level dependencies // and filter references from same package Analyzer.Type verbose = PACKAGE; @@ -709,6 +721,7 @@ class JdepsTask { private static class ResourceBundleHelper { static final ResourceBundle versionRB; static final ResourceBundle bundle; + static final ResourceBundle jdkinternals; static { Locale locale = Locale.getDefault(); @@ -722,6 +735,11 @@ class JdepsTask { } catch (MissingResourceException e) { throw new InternalError("version.resource.missing"); } + try { + jdkinternals = ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdkinternals"); + } catch (MissingResourceException e) { + throw new InternalError("Cannot find jdkinternals resource bundle"); + } } } @@ -928,4 +946,50 @@ class JdepsTask { } return Profile.getProfile(pn); } + + /** + * Returns the recommended replacement API for the given classname; + * or return null if replacement API is not known. + */ + private String replacementFor(String cn) { + String name = cn; + String value = null; + while (value == null && name != null) { + try { + value = ResourceBundleHelper.jdkinternals.getString(name); + } catch (MissingResourceException e) { + // go up one subpackage level + int i = name.lastIndexOf('.'); + name = i > 0 ? name.substring(0, i) : null; + } + } + return value; + }; + + private void showReplacements(Analyzer analyzer) { + Map jdkinternals = new TreeMap<>(); + boolean useInternals = false; + for (Archive source : sourceLocations) { + useInternals = useInternals || analyzer.hasDependences(source); + for (String cn : analyzer.dependences(source)) { + String repl = replacementFor(cn); + if (repl != null) { + jdkinternals.putIfAbsent(cn, repl); + } + } + } + if (useInternals) { + log.println(); + warning("warn.replace.useJDKInternals", getMessage("jdeps.wiki.url")); + } + if (!jdkinternals.isEmpty()) { + log.println(); + log.format("%-40s %s%n", "JDK Internal API", "Suggested Replacement"); + log.format("%-40s %s%n", "----------------", "---------------------"); + for (Map.Entry e : jdkinternals.entrySet()) { + log.format("%-40s %s%n", e.getKey(), e.getValue()); + } + } + + } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties index 7cc433e1f0e..ccd14abe43a 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties +++ b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties @@ -93,5 +93,12 @@ err.profiles.msg=No profile information err.invalid.path=invalid path: {0} warn.invalid.arg=Invalid classname or pathname not exist: {0} warn.split.package=package {0} defined in {1} {2} +warn.replace.useJDKInternals=\ +JDK internal APIs are unsupported and private to JDK implementation that are\n\ +subject to be removed or changed incompatibly and could break your application.\n\ +Please modify your code to eliminate dependency on any JDK internal APIs.\n\ +For the most recent update on JDK internal API replacements, please check:\n\ +{0} artifact.not.found=not found +jdeps.wiki.url=https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties new file mode 100644 index 00000000000..56d7d0af432 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdkinternals.properties @@ -0,0 +1,22 @@ +// No translation needed +com.sun.crypto.provider.SunJCE=Use java.security.Security.getProvider(provider-name) @since 1.3 +com.sun.image.codec=Use javax.imageio @since 1.4 +com.sun.org.apache.xml.internal.security=Use java.xml.crypto @since 1.6 +com.sun.org.apache.xml.internal.security.utils.Base64=Use java.util.Base64 @since 1.8 +com.sun.net.ssl=Use javax.net.ssl @since 1.4 +com.sun.net.ssl.internal.ssl.Provider=Use java.security.Security.getProvider(provider-name) @since 1.3 +com.sun.rowset=Use javax.sql.rowset.RowSetProvider @since 1.7 +com.sun.tools.javac.tree=Use com.sun.source @since 1.6 +com.sun.tools.javac=Use javax.tools and javax.lang.model @since 1.6 +sun.awt.image.codec=Use javax.imageio @since 1.4 +sun.misc.BASE64Encoder=Use java.util.Base64 @since 1.8 +sun.misc.BASE64Decoder=Use java.util.Base64 @since 1.8 +sun.misc.Cleaner=Use java.lang.ref.PhantomReference @since 1.2 +sun.misc.Service=Use java.util.ServiceLoader @since 1.6 +sun.security.action=Use java.security.PrivilegedAction @since 1.1 +sun.security.krb5=Use com.sun.security.jgss +sun.security.provider.PolicyFile=Use java.security.Policy.getInstance("JavaPolicy", new URIParameter(uri)) @since 1.6 +sun.security.provider.Sun=Use java.security.Security.getProvider(provider-name) @since 1.3 +sun.security.util.SecurityConstants=Use appropriate java.security.Permission subclass @since 1.1 +sun.security.x509.X500Name=Use javax.security.auth.x500.X500Principal @since 1.4 +sun.tools.jar=Use java.util.jar or jar tool @since 1.2 diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java index 905e126b82e..6ee47befa5e 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java @@ -32,7 +32,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementScanner6; +import javax.lang.model.util.ElementScanner9; /** Utility class that constructs a textual representation * of the public api of a class. @@ -42,7 +42,7 @@ import javax.lang.model.util.ElementScanner6; * risk. This code and its internal interfaces are subject to change * or deletion without notice.

    */ -public class PubapiVisitor extends ElementScanner6 { +public class PubapiVisitor extends ElementScanner9 { StringBuffer sb; // Important that it is 1! Part of protocol over wire, silly yes. diff --git a/langtools/src/share/classes/javax/lang/model/element/ElementVisitor.java b/langtools/src/share/classes/javax/lang/model/element/ElementVisitor.java index 56c07bde4b8..e0655518eb0 100644 --- a/langtools/src/share/classes/javax/lang/model/element/ElementVisitor.java +++ b/langtools/src/share/classes/javax/lang/model/element/ElementVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,8 +73,6 @@ import javax.lang.model.util.*; * @author Joseph D. Darcy * @author Scott Seligman * @author Peter von der Ahé - * @see AbstractElementVisitor6 - * @see AbstractElementVisitor7 * @since 1.6 */ public interface ElementVisitor { diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java index 46cce98976d..e24a53603b3 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,8 +72,12 @@ import javax.annotation.processing.SupportedSourceVersion; * * @see AbstractAnnotationValueVisitor7 * @see AbstractAnnotationValueVisitor8 + * @see AbstractAnnotationValueVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public abstract class AbstractAnnotationValueVisitor6 implements AnnotationValueVisitor { diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java index ae2438e065e..b03e5a7e8e7 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,8 +65,10 @@ import javax.annotation.processing.SupportedSourceVersion; * * @see AbstractAnnotationValueVisitor6 * @see AbstractAnnotationValueVisitor8 + * @see AbstractAnnotationValueVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public abstract class AbstractAnnotationValueVisitor7 extends AbstractAnnotationValueVisitor6 { diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java index 47c25598d61..eddd27d0998 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,6 +65,7 @@ import javax.annotation.processing.SupportedSourceVersion; * * @see AbstractAnnotationValueVisitor6 * @see AbstractAnnotationValueVisitor7 + * @see AbstractAnnotationValueVisitor9 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java new file mode 100644 index 00000000000..092a714b7e3 --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; +import javax.annotation.processing.SupportedSourceVersion; + +/** + * A skeletal visitor for annotation values with default behavior + * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} + * source version. + * + *

    WARNING: The {@code AnnotationValueVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract annotation + * value visitor class will also be introduced to correspond to the + * new language level; this visitor will have different default + * behavior for the visit method in question. When the new visitor is + * introduced, all or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods + * @param

    the type of the additional parameter to this visitor's methods. + * + * @see AbstractAnnotationValueVisitor6 + * @see AbstractAnnotationValueVisitor7 + * @see AbstractAnnotationValueVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public abstract class AbstractAnnotationValueVisitor9 extends AbstractAnnotationValueVisitor8 { + + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractAnnotationValueVisitor9() { + super(); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java index 2ce7465d151..b9ea796836c 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,8 +74,12 @@ import static javax.lang.model.SourceVersion.*; * * @see AbstractElementVisitor7 * @see AbstractElementVisitor8 + * @see AbstractElementVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public abstract class AbstractElementVisitor6 implements ElementVisitor { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java index f5c87e46d0f..94dcfc8cff5 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,8 +69,10 @@ import static javax.lang.model.SourceVersion.*; * * @see AbstractElementVisitor6 * @see AbstractElementVisitor8 + * @see AbstractElementVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public abstract class AbstractElementVisitor7 extends AbstractElementVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java index fb99d187f36..8237407f1a7 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,6 +69,7 @@ import static javax.lang.model.SourceVersion.*; * * @see AbstractElementVisitor6 * @see AbstractElementVisitor7 + * @see AbstractElementVisitor9 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor9.java new file mode 100644 index 00000000000..1d37826f892 --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractElementVisitor9.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + + +/** + * A skeletal visitor of program elements with default behavior + * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} + * source version. + * + *

    WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract element visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see AbstractElementVisitor6 + * @see AbstractElementVisitor7 + * @see AbstractElementVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public abstract class AbstractElementVisitor9 extends AbstractElementVisitor8 { + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractElementVisitor9(){ + super(); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java index 148cc83065a..a12537d2c96 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,11 @@ package javax.lang.model.util; +import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.type.*; +import static javax.lang.model.SourceVersion.*; + /** * A skeletal visitor of types with default behavior appropriate for * the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6} @@ -70,8 +73,13 @@ import javax.lang.model.type.*; * * @see AbstractTypeVisitor7 * @see AbstractTypeVisitor8 + * @see AbstractTypeVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated +@SupportedSourceVersion(RELEASE_6) public abstract class AbstractTypeVisitor6 implements TypeVisitor { /** * Constructor for concrete subclasses to call. diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java index 3fe08dcc1db..330564a14ff 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,11 @@ package javax.lang.model.util; +import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.type.*; +import static javax.lang.model.SourceVersion.*; + /** * A skeletal visitor of types with default behavior appropriate for * the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7} @@ -66,8 +69,11 @@ import javax.lang.model.type.*; * * @see AbstractTypeVisitor6 * @see AbstractTypeVisitor8 + * @see AbstractTypeVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated +@SupportedSourceVersion(RELEASE_7) public abstract class AbstractTypeVisitor7 extends AbstractTypeVisitor6 { /** * Constructor for concrete subclasses to call. diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java index a23b6e7fc5b..15b4bdcaff3 100644 --- a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,11 @@ package javax.lang.model.util; +import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.type.*; +import static javax.lang.model.SourceVersion.*; + /** * A skeletal visitor of types with default behavior appropriate for * the {@link javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8} @@ -66,8 +69,10 @@ import javax.lang.model.type.*; * * @see AbstractTypeVisitor6 * @see AbstractTypeVisitor7 + * @see AbstractTypeVisitor9 * @since 1.8 */ +@SupportedSourceVersion(RELEASE_8) public abstract class AbstractTypeVisitor8 extends AbstractTypeVisitor7 { /** * Constructor for concrete subclasses to call. diff --git a/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java new file mode 100644 index 00000000000..051100c1f5f --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.type.*; + +import static javax.lang.model.SourceVersion.*; + +/** + * A skeletal visitor of types with default behavior appropriate for + * the {@link javax.lang.model.SourceVersion#RELEASE_9 RELEASE_9} + * source version. + * + *

    WARNING: The {@code TypeVisitor} interface implemented + * by this class may have methods added to it in the future to + * accommodate new, currently unknown, language structures added to + * future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract type visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see AbstractTypeVisitor6 + * @see AbstractTypeVisitor7 + * @see AbstractTypeVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public abstract class AbstractTypeVisitor9 extends AbstractTypeVisitor8 { + /** + * Constructor for concrete subclasses to call. + */ + protected AbstractTypeVisitor9() { + super(); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java index 9925955ed9a..ec188e794de 100644 --- a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,8 +88,12 @@ import javax.lang.model.SourceVersion; * * @see ElementKindVisitor7 * @see ElementKindVisitor8 + * @see ElementKindVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public class ElementKindVisitor6 extends SimpleElementVisitor6 { diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java index ebaeb6ba67b..66874151fbd 100644 --- a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,8 +82,10 @@ import static javax.lang.model.SourceVersion.*; * * @see ElementKindVisitor6 * @see ElementKindVisitor8 + * @see ElementKindVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class ElementKindVisitor7 extends ElementKindVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java index 61ccc789073..3af0257eefa 100644 --- a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,6 +82,7 @@ import javax.lang.model.SourceVersion; * * @see ElementKindVisitor6 * @see ElementKindVisitor7 + * @see ElementKindVisitor9 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor9.java new file mode 100644 index 00000000000..bd561111aba --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/ElementKindVisitor9.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.SourceVersion; + +/** + * A visitor of program elements based on their {@linkplain + * ElementKind kind} with default behavior appropriate for the {@link + * SourceVersion#RELEASE_9 RELEASE_9} source version. For {@linkplain + * Element elements} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods + * call {@link #defaultAction defaultAction}, passing their arguments + * to {@code defaultAction}'s corresponding parameters. + * + *

    Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

    WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it or the + * {@code ElementKind} {@code enum} used in this case may have + * constants added to it in the future to accommodate new, currently + * unknown, language structures added to future versions of the + * Java™ programming language. Therefore, methods whose names + * begin with {@code "visit"} may be added to this class in the + * future; to avoid incompatibilities, classes which extend this class + * should not declare any instance methods with names beginning with + * {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new abstract element kind + * visitor class will also be introduced to correspond to the new + * language level; this visitor will have different default behavior + * for the visit method in question. When the new visitor is + * introduced, all or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see ElementKindVisitor6 + * @see ElementKindVisitor7 + * @see ElementKindVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public class ElementKindVisitor9 extends ElementKindVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected ElementKindVisitor9() { + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected ElementKindVisitor9(R defaultValue) { + super(defaultValue); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java b/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java index 1f9955f4a90..3d7b7dd40a9 100644 --- a/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java +++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,8 +90,12 @@ import static javax.lang.model.SourceVersion.*; * * @see ElementScanner7 * @see ElementScanner8 + * @see ElementScanner9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public class ElementScanner6 extends AbstractElementVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java b/langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java index deee40f2bcb..d99583f1b7a 100644 --- a/langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java +++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,8 +86,10 @@ import static javax.lang.model.SourceVersion.*; * * @see ElementScanner6 * @see ElementScanner8 + * @see ElementScanner9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class ElementScanner7 extends ElementScanner6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementScanner8.java b/langtools/src/share/classes/javax/lang/model/util/ElementScanner8.java index f6871360cd4..517a4f30b4f 100644 --- a/langtools/src/share/classes/javax/lang/model/util/ElementScanner8.java +++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,6 +86,7 @@ import static javax.lang.model.SourceVersion.*; * * @see ElementScanner6 * @see ElementScanner7 + * @see ElementScanner9 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/ElementScanner9.java b/langtools/src/share/classes/javax/lang/model/util/ElementScanner9.java new file mode 100644 index 00000000000..32c368dced5 --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/ElementScanner9.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.lang.model.element.*; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + + +/** + * A scanning visitor of program elements with default behavior + * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} + * source version. The visitXYZ methods in this + * class scan their component elements by calling {@code scan} on + * their {@linkplain Element#getEnclosedElements enclosed elements}, + * {@linkplain ExecutableElement#getParameters parameters}, etc., as + * indicated in the individual method specifications. A subclass can + * control the order elements are visited by overriding the + * visitXYZ methods. Note that clients of a scanner + * may get the desired behavior be invoking {@code v.scan(e, p)} rather + * than {@code v.visit(e, p)} on the root objects of interest. + * + *

    When a subclass overrides a visitXYZ method, the + * new method can cause the enclosed elements to be scanned in the + * default way by calling super.visitXYZ. In this + * fashion, the concrete visitor can control the ordering of traversal + * over the component elements with respect to the additional + * processing; for example, consistently calling + * super.visitXYZ at the start of the overridden + * methods will yield a preorder traversal, etc. If the component + * elements should be traversed in some other order, instead of + * calling super.visitXYZ, an overriding visit method + * should call {@code scan} with the elements in the desired order. + * + *

    Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

    WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new element scanner visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see ElementScanner6 + * @see ElementScanner7 + * @see ElementScanner8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public class ElementScanner9 extends ElementScanner8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected ElementScanner9(){ + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the default value + */ + protected ElementScanner9(R defaultValue){ + super(defaultValue); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java index 1bb58b96376..0006dd4c9df 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,8 +81,12 @@ import javax.annotation.processing.SupportedSourceVersion; * * @see SimpleAnnotationValueVisitor7 * @see SimpleAnnotationValueVisitor8 + * @see SimpleAnnotationValueVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public class SimpleAnnotationValueVisitor6 extends AbstractAnnotationValueVisitor6 { diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java index 0a442111cf7..c6d263fc63f 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,8 +72,10 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleAnnotationValueVisitor6 * @see SimpleAnnotationValueVisitor8 + * @see SimpleAnnotationValueVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class SimpleAnnotationValueVisitor7 extends SimpleAnnotationValueVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java index 1b84d328ca8..1dd055350d0 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,7 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleAnnotationValueVisitor6 * @see SimpleAnnotationValueVisitor7 + * @see SimpleAnnotationValueVisitor8 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java new file mode 100644 index 00000000000..e48903deb7a --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + +/** + * A simple visitor for annotation values with default behavior + * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} + * source version. Visit methods call {@link #defaultAction + * defaultAction} passing their arguments to {@code defaultAction}'s + * corresponding parameters. + * + *

    Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

    WARNING: The {@code AnnotationValueVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new simple annotation + * value visitor class will also be introduced to correspond to the + * new language level; this visitor will have different default + * behavior for the visit method in question. When the new visitor is + * introduced, all or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods + * @param

    the type of the additional parameter to this visitor's methods. + * + * @see SimpleAnnotationValueVisitor6 + * @see SimpleAnnotationValueVisitor7 + * @see SimpleAnnotationValueVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public class SimpleAnnotationValueVisitor9 extends SimpleAnnotationValueVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleAnnotationValueVisitor9() { + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleAnnotationValueVisitor9(R defaultValue) { + super(defaultValue); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java index 8c7ff87fbd9..1f9ca8cab66 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,8 +85,12 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleElementVisitor7 * @see SimpleElementVisitor8 + * @see SimpleElementVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public class SimpleElementVisitor6 extends AbstractElementVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java index b9df9c49e1c..2abe913110a 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,8 +78,10 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleElementVisitor6 * @see SimpleElementVisitor8 + * @see SimpleElementVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class SimpleElementVisitor7 extends SimpleElementVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java index f0cb871c99c..22d50e7fd74 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import static javax.lang.model.SourceVersion.*; * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} * source version. * - * Visit methods corresponding to {@code RELEASE_7} and earlier + * Visit methods corresponding to {@code RELEASE_8} and earlier * language constructs call {@link #defaultAction defaultAction}, * passing their arguments to {@code defaultAction}'s corresponding * parameters. @@ -77,6 +77,7 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleElementVisitor6 * @see SimpleElementVisitor7 + * @see SimpleElementVisitor9 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor9.java new file mode 100644 index 00000000000..d7fc7b489ad --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleElementVisitor9.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; + +/** + * A simple visitor of program elements with default behavior + * appropriate for the {@link SourceVersion#RELEASE_9 RELEASE_9} + * source version. + * + * Visit methods corresponding to {@code RELEASE_9} and earlier + * language constructs call {@link #defaultAction defaultAction}, + * passing their arguments to {@code defaultAction}'s corresponding + * parameters. + * + *

    Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

    WARNING: The {@code ElementVisitor} interface + * implemented by this class may have methods added to it in the + * future to accommodate new, currently unknown, language structures + * added to future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new simple element visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@code Void} + * for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's methods. Use {@code Void} + * for visitors that do not need an additional parameter. + * + * @see SimpleElementVisitor6 + * @see SimpleElementVisitor7 + * @see SimpleElementVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public class SimpleElementVisitor9 extends SimpleElementVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleElementVisitor9(){ + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleElementVisitor9(R defaultValue){ + super(defaultValue); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java index 4b2af1fc991..35ea1f71819 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,8 +85,12 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleTypeVisitor7 * @see SimpleTypeVisitor8 + * @see SimpleTypeVisitor9 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public class SimpleTypeVisitor6 extends AbstractTypeVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java index 66eb20aafa7..99ec8f720b5 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,8 +78,10 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleTypeVisitor6 * @see SimpleTypeVisitor8 + * @see SimpleTypeVisitor9 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class SimpleTypeVisitor7 extends SimpleTypeVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java index bc3aa617ed2..7636f2e03f5 100644 --- a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import static javax.lang.model.SourceVersion.*; /** * A simple visitor of types with default behavior appropriate for the - * {@link SourceVersion#RELEASE_7 RELEASE_7} source version. + * {@link SourceVersion#RELEASE_8 RELEASE_8} source version. * * Visit methods corresponding to {@code RELEASE_8} and earlier * language constructs call {@link #defaultAction defaultAction}, @@ -78,6 +78,7 @@ import static javax.lang.model.SourceVersion.*; * * @see SimpleTypeVisitor6 * @see SimpleTypeVisitor7 + * @see SimpleTypeVisitor9 * @since 1.8 */ @SupportedSourceVersion(RELEASE_8) diff --git a/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java new file mode 100644 index 00000000000..7563ec8c77e --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.type.IntersectionType; +import static javax.lang.model.SourceVersion.*; + +/** + * A simple visitor of types with default behavior appropriate for the + * {@link SourceVersion#RELEASE_9 RELEASE_9} source version. + * + * Visit methods corresponding to {@code RELEASE_9} and earlier + * language constructs call {@link #defaultAction defaultAction}, + * passing their arguments to {@code defaultAction}'s corresponding + * parameters. + * + *

    Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

    WARNING: The {@code TypeVisitor} interface implemented + * by this class may have methods added to it in the future to + * accommodate new, currently unknown, language structures added to + * future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new simple type visitor + * class will also be introduced to correspond to the new language + * level; this visitor will have different default behavior for the + * visit method in question. When the new visitor is introduced, all + * or portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see SimpleTypeVisitor6 + * @see SimpleTypeVisitor7 + * @since 1.8 + */ +@SupportedSourceVersion(RELEASE_9) +public class SimpleTypeVisitor9 extends SimpleTypeVisitor8 { + /** + * Constructor for concrete subclasses; uses {@code null} for the + * default value. + */ + protected SimpleTypeVisitor9(){ + super(null); + } + + /** + * Constructor for concrete subclasses; uses the argument for the + * default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected SimpleTypeVisitor9(R defaultValue){ + super(defaultValue); + } +} diff --git a/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java index 3add039d49a..5ff4097e288 100644 --- a/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java +++ b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java @@ -85,7 +85,10 @@ import static javax.lang.model.SourceVersion.*; * @see TypeKindVisitor7 * @see TypeKindVisitor8 * @since 1.6 + * @deprecated Release 6 is obsolete; update to a visitor for a newer + * release level. */ +@Deprecated @SupportedSourceVersion(RELEASE_6) public class TypeKindVisitor6 extends SimpleTypeVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java index a0a0c1276a3..c560914734a 100644 --- a/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java +++ b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,6 +82,7 @@ import javax.lang.model.SourceVersion; * @see TypeKindVisitor8 * @since 1.7 */ +@SuppressWarnings("deprecation") // Superclass deprecated @SupportedSourceVersion(RELEASE_7) public class TypeKindVisitor7 extends TypeKindVisitor6 { /** diff --git a/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor9.java b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor9.java new file mode 100644 index 00000000000..f92e9d706c3 --- /dev/null +++ b/langtools/src/share/classes/javax/lang/model/util/TypeKindVisitor9.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.lang.model.util; + +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.type.*; +import static javax.lang.model.SourceVersion.*; + +/** + * A visitor of types based on their {@linkplain TypeKind kind} with + * default behavior appropriate for the {@link SourceVersion#RELEASE_9 + * RELEASE_9} source version. For {@linkplain + * TypeMirror types} XYZ that may have more than one + * kind, the visitXYZ methods in this class delegate + * to the visitXYZKind method corresponding to the + * first argument's kind. The visitXYZKind methods + * call {@link #defaultAction defaultAction}, passing their arguments + * to {@code defaultAction}'s corresponding parameters. + * + *

    Methods in this class may be overridden subject to their + * general contract. Note that annotating methods in concrete + * subclasses with {@link java.lang.Override @Override} will help + * ensure that methods are overridden as intended. + * + *

    WARNING: The {@code TypeVisitor} interface implemented + * by this class may have methods added to it in the future to + * accommodate new, currently unknown, language structures added to + * future versions of the Java™ programming language. + * Therefore, methods whose names begin with {@code "visit"} may be + * added to this class in the future; to avoid incompatibilities, + * classes which extend this class should not declare any instance + * methods with names beginning with {@code "visit"}. + * + *

    When such a new visit method is added, the default + * implementation in this class will be to call the {@link + * #visitUnknown visitUnknown} method. A new type kind visitor class + * will also be introduced to correspond to the new language level; + * this visitor will have different default behavior for the visit + * method in question. When the new visitor is introduced, all or + * portions of this visitor may be deprecated. + * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * + * @see TypeKindVisitor6 + * @see TypeKindVisitor7 + * @see TypeKindVisitor8 + * @since 1.9 + */ +@SupportedSourceVersion(RELEASE_9) +public class TypeKindVisitor9 extends TypeKindVisitor8 { + /** + * Constructor for concrete subclasses to call; uses {@code null} + * for the default value. + */ + protected TypeKindVisitor9() { + super(null); + } + + /** + * Constructor for concrete subclasses to call; uses the argument + * for the default value. + * + * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} + */ + protected TypeKindVisitor9(R defaultValue) { + super(defaultValue); + } +} diff --git a/langtools/src/share/sample/javac/processing/src/CheckNamesProcessor.java b/langtools/src/share/sample/javac/processing/src/CheckNamesProcessor.java index 8f9ee067283..e15bb7bf12a 100644 --- a/langtools/src/share/sample/javac/processing/src/CheckNamesProcessor.java +++ b/langtools/src/share/sample/javac/processing/src/CheckNamesProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -138,7 +138,7 @@ public class CheckNamesProcessor extends AbstractProcessor { public SourceVersion getSupportedSourceVersion() { /* * Return latest source version instead of a fixed version - * like RELEASE_8. To return a fixed version, this class + * like RELEASE_9. To return a fixed version, this class * could be annotated with a SupportedSourceVersion * annotation. * @@ -192,7 +192,7 @@ public class CheckNamesProcessor extends AbstractProcessor { /** * Visitor to implement name checks. */ - private class NameCheckScanner extends ElementScanner8 { + private class NameCheckScanner extends ElementScanner9 { // The visitor could be enhanced to return true/false if // there were warnings reported or a count of the number // of warnings. This could be facilitated by using diff --git a/langtools/src/share/sample/language/model/CoreReflectionFactory.java b/langtools/src/share/sample/language/model/CoreReflectionFactory.java index 033765f2667..6c6a32dc003 100644 --- a/langtools/src/share/sample/language/model/CoreReflectionFactory.java +++ b/langtools/src/share/sample/language/model/CoreReflectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,7 +39,7 @@ import java.lang.reflect.*; import java.io.Writer; import java.util.*; -import static javax.lang.model.SourceVersion.RELEASE_8; +import static javax.lang.model.SourceVersion.RELEASE_9; import static java.util.Objects.*; /** @@ -487,10 +487,10 @@ public class CoreReflectionFactory { /** * Base class for concrete visitors of elements backed by core reflection. */ - public static abstract class AbstractReflectionElementVisitor8 - extends AbstractElementVisitor8 + public static abstract class AbstractReflectionElementVisitor9 + extends AbstractElementVisitor9 implements ReflectionElementVisitor { - protected AbstractReflectionElementVisitor8() { + protected AbstractReflectionElementVisitor9() { super(); } } @@ -498,16 +498,16 @@ public class CoreReflectionFactory { /** * Base class for simple visitors of elements that are backed by core reflection. */ - @SupportedSourceVersion(value=RELEASE_8) - public static abstract class SimpleReflectionElementVisitor8 - extends SimpleElementVisitor8 + @SupportedSourceVersion(value=RELEASE_9) + public static abstract class SimpleReflectionElementVisitor9 + extends SimpleElementVisitor9 implements ReflectionElementVisitor { - protected SimpleReflectionElementVisitor8(){ + protected SimpleReflectionElementVisitor9(){ super(); } - protected SimpleReflectionElementVisitor8(R defaultValue) { + protected SimpleReflectionElementVisitor9(R defaultValue) { super(defaultValue); } @@ -2527,7 +2527,7 @@ public class CoreReflectionFactory { Constructor printProcCtor = printProcClass.getConstructor(Writer.class, Elements.class); return (ElementVisitor) printProcCtor.newInstance(w, getElements()); } catch (ReflectiveOperationException | SecurityException e) { - return new ElementScanner8(w){ + return new ElementScanner9(w){ @Override public Writer scan(Element e, Void v) { try { diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html index fc14f0fbaf2..56ccb05b517 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html @@ -58,7 +58,6 @@ Sub-test 32 Expect: ./p2/

    Sub-test 33 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
    Sub-test 33 Expect: ./../docs1/p2/package-summary.html#package_description -

    diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html index cc61652a4cf..abda92fd0c7 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html @@ -59,7 +59,6 @@ Sub-test 21 Expect: ../p Sub-test 22 Actual: {@docRoot}/../docs1/p2/package-summary.html#package_description
    Sub-test 22 Expect: ../../docs1/p2/package-summary.html#package_description -

    diff --git a/langtools/test/tools/all/RunCodingRules.java b/langtools/test/tools/all/RunCodingRules.java new file mode 100644 index 00000000000..35e0992600f --- /dev/null +++ b/langtools/test/tools/all/RunCodingRules.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8043643 + * @summary Run the langtools coding rules over the langtools source code. + */ + + +import java.io.*; +import java.nio.file.Files; +import java.util.*; +import java.util.stream.Collectors; + +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import com.sun.tools.javac.util.Assert; + +public class RunCodingRules { + public static void main(String... args) throws Exception { + new RunCodingRules().run(); + } + + public void run() throws Exception { + File testSrc = new File(System.getProperty("test.src", ".")); + File targetDir = new File(System.getProperty("test.classes", ".")); + File sourceDir = null; + File crulesDir = null; + for (File d = testSrc; d != null; d = d.getParentFile()) { + if (new File(d, "TEST.ROOT").exists()) { + d = d.getParentFile(); + File f = new File(d, "src/share/classes"); + if (f.exists()) { + sourceDir = f; + f = new File(d, "make/tools"); + if (f.exists()) + crulesDir = f; + break; + } + } + } + + if (sourceDir == null || crulesDir == null) { + System.err.println("Warning: sources not found, test skipped."); + return ; + } + + JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null); + DiagnosticListener noErrors = diagnostic -> { + Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString()); + }; + + List crulesFiles = Files.walk(crulesDir.toPath()) + .map(entry -> entry.toFile()) + .filter(entry -> entry.getName().endsWith(".java")) + .filter(entry -> entry.getParentFile().getName().equals("crules")) + .collect(Collectors.toList()); + + File crulesTarget = new File(targetDir, "crules"); + crulesTarget.mkdirs(); + List crulesOptions = Arrays.asList("-d", crulesTarget.getAbsolutePath()); + javaCompiler.getTask(null, fm, noErrors, crulesOptions, null, + fm.getJavaFileObjectsFromFiles(crulesFiles)).call(); + File registration = new File(crulesTarget, "META-INF/services/com.sun.source.util.Plugin"); + registration.getParentFile().mkdirs(); + try (Writer metaInfServices = new FileWriter(registration)) { + metaInfServices.write("crules.CodingRulesAnalyzerPlugin\n"); + } + + List sources = Files.walk(sourceDir.toPath()) + .map(entry -> entry.toFile()) + .filter(entry -> entry.getName().endsWith(".java")) + .collect(Collectors.toList()); + + File sourceTarget = new File(targetDir, "classes"); + sourceTarget.mkdirs(); + String processorPath = crulesTarget.getAbsolutePath() + File.pathSeparator + + crulesDir.getAbsolutePath(); + List options = Arrays.asList("-d", sourceTarget.getAbsolutePath(), + "-processorpath", processorPath, "-Xplugin:coding_rules"); + javaCompiler.getTask(null, fm, noErrors, options, null, + fm.getJavaFileObjectsFromFiles(sources)).call(); + } +} diff --git a/langtools/test/tools/javac/6402516/CheckLocalElements.java b/langtools/test/tools/javac/6402516/CheckLocalElements.java index cd2b6a43d02..ae829bc6f36 100644 --- a/langtools/test/tools/javac/6402516/CheckLocalElements.java +++ b/langtools/test/tools/javac/6402516/CheckLocalElements.java @@ -110,7 +110,7 @@ public class CheckLocalElements extends Checker { return encl == null ? "" : encl.accept(qualNameVisitor, null); } - private ElementVisitor qualNameVisitor = new SimpleElementVisitor8() { + private ElementVisitor qualNameVisitor = new SimpleElementVisitor9() { protected String defaultAction(Element e, Void ignore) { return ""; } diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTestBase.java b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTestBase.java index f0eae64d627..097d8c491bf 100644 --- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTestBase.java +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTestBase.java @@ -36,14 +36,26 @@ import java.util.stream.Stream; import static java.lang.String.format; import static java.util.stream.Collectors.*; - +/** + * Base class for LocalVariableTable and LocalVariableTypeTable attributes tests. + * To add tests cases you should extend this class. + * Then implement {@link #getVariableTables} to get LocalVariableTable or LocalVariableTypeTable attribute. + * Then add method with local variables. + * Finally, annotate method with information about expected variables and their types + * by several {@link LocalVariableTestBase.ExpectedLocals} annotations. + * To run test invoke {@link #test()} method. + * If there are variables with the same name, set different scopes for them. + * + * @see #test() + */ public abstract class LocalVariableTestBase extends TestBase { public static final int DEFAULT_SCOPE = 0; private final ClassFile classFile; private final Class clazz; - protected abstract List getVariableTables(Code_attribute codeAttribute); - + /** + * @param clazz class to test. Must contains annotated methods with expected results. + */ public LocalVariableTestBase(Class clazz) { this.clazz = clazz; try { @@ -53,8 +65,12 @@ public abstract class LocalVariableTestBase extends TestBase { } } + protected abstract List getVariableTables(Code_attribute codeAttribute); - //info in the LocalVariableTable attribute is compared against expected info stored in annotations + /** + * Finds expected variables with their type in VariableTable. + * Also does consistency checks, like variables from the same scope must point to different indexes. + */ public void test() throws IOException { List testMethods = Stream.of(clazz.getDeclaredMethods()) .filter(m -> m.getAnnotationsByType(ExpectedLocals.class).length > 0) @@ -129,7 +145,7 @@ public abstract class LocalVariableTestBase extends TestBase { } } - private void checkNamesAndTypes(List entries, + private void checkNamesAndTypes(List entries, Map expectedLocals2Types) { Map> actualNames2Types = entries.stream() .collect( @@ -163,7 +179,7 @@ public abstract class LocalVariableTestBase extends TestBase { } - private void checkDoubleAndLongIndexes(Collection entries, + private void checkDoubleAndLongIndexes(Collection entries, Map scopes, int maxLocals) { //check every scope separately Map> entriesByScope = groupByScope(entries, scopes); @@ -185,7 +201,7 @@ public abstract class LocalVariableTestBase extends TestBase { } private Map> groupByScope( - Collection entries, Map scopes) { + Collection entries, Map scopes) { return entries.stream().collect(groupingBy(e -> scopes.getOrDefault(e.name() + "&" + e.type(), DEFAULT_SCOPE))); } @@ -198,12 +214,15 @@ public abstract class LocalVariableTestBase extends TestBase { } } - + /** + * LocalVariableTable and LocalVariableTypeTable are similar. + * VariableTable interface is introduced to test this attributes in the same way without code duplication. + */ interface VariableTable { int localVariableTableLength(); - List entries(); + List entries(); int attributeLength(); @@ -231,14 +250,23 @@ public abstract class LocalVariableTestBase extends TestBase { } } + /** + * Used to store expected results in sources + */ @Retention(RetentionPolicy.RUNTIME) @Repeatable(Container.class) @interface ExpectedLocals { + /** + * @return name of a local variable + */ String name(); + /** + * @return type of local variable in the internal format. + */ String type(); - //variables from different scopes can share local variable table index and/or name. + //variables from different scopes can share the local variable table index and/or name. int scope() default DEFAULT_SCOPE; } diff --git a/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java b/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java index dd0a7c3aa4a..944a2d851ec 100644 --- a/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java +++ b/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java @@ -30,18 +30,41 @@ import java.util.List; import java.util.Map; import javax.tools.JavaFileObject; +/** + * Base class for Source file attribute tests. Checks expected file name for specified classes in the SourceFile attribute. + * To add new tests you should extend the SourceFileTestBase class and invoke {@link #test} for static sources + * or {@link #compileAndTest} for generated sources. For more information see corresponding methods. + * + * @see #test + * @see #compileAndTest + */ public class SourceFileTestBase extends TestBase { - + /** + * Checks expected fileName for the specified class in the SourceFile attribute. + * + * @param classToTest class to check its SourceFile attribute + * @param fileName expected name of the file from which the test file is compiled. + */ protected void test(Class classToTest, String fileName) throws Exception { assertAttributePresent(ClassFile.read(getClassFile(classToTest)), fileName); } + /** + * Checks expected fileName for the specified class in the SourceFile attribute. + * + * @param classToTest class name to check its SourceFile attribute + * @param fileName expected name of the file from which the test file is compiled. + */ protected void test(String classToTest, String fileName) throws Exception { assertAttributePresent(ClassFile.read(getClassFile(classToTest + ".class")), fileName); } /** - * Compile sourceCode and for all "classesToTest" checks SourceFile attribute. + * Compiles sourceCode and for each specified class name checks the SourceFile attribute. + * The file name is extracted from source code. + * + * @param sourceCode source code to compile + * @param classesToTest class names to check their SourceFile attribute. */ protected void compileAndTest(String sourceCode, String... classesToTest) throws Exception { diff --git a/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java b/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java index 85a252313b8..17ff2b7b28f 100644 --- a/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java +++ b/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java @@ -23,11 +23,14 @@ import java.io.File; import java.io.IOException; -import java.io.PrintStream; -import java.util.*; +import java.util.List; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Stream; -import javax.tools.*; +import javax.tools.DiagnosticCollector; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.ToolProvider; import static java.lang.String.format; import static java.lang.System.lineSeparator; @@ -36,6 +39,11 @@ import static java.util.Collections.emptyList; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; +/** + * Base class for class file attribute tests. + * Contains methods for compiling generated sources in memory, + * for reading files from disk and a lot of assert* methods. + */ public class TestBase { public static final String LINE_SEPARATOR = lineSeparator(); @@ -66,35 +74,48 @@ public class TestBase { } } + /** + * Compiles sources in memory. + * + * @param sources to compile. + * @return memory file manager which contains class files and class loader. + */ public InMemoryFileManager compile(String... sources) throws IOException, CompilationException { return compile(emptyList(), sources); } /** - * @param options - compiler options - * @param sources + * Compiles sources in memory. + * + * @param options compiler options. + * @param sources sources to compile. * @return map where key is className, value is corresponding ClassFile. - * @throws IOException */ - public InMemoryFileManager compile(List options, String...sources) + public InMemoryFileManager compile(List options, String... sources) throws IOException, CompilationException { return compile(options, ToolBox.JavaSource::new, asList(sources)); } + /** + * Compiles sources in memory. + * + * @param sources sources[i][0] - name of file, sources[i][1] - sources. + * @return map where key is className, value is corresponding ClassFile. + */ public InMemoryFileManager compile(String[]... sources) throws IOException, CompilationException { return compile(emptyList(), sources); } /** - * @param options - compiler options - * @param sources - sources[i][0] - name of file, sources[i][1] - sources + * Compiles sources in memory. + * + * @param options compiler options + * @param sources sources[i][0] - name of file, sources[i][1] - sources. * @return map where key is className, value is corresponding ClassFile. - * @throws IOException - * @throws CompilationException */ - public InMemoryFileManager compile(List options, String[]...sources) + public InMemoryFileManager compile(List options, String[]... sources) throws IOException, CompilationException { return compile(options, src -> new ToolBox.JavaSource(src[0], src[1]), asList(sources)); } @@ -142,11 +163,22 @@ public class TestBase { return getClassFile(clazz.getName().replace(".", "/") + ".class"); } + /** + * Prints message to standard error. New lines are converted to system dependent NL. + * + * @param message string to print. + */ public void echo(String message) { System.err.println(message.replace("\n", LINE_SEPARATOR)); } - public void printf(String template, Object...args) { + /** + * Substitutes args in template and prints result to standard error. New lines are converted to system dependent NL. + * + * @param template template in standard String.format(...) format. + * @param args arguments to substitute in template. + */ + public void printf(String template, Object... args) { System.err.printf(template, Stream.of(args) .map(Objects::toString) .map(m -> m.replace("\n", LINE_SEPARATOR)) diff --git a/langtools/test/tools/javac/generics/5086027/T5086027.java b/langtools/test/tools/javac/generics/5086027/T5086027.java index d037cc9c7db..631550ad7a1 100644 --- a/langtools/test/tools/javac/generics/5086027/T5086027.java +++ b/langtools/test/tools/javac/generics/5086027/T5086027.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5086027 * @summary Inner class of generic class cannot extend Throwable * @author Peter von der Ah\u00e9 - * @compile/fail T5086027.java + * @compile/fail/ref=T5086027.out -XDrawDiagnostics T5086027.java */ public class T5086027 { diff --git a/langtools/test/tools/javac/generics/5086027/T5086027.out b/langtools/test/tools/javac/generics/5086027/T5086027.out new file mode 100644 index 00000000000..16c605c82e6 --- /dev/null +++ b/langtools/test/tools/javac/generics/5086027/T5086027.out @@ -0,0 +1,2 @@ +T5086027.java:10:21: compiler.err.generic.throwable +1 error diff --git a/langtools/test/tools/javac/generics/6227936/Orig.java b/langtools/test/tools/javac/generics/6227936/Orig.java index ba1ad368920..778d26aa8ab 100644 --- a/langtools/test/tools/javac/generics/6227936/Orig.java +++ b/langtools/test/tools/javac/generics/6227936/Orig.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6227936 * @summary Wrong type of inherited method using specialized type parameter - * @compile/fail Orig.java + * @compile/fail/ref=Orig.out -XDrawDiagnostics Orig.java */ class GenericTest { diff --git a/langtools/test/tools/javac/generics/6227936/Orig.out b/langtools/test/tools/javac/generics/6227936/Orig.out new file mode 100644 index 00000000000..5501d3a13a5 --- /dev/null +++ b/langtools/test/tools/javac/generics/6227936/Orig.out @@ -0,0 +1,2 @@ +Orig.java:27:26: compiler.err.cant.resolve.location.args: kindname.method, someMethod, , , (compiler.misc.location: kindname.class, GenericTest.C, null) +1 error diff --git a/langtools/test/tools/javac/generics/6245699/T6245699b.java b/langtools/test/tools/javac/generics/6245699/T6245699b.java index f52836b8fbf..8aafcf4e0d1 100644 --- a/langtools/test/tools/javac/generics/6245699/T6245699b.java +++ b/langtools/test/tools/javac/generics/6245699/T6245699b.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6270396 6245699 * @summary Missing bridge for final method (gives AbstractMethodError at runtime) - * @compile/fail T6245699b.java + * @compile/fail/ref=T6245699b.out -XDrawDiagnostics T6245699b.java */ public class T6245699b { diff --git a/langtools/test/tools/javac/generics/6245699/T6245699b.out b/langtools/test/tools/javac/generics/6245699/T6245699b.out new file mode 100644 index 00000000000..6b8ebe16621 --- /dev/null +++ b/langtools/test/tools/javac/generics/6245699/T6245699b.out @@ -0,0 +1,2 @@ +T6245699b.java:23:23: compiler.err.override.meth: (compiler.misc.cant.override: doIt(), T6245699b.Bar, doIt(), T6245699b.Foo), final +1 error diff --git a/langtools/test/tools/javac/generics/6294779/T6294779c.java b/langtools/test/tools/javac/generics/6294779/T6294779c.java index 93d59046f2d..e864316f117 100644 --- a/langtools/test/tools/javac/generics/6294779/T6294779c.java +++ b/langtools/test/tools/javac/generics/6294779/T6294779c.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6294779 * @summary Problem with interface inheritance and covariant return types * @author Maurizio Cimadamore - * @compile/fail T6294779c.java + * @compile/fail/ref=T6294779c.out -XDrawDiagnostics T6294779c.java */ public class T6294779c { diff --git a/langtools/test/tools/javac/generics/6294779/T6294779c.out b/langtools/test/tools/javac/generics/6294779/T6294779c.out new file mode 100644 index 00000000000..244b9f7fffe --- /dev/null +++ b/langtools/test/tools/javac/generics/6294779/T6294779c.out @@ -0,0 +1,2 @@ +T6294779c.java:29:5: compiler.err.types.incompatible.diff.ret: T6294779c.I2, T6294779c.I1, get() +1 error diff --git a/langtools/test/tools/javac/generics/6413682/T6413682.java b/langtools/test/tools/javac/generics/6413682/T6413682.java index 9a837eb6179..f1d7dabf78e 100644 --- a/langtools/test/tools/javac/generics/6413682/T6413682.java +++ b/langtools/test/tools/javac/generics/6413682/T6413682.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6413682 * @summary Compiler confused about implicit type args and arrays - * @compile/fail T6413682.java + * @compile/fail/ref=T6413682.out -XDrawDiagnostics T6413682.java */ public class T6413682 { diff --git a/langtools/test/tools/javac/generics/6413682/T6413682.out b/langtools/test/tools/javac/generics/6413682/T6413682.out new file mode 100644 index 00000000000..ea4e3e9ca67 --- /dev/null +++ b/langtools/test/tools/javac/generics/6413682/T6413682.out @@ -0,0 +1,2 @@ +T6413682.java:11:2: compiler.err.cannot.create.array.with.type.arguments +1 error diff --git a/langtools/test/tools/javac/generics/6495506/T6495506.java b/langtools/test/tools/javac/generics/6495506/T6495506.java index f522558b5fd..1f8ed916f89 100644 --- a/langtools/test/tools/javac/generics/6495506/T6495506.java +++ b/langtools/test/tools/javac/generics/6495506/T6495506.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6495506 * @summary Cast inserted by generics can cause IllegalAccessError * @compile A.java - * @compile/fail T6495506.java + * @compile/fail/ref=T6495506.out -XDrawDiagnostics T6495506.java */ public class T6495506 { diff --git a/langtools/test/tools/javac/generics/6495506/T6495506.out b/langtools/test/tools/javac/generics/6495506/T6495506.out new file mode 100644 index 00000000000..24dc5a855bb --- /dev/null +++ b/langtools/test/tools/javac/generics/6495506/T6495506.out @@ -0,0 +1,2 @@ +T6495506.java:12:28: compiler.err.report.access: a.A.P, private, a.A +1 error diff --git a/langtools/test/tools/javac/generics/CatchTyparam.java b/langtools/test/tools/javac/generics/CatchTyparam.java index a189a618c32..4feb79e9d25 100644 --- a/langtools/test/tools/javac/generics/CatchTyparam.java +++ b/langtools/test/tools/javac/generics/CatchTyparam.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5057445 * @summary javac allows catching type parameter * @author gafter * - * @compile/fail CatchTyparam.java + * @compile/fail/ref=CatchTyparam.out -XDrawDiagnostics CatchTyparam.java */ class J { diff --git a/langtools/test/tools/javac/generics/CatchTyparam.out b/langtools/test/tools/javac/generics/CatchTyparam.out new file mode 100644 index 00000000000..403a715b1f2 --- /dev/null +++ b/langtools/test/tools/javac/generics/CatchTyparam.out @@ -0,0 +1,3 @@ +CatchTyparam.java:14:18: compiler.err.type.found.req: (compiler.misc.type.parameter: T), (compiler.misc.type.req.class) +CatchTyparam.java:15:18: compiler.err.type.found.req: (compiler.misc.type.parameter: U), (compiler.misc.type.req.class) +2 errors diff --git a/langtools/test/tools/javac/generics/inference/4941882/T4941882.java b/langtools/test/tools/javac/generics/inference/4941882/T4941882.java index 8ca66be9d7f..ff6e7b86fda 100644 --- a/langtools/test/tools/javac/generics/inference/4941882/T4941882.java +++ b/langtools/test/tools/javac/generics/inference/4941882/T4941882.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 4941882 * @summary incorrect inference for result of lub(int[], float[]) - * @compile/fail T4941882.java + * @compile/fail/ref=T4941882.out -XDrawDiagnostics T4941882.java */ public class T4941882 { diff --git a/langtools/test/tools/javac/generics/inference/4941882/T4941882.out b/langtools/test/tools/javac/generics/inference/4941882/T4941882.out new file mode 100644 index 00000000000..6bcaaa93fe7 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/4941882/T4941882.out @@ -0,0 +1,2 @@ +T4941882.java:13:17: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object&java.io.Serializable&java.lang.Cloneable, java.lang.Object[],java.lang.Object) +1 error diff --git a/langtools/test/tools/javac/generics/inference/4972073/T4972073.java b/langtools/test/tools/javac/generics/inference/4972073/T4972073.java index 7edbb713fdf..8a6dd65f1e7 100644 --- a/langtools/test/tools/javac/generics/inference/4972073/T4972073.java +++ b/langtools/test/tools/javac/generics/inference/4972073/T4972073.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 4972073 * @summary same interface allowed twice in compound type - * @compile/fail T4972073.java + * @compile/fail/ref=T4972073.out -XDrawDiagnostics T4972073.java */ public class T4972073 { diff --git a/langtools/test/tools/javac/generics/inference/4972073/T4972073.out b/langtools/test/tools/javac/generics/inference/4972073/T4972073.out new file mode 100644 index 00000000000..02720ed0723 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/4972073/T4972073.out @@ -0,0 +1,3 @@ +T4972073.java:18:80: compiler.err.repeated.interface +T4972073.java:24:68: compiler.err.repeated.interface +2 errors diff --git a/langtools/test/tools/javac/generics/inference/4972073/T4972073a.java b/langtools/test/tools/javac/generics/inference/4972073/T4972073a.java index b5d8a7cce84..a3f644e51aa 100644 --- a/langtools/test/tools/javac/generics/inference/4972073/T4972073a.java +++ b/langtools/test/tools/javac/generics/inference/4972073/T4972073a.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 4972073 * @summary same interface allowed twice in compound type - * @compile/fail T4972073a.java + * @compile/fail/ref=T4972073a.out -XDrawDiagnostics T4972073a.java */ public class T4972073a { diff --git a/langtools/test/tools/javac/generics/inference/4972073/T4972073a.out b/langtools/test/tools/javac/generics/inference/4972073/T4972073a.out new file mode 100644 index 00000000000..5368a94c95a --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/4972073/T4972073a.out @@ -0,0 +1,2 @@ +T4972073a.java:18:80: compiler.err.repeated.interface +1 error diff --git a/langtools/test/tools/javac/generics/inference/4972073/T4972073b.java b/langtools/test/tools/javac/generics/inference/4972073/T4972073b.java index 9702a027961..0046fb4e200 100644 --- a/langtools/test/tools/javac/generics/inference/4972073/T4972073b.java +++ b/langtools/test/tools/javac/generics/inference/4972073/T4972073b.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 4972073 * @summary same interface allowed twice in compound type - * @compile/fail T4972073b.java + * @compile/fail/ref=T4972073b.out -XDrawDiagnostics T4972073b.java */ public class T4972073b { diff --git a/langtools/test/tools/javac/generics/inference/4972073/T4972073b.out b/langtools/test/tools/javac/generics/inference/4972073/T4972073b.out new file mode 100644 index 00000000000..c293197abc3 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/4972073/T4972073b.out @@ -0,0 +1,2 @@ +T4972073b.java:18:68: compiler.err.repeated.interface +1 error diff --git a/langtools/test/tools/javac/generics/inference/5081782/Neg.java b/langtools/test/tools/javac/generics/inference/5081782/Neg.java index 01319611f5d..f8869059944 100644 --- a/langtools/test/tools/javac/generics/inference/5081782/Neg.java +++ b/langtools/test/tools/javac/generics/inference/5081782/Neg.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5081782 * @summary type arguments to non-generic methods * @author Peter von der Ah\u00e9 - * @compile/fail Neg.java + * @compile/fail/ref=Neg.out -XDrawDiagnostics Neg.java */ public class Neg { diff --git a/langtools/test/tools/javac/generics/inference/5081782/Neg.out b/langtools/test/tools/javac/generics/inference/5081782/Neg.out new file mode 100644 index 00000000000..cb0da462429 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/5081782/Neg.out @@ -0,0 +1,8 @@ +Neg.java:12:14: compiler.err.cant.resolve.location: kindname.class, Can, , , (compiler.misc.location: kindname.class, Neg, null) +Neg.java:12:18: compiler.err.cant.resolve.location: kindname.class, I, , , (compiler.misc.location: kindname.class, Neg, null) +Neg.java:12:20: compiler.err.cant.resolve.location: kindname.class, write, , , (compiler.misc.location: kindname.class, Neg, null) +Neg.java:12:26: compiler.err.cant.resolve.location: kindname.class, a, , , (compiler.misc.location: kindname.class, Neg, null) +Neg.java:12:28: compiler.err.cant.resolve.location: kindname.class, little, , , (compiler.misc.location: kindname.class, Neg, null) +Neg.java:12:35: compiler.err.cant.resolve.location: kindname.class, story, , , (compiler.misc.location: kindname.class, Neg, null) +Neg.java:12:41: compiler.err.cant.resolve.location: kindname.class, here, , , (compiler.misc.location: kindname.class, Neg, null) +7 errors diff --git a/langtools/test/tools/javac/generics/rawOverride/Fail1.java b/langtools/test/tools/javac/generics/rawOverride/Fail1.java index d4c460ef88c..1b73b9742fb 100644 --- a/langtools/test/tools/javac/generics/rawOverride/Fail1.java +++ b/langtools/test/tools/javac/generics/rawOverride/Fail1.java @@ -1,34 +1,11 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5073079 * @summary Allow unchecked override of generified methods in * parameterless classes * @author Peter von der Ah\u00e9 * - * @compile/fail Fail1.java + * @compile/fail/ref=Fail1.out -XDrawDiagnostics Fail1.java */ interface MyList {} diff --git a/langtools/test/tools/javac/generics/rawOverride/Fail1.out b/langtools/test/tools/javac/generics/rawOverride/Fail1.out new file mode 100644 index 00000000000..f781e6f2685 --- /dev/null +++ b/langtools/test/tools/javac/generics/rawOverride/Fail1.out @@ -0,0 +1,2 @@ +Fail1.java:21:1: compiler.err.does.not.override.abstract: C, f(MyList), A +1 error diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.java b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.java index 5984d77a225..72c86666b92 100644 --- a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.java +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6318240 * @summary Creation of array of inner class of an enclosing wildcard type doesn't work - * @compile/fail BarNeg1.java + * @compile/fail/ref=BarNeg1.out -XDrawDiagnostics BarNeg1.java */ class BarNeg1 { diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.out b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.out new file mode 100644 index 00000000000..29a23e628aa --- /dev/null +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1.out @@ -0,0 +1,2 @@ +BarNeg1.java:9:45: compiler.err.generic.array.creation +1 error diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.java b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.java index 19a826f8b38..914e7cbf0ae 100644 --- a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.java +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6318240 * @summary Creation of array of inner class of an enclosing wildcard type doesn't work - * @compile/fail BarNeg1a.java + * @compile/fail/ref=BarNeg1a.out -XDrawDiagnostics BarNeg1a.java */ class BarNeg1a { diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.out b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.out new file mode 100644 index 00000000000..e9ae0ce9e31 --- /dev/null +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg1a.out @@ -0,0 +1,2 @@ +BarNeg1a.java:9:36: compiler.err.cant.select.static.class.from.param.type +1 error diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.java b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.java index 474ec5dc720..67d4c2f2267 100644 --- a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.java +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6318240 * @summary Creation of array of inner class of an enclosing wildcard type doesn't work - * @compile/fail BarNeg2.java + * @compile/fail/ref=BarNeg2.out -XDrawDiagnostics BarNeg2.java */ class BarNeg2 { diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.out b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.out new file mode 100644 index 00000000000..d4d4b2a9691 --- /dev/null +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2.out @@ -0,0 +1,2 @@ +BarNeg2.java:9:45: compiler.err.generic.array.creation +1 error diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.java b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.java index 7173df588eb..d6ce3c891f9 100644 --- a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.java +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6318240 * @summary Creation of array of inner class of an enclosing wildcard type doesn't work - * @compile/fail BarNeg2a.java + * @compile/fail/ref=BarNeg2a.out -XDrawDiagnostics BarNeg2a.java */ class BarNeg2a { diff --git a/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.out b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.out new file mode 100644 index 00000000000..f2ddfb3994d --- /dev/null +++ b/langtools/test/tools/javac/generics/syntax/6318240/BarNeg2a.out @@ -0,0 +1,2 @@ +BarNeg2a.java:9:60: compiler.err.cant.select.static.class.from.param.type +1 error diff --git a/langtools/test/tools/javac/generics/typevars/5060485/Neg1.java b/langtools/test/tools/javac/generics/typevars/5060485/Neg1.java index b3da6a89e23..380ef7501da 100644 --- a/langtools/test/tools/javac/generics/typevars/5060485/Neg1.java +++ b/langtools/test/tools/javac/generics/typevars/5060485/Neg1.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5060485 * @summary The scope of a class type parameter is too wide * @author Peter von der Ah\u00e9 - * @compile/fail Neg1.java + * @compile/fail/ref=Neg1.out -XDrawDiagnostics Neg1.java */ public class Neg1 { diff --git a/langtools/test/tools/javac/generics/typevars/5060485/Neg1.out b/langtools/test/tools/javac/generics/typevars/5060485/Neg1.out new file mode 100644 index 00000000000..f01c8609e73 --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/5060485/Neg1.out @@ -0,0 +1,2 @@ +Neg1.java:9:29: compiler.err.cant.resolve: kindname.class, Y, , +1 error diff --git a/langtools/test/tools/javac/generics/typevars/5060485/Neg2.java b/langtools/test/tools/javac/generics/typevars/5060485/Neg2.java index 064f7885ec1..c96080d1777 100644 --- a/langtools/test/tools/javac/generics/typevars/5060485/Neg2.java +++ b/langtools/test/tools/javac/generics/typevars/5060485/Neg2.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5060485 * @summary The scope of a class type parameter is too wide * @author Peter von der Ah\u00e9 - * @compile/fail Neg2.java + * @compile/fail/ref=Neg2.out -XDrawDiagnostics Neg2.java */ public class Neg2 { diff --git a/langtools/test/tools/javac/generics/typevars/5060485/Neg2.out b/langtools/test/tools/javac/generics/typevars/5060485/Neg2.out new file mode 100644 index 00000000000..6b292e024af --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/5060485/Neg2.out @@ -0,0 +1,2 @@ +Neg2.java:9:19: compiler.err.cyclic.inheritance: X +1 error diff --git a/langtools/test/tools/javac/generics/typevars/5061359/T5061359.java b/langtools/test/tools/javac/generics/typevars/5061359/T5061359.java index 3af608c5742..fdef6982656 100644 --- a/langtools/test/tools/javac/generics/typevars/5061359/T5061359.java +++ b/langtools/test/tools/javac/generics/typevars/5061359/T5061359.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5061359 * @summary No error for ambiguous member of intersection - * @compile/fail T5061359.java + * @compile/fail/ref=T5061359.out -XDrawDiagnostics T5061359.java */ class Test { diff --git a/langtools/test/tools/javac/generics/typevars/5061359/T5061359.out b/langtools/test/tools/javac/generics/typevars/5061359/T5061359.out new file mode 100644 index 00000000000..f1fc14a5fd0 --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/5061359/T5061359.out @@ -0,0 +1,2 @@ +T5061359.java:11:10: compiler.err.ref.ambiguous: Inner, kindname.class, Base.Inner, Base, kindname.class, Intf.Inner, Intf +1 error diff --git a/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.java b/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.java index 40617d843da..c818490393f 100644 --- a/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.java +++ b/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.java @@ -1,36 +1,13 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 5061359 * @summary No error for ambiguous member of intersection * @clean Base Intf - * @compile/fail T5061359a.java + * @compile/fail/ref=T5061359a.out -XDrawDiagnostics T5061359a.java * @clean Base Intf T5061359a - * @compile/fail Base.java Intf.java T5061359a.java + * @compile/fail/ref=T5061359a.out -XDrawDiagnostics Base.java Intf.java T5061359a.java * @clean Base Intf T5061359a - * @compile/fail T5061359a.java Base.java Intf.java + * @compile/fail/ref=T5061359a.out -XDrawDiagnostics T5061359a.java Base.java Intf.java */ import java.util.*; diff --git a/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.out b/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.out new file mode 100644 index 00000000000..77400ef39fc --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/5061359/T5061359a.out @@ -0,0 +1,2 @@ +T5061359a.java:16:30: compiler.err.override.incompatible.ret: (compiler.misc.cant.implement: m1(), Base, m1(), Intf), int, void +1 error diff --git a/langtools/test/tools/javac/generics/typevars/6199146/T6199146.java b/langtools/test/tools/javac/generics/typevars/6199146/T6199146.java index 2fd01a844a0..7375792a1c2 100644 --- a/langtools/test/tools/javac/generics/typevars/6199146/T6199146.java +++ b/langtools/test/tools/javac/generics/typevars/6199146/T6199146.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6199146 * @summary Javac accepts ambiguous compound type - * @compile/fail T6199146.java + * @compile/fail/ref=T6199146.out -XDrawDiagnostics T6199146.java */ public class T6199146 { diff --git a/langtools/test/tools/javac/generics/typevars/6199146/T6199146.out b/langtools/test/tools/javac/generics/typevars/6199146/T6199146.out new file mode 100644 index 00000000000..d487e95ab65 --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/6199146/T6199146.out @@ -0,0 +1,2 @@ +T6199146.java:9:25: compiler.err.types.incompatible.diff.ret: T6199146.I2, T6199146.I1, getFoo() +1 error diff --git a/langtools/test/tools/javac/generics/typevars/6486430/T6486430.java b/langtools/test/tools/javac/generics/typevars/6486430/T6486430.java index 46068f7b341..5de2ae54da0 100644 --- a/langtools/test/tools/javac/generics/typevars/6486430/T6486430.java +++ b/langtools/test/tools/javac/generics/typevars/6486430/T6486430.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6486430 * @summary Compiler fails to reject access to static member in parameterized type * @author Peter von der Ah\u00e9 - * @compile/fail T6486430.java + * @compile/fail/ref=T6486430.out -XDrawDiagnostics T6486430.java */ class T6486430 { diff --git a/langtools/test/tools/javac/generics/typevars/6486430/T6486430.out b/langtools/test/tools/javac/generics/typevars/6486430/T6486430.out new file mode 100644 index 00000000000..79c7153203f --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/6486430/T6486430.out @@ -0,0 +1,2 @@ +T6486430.java:10:16: compiler.err.cant.select.static.class.from.param.type +1 error diff --git a/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.java b/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.java index 19a268de55c..35056db6daa 100644 --- a/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.java +++ b/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6486430 * @summary Compiler fails to reject access to static member in parameterized type * @author Peter von der Ah\u00e9 - * @compile/fail T6486430a.java + * @compile/fail/ref=T6486430a.out -XDrawDiagnostics T6486430a.java */ class T6486430a { diff --git a/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.out b/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.out new file mode 100644 index 00000000000..6021e664634 --- /dev/null +++ b/langtools/test/tools/javac/generics/typevars/6486430/T6486430a.out @@ -0,0 +1,2 @@ +T6486430a.java:10:31: compiler.err.cant.select.static.class.from.param.type +1 error diff --git a/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.java b/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.java index 674bcad1772..2fed8da2d8a 100644 --- a/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.java +++ b/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6762569 * @summary Javac crashes with AssertionError in Types.containedBy - * @compile/fail T6762569b.java + * @compile/fail/ref=T6762569b.out -XDrawDiagnostics T6762569b.java */ import java.util.*; diff --git a/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.out b/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.out new file mode 100644 index 00000000000..27e9e152e6e --- /dev/null +++ b/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.out @@ -0,0 +1,2 @@ +T6762569b.java:13:9: compiler.err.cant.apply.symbol: kindname.method, m, T,java.util.List>, java.lang.String,java.util.List>, kindname.class, T6762569b, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number,java.lang.Object) +1 error diff --git a/langtools/test/tools/javac/generics/wildcards/T6450290.java b/langtools/test/tools/javac/generics/wildcards/T6450290.java index f2378e60eca..330922fffb3 100644 --- a/langtools/test/tools/javac/generics/wildcards/T6450290.java +++ b/langtools/test/tools/javac/generics/wildcards/T6450290.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * 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 + * @test /nodynamiccopyright/ * @bug 6450290 * @summary Capture of nested wildcards causes type error * @author Maurizio Cimadamore - * @compile/fail T6450290.java + * @compile/fail/ref=T6450290.out -XDrawDiagnostics T6450290.java */ public class T6450290 { diff --git a/langtools/test/tools/javac/generics/wildcards/T6450290.out b/langtools/test/tools/javac/generics/wildcards/T6450290.out new file mode 100644 index 00000000000..556621c3073 --- /dev/null +++ b/langtools/test/tools/javac/generics/wildcards/T6450290.out @@ -0,0 +1,2 @@ +T6450290.java:19:24: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6450290.Box, T6450290.Box) +1 error diff --git a/jdk/src/share/classes/sun/audio/AudioDataStream.java b/langtools/test/tools/javac/lambda/8051958/T8051958.java similarity index 59% rename from jdk/src/share/classes/sun/audio/AudioDataStream.java rename to langtools/test/tools/javac/lambda/8051958/T8051958.java index dcc21a88233..94fd9fd9891 100644 --- a/jdk/src/share/classes/sun/audio/AudioDataStream.java +++ b/langtools/test/tools/javac/lambda/8051958/T8051958.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,32 +23,49 @@ * questions. */ -package sun.audio; - -import java.io.*; - -/** - * An input stream to play AudioData. - * - * @see AudioPlayer - * @see AudioData - * @author Arthur van Hoff - * @author Kara Kytle +/* + * @test + * @bug 8051958 + * @summary Cannot assign a value to final variable in lambda + * @compile T8051958.java */ -public class AudioDataStream extends ByteArrayInputStream { - private final AudioData ad; +class T8051958 { + Runnable inst_r = ()-> { + final int x; + x = 1; + }; - /** - * Constructor - */ - public AudioDataStream(final AudioData data) { + Runnable static_r = ()-> { + final int x; + x = 1; + }; - super(data.buffer); - this.ad = data; + { + Runnable inst_r = ()-> { + final int x; + x = 1; + }; } - final AudioData getAudioData() { - return ad; + static { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } + + void instTest() { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } + + static void staticTest() { + Runnable static_r = ()-> { + final int x; + x = 1; + }; } } diff --git a/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java index f279b3bd638..1249fa951f5 100644 --- a/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java +++ b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java @@ -28,7 +28,7 @@ import javax.lang.model.util.*; import static javax.lang.model.SourceVersion.*; /** - * An abstract annotation processor tailored to javac regression testing. + * An abstract annotation processor tailored to {@code javac} regression testing. */ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { private static final Set allAnnotations; @@ -103,7 +103,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { */ @SupportedSourceVersion(RELEASE_9) - public static abstract class AbstractAnnotationValueVisitor extends AbstractAnnotationValueVisitor8 { + public static abstract class AbstractAnnotationValueVisitor extends AbstractAnnotationValueVisitor9 { /** * Constructor for concrete subclasses to call. @@ -114,7 +114,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static abstract class AbstractElementVisitor extends AbstractElementVisitor8 { + public static abstract class AbstractElementVisitor extends AbstractElementVisitor9 { /** * Constructor for concrete subclasses to call. */ @@ -124,7 +124,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static abstract class AbstractTypeVisitor extends AbstractTypeVisitor8 { + public static abstract class AbstractTypeVisitor extends AbstractTypeVisitor9 { /** * Constructor for concrete subclasses to call. */ @@ -134,7 +134,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static class ElementKindVisitor extends ElementKindVisitor8 { + public static class ElementKindVisitor extends ElementKindVisitor9 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. @@ -155,7 +155,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static class ElementScanner extends ElementScanner8 { + public static class ElementScanner extends ElementScanner9 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. @@ -174,7 +174,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static class SimpleAnnotationValueVisitor extends SimpleAnnotationValueVisitor8 { + public static class SimpleAnnotationValueVisitor extends SimpleAnnotationValueVisitor9 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. @@ -195,7 +195,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static class SimpleElementVisitor extends SimpleElementVisitor8 { + public static class SimpleElementVisitor extends SimpleElementVisitor9 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. @@ -216,7 +216,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static class SimpleTypeVisitor extends SimpleTypeVisitor8 { + public static class SimpleTypeVisitor extends SimpleTypeVisitor9 { /** * Constructor for concrete subclasses; uses {@code null} for the * default value. @@ -237,7 +237,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { } @SupportedSourceVersion(RELEASE_9) - public static class TypeKindVisitor extends TypeKindVisitor8 { + public static class TypeKindVisitor extends TypeKindVisitor9 { /** * Constructor for concrete subclasses to call; uses {@code null} * for the default value. diff --git a/langtools/test/tools/javac/multicatch/model/ModelChecker.java b/langtools/test/tools/javac/multicatch/model/ModelChecker.java index dcbd5804534..5c3f44dad59 100644 --- a/langtools/test/tools/javac/multicatch/model/ModelChecker.java +++ b/langtools/test/tools/javac/multicatch/model/ModelChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,6 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.UnionType; import javax.lang.model.type.UnknownTypeException; import javax.lang.model.util.SimpleTypeVisitor6; -import javax.lang.model.util.SimpleTypeVisitor7; @SupportedAnnotationTypes("Check") public class ModelChecker extends JavacTestingAbstractProcessor { diff --git a/langtools/test/tools/javac/processing/model/TestSymtabItems.java b/langtools/test/tools/javac/processing/model/TestSymtabItems.java index 661dac4eb74..82accc27b3b 100644 --- a/langtools/test/tools/javac/processing/model/TestSymtabItems.java +++ b/langtools/test/tools/javac/processing/model/TestSymtabItems.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ public class TestSymtabItems { int errors; - class ElemPrinter extends ElementScanner8 { + class ElemPrinter extends ElementScanner9 { @Override public Void visitPackage(PackageElement e, Void p) { show("package", e); @@ -201,7 +201,7 @@ public class TestSymtabItems { int indent; }; - class TypePrinter extends SimpleTypeVisitor7 { + class TypePrinter extends SimpleTypeVisitor9 { @Override public Void defaultAction(TypeMirror m, Types types) { System.err.println(m.getKind() + " " + m + " " + types.asElement(m)); diff --git a/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java b/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java index a391be7e81f..10d2a5dd0de 100644 --- a/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java +++ b/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java @@ -53,7 +53,7 @@ public class TestTypeParameter extends JavacTestingAbstractProcessor { return true; } - class Scanner extends ElementScanner7 { + class Scanner extends ElementScanner { @Override public Integer visitExecutable(ExecutableElement e, Void p) { super.visitExecutable(e, p); diff --git a/langtools/test/tools/javac/processing/model/type/InheritedAP.java b/langtools/test/tools/javac/processing/model/type/InheritedAP.java index d2ba37aea59..36336acc051 100644 --- a/langtools/test/tools/javac/processing/model/type/InheritedAP.java +++ b/langtools/test/tools/javac/processing/model/type/InheritedAP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 8024513 * @library /tools/javac/lib - * @build InheritedAP + * @build JavacTestingAbstractProcessor InheritedAP * @compile -cp . -processor InheritedAP -proc:only InheritedAP.java * @summary NPE in annotation processing */ @@ -40,8 +40,7 @@ import static javax.lang.model.SourceVersion.*; import static javax.lang.model.util.ElementFilter.*; @SupportedAnnotationTypes("testclass") -@SupportedSourceVersion(RELEASE_8) -public class InheritedAP extends AbstractProcessor { +public class InheritedAP extends JavacTestingAbstractProcessor { static Types types; public void init(ProcessingEnvironment penv) {super.init(penv);} public static Types getTypes() { return types; } @@ -54,14 +53,14 @@ public class InheritedAP extends AbstractProcessor { types=processingEnv.getTypeUtils(); for (TypeElement typeElem: typesIn(renv.getRootElements())) { if (typeElem.getAnnotation(testclass.class) != null) { - new ElementScanner( new SimpleTypeMirrorVisitor()).scan(typeElem, null); + new LocalElementScanner( new SimpleTypeMirrorVisitor()).scan(typeElem, null); } } return true ; } } -class SimpleTypeMirrorVisitor extends SimpleTypeVisitor6 { +class SimpleTypeMirrorVisitor extends JavacTestingAbstractProcessor.SimpleTypeVisitor { protected Void defaultAction(TypeMirror mirror, Void p ) { try { System.out.println( "InheritedAP.getTypes().directSupertypes( "+mirror.toString()+" );" ); @@ -72,11 +71,11 @@ class SimpleTypeMirrorVisitor extends SimpleTypeVisitor6 { } } -class ElementScanner > - extends ElementScanner6 { - SimpleTypeVisitor6 typeVisitor; +class LocalElementScanner > + extends JavacTestingAbstractProcessor.ElementScanner { + JavacTestingAbstractProcessor.SimpleTypeVisitor typeVisitor; - public ElementScanner(T typeVisitor) { this.typeVisitor=typeVisitor;} + public LocalElementScanner(T typeVisitor) { this.typeVisitor=typeVisitor;} @Override public Void scan(Element e, Void p) { @@ -86,7 +85,6 @@ class ElementScanner > } return p; } - } diff --git a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java index 57cb1c3b014..9270e157bec 100644 --- a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ * @test * @bug 6877202 6986246 * @summary Elements.getDocComment() is not getting JavaDocComments + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor TestDocComments + * @run main TestDocComments */ import com.sun.source.tree.*; @@ -49,8 +52,7 @@ import javax.tools.*; */ @SupportedOptions("scan") -@SupportedAnnotationTypes("*") -public class TestDocComments extends AbstractProcessor { +public class TestDocComments extends JavacTestingAbstractProcessor { enum CompileKind { API, CMD }; enum ScanKind { TREE, ELEMENT }; @@ -72,7 +74,7 @@ public class TestDocComments extends AbstractProcessor { } static void test(CompileKind ck, ScanKind sk) throws IOException { - String testClasses = System.getProperty("test.classes"); + String testClasses = System.getProperty("test.class.path"); String testSrc = System.getProperty("test.src"); File testDir = new File("test." + ck + "." + sk); testDir.mkdirs(); @@ -136,26 +138,15 @@ public class TestDocComments extends AbstractProcessor { // ----- Annotation processor: scan for elements and check doc comments ---- Map options; - Filer filer; - Messager messager; - Elements elements; Trees trees; ScanKind skind; int round = 0; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - @Override public void init(ProcessingEnvironment pEnv) { super.init(pEnv); options = pEnv.getOptions(); - filer = pEnv.getFiler(); - messager = pEnv.getMessager(); - elements = pEnv.getElementUtils(); trees = Trees.instance(processingEnv); skind = ScanKind.valueOf(options.get("scan")); } @@ -271,7 +262,7 @@ public class TestDocComments extends AbstractProcessor { // ----- Scanners to find elements ----------------------------------------- - class TestElementScanner extends ElementScanner7 { + class TestElementScanner extends ElementScanner { @Override public Void visitExecutable(ExecutableElement e, Void _) { check(e); @@ -306,5 +297,4 @@ public class TestDocComments extends AbstractProcessor { return super.visitVariable(tree, trees); } } - } diff --git a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java index 61b70d28c70..296f7d7bf7c 100644 --- a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java +++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java @@ -25,8 +25,10 @@ * @test * @bug 8042345 * @summary getDocComment() fails for doc comments on PackageElement found in package-info.java + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor TestPackageInfoComments + * @run main TestPackageInfoComments */ - import com.sun.source.util.JavacTask; import java.io.*; @@ -37,14 +39,13 @@ import javax.lang.model.element.*; import javax.lang.model.util.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class TestPackageInfoComments extends AbstractProcessor { +public class TestPackageInfoComments extends JavacTestingAbstractProcessor { public static void main(String... args) throws Exception { String[] opts = { "-implicit:none", "-processor", TestPackageInfoComments.class.getName(), - "-processorpath", System.getProperty("test.classes") + "-processorpath", System.getProperty("test.class.path") }; File[] files = { new File(System.getProperty("test.src"), "p/package-info.java") @@ -68,21 +69,6 @@ public class TestPackageInfoComments extends AbstractProcessor { // -- Annotation processor: Check all PackageDecl's have a doc comment - Messager messager; - Elements elements; - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - @Override - public void init(ProcessingEnvironment pEnv) { - super.init(pEnv); - messager = pEnv.getMessager(); - elements = pEnv.getElementUtils(); - } - @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { for (Element e: roundEnv.getRootElements()) @@ -90,7 +76,7 @@ public class TestPackageInfoComments extends AbstractProcessor { return true; } - class TestElementScanner extends ElementScanner7 { + class TestElementScanner extends ElementScanner { @Override public Void visitPackage(PackageElement e, Void v) { if (elements.getDocComment(e) == null) diff --git a/langtools/test/tools/javac/tree/NoPrivateTypesExported.java b/langtools/test/tools/javac/tree/NoPrivateTypesExported.java index c16340e5782..cea3d2a2ff7 100644 --- a/langtools/test/tools/javac/tree/NoPrivateTypesExported.java +++ b/langtools/test/tools/javac/tree/NoPrivateTypesExported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,8 +51,6 @@ import javax.lang.model.type.IntersectionType; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; import javax.lang.model.type.WildcardType; -import javax.lang.model.util.ElementScanner8; -import javax.lang.model.util.SimpleAnnotationValueVisitor8; import javax.tools.Diagnostic.Kind; public class NoPrivateTypesExported extends JavacTestingAbstractProcessor { @@ -131,7 +129,7 @@ public class NoPrivateTypesExported extends JavacTestingAbstractProcessor { private void verifyReferredTypesAcceptable(Element rootElement, final Set acceptable) { - new ElementScanner8() { + new ElementScanner() { @Override public Void visitType(TypeElement e, Void p) { verifyTypeAcceptable(e.getSuperclass(), acceptable); verifyTypesAcceptable(e.getInterfaces(), acceptable); @@ -189,7 +187,7 @@ public class NoPrivateTypesExported extends JavacTestingAbstractProcessor { private void verifyAnnotationValue(AnnotationValue value, final Set acceptable) { - value.accept(new SimpleAnnotationValueVisitor8() { + value.accept(new SimpleAnnotationValueVisitor() { @Override public Void visitType(TypeMirror t, Void p) { verifyTypeAcceptable(t, acceptable); return null; diff --git a/langtools/test/tools/javap/BadAttributeLength.java b/langtools/test/tools/javap/BadAttributeLength.java new file mode 100644 index 00000000000..8c02770c7a8 --- /dev/null +++ b/langtools/test/tools/javap/BadAttributeLength.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8047072 + * @summary javap OOM on fuzzed classfile + * @run main BadAttributeLength + */ + + +import java.io.*; + +public class BadAttributeLength { + + public static String source = "public class Test {\n" + + " public static void main(String[] args) {}\n" + + "}"; + + public static void main(String[] args) throws Exception { + final File sourceFile = new File("Test.java"); + if (sourceFile.exists()) { + if (!sourceFile.delete()) { + throw new IOException("Can't override the Test.java file. " + + "Check permissions."); + } + } + try (FileWriter fw = new FileWriter(sourceFile)) { + fw.write(source); + } + + final String[] javacOpts = {"Test.java"}; + + if (com.sun.tools.javac.Main.compile(javacOpts) != 0) { + throw new Exception("Can't compile embedded test."); + } + + RandomAccessFile raf = new RandomAccessFile("Test.class", "rw"); + long attPos = getFirstAttributePos(raf); + if (attPos < 0) { + throw new Exception("The class file contains no attributes at all."); + } + raf.seek(attPos + 2); // Jump to the attribute length + raf.writeInt(Integer.MAX_VALUE - 1); + raf.close(); + + String[] opts = { "-v", "Test.class" }; + StringWriter sw = new StringWriter(); + PrintWriter pout = new PrintWriter(sw); + + com.sun.tools.javap.Main.run(opts, pout); + pout.flush(); + + if (sw.getBuffer().indexOf("OutOfMemoryError") != -1) { + throw new Exception("javap exited with OutOfMemoryError " + + "instead of giving the proper error message."); + } + } + + private static long getFirstAttributePos(RandomAccessFile cfile) throws Exception { + cfile.seek(0); + int v1, v2; + v1 = cfile.readInt(); + // System.out.println("Magic: " + String.format("%X", v1)); + + v1 = cfile.readUnsignedShort(); + v2 = cfile.readUnsignedShort(); + // System.out.println("Version: " + String.format("%d.%d", v1, v2)); + + v1 = cfile.readUnsignedShort(); + // System.out.println("CPool size: " + v1); + // Exhaust the constant pool + for (; v1 > 1; v1--) { + // System.out.print("."); + byte tag = cfile.readByte(); + switch (tag) { + case 7 : // Class + case 8 : // String + // Data is 2 bytes long + cfile.skipBytes(2); + break; + case 3 : // Integer + case 4 : // Float + case 9 : // FieldRef + case 10 : // MethodRef + case 11 : // InterfaceMethodRef + case 12 : // Name and Type + // Data is 4 bytes long + cfile.skipBytes(4); + break; + case 5 : // Long + case 6 : // Double + // Data is 8 bytes long + cfile.skipBytes(8); + break; + case 1 : // Utf8 + v2 = cfile.readUnsignedShort(); // Read buffer size + cfile.skipBytes(v2); // Skip buffer + break; + default : + throw new Exception("Unexpected tag in CPool: [" + tag + "] at " + + Long.toHexString(cfile.getFilePointer())); + } + } + // System.out.println(); + + cfile.skipBytes(6); // Access flags, this_class and super_class + v1 = cfile.readUnsignedShort(); // Number of interfaces + // System.out.println("Interfaces: " + v1); + cfile.skipBytes(3 * v1); // Each interface_info record is 3 bytes long + v1 = cfile.readUnsignedShort(); // Number of fields + // System.out.println("Fields: " + v1); + // Exhaust the fields table + for (; v1 > 0; v1--) { + // System.out.print("."); + cfile.skipBytes(6); // Skip access_flags, name_index and descriptor_index + v2 = cfile.readUnsignedShort(); // Field attributes count + if (v2 > 0) { + // This field has some attributes - suits our needs + // System.out.println(); + return cfile.getFilePointer(); + } + } + // System.out.println(); + v1 = cfile.readUnsignedShort(); // Number of methods + // System.out.println("Methods: " + v1); + // Exhaust the methods table + for (; v1 > 0; v1--) { + // System.out.print("."); + cfile.skipBytes(6); // Skip access_flags, name_index and descriptor_index + v2 = cfile.readUnsignedShort(); // Method attributes count + if (v2 > 0) { + // This method got attributes - Ok with us, + // return position of the first one + // System.out.println(); + return cfile.getFilePointer(); + } + } + // System.out.println(); + // Class attributes section + v1 = cfile.readUnsignedShort(); // Counts of attributes in class + if (v1 > 0) { + // Class has some attributes, return position of the first one + return cfile.getFilePointer(); + } + // Bummer! No attributes in the entire class file. Not fair! + return -1L; + } +} diff --git a/langtools/test/tools/jdeps/APIDeps.java b/langtools/test/tools/jdeps/APIDeps.java index bf01a77ba8c..c3d2c9977f7 100644 --- a/langtools/test/tools/jdeps/APIDeps.java +++ b/langtools/test/tools/jdeps/APIDeps.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8015912 8029216 8048063 + * @bug 8015912 8029216 8048063 8050804 * @summary Test -apionly and -jdkinternals options * @build m.Bar m.Foo m.Gee b.B c.C c.I d.D e.E f.F g.G * @run main APIDeps diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 348ae14dbc3..8d434cfcc7e 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -239,11 +239,15 @@ endef # Common echo of option define OptionOnly # opt - $(PRINTF) "%s\n" "$1" + if [ "$1" != "" ] ; then \ + $(PRINTF) "%s\n" "$1"; \ + fi endef + define OptionPair # opt arg $(PRINTF) "%s '%s'\n" "$1" '$2' endef + define OptionTrip # opt arg arg $(PRINTF) "%s '%s' '%s'\n" "$1" '$2' '$3' endef @@ -258,14 +262,7 @@ and working code examples.
    \ $(call CopyrightLine,$(COPYRIGHT_URL),$(FIRST_COPYRIGHT_YEAR),)\ -# Common javadoc options used by all -COMMON_JAVADOCFLAGS = \ - -XDignore.symbol.file=true \ - -quiet \ - -use \ - -keywords \ - -Xprofilespath $(JDK_TOPDIR)/make/profile-rtjar-includes.txt \ - $(ADDITIONAL_JAVADOCFLAGS) +# Common javadoc options used by all bundles ifdef OPENJDK ADDITIONAL_JAVADOCFLAGS = \ @@ -274,6 +271,52 @@ else ADDITIONAL_JAVADOCFLAGS = endif +define COMMON_JAVADOCFLAGS + $(call OptionOnly,-XDignore.symbol.file=true) ; \ + $(call OptionOnly,-quiet) ; \ + $(call OptionOnly,-use) ; \ + $(call OptionOnly,-keywords) ; \ + $(call OptionPair,-Xprofilespath,$(JDK_TOPDIR)/make/profile-rtjar-includes.txt) ; \ + $(call OptionOnly,$(ADDITIONAL_JAVADOCFLAGS)) +endef + +# Common javadoc tags used by all bundles + +# Java language specification cite +TAG_JLS = jls:a:See \ +The Java™ Language Specification: + +# Java virtual machine specification cite +TAG_JVMS = jvms:a:See \ +The Java™ Virtual Machine Specification: + +# In order to get a specific ordering it's necessary to specify the total +# ordering of tags as the tags are otherwise ordered in order of definition. +define COMMON_JAVADOCTAGS + $(call OptionPair,-tag,beaninfo:X) ; \ + $(call OptionPair,-tag,revised:X) ; \ + $(call OptionPair,-tag,since.unbundled:X) ; \ + $(call OptionPair,-tag,spec:X) ; \ + $(call OptionPair,-tag,specdefault:X) ; \ + $(call OptionPair,-tag,Note:X) ; \ + $(call OptionPair,-tag,ToDo:X) ; \ + $(call OptionPair,-tag,apiNote:a:API Note:) ; \ + $(call OptionPair,-tag,implSpec:a:Implementation Requirements:) ; \ + $(call OptionPair,-tag,implNote:a:Implementation Note:) ; \ + $(call OptionPair,-tag,param) ; \ + $(call OptionPair,-tag,return) ; \ + $(call OptionPair,-tag,throws) ; \ + $(call OptionPair,-tag,since) ; \ + $(call OptionPair,-tag,version) ; \ + $(call OptionPair,-tag,serialData) ; \ + $(call OptionPair,-tag,factory) ; \ + $(call OptionPair,-tag,see) ; \ + $(call OptionPair,-tag,$(TAG_JVMS)) ; \ + $(call OptionPair,-tag,$(TAG_JLS)) +endef + + + # Draft used for non-fcs documents DRAFT_HEADER = ifneq ($(MILESTONE), fcs) @@ -338,10 +381,6 @@ COREAPI_WINDOWTITLE = Java Platform SE $(JDK_MINOR_VERSION) COREAPI_HEADER = \ Java$(TRADEMARK) Platform
    Standard Ed. $(JDK_MINOR_VERSION)
    -# Java language specification cite -TAG_JLS = jls:a:See \ -The Java™ Language Specification: - # Overview file for core apis COREAPI_OVERVIEW = $(JDK_SHARE_CLASSES)/overview-core.html @@ -365,29 +404,11 @@ $(COREAPI_INDEX_FILE): $(COREAPI_OPTIONS_FILE) $(COREAPI_PACKAGES_FILE) # Create file with javadoc options in it $(COREAPI_OPTIONS_FILE): $(COREAPI_OVERVIEW) $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ - $(call OptionOnly,-Xdoclint:none) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ + $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ISO-8859-1) ; \ - $(call OptionPair,-tag,beaninfo:X) ; \ - $(call OptionPair,-tag,revised:X) ; \ - $(call OptionPair,-tag,since.unbundled:X) ; \ - $(call OptionPair,-tag,spec:X) ; \ - $(call OptionPair,-tag,specdefault:X) ; \ - $(call OptionPair,-tag,Note:X) ; \ - $(call OptionPair,-tag,ToDo:X) ; \ - $(call OptionPair,-tag,apiNote:a:API Note:) ; \ - $(call OptionPair,-tag,implSpec:a:Implementation Requirements:) ; \ - $(call OptionPair,-tag,implNote:a:Implementation Note:) ; \ - $(call OptionPair,-tag,param) ; \ - $(call OptionPair,-tag,return) ; \ - $(call OptionPair,-tag,throws) ; \ - $(call OptionPair,-tag,since) ; \ - $(call OptionPair,-tag,version) ; \ - $(call OptionPair,-tag,serialData) ; \ - $(call OptionPair,-tag,factory) ; \ - $(call OptionPair,-tag,see) ; \ - $(call OptionPair,-tag,$(TAG_JLS)) ; \ $(call OptionOnly,-splitIndex) ; \ $(call OptionPair,-overview,$(COREAPI_OVERVIEW)) ; \ $(call OptionPair,-doctitle,$(COREAPI_DOCTITLE)) ; \ @@ -441,7 +462,8 @@ $(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE) $( # Create file with javadoc options in it $(DOCLETAPI_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -498,7 +520,8 @@ $(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE) $( # Create file with javadoc options in it $(TAGLETAPI_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -550,7 +573,8 @@ $(DOMAPI_INDEX_FILE): $(DOMAPI_OPTIONS_FILE) $(DOMAPI_PACKAGES_FILE) $(COREAPI_I # Create file with javadoc options in it $(DOMAPI_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -613,7 +637,8 @@ $(JDI_INDEX_FILE): $(JDI_OPTIONS_FILE) $(JDI_PACKAGES_FILE) $(COREAPI_INDEX_FILE # Create file with javadoc options in it $(JDI_OPTIONS_FILE): $(JDI_OVERVIEW) $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -700,7 +725,8 @@ $(JAAS_INDEX_FILE): $(JAAS_OPTIONS_FILE) $(JAAS_PACKAGES_FILE) $(COREAPI_INDEX_F # Create file with javadoc options in it $(JAAS_OPTIONS_FILE): $(JAAS_OVERVIEW) $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -753,7 +779,8 @@ $(JGSS_INDEX_FILE): $(JGSS_OPTIONS_FILE) $(JGSS_PACKAGES_FILE) $(COREAPI_INDEX_F # Create file with javadoc options in it $(JGSS_OPTIONS_FILE): $(JGSS_OVERVIEW) $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -806,7 +833,8 @@ $(SMARTCARDIO_INDEX_FILE): $(SMARTCARDIO_OPTIONS_FILE) $(SMARTCARDIO_PACKAGES_FI # Create file with javadoc options in it $(SMARTCARDIO_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -857,7 +885,8 @@ $(HTTPSERVER_INDEX_HTML): $(HTTPSERVER_OPTIONS_FILE) $(HTTPSERVER_PACKAGES_FILE) # Create file with javadoc options in it $(HTTPSERVER_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -917,7 +946,8 @@ $(MGMT_INDEX_FILE): $(MGMT_OPTIONS_FILE) $(MGMT_PACKAGES_FILE) $(COREAPI_INDEX_F # Create file with javadoc options in it $(MGMT_OPTIONS_FILE): $(MGMT_OVERVIEW) $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -969,7 +999,8 @@ $(ATTACH_INDEX_HTML): $(ATTACH_OPTIONS_FILE) $(ATTACH_PACKAGES_FILE) $(COREAPI_I # Create file with javadoc options in it $(ATTACH_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -1020,7 +1051,8 @@ $(JCONSOLE_INDEX_HTML): $(JCONSOLE_OPTIONS_FILE) $(JCONSOLE_PACKAGES_FILE) $(COR # Create file with javadoc options in it $(JCONSOLE_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -1073,14 +1105,14 @@ $(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE) $(COREAP # Create file with javadoc options in it $(TREEAPI_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:all) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE)) ; \ $(call OptionPair,-windowtitle,$(TREEAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \ $(call OptionPair,-header,$(TREEAPI_HEADER)$(DRAFT_HEADER)) ; \ - $(call OptionPair,-tag,$(TAG_JLS)) ; \ $(call OptionPair,-bottom,$(TREEAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \ $(call OptionTrip,-group,$(TREEAPI_GROUPNAME),$(TREEAPI_REGEXP)); \ $(call OptionTrip,-linkoffline,$(TREEAPI2COREAPI),$(COREAPI_DOCSDIR)/); \ @@ -1125,7 +1157,8 @@ $(SCTPAPI_INDEX_HTML): $(SCTPAPI_OPTIONS_FILE) $(SCTPAPI_PACKAGES_FILE) $(COREAP # Create file with javadoc options in it $(SCTPAPI_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ @@ -1176,7 +1209,8 @@ $(JDKNET_INDEX_HTML): $(JDKNET_OPTIONS_FILE) $(JDKNET_PACKAGES_FILE) $(COREAPI_I # Create file with javadoc options in it $(JDKNET_OPTIONS_FILE): $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + @($(call COMMON_JAVADOCFLAGS) ; \ + $(call COMMON_JAVADOCTAGS) ; \ $(call OptionOnly,-Xdoclint:none) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ diff --git a/make/Jprt.gmk b/make/Jprt.gmk index a7f9226d99f..59b76cdf4eb 100644 --- a/make/Jprt.gmk +++ b/make/Jprt.gmk @@ -46,6 +46,10 @@ ifndef JPRT_ARCHIVE_INSTALL_BUNDLE JPRT_ARCHIVE_INSTALL_BUNDLE=/tmp/jprt_bundles/product-install.zip endif +ifeq ($(SKIP_BOOT_CYCLE), false) + jprt_bundle: bootcycle-images +endif + # This target must be called in the context of a SPEC file jprt_bundle: $(JPRT_ARCHIVE_BUNDLE) @$(call CheckIfMakeAtEnd) diff --git a/make/jprt.properties b/make/jprt.properties index a5ca05cb8c9..eed8b41077d 100644 --- a/make/jprt.properties +++ b/make/jprt.properties @@ -249,7 +249,7 @@ my.test.targets.hotspot.solaris.sparcv9= \ solaris_sparcv9_5.11-{product|fastdebug}-c2-jvm98, \ solaris_sparcv9_5.11-{product|fastdebug}-c2-jvm98_nontiered, \ solaris_sparcv9_5.11-{product|fastdebug}-c2-scimark, \ - solaris_sparcv9_5.11-product-c2-runThese, \ + solaris_sparcv9_5.11-product-c2-runThese8, \ solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_SerialGC, \ solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_ParallelGC, \ solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_ParNewGC, \ @@ -273,8 +273,9 @@ my.test.targets.hotspot.solaris.x64= \ solaris_x64_5.11-{product|fastdebug}-c2-jvm98, \ solaris_x64_5.11-{product|fastdebug}-c2-jvm98_nontiered, \ solaris_x64_5.11-{product|fastdebug}-c2-scimark, \ - solaris_x64_5.11-product-c2-runThese, \ - solaris_x64_5.11-product-c2-runThese_Xcomp, \ + solaris_x64_5.11-product-c2-runThese8, \ + solaris_x64_5.11-product-c2-runThese8_Xcomp_lang, \ + solaris_x64_5.11-product-c2-runThese8_Xcomp_vm, \ solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_SerialGC, \ solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_ParallelGC, \ solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_ParNewGC, \ @@ -298,9 +299,11 @@ my.test.targets.hotspot.linux.i586= \ linux_i586_2.6-{product|fastdebug}-{c1|c2}-jvm98, \ linux_i586_2.6-{product|fastdebug}-c2-jvm98_nontiered, \ linux_i586_2.6-{product|fastdebug}-{c1|c2}-scimark, \ - linux_i586_2.6-product-c1-runThese_Xcomp, \ - linux_i586_2.6-fastdebug-c1-runThese_Xshare, \ - linux_i586_2.6-fastdebug-c2-runThese_Xcomp, \ + linux_i586_2.6-product-c1-runThese8_Xcomp_lang, \ + linux_i586_2.6-product-c1-runThese8_Xcomp_vm, \ + linux_i586_2.6-fastdebug-c1-runThese8_Xshare, \ + linux_i586_2.6-fastdebug-c2-runThese8_Xcomp_lang, \ + linux_i586_2.6-fastdebug-c2-runThese8_Xcomp_vm, \ linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \ linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \ linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_ParNewGC, \ @@ -366,9 +369,10 @@ my.test.targets.hotspot.windows.i586= \ windows_i586_6.1-{product|fastdebug}-{c1|c2}-jvm98, \ windows_i586_6.1-{product|fastdebug}-c2-jvm98_nontiered, \ windows_i586_6.1-{product|fastdebug}-{c1|c2}-scimark, \ - windows_i586_6.1-product-{c1|c2}-runThese, \ - windows_i586_6.1-product-{c1|c2}-runThese_Xcomp, \ - windows_i586_6.1-fastdebug-c1-runThese_Xshare, \ + windows_i586_6.1-product-{c1|c2}-runThese8, \ + windows_i586_6.1-product-{c1|c2}-runThese8_Xcomp_lang, \ + windows_i586_6.1-product-{c1|c2}-runThese8_Xcomp_vm, \ + windows_i586_6.1-fastdebug-c1-runThese8_Xshare, \ windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \ windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \ windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_ParNewGC, \ @@ -392,8 +396,9 @@ my.test.targets.hotspot.windows.x64= \ windows_x64_6.1-{product|fastdebug}-c2-jvm98, \ windows_x64_6.1-{product|fastdebug}-c2-jvm98_nontiered, \ windows_x64_6.1-{product|fastdebug}-c2-scimark, \ - windows_x64_6.1-product-c2-runThese, \ - windows_x64_6.1-product-c2-runThese_Xcomp, \ + windows_x64_6.1-product-c2-runThese8, \ + windows_x64_6.1-product-c2-runThese8_Xcomp_lang, \ + windows_x64_6.1-product-c2-runThese8_Xcomp_vm, \ windows_x64_6.1-{product|fastdebug}-c2-GCBasher_SerialGC, \ windows_x64_6.1-{product|fastdebug}-c2-GCBasher_ParallelGC, \ windows_x64_6.1-{product|fastdebug}-c2-GCBasher_ParNewGC, \ @@ -460,19 +465,23 @@ my.make.rule.test.targets.hotspot.internalvmtests= \ windows_i586_6.1-fastdebug-c2-hotspot_internalvmtests, \ windows_x64_6.1-fastdebug-c2-hotspot_internalvmtests -my.make.rule.test.targets.hotspot.wbapitests= \ - solaris_sparcv9_5.11-{product|fastdebug}-c2-hotspot_wbapitest, \ - solaris_x64_5.11-{product|fastdebug}-c2-hotspot_wbapitest, \ - linux_i586_2.6-{product|fastdebug}-c2-hotspot_wbapitest, \ - linux_x64_2.6-{product|fastdebug}-c2-hotspot_wbapitest, \ - windows_i586_6.1-{product|fastdebug}-c2-hotspot_wbapitest, \ - windows_x64_6.1-{product|fastdebug}-c2-hotspot_wbapitest, \ - linux_i586_2.6-{product|fastdebug}-c1-hotspot_wbapitest, \ - windows_i586_6.1-{product|fastdebug}-c1-hotspot_wbapitest +my.make.rule.test.targets.hotspot.reg.group= \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GROUP, \ + solaris_x64_5.11-{product|fastdebug}-c2-GROUP, \ + linux_i586_2.6-{product|fastdebug}-c2-GROUP, \ + linux_x64_2.6-{product|fastdebug}-c2-GROUP, \ + windows_i586_6.1-{product|fastdebug}-c2-GROUP, \ + windows_x64_6.1-{product|fastdebug}-c2-GROUP, \ + linux_i586_2.6-{product|fastdebug}-c1-GROUP, \ + windows_i586_6.1-{product|fastdebug}-c1-GROUP -my.make.rule.test.targets.hotspot= \ - ${my.make.rule.test.targets.hotspot.clienttests}, \ - ${my.make.rule.test.targets.hotspot.servertests}, \ - ${my.make.rule.test.targets.hotspot.internalvmtests}, \ - ${my.make.rule.test.targets.hotspot.wbapitests}, \ +my.make.rule.test.targets.hotspot= \ + ${my.make.rule.test.targets.hotspot.clienttests}, \ + ${my.make.rule.test.targets.hotspot.servertests}, \ + ${my.make.rule.test.targets.hotspot.internalvmtests}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_wbapitest}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_gc}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_runtime}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_serviceability}, \ ${my.additional.make.rule.test.targets.hotspot} diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 8a3b96daa6c..f529a5ef4ec 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -257,3 +257,5 @@ d703c59c556f9fcd9604272806ef7acf55c92363 jdk9-b20 174cf53bce4e93a3d5d880ed7915ce8d0f08bc5e jdk9-b21 a9d39bcfeb1bb3f7de929c56a2ecbea10a554ca1 jdk9-b22 aa3fda2d2967847dbd264aa962d624c07fc6c29f jdk9-b23 +49d7a2a66ae6b70fee367e2ceb29d0c20f8be01b jdk9-b24 +b33633fc10c5bffd39d3492ed2602dadd8d44642 jdk9-b25 diff --git a/nashorn/make/build-nasgen.xml b/nashorn/make/build-nasgen.xml index 9dca5505316..16094cc964b 100644 --- a/nashorn/make/build-nasgen.xml +++ b/nashorn/make/build-nasgen.xml @@ -36,11 +36,13 @@ + + - + - + diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 78cc8f9ea26..35edc417edb 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -304,6 +304,14 @@ grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" { grant codeBase "file:/${basedir}/${file.reference.testng.jar}" { permission java.security.AllPermission; }; +//// in case of absolute path: +grant codeBase "file:/${nashorn.internal.tests.jar}" { + permission java.security.AllPermission; +}; + +grant codeBase "file:/${file.reference.testng.jar}" { + permission java.security.AllPermission; +}; grant codeBase "file:/${basedir}/test/script/trusted/*" { permission java.security.AllPermission; @@ -391,7 +399,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - + @@ -413,7 +421,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - + @@ -451,7 +459,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - + @@ -471,7 +479,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - + @@ -490,7 +498,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - + @@ -510,7 +518,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - + diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index 77f8ed73bf7..642793a8e66 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -309,7 +309,7 @@ run.test.jvmargs.main=${run.test.jvmargs.common} -ea run.test.jvmargs.octane.main=${run.test.jvmargs.common} -XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode -XX:TypeProfileLevel=222 # Security manager args - make sure that we run with the nashorn.policy that the build creates -run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy +run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${build.dir}/nashorn.policy # VM options for script tests with @fork option test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath} diff --git a/nashorn/src/jdk/internal/dynalink/linker/GuardedInvocation.java b/nashorn/src/jdk/internal/dynalink/linker/GuardedInvocation.java index 34dcdc03d76..00ee9dc77cb 100644 --- a/nashorn/src/jdk/internal/dynalink/linker/GuardedInvocation.java +++ b/nashorn/src/jdk/internal/dynalink/linker/GuardedInvocation.java @@ -193,7 +193,7 @@ public class GuardedInvocation { invocation.getClass(); // NPE check this.invocation = invocation; this.guard = guard; - this.switchPoints = switchPoints; + this.switchPoints = switchPoints == null ? null : switchPoints.clone(); this.exception = exception; } diff --git a/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java b/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java index 91946969370..d1ff028076f 100644 --- a/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java +++ b/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java @@ -111,7 +111,7 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin private final TypeBasedGuardingDynamicLinker[] linkers; private final List[] singletonLinkers; - @SuppressWarnings(value={"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes"}) ClassToLinker(final TypeBasedGuardingDynamicLinker[] linkers) { this.linkers = linkers; singletonLinkers = new List[linkers.length]; @@ -135,7 +135,6 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin case 1: { list = new LinkedList<>(list); } - //$FALL-THROUGH$ default: { list.add(linker); } diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index f19857386e6..abdb79c287c 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -40,6 +40,7 @@ import java.security.ProtectionDomain; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; + import javax.script.AbstractScriptEngine; import javax.script.Bindings; import javax.script.Compilable; @@ -50,6 +51,7 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptException; import javax.script.SimpleBindings; + import jdk.nashorn.internal.objects.Global; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ErrorManager; @@ -429,7 +431,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C return evalImpl(script, ctxt, getNashornGlobalFrom(ctxt)); } - private Object evalImpl(final Context.MultiGlobalCompiledScript mgcs, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException { + private static Object evalImpl(final Context.MultiGlobalCompiledScript mgcs, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException { final Global oldGlobal = Context.getGlobal(); final boolean globalChanged = (oldGlobal != ctxtGlobal); try { @@ -450,7 +452,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } } - private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException { + private static Object evalImpl(final ScriptFunction script, final ScriptContext ctxt, final Global ctxtGlobal) throws ScriptException { if (script == null) { return null; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 46a6b86bfd3..5b7bf91ab2a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -314,7 +314,7 @@ final class CodeGenerator extends NodeOperatorVisitor ", newUnit); + log.fine("Creating new compile unit ", oldUnit, " => ", newUnit); map.put(oldUnit, newUnit); assert newUnit != null; newUnits.add(newUnit); } - log.info("Replacing compile units in Compiler..."); + log.fine("Replacing compile units in Compiler..."); compiler.replaceCompileUnits(newUnits); - log.info("Done"); + log.fine("Done"); //replace old compile units in function nodes, if any are assigned, //for example by running the splitter on this function node in a previous @@ -564,7 +563,7 @@ enum CompilationPhase { append(compiler.getCompileUnits().size()). append(" compile unit(s)]"); - log.info(sb.toString()); + log.fine(sb.toString()); } return setStates(fn.setRootClass(null, rootClass), BYTECODE_INSTALLED); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index f5281ba9d56..205c65b6fe9 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -50,6 +50,7 @@ import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.logging.Level; + import jdk.internal.dynalink.support.NameCodec; import jdk.nashorn.internal.codegen.ClassEmitter.Flag; import jdk.nashorn.internal.codegen.types.Type; @@ -502,7 +503,7 @@ public final class Compiler implements Loggable { */ public FunctionNode compile(final FunctionNode functionNode, final CompilationPhases phases) throws CompilationException { - log.info("Starting compile job for ", DebugLogger.quote(functionNode.getName()), " phases=", quote(phases.getDesc())); + log.finest("Starting compile job for ", DebugLogger.quote(functionNode.getName()), " phases=", quote(phases.getDesc())); log.indent(); final String name = DebugLogger.quote(functionNode.getName()); @@ -531,7 +532,7 @@ public final class Compiler implements Loggable { time += (env.isTimingEnabled() ? phase.getEndTime() - phase.getStartTime() : 0L); } - if(typeInformationFile != null && !phases.isRestOfCompilation()) { + if (typeInformationFile != null && !phases.isRestOfCompilation()) { OptimisticTypesPersistence.store(typeInformationFile, invalidatedProgramPoints); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java index df763c1ba4f..130bd66f906 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java @@ -1196,9 +1196,7 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ } else if(binaryNode.isOptimisticUndecidedType()) { // At this point, we can assign a static type to the optimistic binary ADD operator as now we know // the types of its operands. - final Type type = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType()); - // Use Type.CHARSEQUENCE instead of Type.STRING to avoid conversion of ConsStrings to Strings. - return binaryNode.setType(type.equals(Type.STRING) ? Type.CHARSEQUENCE : type); + return binaryNode.decideType(); } return binaryNode; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 9f713e04dde..f2808791e21 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.ListIterator; + import jdk.nashorn.internal.ir.BaseNode; import jdk.nashorn.internal.ir.BinaryNode; import jdk.nashorn.internal.ir.Block; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java b/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java index 00e59b3c65d..3d5dc27e5b6 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java @@ -41,6 +41,7 @@ import java.util.Base64; import java.util.Date; import java.util.Map; import java.util.TreeMap; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData; @@ -111,6 +112,7 @@ public final class OptimisticTypesPersistence { return; } final File file = ((LocationDescriptor)locationDescriptor).file; + AccessController.doPrivileged(new PrivilegedAction() { @Override public Void run() { @@ -119,7 +121,7 @@ public final class OptimisticTypesPersistence { out.getChannel().lock(); // lock exclusive final DataOutputStream dout = new DataOutputStream(new BufferedOutputStream(out)); dout.writeInt(optimisticTypes.size()); - for(Map.Entry e: optimisticTypes.entrySet()) { + for(final Map.Entry e: optimisticTypes.entrySet()) { dout.writeInt(e.getKey()); final byte typeChar; final Type type = e.getValue(); @@ -156,7 +158,6 @@ public final class OptimisticTypesPersistence { return null; } final File file = ((LocationDescriptor)locationDescriptor).file; - return AccessController.doPrivileged(new PrivilegedAction>() { @Override public Map run() { @@ -229,7 +230,7 @@ public final class OptimisticTypesPersistence { final String versionDirName; try { versionDirName = getVersionDirName(); - } catch(Exception e) { + } catch(final Exception e) { getLogger().warning("Failed to calculate version dir name", e); return null; } @@ -306,7 +307,7 @@ public final class OptimisticTypesPersistence { private static long getLastModifiedClassFile(final File dir, final long max) { long currentMax = max; - for(File f: dir.listFiles()) { + for(final File f: dir.listFiles()) { if(f.getName().endsWith(".class")) { final long lastModified = f.lastModified(); if(lastModified > currentMax) { diff --git a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java index 8411e263bfa..f32f6325622 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java @@ -183,17 +183,31 @@ public final class BinaryNode extends Expression implements Assignment localVariableTypes) { if(type == OPTIMISTIC_UNDECIDED_TYPE) { - return Type.widest(lhs.getType(localVariableTypes), rhs.getType(localVariableTypes)); + return decideType(lhs.getType(localVariableTypes), rhs.getType(localVariableTypes)); } final Type widest = getWidestOperationType(localVariableTypes); if(type == null) { @@ -536,6 +558,32 @@ public final class BinaryNode extends Expression implements Assignment @Override public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterBlock(this)) { - return visitor.leaveBlock(setStatements(lc, Node.accept(visitor, Statement.class, statements))); + return visitor.leaveBlock(setStatements(lc, Node.accept(visitor, statements))); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java index 0751ce4087d..be7abe3287f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CallNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CallNode.java @@ -30,6 +30,7 @@ import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_ import java.util.Collections; import java.util.List; import java.util.function.Function; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.annotations.Immutable; @@ -175,10 +176,10 @@ public final class CallNode extends LexicalContextExpression implements Optimist if (visitor.enterCallNode(this)) { final CallNode newCallNode = (CallNode)visitor.leaveCallNode( setFunction((Expression)function.accept(visitor)). - setArgs(Node.accept(visitor, Expression.class, args)). + setArgs(Node.accept(visitor, args)). setEvalArgs(evalArgs == null ? null : - evalArgs.setArgs(Node.accept(visitor, Expression.class, evalArgs.getArgs())))); + evalArgs.setArgs(Node.accept(visitor, evalArgs.getArgs())))); // Theoretically, we'd need to instead pass lc to every setter and do a replacement on each. In practice, // setType from TypeOverride can't accept a lc, and we don't necessarily want to go there now. if (this != newCallNode) { diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index 282c19ed0c7..9481b3ad95c 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -359,7 +359,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag * @return a list of parameter nodes, potentially modified from original ones by the visitor. */ public List visitParameters(final NodeVisitor visitor) { - return Node.accept(visitor, IdentNode.class, parameters); + return Node.accept(visitor, parameters); } /** diff --git a/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java b/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java index 2a1a4249fb6..543dc08a0b0 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir; import java.io.File; import java.util.Iterator; import java.util.NoSuchElementException; + import jdk.nashorn.internal.runtime.Debug; import jdk.nashorn.internal.runtime.Source; @@ -652,6 +653,7 @@ public class LexicalContext { return lnext; } + @SuppressWarnings("unchecked") private T findNext() { for (int i = index; i >= 0; i--) { final Object node = stack[i]; @@ -660,7 +662,7 @@ public class LexicalContext { } if (clazz.isAssignableFrom(node.getClass())) { index = i - 1; - return clazz.cast(node); + return (T)node; } } return null; diff --git a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java index b71e450389f..787aae225c4 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java @@ -934,7 +934,7 @@ public abstract class LiteralNode extends Expression implements PropertyKey { public Node accept(final LexicalContext lc, final NodeVisitor visitor) { if (visitor.enterLiteralNode(this)) { final List oldValue = Arrays.asList(value); - final List newValue = Node.accept(visitor, Expression.class, oldValue); + final List newValue = Node.accept(visitor, oldValue); return visitor.leaveLiteralNode(oldValue != newValue ? setValue(lc, newValue) : this); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/Node.java b/nashorn/src/jdk/nashorn/internal/ir/Node.java index 191d702ab64..29feadd31ea 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Node.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Node.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir; import java.util.ArrayList; import java.util.List; + import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; import jdk.nashorn.internal.parser.TokenType; @@ -232,19 +233,34 @@ public abstract class Node implements Cloneable { } //on change, we have to replace the entire list, that's we can't simple do ListIterator.set - static List accept(final NodeVisitor visitor, final Class clazz, final List list) { - boolean changed = false; - final List newList = new ArrayList<>(); - - for (final Node node : list) { - final T newNode = node == null ? null : clazz.cast(node.accept(visitor)); - if (newNode != node) { - changed = true; - } - newList.add(newNode); + static List accept(final NodeVisitor visitor, final List list) { + final int size = list.size(); + if (size == 0) { + return list; } - return changed ? newList : list; + List newList = null; + + for (int i = 0; i < size; i++) { + final T node = list.get(i); + @SuppressWarnings("unchecked") + final T newNode = node == null ? null : (T)node.accept(visitor); + if (newNode != node) { + if (newList == null) { + newList = new ArrayList<>(size); + for (int j = 0; j < i; j++) { + newList.add(list.get(j)); + } + } + newList.add(newNode); + } else { + if (newList != null) { + newList.add(node); + } + } + } + + return newList == null ? list : newList; } static T replaceInLexicalContext(final LexicalContext lc, final T oldNode, final T newNode) { diff --git a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java index ca08162bdac..38fd667d095 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ObjectNode.java @@ -61,7 +61,7 @@ public final class ObjectNode extends Expression { @Override public Node accept(final NodeVisitor visitor) { if (visitor.enterObjectNode(this)) { - return visitor.leaveObjectNode(setElements(Node.accept(visitor, PropertyNode.class, elements))); + return visitor.leaveObjectNode(setElements(Node.accept(visitor, elements))); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java index 095fd1987c6..a3eac1ce26f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/SwitchNode.java @@ -104,7 +104,7 @@ public final class SwitchNode extends BreakableStatement { if (visitor.enterSwitchNode(this)) { return visitor.leaveSwitchNode( setExpression(lc, (Expression)expression.accept(visitor)). - setCases(lc, Node.accept(visitor, CaseNode.class, cases), defaultCaseIndex)); + setCases(lc, Node.accept(visitor, cases), defaultCaseIndex)); } return this; diff --git a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java index 29338615881..87a8c565d6d 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/TryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/TryNode.java @@ -112,7 +112,7 @@ public final class TryNode extends Statement implements JoinPredecessor { return visitor.leaveTryNode( setBody(newBody). setFinallyBody(newFinallyBody). - setCatchBlocks(Node.accept(visitor, Block.class, catchBlocks)). + setCatchBlocks(Node.accept(visitor, catchBlocks)). setFinallyCatchAll(finallyCatchAll)); } diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/ClassHistogramElement.java b/nashorn/src/jdk/nashorn/internal/ir/debug/ClassHistogramElement.java index c65f8ef7ce7..d5c8174fe1c 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/ClassHistogramElement.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/ClassHistogramElement.java @@ -30,7 +30,7 @@ import java.util.Comparator; /** * Class histogram element for IR / Java object instrumentation */ -public class ClassHistogramElement { +public final class ClassHistogramElement { /** * Instance comparator */ diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/NashornTextifier.java b/nashorn/src/jdk/nashorn/internal/ir/debug/NashornTextifier.java index 0ec3ea3ccb8..5dbf35432cb 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/NashornTextifier.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/NashornTextifier.java @@ -39,6 +39,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; + import jdk.internal.org.objectweb.asm.Attribute; import jdk.internal.org.objectweb.asm.Handle; import jdk.internal.org.objectweb.asm.Label; @@ -1082,11 +1083,15 @@ public final class NashornTextifier extends Printer { contents.put(node, sb); } + private static String dottyFriendly(final String name) { + return name.replace(':', '_'); + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("digraph " + name + " {"); + sb.append("digraph " + dottyFriendly(name) + " {"); sb.append("\n"); sb.append("\tgraph [fontname=courier]\n"); sb.append("\tnode [style=filled,color="+COLOR_DEFAULT+",fontname=courier]\n"); diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java b/nashorn/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java index 9e3d9ce5e8f..53a09a68aa8 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java @@ -52,7 +52,7 @@ import java.util.Map; * this fact and will report incorrect sizes, as it will presume the default JVM * behavior. */ -public class ObjectSizeCalculator { +public final class ObjectSizeCalculator { /** * Describes constant memory overheads for various constructs in a JVM implementation. diff --git a/nashorn/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java b/nashorn/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java index 0e8de8900c9..8ef13d794c0 100644 --- a/nashorn/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java +++ b/nashorn/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java @@ -124,11 +124,13 @@ public final class MethodHandleFactory { * @return return value unmodified */ static Object traceReturn(final DebugLogger logger, final Object value) { - final String str = " return" + - (VOID_TAG.equals(value) ? - ";" : - " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']')); - logger.log(TRACE_LEVEL, str); + if (logger.isEnabled()) { + final String str = " return" + + (VOID_TAG.equals(value) ? + ";" : + " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']')); + logger.log(TRACE_LEVEL, str); + } return value; } diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index 1c7e96b5a2c..8e72be7efa0 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -46,8 +46,10 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; + import javax.script.ScriptContext; import javax.script.ScriptEngine; + import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; import jdk.nashorn.api.scripting.ScriptObjectMirror; @@ -563,6 +565,8 @@ public final class Global extends ScriptObject implements Scope { * Initialize standard builtin objects like "Object", "Array", "Function" etc. * as well as our extension builtin objects like "Java", "JSAdapter" as properties * of the global scope object. + * + * @param engine ScriptEngine to initialize */ public void initBuiltinObjects(final ScriptEngine engine) { if (this.builtinObject != null) { @@ -1936,15 +1940,16 @@ public final class Global extends ScriptObject implements Scope { } private Object printImpl(final boolean newLine, final Object... objects) { + @SuppressWarnings("resource") final PrintWriter out = scontext != null? new PrintWriter(scontext.getWriter()) : getContext().getEnv().getOut(); final StringBuilder sb = new StringBuilder(); - for (final Object object : objects) { + for (final Object obj : objects) { if (sb.length() != 0) { sb.append(' '); } - sb.append(JSType.toString(object)); + sb.append(JSType.toString(obj)); } // Print all at once to ensure thread friendly result. diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java index 0f42998d261..eac59c46cc3 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java @@ -935,7 +935,6 @@ public final class NativeDate extends ScriptObject { } sb.append(' '); - //$FALL-THROUGH$ case FORMAT_TIME: final TimeZone tz = nd.getTimeZone(); final double utcTime = nd.getTime(); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java index 08ad24cc8a7..0a56d5cdd53 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java @@ -39,6 +39,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Callable; + import jdk.internal.dynalink.beans.BeansLinker; import jdk.internal.dynalink.beans.StaticClass; import jdk.internal.dynalink.linker.GuardedInvocation; @@ -716,7 +717,7 @@ public final class NativeObject { return target; } - /* + /** * Binds the source mirror object's properties to the target object. Binding * properties allows two-way read/write for the properties of the source object. * All inherited, enumerable properties are also bound. This method is used to @@ -731,7 +732,7 @@ public final class NativeObject { // make accessor properties using dynamic invoker getters and setters final AccessorProperty[] props = new AccessorProperty[keys.size()]; int idx = 0; - for (String name : keys) { + for (final String name : keys) { final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE); final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE); props[idx] = AccessorProperty.create(name, 0, getter, setter); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java index 8e81924d3cf..db19ab37a59 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java @@ -80,7 +80,8 @@ public final class NativeUint8ClampedArray extends ArrayBufferView { private static final MethodHandle GET_ELEM = specialCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "getElem", int.class, int.class).methodHandle(); private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); - private static final MethodHandle RINT = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", double.class, double.class).methodHandle(); + private static final MethodHandle RINT_D = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", double.class, double.class).methodHandle(); + private static final MethodHandle RINT_O = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", Object.class, Object.class).methodHandle(); private static final MethodHandle CLAMP_LONG = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "clampLong", long.class, long.class).methodHandle(); private Uint8ClampedArrayData(final ByteBuffer nb, final int start, final int end) { @@ -109,8 +110,10 @@ public final class NativeUint8ClampedArray extends ArrayBufferView { public MethodHandle getElementSetter(final Class elementType) { final MethodHandle setter = super.getElementSetter(elementType); //getContinuousElementSetter(getClass(), setElem(), elementType); if (setter != null) { - if (elementType == double.class) { - return MH.filterArguments(setter, 2, RINT); + if (elementType == Object.class) { + return MH.filterArguments(setter, 2, RINT_O); + } else if (elementType == double.class) { + return MH.filterArguments(setter, 2, RINT_D); } else if (elementType == long.class) { return MH.filterArguments(setter, 2, CLAMP_LONG); } @@ -190,6 +193,11 @@ public final class NativeUint8ClampedArray extends ArrayBufferView { return (int)Math.rint(rint); } + @SuppressWarnings("unused") + private static Object rint(final Object rint) { + return rint(JSType.toNumber(rint)); + } + @SuppressWarnings("unused") private static long clampLong(final long l) { if(l < 0L) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java b/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java index 462028e886b..d7d23eacaf3 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ECMAErrors.java @@ -28,7 +28,7 @@ package jdk.nashorn.internal.runtime; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; -import jdk.nashorn.api.scripting.NashornException; + import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.objects.Global; import jdk.nashorn.internal.scripts.JS; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index fc14707730b..e042007ce00 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -36,6 +36,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.TreeMap; + import jdk.internal.dynalink.support.NameCodec; import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.Compiler; @@ -236,14 +237,14 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp /** * Initialize transient fields on deserialized instances * - * @param source source - * @param installer code installer + * @param src source + * @param inst code installer */ - public void initTransients(final Source source, final CodeInstaller installer) { + public void initTransients(final Source src, final CodeInstaller inst) { if (this.source == null && this.installer == null) { - this.source = source; - this.installer = installer; - } else if (this.source != source || this.installer != installer) { + this.source = src; + this.installer = inst; + } else if (this.source != src || this.installer != inst) { // Existing values must be same as those passed as parameters throw new IllegalArgumentException(); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 4f36eb55e38..fc42e86b55b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -3626,7 +3626,6 @@ public abstract class ScriptObject implements PropertyAccess { return MH.insertArguments(KNOWNFUNCPROPGUARDPROTO, 1, map, getter, depth, func); } - @SuppressWarnings("unused") private static ScriptObject getProto(final ScriptObject self, final int depth) { ScriptObject proto = self; for (int d = 0; d < depth; d++) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java index a73b7ab992f..d4350c5998a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java @@ -484,17 +484,16 @@ public final class ScriptRuntime { final Object unwrapped = ScriptObjectMirror.unwrap(expression, global); if (unwrapped instanceof ScriptObject) { return new WithObject(scope, (ScriptObject)unwrapped); - } else { - // foreign ScriptObjectMirror - ScriptObject exprObj = global.newObject(); - NativeObject.bindAllProperties(exprObj, (ScriptObjectMirror)expression); - return new WithObject(scope, exprObj); - } - } else { - final Object wrappedExpr = JSType.toScriptObject(global, expression); - if (wrappedExpr instanceof ScriptObject) { - return new WithObject(scope, (ScriptObject)wrappedExpr); } + // foreign ScriptObjectMirror + final ScriptObject exprObj = global.newObject(); + NativeObject.bindAllProperties(exprObj, (ScriptObjectMirror)expression); + return new WithObject(scope, exprObj); + } + + final Object wrappedExpr = JSType.toScriptObject(global, expression); + if (wrappedExpr instanceof ScriptObject) { + return new WithObject(scope, (ScriptObject)wrappedExpr); } throw typeError(global, "cant.apply.with.to.non.scriptobject"); @@ -819,9 +818,8 @@ public final class ScriptRuntime { /** ECMA 11.9.6 The Strict Equality Comparison Algorithm */ private static boolean strictEquals(final Object x, final Object y) { - if(x == y) { - return true; - } + // NOTE: you might be tempted to do a quick x == y comparison. Remember, though, that any Double object having + // NaN value is not equal to itself by value even though it is referentially. final JSType xType = JSType.ofNoFunction(x); final JSType yType = JSType.ofNoFunction(y); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java index ac5f5a76e4a..009d7b943a9 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java @@ -31,12 +31,13 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.invoke.SwitchPoint; -import jdk.nashorn.api.scripting.AbstractJSObject; -import jdk.nashorn.api.scripting.ScriptObjectMirror; + import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; import jdk.internal.dynalink.support.CallSiteDescriptorFactory; +import jdk.nashorn.api.scripting.AbstractJSObject; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; import jdk.nashorn.internal.runtime.linker.NashornGuards; @@ -322,6 +323,7 @@ public final class WithObject extends ScriptObject implements Scope { // We need to make sure correct 'this' is used for calls with Ident call // expressions. We do so here using an AbstractJSObject instance. return new AbstractJSObject() { + @Override public Object call(final Object thiz, final Object... args) { return mirror.call(withFilterExpression(receiver), args); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java index db755cb9a0e..ed39fa95481 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java @@ -78,7 +78,10 @@ public final class Options { /** The options map of enabled options */ private final TreeMap> options; - /** System property that can be used for command line option propagation */ + /** System property that can be used to prepend options to the explicitly specified command line. */ + private static final String NASHORN_ARGS_PREPEND_PROPERTY = "nashorn.args.prepend"; + + /** System property that can be used to append options to the explicitly specified command line. */ private static final String NASHORN_ARGS_PROPERTY = "nashorn.args"; /** @@ -419,15 +422,9 @@ public final class Options { */ public void process(final String[] args) { final LinkedList argList = new LinkedList<>(); + addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList); Collections.addAll(argList, args); - - final String extra = getStringProperty(NASHORN_ARGS_PROPERTY, null); - if (extra != null) { - final StringTokenizer st = new StringTokenizer(extra); - while (st.hasMoreTokens()) { - argList.add(st.nextToken()); - } - } + addSystemProperties(NASHORN_ARGS_PROPERTY, argList); while (!argList.isEmpty()) { final String arg = argList.remove(0); @@ -509,6 +506,16 @@ public final class Options { } } + private static void addSystemProperties(final String sysPropName, final List argList) { + final String sysArgs = getStringProperty(sysPropName, null); + if (sysArgs != null) { + final StringTokenizer st = new StringTokenizer(sysArgs); + while (st.hasMoreTokens()) { + argList.add(st.nextToken()); + } + } + } + private static OptionTemplate getOptionTemplate(final String key) { for (final OptionTemplate t : Options.validOptions) { if (t.matches(key)) { diff --git a/nashorn/test/script/basic/JDK-8030182_2.js b/nashorn/test/script/basic/JDK-8030182_2.js index 4c2f5c429f6..9ad8f31bae5 100644 --- a/nashorn/test/script/basic/JDK-8030182_2.js +++ b/nashorn/test/script/basic/JDK-8030182_2.js @@ -41,6 +41,6 @@ str +="g()"; try { eval(str); } catch (e) { - print(e.stack.replace(/\\/g, '/')); + print(e.stack.replace(/\\/g, '/').replace(/@[0-9]+/, '@')); } diff --git a/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED index 090bd1f1ab2..9fdd913f12d 100644 --- a/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED @@ -1,3 +1,3 @@ ReferenceError: "g" is not defined - at (test/script/basic/JDK-8030182_2.js#42:4@1:-1) + at (test/script/basic/JDK-8030182_2.js#42:4@:-1) at (test/script/basic/JDK-8030182_2.js:42) diff --git a/jdk/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.h b/nashorn/test/script/basic/JDK-8051439.js similarity index 63% rename from jdk/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.h rename to nashorn/test/script/basic/JDK-8051439.js index 046eb6758ea..a1f017d1233 100644 --- a/jdk/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.h +++ b/nashorn/test/script/basic/JDK-8051439.js @@ -1,43 +1,52 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * This code is free software; you can redistribute it and/or modify it * 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. - * + * 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-8051439: Wrong type calculated for ADD operator with undefined operand + * + * @test + * @run + */ -#import "jni.h" +// Test + operator +function f1() { + var x; + for (var i = 0;i < 3; i++) { + x = x + i; + } + x = x + "test"; + return x; +} -#import "JVMArgs.h" +// Test += operator +function f2() { + var x; + for (var i = 0;i < 3; i++) { + x += i; + } + x += "test"; + return x; +} - -@interface JavaAppLauncher : NSObject { - JVMArgs *args; - JavaVM *jvm; -} - -@property (retain) JVMArgs *args; - -- (void) findAndLoadJVM; -- (void) invokeBundledAppJavaLauncherWithEnv:(JNIEnv *)env; - -@end +print(f1()); +print(f2()); diff --git a/nashorn/test/script/basic/JDK-8051439.js.EXPECTED b/nashorn/test/script/basic/JDK-8051439.js.EXPECTED new file mode 100644 index 00000000000..5c0f70f1b6e --- /dev/null +++ b/nashorn/test/script/basic/JDK-8051439.js.EXPECTED @@ -0,0 +1,2 @@ +NaNtest +NaNtest diff --git a/nashorn/test/script/basic/compile-octane-normal.js b/nashorn/test/script/basic/compile-octane-normal.js new file mode 100644 index 00000000000..c4dd91ed0e3 --- /dev/null +++ b/nashorn/test/script/basic/compile-octane-normal.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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. + */ + +/** + * Make sure that we run with the class cache off to so that every + * run produces compile time and with optimistic type info caching + * and persistent code store off, for the same reasons. These last two + * are currently default, but this is not guaranteed to be the case + * forever, so make this test future safe, we specify them explicitly + * + * @test + * @runif external.octane + * @option -scripting + * @option -Dnashorn.typeInfo.disabled=true + * @option --class-cache-size=0 + * @option --persistent-code-cache=false + */ + +var fn = __DIR__ + 'compile-octane.js'; +var url = "file://" + fn; +loadWithNewGlobal(new java.net.URL(url)); diff --git a/nashorn/test/script/basic/compile-octane-normal.js.EXPECTED b/nashorn/test/script/basic/compile-octane-normal.js.EXPECTED new file mode 100644 index 00000000000..5577bcca0c2 --- /dev/null +++ b/nashorn/test/script/basic/compile-octane-normal.js.EXPECTED @@ -0,0 +1,30 @@ +Compiling 'box2d'... +Done. +Compiling 'code-load'... +Done. +Compiling 'crypto'... +Done. +Compiling 'deltablue'... +Done. +Compiling 'earley-boyer'... +Done. +Compiling 'gbemu'... (2 files) +Done. +Compiling 'mandreel'... +Done. +Compiling 'navier-stokes'... +Done. +Compiling 'pdfjs'... +Done. +Compiling 'raytrace'... +Done. +Compiling 'regexp'... +Done. +Compiling 'richards'... +Done. +Compiling 'splay'... +Done. +Compiling 'typescript'... (3 files) +Done. +Compiling 'zlib'... (2 files) +Done. diff --git a/nashorn/test/script/basic/compile-octane-splitter.js b/nashorn/test/script/basic/compile-octane-splitter.js index d1256398faf..2bba0e3f4f0 100644 --- a/nashorn/test/script/basic/compile-octane-splitter.js +++ b/nashorn/test/script/basic/compile-octane-splitter.js @@ -22,12 +22,22 @@ */ /** + * Make sure that we run with the class cache off to so that every + * run produces compile time and with optimistic type info caching + * and persistent code store off, for the same reasons. These last two + * are currently default, but this is not guaranteed to be the case + * forever, so make this test future safe, we specify them explicitly + * * @test * @option -Dnashorn.compiler.splitter.threshold=1000 * @fork * @runif external.octane * @option -scripting + * @option -Dnashorn.typeInfo.disabled=true + * @option --class-cache-size=0 + * @option --persistent-code-cache=false */ -compile_only = true; -load(__DIR__ + 'run-octane.js'); +var fn = __DIR__ + 'compile-octane.js'; +var url = "file://" + fn; +loadWithNewGlobal(new java.net.URL(url)); diff --git a/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED b/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED index 565866d0e17..5577bcca0c2 100644 --- a/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED +++ b/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED @@ -1,15 +1,30 @@ -[box2d] Compiled OK -[code-load] Compiled OK -[crypto] Compiled OK -[deltablue] Compiled OK -[earley-boyer] Compiled OK -[gbemu] Compiled OK -[mandreel] Compiled OK -[navier-stokes] Compiled OK -[pdfjs] Compiled OK -[raytrace] Compiled OK -[regexp] Compiled OK -[richards] Compiled OK -[splay] Compiled OK -[typescript] Compiled OK -[zlib] Compiled OK +Compiling 'box2d'... +Done. +Compiling 'code-load'... +Done. +Compiling 'crypto'... +Done. +Compiling 'deltablue'... +Done. +Compiling 'earley-boyer'... +Done. +Compiling 'gbemu'... (2 files) +Done. +Compiling 'mandreel'... +Done. +Compiling 'navier-stokes'... +Done. +Compiling 'pdfjs'... +Done. +Compiling 'raytrace'... +Done. +Compiling 'regexp'... +Done. +Compiling 'richards'... +Done. +Compiling 'splay'... +Done. +Compiling 'typescript'... (3 files) +Done. +Compiling 'zlib'... (2 files) +Done. diff --git a/nashorn/test/script/basic/compile-octane.js b/nashorn/test/script/basic/compile-octane.js index ef37c536295..7d019bbece4 100644 --- a/nashorn/test/script/basic/compile-octane.js +++ b/nashorn/test/script/basic/compile-octane.js @@ -22,10 +22,122 @@ */ /** - * @test - * @runif external.octane - * @option -scripting + * Make sure that we run with the class cache off to so that every + * run produces compile time and with optimistic type info caching + * and persistent code store off, for the same reasons. These last two + * are currently default, but this is not guaranteed to be the case + * forever, so make this test future safe, we specify them explicitly + * + * This means that if you use this subtest as a compilation test + * harness, pass the arguments: + * + * -scripting -Dnashorn.typeInfo.disabled=true --class-cache-size=0 + * --persistent-code-cache=false + * + * @subtest */ -compile_only = true; -load(__DIR__ + 'run-octane.js'); +load(__DIR__ + 'octane-payload.js'); + +var DEFAULT_ITERS = 1; //default is one iteration through each benchmark +var iters = DEFAULT_ITERS; +var args = []; + +if (typeof $ARGS !== 'undefined') { + args = $ARGS; +} else if (typeof arguments !== 'undefined' && arguments.length != 0) { + args = arguments; +} + +var onlyTheseTests = []; +var verbose = false; + +for (var i = 0; i < args.length; ) { + var arg = args[i]; + if (arg === '--iterations') { + iters = +args[++i]; + } else if (arg === '--verbose') { + verbose = true; + } else { + onlyTheseTests.push(arg); + } + i++; +} + +if (isNaN(iters)) { + iters = DEFAULT_ITERS; +} + +if (iters != DEFAULT_ITERS) { + print("Running " + iters + " iterations of each compilation."); +} + +function print_if_verbose(x) { + if (verbose) { + print(x); + } +} + +function contains(a, obj) { + for (var i = 0; i < a.length; i++) { + if (a[i] === obj) { + return true; + } + } + return false; +} + +var testsCompiled = []; + +for (var j in tests) { + var test_name = tests[j].name; + var files = tests[j].files; + + if (onlyTheseTests.length > 0 && !contains(onlyTheseTests, test_name)) { + print_if_verbose("Skipping " + test_name); + continue; + } + + if (!contains(testsCompiled, test_name)) { + testsCompiled.push(test_name); + } + + var str = "Compiling '" + test_name + "'..."; + if (files.length > 1) { + str += " (" + files.length + " files)"; + } + if (iters != 1) { + str += " (" + iters + " times)"; + } + str + "..."; + print(str); + + for (var iteration = 0; iteration < iters; iteration++) { + + //get a new global to avoid symbol pollution and reloads of base + //in the same namespace + var newGlobal = loadWithNewGlobal({script:'this', name:'test'}); + + //load base into the new global so we get BenchmarkSuite etc + newGlobal.load(base); + + //load all files in the single benchmark + for (var k in files) { + var file = files[k]; + if (iteration >= 0) { //only display message on first iteration + var str2 = "\t"; + if (iters > 1) { + str2 += " [iteration " + (iteration + 1) + "]"; + } + str2 += " processing file: " + file + "..."; + print_if_verbose(str2); + } + newGlobal.load("file://" + path + file); + } + } + print("Done."); +} + +if (testsCompiled.length == 0) { + print("Error: no tests given to compile"); +} diff --git a/nashorn/test/script/basic/compile-octane.js.EXPECTED b/nashorn/test/script/basic/compile-octane.js.EXPECTED deleted file mode 100644 index 565866d0e17..00000000000 --- a/nashorn/test/script/basic/compile-octane.js.EXPECTED +++ /dev/null @@ -1,15 +0,0 @@ -[box2d] Compiled OK -[code-load] Compiled OK -[crypto] Compiled OK -[deltablue] Compiled OK -[earley-boyer] Compiled OK -[gbemu] Compiled OK -[mandreel] Compiled OK -[navier-stokes] Compiled OK -[pdfjs] Compiled OK -[raytrace] Compiled OK -[regexp] Compiled OK -[richards] Compiled OK -[splay] Compiled OK -[typescript] Compiled OK -[zlib] Compiled OK diff --git a/nashorn/test/script/basic/hideLocationProperties.js b/nashorn/test/script/basic/hideLocationProperties.js index 66041dccfaa..62c1ec06322 100644 --- a/nashorn/test/script/basic/hideLocationProperties.js +++ b/nashorn/test/script/basic/hideLocationProperties.js @@ -46,7 +46,7 @@ function z(__FILE__) { (function() { print(__FILE__) })() } -print(__FILE__) +print(__FILE__.replace(/\\/g, "/")) var o = { __FILE__: "woot" } with(o) { print(__FILE__) } diff --git a/nashorn/test/script/basic/octane-payload.js b/nashorn/test/script/basic/octane-payload.js new file mode 100644 index 00000000000..36c780d768f --- /dev/null +++ b/nashorn/test/script/basic/octane-payload.js @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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. + */ + +/** + * @subtest + */ + +function initZlib() { + zlib = new BenchmarkSuite('zlib', [152815148], [ + new Benchmark('zlib', false, true, 10, + runZlib, undefined, tearDownZlib, null, 3)]); +} + +var tests = [ + {name:"box2d", files:["box2d.js"], suite:"Box2DBenchmark"}, + {name:"code-load", files:["code-load.js"], suite:"CodeLoad"}, + {name:"crypto", files:["crypto.js"], suite:"Crypto"}, + {name:"deltablue", files:["deltablue.js"], suite:"DeltaBlue"}, + {name:"earley-boyer", files:["earley-boyer.js"], suite:"EarleyBoyer"}, + {name:"gbemu", files:["gbemu-part1.js", "gbemu-part2.js"], suite:"GameboyBenchmark"}, + {name:"mandreel", files:["mandreel.js"], suite:"MandreelBenchmark"}, + {name:"navier-stokes", files:["navier-stokes.js"], suite:"NavierStokes"}, + {name:"pdfjs", files:["pdfjs.js"], suite:"PdfJS"}, + {name:"raytrace", files:["raytrace.js"], suite:"RayTrace"}, + {name:"regexp", files:["regexp.js"], suite:"RegExpSuite"}, + {name:"richards", files:["richards.js"], suite:"Richards"}, + {name:"splay", files:["splay.js"], suite:"Splay"}, + {name:"typescript", files:["typescript.js", "typescript-input.js", "typescript-compiler.js"], suite:"typescript"}, + //zlib currently disabled - requires read + {name:"zlib", files:["zlib.js", "zlib-data.js"], suite:"zlib", before:initZlib} +]; + +var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; + +// TODO: why is this path hard coded when it's defined in project properties? +var path = dir + "../external/octane/"; +var base = path + "base.js"; + diff --git a/nashorn/test/script/basic/optimistic_arithmetic_check_type.js b/nashorn/test/script/basic/optimistic_arithmetic_check_type.js index 66b1e361508..62ff301d0f0 100644 --- a/nashorn/test/script/basic/optimistic_arithmetic_check_type.js +++ b/nashorn/test/script/basic/optimistic_arithmetic_check_type.js @@ -25,6 +25,7 @@ * @test * @bug 8036987, 8037572 * @summary Implement tests that checks static types in the compiled code + * @option --optimistic-types=true * @run */ diff --git a/nashorn/test/script/basic/optimistic_assignment_check_type.js b/nashorn/test/script/basic/optimistic_assignment_check_type.js index 2665c18d9ba..7ead00d8448 100644 --- a/nashorn/test/script/basic/optimistic_assignment_check_type.js +++ b/nashorn/test/script/basic/optimistic_assignment_check_type.js @@ -25,6 +25,7 @@ * @test * @bug 8036987, 8037572 * @summary Implement tests that checks static types in the compiled code + * @option --optimistic-types=true * @run */ diff --git a/nashorn/test/script/basic/optimistic_check_type.js b/nashorn/test/script/basic/optimistic_check_type.js index 163244e817b..d2b50a4c3fb 100644 --- a/nashorn/test/script/basic/optimistic_check_type.js +++ b/nashorn/test/script/basic/optimistic_check_type.js @@ -25,6 +25,7 @@ * @test * @bug 8036987, 8037572 * @summary Implement tests that checks static types in the compiled code + * @option --optimistic-types=true * @run */ diff --git a/nashorn/test/script/basic/run-octane.js b/nashorn/test/script/basic/run-octane.js index 92f71110614..0c666f2f12c 100644 --- a/nashorn/test/script/basic/run-octane.js +++ b/nashorn/test/script/basic/run-octane.js @@ -24,36 +24,8 @@ /** * @subtest */ - - -function initZlib() { - zlib = new BenchmarkSuite('zlib', [152815148], [ - new Benchmark('zlib', false, true, 10, - runZlib, undefined, tearDownZlib, null, 3)]); -} - -var tests = [ - {name:"box2d", files:["box2d.js"], suite:"Box2DBenchmark"}, - {name:"code-load", files:["code-load.js"], suite:"CodeLoad"}, - {name:"crypto", files:["crypto.js"], suite:"Crypto"}, - {name:"deltablue", files:["deltablue.js"], suite:"DeltaBlue"}, - {name:"earley-boyer", files:["earley-boyer.js"], suite:"EarleyBoyer"}, - {name:"gbemu", files:["gbemu-part1.js", "gbemu-part2.js"], suite:"GameboyBenchmark"}, - {name:"mandreel", files:["mandreel.js"], suite:"MandreelBenchmark"}, - {name:"navier-stokes", files:["navier-stokes.js"], suite:"NavierStokes"}, - {name:"pdfjs", files:["pdfjs.js"], suite:"PdfJS"}, - {name:"raytrace", files:["raytrace.js"], suite:"RayTrace"}, - {name:"regexp", files:["regexp.js"], suite:"RegExpSuite"}, - {name:"richards", files:["richards.js"], suite:"Richards"}, - {name:"splay", files:["splay.js"], suite:"Splay"}, - {name:"typescript", files:["typescript.js", "typescript-input.js", "typescript-compiler.js"], suite:"typescript"}, - //zlib currently disabled - requires read - {name:"zlib", files:["zlib.js", "zlib-data.js"], suite:"zlib", before:initZlib} -]; -var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; - -// TODO: why is this path hard coded when it's defined in project properties? -var path = dir + "../external/octane/"; +var payload = __DIR__ + "octane-payload.js"; +load(payload); var runtime = undefined; var verbose = false; diff --git a/nashorn/test/script/nosecurity/JDK-8050964.js b/nashorn/test/script/nosecurity/JDK-8050964.js index 35b001f6d84..186d627030d 100644 --- a/nashorn/test/script/nosecurity/JDK-8050964.js +++ b/nashorn/test/script/nosecurity/JDK-8050964.js @@ -46,8 +46,11 @@ if (! nashornJar.isAbsolute()) { nashornJar = new File(".", nashornJar); } +var javahome = System.getProperty("java.home"); +var jdepsPath = javahome + "/../bin/jdeps".replaceAll(/\//g, File.separater); + // run jdep on nashorn.jar - only summary but print profile info -`jdeps -s -P ${nashornJar.absolutePath}` +`${jdepsPath} -s -P ${nashornJar.absolutePath}` // check for "(compact1)" in output from jdep tool if (! /(compact1)/.test($OUT)) { diff --git a/nashorn/test/script/trusted/event_queue.js b/nashorn/test/script/trusted/event_queue.js index 305240eff45..feecc201da5 100644 --- a/nashorn/test/script/trusted/event_queue.js +++ b/nashorn/test/script/trusted/event_queue.js @@ -29,6 +29,7 @@ * @fork * @option -Dnashorn.debug=true * @option --log=recompile:quiet + * @option --optimistic-types=true */ print(Debug); diff --git a/nashorn/test/script/trusted/optimistic_recompilation.js b/nashorn/test/script/trusted/optimistic_recompilation.js index 2435ed510f9..9c9a9c751b0 100644 --- a/nashorn/test/script/trusted/optimistic_recompilation.js +++ b/nashorn/test/script/trusted/optimistic_recompilation.js @@ -28,6 +28,7 @@ * @fork * @option -Dnashorn.debug=true * @option --log=recompile:quiet + * @option --optimistic-types=true */ var forName = java.lang.Class["forName(String)"]; diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index 3beaf274fcf..4b524ef9092 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -607,6 +607,14 @@ public class ScriptEngineTest { assertEquals(res, "hello"); } + // @bug 8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval() + @Test + public void check__DIR__Test() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + e.eval("__DIR__"); + } + // @bug 8050432:javax.script.filename variable should not be enumerable // with nashorn engine's ENGINE_SCOPE bindings @Test diff --git a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java index b48ed8b5c19..bb16cf48caa 100644 --- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java +++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java @@ -39,7 +39,8 @@ import java.io.Reader; public abstract class TestHelper { public static final String TEST_ROOT = "test"; - public static final String BUILD_ROOT = "build/test"; + public static final String BUILD_ROOT = + System.getProperty("build.dir", "build") + File.separator + "test"; public static final String TEST_PREFIX = TEST_ROOT + File.separator; private TestHelper() {